using Ryujinx.Memory.Range; namespace Ryujinx.Memory.Tracking { /// /// A region of memory. /// abstract class AbstractRegion : INonOverlappingRange { /// /// Base address. /// public ulong Address { get; } /// /// Size of the range in bytes. /// public ulong Size { get; protected set; } /// /// End address. /// public ulong EndAddress => Address + Size; /// /// Create a new region. /// /// Base address /// Size of the range protected AbstractRegion(ulong address, ulong size) { Address = address; Size = size; } /// /// Check if this range overlaps with another. /// /// Base address /// Size of the range /// True if overlapping, false otherwise public bool OverlapsWith(ulong address, ulong size) { return Address < address + size && address < EndAddress; } /// /// Signals to the handles that a memory event has occurred, and unprotects the region. Assumes that the tracking lock has been obtained. /// /// Address accessed /// Size of the region affected in bytes /// Whether the region was written to or read /// Optional ID of the handles that should not be signalled public abstract void Signal(ulong address, ulong size, bool write, int? exemptId); /// /// Signals to the handles that a precise memory event has occurred. Assumes that the tracking lock has been obtained. /// /// Address accessed /// Size of the region affected in bytes /// Whether the region was written to or read /// Optional ID of the handles that should not be signalled public abstract void SignalPrecise(ulong address, ulong size, bool write, int? exemptId); /// /// Split this region into two, around the specified address. /// This region is updated to end at the split address, and a new region is created to represent past that point. /// /// Address to split the region around /// The second part of the split region, with start address at the given split. public abstract INonOverlappingRange Split(ulong splitAddress); } }