diff options
| author | 2020-04-08 23:37:24 -0400 | |
|---|---|---|
| committer | 2020-04-17 00:59:35 -0400 | |
| commit | a8292f6cd9f8b4088ee85b59a87e5bf0ce387cf0 (patch) | |
| tree | ff88e12685101a4f451b5bb56894ff4e7128d0ce /src/core/device_memory.h | |
| parent | kernel: svc: Updates for new VMM. (diff) | |
| download | yuzu-a8292f6cd9f8b4088ee85b59a87e5bf0ce387cf0.tar.gz yuzu-a8292f6cd9f8b4088ee85b59a87e5bf0ce387cf0.tar.xz yuzu-a8292f6cd9f8b4088ee85b59a87e5bf0ce387cf0.zip | |
kernel: memory: page_table: Simplify GetPhysicalAddr impl.
Diffstat (limited to 'src/core/device_memory.h')
| -rw-r--r-- | src/core/device_memory.h | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/src/core/device_memory.h b/src/core/device_memory.h index 44458c2b5..cc7bda070 100644 --- a/src/core/device_memory.h +++ b/src/core/device_memory.h | |||
| @@ -28,15 +28,11 @@ public: | |||
| 28 | ~DeviceMemory(); | 28 | ~DeviceMemory(); |
| 29 | 29 | ||
| 30 | template <typename T> | 30 | template <typename T> |
| 31 | PAddr GetPhysicalAddr(T* ptr) { | 31 | constexpr PAddr GetPhysicalAddr(T* ptr) { |
| 32 | const auto ptr_addr{reinterpret_cast<uintptr_t>(ptr)}; | 32 | return (reinterpret_cast<uintptr_t>(ptr) - reinterpret_cast<uintptr_t>(buffer.data())) + |
| 33 | const auto base_addr{reinterpret_cast<uintptr_t>(buffer.data())}; | 33 | DramMemoryMap::Base; |
| 34 | ASSERT(ptr_addr >= base_addr); | ||
| 35 | return ptr_addr - base_addr + DramMemoryMap::Base; | ||
| 36 | } | 34 | } |
| 37 | 35 | ||
| 38 | PAddr GetPhysicalAddr(VAddr addr); | ||
| 39 | |||
| 40 | constexpr u8* GetPointer(PAddr addr) { | 36 | constexpr u8* GetPointer(PAddr addr) { |
| 41 | return buffer.data() + (addr - DramMemoryMap::Base); | 37 | return buffer.data() + (addr - DramMemoryMap::Base); |
| 42 | } | 38 | } |