diff options
| author | 2015-05-12 22:38:29 -0300 | |
|---|---|---|
| committer | 2015-05-15 00:04:38 -0300 | |
| commit | 7ada357b2d12cf616672425a8961804b865354d6 (patch) | |
| tree | 983003c1efc0950605eca3aa7d135b7c8fe9edcf /src | |
| parent | Memmap: Remove unused declarations (diff) | |
| download | yuzu-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')
34 files changed, 254 insertions, 266 deletions
diff --git a/src/citra_qt/debugger/callstack.cpp b/src/citra_qt/debugger/callstack.cpp index 3742c2d38..94e204717 100644 --- a/src/citra_qt/debugger/callstack.cpp +++ b/src/citra_qt/debugger/callstack.cpp | |||
| @@ -8,7 +8,7 @@ | |||
| 8 | 8 | ||
| 9 | #include "core/core.h" | 9 | #include "core/core.h" |
| 10 | #include "core/arm/arm_interface.h" | 10 | #include "core/arm/arm_interface.h" |
| 11 | #include "core/mem_map.h" | 11 | #include "core/memory.h" |
| 12 | #include "common/symbols.h" | 12 | #include "common/symbols.h" |
| 13 | #include "core/arm/disassembler/arm_disasm.h" | 13 | #include "core/arm/disassembler/arm_disasm.h" |
| 14 | 14 | ||
diff --git a/src/citra_qt/debugger/disassembler.cpp b/src/citra_qt/debugger/disassembler.cpp index 780607e82..e99ec1b30 100644 --- a/src/citra_qt/debugger/disassembler.cpp +++ b/src/citra_qt/debugger/disassembler.cpp | |||
| @@ -7,7 +7,7 @@ | |||
| 7 | #include "../bootmanager.h" | 7 | #include "../bootmanager.h" |
| 8 | #include "../hotkeys.h" | 8 | #include "../hotkeys.h" |
| 9 | 9 | ||
| 10 | #include "core/mem_map.h" | 10 | #include "core/memory.h" |
| 11 | 11 | ||
| 12 | #include "core/core.h" | 12 | #include "core/core.h" |
| 13 | #include "common/break_points.h" | 13 | #include "common/break_points.h" |
diff --git a/src/citra_qt/debugger/graphics_framebuffer.cpp b/src/citra_qt/debugger/graphics_framebuffer.cpp index 3287b4706..0c1a3f47f 100644 --- a/src/citra_qt/debugger/graphics_framebuffer.cpp +++ b/src/citra_qt/debugger/graphics_framebuffer.cpp | |||
| @@ -10,6 +10,8 @@ | |||
| 10 | #include <QSpinBox> | 10 | #include <QSpinBox> |
| 11 | 11 | ||
| 12 | #include "core/hw/gpu.h" | 12 | #include "core/hw/gpu.h" |
| 13 | #include "core/memory.h" | ||
| 14 | |||
| 13 | #include "video_core/color.h" | 15 | #include "video_core/color.h" |
| 14 | #include "video_core/pica.h" | 16 | #include "video_core/pica.h" |
| 15 | #include "video_core/utils.h" | 17 | #include "video_core/utils.h" |
diff --git a/src/citra_qt/debugger/ramview.cpp b/src/citra_qt/debugger/ramview.cpp index 7149a0485..b6ebc7fc4 100644 --- a/src/citra_qt/debugger/ramview.cpp +++ b/src/citra_qt/debugger/ramview.cpp | |||
| @@ -4,8 +4,6 @@ | |||
| 4 | 4 | ||
| 5 | #include "ramview.h" | 5 | #include "ramview.h" |
| 6 | 6 | ||
| 7 | #include "core/mem_map.h" | ||
| 8 | |||
| 9 | 7 | ||
| 10 | GRamView::GRamView(QWidget* parent) : QHexEdit(parent) | 8 | GRamView::GRamView(QWidget* parent) : QHexEdit(parent) |
| 11 | { | 9 | { |
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index ebedcb710..3b67cc49d 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt | |||
| @@ -99,7 +99,7 @@ set(SRCS | |||
| 99 | loader/loader.cpp | 99 | loader/loader.cpp |
| 100 | loader/ncch.cpp | 100 | loader/ncch.cpp |
| 101 | mem_map.cpp | 101 | mem_map.cpp |
| 102 | mem_map_funcs.cpp | 102 | memory.cpp |
| 103 | settings.cpp | 103 | settings.cpp |
| 104 | system.cpp | 104 | system.cpp |
| 105 | ) | 105 | ) |
| @@ -211,6 +211,7 @@ set(HEADERS | |||
| 211 | loader/loader.h | 211 | loader/loader.h |
| 212 | loader/ncch.h | 212 | loader/ncch.h |
| 213 | mem_map.h | 213 | mem_map.h |
| 214 | memory.h | ||
| 214 | settings.h | 215 | settings.h |
| 215 | system.h | 216 | system.h |
| 216 | ) | 217 | ) |
diff --git a/src/core/arm/dyncom/arm_dyncom_interpreter.cpp b/src/core/arm/dyncom/arm_dyncom_interpreter.cpp index 8c52bdb72..b79fd1719 100644 --- a/src/core/arm/dyncom/arm_dyncom_interpreter.cpp +++ b/src/core/arm/dyncom/arm_dyncom_interpreter.cpp | |||
| @@ -10,7 +10,7 @@ | |||
| 10 | #include "common/logging/log.h" | 10 | #include "common/logging/log.h" |
| 11 | #include "common/profiler.h" | 11 | #include "common/profiler.h" |
| 12 | 12 | ||
| 13 | #include "core/mem_map.h" | 13 | #include "core/memory.h" |
| 14 | #include "core/hle/svc.h" | 14 | #include "core/hle/svc.h" |
| 15 | #include "core/arm/disassembler/arm_disasm.h" | 15 | #include "core/arm/disassembler/arm_disasm.h" |
| 16 | #include "core/arm/dyncom/arm_dyncom_interpreter.h" | 16 | #include "core/arm/dyncom/arm_dyncom_interpreter.h" |
diff --git a/src/core/arm/interpreter/arminit.cpp b/src/core/arm/interpreter/arminit.cpp index 31b2bab06..680a94a39 100644 --- a/src/core/arm/interpreter/arminit.cpp +++ b/src/core/arm/interpreter/arminit.cpp | |||
| @@ -16,7 +16,6 @@ | |||
| 16 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ | 16 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ |
| 17 | 17 | ||
| 18 | #include <cstring> | 18 | #include <cstring> |
| 19 | #include "core/mem_map.h" | ||
| 20 | #include "core/arm/skyeye_common/armdefs.h" | 19 | #include "core/arm/skyeye_common/armdefs.h" |
| 21 | #include "core/arm/skyeye_common/armemu.h" | 20 | #include "core/arm/skyeye_common/armemu.h" |
| 22 | #include "core/arm/skyeye_common/vfp/vfp.h" | 21 | #include "core/arm/skyeye_common/vfp/vfp.h" |
diff --git a/src/core/arm/skyeye_common/armmmu.h b/src/core/arm/skyeye_common/armmmu.h index 0463d83c8..c67d7209b 100644 --- a/src/core/arm/skyeye_common/armmmu.h +++ b/src/core/arm/skyeye_common/armmmu.h | |||
| @@ -22,7 +22,7 @@ | |||
| 22 | 22 | ||
| 23 | #include "common/swap.h" | 23 | #include "common/swap.h" |
| 24 | 24 | ||
| 25 | #include "core/mem_map.h" | 25 | #include "core/memory.h" |
| 26 | #include "core/arm/skyeye_common/armdefs.h" | 26 | #include "core/arm/skyeye_common/armdefs.h" |
| 27 | 27 | ||
| 28 | // Register numbers in the MMU | 28 | // Register numbers in the MMU |
diff --git a/src/core/core.cpp b/src/core/core.cpp index 53aae8c2f..79038cd52 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp | |||
| @@ -8,7 +8,6 @@ | |||
| 8 | #include "core/core.h" | 8 | #include "core/core.h" |
| 9 | #include "core/core_timing.h" | 9 | #include "core/core_timing.h" |
| 10 | 10 | ||
| 11 | #include "core/mem_map.h" | ||
| 12 | #include "core/settings.h" | 11 | #include "core/settings.h" |
| 13 | #include "core/arm/arm_interface.h" | 12 | #include "core/arm/arm_interface.h" |
| 14 | #include "core/arm/disassembler/arm_disasm.h" | 13 | #include "core/arm/disassembler/arm_disasm.h" |
diff --git a/src/core/file_sys/archive_backend.cpp b/src/core/file_sys/archive_backend.cpp index 0439868ab..45a559ce8 100644 --- a/src/core/file_sys/archive_backend.cpp +++ b/src/core/file_sys/archive_backend.cpp | |||
| @@ -8,7 +8,7 @@ | |||
| 8 | #include "common/string_util.h" | 8 | #include "common/string_util.h" |
| 9 | 9 | ||
| 10 | #include "core/file_sys/archive_backend.h" | 10 | #include "core/file_sys/archive_backend.h" |
| 11 | #include "core/mem_map.h" | 11 | #include "core/memory.h" |
| 12 | 12 | ||
| 13 | 13 | ||
| 14 | namespace FileSys { | 14 | namespace FileSys { |
diff --git a/src/core/hle/config_mem.cpp b/src/core/hle/config_mem.cpp index 35dc9cf58..2f7cc7ee5 100644 --- a/src/core/hle/config_mem.cpp +++ b/src/core/hle/config_mem.cpp | |||
| @@ -9,7 +9,7 @@ | |||
| 9 | #include "common/common_funcs.h" | 9 | #include "common/common_funcs.h" |
| 10 | 10 | ||
| 11 | #include "core/core.h" | 11 | #include "core/core.h" |
| 12 | #include "core/mem_map.h" | 12 | #include "core/memory.h" |
| 13 | #include "core/hle/config_mem.h" | 13 | #include "core/hle/config_mem.h" |
| 14 | 14 | ||
| 15 | //////////////////////////////////////////////////////////////////////////////////////////////////// | 15 | //////////////////////////////////////////////////////////////////////////////////////////////////// |
diff --git a/src/core/hle/function_wrappers.h b/src/core/hle/function_wrappers.h index be2626eef..eb52c8fb1 100644 --- a/src/core/hle/function_wrappers.h +++ b/src/core/hle/function_wrappers.h | |||
| @@ -7,7 +7,7 @@ | |||
| 7 | #include "common/common_types.h" | 7 | #include "common/common_types.h" |
| 8 | 8 | ||
| 9 | #include "core/arm/arm_interface.h" | 9 | #include "core/arm/arm_interface.h" |
| 10 | #include "core/mem_map.h" | 10 | #include "core/memory.h" |
| 11 | #include "core/hle/hle.h" | 11 | #include "core/hle/hle.h" |
| 12 | 12 | ||
| 13 | namespace HLE { | 13 | namespace HLE { |
| @@ -109,7 +109,7 @@ template<ResultCode func(s64*, u32, void*, s32)> void Wrap(){ | |||
| 109 | 109 | ||
| 110 | template<ResultCode func(u32*, const char*)> void Wrap() { | 110 | template<ResultCode func(u32*, const char*)> void Wrap() { |
| 111 | u32 param_1 = 0; | 111 | u32 param_1 = 0; |
| 112 | u32 retval = func(¶m_1, Memory::GetCharPointer(PARAM(1))).raw; | 112 | u32 retval = func(¶m_1, (char*)Memory::GetPointer(PARAM(1))).raw; |
| 113 | Core::g_app_core->SetReg(1, param_1); | 113 | Core::g_app_core->SetReg(1, param_1); |
| 114 | FuncReturn(retval); | 114 | FuncReturn(retval); |
| 115 | } | 115 | } |
| @@ -163,7 +163,7 @@ template<void func(s64)> void Wrap() { | |||
| 163 | } | 163 | } |
| 164 | 164 | ||
| 165 | template<void func(const char*)> void Wrap() { | 165 | template<void func(const char*)> void Wrap() { |
| 166 | func(Memory::GetCharPointer(PARAM(0))); | 166 | func((char*)Memory::GetPointer(PARAM(0))); |
| 167 | } | 167 | } |
| 168 | 168 | ||
| 169 | #undef PARAM | 169 | #undef PARAM |
diff --git a/src/core/hle/kernel/address_arbiter.cpp b/src/core/hle/kernel/address_arbiter.cpp index 9d7f6b280..a1221766e 100644 --- a/src/core/hle/kernel/address_arbiter.cpp +++ b/src/core/hle/kernel/address_arbiter.cpp | |||
| @@ -5,7 +5,7 @@ | |||
| 5 | #include "common/common_types.h" | 5 | #include "common/common_types.h" |
| 6 | #include "common/logging/log.h" | 6 | #include "common/logging/log.h" |
| 7 | 7 | ||
| 8 | #include "core/mem_map.h" | 8 | #include "core/memory.h" |
| 9 | 9 | ||
| 10 | #include "core/hle/hle.h" | 10 | #include "core/hle/hle.h" |
| 11 | #include "core/hle/kernel/address_arbiter.h" | 11 | #include "core/hle/kernel/address_arbiter.h" |
diff --git a/src/core/hle/kernel/process.cpp b/src/core/hle/kernel/process.cpp index 1e439db9e..0cdfa58d7 100644 --- a/src/core/hle/kernel/process.cpp +++ b/src/core/hle/kernel/process.cpp | |||
| @@ -8,7 +8,7 @@ | |||
| 8 | 8 | ||
| 9 | #include "core/hle/kernel/process.h" | 9 | #include "core/hle/kernel/process.h" |
| 10 | #include "core/hle/kernel/thread.h" | 10 | #include "core/hle/kernel/thread.h" |
| 11 | #include "core/mem_map.h" | 11 | #include "core/memory.h" |
| 12 | 12 | ||
| 13 | namespace Kernel { | 13 | namespace Kernel { |
| 14 | 14 | ||
diff --git a/src/core/hle/kernel/session.h b/src/core/hle/kernel/session.h index 8c3886ffd..54a062971 100644 --- a/src/core/hle/kernel/session.h +++ b/src/core/hle/kernel/session.h | |||
| @@ -6,7 +6,7 @@ | |||
| 6 | 6 | ||
| 7 | #include "core/hle/kernel/kernel.h" | 7 | #include "core/hle/kernel/kernel.h" |
| 8 | #include "core/hle/kernel/thread.h" | 8 | #include "core/hle/kernel/thread.h" |
| 9 | #include "core/mem_map.h" | 9 | #include "core/memory.h" |
| 10 | 10 | ||
| 11 | namespace Kernel { | 11 | namespace Kernel { |
| 12 | 12 | ||
diff --git a/src/core/hle/kernel/shared_memory.cpp b/src/core/hle/kernel/shared_memory.cpp index 0c59f4876..4137683b5 100644 --- a/src/core/hle/kernel/shared_memory.cpp +++ b/src/core/hle/kernel/shared_memory.cpp | |||
| @@ -6,7 +6,7 @@ | |||
| 6 | 6 | ||
| 7 | #include "common/logging/log.h" | 7 | #include "common/logging/log.h" |
| 8 | 8 | ||
| 9 | #include "core/mem_map.h" | 9 | #include "core/memory.h" |
| 10 | #include "core/hle/kernel/shared_memory.h" | 10 | #include "core/hle/kernel/shared_memory.h" |
| 11 | 11 | ||
| 12 | namespace Kernel { | 12 | namespace Kernel { |
diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/thread.cpp index 5bcd03ff3..a5f1904d7 100644 --- a/src/core/hle/kernel/thread.cpp +++ b/src/core/hle/kernel/thread.cpp | |||
| @@ -21,7 +21,7 @@ | |||
| 21 | #include "core/hle/kernel/thread.h" | 21 | #include "core/hle/kernel/thread.h" |
| 22 | #include "core/hle/kernel/mutex.h" | 22 | #include "core/hle/kernel/mutex.h" |
| 23 | #include "core/hle/result.h" | 23 | #include "core/hle/result.h" |
| 24 | #include "core/mem_map.h" | 24 | #include "core/memory.h" |
| 25 | 25 | ||
| 26 | namespace Kernel { | 26 | namespace Kernel { |
| 27 | 27 | ||
diff --git a/src/core/hle/kernel/thread.h b/src/core/hle/kernel/thread.h index 6b329c12a..389928178 100644 --- a/src/core/hle/kernel/thread.h +++ b/src/core/hle/kernel/thread.h | |||
| @@ -12,7 +12,6 @@ | |||
| 12 | #include "common/common_types.h" | 12 | #include "common/common_types.h" |
| 13 | 13 | ||
| 14 | #include "core/core.h" | 14 | #include "core/core.h" |
| 15 | #include "core/mem_map.h" | ||
| 16 | 15 | ||
| 17 | #include "core/hle/kernel/kernel.h" | 16 | #include "core/hle/kernel/kernel.h" |
| 18 | #include "core/hle/result.h" | 17 | #include "core/hle/result.h" |
diff --git a/src/core/hle/service/gsp_gpu.cpp b/src/core/hle/service/gsp_gpu.cpp index c6252a03b..c11c5faba 100644 --- a/src/core/hle/service/gsp_gpu.cpp +++ b/src/core/hle/service/gsp_gpu.cpp | |||
| @@ -5,6 +5,7 @@ | |||
| 5 | #include "common/bit_field.h" | 5 | #include "common/bit_field.h" |
| 6 | 6 | ||
| 7 | #include "core/mem_map.h" | 7 | #include "core/mem_map.h" |
| 8 | #include "core/memory.h" | ||
| 8 | #include "core/hle/kernel/event.h" | 9 | #include "core/hle/kernel/event.h" |
| 9 | #include "core/hle/kernel/shared_memory.h" | 10 | #include "core/hle/kernel/shared_memory.h" |
| 10 | #include "core/hle/result.h" | 11 | #include "core/hle/result.h" |
diff --git a/src/core/hle/shared_page.cpp b/src/core/hle/shared_page.cpp index 4f227a370..9de832158 100644 --- a/src/core/hle/shared_page.cpp +++ b/src/core/hle/shared_page.cpp | |||
| @@ -8,7 +8,7 @@ | |||
| 8 | #include "common/common_funcs.h" | 8 | #include "common/common_funcs.h" |
| 9 | 9 | ||
| 10 | #include "core/core.h" | 10 | #include "core/core.h" |
| 11 | #include "core/mem_map.h" | 11 | #include "core/memory.h" |
| 12 | #include "core/hle/config_mem.h" | 12 | #include "core/hle/config_mem.h" |
| 13 | #include "core/hle/shared_page.h" | 13 | #include "core/hle/shared_page.h" |
| 14 | 14 | ||
diff --git a/src/core/hle/svc.cpp b/src/core/hle/svc.cpp index e8159fbdb..9bf886256 100644 --- a/src/core/hle/svc.cpp +++ b/src/core/hle/svc.cpp | |||
| @@ -315,7 +315,7 @@ static ResultCode GetResourceLimitCurrentValues(s64* values, Handle resource_lim | |||
| 315 | s32 name_count) { | 315 | s32 name_count) { |
| 316 | LOG_ERROR(Kernel_SVC, "(UNIMPLEMENTED) called resource_limit=%08X, names=%p, name_count=%d", | 316 | LOG_ERROR(Kernel_SVC, "(UNIMPLEMENTED) called resource_limit=%08X, names=%p, name_count=%d", |
| 317 | resource_limit, names, name_count); | 317 | resource_limit, names, name_count); |
| 318 | Memory::Write32(Core::g_app_core->GetReg(0), 0); // Normmatt: Set used memory to 0 for now | 318 | values[0] = 0; // Normmatt: Set used memory to 0 for now |
| 319 | return RESULT_SUCCESS; | 319 | return RESULT_SUCCESS; |
| 320 | } | 320 | } |
| 321 | 321 | ||
diff --git a/src/core/hw/gpu.cpp b/src/core/hw/gpu.cpp index e4a0e14c4..8ef1f70df 100644 --- a/src/core/hw/gpu.cpp +++ b/src/core/hw/gpu.cpp | |||
| @@ -8,7 +8,7 @@ | |||
| 8 | 8 | ||
| 9 | #include "core/settings.h" | 9 | #include "core/settings.h" |
| 10 | #include "core/core.h" | 10 | #include "core/core.h" |
| 11 | #include "core/mem_map.h" | 11 | #include "core/memory.h" |
| 12 | #include "core/core_timing.h" | 12 | #include "core/core_timing.h" |
| 13 | 13 | ||
| 14 | #include "core/hle/hle.h" | 14 | #include "core/hle/hle.h" |
diff --git a/src/core/loader/3dsx.cpp b/src/core/loader/3dsx.cpp index e28986085..84b13ee52 100644 --- a/src/core/loader/3dsx.cpp +++ b/src/core/loader/3dsx.cpp | |||
| @@ -12,7 +12,7 @@ | |||
| 12 | #include "core/hle/service/fs/archive.h" | 12 | #include "core/hle/service/fs/archive.h" |
| 13 | #include "core/loader/elf.h" | 13 | #include "core/loader/elf.h" |
| 14 | #include "core/loader/ncch.h" | 14 | #include "core/loader/ncch.h" |
| 15 | #include "core/mem_map.h" | 15 | #include "core/memory.h" |
| 16 | 16 | ||
| 17 | #include "3dsx.h" | 17 | #include "3dsx.h" |
| 18 | 18 | ||
diff --git a/src/core/loader/elf.cpp b/src/core/loader/elf.cpp index 47d4e8cea..a951bc80f 100644 --- a/src/core/loader/elf.cpp +++ b/src/core/loader/elf.cpp | |||
| @@ -12,7 +12,7 @@ | |||
| 12 | 12 | ||
| 13 | #include "core/hle/kernel/kernel.h" | 13 | #include "core/hle/kernel/kernel.h" |
| 14 | #include "core/loader/elf.h" | 14 | #include "core/loader/elf.h" |
| 15 | #include "core/mem_map.h" | 15 | #include "core/memory.h" |
| 16 | 16 | ||
| 17 | //////////////////////////////////////////////////////////////////////////////////////////////////// | 17 | //////////////////////////////////////////////////////////////////////////////////////////////////// |
| 18 | // ELF Header Constants | 18 | // ELF Header Constants |
diff --git a/src/core/loader/loader.cpp b/src/core/loader/loader.cpp index 4f881cf6f..8b14edf00 100644 --- a/src/core/loader/loader.cpp +++ b/src/core/loader/loader.cpp | |||
| @@ -13,7 +13,6 @@ | |||
| 13 | #include "core/loader/3dsx.h" | 13 | #include "core/loader/3dsx.h" |
| 14 | #include "core/loader/elf.h" | 14 | #include "core/loader/elf.h" |
| 15 | #include "core/loader/ncch.h" | 15 | #include "core/loader/ncch.h" |
| 16 | #include "core/mem_map.h" | ||
| 17 | 16 | ||
| 18 | //////////////////////////////////////////////////////////////////////////////////////////////////// | 17 | //////////////////////////////////////////////////////////////////////////////////////////////////// |
| 19 | 18 | ||
diff --git a/src/core/loader/ncch.cpp b/src/core/loader/ncch.cpp index 3325a6ab8..36e341fd4 100644 --- a/src/core/loader/ncch.cpp +++ b/src/core/loader/ncch.cpp | |||
| @@ -12,7 +12,7 @@ | |||
| 12 | 12 | ||
| 13 | #include "core/hle/kernel/kernel.h" | 13 | #include "core/hle/kernel/kernel.h" |
| 14 | #include "core/loader/ncch.h" | 14 | #include "core/loader/ncch.h" |
| 15 | #include "core/mem_map.h" | 15 | #include "core/memory.h" |
| 16 | 16 | ||
| 17 | //////////////////////////////////////////////////////////////////////////////////////////////////// | 17 | //////////////////////////////////////////////////////////////////////////////////////////////////// |
| 18 | // Loader namespace | 18 | // Loader namespace |
diff --git a/src/core/mem_map.cpp b/src/core/mem_map.cpp index f99520464..66c2f77c0 100644 --- a/src/core/mem_map.cpp +++ b/src/core/mem_map.cpp | |||
| @@ -2,10 +2,13 @@ | |||
| 2 | // Licensed under GPLv2 or any later version | 2 | // Licensed under GPLv2 or any later version |
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include <map> | ||
| 6 | |||
| 5 | #include "common/common_types.h" | 7 | #include "common/common_types.h" |
| 6 | #include "common/logging/log.h" | 8 | #include "common/logging/log.h" |
| 7 | 9 | ||
| 8 | #include "core/mem_map.h" | 10 | #include "core/mem_map.h" |
| 11 | #include "core/memory.h" | ||
| 9 | 12 | ||
| 10 | //////////////////////////////////////////////////////////////////////////////////////////////////// | 13 | //////////////////////////////////////////////////////////////////////////////////////////////////// |
| 11 | 14 | ||
| @@ -37,19 +40,109 @@ static MemoryArea memory_areas[] = { | |||
| 37 | {&g_tls_mem, TLS_AREA_SIZE }, | 40 | {&g_tls_mem, TLS_AREA_SIZE }, |
| 38 | }; | 41 | }; |
| 39 | 42 | ||
| 43 | /// Represents a block of memory mapped by ControlMemory/MapMemoryBlock | ||
| 44 | struct MemoryBlock { | ||
| 45 | MemoryBlock() : handle(0), base_address(0), address(0), size(0), operation(0), permissions(0) { | ||
| 46 | } | ||
| 47 | u32 handle; | ||
| 48 | u32 base_address; | ||
| 49 | u32 address; | ||
| 50 | u32 size; | ||
| 51 | u32 operation; | ||
| 52 | u32 permissions; | ||
| 53 | |||
| 54 | const u32 GetVirtualAddress() const{ | ||
| 55 | return base_address + address; | ||
| 56 | } | ||
| 57 | }; | ||
| 58 | |||
| 59 | static std::map<u32, MemoryBlock> heap_map; | ||
| 60 | static std::map<u32, MemoryBlock> heap_linear_map; | ||
| 61 | |||
| 62 | } | ||
| 63 | |||
| 64 | u32 MapBlock_Heap(u32 size, u32 operation, u32 permissions) { | ||
| 65 | MemoryBlock block; | ||
| 66 | |||
| 67 | block.base_address = HEAP_VADDR; | ||
| 68 | block.size = size; | ||
| 69 | block.operation = operation; | ||
| 70 | block.permissions = permissions; | ||
| 71 | |||
| 72 | if (heap_map.size() > 0) { | ||
| 73 | const MemoryBlock last_block = heap_map.rbegin()->second; | ||
| 74 | block.address = last_block.address + last_block.size; | ||
| 75 | } | ||
| 76 | heap_map[block.GetVirtualAddress()] = block; | ||
| 77 | |||
| 78 | return block.GetVirtualAddress(); | ||
| 79 | } | ||
| 80 | |||
| 81 | u32 MapBlock_HeapLinear(u32 size, u32 operation, u32 permissions) { | ||
| 82 | MemoryBlock block; | ||
| 83 | |||
| 84 | block.base_address = LINEAR_HEAP_VADDR; | ||
| 85 | block.size = size; | ||
| 86 | block.operation = operation; | ||
| 87 | block.permissions = permissions; | ||
| 88 | |||
| 89 | if (heap_linear_map.size() > 0) { | ||
| 90 | const MemoryBlock last_block = heap_linear_map.rbegin()->second; | ||
| 91 | block.address = last_block.address + last_block.size; | ||
| 92 | } | ||
| 93 | heap_linear_map[block.GetVirtualAddress()] = block; | ||
| 94 | |||
| 95 | return block.GetVirtualAddress(); | ||
| 96 | } | ||
| 97 | |||
| 98 | PAddr VirtualToPhysicalAddress(const VAddr addr) { | ||
| 99 | if (addr == 0) { | ||
| 100 | return 0; | ||
| 101 | } else if (addr >= VRAM_VADDR && addr < VRAM_VADDR_END) { | ||
| 102 | return addr - VRAM_VADDR + VRAM_PADDR; | ||
| 103 | } else if (addr >= LINEAR_HEAP_VADDR && addr < LINEAR_HEAP_VADDR_END) { | ||
| 104 | return addr - LINEAR_HEAP_VADDR + FCRAM_PADDR; | ||
| 105 | } else if (addr >= DSP_RAM_VADDR && addr < DSP_RAM_VADDR_END) { | ||
| 106 | return addr - DSP_RAM_VADDR + DSP_RAM_PADDR; | ||
| 107 | } else if (addr >= IO_AREA_VADDR && addr < IO_AREA_VADDR_END) { | ||
| 108 | return addr - IO_AREA_VADDR + IO_AREA_PADDR; | ||
| 109 | } | ||
| 110 | |||
| 111 | LOG_ERROR(HW_Memory, "Unknown virtual address @ 0x%08x", addr); | ||
| 112 | // To help with debugging, set bit on address so that it's obviously invalid. | ||
| 113 | return addr | 0x80000000; | ||
| 114 | } | ||
| 115 | |||
| 116 | VAddr PhysicalToVirtualAddress(const PAddr addr) { | ||
| 117 | if (addr == 0) { | ||
| 118 | return 0; | ||
| 119 | } else if (addr >= VRAM_PADDR && addr < VRAM_PADDR_END) { | ||
| 120 | return addr - VRAM_PADDR + VRAM_VADDR; | ||
| 121 | } else if (addr >= FCRAM_PADDR && addr < FCRAM_PADDR_END) { | ||
| 122 | return addr - FCRAM_PADDR + LINEAR_HEAP_VADDR; | ||
| 123 | } else if (addr >= DSP_RAM_PADDR && addr < DSP_RAM_PADDR_END) { | ||
| 124 | return addr - DSP_RAM_PADDR + DSP_RAM_VADDR; | ||
| 125 | } else if (addr >= IO_AREA_PADDR && addr < IO_AREA_PADDR_END) { | ||
| 126 | return addr - IO_AREA_PADDR + IO_AREA_VADDR; | ||
| 127 | } | ||
| 128 | |||
| 129 | LOG_ERROR(HW_Memory, "Unknown physical address @ 0x%08x", addr); | ||
| 130 | // To help with debugging, set bit on address so that it's obviously invalid. | ||
| 131 | return addr | 0x80000000; | ||
| 40 | } | 132 | } |
| 41 | 133 | ||
| 42 | void Init() { | 134 | void Init() { |
| 43 | for (MemoryArea& area : memory_areas) { | 135 | for (MemoryArea& area : memory_areas) { |
| 44 | *area.ptr = new u8[area.size]; | 136 | *area.ptr = new u8[area.size]; |
| 45 | } | 137 | } |
| 46 | MemBlock_Init(); | ||
| 47 | 138 | ||
| 48 | LOG_DEBUG(HW_Memory, "initialized OK, RAM at %p", g_heap); | 139 | LOG_DEBUG(HW_Memory, "initialized OK, RAM at %p", g_heap); |
| 49 | } | 140 | } |
| 50 | 141 | ||
| 51 | void Shutdown() { | 142 | void Shutdown() { |
| 52 | MemBlock_Shutdown(); | 143 | heap_map.clear(); |
| 144 | heap_linear_map.clear(); | ||
| 145 | |||
| 53 | for (MemoryArea& area : memory_areas) { | 146 | for (MemoryArea& area : memory_areas) { |
| 54 | delete[] *area.ptr; | 147 | delete[] *area.ptr; |
| 55 | *area.ptr = nullptr; | 148 | *area.ptr = nullptr; |
diff --git a/src/core/mem_map.h b/src/core/mem_map.h index b6944deb4..945815cd6 100644 --- a/src/core/mem_map.h +++ b/src/core/mem_map.h | |||
| @@ -8,121 +8,6 @@ | |||
| 8 | 8 | ||
| 9 | namespace Memory { | 9 | namespace Memory { |
| 10 | 10 | ||
| 11 | //////////////////////////////////////////////////////////////////////////////////////////////////// | ||
| 12 | |||
| 13 | const u32 PAGE_SIZE = 0x1000; | ||
| 14 | |||
| 15 | /// Physical memory regions as seen from the ARM11 | ||
| 16 | enum : PAddr { | ||
| 17 | /// IO register area | ||
| 18 | IO_AREA_PADDR = 0x10100000, | ||
| 19 | IO_AREA_SIZE = 0x01000000, ///< IO area size (16MB) | ||
| 20 | IO_AREA_PADDR_END = IO_AREA_PADDR + IO_AREA_SIZE, | ||
| 21 | |||
| 22 | /// MPCore internal memory region | ||
| 23 | MPCORE_RAM_PADDR = 0x17E00000, | ||
| 24 | MPCORE_RAM_SIZE = 0x00002000, ///< MPCore internal memory size (8KB) | ||
| 25 | MPCORE_RAM_PADDR_END = MPCORE_RAM_PADDR + MPCORE_RAM_SIZE, | ||
| 26 | |||
| 27 | /// Video memory | ||
| 28 | VRAM_PADDR = 0x18000000, | ||
| 29 | VRAM_SIZE = 0x00600000, ///< VRAM size (6MB) | ||
| 30 | VRAM_PADDR_END = VRAM_PADDR + VRAM_SIZE, | ||
| 31 | |||
| 32 | /// DSP memory | ||
| 33 | DSP_RAM_PADDR = 0x1FF00000, | ||
| 34 | DSP_RAM_SIZE = 0x00080000, ///< DSP memory size (512KB) | ||
| 35 | DSP_RAM_PADDR_END = DSP_RAM_PADDR + DSP_RAM_SIZE, | ||
| 36 | |||
| 37 | /// AXI WRAM | ||
| 38 | AXI_WRAM_PADDR = 0x1FF80000, | ||
| 39 | AXI_WRAM_SIZE = 0x00080000, ///< AXI WRAM size (512KB) | ||
| 40 | AXI_WRAM_PADDR_END = AXI_WRAM_PADDR + AXI_WRAM_SIZE, | ||
| 41 | |||
| 42 | /// Main FCRAM | ||
| 43 | FCRAM_PADDR = 0x20000000, | ||
| 44 | FCRAM_SIZE = 0x08000000, ///< FCRAM size (128MB) | ||
| 45 | FCRAM_PADDR_END = FCRAM_PADDR + FCRAM_SIZE, | ||
| 46 | }; | ||
| 47 | |||
| 48 | /// Virtual user-space memory regions | ||
| 49 | enum : VAddr { | ||
| 50 | /// Where the application text, data and bss reside. | ||
| 51 | PROCESS_IMAGE_VADDR = 0x00100000, | ||
| 52 | PROCESS_IMAGE_MAX_SIZE = 0x03F00000, | ||
| 53 | PROCESS_IMAGE_VADDR_END = PROCESS_IMAGE_VADDR + PROCESS_IMAGE_MAX_SIZE, | ||
| 54 | |||
| 55 | /// Area where IPC buffers are mapped onto. | ||
| 56 | IPC_MAPPING_VADDR = 0x04000000, | ||
| 57 | IPC_MAPPING_SIZE = 0x04000000, | ||
| 58 | IPC_MAPPING_VADDR_END = IPC_MAPPING_VADDR + IPC_MAPPING_SIZE, | ||
| 59 | |||
| 60 | /// Application heap (includes stack). | ||
| 61 | HEAP_VADDR = 0x08000000, | ||
| 62 | HEAP_SIZE = 0x08000000, | ||
| 63 | HEAP_VADDR_END = HEAP_VADDR + HEAP_SIZE, | ||
| 64 | |||
| 65 | /// Area where shared memory buffers are mapped onto. | ||
| 66 | SHARED_MEMORY_VADDR = 0x10000000, | ||
| 67 | SHARED_MEMORY_SIZE = 0x04000000, | ||
| 68 | SHARED_MEMORY_VADDR_END = SHARED_MEMORY_VADDR + SHARED_MEMORY_SIZE, | ||
| 69 | |||
| 70 | /// Maps 1:1 to an offset in FCRAM. Used for HW allocations that need to be linear in physical memory. | ||
| 71 | LINEAR_HEAP_VADDR = 0x14000000, | ||
| 72 | LINEAR_HEAP_SIZE = 0x08000000, | ||
| 73 | LINEAR_HEAP_VADDR_END = LINEAR_HEAP_VADDR + LINEAR_HEAP_SIZE, | ||
| 74 | |||
| 75 | /// Maps 1:1 to the IO register area. | ||
| 76 | IO_AREA_VADDR = 0x1EC00000, | ||
| 77 | IO_AREA_VADDR_END = IO_AREA_VADDR + IO_AREA_SIZE, | ||
| 78 | |||
| 79 | /// Maps 1:1 to VRAM. | ||
| 80 | VRAM_VADDR = 0x1F000000, | ||
| 81 | VRAM_VADDR_END = VRAM_VADDR + VRAM_SIZE, | ||
| 82 | |||
| 83 | /// Maps 1:1 to DSP memory. | ||
| 84 | DSP_RAM_VADDR = 0x1FF00000, | ||
| 85 | DSP_RAM_VADDR_END = DSP_RAM_VADDR + DSP_RAM_SIZE, | ||
| 86 | |||
| 87 | /// Read-only page containing kernel and system configuration values. | ||
| 88 | CONFIG_MEMORY_VADDR = 0x1FF80000, | ||
| 89 | CONFIG_MEMORY_SIZE = 0x00001000, | ||
| 90 | CONFIG_MEMORY_VADDR_END = CONFIG_MEMORY_VADDR + CONFIG_MEMORY_SIZE, | ||
| 91 | |||
| 92 | /// Usually read-only page containing mostly values read from hardware. | ||
| 93 | SHARED_PAGE_VADDR = 0x1FF81000, | ||
| 94 | SHARED_PAGE_SIZE = 0x00001000, | ||
| 95 | SHARED_PAGE_VADDR_END = SHARED_PAGE_VADDR + SHARED_PAGE_SIZE, | ||
| 96 | |||
| 97 | // TODO(yuriks): The size of this area is dynamic, the kernel grows | ||
| 98 | // it as more and more threads are created. For now we'll just use a | ||
| 99 | // hardcoded value. | ||
| 100 | /// Area where TLS (Thread-Local Storage) buffers are allocated. | ||
| 101 | TLS_AREA_VADDR = 0x1FF82000, | ||
| 102 | TLS_AREA_SIZE = 0x00030000, // Each TLS buffer is 0x200 bytes, allows for 300 threads | ||
| 103 | TLS_AREA_VADDR_END = TLS_AREA_VADDR + TLS_AREA_SIZE, | ||
| 104 | }; | ||
| 105 | |||
| 106 | //////////////////////////////////////////////////////////////////////////////////////////////////// | ||
| 107 | |||
| 108 | /// Represents a block of memory mapped by ControlMemory/MapMemoryBlock | ||
| 109 | struct MemoryBlock { | ||
| 110 | MemoryBlock() : handle(0), base_address(0), address(0), size(0), operation(0), permissions(0) { | ||
| 111 | } | ||
| 112 | u32 handle; | ||
| 113 | u32 base_address; | ||
| 114 | u32 address; | ||
| 115 | u32 size; | ||
| 116 | u32 operation; | ||
| 117 | u32 permissions; | ||
| 118 | |||
| 119 | const u32 GetVirtualAddress() const{ | ||
| 120 | return base_address + address; | ||
| 121 | } | ||
| 122 | }; | ||
| 123 | |||
| 124 | //////////////////////////////////////////////////////////////////////////////////////////////////// | ||
| 125 | |||
| 126 | extern u8* g_exefs_code; ///< ExeFS:/.code is loaded here | 11 | extern u8* g_exefs_code; ///< ExeFS:/.code is loaded here |
| 127 | extern u8* g_heap; ///< Application heap (main memory) | 12 | extern u8* g_heap; ///< Application heap (main memory) |
| 128 | extern u8* g_shared_mem; ///< Shared memory | 13 | extern u8* g_shared_mem; ///< Shared memory |
| @@ -134,20 +19,6 @@ extern u8* g_tls_mem; ///< TLS memory | |||
| 134 | void Init(); | 19 | void Init(); |
| 135 | void Shutdown(); | 20 | void Shutdown(); |
| 136 | 21 | ||
| 137 | u8 Read8(VAddr addr); | ||
| 138 | u16 Read16(VAddr addr); | ||
| 139 | u32 Read32(VAddr addr); | ||
| 140 | u64 Read64(VAddr addr); | ||
| 141 | |||
| 142 | void Write8(VAddr addr, u8 data); | ||
| 143 | void Write16(VAddr addr, u16 data); | ||
| 144 | void Write32(VAddr addr, u32 data); | ||
| 145 | void Write64(VAddr addr, u64 data); | ||
| 146 | |||
| 147 | void WriteBlock(VAddr addr, const u8* data, size_t size); | ||
| 148 | |||
| 149 | u8* GetPointer(VAddr virtual_address); | ||
| 150 | |||
| 151 | /** | 22 | /** |
| 152 | * Maps a block of memory on the heap | 23 | * Maps a block of memory on the heap |
| 153 | * @param size Size of block in bytes | 24 | * @param size Size of block in bytes |
| @@ -164,16 +35,6 @@ u32 MapBlock_Heap(u32 size, u32 operation, u32 permissions); | |||
| 164 | */ | 35 | */ |
| 165 | u32 MapBlock_HeapLinear(u32 size, u32 operation, u32 permissions); | 36 | u32 MapBlock_HeapLinear(u32 size, u32 operation, u32 permissions); |
| 166 | 37 | ||
| 167 | /// Initialize mapped memory blocks | ||
| 168 | void MemBlock_Init(); | ||
| 169 | |||
| 170 | /// Shutdown mapped memory blocks | ||
| 171 | void MemBlock_Shutdown(); | ||
| 172 | |||
| 173 | inline const char* GetCharPointer(const VAddr address) { | ||
| 174 | return (const char *)GetPointer(address); | ||
| 175 | } | ||
| 176 | |||
| 177 | /** | 38 | /** |
| 178 | * Converts a virtual address inside a region with 1:1 mapping to physical memory to a physical | 39 | * Converts a virtual address inside a region with 1:1 mapping to physical memory to a physical |
| 179 | * address. This should be used by services to translate addresses for use by the hardware. | 40 | * address. This should be used by services to translate addresses for use by the hardware. |
| @@ -185,13 +46,4 @@ PAddr VirtualToPhysicalAddress(VAddr addr); | |||
| 185 | */ | 46 | */ |
| 186 | VAddr PhysicalToVirtualAddress(PAddr addr); | 47 | VAddr PhysicalToVirtualAddress(PAddr addr); |
| 187 | 48 | ||
| 188 | /** | ||
| 189 | * Gets a pointer to the memory region beginning at the specified physical address. | ||
| 190 | * | ||
| 191 | * @note This is currently implemented using PhysicalToVirtualAddress(). | ||
| 192 | */ | ||
| 193 | inline u8* GetPhysicalPointer(PAddr address) { | ||
| 194 | return GetPointer(PhysicalToVirtualAddress(address)); | ||
| 195 | } | ||
| 196 | |||
| 197 | } // namespace | 49 | } // namespace |
diff --git a/src/core/mem_map_funcs.cpp b/src/core/memory.cpp index f2da60cc6..517167b0a 100644 --- a/src/core/mem_map_funcs.cpp +++ b/src/core/memory.cpp | |||
| @@ -2,58 +2,18 @@ | |||
| 2 | // Licensed under GPLv2 or any later version | 2 | // Licensed under GPLv2 or any later version |
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include <map> | ||
| 6 | |||
| 7 | #include "common/common_types.h" | 5 | #include "common/common_types.h" |
| 8 | #include "common/logging/log.h" | 6 | #include "common/logging/log.h" |
| 9 | #include "common/swap.h" | 7 | #include "common/swap.h" |
| 10 | 8 | ||
| 11 | #include "core/mem_map.h" | 9 | #include "core/hle/config_mem.h" |
| 10 | #include "core/hle/shared_page.h" | ||
| 12 | #include "core/hw/hw.h" | 11 | #include "core/hw/hw.h" |
| 13 | #include "hle/config_mem.h" | 12 | #include "core/mem_map.h" |
| 14 | #include "hle/shared_page.h" | 13 | #include "core/memory.h" |
| 15 | 14 | ||
| 16 | namespace Memory { | 15 | namespace Memory { |
| 17 | 16 | ||
| 18 | static std::map<u32, MemoryBlock> heap_map; | ||
| 19 | static std::map<u32, MemoryBlock> heap_linear_map; | ||
| 20 | |||
| 21 | PAddr VirtualToPhysicalAddress(const VAddr addr) { | ||
| 22 | if (addr == 0) { | ||
| 23 | return 0; | ||
| 24 | } else if (addr >= VRAM_VADDR && addr < VRAM_VADDR_END) { | ||
| 25 | return addr - VRAM_VADDR + VRAM_PADDR; | ||
| 26 | } else if (addr >= LINEAR_HEAP_VADDR && addr < LINEAR_HEAP_VADDR_END) { | ||
| 27 | return addr - LINEAR_HEAP_VADDR + FCRAM_PADDR; | ||
| 28 | } else if (addr >= DSP_RAM_VADDR && addr < DSP_RAM_VADDR_END) { | ||
| 29 | return addr - DSP_RAM_VADDR + DSP_RAM_PADDR; | ||
| 30 | } else if (addr >= IO_AREA_VADDR && addr < IO_AREA_VADDR_END) { | ||
| 31 | return addr - IO_AREA_VADDR + IO_AREA_PADDR; | ||
| 32 | } | ||
| 33 | |||
| 34 | LOG_ERROR(HW_Memory, "Unknown virtual address @ 0x%08x", addr); | ||
| 35 | // To help with debugging, set bit on address so that it's obviously invalid. | ||
| 36 | return addr | 0x80000000; | ||
| 37 | } | ||
| 38 | |||
| 39 | VAddr PhysicalToVirtualAddress(const PAddr addr) { | ||
| 40 | if (addr == 0) { | ||
| 41 | return 0; | ||
| 42 | } else if (addr >= VRAM_PADDR && addr < VRAM_PADDR_END) { | ||
| 43 | return addr - VRAM_PADDR + VRAM_VADDR; | ||
| 44 | } else if (addr >= FCRAM_PADDR && addr < FCRAM_PADDR_END) { | ||
| 45 | return addr - FCRAM_PADDR + LINEAR_HEAP_VADDR; | ||
| 46 | } else if (addr >= DSP_RAM_PADDR && addr < DSP_RAM_PADDR_END) { | ||
| 47 | return addr - DSP_RAM_PADDR + DSP_RAM_VADDR; | ||
| 48 | } else if (addr >= IO_AREA_PADDR && addr < IO_AREA_PADDR_END) { | ||
| 49 | return addr - IO_AREA_PADDR + IO_AREA_VADDR; | ||
| 50 | } | ||
| 51 | |||
| 52 | LOG_ERROR(HW_Memory, "Unknown physical address @ 0x%08x", addr); | ||
| 53 | // To help with debugging, set bit on address so that it's obviously invalid. | ||
| 54 | return addr | 0x80000000; | ||
| 55 | } | ||
| 56 | |||
| 57 | template <typename T> | 17 | template <typename T> |
| 58 | inline void Read(T &var, const VAddr vaddr) { | 18 | inline void Read(T &var, const VAddr vaddr) { |
| 59 | // TODO: Figure out the fastest order of tests for both read and write (they are probably different). | 19 | // TODO: Figure out the fastest order of tests for both read and write (they are probably different). |
| @@ -174,46 +134,8 @@ u8 *GetPointer(const VAddr vaddr) { | |||
| 174 | } | 134 | } |
| 175 | } | 135 | } |
| 176 | 136 | ||
| 177 | u32 MapBlock_Heap(u32 size, u32 operation, u32 permissions) { | 137 | u8* GetPhysicalPointer(PAddr address) { |
| 178 | MemoryBlock block; | 138 | return GetPointer(PhysicalToVirtualAddress(address)); |
| 179 | |||
| 180 | block.base_address = HEAP_VADDR; | ||
| 181 | block.size = size; | ||
| 182 | block.operation = operation; | ||
| 183 | block.permissions = permissions; | ||
| 184 | |||
| 185 | if (heap_map.size() > 0) { | ||
| 186 | const MemoryBlock last_block = heap_map.rbegin()->second; | ||
| 187 | block.address = last_block.address + last_block.size; | ||
| 188 | } | ||
| 189 | heap_map[block.GetVirtualAddress()] = block; | ||
| 190 | |||
| 191 | return block.GetVirtualAddress(); | ||
| 192 | } | ||
| 193 | |||
| 194 | u32 MapBlock_HeapLinear(u32 size, u32 operation, u32 permissions) { | ||
| 195 | MemoryBlock block; | ||
| 196 | |||
| 197 | block.base_address = LINEAR_HEAP_VADDR; | ||
| 198 | block.size = size; | ||
| 199 | block.operation = operation; | ||
| 200 | block.permissions = permissions; | ||
| 201 | |||
| 202 | if (heap_linear_map.size() > 0) { | ||
| 203 | const MemoryBlock last_block = heap_linear_map.rbegin()->second; | ||
| 204 | block.address = last_block.address + last_block.size; | ||
| 205 | } | ||
| 206 | heap_linear_map[block.GetVirtualAddress()] = block; | ||
| 207 | |||
| 208 | return block.GetVirtualAddress(); | ||
| 209 | } | ||
| 210 | |||
| 211 | void MemBlock_Init() { | ||
| 212 | } | ||
| 213 | |||
| 214 | void MemBlock_Shutdown() { | ||
| 215 | heap_map.clear(); | ||
| 216 | heap_linear_map.clear(); | ||
| 217 | } | 139 | } |
| 218 | 140 | ||
| 219 | u8 Read8(const VAddr addr) { | 141 | u8 Read8(const VAddr addr) { |
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 | |||
| 9 | namespace Memory { | ||
| 10 | |||
| 11 | const u32 PAGE_SIZE = 0x1000; | ||
| 12 | |||
| 13 | /// Physical memory regions as seen from the ARM11 | ||
| 14 | enum : 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 | ||
| 47 | enum : 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 | |||
| 104 | u8 Read8(VAddr addr); | ||
| 105 | u16 Read16(VAddr addr); | ||
| 106 | u32 Read32(VAddr addr); | ||
| 107 | u64 Read64(VAddr addr); | ||
| 108 | |||
| 109 | void Write8(VAddr addr, u8 data); | ||
| 110 | void Write16(VAddr addr, u16 data); | ||
| 111 | void Write32(VAddr addr, u32 data); | ||
| 112 | void Write64(VAddr addr, u64 data); | ||
| 113 | |||
| 114 | void WriteBlock(VAddr addr, const u8* data, size_t size); | ||
| 115 | |||
| 116 | u8* 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 | */ | ||
| 123 | u8* GetPhysicalPointer(PAddr address); | ||
| 124 | |||
| 125 | } | ||
diff --git a/src/video_core/pica.h b/src/video_core/pica.h index a53429716..3fbf95721 100644 --- a/src/video_core/pica.h +++ b/src/video_core/pica.h | |||
| @@ -16,8 +16,6 @@ | |||
| 16 | #include "common/common_types.h" | 16 | #include "common/common_types.h" |
| 17 | #include "common/logging/log.h" | 17 | #include "common/logging/log.h" |
| 18 | 18 | ||
| 19 | #include "core/mem_map.h" | ||
| 20 | |||
| 21 | namespace Pica { | 19 | namespace Pica { |
| 22 | 20 | ||
| 23 | // Returns index corresponding to the Regs member labeled by field_name | 21 | // Returns index corresponding to the Regs member labeled by field_name |
diff --git a/src/video_core/rasterizer.cpp b/src/video_core/rasterizer.cpp index 02a08b20e..59eff48f9 100644 --- a/src/video_core/rasterizer.cpp +++ b/src/video_core/rasterizer.cpp | |||
| @@ -9,6 +9,8 @@ | |||
| 9 | #include "common/profiler.h" | 9 | #include "common/profiler.h" |
| 10 | 10 | ||
| 11 | #include "core/hw/gpu.h" | 11 | #include "core/hw/gpu.h" |
| 12 | #include "core/memory.h" | ||
| 13 | |||
| 12 | #include "debug_utils/debug_utils.h" | 14 | #include "debug_utils/debug_utils.h" |
| 13 | #include "math.h" | 15 | #include "math.h" |
| 14 | #include "color.h" | 16 | #include "color.h" |
diff --git a/src/video_core/renderer_opengl/renderer_opengl.cpp b/src/video_core/renderer_opengl/renderer_opengl.cpp index 0c072120d..71ceb021b 100644 --- a/src/video_core/renderer_opengl/renderer_opengl.cpp +++ b/src/video_core/renderer_opengl/renderer_opengl.cpp | |||
| @@ -5,7 +5,7 @@ | |||
| 5 | #include "core/hw/gpu.h" | 5 | #include "core/hw/gpu.h" |
| 6 | #include "core/hw/hw.h" | 6 | #include "core/hw/hw.h" |
| 7 | #include "core/hw/lcd.h" | 7 | #include "core/hw/lcd.h" |
| 8 | #include "core/mem_map.h" | 8 | #include "core/memory.h" |
| 9 | #include "core/settings.h" | 9 | #include "core/settings.h" |
| 10 | 10 | ||
| 11 | #include "common/emu_window.h" | 11 | #include "common/emu_window.h" |
diff --git a/src/video_core/vertex_shader.cpp b/src/video_core/vertex_shader.cpp index 4734e546a..981d1a356 100644 --- a/src/video_core/vertex_shader.cpp +++ b/src/video_core/vertex_shader.cpp | |||
| @@ -8,8 +8,6 @@ | |||
| 8 | 8 | ||
| 9 | #include <common/file_util.h> | 9 | #include <common/file_util.h> |
| 10 | 10 | ||
| 11 | #include <core/mem_map.h> | ||
| 12 | |||
| 13 | #include <nihstro/shader_bytecode.h> | 11 | #include <nihstro/shader_bytecode.h> |
| 14 | 12 | ||
| 15 | #include "common/profiler.h" | 13 | #include "common/profiler.h" |