diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/CMakeLists.txt | 1 | ||||
| -rw-r--r-- | src/core/hle/kernel/memory/memory_layout.h | 73 |
2 files changed, 74 insertions, 0 deletions
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index ff38c6cc2..b0a010846 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt | |||
| @@ -159,6 +159,7 @@ add_library(core STATIC | |||
| 159 | hle/kernel/memory/memory_block.h | 159 | hle/kernel/memory/memory_block.h |
| 160 | hle/kernel/memory/memory_block_manager.cpp | 160 | hle/kernel/memory/memory_block_manager.cpp |
| 161 | hle/kernel/memory/memory_block_manager.h | 161 | hle/kernel/memory/memory_block_manager.h |
| 162 | hle/kernel/memory/memory_layout.h | ||
| 162 | hle/kernel/memory/memory_manager.cpp | 163 | hle/kernel/memory/memory_manager.cpp |
| 163 | hle/kernel/memory/memory_manager.h | 164 | hle/kernel/memory/memory_manager.h |
| 164 | hle/kernel/memory/memory_types.h | 165 | hle/kernel/memory/memory_types.h |
diff --git a/src/core/hle/kernel/memory/memory_layout.h b/src/core/hle/kernel/memory/memory_layout.h new file mode 100644 index 000000000..830c6f0d7 --- /dev/null +++ b/src/core/hle/kernel/memory/memory_layout.h | |||
| @@ -0,0 +1,73 @@ | |||
| 1 | // Copyright 2020 yuzu 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 Kernel::Memory { | ||
| 10 | |||
| 11 | class MemoryRegion final { | ||
| 12 | friend class MemoryLayout; | ||
| 13 | |||
| 14 | public: | ||
| 15 | constexpr PAddr StartAddress() const { | ||
| 16 | return start_address; | ||
| 17 | } | ||
| 18 | |||
| 19 | constexpr PAddr EndAddress() const { | ||
| 20 | return end_address; | ||
| 21 | } | ||
| 22 | |||
| 23 | private: | ||
| 24 | constexpr MemoryRegion() = default; | ||
| 25 | constexpr MemoryRegion(PAddr start_address, PAddr end_address) | ||
| 26 | : start_address{start_address}, end_address{end_address} {} | ||
| 27 | |||
| 28 | const PAddr start_address{}; | ||
| 29 | const PAddr end_address{}; | ||
| 30 | }; | ||
| 31 | |||
| 32 | class MemoryLayout final { | ||
| 33 | public: | ||
| 34 | constexpr const MemoryRegion& Application() const { | ||
| 35 | return application; | ||
| 36 | } | ||
| 37 | |||
| 38 | constexpr const MemoryRegion& Applet() const { | ||
| 39 | return applet; | ||
| 40 | } | ||
| 41 | |||
| 42 | constexpr const MemoryRegion& System() const { | ||
| 43 | return system; | ||
| 44 | } | ||
| 45 | |||
| 46 | static constexpr MemoryLayout GetDefaultLayout() { | ||
| 47 | constexpr std::size_t application_size{0xcd500000}; | ||
| 48 | constexpr std::size_t applet_size{0x1fb00000}; | ||
| 49 | constexpr PAddr application_start_address{Core::DramMemoryMap::End - application_size}; | ||
| 50 | constexpr PAddr application_end_address{Core::DramMemoryMap::End}; | ||
| 51 | constexpr PAddr applet_start_address{application_start_address - applet_size}; | ||
| 52 | constexpr PAddr applet_end_address{applet_start_address + applet_size}; | ||
| 53 | constexpr PAddr system_start_address{Core::DramMemoryMap::SlabHeapEnd}; | ||
| 54 | constexpr PAddr system_end_address{applet_start_address}; | ||
| 55 | return {application_start_address, application_end_address, applet_start_address, | ||
| 56 | applet_end_address, system_start_address, system_end_address}; | ||
| 57 | } | ||
| 58 | |||
| 59 | private: | ||
| 60 | constexpr MemoryLayout(PAddr application_start_address, std::size_t application_size, | ||
| 61 | PAddr applet_start_address, std::size_t applet_size, | ||
| 62 | PAddr system_start_address, std::size_t system_size) | ||
| 63 | : application{application_start_address, application_size}, | ||
| 64 | applet{applet_start_address, applet_size}, system{system_start_address, system_size} {} | ||
| 65 | |||
| 66 | const MemoryRegion application; | ||
| 67 | const MemoryRegion applet; | ||
| 68 | const MemoryRegion system; | ||
| 69 | |||
| 70 | const PAddr start_address{}; | ||
| 71 | }; | ||
| 72 | |||
| 73 | } // namespace Kernel::Memory | ||