mirror of
https://git.743378673.xyz/MeloNX/MeloNX.git
synced 2025-06-29 11:56:24 +02:00
Add NCE code
This commit is contained in:
parent
a1e34041fa
commit
0970972f0d
40 changed files with 2702 additions and 40 deletions
55
src/Ryujinx.Cpu/Nce/NceNativeInterface.cs
Normal file
55
src/Ryujinx.Cpu/Nce/NceNativeInterface.cs
Normal file
|
@ -0,0 +1,55 @@
|
|||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Ryujinx.Cpu.Nce
|
||||
{
|
||||
static class NceNativeInterface
|
||||
{
|
||||
private delegate ulong GetTickCounterDelegate();
|
||||
private delegate bool SuspendThreadHandlerDelegate();
|
||||
private static GetTickCounterDelegate _getTickCounter;
|
||||
private static SuspendThreadHandlerDelegate _suspendThreadHandler;
|
||||
private static IntPtr _getTickCounterPtr;
|
||||
private static IntPtr _suspendThreadHandlerPtr;
|
||||
|
||||
[ThreadStatic]
|
||||
private static NceExecutionContext _context;
|
||||
|
||||
[ThreadStatic]
|
||||
private static ITickSource _tickSource;
|
||||
|
||||
static NceNativeInterface()
|
||||
{
|
||||
_getTickCounter = GetTickCounter;
|
||||
_suspendThreadHandler = SuspendThreadHandler;
|
||||
_getTickCounterPtr = Marshal.GetFunctionPointerForDelegate(_getTickCounter);
|
||||
_suspendThreadHandlerPtr = Marshal.GetFunctionPointerForDelegate(_suspendThreadHandler);
|
||||
}
|
||||
|
||||
public static void RegisterThread(NceExecutionContext context, ITickSource tickSource)
|
||||
{
|
||||
_context = context;
|
||||
_tickSource = tickSource;
|
||||
}
|
||||
|
||||
public static ulong GetTickCounter()
|
||||
{
|
||||
return _tickSource.Counter;
|
||||
}
|
||||
|
||||
public static bool SuspendThreadHandler()
|
||||
{
|
||||
return _context.OnInterrupt();
|
||||
}
|
||||
|
||||
public static IntPtr GetTickCounterAccessFunctionPointer()
|
||||
{
|
||||
return _getTickCounterPtr;
|
||||
}
|
||||
|
||||
public static IntPtr GetSuspendThreadHandlerFunctionPointer()
|
||||
{
|
||||
return _suspendThreadHandlerPtr;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue