aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Horizon/LogManager
diff options
context:
space:
mode:
Diffstat (limited to 'Ryujinx.Horizon/LogManager')
-rw-r--r--Ryujinx.Horizon/LogManager/Ipc/LmLogger.cs (renamed from Ryujinx.Horizon/LogManager/LmLogger.cs)37
-rw-r--r--Ryujinx.Horizon/LogManager/Ipc/LogService.cs (renamed from Ryujinx.Horizon/LogManager/LmLog.cs)11
-rw-r--r--Ryujinx.Horizon/LogManager/LmIpcServer.cs31
-rw-r--r--Ryujinx.Horizon/LogManager/LmMain.cs9
4 files changed, 39 insertions, 49 deletions
diff --git a/Ryujinx.Horizon/LogManager/LmLogger.cs b/Ryujinx.Horizon/LogManager/Ipc/LmLogger.cs
index 461776cd..002a5982 100644
--- a/Ryujinx.Horizon/LogManager/LmLogger.cs
+++ b/Ryujinx.Horizon/LogManager/Ipc/LmLogger.cs
@@ -9,23 +9,23 @@ using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text;
-namespace Ryujinx.Horizon.LogManager
+namespace Ryujinx.Horizon.LogManager.Ipc
{
- partial class LmLogger : IServiceObject
+ partial class LmLogger : ILmLogger
{
- private readonly LmLog _log;
- private readonly ulong _clientProcessId;
+ private readonly LogService _log;
+ private readonly ulong _pid;
- public LmLogger(LmLog log, ulong clientProcessId)
+ public LmLogger(LogService log, ulong pid)
{
_log = log;
- _clientProcessId = clientProcessId;
+ _pid = pid;
}
[CmifCommand(0)]
public Result Log([Buffer(HipcBufferFlags.In | HipcBufferFlags.AutoSelect)] Span<byte> message)
{
- if (!SetProcessId(message, _clientProcessId))
+ if (!SetProcessId(message, _pid))
{
return Result.Success;
}
@@ -35,7 +35,7 @@ namespace Ryujinx.Horizon.LogManager
return Result.Success;
}
- [CmifCommand(1)]
+ [CmifCommand(1)] // 3.0.0+
public Result SetDestination(LogDestination destination)
{
_log.LogDestination = destination;
@@ -48,7 +48,6 @@ namespace Ryujinx.Horizon.LogManager
ref LogPacketHeader header = ref MemoryMarshal.Cast<byte, LogPacketHeader>(message)[0];
uint expectedMessageSize = (uint)Unsafe.SizeOf<LogPacketHeader>() + header.PayloadSize;
-
if (expectedMessageSize != (uint)message.Length)
{
Logger.Warning?.Print(LogClass.ServiceLm, $"Invalid message size (expected 0x{expectedMessageSize:X} but got 0x{message.Length:X}).");
@@ -63,13 +62,11 @@ namespace Ryujinx.Horizon.LogManager
private static string LogImpl(ReadOnlySpan<byte> message)
{
- SpanReader reader = new SpanReader(message);
-
- LogPacketHeader header = reader.Read<LogPacketHeader>();
-
- StringBuilder sb = new StringBuilder();
+ SpanReader reader = new(message);
+ LogPacketHeader header = reader.Read<LogPacketHeader>();
+ StringBuilder builder = new();
- sb.AppendLine($"Guest Log:\n Log level: {header.Severity}");
+ builder.AppendLine($"Guest Log:\n Log level: {header.Severity}");
while (reader.Length > 0)
{
@@ -78,7 +75,7 @@ namespace Ryujinx.Horizon.LogManager
LogDataChunkKey field = (LogDataChunkKey)type;
- string fieldStr = string.Empty;
+ string fieldStr;
if (field == LogDataChunkKey.Start)
{
@@ -111,16 +108,16 @@ namespace Ryujinx.Horizon.LogManager
fieldStr = $"Field{field}: '{Encoding.UTF8.GetString(reader.GetSpan(size)).TrimEnd()}'";
}
- sb.AppendLine($" {fieldStr}");
+ builder.AppendLine($" {fieldStr}");
}
- return sb.ToString();
+ return builder.ToString();
}
private static int ReadUleb128(ref SpanReader reader)
{
int result = 0;
- int count = 0;
+ int count = 0;
byte encoded;
@@ -136,4 +133,4 @@ namespace Ryujinx.Horizon.LogManager
return result;
}
}
-}
+} \ No newline at end of file
diff --git a/Ryujinx.Horizon/LogManager/LmLog.cs b/Ryujinx.Horizon/LogManager/Ipc/LogService.cs
index 772465c4..6899739e 100644
--- a/Ryujinx.Horizon/LogManager/LmLog.cs
+++ b/Ryujinx.Horizon/LogManager/Ipc/LogService.cs
@@ -2,18 +2,19 @@
using Ryujinx.Horizon.Sdk.Lm;
using Ryujinx.Horizon.Sdk.Sf;
-namespace Ryujinx.Horizon.LogManager
+namespace Ryujinx.Horizon.LogManager.Ipc
{
- partial class LmLog : IServiceObject
+ partial class LogService : ILogService
{
public LogDestination LogDestination { get; set; } = LogDestination.TargetManager;
[CmifCommand(0)]
- public Result OpenLogger(out LmLogger logger, [ClientProcessId] ulong clientProcessId)
+ public Result OpenLogger(out LmLogger logger, [ClientProcessId] ulong pid)
{
- logger = new LmLogger(this, clientProcessId);
+ // NOTE: Internal name is Logger, but we rename it LmLogger to avoid name clash with Ryujinx.Common.Logging logger.
+ logger = new LmLogger(this, pid);
return Result.Success;
}
}
-}
+} \ No newline at end of file
diff --git a/Ryujinx.Horizon/LogManager/LmIpcServer.cs b/Ryujinx.Horizon/LogManager/LmIpcServer.cs
index 7b757fe9..71b844a2 100644
--- a/Ryujinx.Horizon/LogManager/LmIpcServer.cs
+++ b/Ryujinx.Horizon/LogManager/LmIpcServer.cs
@@ -1,6 +1,6 @@
-using Ryujinx.Horizon.Sdk.Sf.Hipc;
+using Ryujinx.Horizon.LogManager.Ipc;
+using Ryujinx.Horizon.Sdk.Sf.Hipc;
using Ryujinx.Horizon.Sdk.Sm;
-using Ryujinx.Horizon.Sm;
namespace Ryujinx.Horizon.LogManager
{
@@ -9,36 +9,25 @@ namespace Ryujinx.Horizon.LogManager
private const int LogMaxSessionsCount = 42;
private const int PointerBufferSize = 0x400;
- private const int MaxDomains = 31;
- private const int MaxDomainObjects = 61;
+ private const int MaxDomains = 31;
+ private const int MaxDomainObjects = 61;
+ private const int MaxPortsCount = 1;
- private const int MaxPortsCount = 1;
+ private static readonly ManagerOptions _logManagerOptions = new(PointerBufferSize, MaxDomains, MaxDomainObjects, false);
- private static readonly ManagerOptions _logManagerOptions = new ManagerOptions(
- PointerBufferSize,
- MaxDomains,
- MaxDomainObjects,
- false);
-
- private static readonly ServiceName _logServiceName = ServiceName.Encode("lm");
-
- private SmApi _sm;
+ private SmApi _sm;
private ServerManager _serverManager;
- private LmLog _logServiceObject;
-
public void Initialize()
{
- HeapAllocator allocator = new HeapAllocator();
+ HeapAllocator allocator = new();
_sm = new SmApi();
_sm.Initialize().AbortOnFailure();
_serverManager = new ServerManager(allocator, _sm, MaxPortsCount, _logManagerOptions, LogMaxSessionsCount);
- _logServiceObject = new LmLog();
-
- _serverManager.RegisterObjectForServer(_logServiceObject, _logServiceName, LogMaxSessionsCount);
+ _serverManager.RegisterObjectForServer(new LogService(), ServiceName.Encode("lm"), LogMaxSessionsCount);
}
public void ServiceRequests()
@@ -51,4 +40,4 @@ namespace Ryujinx.Horizon.LogManager
_serverManager.Dispose();
}
}
-}
+} \ No newline at end of file
diff --git a/Ryujinx.Horizon/LogManager/LmMain.cs b/Ryujinx.Horizon/LogManager/LmMain.cs
index 8c0262ac..bbe96d4c 100644
--- a/Ryujinx.Horizon/LogManager/LmMain.cs
+++ b/Ryujinx.Horizon/LogManager/LmMain.cs
@@ -2,13 +2,16 @@
{
class LmMain : IService
{
- public static void Main()
+ public static void Main(ServiceTable serviceTable)
{
- LmIpcServer ipcServer = new LmIpcServer();
+ LmIpcServer ipcServer = new();
ipcServer.Initialize();
+
+ serviceTable.SignalServiceReady();
+
ipcServer.ServiceRequests();
ipcServer.Shutdown();
}
}
-}
+} \ No newline at end of file