MockVirtualMemoryManager.cs 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. using Ryujinx.Memory.Range;
  2. using System;
  3. using System.Collections.Generic;
  4. namespace Ryujinx.Memory.Tests
  5. {
  6. class MockVirtualMemoryManager : IVirtualMemoryManager
  7. {
  8. public bool NoMappings = false;
  9. public event Action<ulong, ulong, MemoryPermission> OnProtect;
  10. public MockVirtualMemoryManager(ulong size, int pageSize)
  11. {
  12. }
  13. public void Map(ulong va, nuint hostAddress, ulong size)
  14. {
  15. throw new NotImplementedException();
  16. }
  17. public void Unmap(ulong va, ulong size)
  18. {
  19. throw new NotImplementedException();
  20. }
  21. public T Read<T>(ulong va) where T : unmanaged
  22. {
  23. throw new NotImplementedException();
  24. }
  25. public void Read(ulong va, Span<byte> data)
  26. {
  27. throw new NotImplementedException();
  28. }
  29. public void Write<T>(ulong va, T value) where T : unmanaged
  30. {
  31. throw new NotImplementedException();
  32. }
  33. public void Write(ulong va, ReadOnlySpan<byte> data)
  34. {
  35. throw new NotImplementedException();
  36. }
  37. public ReadOnlySpan<byte> GetSpan(ulong va, int size, bool tracked = false)
  38. {
  39. throw new NotImplementedException();
  40. }
  41. public WritableRegion GetWritableRegion(ulong va, int size, bool tracked = false)
  42. {
  43. throw new NotImplementedException();
  44. }
  45. public ref T GetRef<T>(ulong va) where T : unmanaged
  46. {
  47. throw new NotImplementedException();
  48. }
  49. IEnumerable<HostMemoryRange> IVirtualMemoryManager.GetPhysicalRegions(ulong va, ulong size)
  50. {
  51. return NoMappings ? new HostMemoryRange[0] : new HostMemoryRange[] { new HostMemoryRange((nuint)va, size) };
  52. }
  53. public bool IsMapped(ulong va)
  54. {
  55. return true;
  56. }
  57. public bool IsRangeMapped(ulong va, ulong size)
  58. {
  59. return true;
  60. }
  61. public ulong GetPhysicalAddress(ulong va)
  62. {
  63. throw new NotImplementedException();
  64. }
  65. public void SignalMemoryTracking(ulong va, ulong size, bool write)
  66. {
  67. throw new NotImplementedException();
  68. }
  69. public void TrackingReprotect(ulong va, ulong size, MemoryPermission protection)
  70. {
  71. OnProtect?.Invoke(va, size, protection);
  72. }
  73. }
  74. }