kernel: memory: page_table: Simplify GetPhysicalAddr impl.
This commit is contained in:
parent
c629e544a7
commit
a8292f6cd9
4 changed files with 6 additions and 19 deletions
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue