mirror of
https://github.com/yuzu-emu/yuzu-mainline.git
synced 2024-12-12 17:54:36 +01:00
- added preliminary support for svc_MapMemoryBlock
- added shared memory region - moarrrr cleanups to memory_map
This commit is contained in:
parent
b7cd4c9e90
commit
890c7261d2
@ -15,14 +15,29 @@
|
||||
|
||||
namespace Syscall {
|
||||
|
||||
enum ControlMemoryOperation {
|
||||
MEMORY_OPERATION_HEAP = 0x00000003,
|
||||
MEMORY_OPERATION_GSP_HEAP = 0x00010003,
|
||||
};
|
||||
|
||||
enum MapMemoryPermission {
|
||||
MEMORY_PERMISSION_UNMAP = 0x00000000,
|
||||
MEMORY_PERMISSION_NORMAL = 0x00000001,
|
||||
};
|
||||
|
||||
/// Map application or GSP heap memory
|
||||
Result ControlMemory(void* outaddr, u32 addr0, u32 addr1, u32 size, u32 operation, u32 permissions) {
|
||||
u32 virtual_address = 0x00000000;
|
||||
|
||||
switch (operation) {
|
||||
|
||||
// Map GSP heap memory?
|
||||
case 0x00010003:
|
||||
// Map normal heap memory
|
||||
case MEMORY_OPERATION_HEAP:
|
||||
virtual_address = Memory::MapBlock_Heap(size, operation, permissions);
|
||||
break;
|
||||
|
||||
// Map GSP heap memory
|
||||
case MEMORY_OPERATION_GSP_HEAP:
|
||||
virtual_address = Memory::MapBlock_HeapGSP(size, operation, permissions);
|
||||
break;
|
||||
|
||||
@ -31,7 +46,22 @@ Result ControlMemory(void* outaddr, u32 addr0, u32 addr1, u32 size, u32 operatio
|
||||
ERROR_LOG(OSHLE, "Unknown ControlMemory operation %08X", operation);
|
||||
}
|
||||
|
||||
Core::g_app_core->SetReg(1, Memory::MapBlock_HeapGSP(size, operation, permissions));
|
||||
Core::g_app_core->SetReg(1, virtual_address);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/// Maps a memory block to specified address
|
||||
Result MapMemoryBlock(Handle memblock, u32 addr, u32 mypermissions, u32 otherpermission) {
|
||||
int x = 0;
|
||||
switch (mypermissions) {
|
||||
case MEMORY_PERMISSION_NORMAL:
|
||||
case MEMORY_PERMISSION_NORMAL + 1:
|
||||
case MEMORY_PERMISSION_NORMAL + 2:
|
||||
Memory::MapBlock_Shared(memblock, addr, mypermissions);
|
||||
break;
|
||||
default:
|
||||
ERROR_LOG(OSHLE, "Unknown MapMemoryBlock permissions %08X", mypermissions);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -93,7 +123,7 @@ const HLE::FunctionDef Syscall_Table[] = {
|
||||
{0x1C, NULL, "CancelTimer"},
|
||||
{0x1D, NULL, "ClearTimer"},
|
||||
{0x1E, NULL, "CreateMemoryBlock"},
|
||||
{0x1F, NULL, "MapMemoryBlock"},
|
||||
{0x1F, WrapI_UUUU<MapMemoryBlock>, "MapMemoryBlock"},
|
||||
{0x20, NULL, "UnmapMemoryBlock"},
|
||||
{0x21, NULL, "CreateAddressArbiter"},
|
||||
{0x22, NULL, "ArbitrateAddress"},
|
||||
|
@ -19,6 +19,7 @@ MemArena g_arena; ///< The MemArena class
|
||||
u8* g_heap = NULL; ///< Application heap (main memory)
|
||||
u8* g_heap_gsp = NULL; ///< GSP heap (main memory)
|
||||
u8* g_vram = NULL; ///< Video memory (VRAM) pointer
|
||||
u8* g_shared_mem = NULL; ///< Shared memory
|
||||
|
||||
u8* g_physical_bootrom = NULL; ///< Bootrom physical memory
|
||||
u8* g_uncached_bootrom = NULL;
|
||||
@ -26,13 +27,14 @@ u8* g_uncached_bootrom = NULL;
|
||||
u8* g_physical_fcram = NULL; ///< Main physical memory (FCRAM)
|
||||
u8* g_physical_heap_gsp = NULL; ///< GSP heap physical memory
|
||||
u8* g_physical_vram = NULL; ///< Video physical memory (VRAM)
|
||||
u8* g_physical_scratchpad = NULL; ///< Scratchpad memory used for main thread stack
|
||||
u8* g_physical_shared_mem = NULL; ///< Physical shared memory
|
||||
|
||||
// We don't declare the IO region in here since its handled by other means.
|
||||
static MemoryView g_views[] = {
|
||||
{&g_vram, &g_physical_vram, VRAM_VADDR, VRAM_SIZE, 0},
|
||||
{&g_heap_gsp, &g_physical_heap_gsp, HEAP_GSP_VADDR, HEAP_GSP_SIZE, 0},
|
||||
{&g_heap, &g_physical_fcram, HEAP_VADDR, HEAP_SIZE, MV_IS_PRIMARY_RAM},
|
||||
{&g_vram, &g_physical_vram, VRAM_VADDR, VRAM_SIZE, 0},
|
||||
{&g_heap, &g_physical_fcram, HEAP_VADDR, HEAP_SIZE, MV_IS_PRIMARY_RAM},
|
||||
{&g_shared_mem, &g_physical_shared_mem, SHARED_MEMORY_VADDR, SHARED_MEMORY_SIZE, 0},
|
||||
{&g_heap_gsp, &g_physical_heap_gsp, HEAP_GSP_VADDR, HEAP_GSP_SIZE, 0},
|
||||
};
|
||||
|
||||
/*static MemoryView views[] =
|
||||
|
@ -21,8 +21,11 @@ enum {
|
||||
SCRATCHPAD_SIZE = 0x00004000, ///< Typical stack size - TODO: Read from exheader
|
||||
HEAP_GSP_SIZE = 0x02000000, ///< GSP heap size... TODO: Define correctly?
|
||||
HEAP_SIZE = FCRAM_SIZE, ///< Application heap size
|
||||
SHARED_MEMORY_SIZE = 0x04000000, ///< Shared memory size
|
||||
HARDWARE_IO_SIZE = 0x01000000,
|
||||
|
||||
SHARED_MEMORY_VADDR = 0x10000000, ///< Shared memory
|
||||
SHARED_MEMORY_VADDR_END = (SHARED_MEMORY_VADDR + SHARED_MEMORY_SIZE),
|
||||
|
||||
HEAP_PADDR = HEAP_GSP_SIZE,
|
||||
HEAP_PADDR_END = (HEAP_PADDR + HEAP_SIZE),
|
||||
@ -38,12 +41,17 @@ enum {
|
||||
SCRATCHPAD_MASK = (SCRATCHPAD_SIZE - 1), ///< Scratchpad memory mask
|
||||
HEAP_GSP_MASK = (HEAP_GSP_SIZE - 1),
|
||||
HEAP_MASK = (HEAP_SIZE - 1),
|
||||
SHARED_MEMORY_MASK = (SHARED_MEMORY_SIZE - 1),
|
||||
|
||||
FCRAM_PADDR = 0x20000000, ///< FCRAM physical address
|
||||
FCRAM_PADDR_END = (FCRAM_PADDR + FCRAM_SIZE), ///< FCRAM end of physical space
|
||||
FCRAM_VADDR = 0x08000000, ///< FCRAM virtual address
|
||||
FCRAM_VADDR_END = (FCRAM_VADDR + FCRAM_SIZE), ///< FCRAM end of virtual space
|
||||
|
||||
HARDWARE_IO_VADDR = 0x1EC00000,
|
||||
HARDWARE_IO_VADDR_END = (HARDWARE_IO_VADDR + HARDWARE_IO_SIZE),
|
||||
|
||||
|
||||
VRAM_VADDR = 0x1F000000,
|
||||
SCRATCHPAD_VADDR_END = 0x10000000,
|
||||
SCRATCHPAD_VADDR = (SCRATCHPAD_VADDR_END - SCRATCHPAD_SIZE), ///< Stack space
|
||||
@ -84,6 +92,7 @@ extern u8 *g_base;
|
||||
extern u8* g_heap_gsp; ///< GSP heap (main memory)
|
||||
extern u8* g_heap; ///< Application heap (main memory)
|
||||
extern u8* g_vram; ///< Video memory (VRAM)
|
||||
extern u8* g_shared_mem; ///< Shared memory
|
||||
|
||||
void Init();
|
||||
void Shutdown();
|
||||
|
@ -43,17 +43,22 @@ inline void _Read(T &var, const u32 addr) {
|
||||
|
||||
// Hardware I/O register reads
|
||||
// 0x10XXXXXX- is physical address space, 0x1EXXXXXX is virtual address space
|
||||
} else if ((vaddr & 0xFF000000) == 0x10000000 || (vaddr & 0xFF000000) == 0x1E000000) {
|
||||
} else if ((vaddr >= HARDWARE_IO_VADDR) && (vaddr < HARDWARE_IO_VADDR_END)) {
|
||||
HW::Read<T>(var, vaddr);
|
||||
|
||||
// FCRAM - GSP heap
|
||||
} else if ((vaddr > HEAP_GSP_VADDR) && (vaddr < HEAP_GSP_VADDR_END)) {
|
||||
} else if ((vaddr >= HEAP_GSP_VADDR) && (vaddr < HEAP_GSP_VADDR_END)) {
|
||||
var = *((const T*)&g_heap_gsp[vaddr & HEAP_GSP_MASK]);
|
||||
|
||||
// FCRAM - application heap
|
||||
} else if ((vaddr > HEAP_VADDR) && (vaddr < HEAP_VADDR_END)) {
|
||||
} else if ((vaddr >= HEAP_VADDR) && (vaddr < HEAP_VADDR_END)) {
|
||||
var = *((const T*)&g_heap[vaddr & HEAP_MASK]);
|
||||
|
||||
// Shared memory
|
||||
} else if ((vaddr >= SHARED_MEMORY_VADDR) && (vaddr < SHARED_MEMORY_VADDR_END)) {
|
||||
NOTICE_LOG(OSHLE, "wtf read");
|
||||
var = *((const T*)&g_shared_mem[vaddr & SHARED_MEMORY_MASK]);
|
||||
|
||||
/*else if ((vaddr & 0x3F800000) == 0x04000000) {
|
||||
var = *((const T*)&m_pVRAM[vaddr & VRAM_MASK]);*/
|
||||
|
||||
@ -74,17 +79,22 @@ inline void _Write(u32 addr, const T data) {
|
||||
|
||||
// Hardware I/O register writes
|
||||
// 0x10XXXXXX- is physical address space, 0x1EXXXXXX is virtual address space
|
||||
} else if ((vaddr & 0xFF000000) == 0x10000000 || (vaddr & 0xFF000000) == 0x1E000000) {
|
||||
} else if ((vaddr >= HARDWARE_IO_VADDR) && (vaddr < HARDWARE_IO_VADDR_END)) {
|
||||
HW::Write<T>(vaddr, data);
|
||||
|
||||
// FCRAM - GSP heap
|
||||
} else if ((vaddr > HEAP_GSP_VADDR) && (vaddr < HEAP_GSP_VADDR_END)) {
|
||||
} else if ((vaddr >= HEAP_GSP_VADDR) && (vaddr < HEAP_GSP_VADDR_END)) {
|
||||
*(T*)&g_heap_gsp[vaddr & HEAP_GSP_MASK] = data;
|
||||
|
||||
// FCRAM - application heap
|
||||
} else if ((vaddr > HEAP_VADDR) && (vaddr < HEAP_VADDR_END)) {
|
||||
} else if ((vaddr >= HEAP_VADDR) && (vaddr < HEAP_VADDR_END)) {
|
||||
*(T*)&g_heap[vaddr & HEAP_MASK] = data;
|
||||
|
||||
// Shared memory
|
||||
} else if ((vaddr >= SHARED_MEMORY_VADDR) && (vaddr < SHARED_MEMORY_VADDR_END)) {
|
||||
NOTICE_LOG(OSHLE, "wtf read");
|
||||
*(T*)&g_shared_mem[vaddr & SHARED_MEMORY_MASK] = data;
|
||||
|
||||
} else if ((vaddr & 0xFF000000) == 0x14000000) {
|
||||
_assert_msg_(MEMMAP, false, "umimplemented write to GSP heap");
|
||||
} else if ((vaddr & 0xFFF00000) == 0x1EC00000) {
|
||||
@ -116,6 +126,11 @@ u8 *GetPointer(const u32 addr) {
|
||||
} else if ((vaddr >= HEAP_VADDR) && (vaddr < HEAP_VADDR_END)) {
|
||||
return g_heap + (vaddr & HEAP_MASK);
|
||||
|
||||
// Shared memory
|
||||
} else if ((vaddr > SHARED_MEMORY_VADDR) && (vaddr < SHARED_MEMORY_VADDR_END)) {
|
||||
NOTICE_LOG(OSHLE, "wtf read");
|
||||
return g_shared_mem + (vaddr & SHARED_MEMORY_MASK);
|
||||
|
||||
} else {
|
||||
ERROR_LOG(MEMMAP, "Unknown GetPointer @ 0x%08x", vaddr);
|
||||
return 0;
|
||||
|
Loading…
Reference in New Issue
Block a user