CpuContext.cs 859 B

1234567891011121314151617181920212223242526272829303132
  1. using ARMeilleure.Memory;
  2. using ARMeilleure.State;
  3. using ARMeilleure.Translation;
  4. namespace Ryujinx.Cpu
  5. {
  6. public class CpuContext
  7. {
  8. private readonly Translator _translator;
  9. public CpuContext(IMemoryManager memory, bool for64Bit)
  10. {
  11. _translator = new Translator(new JitMemoryAllocator(), memory, for64Bit);
  12. memory.UnmapEvent += UnmapHandler;
  13. }
  14. private void UnmapHandler(ulong address, ulong size)
  15. {
  16. _translator.InvalidateJitCacheRegion(address, size);
  17. }
  18. public static ExecutionContext CreateExecutionContext()
  19. {
  20. return new ExecutionContext(new JitMemoryAllocator());
  21. }
  22. public void Execute(ExecutionContext context, ulong address)
  23. {
  24. _translator.Execute(context, address);
  25. }
  26. }
  27. }