diff options
author | bunnei <[email protected]> | 2020-04-08 23:37:24 -0400 |
---|---|---|
committer | bunnei <[email protected]> | 2020-04-17 00:59:35 -0400 |
commit | a8292f6cd9f8b4088ee85b59a87e5bf0ce387cf0 (patch) | |
tree | ff88e12685101a4f451b5bb56894ff4e7128d0ce /src | |
parent | c629e544a7d88daf963c615dd182dad089b8a524 (diff) | |
download | yuzu-android-a8292f6cd9f8b4088ee85b59a87e5bf0ce387cf0.tar.gz yuzu-android-a8292f6cd9f8b4088ee85b59a87e5bf0ce387cf0.zip |
kernel: memory: page_table: Simplify GetPhysicalAddr impl.
Diffstat (limited to 'src')
-rw-r--r-- | src/core/device_memory.cpp | 7 | ||||
-rw-r--r-- | src/core/device_memory.h | 10 | ||||
-rw-r--r-- | src/core/hle/kernel/memory/page_table.cpp | 4 | ||||
-rw-r--r-- | src/core/hle/kernel/memory/page_table.h | 4 |
4 files changed, 6 insertions, 19 deletions
diff --git a/src/core/device_memory.cpp b/src/core/device_memory.cpp index 61429a6ac..51097ced3 100644 --- a/src/core/device_memory.cpp +++ b/src/core/device_memory.cpp @@ -12,11 +12,4 @@ DeviceMemory::DeviceMemory(System& system) : buffer{DramMemoryMap::Size}, system DeviceMemory::~DeviceMemory() = default; -PAddr DeviceMemory::GetPhysicalAddr(VAddr addr) { - const u8* const base{system.Memory().GetPointer(addr)}; - ASSERT(base); - const uintptr_t offset{static_cast<uintptr_t>(base - GetPointer(DramMemoryMap::Base))}; - return DramMemoryMap::Base + offset; -} - } // namespace Core 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 <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); } diff --git a/src/core/hle/kernel/memory/page_table.cpp b/src/core/hle/kernel/memory/page_table.cpp index 93e7253e2..941ecda21 100644 --- a/src/core/hle/kernel/memory/page_table.cpp +++ b/src/core/hle/kernel/memory/page_table.cpp @@ -936,10 +936,6 @@ ResultVal<VAddr> PageTable::AllocateAndMapMemory(std::size_t needed_num_pages, s return MakeResult<VAddr>(addr); } -PAddr PageTable::GetPhysicalAddr(VAddr addr) { - return system.DeviceMemory().GetPhysicalAddr(addr); -} - ResultCode PageTable::InitializeMemoryLayout(VAddr start, VAddr end) { block_manager = std::make_unique<MemoryBlockManager>(start, end); diff --git a/src/core/hle/kernel/memory/page_table.h b/src/core/hle/kernel/memory/page_table.h index 6c3a3c275..80384ab0f 100644 --- a/src/core/hle/kernel/memory/page_table.h +++ b/src/core/hle/kernel/memory/page_table.h @@ -53,7 +53,6 @@ public: bool is_map_only, VAddr region_start, std::size_t region_num_pages, MemoryState state, MemoryPermission perm, PAddr map_addr = 0); - PAddr GetPhysicalAddr(VAddr addr); Common::PageTable& PageTableImpl() { return page_table_impl; @@ -211,6 +210,9 @@ public: constexpr bool IsInsideASLRRegion(VAddr address, std::size_t size) const { return !IsOutsideASLRRegion(address, size); } + constexpr PAddr GetPhysicalAddr(VAddr addr) { + return page_table_impl.backing_addr[addr >> Memory::PageBits] + addr; + } private: constexpr bool Contains(VAddr addr) const { |