summaryrefslogtreecommitdiff
path: root/src/core/memory.cpp
diff options
context:
space:
mode:
authorGravatar James Rowe2016-11-24 12:42:32 -0700
committerGravatar James Rowe2016-11-24 20:41:18 -0700
commitbbe57a66cad1b4159f351bf55f84c97040b04753 (patch)
treea2643734bf9af63e5a8f44ff7207e6f8848267f0 /src/core/memory.cpp
parentCache Vertices instead of Output registers (#2165) (diff)
downloadyuzu-bbe57a66cad1b4159f351bf55f84c97040b04753.tar.gz
yuzu-bbe57a66cad1b4159f351bf55f84c97040b04753.tar.xz
yuzu-bbe57a66cad1b4159f351bf55f84c97040b04753.zip
Expose page table to dynarmic for optimized reads and writes to the JIT
Diffstat (limited to 'src/core/memory.cpp')
-rw-r--r--src/core/memory.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/core/memory.cpp b/src/core/memory.cpp
index 64c388374..65e4bba85 100644
--- a/src/core/memory.cpp
+++ b/src/core/memory.cpp
@@ -45,13 +45,11 @@ struct SpecialRegion {
45 * requires an indexed fetch and a check for NULL. 45 * requires an indexed fetch and a check for NULL.
46 */ 46 */
47struct PageTable { 47struct PageTable {
48 static const size_t NUM_ENTRIES = 1 << (32 - PAGE_BITS);
49
50 /** 48 /**
51 * Array of memory pointers backing each page. An entry can only be non-null if the 49 * Array of memory pointers backing each page. An entry can only be non-null if the
52 * corresponding entry in the `attributes` array is of type `Memory`. 50 * corresponding entry in the `attributes` array is of type `Memory`.
53 */ 51 */
54 std::array<u8*, NUM_ENTRIES> pointers; 52 std::array<u8*, PAGE_TABLE_NUM_ENTRIES> pointers;
55 53
56 /** 54 /**
57 * Contains MMIO handlers that back memory regions whose entries in the `attribute` array is of 55 * Contains MMIO handlers that back memory regions whose entries in the `attribute` array is of
@@ -63,13 +61,13 @@ struct PageTable {
63 * Array of fine grained page attributes. If it is set to any value other than `Memory`, then 61 * Array of fine grained page attributes. If it is set to any value other than `Memory`, then
64 * the corresponding entry in `pointers` MUST be set to null. 62 * the corresponding entry in `pointers` MUST be set to null.
65 */ 63 */
66 std::array<PageType, NUM_ENTRIES> attributes; 64 std::array<PageType, PAGE_TABLE_NUM_ENTRIES> attributes;
67 65
68 /** 66 /**
69 * Indicates the number of externally cached resources touching a page that should be 67 * Indicates the number of externally cached resources touching a page that should be
70 * flushed before the memory is accessed 68 * flushed before the memory is accessed
71 */ 69 */
72 std::array<u8, NUM_ENTRIES> cached_res_count; 70 std::array<u8, PAGE_TABLE_NUM_ENTRIES> cached_res_count;
73}; 71};
74 72
75/// Singular page table used for the singleton process 73/// Singular page table used for the singleton process
@@ -77,6 +75,10 @@ static PageTable main_page_table;
77/// Currently active page table 75/// Currently active page table
78static PageTable* current_page_table = &main_page_table; 76static PageTable* current_page_table = &main_page_table;
79 77
78std::array<u8*, PAGE_TABLE_NUM_ENTRIES>* GetCurrentPageTablePointers() {
79 return &current_page_table->pointers;
80}
81
80static void MapPages(u32 base, u32 size, u8* memory, PageType type) { 82static void MapPages(u32 base, u32 size, u8* memory, PageType type) {
81 LOG_DEBUG(HW_Memory, "Mapping %p onto %08X-%08X", memory, base * PAGE_SIZE, 83 LOG_DEBUG(HW_Memory, "Mapping %p onto %08X-%08X", memory, base * PAGE_SIZE,
82 (base + size) * PAGE_SIZE); 84 (base + size) * PAGE_SIZE);
@@ -84,7 +86,7 @@ static void MapPages(u32 base, u32 size, u8* memory, PageType type) {
84 u32 end = base + size; 86 u32 end = base + size;
85 87
86 while (base != end) { 88 while (base != end) {
87 ASSERT_MSG(base < PageTable::NUM_ENTRIES, "out of range mapping at %08X", base); 89 ASSERT_MSG(base < PAGE_TABLE_NUM_ENTRIES, "out of range mapping at %08X", base);
88 90
89 // Since pages are unmapped on shutdown after video core is shutdown, the renderer may be 91 // Since pages are unmapped on shutdown after video core is shutdown, the renderer may be
90 // null here 92 // null here