diff options
author | bunnei <ericbunnie@gmail.com> | 2014-04-25 05:56:06 +0200 |
---|---|---|
committer | bunnei <ericbunnie@gmail.com> | 2014-04-25 05:56:06 +0200 |
commit | 890c7261d2d6d6a760512ebe93c565ee87220983 (patch) | |
tree | 7d822f01da90c37c188faa76578c0d1733136d06 /src | |
parent | added functions to map Heap and Shared memory space (diff) | |
download | yuzu-890c7261d2d6d6a760512ebe93c565ee87220983.tar yuzu-890c7261d2d6d6a760512ebe93c565ee87220983.tar.gz yuzu-890c7261d2d6d6a760512ebe93c565ee87220983.tar.bz2 yuzu-890c7261d2d6d6a760512ebe93c565ee87220983.tar.lz yuzu-890c7261d2d6d6a760512ebe93c565ee87220983.tar.xz yuzu-890c7261d2d6d6a760512ebe93c565ee87220983.tar.zst yuzu-890c7261d2d6d6a760512ebe93c565ee87220983.zip |
Diffstat (limited to '')
-rw-r--r-- | src/core/hle/syscall.cpp | 38 | ||||
-rw-r--r-- | src/core/mem_map.cpp | 10 | ||||
-rw-r--r-- | src/core/mem_map.h | 9 | ||||
-rw-r--r-- | src/core/mem_map_funcs.cpp | 27 |
4 files changed, 70 insertions, 14 deletions
diff --git a/src/core/hle/syscall.cpp b/src/core/hle/syscall.cpp index e5533a741..de1c11862 100644 --- a/src/core/hle/syscall.cpp +++ b/src/core/hle/syscall.cpp @@ -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"}, diff --git a/src/core/mem_map.cpp b/src/core/mem_map.cpp index f0090206e..96245e320 100644 --- a/src/core/mem_map.cpp +++ b/src/core/mem_map.cpp @@ -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[] = diff --git a/src/core/mem_map.h b/src/core/mem_map.h index 5346d04ee..ab96e210f 100644 --- a/src/core/mem_map.h +++ b/src/core/mem_map.h @@ -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(); diff --git a/src/core/mem_map_funcs.cpp b/src/core/mem_map_funcs.cpp index eff0cf4b8..b2c39c57c 100644 --- a/src/core/mem_map_funcs.cpp +++ b/src/core/mem_map_funcs.cpp @@ -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; |