From cee712105850ac3385cd0091a923438167433f9f Mon Sep 17 00:00:00 2001 From: TSR Berry <20988865+TSRBerry@users.noreply.github.com> Date: Sat, 8 Apr 2023 01:22:00 +0200 Subject: Move solution and projects to src --- src/Ryujinx.Memory/Tracking/AbstractRegion.cs | 73 +++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 src/Ryujinx.Memory/Tracking/AbstractRegion.cs (limited to 'src/Ryujinx.Memory/Tracking/AbstractRegion.cs') diff --git a/src/Ryujinx.Memory/Tracking/AbstractRegion.cs b/src/Ryujinx.Memory/Tracking/AbstractRegion.cs new file mode 100644 index 00000000..bd4c8ab5 --- /dev/null +++ b/src/Ryujinx.Memory/Tracking/AbstractRegion.cs @@ -0,0 +1,73 @@ +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); + } +} -- cgit v1.2.3