kernel: memory: page_table: Simplify GetPhysicalAddr impl.

This commit is contained in:
bunnei 2020-04-08 23:37:24 -04:00
parent c629e544a7
commit a8292f6cd9
4 changed files with 6 additions and 19 deletions

View file

@ -28,15 +28,11 @@ public:
~DeviceMemory();
template <typename T>
PAddr GetPhysicalAddr(T* ptr) {
const auto ptr_addr{reinterpret_cast<uintptr_t>(ptr)};
const auto base_addr{reinterpret_cast<uintptr_t>(buffer.data())};
ASSERT(ptr_addr >= base_addr);
return ptr_addr - base_addr + DramMemoryMap::Base;
constexpr PAddr GetPhysicalAddr(T* ptr) {
return (reinterpret_cast<uintptr_t>(ptr) - reinterpret_cast<uintptr_t>(buffer.data())) +
DramMemoryMap::Base;
}
PAddr GetPhysicalAddr(VAddr addr);
constexpr u8* GetPointer(PAddr addr) {
return buffer.data() + (addr - DramMemoryMap::Base);
}