MockVirtualMemoryManager.cs 2.9 KB

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