summaryrefslogtreecommitdiffstats
path: root/src/core/memory.cpp
diff options
context:
space:
mode:
authorLioncash <mathew1800@gmail.com>2018-09-24 16:29:56 +0200
committerLioncash <mathew1800@gmail.com>2018-09-25 04:15:53 +0200
commit7fd598636e819d4e86874b20081945936a05c5f1 (patch)
tree046da702e80db7f8f5d75521b7864a1b7eb822a3 /src/core/memory.cpp
parentprocess/vm_manager: Amend API to allow reading parameters from NPDM metadata (diff)
downloadyuzu-7fd598636e819d4e86874b20081945936a05c5f1.tar
yuzu-7fd598636e819d4e86874b20081945936a05c5f1.tar.gz
yuzu-7fd598636e819d4e86874b20081945936a05c5f1.tar.bz2
yuzu-7fd598636e819d4e86874b20081945936a05c5f1.tar.lz
yuzu-7fd598636e819d4e86874b20081945936a05c5f1.tar.xz
yuzu-7fd598636e819d4e86874b20081945936a05c5f1.tar.zst
yuzu-7fd598636e819d4e86874b20081945936a05c5f1.zip
Diffstat (limited to '')
-rw-r--r--src/core/memory.cpp18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/core/memory.cpp b/src/core/memory.cpp
index 316b46820..674ef0829 100644
--- a/src/core/memory.cpp
+++ b/src/core/memory.cpp
@@ -3,7 +3,6 @@
// Refer to the license.txt file included.
#include <algorithm>
-#include <array>
#include <cstring>
#include <utility>
@@ -41,6 +40,21 @@ PageTable* GetCurrentPageTable() {
return current_page_table;
}
+PageTable::PageTable() = default;
+
+PageTable::PageTable(std::size_t address_space_width_in_bits) {
+ Resize(address_space_width_in_bits);
+}
+
+PageTable::~PageTable() = default;
+
+void PageTable::Resize(std::size_t address_space_width_in_bits) {
+ const std::size_t num_page_table_entries = 1ULL << (address_space_width_in_bits - PAGE_BITS);
+
+ pointers.resize(num_page_table_entries);
+ attributes.resize(num_page_table_entries);
+}
+
static void MapPages(PageTable& page_table, VAddr base, u64 size, u8* memory, PageType type) {
LOG_DEBUG(HW_Memory, "Mapping {} onto {:016X}-{:016X}", fmt::ptr(memory), base * PAGE_SIZE,
(base + size) * PAGE_SIZE);
@@ -50,7 +64,7 @@ static void MapPages(PageTable& page_table, VAddr base, u64 size, u8* memory, Pa
VAddr end = base + size;
while (base != end) {
- ASSERT_MSG(base < PAGE_TABLE_NUM_ENTRIES, "out of range mapping at {:016X}", base);
+ ASSERT_MSG(base < page_table.pointers.size(), "out of range mapping at {:016X}", base);
page_table.attributes[base] = type;
page_table.pointers[base] = memory;