Merge pull request #2210 from jroweboy/pagetables
Expose page table to dynarmic for optimized reads and writes to the JIT
This commit is contained in:
commit
ed2ff8df85
|
@ -52,6 +52,7 @@ static Dynarmic::UserCallbacks GetUserCallbacks(ARMul_State* interpeter_state) {
|
||||||
user_callbacks.MemoryWrite16 = &Memory::Write16;
|
user_callbacks.MemoryWrite16 = &Memory::Write16;
|
||||||
user_callbacks.MemoryWrite32 = &Memory::Write32;
|
user_callbacks.MemoryWrite32 = &Memory::Write32;
|
||||||
user_callbacks.MemoryWrite64 = &Memory::Write64;
|
user_callbacks.MemoryWrite64 = &Memory::Write64;
|
||||||
|
user_callbacks.page_table = Memory::GetCurrentPageTablePointers();
|
||||||
return user_callbacks;
|
return user_callbacks;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -45,13 +45,11 @@ struct SpecialRegion {
|
||||||
* requires an indexed fetch and a check for NULL.
|
* requires an indexed fetch and a check for NULL.
|
||||||
*/
|
*/
|
||||||
struct PageTable {
|
struct PageTable {
|
||||||
static const size_t NUM_ENTRIES = 1 << (32 - PAGE_BITS);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Array of memory pointers backing each page. An entry can only be non-null if the
|
* 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`.
|
* corresponding entry in the `attributes` array is of type `Memory`.
|
||||||
*/
|
*/
|
||||||
std::array<u8*, NUM_ENTRIES> pointers;
|
std::array<u8*, PAGE_TABLE_NUM_ENTRIES> pointers;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Contains MMIO handlers that back memory regions whose entries in the `attribute` array is of
|
* Contains MMIO handlers that back memory regions whose entries in the `attribute` array is of
|
||||||
|
@ -63,13 +61,13 @@ struct PageTable {
|
||||||
* Array of fine grained page attributes. If it is set to any value other than `Memory`, then
|
* Array 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.
|
* the corresponding entry in `pointers` MUST be set to null.
|
||||||
*/
|
*/
|
||||||
std::array<PageType, NUM_ENTRIES> attributes;
|
std::array<PageType, PAGE_TABLE_NUM_ENTRIES> attributes;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Indicates the number of externally cached resources touching a page that should be
|
* Indicates the number of externally cached resources touching a page that should be
|
||||||
* flushed before the memory is accessed
|
* flushed before the memory is accessed
|
||||||
*/
|
*/
|
||||||
std::array<u8, NUM_ENTRIES> cached_res_count;
|
std::array<u8, PAGE_TABLE_NUM_ENTRIES> cached_res_count;
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Singular page table used for the singleton process
|
/// Singular page table used for the singleton process
|
||||||
|
@ -77,6 +75,10 @@ static PageTable main_page_table;
|
||||||
/// Currently active page table
|
/// Currently active page table
|
||||||
static PageTable* current_page_table = &main_page_table;
|
static PageTable* current_page_table = &main_page_table;
|
||||||
|
|
||||||
|
std::array<u8*, PAGE_TABLE_NUM_ENTRIES>* GetCurrentPageTablePointers() {
|
||||||
|
return ¤t_page_table->pointers;
|
||||||
|
}
|
||||||
|
|
||||||
static void MapPages(u32 base, u32 size, u8* memory, PageType type) {
|
static void MapPages(u32 base, u32 size, u8* memory, PageType type) {
|
||||||
LOG_DEBUG(HW_Memory, "Mapping %p onto %08X-%08X", memory, base * PAGE_SIZE,
|
LOG_DEBUG(HW_Memory, "Mapping %p onto %08X-%08X", memory, base * PAGE_SIZE,
|
||||||
(base + size) * PAGE_SIZE);
|
(base + size) * PAGE_SIZE);
|
||||||
|
@ -84,7 +86,7 @@ static void MapPages(u32 base, u32 size, u8* memory, PageType type) {
|
||||||
u32 end = base + size;
|
u32 end = base + size;
|
||||||
|
|
||||||
while (base != end) {
|
while (base != end) {
|
||||||
ASSERT_MSG(base < PageTable::NUM_ENTRIES, "out of range mapping at %08X", base);
|
ASSERT_MSG(base < PAGE_TABLE_NUM_ENTRIES, "out of range mapping at %08X", base);
|
||||||
|
|
||||||
// Since pages are unmapped on shutdown after video core is shutdown, the renderer may be
|
// Since pages are unmapped on shutdown after video core is shutdown, the renderer may be
|
||||||
// null here
|
// null here
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <array>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "common/common_types.h"
|
#include "common/common_types.h"
|
||||||
|
@ -17,6 +18,7 @@ namespace Memory {
|
||||||
const u32 PAGE_SIZE = 0x1000;
|
const u32 PAGE_SIZE = 0x1000;
|
||||||
const u32 PAGE_MASK = PAGE_SIZE - 1;
|
const u32 PAGE_MASK = PAGE_SIZE - 1;
|
||||||
const int PAGE_BITS = 12;
|
const int PAGE_BITS = 12;
|
||||||
|
const size_t PAGE_TABLE_NUM_ENTRIES = 1 << (32 - PAGE_BITS);
|
||||||
|
|
||||||
/// Physical memory regions as seen from the ARM11
|
/// Physical memory regions as seen from the ARM11
|
||||||
enum : PAddr {
|
enum : PAddr {
|
||||||
|
@ -166,4 +168,11 @@ void RasterizerFlushRegion(PAddr start, u32 size);
|
||||||
* Flushes and invalidates any externally cached rasterizer resources touching the given region.
|
* Flushes and invalidates any externally cached rasterizer resources touching the given region.
|
||||||
*/
|
*/
|
||||||
void RasterizerFlushAndInvalidateRegion(PAddr start, u32 size);
|
void RasterizerFlushAndInvalidateRegion(PAddr start, u32 size);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dynarmic has an optimization to memory accesses when the pointer to the page exists that
|
||||||
|
* can be used by setting up the current page table as a callback. This function is used to
|
||||||
|
* retrieve the current page table for that purpose.
|
||||||
|
*/
|
||||||
|
std::array<u8*, PAGE_TABLE_NUM_ENTRIES>* GetCurrentPageTablePointers();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue