aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.HLE
diff options
context:
space:
mode:
Diffstat (limited to 'Ryujinx.HLE')
-rw-r--r--Ryujinx.HLE/DeviceMemory.cs2
-rw-r--r--Ryujinx.HLE/Exceptions/UndefinedInstructionException.cs2
-rw-r--r--Ryujinx.HLE/HOS/Homebrew.cs8
-rw-r--r--Ryujinx.HLE/HOS/Horizon.cs2
-rw-r--r--Ryujinx.HLE/HOS/Ipc/IpcHandler.cs4
-rw-r--r--Ryujinx.HLE/HOS/Kernel/Common/KernelTransfer.cs2
-rw-r--r--Ryujinx.HLE/HOS/Kernel/Memory/KMemoryManager.cs6
-rw-r--r--Ryujinx.HLE/HOS/Kernel/Process/HleProcessDebugger.cs12
-rw-r--r--Ryujinx.HLE/HOS/Kernel/Process/KProcess.cs46
-rw-r--r--Ryujinx.HLE/HOS/Kernel/SupervisorCall/SvcHandler.cs15
-rw-r--r--Ryujinx.HLE/HOS/Kernel/SupervisorCall/SvcIpc.cs2
-rw-r--r--Ryujinx.HLE/HOS/Kernel/SupervisorCall/SvcSystem.cs4
-rw-r--r--Ryujinx.HLE/HOS/Kernel/SupervisorCall/SvcTable.cs59
-rw-r--r--Ryujinx.HLE/HOS/Kernel/SupervisorCall/SvcThread.cs155
-rw-r--r--Ryujinx.HLE/HOS/Kernel/Threading/HleScheduler.cs18
-rw-r--r--Ryujinx.HLE/HOS/Kernel/Threading/KCoreContext.cs6
-rw-r--r--Ryujinx.HLE/HOS/Kernel/Threading/KCriticalSection.cs10
-rw-r--r--Ryujinx.HLE/HOS/Kernel/Threading/KScheduler.cs2
-rw-r--r--Ryujinx.HLE/HOS/Kernel/Threading/KThread.cs64
-rw-r--r--Ryujinx.HLE/HOS/ProgramLoader.cs2
-rw-r--r--Ryujinx.HLE/HOS/ServiceCtx.cs6
-rw-r--r--Ryujinx.HLE/HOS/Services/Acc/IProfile.cs2
-rw-r--r--Ryujinx.HLE/HOS/Services/Aud/AudioOut/IAudioOut.cs2
-rw-r--r--Ryujinx.HLE/HOS/Services/Aud/AudioRenderer/IAudioRenderer.cs6
-rw-r--r--Ryujinx.HLE/HOS/Services/Aud/AudioRenderer/VoiceContext.cs6
-rw-r--r--Ryujinx.HLE/HOS/Services/Aud/IAudioOutManager.cs2
-rw-r--r--Ryujinx.HLE/HOS/Services/Ldr/IRoInterface.cs2
-rw-r--r--Ryujinx.HLE/HOS/Services/Nv/INvDrvServices.cs2
-rw-r--r--Ryujinx.HLE/HOS/Services/Nv/NvGpuAS/NvGpuASIoctl.cs2
-rw-r--r--Ryujinx.HLE/HOS/Services/Nv/NvGpuGpu/NvGpuGpuIoctl.cs2
-rw-r--r--Ryujinx.HLE/HOS/Services/Nv/NvHostChannel/NvHostChannelIoctl.cs2
-rw-r--r--Ryujinx.HLE/HOS/Services/Nv/NvHostCtrl/NvHostCtrlIoctl.cs2
-rw-r--r--Ryujinx.HLE/HOS/Services/Nv/NvMap/NvMapIoctl.cs2
-rw-r--r--Ryujinx.HLE/HOS/Services/Time/Clock/StandardSteadyClockCore.cs2
-rw-r--r--Ryujinx.HLE/HOS/Services/Time/Clock/TickBasedSteadyClockCore.cs2
-rw-r--r--Ryujinx.HLE/HOS/Services/Time/IStaticService.cs2
-rw-r--r--Ryujinx.HLE/HOS/Services/Time/ITimeZoneService.cs4
-rw-r--r--Ryujinx.HLE/HOS/Services/Vi/IApplicationDisplayService.cs2
-rw-r--r--Ryujinx.HLE/Ryujinx.HLE.csproj6
-rw-r--r--Ryujinx.HLE/Utilities/StructReader.cs6
-rw-r--r--Ryujinx.HLE/Utilities/StructWriter.cs6
41 files changed, 266 insertions, 223 deletions
diff --git a/Ryujinx.HLE/DeviceMemory.cs b/Ryujinx.HLE/DeviceMemory.cs
index 3553a6e7..0ead1747 100644
--- a/Ryujinx.HLE/DeviceMemory.cs
+++ b/Ryujinx.HLE/DeviceMemory.cs
@@ -1,4 +1,4 @@
-using ChocolArm64.Memory;
+using ARMeilleure.Memory;
using System;
using System.Runtime.InteropServices;
diff --git a/Ryujinx.HLE/Exceptions/UndefinedInstructionException.cs b/Ryujinx.HLE/Exceptions/UndefinedInstructionException.cs
index 84bb1fc5..dfbd6c27 100644
--- a/Ryujinx.HLE/Exceptions/UndefinedInstructionException.cs
+++ b/Ryujinx.HLE/Exceptions/UndefinedInstructionException.cs
@@ -8,6 +8,6 @@ namespace Ryujinx.HLE.Exceptions
public UndefinedInstructionException() : base() { }
- public UndefinedInstructionException(long position, int opCode) : base(string.Format(ExMsg, position, opCode)) { }
+ public UndefinedInstructionException(ulong address, int opCode) : base(string.Format(ExMsg, address, opCode)) { }
}
} \ No newline at end of file
diff --git a/Ryujinx.HLE/HOS/Homebrew.cs b/Ryujinx.HLE/HOS/Homebrew.cs
index b11a4640..8e54f82c 100644
--- a/Ryujinx.HLE/HOS/Homebrew.cs
+++ b/Ryujinx.HLE/HOS/Homebrew.cs
@@ -1,4 +1,4 @@
-using ChocolArm64.Memory;
+using ARMeilleure.Memory;
using System.Text;
namespace Ryujinx.HLE.HOS
@@ -8,7 +8,7 @@ namespace Ryujinx.HLE.HOS
public const string TemporaryNroSuffix = ".ryu_tmp.nro";
// http://switchbrew.org/index.php?title=Homebrew_ABI
- public static void WriteHbAbiData(MemoryManager memory, long position, int mainThreadHandle, string switchPath)
+ public static void WriteHbAbiData(IMemoryManager memory, long position, int mainThreadHandle, string switchPath)
{
// MainThreadHandle.
WriteConfigEntry(memory, ref position, 1, 0, mainThreadHandle);
@@ -31,7 +31,7 @@ namespace Ryujinx.HLE.HOS
}
private static void WriteConfigEntry(
- MemoryManager memory,
+ IMemoryManager memory,
ref long position,
int key,
int flags = 0,
@@ -46,7 +46,7 @@ namespace Ryujinx.HLE.HOS
position += 0x18;
}
- public static string ReadHbAbiNextLoadPath(MemoryManager memory, long position)
+ public static string ReadHbAbiNextLoadPath(IMemoryManager memory, long position)
{
string fileName = null;
diff --git a/Ryujinx.HLE/HOS/Horizon.cs b/Ryujinx.HLE/HOS/Horizon.cs
index f8bb345f..5873223e 100644
--- a/Ryujinx.HLE/HOS/Horizon.cs
+++ b/Ryujinx.HLE/HOS/Horizon.cs
@@ -110,6 +110,8 @@ namespace Ryujinx.HLE.HOS
public int GlobalAccessLogMode { get; set; }
+ public bool UseLegacyJit { get; set; }
+
internal long HidBaseAddress { get; private set; }
public Horizon(Switch device)
diff --git a/Ryujinx.HLE/HOS/Ipc/IpcHandler.cs b/Ryujinx.HLE/HOS/Ipc/IpcHandler.cs
index e940d774..50ab3d10 100644
--- a/Ryujinx.HLE/HOS/Ipc/IpcHandler.cs
+++ b/Ryujinx.HLE/HOS/Ipc/IpcHandler.cs
@@ -1,4 +1,4 @@
-using ChocolArm64.Memory;
+using ARMeilleure.Memory;
using Ryujinx.HLE.HOS.Kernel.Common;
using Ryujinx.HLE.HOS.Kernel.Ipc;
using Ryujinx.HLE.HOS.Kernel.Process;
@@ -13,7 +13,7 @@ namespace Ryujinx.HLE.HOS.Ipc
public static KernelResult IpcCall(
Switch device,
KProcess process,
- MemoryManager memory,
+ IMemoryManager memory,
KThread thread,
KClientSession session,
IpcMessage request,
diff --git a/Ryujinx.HLE/HOS/Kernel/Common/KernelTransfer.cs b/Ryujinx.HLE/HOS/Kernel/Common/KernelTransfer.cs
index 0fcb3148..62330d6b 100644
--- a/Ryujinx.HLE/HOS/Kernel/Common/KernelTransfer.cs
+++ b/Ryujinx.HLE/HOS/Kernel/Common/KernelTransfer.cs
@@ -1,5 +1,5 @@
using Ryujinx.HLE.HOS.Kernel.Process;
-using ChocolArm64.Memory;
+using ARMeilleure.Memory;
namespace Ryujinx.HLE.HOS.Kernel.Common
{
diff --git a/Ryujinx.HLE/HOS/Kernel/Memory/KMemoryManager.cs b/Ryujinx.HLE/HOS/Kernel/Memory/KMemoryManager.cs
index 448ae54c..fd80b3b9 100644
--- a/Ryujinx.HLE/HOS/Kernel/Memory/KMemoryManager.cs
+++ b/Ryujinx.HLE/HOS/Kernel/Memory/KMemoryManager.cs
@@ -1,4 +1,4 @@
-using ChocolArm64.Memory;
+using ARMeilleure.Memory;
using Ryujinx.Common;
using Ryujinx.HLE.HOS.Kernel.Common;
using Ryujinx.HLE.HOS.Kernel.Process;
@@ -29,7 +29,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
private LinkedList<KMemoryBlock> _blocks;
- private MemoryManager _cpuMemory;
+ private IMemoryManager _cpuMemory;
private Horizon _system;
@@ -72,7 +72,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
private MersenneTwister _randomNumberGenerator;
- public KMemoryManager(Horizon system, MemoryManager cpuMemory)
+ public KMemoryManager(Horizon system, IMemoryManager cpuMemory)
{
_system = system;
_cpuMemory = cpuMemory;
diff --git a/Ryujinx.HLE/HOS/Kernel/Process/HleProcessDebugger.cs b/Ryujinx.HLE/HOS/Kernel/Process/HleProcessDebugger.cs
index 223bf5da..e2ca44b5 100644
--- a/Ryujinx.HLE/HOS/Kernel/Process/HleProcessDebugger.cs
+++ b/Ryujinx.HLE/HOS/Kernel/Process/HleProcessDebugger.cs
@@ -1,5 +1,5 @@
-using ChocolArm64.Memory;
-using ChocolArm64.State;
+using ARMeilleure.Memory;
+using ARMeilleure.State;
using Ryujinx.HLE.HOS.Diagnostics.Demangler;
using Ryujinx.HLE.HOS.Kernel.Memory;
using Ryujinx.HLE.Loaders.Elf;
@@ -40,7 +40,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
_images = new List<Image>();
}
- public string GetGuestStackTrace(CpuThreadState threadState)
+ public string GetGuestStackTrace(IExecutionContext context)
{
EnsureLoaded();
@@ -74,7 +74,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
}
// TODO: ARM32.
- long framePointer = (long)threadState.X29;
+ long framePointer = (long)context.GetX(29);
trace.AppendLine($"Process: {_owner.Name}, PID: {_owner.Pid}");
@@ -218,7 +218,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
}
}
- private void LoadMod0Symbols(MemoryManager memory, long textOffset)
+ private void LoadMod0Symbols(IMemoryManager memory, long textOffset)
{
long mod0Offset = textOffset + memory.ReadUInt32(textOffset + 4);
@@ -288,7 +288,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
}
}
- private ElfSymbol GetSymbol(MemoryManager memory, long address, long strTblAddr)
+ private ElfSymbol GetSymbol(IMemoryManager memory, long address, long strTblAddr)
{
int nameIndex = memory.ReadInt32(address + 0);
int info = memory.ReadByte (address + 4);
diff --git a/Ryujinx.HLE/HOS/Kernel/Process/KProcess.cs b/Ryujinx.HLE/HOS/Kernel/Process/KProcess.cs
index 1b5a6772..beb376f6 100644
--- a/Ryujinx.HLE/HOS/Kernel/Process/KProcess.cs
+++ b/Ryujinx.HLE/HOS/Kernel/Process/KProcess.cs
@@ -1,9 +1,7 @@
-using ChocolArm64;
-using ChocolArm64.Events;
-using ChocolArm64.Memory;
-using ChocolArm64.Translation;
+using ARMeilleure.Memory;
+using ARMeilleure.State;
+using ARMeilleure.Translation;
using Ryujinx.Common;
-using Ryujinx.Common.Logging;
using Ryujinx.HLE.Exceptions;
using Ryujinx.HLE.HOS.Kernel.Common;
using Ryujinx.HLE.HOS.Kernel.Memory;
@@ -80,9 +78,9 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
public bool IsPaused { get; private set; }
- public MemoryManager CpuMemory { get; private set; }
+ public IMemoryManager CpuMemory { get; private set; }
- public Translator Translator { get; private set; }
+ public ITranslator Translator { get; private set; }
private SvcHandler _svcHandler;
@@ -793,11 +791,11 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
}
}
- public void SubscribeThreadEventHandlers(CpuThread context)
+ public void SubscribeThreadEventHandlers(IExecutionContext context)
{
- context.ThreadState.Interrupt += InterruptHandler;
- context.ThreadState.SvcCall += _svcHandler.SvcCall;
- context.ThreadState.Undefined += UndefinedInstructionHandler;
+ context.Interrupt += InterruptHandler;
+ context.SupervisorCall += _svcHandler.SvcCall;
+ context.Undefined += UndefinedInstructionHandler;
}
private void InterruptHandler(object sender, EventArgs e)
@@ -1001,9 +999,9 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
{
foreach (KThread thread in _threads)
{
- thread.Context.StopExecution();
+ thread.Context.Running = false;
- System.Scheduler.CoreManager.Set(thread.Context.Work);
+ System.Scheduler.CoreManager.Set(thread.HostThread);
}
}
}
@@ -1024,13 +1022,20 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
bool useFlatPageTable = memRegion == MemoryRegion.Application;
- CpuMemory = new MemoryManager(_system.Device.Memory.RamPointer, addrSpaceBits, useFlatPageTable);
+ if (_system.UseLegacyJit)
+ {
+ CpuMemory = new ChocolArm64.Memory.MemoryManager(_system.Device.Memory.RamPointer, addrSpaceBits, useFlatPageTable);
- MemoryManager = new KMemoryManager(_system, CpuMemory);
+ Translator = new ChocolArm64.Translation.Translator((ChocolArm64.Memory.MemoryManager)CpuMemory);
+ }
+ else
+ {
+ CpuMemory = new MemoryManager(_system.Device.Memory.RamPointer, addrSpaceBits, useFlatPageTable);
- Translator = new Translator(CpuMemory);
+ Translator = new Translator((MemoryManager)CpuMemory);
+ }
- Translator.CpuTrace += CpuTraceHandler;
+ MemoryManager = new KMemoryManager(_system, CpuMemory);
}
public void PrintCurrentThreadStackTrace()
@@ -1038,14 +1043,9 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
System.Scheduler.GetCurrentThread().PrintGuestStackTrace();
}
- private void CpuTraceHandler(object sender, CpuTraceEventArgs e)
- {
- Logger.PrintInfo(LogClass.Cpu, $"Executing at 0x{e.Position:X16}.");
- }
-
private void UndefinedInstructionHandler(object sender, InstUndefinedEventArgs e)
{
- throw new UndefinedInstructionException(e.Position, e.RawOpCode);
+ throw new UndefinedInstructionException(e.Address, e.OpCode);
}
}
} \ No newline at end of file
diff --git a/Ryujinx.HLE/HOS/Kernel/SupervisorCall/SvcHandler.cs b/Ryujinx.HLE/HOS/Kernel/SupervisorCall/SvcHandler.cs
index cf881a79..7509ae04 100644
--- a/Ryujinx.HLE/HOS/Kernel/SupervisorCall/SvcHandler.cs
+++ b/Ryujinx.HLE/HOS/Kernel/SupervisorCall/SvcHandler.cs
@@ -1,5 +1,4 @@
-using ChocolArm64.Events;
-using ChocolArm64.State;
+using ARMeilleure.State;
using Ryujinx.HLE.HOS.Kernel.Process;
using System;
@@ -7,9 +6,9 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
{
partial class SvcHandler
{
- private Switch _device;
- private KProcess _process;
- private Horizon _system;
+ private Switch _device;
+ private KProcess _process;
+ private Horizon _system;
public SvcHandler(Switch device, KProcess process)
{
@@ -20,16 +19,16 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
public void SvcCall(object sender, InstExceptionEventArgs e)
{
- Action<SvcHandler, CpuThreadState> svcFunc = SvcTable.GetSvcFunc(e.Id);
+ Action<SvcHandler, IExecutionContext> svcFunc = SvcTable.GetSvcFunc(e.Id);
if (svcFunc == null)
{
throw new NotImplementedException($"SVC 0x{e.Id:X4} is not implemented.");
}
- CpuThreadState threadState = (CpuThreadState)sender;
+ IExecutionContext context = (IExecutionContext)sender;
- svcFunc(this, threadState);
+ svcFunc(this, context);
}
}
} \ No newline at end of file
diff --git a/Ryujinx.HLE/HOS/Kernel/SupervisorCall/SvcIpc.cs b/Ryujinx.HLE/HOS/Kernel/SupervisorCall/SvcIpc.cs
index eb7595c0..7c1c981b 100644
--- a/Ryujinx.HLE/HOS/Kernel/SupervisorCall/SvcIpc.cs
+++ b/Ryujinx.HLE/HOS/Kernel/SupervisorCall/SvcIpc.cs
@@ -83,7 +83,7 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
public KernelResult SendSyncRequest64(int handle)
{
- return SendSyncRequest((ulong)_system.Scheduler.GetCurrentThread().Context.ThreadState.Tpidr, 0x100, handle);
+ return SendSyncRequest((ulong)_system.Scheduler.GetCurrentThread().Context.Tpidr, 0x100, handle);
}
public KernelResult SendSyncRequestWithUserBuffer64(ulong messagePtr, ulong size, int handle)
diff --git a/Ryujinx.HLE/HOS/Kernel/SupervisorCall/SvcSystem.cs b/Ryujinx.HLE/HOS/Kernel/SupervisorCall/SvcSystem.cs
index 5f971131..094e1935 100644
--- a/Ryujinx.HLE/HOS/Kernel/SupervisorCall/SvcSystem.cs
+++ b/Ryujinx.HLE/HOS/Kernel/SupervisorCall/SvcSystem.cs
@@ -1,4 +1,4 @@
-using ChocolArm64.Memory;
+using ARMeilleure.Memory;
using Ryujinx.Common;
using Ryujinx.Common.Logging;
using Ryujinx.HLE.Exceptions;
@@ -138,7 +138,7 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
public ulong GetSystemTick64()
{
- return _system.Scheduler.GetCurrentThread().Context.ThreadState.CntpctEl0;
+ return _system.Scheduler.GetCurrentThread().Context.CntpctEl0;
}
public KernelResult GetProcessId64(int handle, out long pid)
diff --git a/Ryujinx.HLE/HOS/Kernel/SupervisorCall/SvcTable.cs b/Ryujinx.HLE/HOS/Kernel/SupervisorCall/SvcTable.cs
index 23934649..c1a31da9 100644
--- a/Ryujinx.HLE/HOS/Kernel/SupervisorCall/SvcTable.cs
+++ b/Ryujinx.HLE/HOS/Kernel/SupervisorCall/SvcTable.cs
@@ -1,4 +1,4 @@
-using ChocolArm64.State;
+using ARMeilleure.State;
using Ryujinx.Common.Logging;
using Ryujinx.HLE.HOS.Kernel.Common;
using System;
@@ -14,7 +14,7 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
private static Dictionary<int, string> _svcFuncs64;
- private static Action<SvcHandler, CpuThreadState>[] _svcTable64;
+ private static Action<SvcHandler, IExecutionContext>[] _svcTable64;
static SvcTable()
{
@@ -77,10 +77,10 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
{ 0x78, nameof(SvcHandler.UnmapProcessCodeMemory64) }
};
- _svcTable64 = new Action<SvcHandler, CpuThreadState>[0x80];
+ _svcTable64 = new Action<SvcHandler, IExecutionContext>[0x80];
}
- public static Action<SvcHandler, CpuThreadState> GetSvcFunc(int svcId)
+ public static Action<SvcHandler, IExecutionContext> GetSvcFunc(int svcId)
{
if (_svcTable64[svcId] != null)
{
@@ -95,9 +95,9 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
return null;
}
- private static Action<SvcHandler, CpuThreadState> GenerateMethod(string svcName)
+ private static Action<SvcHandler, IExecutionContext> GenerateMethod(string svcName)
{
- Type[] argTypes = new Type[] { typeof(SvcHandler), typeof(CpuThreadState) };
+ Type[] argTypes = new Type[] { typeof(SvcHandler), typeof(IExecutionContext) };
DynamicMethod method = new DynamicMethod(svcName, null, argTypes);
@@ -183,7 +183,11 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
generator.Emit(OpCodes.Conv_I);
generator.Emit(OpCodes.Ldarg_1);
- generator.Emit(OpCodes.Ldfld, GetStateFieldX(byRefArgsCount + index));
+ generator.Emit(OpCodes.Ldc_I4, byRefArgsCount + index);
+
+ MethodInfo info = typeof(IExecutionContext).GetMethod(nameof(IExecutionContext.GetX));
+
+ generator.Emit(OpCodes.Call, info);
generator.Emit(OpCodes.Box, typeof(ulong));
@@ -227,7 +231,11 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
else
{
generator.Emit(OpCodes.Ldarg_1);
- generator.Emit(OpCodes.Ldfld, GetStateFieldX(byRefArgsCount + index));
+ generator.Emit(OpCodes.Ldc_I4, byRefArgsCount + index);
+
+ MethodInfo info = typeof(IExecutionContext).GetMethod(nameof(IExecutionContext.GetX));
+
+ generator.Emit(OpCodes.Call, info);
ConvertToArgType(argType);
}
@@ -258,51 +266,44 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
generator.Emit(OpCodes.Stloc, tempLocal);
generator.Emit(OpCodes.Ldarg_1);
+ generator.Emit(OpCodes.Ldc_I4, outRegIndex++);
generator.Emit(OpCodes.Ldloc, tempLocal);
ConvertToFieldType(retType);
- generator.Emit(OpCodes.Stfld, GetStateFieldX(outRegIndex++));
+ MethodInfo info = typeof(IExecutionContext).GetMethod(nameof(IExecutionContext.SetX));
+
+ generator.Emit(OpCodes.Call, info);
}
for (int index = 0; index < locals.Count; index++)
{
generator.Emit(OpCodes.Ldarg_1);
+ generator.Emit(OpCodes.Ldc_I4, outRegIndex++);
generator.Emit(OpCodes.Ldloc, locals[index]);
ConvertToFieldType(locals[index].LocalType);
- generator.Emit(OpCodes.Stfld, GetStateFieldX(outRegIndex++));
+ MethodInfo info = typeof(IExecutionContext).GetMethod(nameof(IExecutionContext.SetX));
+
+ generator.Emit(OpCodes.Call, info);
}
// Zero out the remaining unused registers.
while (outRegIndex < SvcFuncMaxArguments)
{
generator.Emit(OpCodes.Ldarg_1);
+ generator.Emit(OpCodes.Ldc_I4, outRegIndex++);
generator.Emit(OpCodes.Ldc_I8, 0L);
- generator.Emit(OpCodes.Stfld, GetStateFieldX(outRegIndex++));
- }
- generator.Emit(OpCodes.Ret);
-
- return (Action<SvcHandler, CpuThreadState>)method.CreateDelegate(typeof(Action<SvcHandler, CpuThreadState>));
- }
+ MethodInfo info = typeof(IExecutionContext).GetMethod(nameof(IExecutionContext.SetX));
- private static FieldInfo GetStateFieldX(int index)
- {
- switch (index)
- {
- case 0: return typeof(CpuThreadState).GetField(nameof(CpuThreadState.X0));
- case 1: return typeof(CpuThreadState).GetField(nameof(CpuThreadState.X1));
- case 2: return typeof(CpuThreadState).GetField(nameof(CpuThreadState.X2));
- case 3: return typeof(CpuThreadState).GetField(nameof(CpuThreadState.X3));
- case 4: return typeof(CpuThreadState).GetField(nameof(CpuThreadState.X4));
- case 5: return typeof(CpuThreadState).GetField(nameof(CpuThreadState.X5));
- case 6: return typeof(CpuThreadState).GetField(nameof(CpuThreadState.X6));
- case 7: return typeof(CpuThreadState).GetField(nameof(CpuThreadState.X7));
+ generator.Emit(OpCodes.Call, info);
}
- throw new ArgumentOutOfRangeException(nameof(index));
+ generator.Emit(OpCodes.Ret);
+
+ return (Action<SvcHandler, IExecutionContext>)method.CreateDelegate(typeof(Action<SvcHandler, IExecutionContext>));
}
private static void CheckIfTypeIsSupported(Type type, string svcName)
diff --git a/Ryujinx.HLE/HOS/Kernel/SupervisorCall/SvcThread.cs b/Ryujinx.HLE/HOS/Kernel/SupervisorCall/SvcThread.cs
index e1f018c1..e49da023 100644
--- a/Ryujinx.HLE/HOS/Kernel/SupervisorCall/SvcThread.cs
+++ b/Ryujinx.HLE/HOS/Kernel/SupervisorCall/SvcThread.cs
@@ -1,4 +1,5 @@
-using ChocolArm64.Memory;
+using ARMeilleure.Memory;
+using ARMeilleure.State;
using Ryujinx.HLE.HOS.Kernel.Common;
using Ryujinx.HLE.HOS.Kernel.Process;
using Ryujinx.HLE.HOS.Kernel.Threading;
@@ -347,83 +348,91 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
return KernelResult.InvalidThread;
}
- MemoryManager memory = currentProcess.CpuMemory;
-
- memory.WriteUInt64((long)address + 0x0, thread.Context.ThreadState.X0);
- memory.WriteUInt64((long)address + 0x8, thread.Context.ThreadState.X1);
- memory.WriteUInt64((long)address + 0x10, thread.Context.ThreadState.X2);
- memory.WriteUInt64((long)address + 0x18, thread.Context.ThreadState.X3);
- memory.WriteUInt64((long)address + 0x20, thread.Context.ThreadState.X4);
- memory.WriteUInt64((long)address + 0x28, thread.Context.ThreadState.X5);
- memory.WriteUInt64((long)address + 0x30, thread.Context.ThreadState.X6);
- memory.WriteUInt64((long)address + 0x38, thread.Context.ThreadState.X7);
- memory.WriteUInt64((long)address + 0x40, thread.Context.ThreadState.X8);
- memory.WriteUInt64((long)address + 0x48, thread.Context.ThreadState.X9);
- memory.WriteUInt64((long)address + 0x50, thread.Context.ThreadState.X10);
- memory.WriteUInt64((long)address + 0x58, thread.Context.ThreadState.X11);
- memory.WriteUInt64((long)address + 0x60, thread.Context.ThreadState.X12);
- memory.WriteUInt64((long)address + 0x68, thread.Context.ThreadState.X13);
- memory.WriteUInt64((long)address + 0x70, thread.Context.ThreadState.X14);
- memory.WriteUInt64((long)address + 0x78, thread.Context.ThreadState.X15);
- memory.WriteUInt64((long)address + 0x80, thread.Context.ThreadState.X16);
- memory.WriteUInt64((long)address + 0x88, thread.Context.ThreadState.X17);
- memory.WriteUInt64((long)address + 0x90, thread.Context.ThreadState.X18);
- memory.WriteUInt64((long)address + 0x98, thread.Context.ThreadState.X19);
- memory.WriteUInt64((long)address + 0xa0, thread.Context.ThreadState.X20);
- memory.WriteUInt64((long)address + 0xa8, thread.Context.ThreadState.X21);
- memory.WriteUInt64((long)address + 0xb0, thread.Context.ThreadState.X22);
- memory.WriteUInt64((long)address + 0xb8, thread.Context.ThreadState.X23);
- memory.WriteUInt64((long)address + 0xc0, thread.Context.ThreadState.X24);
- memory.WriteUInt64((long)address + 0xc8, thread.Context.ThreadState.X25);
- memory.WriteUInt64((long)address + 0xd0, thread.Context.ThreadState.X26);
- memory.WriteUInt64((long)address + 0xd8, thread.Context.ThreadState.X27);
- memory.WriteUInt64((long)address + 0xe0, thread.Context.ThreadState.X28);
- memory.WriteUInt64((long)address + 0xe8, thread.Context.ThreadState.X29);
- memory.WriteUInt64((long)address + 0xf0, thread.Context.ThreadState.X30);
- memory.WriteUInt64((long)address + 0xf8, thread.Context.ThreadState.X31);
+ IMemoryManager memory = currentProcess.CpuMemory;
+
+ memory.WriteUInt64((long)address + 0x0, thread.Context.GetX(0));
+ memory.WriteUInt64((long)address + 0x8, thread.Context.GetX(1));
+ memory.WriteUInt64((long)address + 0x10, thread.Context.GetX(2));
+ memory.WriteUInt64((long)address + 0x18, thread.Context.GetX(3));
+ memory.WriteUInt64((long)address + 0x20, thread.Context.GetX(4));
+ memory.WriteUInt64((long)address + 0x28, thread.Context.GetX(5));
+ memory.WriteUInt64((long)address + 0x30, thread.Context.GetX(6));
+ memory.WriteUInt64((long)address + 0x38, thread.Context.GetX(7));
+ memory.WriteUInt64((long)address + 0x40, thread.Context.GetX(8));
+ memory.WriteUInt64((long)address + 0x48, thread.Context.GetX(9));
+ memory.WriteUInt64((long)address + 0x50, thread.Context.GetX(10));
+ memory.WriteUInt64((long)address + 0x58, thread.Context.GetX(11));
+ memory.WriteUInt64((long)address + 0x60, thread.Context.GetX(12));
+ memory.WriteUInt64((long)address + 0x68, thread.Context.GetX(13));
+ memory.WriteUInt64((long)address + 0x70, thread.Context.GetX(14));
+ memory.WriteUInt64((long)address + 0x78, thread.Context.GetX(15));
+ memory.WriteUInt64((long)address + 0x80, thread.Context.GetX(16));
+ memory.WriteUInt64((long)address + 0x88, thread.Context.GetX(17));
+ memory.WriteUInt64((long)address + 0x90, thread.Context.GetX(18));
+ memory.WriteUInt64((long)address + 0x98, thread.Context.GetX(19));
+ memory.WriteUInt64((long)address + 0xa0, thread.Context.GetX(20));
+ memory.WriteUInt64((long)address + 0xa8, thread.Context.GetX(21));
+ memory.WriteUInt64((long)address + 0xb0, thread.Context.GetX(22));
+ memory.WriteUInt64((long)address + 0xb8, thread.Context.GetX(23));
+ memory.WriteUInt64((long)address + 0xc0, thread.Context.GetX(24));
+ memory.WriteUInt64((long)address + 0xc8, thread.Context.GetX(25));
+ memory.WriteUInt64((long)address + 0xd0, thread.Context.GetX(26));
+ memory.WriteUInt64((long)address + 0xd8, thread.Context.GetX(27));
+ memory.WriteUInt64((long)address + 0xe0, thread.Context.GetX(28));
+ memory.WriteUInt64((long)address + 0xe8, thread.Context.GetX(29));
+ memory.WriteUInt64((long)address + 0xf0, thread.Context.GetX(30));
+ memory.WriteUInt64((long)address + 0xf8, thread.Context.GetX(31));
memory.WriteInt64((long)address + 0x100, thread.LastPc);
- memory.WriteUInt64((long)address + 0x108, (ulong)thread.Context.ThreadState.Psr);
-
- memory.WriteVector128((long)address + 0x110, thread.Context.ThreadState.V0);
- memory.WriteVector128((long)address + 0x120, thread.Context.ThreadState.V1);
- memory.WriteVector128((long)address + 0x130, thread.Context.ThreadState.V2);
- memory.WriteVector128((long)address + 0x140, thread.Context.ThreadState.V3);
- memory.WriteVector128((long)address + 0x150, thread.Context.ThreadState.V4);
- memory.WriteVector128((long)address + 0x160, thread.Context.ThreadState.V5);
- memory.WriteVector128((long)address + 0x170, thread.Context.ThreadState.V6);
- memory.WriteVector128((long)address + 0x180, thread.Context.ThreadState.V7);
- memory.WriteVector128((long)address + 0x190, thread.Context.ThreadState.V8);
- memory.WriteVector128((long)address + 0x1a0, thread.Context.ThreadState.V9);
- memory.WriteVector128((long)address + 0x1b0, thread.Context.ThreadState.V10);
- memory.WriteVector128((long)address + 0x1c0, thread.Context.ThreadState.V11);
- memory.WriteVector128((long)address + 0x1d0, thread.Context.ThreadState.V12);
- memory.WriteVector128((long)address + 0x1e0, thread.Context.ThreadState.V13);
- memory.WriteVector128((long)address + 0x1f0, thread.Context.ThreadState.V14);
- memory.WriteVector128((long)address + 0x200, thread.Context.ThreadState.V15);
- memory.WriteVector128((long)address + 0x210, thread.Context.ThreadState.V16);
- memory.WriteVector128((long)address + 0x220, thread.Context.ThreadState.V17);
- memory.WriteVector128((long)address + 0x230, thread.Context.ThreadState.V18);
- memory.WriteVector128((long)address + 0x240, thread.Context.ThreadState.V19);
- memory.WriteVector128((long)address + 0x250, thread.Context.ThreadState.V20);
- memory.WriteVector128((long)address + 0x260, thread.Context.ThreadState.V21);
- memory.WriteVector128((long)address + 0x270, thread.Context.ThreadState.V22);
- memory.WriteVector128((long)address + 0x280, thread.Context.ThreadState.V23);
- memory.WriteVector128((long)address + 0x290, thread.Context.ThreadState.V24);
- memory.WriteVector128((long)address + 0x2a0, thread.Context.ThreadState.V25);
- memory.WriteVector128((long)address + 0x2b0, thread.Context.ThreadState.V26);
- memory.WriteVector128((long)address + 0x2c0, thread.Context.ThreadState.V27);
- memory.WriteVector128((long)address + 0x2d0, thread.Context.ThreadState.V28);
- memory.WriteVector128((long)address + 0x2e0, thread.Context.ThreadState.V29);
- memory.WriteVector128((long)address + 0x2f0, thread.Context.ThreadState.V30);
- memory.WriteVector128((long)address + 0x300, thread.Context.ThreadState.V31);
-
- memory.WriteInt32((long)address + 0x310, thread.Context.ThreadState.Fpcr);
- memory.WriteInt32((long)address + 0x314, thread.Context.ThreadState.Fpsr);
- memory.WriteInt64((long)address + 0x318, thread.Context.ThreadState.Tpidr);
+ memory.WriteUInt64((long)address + 0x108, (ulong)GetPsr(thread.Context));
+
+ memory.WriteVector128((long)address + 0x110, thread.Context.GetV(0));
+ memory.WriteVector128((long)address + 0x120, thread.Context.GetV(1));
+ memory.WriteVector128((long)address + 0x130, thread.Context.GetV(2));
+ memory.WriteVector128((long)address + 0x140, thread.Context.GetV(3));
+ memory.WriteVector128((long)address + 0x150, thread.Context.GetV(4));
+ memory.WriteVector128((long)address + 0x160, thread.Context.GetV(5));
+ memory.WriteVector128((long)address + 0x170, thread.Context.GetV(6));
+ memory.WriteVector128((long)address + 0x180, thread.Context.GetV(7));
+ memory.WriteVector128((long)address + 0x190, thread.Context.GetV(8));
+ memory.WriteVector128((long)address + 0x1a0, thread.Context.GetV(9));
+ memory.WriteVector128((long)address + 0x1b0, thread.Context.GetV(10));
+ memory.WriteVector128((long)address + 0x1c0, thread.Context.GetV(11));
+ memory.WriteVector128((long)address + 0x1d0, thread.Context.GetV(12));
+ memory.WriteVector128((long)address + 0x1e0, thread.Context.GetV(13));
+ memory.WriteVector128((long)address + 0x1f0, thread.Context.GetV(14));
+ memory.WriteVector128((long)address + 0x200, thread.Context.GetV(15));
+ memory.WriteVector128((long)address + 0x210, thread.Context.GetV(16));
+ memory.WriteVector128((long)address + 0x220, thread.Context.GetV(17));
+ memory.WriteVector128((long)address + 0x230, thread.Context.GetV(18));
+ memory.WriteVector128((long)address + 0x240, thread.Context.GetV(19));
+ memory.WriteVector128((long)address + 0x250, thread.Context.GetV(20));
+ memory.WriteVector128((long)address + 0x260, thread.Context.GetV(21));
+ memory.WriteVector128((long)address + 0x270, thread.Context.GetV(22));
+ memory.WriteVector128((long)address + 0x280, thread.Context.GetV(23));
+ memory.WriteVector128((long)address + 0x290, thread.Context.GetV(24));
+ memory.WriteVector128((long)address + 0x2a0, thread.Context.GetV(25));
+ memory.WriteVector128((long)address + 0x2b0, thread.Context.GetV(26));
+ memory.WriteVector128((long)address + 0x2c0, thread.Context.GetV(27));
+ memory.WriteVector128((long)address + 0x2d0, thread.Context.GetV(28));
+ memory.WriteVector128((long)address + 0x2e0, thread.Context.GetV(29));
+ memory.WriteVector128((long)address + 0x2f0, thread.Context.GetV(30));
+ memory.WriteVector128((long)address + 0x300, thread.Context.GetV(31));
+
+ memory.WriteInt32((long)address + 0x310, (int)thread.Context.Fpcr);
+ memory.WriteInt32((long)address + 0x314, (int)thread.Context.Fpsr);
+ memory.WriteInt64((long)address + 0x318, thread.Context.Tpidr);
return KernelResult.Success;
}
+
+ private static int GetPsr(IExecutionContext context)
+ {
+ return (context.GetPstateFlag(PState.NFlag) ? (1 << 31) : 0) |
+ (context.GetPstateFlag(PState.ZFlag) ? (1 << 30) : 0) |
+ (context.GetPstateFlag(PState.CFlag) ? (1 << 29) : 0) |
+ (context.GetPstateFlag(PState.VFlag) ? (1 << 28) : 0);
+ }
}
} \ No newline at end of file
diff --git a/Ryujinx.HLE/HOS/Kernel/Threading/HleScheduler.cs b/Ryujinx.HLE/HOS/Kernel/Threading/HleScheduler.cs
index 42eed26a..0b951134 100644
--- a/Ryujinx.HLE/HOS/Kernel/Threading/HleScheduler.cs
+++ b/Ryujinx.HLE/HOS/Kernel/Threading/HleScheduler.cs
@@ -36,12 +36,12 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading
{
KCoreContext coreContext = CoreContexts[core];
- if (coreContext.ContextSwitchNeeded && (coreContext.CurrentThread?.Context.IsCurrentThread() ?? false))
+ if (coreContext.ContextSwitchNeeded && (coreContext.CurrentThread?.IsCurrentHostThread() ?? false))
{
coreContext.ContextSwitch();
}
- if (coreContext.CurrentThread?.Context.IsCurrentThread() ?? false)
+ if (coreContext.CurrentThread?.IsCurrentHostThread() ?? false)
{
selectedCount++;
}
@@ -70,14 +70,14 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading
{
// If this is not the thread that is currently executing, we need
// to request an interrupt to allow safely starting another thread.
- if (!currentThread.Context.IsCurrentThread())
+ if (!currentThread.IsCurrentHostThread())
{
currentThread.Context.RequestInterrupt();
return;
}
- CoreManager.Reset(currentThread.Context.Work);
+ CoreManager.Reset(currentThread.HostThread);
}
// Advance current core and try picking a thread,
@@ -92,9 +92,9 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading
if (coreContext.CurrentThread != null)
{
- CoreManager.Set(coreContext.CurrentThread.Context.Work);
+ CoreManager.Set(coreContext.CurrentThread.HostThread);
- coreContext.CurrentThread.Context.Execute();
+ coreContext.CurrentThread.Execute();
break;
}
@@ -134,14 +134,14 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading
public void ExitThread(KThread thread)
{
- thread.Context.StopExecution();
+ thread.Context.Running = false;
- CoreManager.Exit(thread.Context.Work);
+ CoreManager.Exit(thread.HostThread);
}
public void RemoveThread(KThread thread)
{
- CoreManager.RemoveThread(thread.Context.Work);
+ CoreManager.RemoveThread(thread.HostThread);
}
}
} \ No newline at end of file
diff --git a/Ryujinx.HLE/HOS/Kernel/Threading/KCoreContext.cs b/Ryujinx.HLE/HOS/Kernel/Threading/KCoreContext.cs
index 97907177..0aa12b0d 100644
--- a/Ryujinx.HLE/HOS/Kernel/Threading/KCoreContext.cs
+++ b/Ryujinx.HLE/HOS/Kernel/Threading/KCoreContext.cs
@@ -58,7 +58,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading
if (CurrentThread != null)
{
- _coreManager.Reset(CurrentThread.Context.Work);
+ _coreManager.Reset(CurrentThread.HostThread);
}
CurrentThread = SelectedThread;
@@ -70,9 +70,9 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading
CurrentThread.TotalTimeRunning += currentTime - CurrentThread.LastScheduledTime;
CurrentThread.LastScheduledTime = currentTime;
- _coreManager.Set(CurrentThread.Context.Work);
+ _coreManager.Set(CurrentThread.HostThread);
- CurrentThread.Context.Execute();
+ CurrentThread.Execute();
}
}
}
diff --git a/Ryujinx.HLE/HOS/Kernel/Threading/KCriticalSection.cs b/Ryujinx.HLE/HOS/Kernel/Threading/KCriticalSection.cs
index 39c857b5..b7013bb7 100644
--- a/Ryujinx.HLE/HOS/Kernel/Threading/KCriticalSection.cs
+++ b/Ryujinx.HLE/HOS/Kernel/Threading/KCriticalSection.cs
@@ -1,4 +1,4 @@
-using ChocolArm64;
+using ARMeilleure;
using System.Threading;
namespace Ryujinx.HLE.HOS.Kernel.Threading
@@ -53,14 +53,14 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading
if (coreContext.ContextSwitchNeeded)
{
- CpuThread currentHleThread = coreContext.CurrentThread?.Context;
+ KThread currentThread = coreContext.CurrentThread;
- if (currentHleThread == null)
+ if (currentThread == null)
{
// Nothing is running, we can perform the context switch immediately.
coreContext.ContextSwitch();
}
- else if (currentHleThread.IsCurrentThread())
+ else if (currentThread.IsCurrentHostThread())
{
// Thread running on the current core, context switch will block.
doContextSwitch = true;
@@ -68,7 +68,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading
else
{
// Thread running on another core, request a interrupt.
- currentHleThread.RequestInterrupt();
+ currentThread.Context.RequestInterrupt();
}
}
}
diff --git a/Ryujinx.HLE/HOS/Kernel/Threading/KScheduler.cs b/Ryujinx.HLE/HOS/Kernel/Threading/KScheduler.cs
index 8d2cdfce..dd5422b8 100644
--- a/Ryujinx.HLE/HOS/Kernel/Threading/KScheduler.cs
+++ b/Ryujinx.HLE/HOS/Kernel/Threading/KScheduler.cs
@@ -203,7 +203,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading
{
for (int core = 0; core < CpuCoresCount; core++)
{
- if (CoreContexts[core].CurrentThread?.Context.IsCurrentThread() ?? false)
+ if (CoreContexts[core].CurrentThread?.IsCurrentHostThread() ?? false)
{
return CoreContexts[core].CurrentThread;
}
diff --git a/Ryujinx.HLE/HOS/Kernel/Threading/KThread.cs b/Ryujinx.HLE/HOS/Kernel/Threading/KThread.cs
index 50c71ea9..54d5d06c 100644
--- a/Ryujinx.HLE/HOS/Kernel/Threading/KThread.cs
+++ b/Ryujinx.HLE/HOS/Kernel/Threading/KThread.cs
@@ -1,5 +1,5 @@
-using ChocolArm64;
-using ChocolArm64.Memory;
+using ARMeilleure.Memory;
+using ARMeilleure.State;
using Ryujinx.Common.Logging;
using Ryujinx.HLE.HOS.Kernel.Common;
using Ryujinx.HLE.HOS.Kernel.Process;
@@ -7,12 +7,17 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
+using System.Threading;
namespace Ryujinx.HLE.HOS.Kernel.Threading
{
class KThread : KSynchronizationObject, IKFutureSchedulerObject
{
- public CpuThread Context { get; private set; }
+ private int _hostThreadRunning;
+
+ public Thread HostThread { get; private set; }
+
+ public IExecutionContext Context { get; private set; }
public long AffinityMask { get; set; }
@@ -152,30 +157,35 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading
is64Bits = true;
}
- Context = new CpuThread(owner.Translator, owner.CpuMemory, (long)entrypoint);
+ HostThread = new Thread(() => ThreadStart(entrypoint));
- bool isAarch32 = (Owner.MmuFlags & 1) == 0;
+ if (System.UseLegacyJit)
+ {
+ Context = new ChocolArm64.State.CpuThreadState();
+ }
+ else
+ {
+ Context = new ARMeilleure.State.ExecutionContext();
+ }
- Context.ThreadState.Aarch32 = isAarch32;
+ bool isAarch32 = (Owner.MmuFlags & 1) == 0;
- Context.ThreadState.X0 = argsPtr;
+ Context.SetX(0, argsPtr);
if (isAarch32)
{
- Context.ThreadState.X13 = (uint)stackTop;
+ Context.SetX(13, (uint)stackTop);
}
else
{
- Context.ThreadState.X31 = stackTop;
+ Context.SetX(31, stackTop);
}
- Context.ThreadState.CntfrqEl0 = 19200000;
- Context.ThreadState.Tpidr = (long)_tlsAddress;
+ Context.CntfrqEl0 = 19200000;
+ Context.Tpidr = (long)_tlsAddress;
owner.SubscribeThreadEventHandlers(Context);
- Context.WorkFinished += ThreadFinishedHandler;
-
ThreadUid = System.GetThreadUid();
_hasBeenInitialized = true;
@@ -1002,8 +1012,8 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading
public void SetEntryArguments(long argsPtr, int threadHandle)
{
- Context.ThreadState.X0 = (ulong)argsPtr;
- Context.ThreadState.X1 = (ulong)threadHandle;
+ Context.SetX(0, (ulong)argsPtr);
+ Context.SetX(1, (ulong)threadHandle);
}
public void TimeUp()
@@ -1013,7 +1023,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading
public string GetGuestStackTrace()
{
- return Owner.Debugger.GetGuestStackTrace(Context.ThreadState);
+ return Owner.Debugger.GetGuestStackTrace(Context);
}
public void PrintGuestStackTrace()
@@ -1026,12 +1036,32 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading
Logger.PrintInfo(LogClass.Cpu, trace.ToString());
}
- private void ThreadFinishedHandler(object sender, EventArgs e)
+ public void Execute()
+ {
+ if (Interlocked.CompareExchange(ref _hostThreadRunning, 1, 0) == 0)
+ {
+ HostThread.Start();
+ }
+ }
+
+ private void ThreadStart(ulong entrypoint)
+ {
+ Owner.Translator.Execute(Context, entrypoint);
+
+ ThreadExit();
+ }
+
+ private void ThreadExit()
{
System.Scheduler.ExitThread(this);
System.Scheduler.RemoveThread(this);
}
+ public bool IsCurrentHostThread()
+ {
+ return Thread.CurrentThread == HostThread;
+ }
+
public override bool IsSignaled()
{
return _hasExited;
diff --git a/Ryujinx.HLE/HOS/ProgramLoader.cs b/Ryujinx.HLE/HOS/ProgramLoader.cs
index af974e18..0bc6447e 100644
--- a/Ryujinx.HLE/HOS/ProgramLoader.cs
+++ b/Ryujinx.HLE/HOS/ProgramLoader.cs
@@ -1,4 +1,4 @@
-using ChocolArm64.Memory;
+using ARMeilleure.Memory;
using Ryujinx.Common;
using Ryujinx.Common.Logging;
using Ryujinx.HLE.HOS.Kernel.Common;
diff --git a/Ryujinx.HLE/HOS/ServiceCtx.cs b/Ryujinx.HLE/HOS/ServiceCtx.cs
index 99b2d5af..df74ba0a 100644
--- a/Ryujinx.HLE/HOS/ServiceCtx.cs
+++ b/Ryujinx.HLE/HOS/ServiceCtx.cs
@@ -1,4 +1,4 @@
-using ChocolArm64.Memory;
+using ARMeilleure.Memory;
using Ryujinx.HLE.HOS.Ipc;
using Ryujinx.HLE.HOS.Kernel.Ipc;
using Ryujinx.HLE.HOS.Kernel.Process;
@@ -11,7 +11,7 @@ namespace Ryujinx.HLE.HOS
{
public Switch Device { get; }
public KProcess Process { get; }
- public MemoryManager Memory { get; }
+ public IMemoryManager Memory { get; }
public KThread Thread { get; }
public KClientSession Session { get; }
public IpcMessage Request { get; }
@@ -22,7 +22,7 @@ namespace Ryujinx.HLE.HOS
public ServiceCtx(
Switch device,
KProcess process,
- MemoryManager memory,
+ IMemoryManager memory,
KThread thread,
KClientSession session,
IpcMessage request,
diff --git a/Ryujinx.HLE/HOS/Services/Acc/IProfile.cs b/Ryujinx.HLE/HOS/Services/Acc/IProfile.cs
index 050e4497..10210afe 100644
--- a/Ryujinx.HLE/HOS/Services/Acc/IProfile.cs
+++ b/Ryujinx.HLE/HOS/Services/Acc/IProfile.cs
@@ -1,4 +1,4 @@
-using ChocolArm64.Memory;
+using ARMeilleure.Memory;
using Ryujinx.Common.Logging;
using Ryujinx.HLE.HOS.SystemState;
using Ryujinx.HLE.Utilities;
diff --git a/Ryujinx.HLE/HOS/Services/Aud/AudioOut/IAudioOut.cs b/Ryujinx.HLE/HOS/Services/Aud/AudioOut/IAudioOut.cs
index 4191dfd6..751d3f70 100644
--- a/Ryujinx.HLE/HOS/Services/Aud/AudioOut/IAudioOut.cs
+++ b/Ryujinx.HLE/HOS/Services/Aud/AudioOut/IAudioOut.cs
@@ -1,4 +1,4 @@
-using ChocolArm64.Memory;
+using ARMeilleure.Memory;
using Ryujinx.Audio;
using Ryujinx.HLE.HOS.Ipc;
using Ryujinx.HLE.HOS.Kernel.Common;
diff --git a/Ryujinx.HLE/HOS/Services/Aud/AudioRenderer/IAudioRenderer.cs b/Ryujinx.HLE/HOS/Services/Aud/AudioRenderer/IAudioRenderer.cs
index 599f3d81..e8baf819 100644
--- a/Ryujinx.HLE/HOS/Services/Aud/AudioRenderer/IAudioRenderer.cs
+++ b/Ryujinx.HLE/HOS/Services/Aud/AudioRenderer/IAudioRenderer.cs
@@ -1,4 +1,4 @@
-using ChocolArm64.Memory;
+using ARMeilleure.Memory;
using Ryujinx.Audio;
using Ryujinx.Audio.Adpcm;
using Ryujinx.Common.Logging;
@@ -24,7 +24,7 @@ namespace Ryujinx.HLE.HOS.Services.Aud.AudioRenderer
private KEvent _updateEvent;
- private MemoryManager _memory;
+ private IMemoryManager _memory;
private IAalOutput _audioOut;
@@ -40,7 +40,7 @@ namespace Ryujinx.HLE.HOS.Services.Aud.AudioRenderer
public IAudioRenderer(
Horizon system,
- MemoryManager memory,
+ IMemoryManager memory,
IAalOutput audioOut,
AudioRendererParameter Params)
{
diff --git a/Ryujinx.HLE/HOS/Services/Aud/AudioRenderer/VoiceContext.cs b/Ryujinx.HLE/HOS/Services/Aud/AudioRenderer/VoiceContext.cs
index 93a16a61..aaff20a5 100644
--- a/Ryujinx.HLE/HOS/Services/Aud/AudioRenderer/VoiceContext.cs
+++ b/Ryujinx.HLE/HOS/Services/Aud/AudioRenderer/VoiceContext.cs
@@ -1,4 +1,4 @@
-using ChocolArm64.Memory;
+using ARMeilleure.Memory;
using Ryujinx.Audio.Adpcm;
using System;
@@ -65,7 +65,7 @@ namespace Ryujinx.HLE.HOS.Services.Aud.AudioRenderer
_outStatus.VoiceDropsCount = 0;
}
- public int[] GetBufferData(MemoryManager memory, int maxSamples, out int samplesCount)
+ public int[] GetBufferData(IMemoryManager memory, int maxSamples, out int samplesCount)
{
if (!Playing)
{
@@ -122,7 +122,7 @@ namespace Ryujinx.HLE.HOS.Services.Aud.AudioRenderer
return output;
}
- private void UpdateBuffer(MemoryManager memory)
+ private void UpdateBuffer(IMemoryManager memory)
{
// TODO: Implement conversion for formats other
// than interleaved stereo (2 channels).
diff --git a/Ryujinx.HLE/HOS/Services/Aud/IAudioOutManager.cs b/Ryujinx.HLE/HOS/Services/Aud/IAudioOutManager.cs
index ad0dd044..bea0f3f2 100644
--- a/Ryujinx.HLE/HOS/Services/Aud/IAudioOutManager.cs
+++ b/Ryujinx.HLE/HOS/Services/Aud/IAudioOutManager.cs
@@ -1,4 +1,4 @@
-using ChocolArm64.Memory;
+using ARMeilleure.Memory;
using Ryujinx.Audio;
using Ryujinx.Common.Logging;
using Ryujinx.HLE.HOS.Kernel.Threading;
diff --git a/Ryujinx.HLE/HOS/Services/Ldr/IRoInterface.cs b/Ryujinx.HLE/HOS/Services/Ldr/IRoInterface.cs
index b8780730..748a600d 100644
--- a/Ryujinx.HLE/HOS/Services/Ldr/IRoInterface.cs
+++ b/Ryujinx.HLE/HOS/Services/Ldr/IRoInterface.cs
@@ -1,4 +1,4 @@
-using ChocolArm64.Memory;
+using ARMeilleure.Memory;
using Ryujinx.Common;
using Ryujinx.HLE.HOS.Ipc;
using Ryujinx.HLE.HOS.Kernel.Common;
diff --git a/Ryujinx.HLE/HOS/Services/Nv/INvDrvServices.cs b/Ryujinx.HLE/HOS/Services/Nv/INvDrvServices.cs
index 50ab7e01..261c1c5a 100644
--- a/Ryujinx.HLE/HOS/Services/Nv/INvDrvServices.cs
+++ b/Ryujinx.HLE/HOS/Services/Nv/INvDrvServices.cs
@@ -1,4 +1,4 @@
-using ChocolArm64.Memory;
+using ARMeilleure.Memory;
using Ryujinx.Common.Logging;
using Ryujinx.HLE.HOS.Ipc;
using Ryujinx.HLE.HOS.Kernel.Common;
diff --git a/Ryujinx.HLE/HOS/Services/Nv/NvGpuAS/NvGpuASIoctl.cs b/Ryujinx.HLE/HOS/Services/Nv/NvGpuAS/NvGpuASIoctl.cs
index 3b96ed6b..47d15a7e 100644
--- a/Ryujinx.HLE/HOS/Services/Nv/NvGpuAS/NvGpuASIoctl.cs
+++ b/Ryujinx.HLE/HOS/Services/Nv/NvGpuAS/NvGpuASIoctl.cs
@@ -1,4 +1,4 @@
-using ChocolArm64.Memory;
+using ARMeilleure.Memory;
using Ryujinx.Common.Logging;
using Ryujinx.Graphics.Memory;
using Ryujinx.HLE.HOS.Kernel.Process;
diff --git a/Ryujinx.HLE/HOS/Services/Nv/NvGpuGpu/NvGpuGpuIoctl.cs b/Ryujinx.HLE/HOS/Services/Nv/NvGpuGpu/NvGpuGpuIoctl.cs
index 4f276d5d..04b0c63c 100644
--- a/Ryujinx.HLE/HOS/Services/Nv/NvGpuGpu/NvGpuGpuIoctl.cs
+++ b/Ryujinx.HLE/HOS/Services/Nv/NvGpuGpu/NvGpuGpuIoctl.cs
@@ -1,4 +1,4 @@
-using ChocolArm64.Memory;
+using ARMeilleure.Memory;
using Ryujinx.Common.Logging;
using System;
using System.Diagnostics;
diff --git a/Ryujinx.HLE/HOS/Services/Nv/NvHostChannel/NvHostChannelIoctl.cs b/Ryujinx.HLE/HOS/Services/Nv/NvHostChannel/NvHostChannelIoctl.cs
index c5f29636..e7879f4a 100644
--- a/Ryujinx.HLE/HOS/Services/Nv/NvHostChannel/NvHostChannelIoctl.cs
+++ b/Ryujinx.HLE/HOS/Services/Nv/NvHostChannel/NvHostChannelIoctl.cs
@@ -1,4 +1,4 @@
-using ChocolArm64.Memory;
+using ARMeilleure.Memory;
using Ryujinx.Common.Logging;
using Ryujinx.Graphics.Memory;
using Ryujinx.HLE.HOS.Kernel.Process;
diff --git a/Ryujinx.HLE/HOS/Services/Nv/NvHostCtrl/NvHostCtrlIoctl.cs b/Ryujinx.HLE/HOS/Services/Nv/NvHostCtrl/NvHostCtrlIoctl.cs
index 35f1a949..2a84b677 100644
--- a/Ryujinx.HLE/HOS/Services/Nv/NvHostCtrl/NvHostCtrlIoctl.cs
+++ b/Ryujinx.HLE/HOS/Services/Nv/NvHostCtrl/NvHostCtrlIoctl.cs
@@ -1,4 +1,4 @@
-using ChocolArm64.Memory;
+using ARMeilleure.Memory;
using Ryujinx.Common.Logging;
using Ryujinx.HLE.HOS.Kernel.Process;
using System;
diff --git a/Ryujinx.HLE/HOS/Services/Nv/NvMap/NvMapIoctl.cs b/Ryujinx.HLE/HOS/Services/Nv/NvMap/NvMapIoctl.cs
index 72286662..d9c579a2 100644
--- a/Ryujinx.HLE/HOS/Services/Nv/NvMap/NvMapIoctl.cs
+++ b/Ryujinx.HLE/HOS/Services/Nv/NvMap/NvMapIoctl.cs
@@ -1,4 +1,4 @@
-using ChocolArm64.Memory;
+using ARMeilleure.Memory;
using Ryujinx.Common.Logging;
using Ryujinx.Graphics.Memory;
using Ryujinx.HLE.HOS.Kernel.Process;
diff --git a/Ryujinx.HLE/HOS/Services/Time/Clock/StandardSteadyClockCore.cs b/Ryujinx.HLE/HOS/Services/Time/Clock/StandardSteadyClockCore.cs
index fea5bf2f..5b2d6c84 100644
--- a/Ryujinx.HLE/HOS/Services/Time/Clock/StandardSteadyClockCore.cs
+++ b/Ryujinx.HLE/HOS/Services/Time/Clock/StandardSteadyClockCore.cs
@@ -40,7 +40,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.Clock
ClockSourceId = GetClockSourceId()
};
- TimeSpanType ticksTimeSpan = TimeSpanType.FromTicks(thread.Context.ThreadState.CntpctEl0, thread.Context.ThreadState.CntfrqEl0);
+ TimeSpanType ticksTimeSpan = TimeSpanType.FromTicks(thread.Context.CntpctEl0, thread.Context.CntfrqEl0);
result.TimePoint = _setupValue + ticksTimeSpan.ToSeconds();
diff --git a/Ryujinx.HLE/HOS/Services/Time/Clock/TickBasedSteadyClockCore.cs b/Ryujinx.HLE/HOS/Services/Time/Clock/TickBasedSteadyClockCore.cs
index 7a69b014..6cd4c80b 100644
--- a/Ryujinx.HLE/HOS/Services/Time/Clock/TickBasedSteadyClockCore.cs
+++ b/Ryujinx.HLE/HOS/Services/Time/Clock/TickBasedSteadyClockCore.cs
@@ -30,7 +30,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.Clock
ClockSourceId = GetClockSourceId()
};
- TimeSpanType ticksTimeSpan = TimeSpanType.FromTicks(thread.Context.ThreadState.CntpctEl0, thread.Context.ThreadState.CntfrqEl0);
+ TimeSpanType ticksTimeSpan = TimeSpanType.FromTicks(thread.Context.CntpctEl0, thread.Context.CntfrqEl0);
result.TimePoint = ticksTimeSpan.ToSeconds();
diff --git a/Ryujinx.HLE/HOS/Services/Time/IStaticService.cs b/Ryujinx.HLE/HOS/Services/Time/IStaticService.cs
index 9ee038d5..d9c5b4f2 100644
--- a/Ryujinx.HLE/HOS/Services/Time/IStaticService.cs
+++ b/Ryujinx.HLE/HOS/Services/Time/IStaticService.cs
@@ -141,7 +141,7 @@ namespace Ryujinx.HLE.HOS.Services.Time
if (currentTimePoint.ClockSourceId == otherContext.SteadyTimePoint.ClockSourceId)
{
- TimeSpanType ticksTimeSpan = TimeSpanType.FromTicks(context.Thread.Context.ThreadState.CntpctEl0, context.Thread.Context.ThreadState.CntfrqEl0);
+ TimeSpanType ticksTimeSpan = TimeSpanType.FromTicks(context.Thread.Context.CntpctEl0, context.Thread.Context.CntfrqEl0);
long baseTimePoint = otherContext.Offset + currentTimePoint.TimePoint - ticksTimeSpan.ToSeconds();
context.ResponseData.Write(baseTimePoint);
diff --git a/Ryujinx.HLE/HOS/Services/Time/ITimeZoneService.cs b/Ryujinx.HLE/HOS/Services/Time/ITimeZoneService.cs
index 895bb1f3..b820de38 100644
--- a/Ryujinx.HLE/HOS/Services/Time/ITimeZoneService.cs
+++ b/Ryujinx.HLE/HOS/Services/Time/ITimeZoneService.cs
@@ -1,4 +1,4 @@
-using ChocolArm64.Memory;
+using ARMeilleure.Memory;
using Ryujinx.Common;
using Ryujinx.Common.Logging;
using Ryujinx.HLE.HOS.Services.Time.TimeZone;
@@ -106,7 +106,7 @@ namespace Ryujinx.HLE.HOS.Services.Time
string locationName = Encoding.ASCII.GetString(context.RequestData.ReadBytes(0x24)).TrimEnd('\0');
ResultCode resultCode = TimeZoneManager.Instance.LoadTimeZoneRules(out TimeZoneRule rules, locationName);
-
+
// Write TimeZoneRule if success
if (resultCode == 0)
{
diff --git a/Ryujinx.HLE/HOS/Services/Vi/IApplicationDisplayService.cs b/Ryujinx.HLE/HOS/Services/Vi/IApplicationDisplayService.cs
index 2f1e68e8..15db6ff2 100644
--- a/Ryujinx.HLE/HOS/Services/Vi/IApplicationDisplayService.cs
+++ b/Ryujinx.HLE/HOS/Services/Vi/IApplicationDisplayService.cs
@@ -1,4 +1,4 @@
-using ChocolArm64.Memory;
+using ARMeilleure.Memory;
using Ryujinx.HLE.HOS.Ipc;
using Ryujinx.HLE.HOS.Kernel.Common;
using System;
diff --git a/Ryujinx.HLE/Ryujinx.HLE.csproj b/Ryujinx.HLE/Ryujinx.HLE.csproj
index 78e5c2a3..3a12a179 100644
--- a/Ryujinx.HLE/Ryujinx.HLE.csproj
+++ b/Ryujinx.HLE/Ryujinx.HLE.csproj
@@ -2,7 +2,7 @@
<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
- <RuntimeIdentifiers>win10-x64;osx-x64;linux-x64</RuntimeIdentifiers>
+ <RuntimeIdentifiers>win-x64;osx-x64;linux-x64</RuntimeIdentifiers>
<Configurations>Debug;Release;Profile Debug;Profile Release</Configurations>
<LangVersion>7.1</LangVersion>
</PropertyGroup>
@@ -38,16 +38,18 @@
</ItemGroup>
<ItemGroup>
- <ProjectReference Include="..\ChocolArm64\ChocolArm64.csproj" />
<ProjectReference Include="..\Ryujinx.Audio\Ryujinx.Audio.csproj" />
<ProjectReference Include="..\Ryujinx.Common\Ryujinx.Common.csproj" />
<ProjectReference Include="..\Ryujinx.Graphics\Ryujinx.Graphics.csproj" />
<ProjectReference Include="..\Ryujinx.Profiler\Ryujinx.Profiler.csproj" />
+ <ProjectReference Include="..\ARMeilleure\ARMeilleure.csproj" />
+ <ProjectReference Include="..\ChocolArm64\ChocolArm64.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Concentus" Version="1.1.7" />
<PackageReference Include="LibHac" Version="0.5.0" />
+ <PackageReference Include="System.Runtime.Intrinsics.Experimental" Version="4.5.0-rc1" />
<PackageReference Include="TimeZoneConverter.Posix" Version="2.1.0" />
</ItemGroup>
diff --git a/Ryujinx.HLE/Utilities/StructReader.cs b/Ryujinx.HLE/Utilities/StructReader.cs
index 441dfd19..36e5c7d1 100644
--- a/Ryujinx.HLE/Utilities/StructReader.cs
+++ b/Ryujinx.HLE/Utilities/StructReader.cs
@@ -1,15 +1,15 @@
-using ChocolArm64.Memory;
+using ARMeilleure.Memory;
using System.Runtime.InteropServices;
namespace Ryujinx.HLE.Utilities
{
class StructReader
{
- private MemoryManager _memory;
+ private IMemoryManager _memory;
public long Position { get; private set; }
- public StructReader(MemoryManager memory, long position)
+ public StructReader(IMemoryManager memory, long position)
{
_memory = memory;
Position = position;
diff --git a/Ryujinx.HLE/Utilities/StructWriter.cs b/Ryujinx.HLE/Utilities/StructWriter.cs
index 86cfeedd..c156956d 100644
--- a/Ryujinx.HLE/Utilities/StructWriter.cs
+++ b/Ryujinx.HLE/Utilities/StructWriter.cs
@@ -1,15 +1,15 @@
-using ChocolArm64.Memory;
+using ARMeilleure.Memory;
using System.Runtime.InteropServices;
namespace Ryujinx.HLE.Utilities
{
class StructWriter
{
- private MemoryManager _memory;
+ private IMemoryManager _memory;
public long Position { get; private set; }
- public StructWriter(MemoryManager memory, long position)
+ public StructWriter(IMemoryManager memory, long position)
{
_memory = memory;
Position = position;