diff options
| author | 2018-09-24 10:29:56 -0400 | |
|---|---|---|
| committer | 2018-09-24 22:15:53 -0400 | |
| commit | 7fd598636e819d4e86874b20081945936a05c5f1 (patch) | |
| tree | 046da702e80db7f8f5d75521b7864a1b7eb822a3 /src/core/memory.cpp | |
| parent | process/vm_manager: Amend API to allow reading parameters from NPDM metadata (diff) | |
| download | yuzu-7fd598636e819d4e86874b20081945936a05c5f1.tar.gz yuzu-7fd598636e819d4e86874b20081945936a05c5f1.tar.xz yuzu-7fd598636e819d4e86874b20081945936a05c5f1.zip | |
memory: Dehardcode the use of a 36-bit address space
Given games can also request a 32-bit or 39-bit address space, we
shouldn't be hardcoding the address space range as 36-bit.
Diffstat (limited to 'src/core/memory.cpp')
| -rw-r--r-- | src/core/memory.cpp | 18 |
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 @@ | |||
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include <algorithm> | 5 | #include <algorithm> |
| 6 | #include <array> | ||
| 7 | #include <cstring> | 6 | #include <cstring> |
| 8 | #include <utility> | 7 | #include <utility> |
| 9 | 8 | ||
| @@ -41,6 +40,21 @@ PageTable* GetCurrentPageTable() { | |||
| 41 | return current_page_table; | 40 | return current_page_table; |
| 42 | } | 41 | } |
| 43 | 42 | ||
| 43 | PageTable::PageTable() = default; | ||
| 44 | |||
| 45 | PageTable::PageTable(std::size_t address_space_width_in_bits) { | ||
| 46 | Resize(address_space_width_in_bits); | ||
| 47 | } | ||
| 48 | |||
| 49 | PageTable::~PageTable() = default; | ||
| 50 | |||
| 51 | void PageTable::Resize(std::size_t address_space_width_in_bits) { | ||
| 52 | const std::size_t num_page_table_entries = 1ULL << (address_space_width_in_bits - PAGE_BITS); | ||
| 53 | |||
| 54 | pointers.resize(num_page_table_entries); | ||
| 55 | attributes.resize(num_page_table_entries); | ||
| 56 | } | ||
| 57 | |||
| 44 | static void MapPages(PageTable& page_table, VAddr base, u64 size, u8* memory, PageType type) { | 58 | static void MapPages(PageTable& page_table, VAddr base, u64 size, u8* memory, PageType type) { |
| 45 | LOG_DEBUG(HW_Memory, "Mapping {} onto {:016X}-{:016X}", fmt::ptr(memory), base * PAGE_SIZE, | 59 | LOG_DEBUG(HW_Memory, "Mapping {} onto {:016X}-{:016X}", fmt::ptr(memory), base * PAGE_SIZE, |
| 46 | (base + size) * PAGE_SIZE); | 60 | (base + size) * PAGE_SIZE); |
| @@ -50,7 +64,7 @@ static void MapPages(PageTable& page_table, VAddr base, u64 size, u8* memory, Pa | |||
| 50 | 64 | ||
| 51 | VAddr end = base + size; | 65 | VAddr end = base + size; |
| 52 | while (base != end) { | 66 | while (base != end) { |
| 53 | ASSERT_MSG(base < PAGE_TABLE_NUM_ENTRIES, "out of range mapping at {:016X}", base); | 67 | ASSERT_MSG(base < page_table.pointers.size(), "out of range mapping at {:016X}", base); |
| 54 | 68 | ||
| 55 | page_table.attributes[base] = type; | 69 | page_table.attributes[base] = type; |
| 56 | page_table.pointers[base] = memory; | 70 | page_table.pointers[base] = memory; |