summaryrefslogtreecommitdiff
path: root/src/core/memory.cpp
diff options
context:
space:
mode:
authorGravatar bunnei2019-03-17 14:42:57 -0400
committerGravatar GitHub2019-03-17 14:42:57 -0400
commit57ca1e3e6942d1ef1b59c458e76ba969f0b739d5 (patch)
tree1d7a026c695a73932030048329a2c0707656666e /src/core/memory.cpp
parentMerge pull request #2251 from bunnei/skip-zero-flush (diff)
parentcore: Move PageTable struct into Common. (diff)
downloadyuzu-57ca1e3e6942d1ef1b59c458e76ba969f0b739d5.tar.gz
yuzu-57ca1e3e6942d1ef1b59c458e76ba969f0b739d5.tar.xz
yuzu-57ca1e3e6942d1ef1b59c458e76ba969f0b739d5.zip
Merge pull request #2252 from bunnei/move-page-table
core: Move PageTable struct into Common.
Diffstat (limited to 'src/core/memory.cpp')
-rw-r--r--src/core/memory.cpp134
1 files changed, 60 insertions, 74 deletions
diff --git a/src/core/memory.cpp b/src/core/memory.cpp
index e0cc5175f..365ac82b4 100644
--- a/src/core/memory.cpp
+++ b/src/core/memory.cpp
@@ -10,6 +10,7 @@
10#include "common/assert.h" 10#include "common/assert.h"
11#include "common/common_types.h" 11#include "common/common_types.h"
12#include "common/logging/log.h" 12#include "common/logging/log.h"
13#include "common/page_table.h"
13#include "common/swap.h" 14#include "common/swap.h"
14#include "core/arm/arm_interface.h" 15#include "core/arm/arm_interface.h"
15#include "core/core.h" 16#include "core/core.h"
@@ -23,9 +24,9 @@
23 24
24namespace Memory { 25namespace Memory {
25 26
26static PageTable* current_page_table = nullptr; 27static Common::PageTable* current_page_table = nullptr;
27 28
28void SetCurrentPageTable(PageTable* page_table) { 29void SetCurrentPageTable(Common::PageTable* page_table) {
29 current_page_table = page_table; 30 current_page_table = page_table;
30 31
31 auto& system = Core::System::GetInstance(); 32 auto& system = Core::System::GetInstance();
@@ -37,34 +38,12 @@ void SetCurrentPageTable(PageTable* page_table) {
37 } 38 }
38} 39}
39 40
40PageTable* GetCurrentPageTable() { 41Common::PageTable* GetCurrentPageTable() {
41 return current_page_table; 42 return current_page_table;
42} 43}
43 44
44PageTable::PageTable() = default; 45static void MapPages(Common::PageTable& page_table, VAddr base, u64 size, u8* memory,
45 46 Common::PageType type) {
46PageTable::PageTable(std::size_t address_space_width_in_bits) {
47 Resize(address_space_width_in_bits);
48}
49
50PageTable::~PageTable() = default;
51
52void PageTable::Resize(std::size_t address_space_width_in_bits) {
53 const std::size_t num_page_table_entries = 1ULL << (address_space_width_in_bits - PAGE_BITS);
54
55 pointers.resize(num_page_table_entries);
56 attributes.resize(num_page_table_entries);
57
58 // The default is a 39-bit address space, which causes an initial 1GB allocation size. If the
59 // vector size is subsequently decreased (via resize), the vector might not automatically
60 // actually reallocate/resize its underlying allocation, which wastes up to ~800 MB for
61 // 36-bit titles. Call shrink_to_fit to reduce capacity to what's actually in use.
62
63 pointers.shrink_to_fit();
64 attributes.shrink_to_fit();
65}
66
67static void MapPages(PageTable& page_table, VAddr base, u64 size, u8* memory, PageType type) {
68 LOG_DEBUG(HW_Memory, "Mapping {} onto {:016X}-{:016X}", fmt::ptr(memory), base * PAGE_SIZE, 47 LOG_DEBUG(HW_Memory, "Mapping {} onto {:016X}-{:016X}", fmt::ptr(memory), base * PAGE_SIZE,
69 (base + size) * PAGE_SIZE); 48 (base + size) * PAGE_SIZE);
70 49
@@ -92,41 +71,47 @@ static void MapPages(PageTable& page_table, VAddr base, u64 size, u8* memory, Pa
92 } 71 }
93} 72}
94 73
95void MapMemoryRegion(PageTable& page_table, VAddr base, u64 size, u8* target) { 74void MapMemoryRegion(Common::PageTable& page_table, VAddr base, u64 size, u8* target) {
96 ASSERT_MSG((size & PAGE_MASK) == 0, "non-page aligned size: {:016X}", size); 75 ASSERT_MSG((size & PAGE_MASK) == 0, "non-page aligned size: {:016X}", size);
97 ASSERT_MSG((base & PAGE_MASK) == 0, "non-page aligned base: {:016X}", base); 76 ASSERT_MSG((base & PAGE_MASK) == 0, "non-page aligned base: {:016X}", base);
98 MapPages(page_table, base / PAGE_SIZE, size / PAGE_SIZE, target, PageType::Memory); 77 MapPages(page_table, base / PAGE_SIZE, size / PAGE_SIZE, target, Common::PageType::Memory);
99} 78}
100 79
101void MapIoRegion(PageTable& page_table, VAddr base, u64 size, MemoryHookPointer mmio_handler) { 80void MapIoRegion(Common::PageTable& page_table, VAddr base, u64 size,
81 Common::MemoryHookPointer mmio_handler) {
102 ASSERT_MSG((size & PAGE_MASK) == 0, "non-page aligned size: {:016X}", size); 82 ASSERT_MSG((size & PAGE_MASK) == 0, "non-page aligned size: {:016X}", size);
103 ASSERT_MSG((base & PAGE_MASK) == 0, "non-page aligned base: {:016X}", base); 83 ASSERT_MSG((base & PAGE_MASK) == 0, "non-page aligned base: {:016X}", base);
104 MapPages(page_table, base / PAGE_SIZE, size / PAGE_SIZE, nullptr, PageType::Special); 84 MapPages(page_table, base / PAGE_SIZE, size / PAGE_SIZE, nullptr, Common::PageType::Special);
105 85
106 auto interval = boost::icl::discrete_interval<VAddr>::closed(base, base + size - 1); 86 auto interval = boost::icl::discrete_interval<VAddr>::closed(base, base + size - 1);
107 SpecialRegion region{SpecialRegion::Type::IODevice, std::move(mmio_handler)}; 87 Common::SpecialRegion region{Common::SpecialRegion::Type::IODevice, std::move(mmio_handler)};
108 page_table.special_regions.add(std::make_pair(interval, std::set<SpecialRegion>{region})); 88 page_table.special_regions.add(
89 std::make_pair(interval, std::set<Common::SpecialRegion>{region}));
109} 90}
110 91
111void UnmapRegion(PageTable& page_table, VAddr base, u64 size) { 92void UnmapRegion(Common::PageTable& page_table, VAddr base, u64 size) {
112 ASSERT_MSG((size & PAGE_MASK) == 0, "non-page aligned size: {:016X}", size); 93 ASSERT_MSG((size & PAGE_MASK) == 0, "non-page aligned size: {:016X}", size);
113 ASSERT_MSG((base & PAGE_MASK) == 0, "non-page aligned base: {:016X}", base); 94 ASSERT_MSG((base & PAGE_MASK) == 0, "non-page aligned base: {:016X}", base);
114 MapPages(page_table, base / PAGE_SIZE, size / PAGE_SIZE, nullptr, PageType::Unmapped); 95 MapPages(page_table, base / PAGE_SIZE, size / PAGE_SIZE, nullptr, Common::PageType::Unmapped);
115 96
116 auto interval = boost::icl::discrete_interval<VAddr>::closed(base, base + size - 1); 97 auto interval = boost::icl::discrete_interval<VAddr>::closed(base, base + size - 1);
117 page_table.special_regions.erase(interval); 98 page_table.special_regions.erase(interval);
118} 99}
119 100
120void AddDebugHook(PageTable& page_table, VAddr base, u64 size, MemoryHookPointer hook) { 101void AddDebugHook(Common::PageTable& page_table, VAddr base, u64 size,
102 Common::MemoryHookPointer hook) {
121 auto interval = boost::icl::discrete_interval<VAddr>::closed(base, base + size - 1); 103 auto interval = boost::icl::discrete_interval<VAddr>::closed(base, base + size - 1);
122 SpecialRegion region{SpecialRegion::Type::DebugHook, std::move(hook)}; 104 Common::SpecialRegion region{Common::SpecialRegion::Type::DebugHook, std::move(hook)};
123 page_table.special_regions.add(std::make_pair(interval, std::set<SpecialRegion>{region})); 105 page_table.special_regions.add(
106 std::make_pair(interval, std::set<Common::SpecialRegion>{region}));
124} 107}
125 108
126void RemoveDebugHook(PageTable& page_table, VAddr base, u64 size, MemoryHookPointer hook) { 109void RemoveDebugHook(Common::PageTable& page_table, VAddr base, u64 size,
110 Common::MemoryHookPointer hook) {
127 auto interval = boost::icl::discrete_interval<VAddr>::closed(base, base + size - 1); 111 auto interval = boost::icl::discrete_interval<VAddr>::closed(base, base + size - 1);
128 SpecialRegion region{SpecialRegion::Type::DebugHook, std::move(hook)}; 112 Common::SpecialRegion region{Common::SpecialRegion::Type::DebugHook, std::move(hook)};
129 page_table.special_regions.subtract(std::make_pair(interval, std::set<SpecialRegion>{region})); 113 page_table.special_regions.subtract(
114 std::make_pair(interval, std::set<Common::SpecialRegion>{region}));
130} 115}
131 116
132/** 117/**
@@ -175,15 +160,15 @@ T Read(const VAddr vaddr) {
175 return value; 160 return value;
176 } 161 }
177 162
178 PageType type = current_page_table->attributes[vaddr >> PAGE_BITS]; 163 Common::PageType type = current_page_table->attributes[vaddr >> PAGE_BITS];
179 switch (type) { 164 switch (type) {
180 case PageType::Unmapped: 165 case Common::PageType::Unmapped:
181 LOG_ERROR(HW_Memory, "Unmapped Read{} @ 0x{:08X}", sizeof(T) * 8, vaddr); 166 LOG_ERROR(HW_Memory, "Unmapped Read{} @ 0x{:08X}", sizeof(T) * 8, vaddr);
182 return 0; 167 return 0;
183 case PageType::Memory: 168 case Common::PageType::Memory:
184 ASSERT_MSG(false, "Mapped memory page without a pointer @ {:016X}", vaddr); 169 ASSERT_MSG(false, "Mapped memory page without a pointer @ {:016X}", vaddr);
185 break; 170 break;
186 case PageType::RasterizerCachedMemory: { 171 case Common::PageType::RasterizerCachedMemory: {
187 auto host_ptr{GetPointerFromVMA(vaddr)}; 172 auto host_ptr{GetPointerFromVMA(vaddr)};
188 Core::System::GetInstance().GPU().FlushRegion(ToCacheAddr(host_ptr), sizeof(T)); 173 Core::System::GetInstance().GPU().FlushRegion(ToCacheAddr(host_ptr), sizeof(T));
189 T value; 174 T value;
@@ -205,16 +190,16 @@ void Write(const VAddr vaddr, const T data) {
205 return; 190 return;
206 } 191 }
207 192
208 PageType type = current_page_table->attributes[vaddr >> PAGE_BITS]; 193 Common::PageType type = current_page_table->attributes[vaddr >> PAGE_BITS];
209 switch (type) { 194 switch (type) {
210 case PageType::Unmapped: 195 case Common::PageType::Unmapped:
211 LOG_ERROR(HW_Memory, "Unmapped Write{} 0x{:08X} @ 0x{:016X}", sizeof(data) * 8, 196 LOG_ERROR(HW_Memory, "Unmapped Write{} 0x{:08X} @ 0x{:016X}", sizeof(data) * 8,
212 static_cast<u32>(data), vaddr); 197 static_cast<u32>(data), vaddr);
213 return; 198 return;
214 case PageType::Memory: 199 case Common::PageType::Memory:
215 ASSERT_MSG(false, "Mapped memory page without a pointer @ {:016X}", vaddr); 200 ASSERT_MSG(false, "Mapped memory page without a pointer @ {:016X}", vaddr);
216 break; 201 break;
217 case PageType::RasterizerCachedMemory: { 202 case Common::PageType::RasterizerCachedMemory: {
218 auto host_ptr{GetPointerFromVMA(vaddr)}; 203 auto host_ptr{GetPointerFromVMA(vaddr)};
219 Core::System::GetInstance().GPU().InvalidateRegion(ToCacheAddr(host_ptr), sizeof(T)); 204 Core::System::GetInstance().GPU().InvalidateRegion(ToCacheAddr(host_ptr), sizeof(T));
220 std::memcpy(host_ptr, &data, sizeof(T)); 205 std::memcpy(host_ptr, &data, sizeof(T));
@@ -232,10 +217,10 @@ bool IsValidVirtualAddress(const Kernel::Process& process, const VAddr vaddr) {
232 if (page_pointer) 217 if (page_pointer)
233 return true; 218 return true;
234 219
235 if (page_table.attributes[vaddr >> PAGE_BITS] == PageType::RasterizerCachedMemory) 220 if (page_table.attributes[vaddr >> PAGE_BITS] == Common::PageType::RasterizerCachedMemory)
236 return true; 221 return true;
237 222
238 if (page_table.attributes[vaddr >> PAGE_BITS] != PageType::Special) 223 if (page_table.attributes[vaddr >> PAGE_BITS] != Common::PageType::Special)
239 return false; 224 return false;
240 225
241 return false; 226 return false;
@@ -255,7 +240,8 @@ u8* GetPointer(const VAddr vaddr) {
255 return page_pointer + (vaddr & PAGE_MASK); 240 return page_pointer + (vaddr & PAGE_MASK);
256 } 241 }
257 242
258 if (current_page_table->attributes[vaddr >> PAGE_BITS] == PageType::RasterizerCachedMemory) { 243 if (current_page_table->attributes[vaddr >> PAGE_BITS] ==
244 Common::PageType::RasterizerCachedMemory) {
259 return GetPointerFromVMA(vaddr); 245 return GetPointerFromVMA(vaddr);
260 } 246 }
261 247
@@ -289,20 +275,20 @@ void RasterizerMarkRegionCached(VAddr vaddr, u64 size, bool cached) {
289 275
290 u64 num_pages = ((vaddr + size - 1) >> PAGE_BITS) - (vaddr >> PAGE_BITS) + 1; 276 u64 num_pages = ((vaddr + size - 1) >> PAGE_BITS) - (vaddr >> PAGE_BITS) + 1;
291 for (unsigned i = 0; i < num_pages; ++i, vaddr += PAGE_SIZE) { 277 for (unsigned i = 0; i < num_pages; ++i, vaddr += PAGE_SIZE) {
292 PageType& page_type = current_page_table->attributes[vaddr >> PAGE_BITS]; 278 Common::PageType& page_type = current_page_table->attributes[vaddr >> PAGE_BITS];
293 279
294 if (cached) { 280 if (cached) {
295 // Switch page type to cached if now cached 281 // Switch page type to cached if now cached
296 switch (page_type) { 282 switch (page_type) {
297 case PageType::Unmapped: 283 case Common::PageType::Unmapped:
298 // It is not necessary for a process to have this region mapped into its address 284 // It is not necessary for a process to have this region mapped into its address
299 // space, for example, a system module need not have a VRAM mapping. 285 // space, for example, a system module need not have a VRAM mapping.
300 break; 286 break;
301 case PageType::Memory: 287 case Common::PageType::Memory:
302 page_type = PageType::RasterizerCachedMemory; 288 page_type = Common::PageType::RasterizerCachedMemory;
303 current_page_table->pointers[vaddr >> PAGE_BITS] = nullptr; 289 current_page_table->pointers[vaddr >> PAGE_BITS] = nullptr;
304 break; 290 break;
305 case PageType::RasterizerCachedMemory: 291 case Common::PageType::RasterizerCachedMemory:
306 // There can be more than one GPU region mapped per CPU region, so it's common that 292 // There can be more than one GPU region mapped per CPU region, so it's common that
307 // this area is already marked as cached. 293 // this area is already marked as cached.
308 break; 294 break;
@@ -312,23 +298,23 @@ void RasterizerMarkRegionCached(VAddr vaddr, u64 size, bool cached) {
312 } else { 298 } else {
313 // Switch page type to uncached if now uncached 299 // Switch page type to uncached if now uncached
314 switch (page_type) { 300 switch (page_type) {
315 case PageType::Unmapped: 301 case Common::PageType::Unmapped:
316 // It is not necessary for a process to have this region mapped into its address 302 // It is not necessary for a process to have this region mapped into its address
317 // space, for example, a system module need not have a VRAM mapping. 303 // space, for example, a system module need not have a VRAM mapping.
318 break; 304 break;
319 case PageType::Memory: 305 case Common::PageType::Memory:
320 // There can be more than one GPU region mapped per CPU region, so it's common that 306 // There can be more than one GPU region mapped per CPU region, so it's common that
321 // this area is already unmarked as cached. 307 // this area is already unmarked as cached.
322 break; 308 break;
323 case PageType::RasterizerCachedMemory: { 309 case Common::PageType::RasterizerCachedMemory: {
324 u8* pointer = GetPointerFromVMA(vaddr & ~PAGE_MASK); 310 u8* pointer = GetPointerFromVMA(vaddr & ~PAGE_MASK);
325 if (pointer == nullptr) { 311 if (pointer == nullptr) {
326 // It's possible that this function has been called while updating the pagetable 312 // It's possible that this function has been called while updating the pagetable
327 // after unmapping a VMA. In that case the underlying VMA will no longer exist, 313 // after unmapping a VMA. In that case the underlying VMA will no longer exist,
328 // and we should just leave the pagetable entry blank. 314 // and we should just leave the pagetable entry blank.
329 page_type = PageType::Unmapped; 315 page_type = Common::PageType::Unmapped;
330 } else { 316 } else {
331 page_type = PageType::Memory; 317 page_type = Common::PageType::Memory;
332 current_page_table->pointers[vaddr >> PAGE_BITS] = pointer; 318 current_page_table->pointers[vaddr >> PAGE_BITS] = pointer;
333 } 319 }
334 break; 320 break;
@@ -370,21 +356,21 @@ void ReadBlock(const Kernel::Process& process, const VAddr src_addr, void* dest_
370 const VAddr current_vaddr = static_cast<VAddr>((page_index << PAGE_BITS) + page_offset); 356 const VAddr current_vaddr = static_cast<VAddr>((page_index << PAGE_BITS) + page_offset);
371 357
372 switch (page_table.attributes[page_index]) { 358 switch (page_table.attributes[page_index]) {
373 case PageType::Unmapped: { 359 case Common::PageType::Unmapped: {
374 LOG_ERROR(HW_Memory, 360 LOG_ERROR(HW_Memory,
375 "Unmapped ReadBlock @ 0x{:016X} (start address = 0x{:016X}, size = {})", 361 "Unmapped ReadBlock @ 0x{:016X} (start address = 0x{:016X}, size = {})",
376 current_vaddr, src_addr, size); 362 current_vaddr, src_addr, size);
377 std::memset(dest_buffer, 0, copy_amount); 363 std::memset(dest_buffer, 0, copy_amount);
378 break; 364 break;
379 } 365 }
380 case PageType::Memory: { 366 case Common::PageType::Memory: {
381 DEBUG_ASSERT(page_table.pointers[page_index]); 367 DEBUG_ASSERT(page_table.pointers[page_index]);
382 368
383 const u8* src_ptr = page_table.pointers[page_index] + page_offset; 369 const u8* src_ptr = page_table.pointers[page_index] + page_offset;
384 std::memcpy(dest_buffer, src_ptr, copy_amount); 370 std::memcpy(dest_buffer, src_ptr, copy_amount);
385 break; 371 break;
386 } 372 }
387 case PageType::RasterizerCachedMemory: { 373 case Common::PageType::RasterizerCachedMemory: {
388 const auto& host_ptr{GetPointerFromVMA(process, current_vaddr)}; 374 const auto& host_ptr{GetPointerFromVMA(process, current_vaddr)};
389 Core::System::GetInstance().GPU().FlushRegion(ToCacheAddr(host_ptr), copy_amount); 375 Core::System::GetInstance().GPU().FlushRegion(ToCacheAddr(host_ptr), copy_amount);
390 std::memcpy(dest_buffer, host_ptr, copy_amount); 376 std::memcpy(dest_buffer, host_ptr, copy_amount);
@@ -434,20 +420,20 @@ void WriteBlock(const Kernel::Process& process, const VAddr dest_addr, const voi
434 const VAddr current_vaddr = static_cast<VAddr>((page_index << PAGE_BITS) + page_offset); 420 const VAddr current_vaddr = static_cast<VAddr>((page_index << PAGE_BITS) + page_offset);
435 421
436 switch (page_table.attributes[page_index]) { 422 switch (page_table.attributes[page_index]) {
437 case PageType::Unmapped: { 423 case Common::PageType::Unmapped: {
438 LOG_ERROR(HW_Memory, 424 LOG_ERROR(HW_Memory,
439 "Unmapped WriteBlock @ 0x{:016X} (start address = 0x{:016X}, size = {})", 425 "Unmapped WriteBlock @ 0x{:016X} (start address = 0x{:016X}, size = {})",
440 current_vaddr, dest_addr, size); 426 current_vaddr, dest_addr, size);
441 break; 427 break;
442 } 428 }
443 case PageType::Memory: { 429 case Common::PageType::Memory: {
444 DEBUG_ASSERT(page_table.pointers[page_index]); 430 DEBUG_ASSERT(page_table.pointers[page_index]);
445 431
446 u8* dest_ptr = page_table.pointers[page_index] + page_offset; 432 u8* dest_ptr = page_table.pointers[page_index] + page_offset;
447 std::memcpy(dest_ptr, src_buffer, copy_amount); 433 std::memcpy(dest_ptr, src_buffer, copy_amount);
448 break; 434 break;
449 } 435 }
450 case PageType::RasterizerCachedMemory: { 436 case Common::PageType::RasterizerCachedMemory: {
451 const auto& host_ptr{GetPointerFromVMA(process, current_vaddr)}; 437 const auto& host_ptr{GetPointerFromVMA(process, current_vaddr)};
452 Core::System::GetInstance().GPU().InvalidateRegion(ToCacheAddr(host_ptr), copy_amount); 438 Core::System::GetInstance().GPU().InvalidateRegion(ToCacheAddr(host_ptr), copy_amount);
453 std::memcpy(host_ptr, src_buffer, copy_amount); 439 std::memcpy(host_ptr, src_buffer, copy_amount);
@@ -480,20 +466,20 @@ void ZeroBlock(const Kernel::Process& process, const VAddr dest_addr, const std:
480 const VAddr current_vaddr = static_cast<VAddr>((page_index << PAGE_BITS) + page_offset); 466 const VAddr current_vaddr = static_cast<VAddr>((page_index << PAGE_BITS) + page_offset);
481 467
482 switch (page_table.attributes[page_index]) { 468 switch (page_table.attributes[page_index]) {
483 case PageType::Unmapped: { 469 case Common::PageType::Unmapped: {
484 LOG_ERROR(HW_Memory, 470 LOG_ERROR(HW_Memory,
485 "Unmapped ZeroBlock @ 0x{:016X} (start address = 0x{:016X}, size = {})", 471 "Unmapped ZeroBlock @ 0x{:016X} (start address = 0x{:016X}, size = {})",
486 current_vaddr, dest_addr, size); 472 current_vaddr, dest_addr, size);
487 break; 473 break;
488 } 474 }
489 case PageType::Memory: { 475 case Common::PageType::Memory: {
490 DEBUG_ASSERT(page_table.pointers[page_index]); 476 DEBUG_ASSERT(page_table.pointers[page_index]);
491 477
492 u8* dest_ptr = page_table.pointers[page_index] + page_offset; 478 u8* dest_ptr = page_table.pointers[page_index] + page_offset;
493 std::memset(dest_ptr, 0, copy_amount); 479 std::memset(dest_ptr, 0, copy_amount);
494 break; 480 break;
495 } 481 }
496 case PageType::RasterizerCachedMemory: { 482 case Common::PageType::RasterizerCachedMemory: {
497 const auto& host_ptr{GetPointerFromVMA(process, current_vaddr)}; 483 const auto& host_ptr{GetPointerFromVMA(process, current_vaddr)};
498 Core::System::GetInstance().GPU().InvalidateRegion(ToCacheAddr(host_ptr), copy_amount); 484 Core::System::GetInstance().GPU().InvalidateRegion(ToCacheAddr(host_ptr), copy_amount);
499 std::memset(host_ptr, 0, copy_amount); 485 std::memset(host_ptr, 0, copy_amount);
@@ -522,20 +508,20 @@ void CopyBlock(const Kernel::Process& process, VAddr dest_addr, VAddr src_addr,
522 const VAddr current_vaddr = static_cast<VAddr>((page_index << PAGE_BITS) + page_offset); 508 const VAddr current_vaddr = static_cast<VAddr>((page_index << PAGE_BITS) + page_offset);
523 509
524 switch (page_table.attributes[page_index]) { 510 switch (page_table.attributes[page_index]) {
525 case PageType::Unmapped: { 511 case Common::PageType::Unmapped: {
526 LOG_ERROR(HW_Memory, 512 LOG_ERROR(HW_Memory,
527 "Unmapped CopyBlock @ 0x{:016X} (start address = 0x{:016X}, size = {})", 513 "Unmapped CopyBlock @ 0x{:016X} (start address = 0x{:016X}, size = {})",
528 current_vaddr, src_addr, size); 514 current_vaddr, src_addr, size);
529 ZeroBlock(process, dest_addr, copy_amount); 515 ZeroBlock(process, dest_addr, copy_amount);
530 break; 516 break;
531 } 517 }
532 case PageType::Memory: { 518 case Common::PageType::Memory: {
533 DEBUG_ASSERT(page_table.pointers[page_index]); 519 DEBUG_ASSERT(page_table.pointers[page_index]);
534 const u8* src_ptr = page_table.pointers[page_index] + page_offset; 520 const u8* src_ptr = page_table.pointers[page_index] + page_offset;
535 WriteBlock(process, dest_addr, src_ptr, copy_amount); 521 WriteBlock(process, dest_addr, src_ptr, copy_amount);
536 break; 522 break;
537 } 523 }
538 case PageType::RasterizerCachedMemory: { 524 case Common::PageType::RasterizerCachedMemory: {
539 const auto& host_ptr{GetPointerFromVMA(process, current_vaddr)}; 525 const auto& host_ptr{GetPointerFromVMA(process, current_vaddr)};
540 Core::System::GetInstance().GPU().FlushRegion(ToCacheAddr(host_ptr), copy_amount); 526 Core::System::GetInstance().GPU().FlushRegion(ToCacheAddr(host_ptr), copy_amount);
541 WriteBlock(process, dest_addr, host_ptr, copy_amount); 527 WriteBlock(process, dest_addr, host_ptr, copy_amount);