Merge pull request #244 from bunnei/cleanup-memmap
MemMap: Updated memory map to subtract base address instead of mask.
This commit is contained in:
commit
a6bf3fd613
@ -26,12 +26,10 @@ enum : u32 {
|
|||||||
FCRAM_PADDR_END = (FCRAM_PADDR + FCRAM_SIZE), ///< FCRAM end of physical space
|
FCRAM_PADDR_END = (FCRAM_PADDR + FCRAM_SIZE), ///< FCRAM end of physical space
|
||||||
FCRAM_VADDR = 0x08000000, ///< FCRAM virtual address
|
FCRAM_VADDR = 0x08000000, ///< FCRAM virtual address
|
||||||
FCRAM_VADDR_END = (FCRAM_VADDR + FCRAM_SIZE), ///< FCRAM end of virtual space
|
FCRAM_VADDR_END = (FCRAM_VADDR + FCRAM_SIZE), ///< FCRAM end of virtual space
|
||||||
FCRAM_MASK = (FCRAM_SIZE - 1), ///< FCRAM mask
|
|
||||||
|
|
||||||
SHARED_MEMORY_SIZE = 0x04000000, ///< Shared memory size
|
SHARED_MEMORY_SIZE = 0x04000000, ///< Shared memory size
|
||||||
SHARED_MEMORY_VADDR = 0x10000000, ///< Shared memory
|
SHARED_MEMORY_VADDR = 0x10000000, ///< Shared memory
|
||||||
SHARED_MEMORY_VADDR_END = (SHARED_MEMORY_VADDR + SHARED_MEMORY_SIZE),
|
SHARED_MEMORY_VADDR_END = (SHARED_MEMORY_VADDR + SHARED_MEMORY_SIZE),
|
||||||
SHARED_MEMORY_MASK = (SHARED_MEMORY_SIZE - 1),
|
|
||||||
|
|
||||||
DSP_MEMORY_SIZE = 0x00080000, ///< DSP memory size
|
DSP_MEMORY_SIZE = 0x00080000, ///< DSP memory size
|
||||||
DSP_MEMORY_VADDR = 0x1FF00000, ///< DSP memory virtual address
|
DSP_MEMORY_VADDR = 0x1FF00000, ///< DSP memory virtual address
|
||||||
@ -39,37 +37,31 @@ enum : u32 {
|
|||||||
CONFIG_MEMORY_SIZE = 0x00001000, ///< Configuration memory size
|
CONFIG_MEMORY_SIZE = 0x00001000, ///< Configuration memory size
|
||||||
CONFIG_MEMORY_VADDR = 0x1FF80000, ///< Configuration memory virtual address
|
CONFIG_MEMORY_VADDR = 0x1FF80000, ///< Configuration memory virtual address
|
||||||
CONFIG_MEMORY_VADDR_END = (CONFIG_MEMORY_VADDR + CONFIG_MEMORY_SIZE),
|
CONFIG_MEMORY_VADDR_END = (CONFIG_MEMORY_VADDR + CONFIG_MEMORY_SIZE),
|
||||||
CONFIG_MEMORY_MASK = (CONFIG_MEMORY_SIZE - 1),
|
|
||||||
|
|
||||||
KERNEL_MEMORY_SIZE = 0x00001000, ///< Kernel memory size
|
KERNEL_MEMORY_SIZE = 0x00001000, ///< Kernel memory size
|
||||||
KERNEL_MEMORY_VADDR = 0xFFFF0000, ///< Kernel memory where the kthread objects etc are
|
KERNEL_MEMORY_VADDR = 0xFFFF0000, ///< Kernel memory where the kthread objects etc are
|
||||||
KERNEL_MEMORY_VADDR_END = (KERNEL_MEMORY_VADDR + KERNEL_MEMORY_SIZE),
|
KERNEL_MEMORY_VADDR_END = (KERNEL_MEMORY_VADDR + KERNEL_MEMORY_SIZE),
|
||||||
KERNEL_MEMORY_MASK = (KERNEL_MEMORY_SIZE - 1),
|
|
||||||
|
|
||||||
EXEFS_CODE_SIZE = 0x03F00000,
|
EXEFS_CODE_SIZE = 0x03F00000,
|
||||||
EXEFS_CODE_VADDR = 0x00100000, ///< ExeFS:/.code is loaded here
|
EXEFS_CODE_VADDR = 0x00100000, ///< ExeFS:/.code is loaded here
|
||||||
EXEFS_CODE_VADDR_END = (EXEFS_CODE_VADDR + EXEFS_CODE_SIZE),
|
EXEFS_CODE_VADDR_END = (EXEFS_CODE_VADDR + EXEFS_CODE_SIZE),
|
||||||
EXEFS_CODE_MASK = 0x03FFFFFF,
|
|
||||||
|
|
||||||
// Region of FCRAM used by system
|
// Region of FCRAM used by system
|
||||||
SYSTEM_MEMORY_SIZE = 0x02C00000, ///< 44MB
|
SYSTEM_MEMORY_SIZE = 0x02C00000, ///< 44MB
|
||||||
SYSTEM_MEMORY_VADDR = 0x04000000,
|
SYSTEM_MEMORY_VADDR = 0x04000000,
|
||||||
SYSTEM_MEMORY_VADDR_END = (SYSTEM_MEMORY_VADDR + SYSTEM_MEMORY_SIZE),
|
SYSTEM_MEMORY_VADDR_END = (SYSTEM_MEMORY_VADDR + SYSTEM_MEMORY_SIZE),
|
||||||
SYSTEM_MEMORY_MASK = 0x03FFFFFF,
|
|
||||||
|
|
||||||
HEAP_SIZE = FCRAM_SIZE, ///< Application heap size
|
HEAP_SIZE = FCRAM_SIZE, ///< Application heap size
|
||||||
//HEAP_PADDR = HEAP_GSP_SIZE,
|
//HEAP_PADDR = HEAP_GSP_SIZE,
|
||||||
//HEAP_PADDR_END = (HEAP_PADDR + HEAP_SIZE),
|
//HEAP_PADDR_END = (HEAP_PADDR + HEAP_SIZE),
|
||||||
HEAP_VADDR = 0x08000000,
|
HEAP_VADDR = 0x08000000,
|
||||||
HEAP_VADDR_END = (HEAP_VADDR + HEAP_SIZE),
|
HEAP_VADDR_END = (HEAP_VADDR + HEAP_SIZE),
|
||||||
HEAP_MASK = (HEAP_SIZE - 1),
|
|
||||||
|
|
||||||
HEAP_GSP_SIZE = 0x02000000, ///< GSP heap size... TODO: Define correctly?
|
HEAP_GSP_SIZE = 0x02000000, ///< GSP heap size... TODO: Define correctly?
|
||||||
HEAP_GSP_VADDR = 0x14000000,
|
HEAP_GSP_VADDR = 0x14000000,
|
||||||
HEAP_GSP_VADDR_END = (HEAP_GSP_VADDR + HEAP_GSP_SIZE),
|
HEAP_GSP_VADDR_END = (HEAP_GSP_VADDR + HEAP_GSP_SIZE),
|
||||||
HEAP_GSP_PADDR = 0x00000000,
|
HEAP_GSP_PADDR = 0x00000000,
|
||||||
HEAP_GSP_PADDR_END = (HEAP_GSP_PADDR + HEAP_GSP_SIZE),
|
HEAP_GSP_PADDR_END = (HEAP_GSP_PADDR + HEAP_GSP_SIZE),
|
||||||
HEAP_GSP_MASK = (HEAP_GSP_SIZE - 1),
|
|
||||||
|
|
||||||
HARDWARE_IO_SIZE = 0x01000000,
|
HARDWARE_IO_SIZE = 0x01000000,
|
||||||
HARDWARE_IO_PADDR = 0x10000000, ///< IO physical address start
|
HARDWARE_IO_PADDR = 0x10000000, ///< IO physical address start
|
||||||
@ -82,12 +74,10 @@ enum : u32 {
|
|||||||
VRAM_VADDR = 0x1F000000,
|
VRAM_VADDR = 0x1F000000,
|
||||||
VRAM_PADDR_END = (VRAM_PADDR + VRAM_SIZE),
|
VRAM_PADDR_END = (VRAM_PADDR + VRAM_SIZE),
|
||||||
VRAM_VADDR_END = (VRAM_VADDR + VRAM_SIZE),
|
VRAM_VADDR_END = (VRAM_VADDR + VRAM_SIZE),
|
||||||
VRAM_MASK = 0x007FFFFF,
|
|
||||||
|
|
||||||
SCRATCHPAD_SIZE = 0x00004000, ///< Typical stack size - TODO: Read from exheader
|
SCRATCHPAD_SIZE = 0x00004000, ///< Typical stack size - TODO: Read from exheader
|
||||||
SCRATCHPAD_VADDR_END = 0x10000000,
|
SCRATCHPAD_VADDR_END = 0x10000000,
|
||||||
SCRATCHPAD_VADDR = (SCRATCHPAD_VADDR_END - SCRATCHPAD_SIZE), ///< Stack space
|
SCRATCHPAD_VADDR = (SCRATCHPAD_VADDR_END - SCRATCHPAD_SIZE), ///< Stack space
|
||||||
SCRATCHPAD_MASK = (SCRATCHPAD_SIZE - 1), ///< Scratchpad memory mask
|
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -56,7 +56,7 @@ inline void Read(T &var, const VAddr vaddr) {
|
|||||||
|
|
||||||
// Kernel memory command buffer
|
// Kernel memory command buffer
|
||||||
if (vaddr >= KERNEL_MEMORY_VADDR && vaddr < KERNEL_MEMORY_VADDR_END) {
|
if (vaddr >= KERNEL_MEMORY_VADDR && vaddr < KERNEL_MEMORY_VADDR_END) {
|
||||||
var = *((const T*)&g_kernel_mem[vaddr & KERNEL_MEMORY_MASK]);
|
var = *((const T*)&g_kernel_mem[vaddr - KERNEL_MEMORY_VADDR]);
|
||||||
|
|
||||||
// Hardware I/O register reads
|
// Hardware I/O register reads
|
||||||
// 0x10XXXXXX- is physical address space, 0x1EXXXXXX is virtual address space
|
// 0x10XXXXXX- is physical address space, 0x1EXXXXXX is virtual address space
|
||||||
@ -65,23 +65,23 @@ inline void Read(T &var, const VAddr vaddr) {
|
|||||||
|
|
||||||
// ExeFS:/.code is loaded here
|
// ExeFS:/.code is loaded here
|
||||||
} else if ((vaddr >= EXEFS_CODE_VADDR) && (vaddr < EXEFS_CODE_VADDR_END)) {
|
} else if ((vaddr >= EXEFS_CODE_VADDR) && (vaddr < EXEFS_CODE_VADDR_END)) {
|
||||||
var = *((const T*)&g_exefs_code[vaddr & EXEFS_CODE_MASK]);
|
var = *((const T*)&g_exefs_code[vaddr - EXEFS_CODE_VADDR]);
|
||||||
|
|
||||||
// FCRAM - GSP heap
|
// 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]);
|
var = *((const T*)&g_heap_gsp[vaddr - HEAP_GSP_VADDR]);
|
||||||
|
|
||||||
// FCRAM - application heap
|
// 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]);
|
var = *((const T*)&g_heap[vaddr - HEAP_VADDR]);
|
||||||
|
|
||||||
// Shared memory
|
// Shared memory
|
||||||
} else if ((vaddr >= SHARED_MEMORY_VADDR) && (vaddr < SHARED_MEMORY_VADDR_END)) {
|
} else if ((vaddr >= SHARED_MEMORY_VADDR) && (vaddr < SHARED_MEMORY_VADDR_END)) {
|
||||||
var = *((const T*)&g_shared_mem[vaddr & SHARED_MEMORY_MASK]);
|
var = *((const T*)&g_shared_mem[vaddr - SHARED_MEMORY_VADDR]);
|
||||||
|
|
||||||
// System memory
|
// System memory
|
||||||
} else if ((vaddr >= SYSTEM_MEMORY_VADDR) && (vaddr < SYSTEM_MEMORY_VADDR_END)) {
|
} else if ((vaddr >= SYSTEM_MEMORY_VADDR) && (vaddr < SYSTEM_MEMORY_VADDR_END)) {
|
||||||
var = *((const T*)&g_system_mem[vaddr & SYSTEM_MEMORY_MASK]);
|
var = *((const T*)&g_system_mem[vaddr - SYSTEM_MEMORY_VADDR]);
|
||||||
|
|
||||||
// Config memory
|
// Config memory
|
||||||
} else if ((vaddr >= CONFIG_MEMORY_VADDR) && (vaddr < CONFIG_MEMORY_VADDR_END)) {
|
} else if ((vaddr >= CONFIG_MEMORY_VADDR) && (vaddr < CONFIG_MEMORY_VADDR_END)) {
|
||||||
@ -89,7 +89,7 @@ inline void Read(T &var, const VAddr vaddr) {
|
|||||||
|
|
||||||
// VRAM
|
// VRAM
|
||||||
} else if ((vaddr >= VRAM_VADDR) && (vaddr < VRAM_VADDR_END)) {
|
} else if ((vaddr >= VRAM_VADDR) && (vaddr < VRAM_VADDR_END)) {
|
||||||
var = *((const T*)&g_vram[vaddr & VRAM_MASK]);
|
var = *((const T*)&g_vram[vaddr - VRAM_VADDR]);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
ERROR_LOG(MEMMAP, "unknown Read%lu @ 0x%08X", sizeof(var) * 8, vaddr);
|
ERROR_LOG(MEMMAP, "unknown Read%lu @ 0x%08X", sizeof(var) * 8, vaddr);
|
||||||
@ -101,7 +101,7 @@ inline void Write(const VAddr vaddr, const T data) {
|
|||||||
|
|
||||||
// Kernel memory command buffer
|
// Kernel memory command buffer
|
||||||
if (vaddr >= KERNEL_MEMORY_VADDR && vaddr < KERNEL_MEMORY_VADDR_END) {
|
if (vaddr >= KERNEL_MEMORY_VADDR && vaddr < KERNEL_MEMORY_VADDR_END) {
|
||||||
*(T*)&g_kernel_mem[vaddr & KERNEL_MEMORY_MASK] = data;
|
*(T*)&g_kernel_mem[vaddr - KERNEL_MEMORY_VADDR] = data;
|
||||||
|
|
||||||
// Hardware I/O register writes
|
// Hardware I/O register writes
|
||||||
// 0x10XXXXXX- is physical address space, 0x1EXXXXXX is virtual address space
|
// 0x10XXXXXX- is physical address space, 0x1EXXXXXX is virtual address space
|
||||||
@ -110,27 +110,27 @@ inline void Write(const VAddr vaddr, const T data) {
|
|||||||
|
|
||||||
// ExeFS:/.code is loaded here
|
// ExeFS:/.code is loaded here
|
||||||
} else if ((vaddr >= EXEFS_CODE_VADDR) && (vaddr < EXEFS_CODE_VADDR_END)) {
|
} else if ((vaddr >= EXEFS_CODE_VADDR) && (vaddr < EXEFS_CODE_VADDR_END)) {
|
||||||
*(T*)&g_exefs_code[vaddr & EXEFS_CODE_MASK] = data;
|
*(T*)&g_exefs_code[vaddr - EXEFS_CODE_VADDR] = data;
|
||||||
|
|
||||||
// FCRAM - GSP heap
|
// 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;
|
*(T*)&g_heap_gsp[vaddr - HEAP_GSP_VADDR] = data;
|
||||||
|
|
||||||
// FCRAM - application heap
|
// 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;
|
*(T*)&g_heap[vaddr - HEAP_VADDR] = data;
|
||||||
|
|
||||||
// Shared memory
|
// Shared memory
|
||||||
} else if ((vaddr >= SHARED_MEMORY_VADDR) && (vaddr < SHARED_MEMORY_VADDR_END)) {
|
} else if ((vaddr >= SHARED_MEMORY_VADDR) && (vaddr < SHARED_MEMORY_VADDR_END)) {
|
||||||
*(T*)&g_shared_mem[vaddr & SHARED_MEMORY_MASK] = data;
|
*(T*)&g_shared_mem[vaddr - SHARED_MEMORY_VADDR] = data;
|
||||||
|
|
||||||
// System memory
|
// System memory
|
||||||
} else if ((vaddr >= SYSTEM_MEMORY_VADDR) && (vaddr < SYSTEM_MEMORY_VADDR_END)) {
|
} else if ((vaddr >= SYSTEM_MEMORY_VADDR) && (vaddr < SYSTEM_MEMORY_VADDR_END)) {
|
||||||
*(T*)&g_system_mem[vaddr & SYSTEM_MEMORY_MASK] = data;
|
*(T*)&g_system_mem[vaddr - SYSTEM_MEMORY_VADDR] = data;
|
||||||
|
|
||||||
// VRAM
|
// VRAM
|
||||||
} else if ((vaddr >= VRAM_VADDR) && (vaddr < VRAM_VADDR_END)) {
|
} else if ((vaddr >= VRAM_VADDR) && (vaddr < VRAM_VADDR_END)) {
|
||||||
*(T*)&g_vram[vaddr & VRAM_MASK] = data;
|
*(T*)&g_vram[vaddr - VRAM_VADDR] = data;
|
||||||
|
|
||||||
//} else if ((vaddr & 0xFFF00000) == 0x1FF00000) {
|
//} else if ((vaddr & 0xFFF00000) == 0x1FF00000) {
|
||||||
// _assert_msg_(MEMMAP, false, "umimplemented write to DSP memory");
|
// _assert_msg_(MEMMAP, false, "umimplemented write to DSP memory");
|
||||||
@ -148,31 +148,31 @@ inline void Write(const VAddr vaddr, const T data) {
|
|||||||
u8 *GetPointer(const VAddr vaddr) {
|
u8 *GetPointer(const VAddr vaddr) {
|
||||||
// Kernel memory command buffer
|
// Kernel memory command buffer
|
||||||
if (vaddr >= KERNEL_MEMORY_VADDR && vaddr < KERNEL_MEMORY_VADDR_END) {
|
if (vaddr >= KERNEL_MEMORY_VADDR && vaddr < KERNEL_MEMORY_VADDR_END) {
|
||||||
return g_kernel_mem + (vaddr & KERNEL_MEMORY_MASK);
|
return g_kernel_mem + (vaddr - KERNEL_MEMORY_VADDR);
|
||||||
|
|
||||||
// ExeFS:/.code is loaded here
|
// ExeFS:/.code is loaded here
|
||||||
} else if ((vaddr >= EXEFS_CODE_VADDR) && (vaddr < EXEFS_CODE_VADDR_END)) {
|
} else if ((vaddr >= EXEFS_CODE_VADDR) && (vaddr < EXEFS_CODE_VADDR_END)) {
|
||||||
return g_exefs_code + (vaddr & EXEFS_CODE_MASK);
|
return g_exefs_code + (vaddr - EXEFS_CODE_VADDR);
|
||||||
|
|
||||||
// FCRAM - GSP heap
|
// 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)) {
|
||||||
return g_heap_gsp + (vaddr & HEAP_GSP_MASK);
|
return g_heap_gsp + (vaddr - HEAP_GSP_VADDR);
|
||||||
|
|
||||||
// FCRAM - application heap
|
// FCRAM - application heap
|
||||||
} else if ((vaddr >= HEAP_VADDR) && (vaddr < HEAP_VADDR_END)) {
|
} else if ((vaddr >= HEAP_VADDR) && (vaddr < HEAP_VADDR_END)) {
|
||||||
return g_heap + (vaddr & HEAP_MASK);
|
return g_heap + (vaddr - HEAP_VADDR);
|
||||||
|
|
||||||
// Shared memory
|
// Shared memory
|
||||||
} else if ((vaddr >= SHARED_MEMORY_VADDR) && (vaddr < SHARED_MEMORY_VADDR_END)) {
|
} else if ((vaddr >= SHARED_MEMORY_VADDR) && (vaddr < SHARED_MEMORY_VADDR_END)) {
|
||||||
return g_shared_mem + (vaddr & SHARED_MEMORY_MASK);
|
return g_shared_mem + (vaddr - SHARED_MEMORY_VADDR);
|
||||||
|
|
||||||
// System memory
|
// System memory
|
||||||
} else if ((vaddr >= SYSTEM_MEMORY_VADDR) && (vaddr < SYSTEM_MEMORY_VADDR_END)) {
|
} else if ((vaddr >= SYSTEM_MEMORY_VADDR) && (vaddr < SYSTEM_MEMORY_VADDR_END)) {
|
||||||
return g_system_mem + (vaddr & SYSTEM_MEMORY_MASK);
|
return g_system_mem + (vaddr - SYSTEM_MEMORY_VADDR);
|
||||||
|
|
||||||
// VRAM
|
// VRAM
|
||||||
} else if ((vaddr >= VRAM_VADDR) && (vaddr < VRAM_VADDR_END)) {
|
} else if ((vaddr >= VRAM_VADDR) && (vaddr < VRAM_VADDR_END)) {
|
||||||
return g_vram + (vaddr & VRAM_MASK);
|
return g_vram + (vaddr - VRAM_VADDR);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
ERROR_LOG(MEMMAP, "unknown GetPointer @ 0x%08x", vaddr);
|
ERROR_LOG(MEMMAP, "unknown GetPointer @ 0x%08x", vaddr);
|
||||||
|
Loading…
Reference in New Issue
Block a user