diff options
| author | 2020-04-02 22:00:41 -0400 | |
|---|---|---|
| committer | 2020-04-17 00:59:29 -0400 | |
| commit | dc25c86556c36dd23224d88234afc9ecbf780719 (patch) | |
| tree | 5dbe45bcc17ecad8675e7a4cb03dd34361f01e03 /src/core/device_memory.h | |
| parent | dynarmic: Enable strict alignment checks. (diff) | |
| download | yuzu-dc25c86556c36dd23224d88234afc9ecbf780719.tar.gz yuzu-dc25c86556c36dd23224d88234afc9ecbf780719.tar.xz yuzu-dc25c86556c36dd23224d88234afc9ecbf780719.zip | |
core: device_manager: Add a simple class to manage device RAM.
Diffstat (limited to 'src/core/device_memory.h')
| -rw-r--r-- | src/core/device_memory.h | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/src/core/device_memory.h b/src/core/device_memory.h new file mode 100644 index 000000000..a60a7238a --- /dev/null +++ b/src/core/device_memory.h | |||
| @@ -0,0 +1,48 @@ | |||
| 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/assert.h" | ||
| 8 | #include "common/common_funcs.h" | ||
| 9 | #include "core/hle/kernel/physical_memory.h" | ||
| 10 | |||
| 11 | namespace Core { | ||
| 12 | |||
| 13 | class System; | ||
| 14 | |||
| 15 | namespace DramMemoryMap { | ||
| 16 | constexpr u64 Base = 0x80000000ULL; | ||
| 17 | constexpr u64 Size = 0x100000000ULL; | ||
| 18 | constexpr u64 End = Base + Size; | ||
| 19 | constexpr u64 KernelReserveBase = Base + 0x60000; | ||
| 20 | constexpr u64 SlabHeapBase = KernelReserveBase + 0x85000; | ||
| 21 | constexpr u64 SlapHeapSize = 0xa21000; | ||
| 22 | constexpr u64 SlabHeapEnd = SlabHeapBase + SlapHeapSize; | ||
| 23 | }; // namespace DramMemoryMap | ||
| 24 | |||
| 25 | class DeviceMemory : NonCopyable { | ||
| 26 | public: | ||
| 27 | DeviceMemory(Core::System& system); | ||
| 28 | ~DeviceMemory(); | ||
| 29 | |||
| 30 | template <typename T> | ||
| 31 | PAddr GetPhysicalAddr(T* ptr) { | ||
| 32 | const auto ptr_addr{reinterpret_cast<uintptr_t>(ptr)}; | ||
| 33 | const auto base_addr{reinterpret_cast<uintptr_t>(base)}; | ||
| 34 | ASSERT(ptr_addr >= base_addr); | ||
| 35 | return ptr_addr - base_addr + DramMemoryMap::Base; | ||
| 36 | } | ||
| 37 | |||
| 38 | PAddr GetPhysicalAddr(VAddr addr); | ||
| 39 | |||
| 40 | u8* GetPointer(PAddr addr); | ||
| 41 | |||
| 42 | private: | ||
| 43 | u8* base{}; | ||
| 44 | Kernel::PhysicalMemory physical_memory; | ||
| 45 | Core::System& system; | ||
| 46 | }; | ||
| 47 | |||
| 48 | } // namespace Core | ||