diff options
Diffstat (limited to 'src/Ryujinx.Memory')
| -rw-r--r-- | src/Ryujinx.Memory/Range/IMultiRangeItem.cs | 18 | ||||
| -rw-r--r-- | src/Ryujinx.Memory/Range/MemoryRange.cs | 18 | ||||
| -rw-r--r-- | src/Ryujinx.Memory/Range/MultiRangeList.cs | 17 |
3 files changed, 37 insertions, 16 deletions
diff --git a/src/Ryujinx.Memory/Range/IMultiRangeItem.cs b/src/Ryujinx.Memory/Range/IMultiRangeItem.cs index 87fde246..5f9611c7 100644 --- a/src/Ryujinx.Memory/Range/IMultiRangeItem.cs +++ b/src/Ryujinx.Memory/Range/IMultiRangeItem.cs @@ -4,6 +4,22 @@ namespace Ryujinx.Memory.Range { MultiRange Range { get; } - ulong BaseAddress => Range.GetSubRange(0).Address; + ulong BaseAddress + { + get + { + for (int index = 0; index < Range.Count; index++) + { + MemoryRange subRange = Range.GetSubRange(index); + + if (!MemoryRange.IsInvalid(ref subRange)) + { + return subRange.Address; + } + } + + return MemoryRange.InvalidAddress; + } + } } } diff --git a/src/Ryujinx.Memory/Range/MemoryRange.cs b/src/Ryujinx.Memory/Range/MemoryRange.cs index 46aca9ba..20e9d00b 100644 --- a/src/Ryujinx.Memory/Range/MemoryRange.cs +++ b/src/Ryujinx.Memory/Range/MemoryRange.cs @@ -6,6 +6,11 @@ namespace Ryujinx.Memory.Range public readonly record struct MemoryRange { /// <summary> + /// Special address value used to indicate than an address is invalid. + /// </summary> + internal const ulong InvalidAddress = ulong.MaxValue; + + /// <summary> /// An empty memory range, with a null address and zero size. /// </summary> public static MemoryRange Empty => new(0UL, 0); @@ -59,12 +64,23 @@ namespace Ryujinx.Memory.Range } /// <summary> + /// Checks if a given sub-range of memory is invalid. + /// Those are used to represent unmapped memory regions (holes in the region mapping). + /// </summary> + /// <param name="subRange">Memory range to check</param> + /// <returns>True if the memory range is considered invalid, false otherwise</returns> + internal static bool IsInvalid(ref MemoryRange subRange) + { + return subRange.Address == InvalidAddress; + } + + /// <summary> /// Returns a string summary of the memory range. /// </summary> /// <returns>A string summary of the memory range</returns> public override string ToString() { - if (Address == ulong.MaxValue) + if (Address == InvalidAddress) { return $"[Unmapped 0x{Size:X}]"; } diff --git a/src/Ryujinx.Memory/Range/MultiRangeList.cs b/src/Ryujinx.Memory/Range/MultiRangeList.cs index 1804ff5c..c3c6ae79 100644 --- a/src/Ryujinx.Memory/Range/MultiRangeList.cs +++ b/src/Ryujinx.Memory/Range/MultiRangeList.cs @@ -30,7 +30,7 @@ namespace Ryujinx.Memory.Range { var subrange = range.GetSubRange(i); - if (IsInvalid(ref subrange)) + if (MemoryRange.IsInvalid(ref subrange)) { continue; } @@ -56,7 +56,7 @@ namespace Ryujinx.Memory.Range { var subrange = range.GetSubRange(i); - if (IsInvalid(ref subrange)) + if (MemoryRange.IsInvalid(ref subrange)) { continue; } @@ -99,7 +99,7 @@ namespace Ryujinx.Memory.Range { var subrange = range.GetSubRange(i); - if (IsInvalid(ref subrange)) + if (MemoryRange.IsInvalid(ref subrange)) { continue; } @@ -143,17 +143,6 @@ namespace Ryujinx.Memory.Range } /// <summary> - /// Checks if a given sub-range of memory is invalid. - /// Those are used to represent unmapped memory regions (holes in the region mapping). - /// </summary> - /// <param name="subRange">Memory range to checl</param> - /// <returns>True if the memory range is considered invalid, false otherwise</returns> - private static bool IsInvalid(ref MemoryRange subRange) - { - return subRange.Address == ulong.MaxValue; - } - - /// <summary> /// Gets all items on the list starting at the specified memory address. /// </summary> /// <param name="baseAddress">Base address to find</param> |
