Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
Suyu
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
many-archive
Suyu
Commits
b7cd4c9e
There was an error fetching the commit references. Please try again later.
Commit
b7cd4c9e
authored
10 years ago
by
bunnei
Browse files
Options
Downloads
Patches
Plain Diff
added functions to map Heap and Shared memory space
parent
66e1f8ab
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/core/mem_map.cpp
+2
-2
2 additions, 2 deletions
src/core/mem_map.cpp
src/core/mem_map.h
+23
-4
23 additions, 4 deletions
src/core/mem_map.h
src/core/mem_map_funcs.cpp
+51
-3
51 additions, 3 deletions
src/core/mem_map_funcs.cpp
with
76 additions
and
9 deletions
src/core/mem_map.cpp
+
2
−
2
View file @
b7cd4c9e
...
...
@@ -16,15 +16,15 @@ u8* g_base = NULL; ///< The base pointer to the aut
MemArena
g_arena
;
///< The MemArena class
u8
*
g_heap_gsp
=
NULL
;
///< GSP heap (main memory)
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_physical_bootrom
=
NULL
;
///< Bootrom physical memory
u8
*
g_uncached_bootrom
=
NULL
;
u8
*
g_physical_fcram
=
NULL
;
///< Main physical memory (FCRAM)
u8
*
g_physical_heap_gsp
=
NULL
;
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
...
...
This diff is collapsed.
Click to expand it.
src/core/mem_map.h
+
23
−
4
View file @
b7cd4c9e
...
...
@@ -22,6 +22,8 @@ enum {
HEAP_GSP_SIZE
=
0x02000000
,
///< GSP heap size... TODO: Define correctly?
HEAP_SIZE
=
FCRAM_SIZE
,
///< Application heap size
SHARED_MEMORY_VADDR
=
0x10000000
,
///< Shared memory
HEAP_PADDR
=
HEAP_GSP_SIZE
,
HEAP_PADDR_END
=
(
HEAP_PADDR
+
HEAP_SIZE
),
HEAP_VADDR
=
0x08000000
,
...
...
@@ -49,10 +51,11 @@ enum {
////////////////////////////////////////////////////////////////////////////////////////////////////
/// Represents a block of
heap
memory mapped by ControlMemory
struct
Heap
Block
{
Heap
Block
()
:
base_address
(
0
),
address
(
0
),
size
(
0
),
operation
(
0
),
permissions
(
0
)
{
/// Represents a block of memory mapped by ControlMemory
/MapMemoryBlock
struct
Memory
Block
{
Memory
Block
()
:
handle
(
0
),
base_address
(
0
),
address
(
0
),
size
(
0
),
operation
(
0
),
permissions
(
0
)
{
}
u32
handle
;
u32
base_address
;
u32
address
;
u32
size
;
...
...
@@ -98,10 +101,26 @@ void Write32(const u32 addr, const u32 data);
u8
*
GetPointer
(
const
u32
Address
);
/**
* Maps a block of memory in shared memory
* @param handle Handle to map memory block for
* @param addr Address to map memory block to
* @param permissions Memory map permissions
*/
u32
MapBlock_Shared
(
u32
handle
,
u32
addr
,
u32
permissions
)
;
/**
* Maps a block of memory on the heap
* @param size Size of block in bytes
* @param operation Memory map operation type
* @param flags Memory allocation flags
*/
u32
MapBlock_Heap
(
u32
size
,
u32
operation
,
u32
permissions
);
/**
* Maps a block of memory on the GSP heap
* @param size Size of block in bytes
* @param operation
Control m
emory operation
* @param operation
M
emory
map
operation
type
* @param permissions Control memory permissions
*/
u32
MapBlock_HeapGSP
(
u32
size
,
u32
operation
,
u32
permissions
);
...
...
This diff is collapsed.
Click to expand it.
src/core/mem_map_funcs.cpp
+
51
−
3
View file @
b7cd4c9e
...
...
@@ -12,7 +12,9 @@
namespace
Memory
{
std
::
map
<
u32
,
HeapBlock
>
g_heap_gsp_map
;
std
::
map
<
u32
,
MemoryBlock
>
g_heap_map
;
std
::
map
<
u32
,
MemoryBlock
>
g_heap_gsp_map
;
std
::
map
<
u32
,
MemoryBlock
>
g_shared_map
;
/// Convert a physical address to virtual address
u32
_AddressPhysicalToVirtual
(
const
u32
addr
)
{
...
...
@@ -120,13 +122,59 @@ u8 *GetPointer(const u32 addr) {
}
}
/**
* Maps a block of memory in shared memory
* @param handle Handle to map memory block for
* @param addr Address to map memory block to
* @param permissions Memory map permissions
*/
u32
MapBlock_Shared
(
u32
handle
,
u32
addr
,
u32
permissions
)
{
MemoryBlock
block
;
block
.
handle
=
handle
;
block
.
base_address
=
addr
;
block
.
permissions
=
permissions
;
if
(
g_shared_map
.
size
()
>
0
)
{
const
MemoryBlock
last_block
=
g_shared_map
.
rbegin
()
->
second
;
block
.
address
=
last_block
.
address
+
last_block
.
size
;
}
g_shared_map
[
block
.
GetVirtualAddress
()]
=
block
;
return
block
.
GetVirtualAddress
();
}
/**
* Maps a block of memory on the heap
* @param size Size of block in bytes
* @param operation Memory map operation type
* @param flags Memory allocation flags
*/
u32
MapBlock_Heap
(
u32
size
,
u32
operation
,
u32
permissions
)
{
MemoryBlock
block
;
block
.
base_address
=
HEAP_VADDR
;
block
.
size
=
size
;
block
.
operation
=
operation
;
block
.
permissions
=
permissions
;
if
(
g_heap_map
.
size
()
>
0
)
{
const
MemoryBlock
last_block
=
g_heap_map
.
rbegin
()
->
second
;
block
.
address
=
last_block
.
address
+
last_block
.
size
;
}
g_heap_map
[
block
.
GetVirtualAddress
()]
=
block
;
return
block
.
GetVirtualAddress
();
}
/**
* Maps a block of memory on the GSP heap
* @param size Size of block in bytes
* @param operation Memory map operation type
* @param flags Memory allocation flags
*/
u32
MapBlock_HeapGSP
(
u32
size
,
u32
operation
,
u32
permissions
)
{
Heap
Block
block
;
Memory
Block
block
;
block
.
base_address
=
HEAP_GSP_VADDR
;
block
.
size
=
size
;
...
...
@@ -134,7 +182,7 @@ u32 MapBlock_HeapGSP(u32 size, u32 operation, u32 permissions) {
block
.
permissions
=
permissions
;
if
(
g_heap_gsp_map
.
size
()
>
0
)
{
const
Heap
Block
last_block
=
g_heap_gsp_map
.
rbegin
()
->
second
;
const
Memory
Block
last_block
=
g_heap_gsp_map
.
rbegin
()
->
second
;
block
.
address
=
last_block
.
address
+
last_block
.
size
;
}
g_heap_gsp_map
[
block
.
GetVirtualAddress
()]
=
block
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment