diff options
Diffstat (limited to 'src/core/device_memory.h')
| -rw-r--r-- | src/core/device_memory.h | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/src/core/device_memory.h b/src/core/device_memory.h new file mode 100644 index 000000000..9efa088d0 --- /dev/null +++ b/src/core/device_memory.h | |||
| @@ -0,0 +1,51 @@ | |||
| 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 "common/virtual_buffer.h" | ||
| 10 | |||
| 11 | namespace Core { | ||
| 12 | |||
| 13 | class System; | ||
| 14 | |||
| 15 | namespace DramMemoryMap { | ||
| 16 | enum : u64 { | ||
| 17 | Base = 0x80000000ULL, | ||
| 18 | Size = 0x100000000ULL, | ||
| 19 | End = Base + Size, | ||
| 20 | KernelReserveBase = Base + 0x60000, | ||
| 21 | SlabHeapBase = KernelReserveBase + 0x85000, | ||
| 22 | SlapHeapSize = 0xa21000, | ||
| 23 | SlabHeapEnd = SlabHeapBase + SlapHeapSize, | ||
| 24 | }; | ||
| 25 | }; // namespace DramMemoryMap | ||
| 26 | |||
| 27 | class DeviceMemory : NonCopyable { | ||
| 28 | public: | ||
| 29 | explicit DeviceMemory(Core::System& system); | ||
| 30 | ~DeviceMemory(); | ||
| 31 | |||
| 32 | template <typename T> | ||
| 33 | PAddr GetPhysicalAddr(const T* ptr) const { | ||
| 34 | return (reinterpret_cast<uintptr_t>(ptr) - reinterpret_cast<uintptr_t>(buffer.data())) + | ||
| 35 | DramMemoryMap::Base; | ||
| 36 | } | ||
| 37 | |||
| 38 | u8* GetPointer(PAddr addr) { | ||
| 39 | return buffer.data() + (addr - DramMemoryMap::Base); | ||
| 40 | } | ||
| 41 | |||
| 42 | const u8* GetPointer(PAddr addr) const { | ||
| 43 | return buffer.data() + (addr - DramMemoryMap::Base); | ||
| 44 | } | ||
| 45 | |||
| 46 | private: | ||
| 47 | Common::VirtualBuffer<u8> buffer; | ||
| 48 | Core::System& system; | ||
| 49 | }; | ||
| 50 | |||
| 51 | } // namespace Core | ||