diff options
| author | 2020-04-08 17:39:58 -0400 | |
|---|---|---|
| committer | 2020-04-17 00:59:31 -0400 | |
| commit | a040a152468bbd315781c3d50bea484c07e2e02a (patch) | |
| tree | 2723c7160111f0328ce13aa09445c8badc02a3bb /src/core/device_memory.h | |
| parent | common: Add VirtualBuffer class, to abstract memory virtualization. (diff) | |
| download | yuzu-a040a152468bbd315781c3d50bea484c07e2e02a.tar.gz yuzu-a040a152468bbd315781c3d50bea484c07e2e02a.tar.xz yuzu-a040a152468bbd315781c3d50bea484c07e2e02a.zip | |
core: device_memory: Update to use VirtualBuffer class.
Diffstat (limited to 'src/core/device_memory.h')
| -rw-r--r-- | src/core/device_memory.h | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/core/device_memory.h b/src/core/device_memory.h index a60a7238a..44458c2b5 100644 --- a/src/core/device_memory.h +++ b/src/core/device_memory.h | |||
| @@ -6,7 +6,7 @@ | |||
| 6 | 6 | ||
| 7 | #include "common/assert.h" | 7 | #include "common/assert.h" |
| 8 | #include "common/common_funcs.h" | 8 | #include "common/common_funcs.h" |
| 9 | #include "core/hle/kernel/physical_memory.h" | 9 | #include "common/virtual_buffer.h" |
| 10 | 10 | ||
| 11 | namespace Core { | 11 | namespace Core { |
| 12 | 12 | ||
| @@ -24,24 +24,25 @@ constexpr u64 SlabHeapEnd = SlabHeapBase + SlapHeapSize; | |||
| 24 | 24 | ||
| 25 | class DeviceMemory : NonCopyable { | 25 | class DeviceMemory : NonCopyable { |
| 26 | public: | 26 | public: |
| 27 | DeviceMemory(Core::System& system); | 27 | explicit DeviceMemory(Core::System& system); |
| 28 | ~DeviceMemory(); | 28 | ~DeviceMemory(); |
| 29 | 29 | ||
| 30 | template <typename T> | 30 | template <typename T> |
| 31 | PAddr GetPhysicalAddr(T* ptr) { | 31 | PAddr GetPhysicalAddr(T* ptr) { |
| 32 | const auto ptr_addr{reinterpret_cast<uintptr_t>(ptr)}; | 32 | const auto ptr_addr{reinterpret_cast<uintptr_t>(ptr)}; |
| 33 | const auto base_addr{reinterpret_cast<uintptr_t>(base)}; | 33 | const auto base_addr{reinterpret_cast<uintptr_t>(buffer.data())}; |
| 34 | ASSERT(ptr_addr >= base_addr); | 34 | ASSERT(ptr_addr >= base_addr); |
| 35 | return ptr_addr - base_addr + DramMemoryMap::Base; | 35 | return ptr_addr - base_addr + DramMemoryMap::Base; |
| 36 | } | 36 | } |
| 37 | 37 | ||
| 38 | PAddr GetPhysicalAddr(VAddr addr); | 38 | PAddr GetPhysicalAddr(VAddr addr); |
| 39 | 39 | ||
| 40 | u8* GetPointer(PAddr addr); | 40 | constexpr u8* GetPointer(PAddr addr) { |
| 41 | return buffer.data() + (addr - DramMemoryMap::Base); | ||
| 42 | } | ||
| 41 | 43 | ||
| 42 | private: | 44 | private: |
| 43 | u8* base{}; | 45 | Common::VirtualBuffer<u8> buffer; |
| 44 | Kernel::PhysicalMemory physical_memory; | ||
| 45 | Core::System& system; | 46 | Core::System& system; |
| 46 | }; | 47 | }; |
| 47 | 48 | ||