mirror of
https://github.com/yuzu-mirror/yuzu
synced 2024-11-24 10:23:01 +00:00
MemMap: Renamed "GSP" heap to "linear", as this is not specific to GSP.
- Linear simply indicates that the mapped physical address is always MappedVAddr+0x0C000000, thus this memory can be used for hardware devices' DMA (such as the GPU).
This commit is contained in:
parent
3a75c8069e
commit
4cb7a44d4e
5 changed files with 34 additions and 34 deletions
|
@ -43,7 +43,7 @@ static Result ControlMemory(u32* out_addr, u32 operation, u32 addr0, u32 addr1,
|
||||||
|
|
||||||
// Map GSP heap memory
|
// Map GSP heap memory
|
||||||
case MEMORY_OPERATION_GSP_HEAP:
|
case MEMORY_OPERATION_GSP_HEAP:
|
||||||
*out_addr = Memory::MapBlock_HeapGSP(size, operation, permissions);
|
*out_addr = Memory::MapBlock_HeapLinear(size, operation, permissions);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// Unknown ControlMemory operation
|
// Unknown ControlMemory operation
|
||||||
|
|
|
@ -18,7 +18,7 @@ static MemArena arena; ///< The MemArena class
|
||||||
u8* g_exefs_code = nullptr; ///< ExeFS:/.code is loaded here
|
u8* g_exefs_code = nullptr; ///< ExeFS:/.code is loaded here
|
||||||
u8* g_system_mem = nullptr; ///< System memory
|
u8* g_system_mem = nullptr; ///< System memory
|
||||||
u8* g_heap = nullptr; ///< Application heap (main memory)
|
u8* g_heap = nullptr; ///< Application heap (main memory)
|
||||||
u8* g_heap_gsp = nullptr; ///< GSP heap (main memory)
|
u8* g_heap_linear = nullptr; ///< Linear heap
|
||||||
u8* g_vram = nullptr; ///< Video memory (VRAM) pointer
|
u8* g_vram = nullptr; ///< Video memory (VRAM) pointer
|
||||||
u8* g_shared_mem = nullptr; ///< Shared memory
|
u8* g_shared_mem = nullptr; ///< Shared memory
|
||||||
u8* g_kernel_mem; ///< Kernel memory
|
u8* g_kernel_mem; ///< Kernel memory
|
||||||
|
@ -42,7 +42,7 @@ static MemoryView g_views[] = {
|
||||||
{&g_shared_mem, &physical_shared_mem, SHARED_MEMORY_VADDR, SHARED_MEMORY_SIZE, 0},
|
{&g_shared_mem, &physical_shared_mem, SHARED_MEMORY_VADDR, SHARED_MEMORY_SIZE, 0},
|
||||||
{&g_system_mem, &physical_system_mem, SYSTEM_MEMORY_VADDR, SYSTEM_MEMORY_SIZE, 0},
|
{&g_system_mem, &physical_system_mem, SYSTEM_MEMORY_VADDR, SYSTEM_MEMORY_SIZE, 0},
|
||||||
{&g_kernel_mem, &physical_kernel_mem, KERNEL_MEMORY_VADDR, KERNEL_MEMORY_SIZE, 0},
|
{&g_kernel_mem, &physical_kernel_mem, KERNEL_MEMORY_VADDR, KERNEL_MEMORY_SIZE, 0},
|
||||||
{&g_heap_gsp, &physical_heap_gsp, HEAP_GSP_VADDR, HEAP_GSP_SIZE, 0},
|
{&g_heap_linear, &physical_heap_gsp, HEAP_LINEAR_VADDR, HEAP_LINEAR_SIZE, 0},
|
||||||
};
|
};
|
||||||
|
|
||||||
/*static MemoryView views[] =
|
/*static MemoryView views[] =
|
||||||
|
|
|
@ -57,11 +57,11 @@ enum : u32 {
|
||||||
HEAP_VADDR = 0x08000000,
|
HEAP_VADDR = 0x08000000,
|
||||||
HEAP_VADDR_END = (HEAP_VADDR + HEAP_SIZE),
|
HEAP_VADDR_END = (HEAP_VADDR + HEAP_SIZE),
|
||||||
|
|
||||||
HEAP_GSP_SIZE = 0x02000000, ///< GSP heap size... TODO: Define correctly?
|
HEAP_LINEAR_SIZE = 0x08000000, ///< Linear heap size... TODO: Define correctly?
|
||||||
HEAP_GSP_VADDR = 0x14000000,
|
HEAP_LINEAR_VADDR = 0x14000000,
|
||||||
HEAP_GSP_VADDR_END = (HEAP_GSP_VADDR + HEAP_GSP_SIZE),
|
HEAP_LINEAR_VADDR_END = (HEAP_LINEAR_VADDR + HEAP_LINEAR_SIZE),
|
||||||
HEAP_GSP_PADDR = 0x00000000,
|
HEAP_LINEAR_PADDR = 0x00000000,
|
||||||
HEAP_GSP_PADDR_END = (HEAP_GSP_PADDR + HEAP_GSP_SIZE),
|
HEAP_LINEAR_PADDR_END = (HEAP_LINEAR_PADDR + HEAP_LINEAR_SIZE),
|
||||||
|
|
||||||
HARDWARE_IO_SIZE = 0x01000000,
|
HARDWARE_IO_SIZE = 0x01000000,
|
||||||
HARDWARE_IO_PADDR = 0x10000000, ///< IO physical address start
|
HARDWARE_IO_PADDR = 0x10000000, ///< IO physical address start
|
||||||
|
@ -112,7 +112,7 @@ extern u8 *g_base;
|
||||||
// These are guaranteed to point to "low memory" addresses (sub-32-bit).
|
// These are guaranteed to point to "low memory" addresses (sub-32-bit).
|
||||||
// 64-bit: Pointers to low-mem (sub-0x10000000) mirror
|
// 64-bit: Pointers to low-mem (sub-0x10000000) mirror
|
||||||
// 32-bit: Same as the corresponding physical/virtual pointers.
|
// 32-bit: Same as the corresponding physical/virtual pointers.
|
||||||
extern u8* g_heap_gsp; ///< GSP heap (main memory)
|
extern u8* g_heap_linear; ///< Linear heap (main memory)
|
||||||
extern u8* g_heap; ///< Application heap (main memory)
|
extern u8* g_heap; ///< Application heap (main memory)
|
||||||
extern u8* g_vram; ///< Video memory (VRAM)
|
extern u8* g_vram; ///< Video memory (VRAM)
|
||||||
extern u8* g_shared_mem; ///< Shared memory
|
extern u8* g_shared_mem; ///< Shared memory
|
||||||
|
@ -159,7 +159,7 @@ u32 MapBlock_Heap(u32 size, u32 operation, u32 permissions);
|
||||||
* @param operation Memory map operation type
|
* @param operation Memory map operation type
|
||||||
* @param permissions Control memory permissions
|
* @param permissions Control memory permissions
|
||||||
*/
|
*/
|
||||||
u32 MapBlock_HeapGSP(u32 size, u32 operation, u32 permissions);
|
u32 MapBlock_HeapLinear(u32 size, u32 operation, u32 permissions);
|
||||||
|
|
||||||
inline const char* GetCharPointer(const VAddr address) {
|
inline const char* GetCharPointer(const VAddr address) {
|
||||||
return (const char *)GetPointer(address);
|
return (const char *)GetPointer(address);
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
namespace Memory {
|
namespace Memory {
|
||||||
|
|
||||||
static std::map<u32, MemoryBlock> heap_map;
|
static std::map<u32, MemoryBlock> heap_map;
|
||||||
static std::map<u32, MemoryBlock> heap_gsp_map;
|
static std::map<u32, MemoryBlock> heap_linear_map;
|
||||||
static std::map<u32, MemoryBlock> shared_map;
|
static std::map<u32, MemoryBlock> shared_map;
|
||||||
|
|
||||||
/// Convert a physical address to virtual address
|
/// Convert a physical address to virtual address
|
||||||
|
@ -67,9 +67,9 @@ inline void Read(T &var, const VAddr vaddr) {
|
||||||
} 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_VADDR]);
|
var = *((const T*)&g_exefs_code[vaddr - EXEFS_CODE_VADDR]);
|
||||||
|
|
||||||
// FCRAM - GSP heap
|
// FCRAM - linear heap
|
||||||
} else if ((vaddr >= HEAP_GSP_VADDR) && (vaddr < HEAP_GSP_VADDR_END)) {
|
} else if ((vaddr >= HEAP_LINEAR_VADDR) && (vaddr < HEAP_LINEAR_VADDR_END)) {
|
||||||
var = *((const T*)&g_heap_gsp[vaddr - HEAP_GSP_VADDR]);
|
var = *((const T*)&g_heap_linear[vaddr - HEAP_LINEAR_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)) {
|
||||||
|
@ -112,9 +112,9 @@ inline void Write(const VAddr vaddr, const T data) {
|
||||||
} 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_VADDR] = data;
|
*(T*)&g_exefs_code[vaddr - EXEFS_CODE_VADDR] = data;
|
||||||
|
|
||||||
// FCRAM - GSP heap
|
// FCRAM - linear heap
|
||||||
} else if ((vaddr >= HEAP_GSP_VADDR) && (vaddr < HEAP_GSP_VADDR_END)) {
|
} else if ((vaddr >= HEAP_LINEAR_VADDR) && (vaddr < HEAP_LINEAR_VADDR_END)) {
|
||||||
*(T*)&g_heap_gsp[vaddr - HEAP_GSP_VADDR] = data;
|
*(T*)&g_heap_linear[vaddr - HEAP_LINEAR_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)) {
|
||||||
|
@ -154,9 +154,9 @@ u8 *GetPointer(const VAddr vaddr) {
|
||||||
} 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_VADDR);
|
return g_exefs_code + (vaddr - EXEFS_CODE_VADDR);
|
||||||
|
|
||||||
// FCRAM - GSP heap
|
// FCRAM - linear heap
|
||||||
} else if ((vaddr >= HEAP_GSP_VADDR) && (vaddr < HEAP_GSP_VADDR_END)) {
|
} else if ((vaddr >= HEAP_LINEAR_VADDR) && (vaddr < HEAP_LINEAR_VADDR_END)) {
|
||||||
return g_heap_gsp + (vaddr - HEAP_GSP_VADDR);
|
return g_heap_linear + (vaddr - HEAP_LINEAR_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)) {
|
||||||
|
@ -204,24 +204,24 @@ u32 MapBlock_Heap(u32 size, u32 operation, u32 permissions) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Maps a block of memory on the GSP heap
|
* Maps a block of memory on the linear heap
|
||||||
* @param size Size of block in bytes
|
* @param size Size of block in bytes
|
||||||
* @param operation Memory map operation type
|
* @param operation Memory map operation type
|
||||||
* @param flags Memory allocation flags
|
* @param flags Memory allocation flags
|
||||||
*/
|
*/
|
||||||
u32 MapBlock_HeapGSP(u32 size, u32 operation, u32 permissions) {
|
u32 MapBlock_HeapLinear(u32 size, u32 operation, u32 permissions) {
|
||||||
MemoryBlock block;
|
MemoryBlock block;
|
||||||
|
|
||||||
block.base_address = HEAP_GSP_VADDR;
|
block.base_address = HEAP_LINEAR_VADDR;
|
||||||
block.size = size;
|
block.size = size;
|
||||||
block.operation = operation;
|
block.operation = operation;
|
||||||
block.permissions = permissions;
|
block.permissions = permissions;
|
||||||
|
|
||||||
if (heap_gsp_map.size() > 0) {
|
if (heap_linear_map.size() > 0) {
|
||||||
const MemoryBlock last_block = heap_gsp_map.rbegin()->second;
|
const MemoryBlock last_block = heap_linear_map.rbegin()->second;
|
||||||
block.address = last_block.address + last_block.size;
|
block.address = last_block.address + last_block.size;
|
||||||
}
|
}
|
||||||
heap_gsp_map[block.GetVirtualAddress()] = block;
|
heap_linear_map[block.GetVirtualAddress()] = block;
|
||||||
|
|
||||||
return block.GetVirtualAddress();
|
return block.GetVirtualAddress();
|
||||||
}
|
}
|
||||||
|
|
|
@ -116,7 +116,7 @@ struct Regs {
|
||||||
u32 address;
|
u32 address;
|
||||||
|
|
||||||
u32 GetPhysicalAddress() const {
|
u32 GetPhysicalAddress() const {
|
||||||
return DecodeAddressRegister(address) - Memory::FCRAM_PADDR + Memory::HEAP_GSP_VADDR;
|
return DecodeAddressRegister(address) - Memory::FCRAM_PADDR + Memory::HEAP_LINEAR_VADDR;
|
||||||
}
|
}
|
||||||
|
|
||||||
// texture1 and texture2 store the texture format directly after the address
|
// texture1 and texture2 store the texture format directly after the address
|
||||||
|
@ -312,7 +312,7 @@ struct Regs {
|
||||||
|
|
||||||
inline u32 GetBaseAddress() const {
|
inline u32 GetBaseAddress() const {
|
||||||
// TODO: Ugly, should fix PhysicalToVirtualAddress instead
|
// TODO: Ugly, should fix PhysicalToVirtualAddress instead
|
||||||
return DecodeAddressRegister(base_address) - Memory::FCRAM_PADDR + Memory::HEAP_GSP_VADDR;
|
return DecodeAddressRegister(base_address) - Memory::FCRAM_PADDR + Memory::HEAP_LINEAR_VADDR;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Descriptor for internal vertex attributes
|
// Descriptor for internal vertex attributes
|
||||||
|
|
Loading…
Reference in a new issue