summaryrefslogtreecommitdiffstats
path: root/src/core/hle/service/lm/manager.h
diff options
context:
space:
mode:
authorZach Hilman <zachhilman@gmail.com>2019-06-29 23:18:07 +0200
committerZach Hilman <zachhilman@gmail.com>2019-09-22 18:34:55 +0200
commitef9a7fa1f5e593bf6cd49aab2ee371b7ca84512e (patch)
tree86afb16448acf822ab4a1e2fe0c71c7a6866e41d /src/core/hle/service/lm/manager.h
parentcore: Add LM::Manager to system (diff)
downloadyuzu-ef9a7fa1f5e593bf6cd49aab2ee371b7ca84512e.tar
yuzu-ef9a7fa1f5e593bf6cd49aab2ee371b7ca84512e.tar.gz
yuzu-ef9a7fa1f5e593bf6cd49aab2ee371b7ca84512e.tar.bz2
yuzu-ef9a7fa1f5e593bf6cd49aab2ee371b7ca84512e.tar.lz
yuzu-ef9a7fa1f5e593bf6cd49aab2ee371b7ca84512e.tar.xz
yuzu-ef9a7fa1f5e593bf6cd49aab2ee371b7ca84512e.tar.zst
yuzu-ef9a7fa1f5e593bf6cd49aab2ee371b7ca84512e.zip
Diffstat (limited to 'src/core/hle/service/lm/manager.h')
-rw-r--r--src/core/hle/service/lm/manager.h104
1 files changed, 104 insertions, 0 deletions
diff --git a/src/core/hle/service/lm/manager.h b/src/core/hle/service/lm/manager.h
new file mode 100644
index 000000000..af0a27257
--- /dev/null
+++ b/src/core/hle/service/lm/manager.h
@@ -0,0 +1,104 @@
+// Copyright 2019 yuzu emulator team
+// Licensed under GPLv2 or any later version
+// Refer to the license.txt file included.
+
+#pragma once
+
+#include <map>
+#include <ostream>
+#include <vector>
+#include "common/bit_field.h"
+#include "common/common_types.h"
+#include "common/swap.h"
+
+namespace Core {
+class Reporter;
+}
+
+namespace Service::LM {
+
+enum class DestinationFlag : u32 {
+ Default = 1,
+ UART = 2,
+ UARTSleeping = 4,
+
+ All = 0xFFFF,
+};
+
+struct MessageHeader {
+ enum Flags : u32_le {
+ IsHead = 1,
+ IsTail = 2,
+ };
+ enum Severity : u32_le {
+ Trace,
+ Info,
+ Warning,
+ Error,
+ Critical,
+ };
+
+ u64_le pid;
+ u64_le thread_context;
+ union {
+ BitField<0, 16, Flags> flags;
+ BitField<16, 8, Severity> severity;
+ BitField<24, 8, u32> verbosity;
+ };
+ u32_le payload_size;
+
+ bool IsHeadLog() const {
+ return flags & IsHead;
+ }
+ bool IsTailLog() const {
+ return flags & IsTail;
+ }
+};
+static_assert(sizeof(MessageHeader) == 0x18, "MessageHeader is incorrect size");
+
+enum class Field : u8 {
+ Skip = 1,
+ Message = 2,
+ Line = 3,
+ Filename = 4,
+ Function = 5,
+ Module = 6,
+ Thread = 7,
+};
+
+std::ostream& operator<<(std::ostream& os, DestinationFlag dest);
+std::ostream& operator<<(std::ostream& os, MessageHeader::Severity severity);
+std::ostream& operator<<(std::ostream& os, Field field);
+
+using FieldMap = std::map<Field, std::vector<u8>>;
+
+struct LogMessage {
+ MessageHeader header;
+ FieldMap fields;
+};
+
+std::string FormatField(Field type, const std::vector<u8>& data);
+
+class Manager {
+public:
+ Manager(Core::Reporter& reporter);
+ ~Manager();
+
+ void SetEnabled(bool enabled);
+ void SetDestination(DestinationFlag destination);
+
+ void Log(LogMessage message);
+
+private:
+ void InitializeLog();
+ void FinalizeLog();
+
+ bool enabled = true;
+ DestinationFlag destination = DestinationFlag::All;
+
+ std::vector<LogMessage> current_log;
+
+ Core::Reporter& reporter;
+};
+
+} // namespace Service::LM