summaryrefslogtreecommitdiff
path: root/src/core/memory.h
diff options
context:
space:
mode:
authorGravatar Yuri Kunde Schlesner2015-05-12 22:38:29 -0300
committerGravatar Yuri Kunde Schlesner2015-05-15 00:04:38 -0300
commit7ada357b2d12cf616672425a8961804b865354d6 (patch)
tree983003c1efc0950605eca3aa7d135b7c8fe9edcf /src/core/memory.h
parentMemmap: Remove unused declarations (diff)
downloadyuzu-7ada357b2d12cf616672425a8961804b865354d6.tar.gz
yuzu-7ada357b2d12cf616672425a8961804b865354d6.tar.xz
yuzu-7ada357b2d12cf616672425a8961804b865354d6.zip
Memmap: Re-organize memory function in two files
memory.cpp/h contains definitions related to acessing memory and configuring the address space mem_map.cpp/h contains higher-level definitions related to configuring the address space accoording to the kernel and allocating memory.
Diffstat (limited to 'src/core/memory.h')
-rw-r--r--src/core/memory.h125
1 files changed, 125 insertions, 0 deletions
diff --git a/src/core/memory.h b/src/core/memory.h
new file mode 100644
index 000000000..5ae7784e0
--- /dev/null
+++ b/src/core/memory.h
@@ -0,0 +1,125 @@
1// Copyright 2014 Citra Emulator Project
2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included.
4
5#pragma once
6
7#include "common/common_types.h"
8
9namespace Memory {
10
11const u32 PAGE_SIZE = 0x1000;
12
13/// Physical memory regions as seen from the ARM11
14enum : PAddr {
15 /// IO register area
16 IO_AREA_PADDR = 0x10100000,
17 IO_AREA_SIZE = 0x01000000, ///< IO area size (16MB)
18 IO_AREA_PADDR_END = IO_AREA_PADDR + IO_AREA_SIZE,
19
20 /// MPCore internal memory region
21 MPCORE_RAM_PADDR = 0x17E00000,
22 MPCORE_RAM_SIZE = 0x00002000, ///< MPCore internal memory size (8KB)
23 MPCORE_RAM_PADDR_END = MPCORE_RAM_PADDR + MPCORE_RAM_SIZE,
24
25 /// Video memory
26 VRAM_PADDR = 0x18000000,
27 VRAM_SIZE = 0x00600000, ///< VRAM size (6MB)
28 VRAM_PADDR_END = VRAM_PADDR + VRAM_SIZE,
29
30 /// DSP memory
31 DSP_RAM_PADDR = 0x1FF00000,
32 DSP_RAM_SIZE = 0x00080000, ///< DSP memory size (512KB)
33 DSP_RAM_PADDR_END = DSP_RAM_PADDR + DSP_RAM_SIZE,
34
35 /// AXI WRAM
36 AXI_WRAM_PADDR = 0x1FF80000,
37 AXI_WRAM_SIZE = 0x00080000, ///< AXI WRAM size (512KB)
38 AXI_WRAM_PADDR_END = AXI_WRAM_PADDR + AXI_WRAM_SIZE,
39
40 /// Main FCRAM
41 FCRAM_PADDR = 0x20000000,
42 FCRAM_SIZE = 0x08000000, ///< FCRAM size (128MB)
43 FCRAM_PADDR_END = FCRAM_PADDR + FCRAM_SIZE,
44};
45
46/// Virtual user-space memory regions
47enum : VAddr {
48 /// Where the application text, data and bss reside.
49 PROCESS_IMAGE_VADDR = 0x00100000,
50 PROCESS_IMAGE_MAX_SIZE = 0x03F00000,
51 PROCESS_IMAGE_VADDR_END = PROCESS_IMAGE_VADDR + PROCESS_IMAGE_MAX_SIZE,
52
53 /// Area where IPC buffers are mapped onto.
54 IPC_MAPPING_VADDR = 0x04000000,
55 IPC_MAPPING_SIZE = 0x04000000,
56 IPC_MAPPING_VADDR_END = IPC_MAPPING_VADDR + IPC_MAPPING_SIZE,
57
58 /// Application heap (includes stack).
59 HEAP_VADDR = 0x08000000,
60 HEAP_SIZE = 0x08000000,
61 HEAP_VADDR_END = HEAP_VADDR + HEAP_SIZE,
62
63 /// Area where shared memory buffers are mapped onto.
64 SHARED_MEMORY_VADDR = 0x10000000,
65 SHARED_MEMORY_SIZE = 0x04000000,
66 SHARED_MEMORY_VADDR_END = SHARED_MEMORY_VADDR + SHARED_MEMORY_SIZE,
67
68 /// Maps 1:1 to an offset in FCRAM. Used for HW allocations that need to be linear in physical memory.
69 LINEAR_HEAP_VADDR = 0x14000000,
70 LINEAR_HEAP_SIZE = 0x08000000,
71 LINEAR_HEAP_VADDR_END = LINEAR_HEAP_VADDR + LINEAR_HEAP_SIZE,
72
73 /// Maps 1:1 to the IO register area.
74 IO_AREA_VADDR = 0x1EC00000,
75 IO_AREA_VADDR_END = IO_AREA_VADDR + IO_AREA_SIZE,
76
77 /// Maps 1:1 to VRAM.
78 VRAM_VADDR = 0x1F000000,
79 VRAM_VADDR_END = VRAM_VADDR + VRAM_SIZE,
80
81 /// Maps 1:1 to DSP memory.
82 DSP_RAM_VADDR = 0x1FF00000,
83 DSP_RAM_VADDR_END = DSP_RAM_VADDR + DSP_RAM_SIZE,
84
85 /// Read-only page containing kernel and system configuration values.
86 CONFIG_MEMORY_VADDR = 0x1FF80000,
87 CONFIG_MEMORY_SIZE = 0x00001000,
88 CONFIG_MEMORY_VADDR_END = CONFIG_MEMORY_VADDR + CONFIG_MEMORY_SIZE,
89
90 /// Usually read-only page containing mostly values read from hardware.
91 SHARED_PAGE_VADDR = 0x1FF81000,
92 SHARED_PAGE_SIZE = 0x00001000,
93 SHARED_PAGE_VADDR_END = SHARED_PAGE_VADDR + SHARED_PAGE_SIZE,
94
95 // TODO(yuriks): The size of this area is dynamic, the kernel grows
96 // it as more and more threads are created. For now we'll just use a
97 // hardcoded value.
98 /// Area where TLS (Thread-Local Storage) buffers are allocated.
99 TLS_AREA_VADDR = 0x1FF82000,
100 TLS_AREA_SIZE = 0x00030000, // Each TLS buffer is 0x200 bytes, allows for 300 threads
101 TLS_AREA_VADDR_END = TLS_AREA_VADDR + TLS_AREA_SIZE,
102};
103
104u8 Read8(VAddr addr);
105u16 Read16(VAddr addr);
106u32 Read32(VAddr addr);
107u64 Read64(VAddr addr);
108
109void Write8(VAddr addr, u8 data);
110void Write16(VAddr addr, u16 data);
111void Write32(VAddr addr, u32 data);
112void Write64(VAddr addr, u64 data);
113
114void WriteBlock(VAddr addr, const u8* data, size_t size);
115
116u8* GetPointer(VAddr virtual_address);
117
118/**
119 * Gets a pointer to the memory region beginning at the specified physical address.
120 *
121 * @note This is currently implemented using PhysicalToVirtualAddress().
122 */
123u8* GetPhysicalPointer(PAddr address);
124
125}