diff options
author | Subv <subv2112@gmail.com> | 2017-09-27 00:27:44 +0200 |
---|---|---|
committer | Subv <subv2112@gmail.com> | 2017-09-27 00:27:44 +0200 |
commit | 35da7f57efd5153be37a05ffcbb57412da74265a (patch) | |
tree | 94e5c1b2719be32d6a6768ba472025335d6235b2 /src/core/memory.cpp | |
parent | Merge pull request #2958 from Subv/audio_buffer_datatype (diff) | |
download | yuzu-35da7f57efd5153be37a05ffcbb57412da74265a.tar yuzu-35da7f57efd5153be37a05ffcbb57412da74265a.tar.gz yuzu-35da7f57efd5153be37a05ffcbb57412da74265a.tar.bz2 yuzu-35da7f57efd5153be37a05ffcbb57412da74265a.tar.lz yuzu-35da7f57efd5153be37a05ffcbb57412da74265a.tar.xz yuzu-35da7f57efd5153be37a05ffcbb57412da74265a.tar.zst yuzu-35da7f57efd5153be37a05ffcbb57412da74265a.zip |
Diffstat (limited to '')
-rw-r--r-- | src/core/memory.cpp | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/src/core/memory.cpp b/src/core/memory.cpp index a6b5f6c99..c42f4326b 100644 --- a/src/core/memory.cpp +++ b/src/core/memory.cpp @@ -110,8 +110,8 @@ static u8* GetPointerFromVMA(VAddr vaddr) { /** * This function should only be called for virtual addreses with attribute `PageType::Special`. */ -static MMIORegionPointer GetMMIOHandler(VAddr vaddr) { - for (const auto& region : current_page_table->special_regions) { +static MMIORegionPointer GetMMIOHandler(const PageTable& page_table, VAddr vaddr) { + for (const auto& region : page_table.special_regions) { if (vaddr >= region.base && vaddr < (region.base + region.size)) { return region.handler; } @@ -120,6 +120,11 @@ static MMIORegionPointer GetMMIOHandler(VAddr vaddr) { return nullptr; // Should never happen } +static MMIORegionPointer GetMMIOHandler(VAddr vaddr) { + const PageTable& page_table = Kernel::g_current_process->vm_manager.page_table; + return GetMMIOHandler(page_table, vaddr); +} + template <typename T> T ReadMMIO(MMIORegionPointer mmio_handler, VAddr addr); @@ -204,18 +209,20 @@ void Write(const VAddr vaddr, const T data) { } } -bool IsValidVirtualAddress(const VAddr vaddr) { - const u8* page_pointer = current_page_table->pointers[vaddr >> PAGE_BITS]; +bool IsValidVirtualAddress(const Kernel::Process& process, const VAddr vaddr) { + auto& page_table = process.vm_manager.page_table; + + const u8* page_pointer = page_table.pointers[vaddr >> PAGE_BITS]; if (page_pointer) return true; - if (current_page_table->attributes[vaddr >> PAGE_BITS] == PageType::RasterizerCachedMemory) + if (page_table.attributes[vaddr >> PAGE_BITS] == PageType::RasterizerCachedMemory) return true; - if (current_page_table->attributes[vaddr >> PAGE_BITS] != PageType::Special) + if (page_table.attributes[vaddr >> PAGE_BITS] != PageType::Special) return false; - MMIORegionPointer mmio_region = GetMMIOHandler(vaddr); + MMIORegionPointer mmio_region = GetMMIOHandler(page_table, vaddr); if (mmio_region) { return mmio_region->IsValidAddress(vaddr); } @@ -223,6 +230,10 @@ bool IsValidVirtualAddress(const VAddr vaddr) { return false; } +bool IsValidVirtualAddress(const VAddr vaddr) { + return IsValidVirtualAddress(*Kernel::g_current_process, vaddr); +} + bool IsValidPhysicalAddress(const PAddr paddr) { return GetPhysicalPointer(paddr) != nullptr; } |