summaryrefslogtreecommitdiff
path: root/src/core/memory.h
diff options
context:
space:
mode:
authorGravatar Yuri Kunde Schlesner2015-08-22 14:01:57 -0700
committerGravatar Yuri Kunde Schlesner2015-08-22 14:01:57 -0700
commit3efb205a68d38fe377b2c27349d91ec4c6a2d390 (patch)
tree4326d8394e66fec3831ce6b9851da689e5aa78e8 /src/core/memory.h
parentMerge pull request #1056 from lioncash/emitter (diff)
parentKernel: Remove unused legacy heap MapBlock_* functions (diff)
downloadyuzu-3efb205a68d38fe377b2c27349d91ec4c6a2d390.tar.gz
yuzu-3efb205a68d38fe377b2c27349d91ec4c6a2d390.tar.xz
yuzu-3efb205a68d38fe377b2c27349d91ec4c6a2d390.zip
Merge pull request #1025 from yuriks/heap-management
Kernel: Correct(er) handling of Heap and Linear Heap allocations
Diffstat (limited to 'src/core/memory.h')
-rw-r--r--src/core/memory.h22
1 files changed, 21 insertions, 1 deletions
diff --git a/src/core/memory.h b/src/core/memory.h
index 418609de0..c136cbd55 100644
--- a/src/core/memory.h
+++ b/src/core/memory.h
@@ -15,6 +15,8 @@ namespace Memory {
15 * be mapped. 15 * be mapped.
16 */ 16 */
17const u32 PAGE_SIZE = 0x1000; 17const u32 PAGE_SIZE = 0x1000;
18const u32 PAGE_MASK = PAGE_SIZE - 1;
19const int PAGE_BITS = 12;
18 20
19/// Physical memory regions as seen from the ARM11 21/// Physical memory regions as seen from the ARM11
20enum : PAddr { 22enum : PAddr {
@@ -103,8 +105,15 @@ enum : VAddr {
103 // hardcoded value. 105 // hardcoded value.
104 /// Area where TLS (Thread-Local Storage) buffers are allocated. 106 /// Area where TLS (Thread-Local Storage) buffers are allocated.
105 TLS_AREA_VADDR = 0x1FF82000, 107 TLS_AREA_VADDR = 0x1FF82000,
106 TLS_AREA_SIZE = 0x00030000, // Each TLS buffer is 0x200 bytes, allows for 300 threads 108 TLS_ENTRY_SIZE = 0x200,
109 TLS_AREA_SIZE = 300 * TLS_ENTRY_SIZE, // Allows for up to 300 threads
107 TLS_AREA_VADDR_END = TLS_AREA_VADDR + TLS_AREA_SIZE, 110 TLS_AREA_VADDR_END = TLS_AREA_VADDR + TLS_AREA_SIZE,
111
112
113 /// Equivalent to LINEAR_HEAP_VADDR, but expanded to cover the extra memory in the New 3DS.
114 NEW_LINEAR_HEAP_VADDR = 0x30000000,
115 NEW_LINEAR_HEAP_SIZE = 0x10000000,
116 NEW_LINEAR_HEAP_VADDR_END = NEW_LINEAR_HEAP_VADDR + NEW_LINEAR_HEAP_SIZE,
108}; 117};
109 118
110u8 Read8(VAddr addr); 119u8 Read8(VAddr addr);
@@ -122,6 +131,17 @@ void WriteBlock(VAddr addr, const u8* data, size_t size);
122u8* GetPointer(VAddr virtual_address); 131u8* GetPointer(VAddr virtual_address);
123 132
124/** 133/**
134* Converts a virtual address inside a region with 1:1 mapping to physical memory to a physical
135* address. This should be used by services to translate addresses for use by the hardware.
136*/
137PAddr VirtualToPhysicalAddress(VAddr addr);
138
139/**
140* Undoes a mapping performed by VirtualToPhysicalAddress().
141*/
142VAddr PhysicalToVirtualAddress(PAddr addr);
143
144/**
125 * Gets a pointer to the memory region beginning at the specified physical address. 145 * Gets a pointer to the memory region beginning at the specified physical address.
126 * 146 *
127 * @note This is currently implemented using PhysicalToVirtualAddress(). 147 * @note This is currently implemented using PhysicalToVirtualAddress().