using System; namespace ARMeilleure.Memory { public interface IMemoryManager { int AddressSpaceBits { get; } IntPtr PageTablePointer { get; } MemoryManagerType Type { get; } event Action UnmapEvent; /// /// Reads data from CPU mapped memory. /// /// Type of the data being read /// Virtual address of the data in memory /// The data T Read(ulong va) where T : unmanaged; /// /// Reads data from CPU mapped memory, with read tracking /// /// Type of the data being read /// Virtual address of the data in memory /// The data T ReadTracked(ulong va) where T : unmanaged; /// /// Writes data to CPU mapped memory. /// /// Type of the data being written /// Virtual address to write the data into /// Data to be written void Write(ulong va, T value) where T : unmanaged; /// /// Gets a read-only span of data from CPU mapped memory. /// /// Virtual address of the data /// Size of the data /// True if read tracking is triggered on the span /// A read-only span of the data ReadOnlySpan GetSpan(ulong va, int size, bool tracked = false); /// /// Gets a reference for the given type at the specified virtual memory address. /// /// /// The data must be located at a contiguous memory region. /// /// Type of the data to get the reference /// Virtual address of the data /// A reference to the data in memory ref T GetRef(ulong va) where T : unmanaged; /// /// Checks if the page at a given CPU virtual address is mapped. /// /// Virtual address to check /// True if the address is mapped, false otherwise bool IsMapped(ulong va); /// /// Alerts the memory tracking that a given region has been read from or written to. /// This should be called before read/write is performed. /// /// Virtual address of the region /// Size of the region /// True if the region was written, false if read /// True if the access is precise, false otherwise /// Optional ID of the handles that should not be signalled void SignalMemoryTracking(ulong va, ulong size, bool write, bool precise = false, int? exemptId = null); } }