aboutsummaryrefslogtreecommitdiff
path: root/src/Ryujinx.HLE/HOS/Services/Pm
diff options
context:
space:
mode:
authorTSR Berry <20988865+TSRBerry@users.noreply.github.com>2023-04-08 01:22:00 +0200
committerMary <thog@protonmail.com>2023-04-27 23:51:14 +0200
commitcee712105850ac3385cd0091a923438167433f9f (patch)
tree4a5274b21d8b7f938c0d0ce18736d3f2993b11b1 /src/Ryujinx.HLE/HOS/Services/Pm
parentcd124bda587ef09668a971fa1cac1c3f0cfc9f21 (diff)
Move solution and projects to src
Diffstat (limited to 'src/Ryujinx.HLE/HOS/Services/Pm')
-rw-r--r--src/Ryujinx.HLE/HOS/Services/Pm/IBootModeInterface.cs8
-rw-r--r--src/Ryujinx.HLE/HOS/Services/Pm/IDebugMonitorInterface.cs49
-rw-r--r--src/Ryujinx.HLE/HOS/Services/Pm/IInformationInterface.cs27
-rw-r--r--src/Ryujinx.HLE/HOS/Services/Pm/IShellInterface.cs21
-rw-r--r--src/Ryujinx.HLE/HOS/Services/Pm/ResultCode.cs17
5 files changed, 122 insertions, 0 deletions
diff --git a/src/Ryujinx.HLE/HOS/Services/Pm/IBootModeInterface.cs b/src/Ryujinx.HLE/HOS/Services/Pm/IBootModeInterface.cs
new file mode 100644
index 00000000..45771db6
--- /dev/null
+++ b/src/Ryujinx.HLE/HOS/Services/Pm/IBootModeInterface.cs
@@ -0,0 +1,8 @@
+namespace Ryujinx.HLE.HOS.Services.Pm
+{
+ [Service("pm:bm")]
+ class IBootModeInterface : IpcService
+ {
+ public IBootModeInterface(ServiceCtx context) { }
+ }
+} \ No newline at end of file
diff --git a/src/Ryujinx.HLE/HOS/Services/Pm/IDebugMonitorInterface.cs b/src/Ryujinx.HLE/HOS/Services/Pm/IDebugMonitorInterface.cs
new file mode 100644
index 00000000..cce2967a
--- /dev/null
+++ b/src/Ryujinx.HLE/HOS/Services/Pm/IDebugMonitorInterface.cs
@@ -0,0 +1,49 @@
+using Ryujinx.HLE.HOS.Ipc;
+using Ryujinx.HLE.HOS.Kernel;
+using Ryujinx.HLE.HOS.Kernel.Process;
+using Ryujinx.Horizon.Common;
+
+namespace Ryujinx.HLE.HOS.Services.Pm
+{
+ [Service("pm:dmnt")]
+ class IDebugMonitorInterface : IpcService
+ {
+ public IDebugMonitorInterface(ServiceCtx context) { }
+
+ [CommandCmif(4)]
+ // GetProgramId() -> sf::Out<ncm::ProgramId> out_process_id
+ public ResultCode GetApplicationProcessId(ServiceCtx context)
+ {
+ // TODO: Not correct as it shouldn't be directly using kernel objects here
+ foreach (KProcess process in context.Device.System.KernelContext.Processes.Values)
+ {
+ if (process.IsApplication)
+ {
+ context.ResponseData.Write(process.Pid);
+
+ return ResultCode.Success;
+ }
+ }
+
+ return ResultCode.ProcessNotFound;
+ }
+
+ [CommandCmif(65000)]
+ // AtmosphereGetProcessInfo(os::ProcessId process_id) -> sf::OutCopyHandle out_process_handle, sf::Out<ncm::ProgramLocation> out_loc, sf::Out<cfg::OverrideStatus> out_status
+ public ResultCode GetProcessInfo(ServiceCtx context)
+ {
+ ulong pid = context.RequestData.ReadUInt64();
+
+ KProcess process = KernelStatic.GetProcessByPid(pid);
+
+ if (context.Process.HandleTable.GenerateHandle(process, out int processHandle) != Result.Success)
+ {
+ throw new System.Exception("Out of handles!");
+ }
+
+ context.Response.HandleDesc = IpcHandleDesc.MakeCopy(processHandle);
+
+ return ResultCode.Success;
+ }
+ }
+} \ No newline at end of file
diff --git a/src/Ryujinx.HLE/HOS/Services/Pm/IInformationInterface.cs b/src/Ryujinx.HLE/HOS/Services/Pm/IInformationInterface.cs
new file mode 100644
index 00000000..b3b5595f
--- /dev/null
+++ b/src/Ryujinx.HLE/HOS/Services/Pm/IInformationInterface.cs
@@ -0,0 +1,27 @@
+using Ryujinx.HLE.HOS.Kernel.Process;
+
+namespace Ryujinx.HLE.HOS.Services.Pm
+{
+ [Service("pm:info")]
+ class IInformationInterface : IpcService
+ {
+ public IInformationInterface(ServiceCtx context) { }
+
+ [CommandCmif(0)]
+ // GetProgramId(os::ProcessId process_id) -> sf::Out<ncm::ProgramId> out
+ public ResultCode GetProgramId(ServiceCtx context)
+ {
+ ulong pid = context.RequestData.ReadUInt64();
+
+ // TODO: Not correct as it shouldn't be directly using kernel objects here
+ if (context.Device.System.KernelContext.Processes.TryGetValue(pid, out KProcess process))
+ {
+ context.ResponseData.Write(process.TitleId);
+
+ return ResultCode.Success;
+ }
+
+ return ResultCode.ProcessNotFound;
+ }
+ }
+} \ No newline at end of file
diff --git a/src/Ryujinx.HLE/HOS/Services/Pm/IShellInterface.cs b/src/Ryujinx.HLE/HOS/Services/Pm/IShellInterface.cs
new file mode 100644
index 00000000..96202326
--- /dev/null
+++ b/src/Ryujinx.HLE/HOS/Services/Pm/IShellInterface.cs
@@ -0,0 +1,21 @@
+namespace Ryujinx.HLE.HOS.Services.Pm
+{
+ [Service("pm:shell")]
+ class IShellInterface : IpcService
+ {
+ public IShellInterface(ServiceCtx context) { }
+
+ [CommandCmif(6)]
+ // GetApplicationPid() -> u64
+ public ResultCode GetApplicationPid(ServiceCtx context)
+ {
+ // FIXME: This is wrong but needed to make hb loader works
+ // TODO: Change this when we will have a way to process via a PM like interface.
+ ulong pid = context.Process.Pid;
+
+ context.ResponseData.Write(pid);
+
+ return ResultCode.Success;
+ }
+ }
+}
diff --git a/src/Ryujinx.HLE/HOS/Services/Pm/ResultCode.cs b/src/Ryujinx.HLE/HOS/Services/Pm/ResultCode.cs
new file mode 100644
index 00000000..92b5925e
--- /dev/null
+++ b/src/Ryujinx.HLE/HOS/Services/Pm/ResultCode.cs
@@ -0,0 +1,17 @@
+namespace Ryujinx.HLE.HOS.Services.Pm
+{
+ enum ResultCode
+ {
+ ModuleId = 15,
+ ErrorCodeShift = 9,
+
+ Success = 0,
+
+ ProcessNotFound = (1 << ErrorCodeShift) | ModuleId,
+ AlreadyStarted = (2 << ErrorCodeShift) | ModuleId,
+ NotTerminated = (3 << ErrorCodeShift) | ModuleId,
+ DebugHookInUse = (4 << ErrorCodeShift) | ModuleId,
+ ApplicationRunning = (5 << ErrorCodeShift) | ModuleId,
+ InvalidSize = (6 << ErrorCodeShift) | ModuleId,
+ }
+} \ No newline at end of file