summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/core/CMakeLists.txt1
-rw-r--r--src/core/hle/kernel/k_memory_region.h36
-rw-r--r--src/core/hle/kernel/k_memory_region_type.h22
3 files changed, 41 insertions, 18 deletions
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt
index d9eea00ca..299f1ed13 100644
--- a/src/core/CMakeLists.txt
+++ b/src/core/CMakeLists.txt
@@ -173,6 +173,7 @@ add_library(core STATIC
hle/kernel/k_memory_manager.cpp
hle/kernel/k_memory_manager.h
hle/kernel/k_memory_region.h
+ hle/kernel/k_memory_region_type.h
hle/kernel/k_page_bitmap.h
hle/kernel/k_page_heap.cpp
hle/kernel/k_page_heap.h
diff --git a/src/core/hle/kernel/k_memory_region.h b/src/core/hle/kernel/k_memory_region.h
index de236df6a..afa89011c 100644
--- a/src/core/hle/kernel/k_memory_region.h
+++ b/src/core/hle/kernel/k_memory_region.h
@@ -7,15 +7,26 @@
#include "common/assert.h"
#include "common/common_types.h"
#include "common/intrusive_red_black_tree.h"
+#include "core/hle/kernel/k_memory_region_type.h"
namespace Kernel {
class KMemoryRegion final : public Common::IntrusiveRedBlackTreeBaseNode<KMemoryRegion>,
NonCopyable {
- friend class KMemoryLayout;
friend class KMemoryRegionTree;
public:
+ constexpr KMemoryRegion() = default;
+ constexpr KMemoryRegion(u64 address_, u64 last_address_)
+ : address{address_}, last_address{last_address_} {}
+ constexpr KMemoryRegion(u64 address_, u64 last_address_, u64 pair_address_, u32 attributes_,
+ u32 type_id_)
+ : address(address_), last_address(last_address_), pair_address(pair_address_),
+ attributes(attributes_), type_id(type_id_) {}
+ constexpr KMemoryRegion(u64 address_, u64 last_address_, u32 attributes_, u32 type_id_)
+ : KMemoryRegion(address_, last_address_, std::numeric_limits<uintptr_t>::max(), attributes_,
+ type_id_) {}
+
static constexpr int Compare(const KMemoryRegion& lhs, const KMemoryRegion& rhs) {
if (lhs.GetAddress() < rhs.GetAddress()) {
return -1;
@@ -68,9 +79,9 @@ public:
return (this->GetType() | type) == this->GetType();
}
- // constexpr bool HasTypeAttribute(KMemoryRegionAttr attr) const {
- // return (this->GetType() | attr) == this->GetType();
- //}
+ constexpr bool HasTypeAttribute(KMemoryRegionAttr attr) const {
+ return (this->GetType() | static_cast<u32>(attr)) == this->GetType();
+ }
constexpr bool CanDerive(u32 type) const {
return (this->GetType() | type) == type;
@@ -80,22 +91,11 @@ public:
pair_address = a;
}
- // constexpr void SetTypeAttribute(KMemoryRegionAttr attr) {
- // type_id |= attr;
- //}
+ constexpr void SetTypeAttribute(KMemoryRegionAttr attr) {
+ type_id |= static_cast<u32>(attr);
+ }
private:
- constexpr KMemoryRegion() = default;
- constexpr KMemoryRegion(u64 address_, u64 last_address_)
- : address{address_}, last_address{last_address_} {}
- constexpr KMemoryRegion(u64 address_, u64 last_address_, u64 pair_address_, u32 attributes_,
- u32 type_id_)
- : address(address_), last_address(last_address_), pair_address(pair_address_),
- attributes(attributes_), type_id(type_id_) {}
- constexpr KMemoryRegion(u64 address_, u64 last_address_, u32 attributes_, u32 type_id_)
- : KMemoryRegion(address_, last_address_, std::numeric_limits<uintptr_t>::max(), attributes_,
- type_id_) {}
-
const u64 address{};
const u64 last_address{};
u64 pair_address{};
diff --git a/src/core/hle/kernel/k_memory_region_type.h b/src/core/hle/kernel/k_memory_region_type.h
new file mode 100644
index 000000000..6fb5abde9
--- /dev/null
+++ b/src/core/hle/kernel/k_memory_region_type.h
@@ -0,0 +1,22 @@
+// Copyright 2021 yuzu Emulator Project
+// Licensed under GPLv2 or any later version
+// Refer to the license.txt file included.
+
+#pragma once
+
+#include "common/common_types.h"
+
+namespace Kernel {
+
+enum class KMemoryRegionType : u32 {};
+
+enum class KMemoryRegionAttr : typename std::underlying_type<KMemoryRegionType>::type {
+ CarveoutProtected = 0x04000000,
+ DidKernelMap = 0x08000000,
+ ShouldKernelMap = 0x10000000,
+ UserReadOnly = 0x20000000,
+ NoUserMap = 0x40000000,
+ LinearMapped = 0x80000000,
+};
+
+} // namespace Kernel