Files
ryujinx-ryubing/src/Ryujinx.HLE/HOS/Kernel/KernelStatic.cs
LotP1 918ec1bde3 cores rework (#505)
This PR changes the core count to be defined in the device instead of
being a const value.
This is mostly a change for future features I want to implement and
should not impact any functionality.
The console will now log the range of cores requested from the
application, and for now, if the requested range is not 0 to 2 (the 3
cores used for application emulation), it will give an error message
which tells the user to contact me on discord. I'm doing this because
I'm interested in finding applications/games that don't use 3 cores and
the error will be removed in the future once I've gotten enough data.
2025-01-09 21:43:18 -06:00

74 lines
1.9 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<uint> capabilities,
int mainThreadPriority,
ThreadStart customThreadStart)
{
KProcess process = new(context);
Result result = process.Initialize(
creationInfo,
capabilities,
context.ResourceLimit,
MemoryRegion.Service,
null,
customThreadStart);
if (result != Result.Success)
{
return result;
}
process.DefaultCpuCore = KScheduler.CpuCoresCount - 1;
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;
}
}
}