@ -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_Heap GSP ( u32 size , u32 operation , u32 permissions ) {
u32 MapBlock_Heap Linear ( 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 ( ) ;
}
}