VERY experimental Nintendo Switch 2 emulator
C++
hle: kernel: Add initial KMemoryRegionType module.
bunneibbc5e3a0aaa1
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txtindex d9eea00ca4..299f1ed135 100644--- a/src/core/CMakeLists.txt+++ b/src/core/CMakeLists.txt@@ -173,6 +173,7 @@ add_library(core STATIChle/kernel/k_memory_manager.cpphle/kernel/k_memory_manager.hhle/kernel/k_memory_region.h+ hle/kernel/k_memory_region_type.hhle/kernel/k_page_bitmap.hhle/kernel/k_page_heap.cpphle/kernel/k_page_heap.hdiff --git a/src/core/hle/kernel/k_memory_region.h b/src/core/hle/kernel/k_memory_region.hindex de236df6a7..afa89011c9 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.hnew file mode 100644index 0000000000..6fb5abde95--- /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