diff options
| author | 2021-02-13 01:07:23 -0800 | |
|---|---|---|
| committer | 2021-03-21 14:45:02 -0700 | |
| commit | 541b4353e4a85a1f10c53d643ea48b8e31363a62 (patch) | |
| tree | 4546b14777c69cf74bbbdedfa50dfd904d8e8f59 /src | |
| parent | hle: kernel: Move KMemoryRegion to its own module and update. (diff) | |
| download | yuzu-541b4353e4a85a1f10c53d643ea48b8e31363a62.tar.gz yuzu-541b4353e4a85a1f10c53d643ea48b8e31363a62.tar.xz yuzu-541b4353e4a85a1f10c53d643ea48b8e31363a62.zip | |
hle: kernel: Add initial KMemoryRegionType module.
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/CMakeLists.txt | 1 | ||||
| -rw-r--r-- | src/core/hle/kernel/k_memory_region.h | 36 | ||||
| -rw-r--r-- | src/core/hle/kernel/k_memory_region_type.h | 22 |
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 | |||
| 173 | hle/kernel/k_memory_manager.cpp | 173 | hle/kernel/k_memory_manager.cpp |
| 174 | hle/kernel/k_memory_manager.h | 174 | hle/kernel/k_memory_manager.h |
| 175 | hle/kernel/k_memory_region.h | 175 | hle/kernel/k_memory_region.h |
| 176 | hle/kernel/k_memory_region_type.h | ||
| 176 | hle/kernel/k_page_bitmap.h | 177 | hle/kernel/k_page_bitmap.h |
| 177 | hle/kernel/k_page_heap.cpp | 178 | hle/kernel/k_page_heap.cpp |
| 178 | hle/kernel/k_page_heap.h | 179 | 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 @@ | |||
| 7 | #include "common/assert.h" | 7 | #include "common/assert.h" |
| 8 | #include "common/common_types.h" | 8 | #include "common/common_types.h" |
| 9 | #include "common/intrusive_red_black_tree.h" | 9 | #include "common/intrusive_red_black_tree.h" |
| 10 | #include "core/hle/kernel/k_memory_region_type.h" | ||
| 10 | 11 | ||
| 11 | namespace Kernel { | 12 | namespace Kernel { |
| 12 | 13 | ||
| 13 | class KMemoryRegion final : public Common::IntrusiveRedBlackTreeBaseNode<KMemoryRegion>, | 14 | class KMemoryRegion final : public Common::IntrusiveRedBlackTreeBaseNode<KMemoryRegion>, |
| 14 | NonCopyable { | 15 | NonCopyable { |
| 15 | friend class KMemoryLayout; | ||
| 16 | friend class KMemoryRegionTree; | 16 | friend class KMemoryRegionTree; |
| 17 | 17 | ||
| 18 | public: | 18 | public: |
| 19 | constexpr KMemoryRegion() = default; | ||
| 20 | constexpr KMemoryRegion(u64 address_, u64 last_address_) | ||
| 21 | : address{address_}, last_address{last_address_} {} | ||
| 22 | constexpr KMemoryRegion(u64 address_, u64 last_address_, u64 pair_address_, u32 attributes_, | ||
| 23 | u32 type_id_) | ||
| 24 | : address(address_), last_address(last_address_), pair_address(pair_address_), | ||
| 25 | attributes(attributes_), type_id(type_id_) {} | ||
| 26 | constexpr KMemoryRegion(u64 address_, u64 last_address_, u32 attributes_, u32 type_id_) | ||
| 27 | : KMemoryRegion(address_, last_address_, std::numeric_limits<uintptr_t>::max(), attributes_, | ||
| 28 | type_id_) {} | ||
| 29 | |||
| 19 | static constexpr int Compare(const KMemoryRegion& lhs, const KMemoryRegion& rhs) { | 30 | static constexpr int Compare(const KMemoryRegion& lhs, const KMemoryRegion& rhs) { |
| 20 | if (lhs.GetAddress() < rhs.GetAddress()) { | 31 | if (lhs.GetAddress() < rhs.GetAddress()) { |
| 21 | return -1; | 32 | return -1; |
| @@ -68,9 +79,9 @@ public: | |||
| 68 | return (this->GetType() | type) == this->GetType(); | 79 | return (this->GetType() | type) == this->GetType(); |
| 69 | } | 80 | } |
| 70 | 81 | ||
| 71 | // constexpr bool HasTypeAttribute(KMemoryRegionAttr attr) const { | 82 | constexpr bool HasTypeAttribute(KMemoryRegionAttr attr) const { |
| 72 | // return (this->GetType() | attr) == this->GetType(); | 83 | return (this->GetType() | static_cast<u32>(attr)) == this->GetType(); |
| 73 | //} | 84 | } |
| 74 | 85 | ||
| 75 | constexpr bool CanDerive(u32 type) const { | 86 | constexpr bool CanDerive(u32 type) const { |
| 76 | return (this->GetType() | type) == type; | 87 | return (this->GetType() | type) == type; |
| @@ -80,22 +91,11 @@ public: | |||
| 80 | pair_address = a; | 91 | pair_address = a; |
| 81 | } | 92 | } |
| 82 | 93 | ||
| 83 | // constexpr void SetTypeAttribute(KMemoryRegionAttr attr) { | 94 | constexpr void SetTypeAttribute(KMemoryRegionAttr attr) { |
| 84 | // type_id |= attr; | 95 | type_id |= static_cast<u32>(attr); |
| 85 | //} | 96 | } |
| 86 | 97 | ||
| 87 | private: | 98 | private: |
| 88 | constexpr KMemoryRegion() = default; | ||
| 89 | constexpr KMemoryRegion(u64 address_, u64 last_address_) | ||
| 90 | : address{address_}, last_address{last_address_} {} | ||
| 91 | constexpr KMemoryRegion(u64 address_, u64 last_address_, u64 pair_address_, u32 attributes_, | ||
| 92 | u32 type_id_) | ||
| 93 | : address(address_), last_address(last_address_), pair_address(pair_address_), | ||
| 94 | attributes(attributes_), type_id(type_id_) {} | ||
| 95 | constexpr KMemoryRegion(u64 address_, u64 last_address_, u32 attributes_, u32 type_id_) | ||
| 96 | : KMemoryRegion(address_, last_address_, std::numeric_limits<uintptr_t>::max(), attributes_, | ||
| 97 | type_id_) {} | ||
| 98 | |||
| 99 | const u64 address{}; | 99 | const u64 address{}; |
| 100 | const u64 last_address{}; | 100 | const u64 last_address{}; |
| 101 | u64 pair_address{}; | 101 | 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 @@ | |||
| 1 | // Copyright 2021 yuzu Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #pragma once | ||
| 6 | |||
| 7 | #include "common/common_types.h" | ||
| 8 | |||
| 9 | namespace Kernel { | ||
| 10 | |||
| 11 | enum class KMemoryRegionType : u32 {}; | ||
| 12 | |||
| 13 | enum class KMemoryRegionAttr : typename std::underlying_type<KMemoryRegionType>::type { | ||
| 14 | CarveoutProtected = 0x04000000, | ||
| 15 | DidKernelMap = 0x08000000, | ||
| 16 | ShouldKernelMap = 0x10000000, | ||
| 17 | UserReadOnly = 0x20000000, | ||
| 18 | NoUserMap = 0x40000000, | ||
| 19 | LinearMapped = 0x80000000, | ||
| 20 | }; | ||
| 21 | |||
| 22 | } // namespace Kernel | ||