From d0afc6605f623b54d9d297db7ed14b87ec30a6f6 Mon Sep 17 00:00:00 2001 From: merry Date: Sun, 13 Feb 2022 14:21:23 +0000 Subject: [PATCH] Call InvalidateCacheRegion --- Ryujinx.Cpu/CpuContext.cs | 2 +- Ryujinx.HLE/Debugger/Debugger.cs | 4 +- Ryujinx.HLE/Debugger/IDebuggableProcess.cs | 11 +++-- Ryujinx.HLE/HOS/ArmProcessContext.cs | 2 +- Ryujinx.HLE/HOS/Horizon.cs | 9 ++-- .../HOS/Kernel/Process/IProcessContext.cs | 2 +- Ryujinx.HLE/HOS/Kernel/Process/KProcess.cs | 49 +++++++++++++------ .../HOS/Kernel/Process/ProcessContext.cs | 2 +- 8 files changed, 52 insertions(+), 29 deletions(-) diff --git a/Ryujinx.Cpu/CpuContext.cs b/Ryujinx.Cpu/CpuContext.cs index 9c09746bf..56584b732 100644 --- a/Ryujinx.Cpu/CpuContext.cs +++ b/Ryujinx.Cpu/CpuContext.cs @@ -34,4 +34,4 @@ namespace Ryujinx.Cpu _translator.InvalidateJitCacheRegion(address, size); } } -} +} \ No newline at end of file diff --git a/Ryujinx.HLE/Debugger/Debugger.cs b/Ryujinx.HLE/Debugger/Debugger.cs index e7856e139..8df74651f 100644 --- a/Ryujinx.HLE/Debugger/Debugger.cs +++ b/Ryujinx.HLE/Debugger/Debugger.cs @@ -46,9 +46,10 @@ namespace Ryujinx.HLE.Debugger private ARMeilleure.State.ExecutionContext GetThread(long threadUid) => Device.System.DebugGetApplicationProcess().DebugGetThreadContext(threadUid); - private ARMeilleure.State.ExecutionContext[] GetThreads() => GetThreadIds().Select(GetThread).ToArray(); private IVirtualMemoryManager GetMemory() => Device.System.DebugGetApplicationProcess().CpuMemory; + private void InvalidateCacheRegion(ulong address, ulong size) => + Device.System.DebugGetApplicationProcess().InvalidateCacheRegion(address, size); const int GdbRegisterCount = 68; @@ -438,6 +439,7 @@ namespace Ryujinx.HLE.Debugger } GetMemory().Write(addr, data); + InvalidateCacheRegion(addr, len); ReplyOK(); } catch (InvalidMemoryRegionException) diff --git a/Ryujinx.HLE/Debugger/IDebuggableProcess.cs b/Ryujinx.HLE/Debugger/IDebuggableProcess.cs index 2e4943055..719888da4 100644 --- a/Ryujinx.HLE/Debugger/IDebuggableProcess.cs +++ b/Ryujinx.HLE/Debugger/IDebuggableProcess.cs @@ -4,9 +4,10 @@ namespace Ryujinx.HLE.Debugger { public interface IDebuggableProcess { - public void DebugStopAllThreads(); - public long[] DebugGetThreadUids(); - public ARMeilleure.State.ExecutionContext DebugGetThreadContext(long threadUid); - public IVirtualMemoryManager CpuMemory { get; } + void DebugStopAllThreads(); + long[] DebugGetThreadUids(); + ARMeilleure.State.ExecutionContext DebugGetThreadContext(long threadUid); + IVirtualMemoryManager CpuMemory { get; } + void InvalidateCacheRegion(ulong address, ulong size); } -} +} \ No newline at end of file diff --git a/Ryujinx.HLE/HOS/ArmProcessContext.cs b/Ryujinx.HLE/HOS/ArmProcessContext.cs index dfa01c1ff..8748407cd 100644 --- a/Ryujinx.HLE/HOS/ArmProcessContext.cs +++ b/Ryujinx.HLE/HOS/ArmProcessContext.cs @@ -52,4 +52,4 @@ namespace Ryujinx.HLE.HOS } } } -} +} \ No newline at end of file diff --git a/Ryujinx.HLE/HOS/Horizon.cs b/Ryujinx.HLE/HOS/Horizon.cs index af80bddcd..8c81be300 100644 --- a/Ryujinx.HLE/HOS/Horizon.cs +++ b/Ryujinx.HLE/HOS/Horizon.cs @@ -10,6 +10,7 @@ using Ryujinx.Audio.Integration; using Ryujinx.Audio.Output; using Ryujinx.Audio.Renderer.Device; using Ryujinx.Audio.Renderer.Server; +using Ryujinx.HLE.Debugger; using Ryujinx.HLE.FileSystem; using Ryujinx.HLE.HOS.Kernel; using Ryujinx.HLE.HOS.Kernel.Memory; @@ -468,7 +469,7 @@ namespace Ryujinx.HLE.HOS AudioRendererManager.Dispose(); LibHacHorizonManager.PmClient.Fs.UnregisterProgram(LibHacHorizonManager.ApplicationClient.Os.GetCurrentProcessId().Value).ThrowIfFailure(); - + KernelContext.Dispose(); } } @@ -500,12 +501,12 @@ namespace Ryujinx.HLE.HOS IsPaused = pause; } - public Debugger.IDebuggableProcess DebugGetApplicationProcess() + public IDebuggableProcess DebugGetApplicationProcess() { lock (KernelContext.Processes) { - return KernelContext.Processes.Values.Where(x => x.IsApplication).First(); + return KernelContext.Processes.Values.First(x => x.IsApplication).GdbStubInterface; } } } -} +} \ No newline at end of file diff --git a/Ryujinx.HLE/HOS/Kernel/Process/IProcessContext.cs b/Ryujinx.HLE/HOS/Kernel/Process/IProcessContext.cs index 707e6d981..0321dca7f 100644 --- a/Ryujinx.HLE/HOS/Kernel/Process/IProcessContext.cs +++ b/Ryujinx.HLE/HOS/Kernel/Process/IProcessContext.cs @@ -11,4 +11,4 @@ namespace Ryujinx.HLE.HOS.Kernel.Process void Execute(ExecutionContext context, ulong codeAddress); void InvalidateCacheRegion(ulong address, ulong size); } -} +} \ No newline at end of file diff --git a/Ryujinx.HLE/HOS/Kernel/Process/KProcess.cs b/Ryujinx.HLE/HOS/Kernel/Process/KProcess.cs index fd0db3255..09a0136be 100644 --- a/Ryujinx.HLE/HOS/Kernel/Process/KProcess.cs +++ b/Ryujinx.HLE/HOS/Kernel/Process/KProcess.cs @@ -2,6 +2,7 @@ using ARMeilleure.State; using Ryujinx.Common; using Ryujinx.Common.Logging; using Ryujinx.Cpu; +using Ryujinx.HLE.Debugger; using Ryujinx.HLE.Exceptions; using Ryujinx.HLE.HOS.Kernel.Common; using Ryujinx.HLE.HOS.Kernel.Memory; @@ -14,7 +15,7 @@ using System.Threading; namespace Ryujinx.HLE.HOS.Kernel.Process { - class KProcess : KSynchronizationObject, Debugger.IDebuggableProcess + class KProcess : KSynchronizationObject { public const int KernelVersionMajor = 10; public const int KernelVersionMinor = 4; @@ -89,6 +90,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Process public IVirtualMemoryManager CpuMemory => Context.AddressSpace; public HleProcessDebugger Debugger { get; private set; } + public IDebuggableProcess GdbStubInterface { get { return new DebuggerInterface(this); } } public KProcess(KernelContext context) : base(context) { @@ -1191,30 +1193,47 @@ namespace Ryujinx.HLE.HOS.Kernel.Process return false; } - public void DebugStopAllThreads() + private class DebuggerInterface : IDebuggableProcess { - lock (_threadingLock) + private readonly KProcess _parent; + + public DebuggerInterface(KProcess p) { - foreach (KThread thread in _threads) + _parent = p; + } + + public void DebugStopAllThreads() + { + lock (_parent._threadingLock) { - thread.Context.DebugStop(); + foreach (KThread thread in _parent._threads) + { + thread.Context.DebugStop(); + } } } - } - public long[] DebugGetThreadUids() - { - lock (_threadingLock) + public long[] DebugGetThreadUids() { - return _threads.Select(x => x.ThreadUid).ToArray(); + lock (_parent._threadingLock) + { + return _parent._threads.Select(x => x.ThreadUid).ToArray(); + } } - } - public ARMeilleure.State.ExecutionContext DebugGetThreadContext(long threadUid) - { - lock (_threadingLock) + public ARMeilleure.State.ExecutionContext DebugGetThreadContext(long threadUid) { - return _threads.Where(x => x.ThreadUid == threadUid).FirstOrDefault()?.Context; + lock (_parent._threadingLock) + { + return _parent._threads.FirstOrDefault(x => x.ThreadUid == threadUid)?.Context; + } + } + + public IVirtualMemoryManager CpuMemory { get { return _parent.CpuMemory; } } + + public void InvalidateCacheRegion(ulong address, ulong size) + { + _parent.Context.InvalidateCacheRegion(address, size); } } } diff --git a/Ryujinx.HLE/HOS/Kernel/Process/ProcessContext.cs b/Ryujinx.HLE/HOS/Kernel/Process/ProcessContext.cs index bb3a15570..e803f508c 100644 --- a/Ryujinx.HLE/HOS/Kernel/Process/ProcessContext.cs +++ b/Ryujinx.HLE/HOS/Kernel/Process/ProcessContext.cs @@ -26,4 +26,4 @@ namespace Ryujinx.HLE.HOS.Kernel.Process { } } -} +} \ No newline at end of file