MockVirtualMemoryManager.cs 3.3 KB

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