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