diff options
Diffstat (limited to 'src/core/memory.cpp')
| -rw-r--r-- | src/core/memory.cpp | 50 |
1 files changed, 26 insertions, 24 deletions
diff --git a/src/core/memory.cpp b/src/core/memory.cpp index ff0420c56..d7c0080fa 100644 --- a/src/core/memory.cpp +++ b/src/core/memory.cpp | |||
| @@ -39,8 +39,8 @@ PageTable* GetCurrentPageTable() { | |||
| 39 | } | 39 | } |
| 40 | 40 | ||
| 41 | static void MapPages(PageTable& page_table, VAddr base, u64 size, u8* memory, PageType type) { | 41 | static void MapPages(PageTable& page_table, VAddr base, u64 size, u8* memory, PageType type) { |
| 42 | LOG_DEBUG(HW_Memory, "Mapping %p onto %016" PRIX64 "-%016" PRIX64, memory, base * PAGE_SIZE, | 42 | NGLOG_DEBUG(HW_Memory, "Mapping {} onto {:016X}-{:016X}", fmt::ptr(memory), base * PAGE_SIZE, |
| 43 | (base + size) * PAGE_SIZE); | 43 | (base + size) * PAGE_SIZE); |
| 44 | 44 | ||
| 45 | RasterizerFlushVirtualRegion(base << PAGE_BITS, size * PAGE_SIZE, | 45 | RasterizerFlushVirtualRegion(base << PAGE_BITS, size * PAGE_SIZE, |
| 46 | FlushMode::FlushAndInvalidate); | 46 | FlushMode::FlushAndInvalidate); |
| @@ -169,10 +169,10 @@ T Read(const VAddr vaddr) { | |||
| 169 | PageType type = current_page_table->attributes[vaddr >> PAGE_BITS]; | 169 | PageType type = current_page_table->attributes[vaddr >> PAGE_BITS]; |
| 170 | switch (type) { | 170 | switch (type) { |
| 171 | case PageType::Unmapped: | 171 | case PageType::Unmapped: |
| 172 | LOG_ERROR(HW_Memory, "unmapped Read%lu @ 0x%08X", sizeof(T) * 8, vaddr); | 172 | NGLOG_ERROR(HW_Memory, "Unmapped Read{} @ {:#010X}", sizeof(T) * 8, vaddr); |
| 173 | return 0; | 173 | return 0; |
| 174 | case PageType::Memory: | 174 | case PageType::Memory: |
| 175 | ASSERT_MSG(false, "Mapped memory page without a pointer @ %08X", vaddr); | 175 | ASSERT_MSG(false, "Mapped memory page without a pointer @ %016" PRIX64, vaddr); |
| 176 | break; | 176 | break; |
| 177 | case PageType::RasterizerCachedMemory: { | 177 | case PageType::RasterizerCachedMemory: { |
| 178 | RasterizerFlushVirtualRegion(vaddr, sizeof(T), FlushMode::Flush); | 178 | RasterizerFlushVirtualRegion(vaddr, sizeof(T), FlushMode::Flush); |
| @@ -201,11 +201,11 @@ void Write(const VAddr vaddr, const T data) { | |||
| 201 | PageType type = current_page_table->attributes[vaddr >> PAGE_BITS]; | 201 | PageType type = current_page_table->attributes[vaddr >> PAGE_BITS]; |
| 202 | switch (type) { | 202 | switch (type) { |
| 203 | case PageType::Unmapped: | 203 | case PageType::Unmapped: |
| 204 | LOG_ERROR(HW_Memory, "unmapped Write%lu 0x%08X @ 0x%08X", sizeof(data) * 8, (u32)data, | 204 | NGLOG_ERROR(HW_Memory, "Unmapped Write{} {:#010X} @ {:#018X}", sizeof(data) * 8, (u32)data, |
| 205 | vaddr); | 205 | vaddr); |
| 206 | return; | 206 | return; |
| 207 | case PageType::Memory: | 207 | case PageType::Memory: |
| 208 | ASSERT_MSG(false, "Mapped memory page without a pointer @ %08X", vaddr); | 208 | ASSERT_MSG(false, "Mapped memory page without a pointer @ %016" PRIX64, vaddr); |
| 209 | break; | 209 | break; |
| 210 | case PageType::RasterizerCachedMemory: { | 210 | case PageType::RasterizerCachedMemory: { |
| 211 | RasterizerFlushVirtualRegion(vaddr, sizeof(T), FlushMode::Invalidate); | 211 | RasterizerFlushVirtualRegion(vaddr, sizeof(T), FlushMode::Invalidate); |
| @@ -251,7 +251,7 @@ u8* GetPointer(const VAddr vaddr) { | |||
| 251 | return GetPointerFromVMA(vaddr); | 251 | return GetPointerFromVMA(vaddr); |
| 252 | } | 252 | } |
| 253 | 253 | ||
| 254 | LOG_ERROR(HW_Memory, "unknown GetPointer @ 0x%08x", vaddr); | 254 | NGLOG_ERROR(HW_Memory, "Unknown GetPointer @ {:#018X}", vaddr); |
| 255 | return nullptr; | 255 | return nullptr; |
| 256 | } | 256 | } |
| 257 | 257 | ||
| @@ -288,13 +288,12 @@ u8* GetPhysicalPointer(PAddr address) { | |||
| 288 | }); | 288 | }); |
| 289 | 289 | ||
| 290 | if (area == std::end(memory_areas)) { | 290 | if (area == std::end(memory_areas)) { |
| 291 | LOG_ERROR(HW_Memory, "unknown GetPhysicalPointer @ 0x%016" PRIX64, address); | 291 | NGLOG_ERROR(HW_Memory, "Unknown GetPhysicalPointer @ {:#018X}", address); |
| 292 | return nullptr; | 292 | return nullptr; |
| 293 | } | 293 | } |
| 294 | 294 | ||
| 295 | if (area->paddr_base == IO_AREA_PADDR) { | 295 | if (area->paddr_base == IO_AREA_PADDR) { |
| 296 | LOG_ERROR(HW_Memory, "MMIO mappings are not supported yet. phys_addr=0x%016" PRIX64, | 296 | NGLOG_ERROR(HW_Memory, "MMIO mappings are not supported yet. phys_addr={:018X}", address); |
| 297 | address); | ||
| 298 | return nullptr; | 297 | return nullptr; |
| 299 | } | 298 | } |
| 300 | 299 | ||
| @@ -341,9 +340,9 @@ void RasterizerMarkRegionCached(Tegra::GPUVAddr gpu_addr, u64 size, bool cached) | |||
| 341 | Core::System::GetInstance().GPU().memory_manager->GpuToCpuAddress(gpu_addr); | 340 | Core::System::GetInstance().GPU().memory_manager->GpuToCpuAddress(gpu_addr); |
| 342 | // The GPU <-> CPU virtual memory mapping is not 1:1 | 341 | // The GPU <-> CPU virtual memory mapping is not 1:1 |
| 343 | if (!maybe_vaddr) { | 342 | if (!maybe_vaddr) { |
| 344 | LOG_ERROR(HW_Memory, | 343 | NGLOG_ERROR(HW_Memory, |
| 345 | "Trying to flush a cached region to an invalid physical address %08X", | 344 | "Trying to flush a cached region to an invalid physical address {:016X}", |
| 346 | gpu_addr); | 345 | gpu_addr); |
| 347 | continue; | 346 | continue; |
| 348 | } | 347 | } |
| 349 | VAddr vaddr = *maybe_vaddr; | 348 | VAddr vaddr = *maybe_vaddr; |
| @@ -477,8 +476,9 @@ void ReadBlock(const Kernel::Process& process, const VAddr src_addr, void* dest_ | |||
| 477 | 476 | ||
| 478 | switch (page_table.attributes[page_index]) { | 477 | switch (page_table.attributes[page_index]) { |
| 479 | case PageType::Unmapped: { | 478 | case PageType::Unmapped: { |
| 480 | LOG_ERROR(HW_Memory, "unmapped ReadBlock @ 0x%08X (start address = 0x%08X, size = %zu)", | 479 | NGLOG_ERROR(HW_Memory, |
| 481 | current_vaddr, src_addr, size); | 480 | "Unmapped ReadBlock @ {:#018X} (start address = {:#018X}, size = {})", |
| 481 | current_vaddr, src_addr, size); | ||
| 482 | std::memset(dest_buffer, 0, copy_amount); | 482 | std::memset(dest_buffer, 0, copy_amount); |
| 483 | break; | 483 | break; |
| 484 | } | 484 | } |
| @@ -540,9 +540,9 @@ void WriteBlock(const Kernel::Process& process, const VAddr dest_addr, const voi | |||
| 540 | 540 | ||
| 541 | switch (page_table.attributes[page_index]) { | 541 | switch (page_table.attributes[page_index]) { |
| 542 | case PageType::Unmapped: { | 542 | case PageType::Unmapped: { |
| 543 | LOG_ERROR(HW_Memory, | 543 | NGLOG_ERROR(HW_Memory, |
| 544 | "unmapped WriteBlock @ 0x%08X (start address = 0x%08X, size = %zu)", | 544 | "Unmapped WriteBlock @ {:#018X} (start address = {:#018X}, size = {})", |
| 545 | current_vaddr, dest_addr, size); | 545 | current_vaddr, dest_addr, size); |
| 546 | break; | 546 | break; |
| 547 | } | 547 | } |
| 548 | case PageType::Memory: { | 548 | case PageType::Memory: { |
| @@ -588,8 +588,9 @@ void ZeroBlock(const Kernel::Process& process, const VAddr dest_addr, const size | |||
| 588 | 588 | ||
| 589 | switch (page_table.attributes[page_index]) { | 589 | switch (page_table.attributes[page_index]) { |
| 590 | case PageType::Unmapped: { | 590 | case PageType::Unmapped: { |
| 591 | LOG_ERROR(HW_Memory, "unmapped ZeroBlock @ 0x%08X (start address = 0x%08X, size = %zu)", | 591 | NGLOG_ERROR(HW_Memory, |
| 592 | current_vaddr, dest_addr, size); | 592 | "Unmapped ZeroBlock @ {:#018X} (start address = {#:018X}, size = {})", |
| 593 | current_vaddr, dest_addr, size); | ||
| 593 | break; | 594 | break; |
| 594 | } | 595 | } |
| 595 | case PageType::Memory: { | 596 | case PageType::Memory: { |
| @@ -628,8 +629,9 @@ void CopyBlock(const Kernel::Process& process, VAddr dest_addr, VAddr src_addr, | |||
| 628 | 629 | ||
| 629 | switch (page_table.attributes[page_index]) { | 630 | switch (page_table.attributes[page_index]) { |
| 630 | case PageType::Unmapped: { | 631 | case PageType::Unmapped: { |
| 631 | LOG_ERROR(HW_Memory, "unmapped CopyBlock @ 0x%08X (start address = 0x%08X, size = %zu)", | 632 | NGLOG_ERROR(HW_Memory, |
| 632 | current_vaddr, src_addr, size); | 633 | "Unmapped CopyBlock @ {:#018X} (start address = {:#018X}, size = {})", |
| 634 | current_vaddr, src_addr, size); | ||
| 633 | ZeroBlock(process, dest_addr, copy_amount); | 635 | ZeroBlock(process, dest_addr, copy_amount); |
| 634 | break; | 636 | break; |
| 635 | } | 637 | } |
| @@ -678,7 +680,7 @@ boost::optional<PAddr> TryVirtualToPhysicalAddress(const VAddr addr) { | |||
| 678 | PAddr VirtualToPhysicalAddress(const VAddr addr) { | 680 | PAddr VirtualToPhysicalAddress(const VAddr addr) { |
| 679 | auto paddr = TryVirtualToPhysicalAddress(addr); | 681 | auto paddr = TryVirtualToPhysicalAddress(addr); |
| 680 | if (!paddr) { | 682 | if (!paddr) { |
| 681 | LOG_ERROR(HW_Memory, "Unknown virtual address @ 0x%016" PRIX64, addr); | 683 | NGLOG_ERROR(HW_Memory, "Unknown virtual address @ {:#018X}", addr); |
| 682 | // To help with debugging, set bit on address so that it's obviously invalid. | 684 | // To help with debugging, set bit on address so that it's obviously invalid. |
| 683 | return addr | 0x80000000; | 685 | return addr | 0x80000000; |
| 684 | } | 686 | } |