CpuContext.cs 1.1 KB

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