From a8292f6cd9f8b4088ee85b59a87e5bf0ce387cf0 Mon Sep 17 00:00:00 2001 From: bunnei Date: Wed, 8 Apr 2020 23:37:24 -0400 Subject: kernel: memory: page_table: Simplify GetPhysicalAddr impl. --- src/core/device_memory.h | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'src/core/device_memory.h') 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: ~DeviceMemory(); template - PAddr GetPhysicalAddr(T* ptr) { - const auto ptr_addr{reinterpret_cast(ptr)}; - const auto base_addr{reinterpret_cast(buffer.data())}; - ASSERT(ptr_addr >= base_addr); - return ptr_addr - base_addr + DramMemoryMap::Base; + constexpr PAddr GetPhysicalAddr(T* ptr) { + return (reinterpret_cast(ptr) - reinterpret_cast(buffer.data())) + + DramMemoryMap::Base; } - PAddr GetPhysicalAddr(VAddr addr); - constexpr u8* GetPointer(PAddr addr) { return buffer.data() + (addr - DramMemoryMap::Base); } -- cgit v1.2.3