ArmProcessContext.cs 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. using ARMeilleure.Memory;
  2. using ARMeilleure.State;
  3. using Ryujinx.Cpu;
  4. using Ryujinx.HLE.HOS.Kernel.Process;
  5. using Ryujinx.Memory;
  6. namespace Ryujinx.HLE.HOS
  7. {
  8. class ArmProcessContext<T> : IProcessContext where T : class, IVirtualMemoryManager, IMemoryManager
  9. {
  10. private readonly CpuContext _cpuContext;
  11. private T _memoryManager;
  12. public IVirtualMemoryManager AddressSpace => _memoryManager;
  13. public ArmProcessContext(T memoryManager, bool for64Bit)
  14. {
  15. if (memoryManager is IRefCounted rc)
  16. {
  17. rc.IncrementReferenceCount();
  18. }
  19. _memoryManager = memoryManager;
  20. _cpuContext = new CpuContext(memoryManager, for64Bit);
  21. }
  22. public void Execute(ExecutionContext context, ulong codeAddress)
  23. {
  24. _cpuContext.Execute(context, codeAddress);
  25. }
  26. public void Dispose()
  27. {
  28. if (_memoryManager is IRefCounted rc)
  29. {
  30. rc.DecrementReferenceCount();
  31. _memoryManager = null;
  32. }
  33. }
  34. }
  35. }