diff options
| author | 2020-12-27 21:08:31 -0800 | |
|---|---|---|
| committer | 2021-01-11 14:23:16 -0800 | |
| commit | 7420a717e6b69d223ea021ae3515538b325a54a4 (patch) | |
| tree | ac44eb0516347e5ceb96569a1c52cd62da0e45f1 | |
| parent | core: hle: kernel: svc_types: Add type definitions for KAddressArbiter. (diff) | |
| download | yuzu-7420a717e6b69d223ea021ae3515538b325a54a4.tar.gz yuzu-7420a717e6b69d223ea021ae3515538b325a54a4.tar.xz yuzu-7420a717e6b69d223ea021ae3515538b325a54a4.zip | |
core: hle: kernel: Add some useful functions for checking kernel addresses.
| -rw-r--r-- | src/core/hle/kernel/memory/memory_layout.h | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/core/hle/kernel/memory/memory_layout.h b/src/core/hle/kernel/memory/memory_layout.h index 9b3d6267a..c7c0b2f49 100644 --- a/src/core/hle/kernel/memory/memory_layout.h +++ b/src/core/hle/kernel/memory/memory_layout.h | |||
| @@ -5,9 +5,28 @@ | |||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include "common/common_types.h" | 7 | #include "common/common_types.h" |
| 8 | #include "core/device_memory.h" | ||
| 8 | 9 | ||
| 9 | namespace Kernel::Memory { | 10 | namespace Kernel::Memory { |
| 10 | 11 | ||
| 12 | constexpr std::size_t KernelAslrAlignment = 2 * 1024 * 1024; | ||
| 13 | constexpr std::size_t KernelVirtualAddressSpaceWidth = 1ULL << 39; | ||
| 14 | constexpr std::size_t KernelPhysicalAddressSpaceWidth = 1ULL << 48; | ||
| 15 | constexpr std::size_t KernelVirtualAddressSpaceBase = 0ULL - KernelVirtualAddressSpaceWidth; | ||
| 16 | constexpr std::size_t KernelVirtualAddressSpaceEnd = | ||
| 17 | KernelVirtualAddressSpaceBase + (KernelVirtualAddressSpaceWidth - KernelAslrAlignment); | ||
| 18 | constexpr std::size_t KernelVirtualAddressSpaceLast = KernelVirtualAddressSpaceEnd - 1; | ||
| 19 | constexpr std::size_t KernelVirtualAddressSpaceSize = | ||
| 20 | KernelVirtualAddressSpaceEnd - KernelVirtualAddressSpaceBase; | ||
| 21 | |||
| 22 | constexpr bool IsKernelAddressKey(VAddr key) { | ||
| 23 | return KernelVirtualAddressSpaceBase <= key && key <= KernelVirtualAddressSpaceLast; | ||
| 24 | } | ||
| 25 | |||
| 26 | constexpr bool IsKernelAddress(VAddr address) { | ||
| 27 | return KernelVirtualAddressSpaceBase <= address && address < KernelVirtualAddressSpaceEnd; | ||
| 28 | } | ||
| 29 | |||
| 11 | class MemoryRegion final { | 30 | class MemoryRegion final { |
| 12 | friend class MemoryLayout; | 31 | friend class MemoryLayout; |
| 13 | 32 | ||