diff options
Diffstat (limited to 'src/common/page_table.h')
-rw-r--r-- | src/common/page_table.h | 53 |
1 files changed, 20 insertions, 33 deletions
diff --git a/src/common/page_table.h b/src/common/page_table.h index dbc272ab7b..9754fabf91 100644 --- a/src/common/page_table.h +++ b/src/common/page_table.h @@ -4,10 +4,11 @@ #pragma once -#include <vector> -#include <boost/icl/interval_map.hpp> +#include <tuple> + #include "common/common_types.h" #include "common/memory_hook.h" +#include "common/virtual_buffer.h" namespace Common { @@ -33,11 +34,11 @@ struct SpecialRegion { MemoryHookPointer handler; - bool operator<(const SpecialRegion& other) const { + [[nodiscard]] bool operator<(const SpecialRegion& other) const { return std::tie(type, handler) < std::tie(other.type, other.handler); } - bool operator==(const SpecialRegion& other) const { + [[nodiscard]] bool operator==(const SpecialRegion& other) const { return std::tie(type, handler) == std::tie(other.type, other.handler); } }; @@ -47,49 +48,35 @@ struct SpecialRegion { * mimics the way a real CPU page table works. */ struct PageTable { - explicit PageTable(std::size_t page_size_in_bits); - ~PageTable(); + PageTable(); + ~PageTable() noexcept; + + PageTable(const PageTable&) = delete; + PageTable& operator=(const PageTable&) = delete; + + PageTable(PageTable&&) noexcept = default; + PageTable& operator=(PageTable&&) noexcept = default; /** * 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. + * @param page_size_in_bits The page size in bits. + * @param has_attribute Whether or not this page has any backing attributes. */ - void Resize(std::size_t address_space_width_in_bits); + void Resize(std::size_t address_space_width_in_bits, std::size_t page_size_in_bits, + bool has_attribute); /** * 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::vector<u8*> pointers; - - /** - * Contains MMIO handlers that back memory regions whose entries in the `attribute` vector is - * of type `Special`. - */ - boost::icl::interval_map<u64, std::set<SpecialRegion>> special_regions; - - /** - * 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::vector<PageType> attributes; - - const std::size_t page_size_in_bits{}; -}; - -/** - * A more advanced Page Table with the ability to save a backing address when using it - * depends on another MMU. - */ -struct BackingPageTable : PageTable { - explicit BackingPageTable(std::size_t page_size_in_bits); - ~BackingPageTable(); + VirtualBuffer<u8*> pointers; - void Resize(std::size_t address_space_width_in_bits); + VirtualBuffer<u64> backing_addr; - std::vector<u64> backing_addr; + VirtualBuffer<PageType> attributes; }; } // namespace Common |