diff options
author | bunnei <bunneidev@gmail.com> | 2019-03-17 19:42:57 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-03-17 19:42:57 +0100 |
commit | 57ca1e3e6942d1ef1b59c458e76ba969f0b739d5 (patch) | |
tree | 1d7a026c695a73932030048329a2c0707656666e /src/core/memory.h | |
parent | Merge pull request #2251 from bunnei/skip-zero-flush (diff) | |
parent | core: Move PageTable struct into Common. (diff) | |
download | yuzu-57ca1e3e6942d1ef1b59c458e76ba969f0b739d5.tar yuzu-57ca1e3e6942d1ef1b59c458e76ba969f0b739d5.tar.gz yuzu-57ca1e3e6942d1ef1b59c458e76ba969f0b739d5.tar.bz2 yuzu-57ca1e3e6942d1ef1b59c458e76ba969f0b739d5.tar.lz yuzu-57ca1e3e6942d1ef1b59c458e76ba969f0b739d5.tar.xz yuzu-57ca1e3e6942d1ef1b59c458e76ba969f0b739d5.tar.zst yuzu-57ca1e3e6942d1ef1b59c458e76ba969f0b739d5.zip |
Diffstat (limited to '')
-rw-r--r-- | src/core/memory.h | 74 |
1 files changed, 6 insertions, 68 deletions
diff --git a/src/core/memory.h b/src/core/memory.h index c2c6643ee..3f60d868c 100644 --- a/src/core/memory.h +++ b/src/core/memory.h @@ -10,7 +10,10 @@ #include <vector> #include <boost/icl/interval_map.hpp> #include "common/common_types.h" -#include "core/memory_hook.h" + +namespace Common { +struct PageTable; +} namespace Kernel { class Process; @@ -26,71 +29,6 @@ constexpr std::size_t PAGE_BITS = 12; constexpr u64 PAGE_SIZE = 1ULL << PAGE_BITS; constexpr u64 PAGE_MASK = PAGE_SIZE - 1; -enum class PageType : u8 { - /// Page is unmapped and should cause an access error. - Unmapped, - /// Page is mapped to regular memory. This is the only type you can get pointers to. - Memory, - /// Page is mapped to regular memory, but also needs to check for rasterizer cache flushing and - /// invalidation - RasterizerCachedMemory, - /// Page is mapped to a I/O region. Writing and reading to this page is handled by functions. - Special, -}; - -struct SpecialRegion { - enum class Type { - DebugHook, - IODevice, - } type; - - MemoryHookPointer handler; - - bool operator<(const SpecialRegion& other) const { - return std::tie(type, handler) < std::tie(other.type, other.handler); - } - - bool operator==(const SpecialRegion& other) const { - return std::tie(type, handler) == std::tie(other.type, other.handler); - } -}; - -/** - * A (reasonably) fast way of allowing switchable and remappable process address spaces. It loosely - * 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); - - /** - * 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<VAddr, 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; -}; - /// Virtual user-space memory regions enum : VAddr { /// Read-only page containing kernel and system configuration values. @@ -116,8 +54,8 @@ enum : VAddr { }; /// Currently active page table -void SetCurrentPageTable(PageTable* page_table); -PageTable* GetCurrentPageTable(); +void SetCurrentPageTable(Common::PageTable* page_table); +Common::PageTable* GetCurrentPageTable(); /// Determines if the given VAddr is valid for the specified process. bool IsValidVirtualAddress(const Kernel::Process& process, VAddr vaddr); |