summaryrefslogtreecommitdiffstats
path: root/src/core/hle/kernel
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2020-12-28 06:08:31 +0100
committerbunnei <bunneidev@gmail.com>2021-01-11 23:23:16 +0100
commit7420a717e6b69d223ea021ae3515538b325a54a4 (patch)
treeac44eb0516347e5ceb96569a1c52cd62da0e45f1 /src/core/hle/kernel
parentcore: hle: kernel: svc_types: Add type definitions for KAddressArbiter. (diff)
downloadyuzu-7420a717e6b69d223ea021ae3515538b325a54a4.tar
yuzu-7420a717e6b69d223ea021ae3515538b325a54a4.tar.gz
yuzu-7420a717e6b69d223ea021ae3515538b325a54a4.tar.bz2
yuzu-7420a717e6b69d223ea021ae3515538b325a54a4.tar.lz
yuzu-7420a717e6b69d223ea021ae3515538b325a54a4.tar.xz
yuzu-7420a717e6b69d223ea021ae3515538b325a54a4.tar.zst
yuzu-7420a717e6b69d223ea021ae3515538b325a54a4.zip
Diffstat (limited to 'src/core/hle/kernel')
-rw-r--r--src/core/hle/kernel/memory/memory_layout.h19
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 @@
#pragma once
#include "common/common_types.h"
+#include "core/device_memory.h"
namespace Kernel::Memory {
+constexpr std::size_t KernelAslrAlignment = 2 * 1024 * 1024;
+constexpr std::size_t KernelVirtualAddressSpaceWidth = 1ULL << 39;
+constexpr std::size_t KernelPhysicalAddressSpaceWidth = 1ULL << 48;
+constexpr std::size_t KernelVirtualAddressSpaceBase = 0ULL - KernelVirtualAddressSpaceWidth;
+constexpr std::size_t KernelVirtualAddressSpaceEnd =
+ KernelVirtualAddressSpaceBase + (KernelVirtualAddressSpaceWidth - KernelAslrAlignment);
+constexpr std::size_t KernelVirtualAddressSpaceLast = KernelVirtualAddressSpaceEnd - 1;
+constexpr std::size_t KernelVirtualAddressSpaceSize =
+ KernelVirtualAddressSpaceEnd - KernelVirtualAddressSpaceBase;
+
+constexpr bool IsKernelAddressKey(VAddr key) {
+ return KernelVirtualAddressSpaceBase <= key && key <= KernelVirtualAddressSpaceLast;
+}
+
+constexpr bool IsKernelAddress(VAddr address) {
+ return KernelVirtualAddressSpaceBase <= address && address < KernelVirtualAddressSpaceEnd;
+}
+
class MemoryRegion final {
friend class MemoryLayout;