diff options
| author | TSR Berry <20988865+TSRBerry@users.noreply.github.com> | 2023-04-08 01:22:00 +0200 |
|---|---|---|
| committer | Mary <thog@protonmail.com> | 2023-04-27 23:51:14 +0200 |
| commit | cee712105850ac3385cd0091a923438167433f9f (patch) | |
| tree | 4a5274b21d8b7f938c0d0ce18736d3f2993b11b1 /src/Ryujinx.HLE/HOS/ArmProcessContext.cs | |
| parent | cd124bda587ef09668a971fa1cac1c3f0cfc9f21 (diff) | |
Move solution and projects to src
Diffstat (limited to 'src/Ryujinx.HLE/HOS/ArmProcessContext.cs')
| -rw-r--r-- | src/Ryujinx.HLE/HOS/ArmProcessContext.cs | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/src/Ryujinx.HLE/HOS/ArmProcessContext.cs b/src/Ryujinx.HLE/HOS/ArmProcessContext.cs new file mode 100644 index 00000000..6338edc1 --- /dev/null +++ b/src/Ryujinx.HLE/HOS/ArmProcessContext.cs @@ -0,0 +1,80 @@ +using ARMeilleure.Memory; +using Ryujinx.Cpu; +using Ryujinx.Graphics.Gpu; +using Ryujinx.HLE.HOS.Kernel.Process; +using Ryujinx.Memory; + +namespace Ryujinx.HLE.HOS +{ + interface IArmProcessContext : IProcessContext + { + IDiskCacheLoadState Initialize( + string titleIdText, + string displayVersion, + bool diskCacheEnabled, + ulong codeAddress, + ulong codeSize); + } + + class ArmProcessContext<T> : IArmProcessContext where T : class, IVirtualMemoryManagerTracked, IMemoryManager + { + private readonly ulong _pid; + private readonly GpuContext _gpuContext; + private readonly ICpuContext _cpuContext; + private T _memoryManager; + + public IVirtualMemoryManager AddressSpace => _memoryManager; + + public ArmProcessContext(ulong pid, ICpuEngine cpuEngine, GpuContext gpuContext, T memoryManager, bool for64Bit) + { + if (memoryManager is IRefCounted rc) + { + rc.IncrementReferenceCount(); + } + + gpuContext.RegisterProcess(pid, memoryManager); + + _pid = pid; + _gpuContext = gpuContext; + _cpuContext = cpuEngine.CreateCpuContext(memoryManager, for64Bit); + _memoryManager = memoryManager; + } + + public IExecutionContext CreateExecutionContext(ExceptionCallbacks exceptionCallbacks) + { + return _cpuContext.CreateExecutionContext(exceptionCallbacks); + } + + public void Execute(IExecutionContext context, ulong codeAddress) + { + _cpuContext.Execute(context, codeAddress); + } + + public IDiskCacheLoadState Initialize( + string titleIdText, + string displayVersion, + bool diskCacheEnabled, + ulong codeAddress, + ulong codeSize) + { + _cpuContext.PrepareCodeRange(codeAddress, codeSize); + return _cpuContext.LoadDiskCache(titleIdText, displayVersion, diskCacheEnabled); + } + + public void InvalidateCacheRegion(ulong address, ulong size) + { + _cpuContext.InvalidateCacheRegion(address, size); + } + + public void Dispose() + { + if (_memoryManager is IRefCounted rc) + { + rc.DecrementReferenceCount(); + + _memoryManager = null; + _gpuContext.UnregisterProcess(_pid); + } + } + } +} |
