diff options
author | Markus Wick <markus@selfnet.de> | 2020-01-19 01:49:30 +0100 |
---|---|---|
committer | Markus Wick <markus@selfnet.de> | 2021-06-11 17:27:06 +0200 |
commit | 621f3f5f47bf9619148cc0ab7ed315e05abf79d7 (patch) | |
tree | d2008e290ac507772b5f1d3b019472fc416278f2 /src/core/memory.cpp | |
parent | tests: Add tests for host memory (diff) | |
download | yuzu-621f3f5f47bf9619148cc0ab7ed315e05abf79d7.tar yuzu-621f3f5f47bf9619148cc0ab7ed315e05abf79d7.tar.gz yuzu-621f3f5f47bf9619148cc0ab7ed315e05abf79d7.tar.bz2 yuzu-621f3f5f47bf9619148cc0ab7ed315e05abf79d7.tar.lz yuzu-621f3f5f47bf9619148cc0ab7ed315e05abf79d7.tar.xz yuzu-621f3f5f47bf9619148cc0ab7ed315e05abf79d7.tar.zst yuzu-621f3f5f47bf9619148cc0ab7ed315e05abf79d7.zip |
Diffstat (limited to 'src/core/memory.cpp')
-rw-r--r-- | src/core/memory.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/core/memory.cpp b/src/core/memory.cpp index 9857278f6..79468e4dc 100644 --- a/src/core/memory.cpp +++ b/src/core/memory.cpp @@ -12,6 +12,7 @@ #include "common/common_types.h" #include "common/logging/log.h" #include "common/page_table.h" +#include "common/settings.h" #include "common/swap.h" #include "core/arm/arm_interface.h" #include "core/core.h" @@ -32,6 +33,7 @@ struct Memory::Impl { void SetCurrentPageTable(Kernel::KProcess& process, u32 core_id) { current_page_table = &process.PageTable().PageTableImpl(); + current_page_table->fastmem_arena = system.DeviceMemory().buffer.VirtualBasePointer(); const std::size_t address_space_width = process.PageTable().GetAddressSpaceWidth(); @@ -41,13 +43,19 @@ struct Memory::Impl { void MapMemoryRegion(Common::PageTable& page_table, VAddr base, u64 size, PAddr target) { ASSERT_MSG((size & PAGE_MASK) == 0, "non-page aligned size: {:016X}", size); ASSERT_MSG((base & PAGE_MASK) == 0, "non-page aligned base: {:016X}", base); + ASSERT_MSG(target >= DramMemoryMap::Base && target < DramMemoryMap::End, + "Out of bounds target: {:016X}", target); MapPages(page_table, base / PAGE_SIZE, size / PAGE_SIZE, target, Common::PageType::Memory); + + system.DeviceMemory().buffer.Map(base, target - DramMemoryMap::Base, size); } void UnmapRegion(Common::PageTable& page_table, VAddr base, u64 size) { ASSERT_MSG((size & PAGE_MASK) == 0, "non-page aligned size: {:016X}", size); ASSERT_MSG((base & PAGE_MASK) == 0, "non-page aligned base: {:016X}", base); MapPages(page_table, base / PAGE_SIZE, size / PAGE_SIZE, 0, Common::PageType::Unmapped); + + system.DeviceMemory().buffer.Unmap(base, size); } bool IsValidVirtualAddress(const Kernel::KProcess& process, const VAddr vaddr) const { @@ -466,6 +474,10 @@ struct Memory::Impl { if (vaddr == 0) { return; } + + const bool is_read_enable = Settings::IsGPULevelHigh() || !cached; + system.DeviceMemory().buffer.Protect(vaddr, size, is_read_enable, !cached); + // Iterate over a contiguous CPU address space, which corresponds to the specified GPU // address space, marking the region as un/cached. The region is marked un/cached at a // granularity of CPU pages, hence why we iterate on a CPU page basis (note: GPU page size |