diff options
author | Lioncash <mathew1800@gmail.com> | 2019-03-04 22:30:17 +0100 |
---|---|---|
committer | Lioncash <mathew1800@gmail.com> | 2019-03-04 22:32:03 +0100 |
commit | 0be8fffc992e30da42004b4e640b7095e1040f53 (patch) | |
tree | d9827c3b2549658e220ee5bf78f26b6e021e83dc /src/core/hle/kernel/vm_manager.cpp | |
parent | Merge pull request #2165 from ReinUsesLisp/unbind-tex (diff) | |
download | yuzu-0be8fffc992e30da42004b4e640b7095e1040f53.tar yuzu-0be8fffc992e30da42004b4e640b7095e1040f53.tar.gz yuzu-0be8fffc992e30da42004b4e640b7095e1040f53.tar.bz2 yuzu-0be8fffc992e30da42004b4e640b7095e1040f53.tar.lz yuzu-0be8fffc992e30da42004b4e640b7095e1040f53.tar.xz yuzu-0be8fffc992e30da42004b4e640b7095e1040f53.tar.zst yuzu-0be8fffc992e30da42004b4e640b7095e1040f53.zip |
Diffstat (limited to '')
-rw-r--r-- | src/core/hle/kernel/vm_manager.cpp | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/src/core/hle/kernel/vm_manager.cpp b/src/core/hle/kernel/vm_manager.cpp index 10ad94aa6..56f3d1f79 100644 --- a/src/core/hle/kernel/vm_manager.cpp +++ b/src/core/hle/kernel/vm_manager.cpp @@ -17,8 +17,8 @@ #include "core/memory_setup.h" namespace Kernel { - -static const char* GetMemoryStateName(MemoryState state) { +namespace { +const char* GetMemoryStateName(MemoryState state) { static constexpr const char* names[] = { "Unmapped", "Io", "Normal", "CodeStatic", @@ -35,6 +35,14 @@ static const char* GetMemoryStateName(MemoryState state) { return names[ToSvcMemoryState(state)]; } +// Checks if a given address range lies within a larger address range. +constexpr bool IsInsideAddressRange(VAddr address, u64 size, VAddr address_range_begin, + VAddr address_range_end) { + const VAddr end_address = address + size - 1; + return address_range_begin <= address && end_address <= address_range_end - 1; +} +} // Anonymous namespace + bool VirtualMemoryArea::CanBeMergedWith(const VirtualMemoryArea& next) const { ASSERT(base + size == next.base); if (permissions != next.permissions || state != next.state || attribute != next.attribute || @@ -706,6 +714,11 @@ u64 VMManager::GetAddressSpaceWidth() const { return address_space_width; } +bool VMManager::IsWithinAddressSpace(VAddr address, u64 size) const { + return IsInsideAddressRange(address, size, GetAddressSpaceBaseAddress(), + GetAddressSpaceEndAddress()); +} + VAddr VMManager::GetASLRRegionBaseAddress() const { return aslr_region_base; } @@ -786,6 +799,11 @@ u64 VMManager::GetNewMapRegionSize() const { return new_map_region_end - new_map_region_base; } +bool VMManager::IsWithinNewMapRegion(VAddr address, u64 size) const { + return IsInsideAddressRange(address, size, GetNewMapRegionBaseAddress(), + GetNewMapRegionEndAddress()); +} + VAddr VMManager::GetTLSIORegionBaseAddress() const { return tls_io_region_base; } |