From dcd6bb82f7a5bc1daaa8570f710ffb062fa4c596 Mon Sep 17 00:00:00 2001 From: bunnei Date: Thu, 19 Oct 2017 23:00:46 -0400 Subject: hle: Fix QueryMemory response for MemoryInfo. --- src/core/hle/kernel/memory.cpp | 66 ------------------------------------------ 1 file changed, 66 deletions(-) (limited to 'src/core/hle/kernel/memory.cpp') diff --git a/src/core/hle/kernel/memory.cpp b/src/core/hle/kernel/memory.cpp index 7f27e9655..95d3a6bf6 100644 --- a/src/core/hle/kernel/memory.cpp +++ b/src/core/hle/kernel/memory.cpp @@ -96,75 +96,9 @@ MemoryRegionInfo* GetMemoryRegion(MemoryRegion region) { } void HandleSpecialMapping(VMManager& address_space, const AddressMapping& mapping) { - using namespace Memory; - - struct MemoryArea { - VAddr vaddr_base; - PAddr paddr_base; - u32 size; - }; - - // The order of entries in this array is important. The VRAM and IO VAddr ranges overlap, and - // VRAM must be tried first. - static constexpr MemoryArea memory_areas[] = { - {VRAM_VADDR, VRAM_PADDR, VRAM_SIZE}, - {IO_AREA_VADDR, IO_AREA_PADDR, IO_AREA_SIZE}, - {DSP_RAM_VADDR, DSP_RAM_PADDR, DSP_RAM_SIZE}, - {N3DS_EXTRA_RAM_VADDR, N3DS_EXTRA_RAM_PADDR, N3DS_EXTRA_RAM_SIZE - 0x20000}, - }; - - VAddr mapping_limit = mapping.address + mapping.size; - if (mapping_limit < mapping.address) { - LOG_CRITICAL(Loader, "Mapping size overflowed: address=0x%08" PRIX32 " size=0x%" PRIX32, - mapping.address, mapping.size); - return; - } - - auto area = - std::find_if(std::begin(memory_areas), std::end(memory_areas), [&](const auto& area) { - return mapping.address >= area.vaddr_base && - mapping_limit <= area.vaddr_base + area.size; - }); - if (area == std::end(memory_areas)) { - LOG_ERROR(Loader, "Unhandled special mapping: address=0x%08" PRIX32 " size=0x%" PRIX32 - " read_only=%d unk_flag=%d", - mapping.address, mapping.size, mapping.read_only, mapping.unk_flag); - return; - } - - u32 offset_into_region = mapping.address - area->vaddr_base; - if (area->paddr_base == IO_AREA_PADDR) { - LOG_ERROR(Loader, "MMIO mappings are not supported yet. phys_addr=0x%08" PRIX32, - area->paddr_base + offset_into_region); - return; - } - - u8* target_pointer = Memory::GetPhysicalPointer(area->paddr_base + offset_into_region); - - // TODO(yuriks): This flag seems to have some other effect, but it's unknown what - MemoryState memory_state = mapping.unk_flag ? MemoryState::Static : MemoryState::IO; - - auto vma = - address_space.MapBackingMemory(mapping.address, target_pointer, mapping.size, memory_state) - .Unwrap(); - address_space.Reprotect(vma, - mapping.read_only ? VMAPermission::Read : VMAPermission::ReadWrite); } void MapSharedPages(VMManager& address_space) { - auto cfg_mem_vma = address_space - .MapBackingMemory(Memory::CONFIG_MEMORY_VADDR, - reinterpret_cast(&ConfigMem::config_mem), - Memory::CONFIG_MEMORY_SIZE, MemoryState::Shared) - .Unwrap(); - address_space.Reprotect(cfg_mem_vma, VMAPermission::Read); - - auto shared_page_vma = address_space - .MapBackingMemory(Memory::SHARED_PAGE_VADDR, - reinterpret_cast(&SharedPage::shared_page), - Memory::SHARED_PAGE_SIZE, MemoryState::Shared) - .Unwrap(); - address_space.Reprotect(shared_page_vma, VMAPermission::Read); } } // namespace Kernel -- cgit v1.2.3