mirror of
https://github.com/yuzu-emu/yuzu.git
synced 2024-07-04 23:31:19 +01:00
core: hle: kernel: Add some useful functions for checking kernel addresses.
This commit is contained in:
parent
4bbf173fc1
commit
7420a717e6
1 changed files with 19 additions and 0 deletions
|
@ -5,9 +5,28 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "common/common_types.h"
|
#include "common/common_types.h"
|
||||||
|
#include "core/device_memory.h"
|
||||||
|
|
||||||
namespace Kernel::Memory {
|
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 {
|
class MemoryRegion final {
|
||||||
friend class MemoryLayout;
|
friend class MemoryLayout;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue