Kernel/Memory: Add TypedMapping base_address method

This method will be used to ease usage with the structure when we need
to do virtual pointer arithmetics.
This commit is contained in:
Liav A 2022-03-27 17:51:16 +03:00 committed by Andreas Kling
parent 3a3700f95e
commit e6ebf9e5c1

View file

@ -15,6 +15,7 @@ template<typename T>
struct TypedMapping {
const T* ptr() const { return reinterpret_cast<const T*>(region->vaddr().offset(offset).as_ptr()); }
T* ptr() { return reinterpret_cast<T*>(region->vaddr().offset(offset).as_ptr()); }
VirtualAddress base_address() const { return region->vaddr().offset(offset); }
const T* operator->() const { return ptr(); }
T* operator->() { return ptr(); }
const T& operator*() const { return *ptr(); }