summaryrefslogtreecommitdiffstats
path: root/src/core/memory.h
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.h
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.h32
1 files changed, 21 insertions, 11 deletions
diff --git a/src/core/memory.h b/src/core/memory.h
index 2a27c0251..739e5be94 100644
--- a/src/core/memory.h
+++ b/src/core/memory.h
@@ -4,10 +4,10 @@
#pragma once
-#include <array>
#include <cstddef>
#include <string>
#include <tuple>
+#include <vector>
#include <boost/icl/interval_map.hpp>
#include "common/common_types.h"
#include "core/memory_hook.h"
@@ -23,10 +23,8 @@ namespace Memory {
* be mapped.
*/
constexpr std::size_t PAGE_BITS = 12;
-constexpr u64 PAGE_SIZE = 1 << PAGE_BITS;
+constexpr u64 PAGE_SIZE = 1ULL << PAGE_BITS;
constexpr u64 PAGE_MASK = PAGE_SIZE - 1;
-constexpr std::size_t ADDRESS_SPACE_BITS = 36;
-constexpr std::size_t PAGE_TABLE_NUM_ENTRIES = 1ULL << (ADDRESS_SPACE_BITS - PAGE_BITS);
enum class PageType : u8 {
/// Page is unmapped and should cause an access error.
@@ -62,23 +60,35 @@ struct SpecialRegion {
* mimics the way a real CPU page table works.
*/
struct PageTable {
+ explicit PageTable();
+ explicit PageTable(std::size_t address_space_width_in_bits);
+ ~PageTable();
+
+ /**
+ * Resizes the page table to be able to accomodate enough pages within
+ * a given address space.
+ *
+ * @param address_space_width_in_bits The address size width in bits.
+ */
+ void Resize(std::size_t address_space_width_in_bits);
+
/**
- * Array of memory pointers backing each page. An entry can only be non-null if the
- * corresponding entry in the `attributes` array is of type `Memory`.
+ * Vector of memory pointers backing each page. An entry can only be non-null if the
+ * corresponding entry in the `attributes` vector is of type `Memory`.
*/
- std::array<u8*, PAGE_TABLE_NUM_ENTRIES> pointers;
+ std::vector<u8*> pointers;
/**
- * Contains MMIO handlers that back memory regions whose entries in the `attribute` array is of
- * type `Special`.
+ * Contains MMIO handlers that back memory regions whose entries in the `attribute` vector is
+ * of type `Special`.
*/
boost::icl::interval_map<VAddr, std::set<SpecialRegion>> special_regions;
/**
- * Array of fine grained page attributes. If it is set to any value other than `Memory`, then
+ * Vector of fine grained page attributes. If it is set to any value other than `Memory`, then
* the corresponding entry in `pointers` MUST be set to null.
*/
- std::array<PageType, PAGE_TABLE_NUM_ENTRIES> attributes;
+ std::vector<PageType> attributes;
};
/// Virtual user-space memory regions