From 2f0418c10134b4c8e5ae47ace623b5db57c0435c Mon Sep 17 00:00:00 2001 From: Fernando Sahmkow Date: Thu, 21 Dec 2023 00:04:03 +0100 Subject: Core: Initial implementation of device memory mapping --- src/core/device_memory.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/core/device_memory.h') diff --git a/src/core/device_memory.h b/src/core/device_memory.h index 13388b73e..11bf0e326 100644 --- a/src/core/device_memory.h +++ b/src/core/device_memory.h @@ -31,6 +31,12 @@ public: DramMemoryMap::Base; } + template + PAddr GetRawPhysicalAddr(const T* ptr) const { + return static_cast(reinterpret_cast(ptr) - + reinterpret_cast(buffer.BackingBasePointer())); + } + template T* GetPointer(Common::PhysicalAddress addr) { return reinterpret_cast(buffer.BackingBasePointer() + @@ -43,6 +49,16 @@ public: (GetInteger(addr) - DramMemoryMap::Base)); } + template + T* GetPointerFromRaw(PAddr addr) { + return reinterpret_cast(buffer.BackingBasePointer() + addr); + } + + template + const T* GetPointerFromRaw(PAddr addr) const { + return reinterpret_cast(buffer.BackingBasePointer() + addr); + } + Common::HostMemory buffer; }; -- cgit v1.2.3