JinxRyu/Ryujinx.HLE/HOS/Kernel/KernelStatic.cs
Isaac Marovitz 139a930407
Implement missing service calls in pm (#4210)
* Implement `GetTitleId`

Fixes #2516

* Null check + Proper result code

* Better comment

* Implement `GetApplicationProcessId`

* Add TODOs

* Update Ryujinx.HLE/HOS/Services/Pm/IInformationInterface.cs

Co-authored-by: Ac_K <Acoustik666@gmail.com>

* Update Ryujinx.HLE/HOS/Services/Pm/IDebugMonitorInterface.cs

Co-authored-by: Ac_K <Acoustik666@gmail.com>

* Remove new function from KernelStatic

Co-authored-by: Ac_K <Acoustik666@gmail.com>
2023-01-15 22:16:24 +01:00

73 lines
No EOL
1.8 KiB
C#

using Ryujinx.HLE.HOS.Kernel.Memory;
using Ryujinx.HLE.HOS.Kernel.Process;
using Ryujinx.HLE.HOS.Kernel.Threading;
using Ryujinx.Horizon.Common;
using System;
using System.Threading;
namespace Ryujinx.HLE.HOS.Kernel
{
static class KernelStatic
{
[ThreadStatic]
private static KernelContext Context;
[ThreadStatic]
private static KThread CurrentThread;
public static Result StartInitialProcess(
KernelContext context,
ProcessCreationInfo creationInfo,
ReadOnlySpan<int> capabilities,
int mainThreadPriority,
ThreadStart customThreadStart)
{
KProcess process = new KProcess(context);
Result result = process.Initialize(
creationInfo,
capabilities,
context.ResourceLimit,
MemoryRegion.Service,
null,
customThreadStart);
if (result != Result.Success)
{
return result;
}
process.DefaultCpuCore = 3;
context.Processes.TryAdd(process.Pid, process);
return process.Start(mainThreadPriority, 0x1000UL);
}
internal static void SetKernelContext(KernelContext context, KThread thread)
{
Context = context;
CurrentThread = thread;
}
internal static KThread GetCurrentThread()
{
return CurrentThread;
}
internal static KProcess GetCurrentProcess()
{
return GetCurrentThread().Owner;
}
internal static KProcess GetProcessByPid(ulong pid)
{
if (Context.Processes.TryGetValue(pid, out KProcess process))
{
return process;
}
return null;
}
}
}