diff options
Diffstat (limited to 'src/core/memory.cpp')
| -rw-r--r-- | src/core/memory.cpp | 36 |
1 files changed, 22 insertions, 14 deletions
diff --git a/src/core/memory.cpp b/src/core/memory.cpp index 5ea0694a9..847e69710 100644 --- a/src/core/memory.cpp +++ b/src/core/memory.cpp | |||
| @@ -477,7 +477,7 @@ void ReadBlock(const VAddr src_addr, void* dest_buffer, const size_t size) { | |||
| 477 | 477 | ||
| 478 | while (remaining_size > 0) { | 478 | while (remaining_size > 0) { |
| 479 | const size_t copy_amount = std::min(PAGE_SIZE - page_offset, remaining_size); | 479 | const size_t copy_amount = std::min(PAGE_SIZE - page_offset, remaining_size); |
| 480 | const VAddr current_vaddr = (page_index << PAGE_BITS) + page_offset; | 480 | const VAddr current_vaddr = static_cast<VAddr>((page_index << PAGE_BITS) + page_offset); |
| 481 | 481 | ||
| 482 | switch (current_page_table->attributes[page_index]) { | 482 | switch (current_page_table->attributes[page_index]) { |
| 483 | case PageType::Unmapped: { | 483 | case PageType::Unmapped: { |
| @@ -500,13 +500,15 @@ void ReadBlock(const VAddr src_addr, void* dest_buffer, const size_t size) { | |||
| 500 | break; | 500 | break; |
| 501 | } | 501 | } |
| 502 | case PageType::RasterizerCachedMemory: { | 502 | case PageType::RasterizerCachedMemory: { |
| 503 | RasterizerFlushVirtualRegion(current_vaddr, copy_amount, FlushMode::Flush); | 503 | RasterizerFlushVirtualRegion(current_vaddr, static_cast<u32>(copy_amount), |
| 504 | FlushMode::Flush); | ||
| 504 | std::memcpy(dest_buffer, GetPointerFromVMA(current_vaddr), copy_amount); | 505 | std::memcpy(dest_buffer, GetPointerFromVMA(current_vaddr), copy_amount); |
| 505 | break; | 506 | break; |
| 506 | } | 507 | } |
| 507 | case PageType::RasterizerCachedSpecial: { | 508 | case PageType::RasterizerCachedSpecial: { |
| 508 | DEBUG_ASSERT(GetMMIOHandler(current_vaddr)); | 509 | DEBUG_ASSERT(GetMMIOHandler(current_vaddr)); |
| 509 | RasterizerFlushVirtualRegion(current_vaddr, copy_amount, FlushMode::Flush); | 510 | RasterizerFlushVirtualRegion(current_vaddr, static_cast<u32>(copy_amount), |
| 511 | FlushMode::Flush); | ||
| 510 | GetMMIOHandler(current_vaddr)->ReadBlock(current_vaddr, dest_buffer, copy_amount); | 512 | GetMMIOHandler(current_vaddr)->ReadBlock(current_vaddr, dest_buffer, copy_amount); |
| 511 | break; | 513 | break; |
| 512 | } | 514 | } |
| @@ -544,7 +546,7 @@ void WriteBlock(const VAddr dest_addr, const void* src_buffer, const size_t size | |||
| 544 | 546 | ||
| 545 | while (remaining_size > 0) { | 547 | while (remaining_size > 0) { |
| 546 | const size_t copy_amount = std::min(PAGE_SIZE - page_offset, remaining_size); | 548 | const size_t copy_amount = std::min(PAGE_SIZE - page_offset, remaining_size); |
| 547 | const VAddr current_vaddr = (page_index << PAGE_BITS) + page_offset; | 549 | const VAddr current_vaddr = static_cast<VAddr>((page_index << PAGE_BITS) + page_offset); |
| 548 | 550 | ||
| 549 | switch (current_page_table->attributes[page_index]) { | 551 | switch (current_page_table->attributes[page_index]) { |
| 550 | case PageType::Unmapped: { | 552 | case PageType::Unmapped: { |
| @@ -567,13 +569,15 @@ void WriteBlock(const VAddr dest_addr, const void* src_buffer, const size_t size | |||
| 567 | break; | 569 | break; |
| 568 | } | 570 | } |
| 569 | case PageType::RasterizerCachedMemory: { | 571 | case PageType::RasterizerCachedMemory: { |
| 570 | RasterizerFlushVirtualRegion(current_vaddr, copy_amount, FlushMode::FlushAndInvalidate); | 572 | RasterizerFlushVirtualRegion(current_vaddr, static_cast<u32>(copy_amount), |
| 573 | FlushMode::FlushAndInvalidate); | ||
| 571 | std::memcpy(GetPointerFromVMA(current_vaddr), src_buffer, copy_amount); | 574 | std::memcpy(GetPointerFromVMA(current_vaddr), src_buffer, copy_amount); |
| 572 | break; | 575 | break; |
| 573 | } | 576 | } |
| 574 | case PageType::RasterizerCachedSpecial: { | 577 | case PageType::RasterizerCachedSpecial: { |
| 575 | DEBUG_ASSERT(GetMMIOHandler(current_vaddr)); | 578 | DEBUG_ASSERT(GetMMIOHandler(current_vaddr)); |
| 576 | RasterizerFlushVirtualRegion(current_vaddr, copy_amount, FlushMode::FlushAndInvalidate); | 579 | RasterizerFlushVirtualRegion(current_vaddr, static_cast<u32>(copy_amount), |
| 580 | FlushMode::FlushAndInvalidate); | ||
| 577 | GetMMIOHandler(current_vaddr)->WriteBlock(current_vaddr, src_buffer, copy_amount); | 581 | GetMMIOHandler(current_vaddr)->WriteBlock(current_vaddr, src_buffer, copy_amount); |
| 578 | break; | 582 | break; |
| 579 | } | 583 | } |
| @@ -597,7 +601,7 @@ void ZeroBlock(const VAddr dest_addr, const size_t size) { | |||
| 597 | 601 | ||
| 598 | while (remaining_size > 0) { | 602 | while (remaining_size > 0) { |
| 599 | const size_t copy_amount = std::min(PAGE_SIZE - page_offset, remaining_size); | 603 | const size_t copy_amount = std::min(PAGE_SIZE - page_offset, remaining_size); |
| 600 | const VAddr current_vaddr = (page_index << PAGE_BITS) + page_offset; | 604 | const VAddr current_vaddr = static_cast<VAddr>((page_index << PAGE_BITS) + page_offset); |
| 601 | 605 | ||
| 602 | switch (current_page_table->attributes[page_index]) { | 606 | switch (current_page_table->attributes[page_index]) { |
| 603 | case PageType::Unmapped: { | 607 | case PageType::Unmapped: { |
| @@ -619,13 +623,15 @@ void ZeroBlock(const VAddr dest_addr, const size_t size) { | |||
| 619 | break; | 623 | break; |
| 620 | } | 624 | } |
| 621 | case PageType::RasterizerCachedMemory: { | 625 | case PageType::RasterizerCachedMemory: { |
| 622 | RasterizerFlushVirtualRegion(current_vaddr, copy_amount, FlushMode::FlushAndInvalidate); | 626 | RasterizerFlushVirtualRegion(current_vaddr, static_cast<u32>(copy_amount), |
| 627 | FlushMode::FlushAndInvalidate); | ||
| 623 | std::memset(GetPointerFromVMA(current_vaddr), 0, copy_amount); | 628 | std::memset(GetPointerFromVMA(current_vaddr), 0, copy_amount); |
| 624 | break; | 629 | break; |
| 625 | } | 630 | } |
| 626 | case PageType::RasterizerCachedSpecial: { | 631 | case PageType::RasterizerCachedSpecial: { |
| 627 | DEBUG_ASSERT(GetMMIOHandler(current_vaddr)); | 632 | DEBUG_ASSERT(GetMMIOHandler(current_vaddr)); |
| 628 | RasterizerFlushVirtualRegion(current_vaddr, copy_amount, FlushMode::FlushAndInvalidate); | 633 | RasterizerFlushVirtualRegion(current_vaddr, static_cast<u32>(copy_amount), |
| 634 | FlushMode::FlushAndInvalidate); | ||
| 629 | GetMMIOHandler(current_vaddr)->WriteBlock(current_vaddr, zeros.data(), copy_amount); | 635 | GetMMIOHandler(current_vaddr)->WriteBlock(current_vaddr, zeros.data(), copy_amount); |
| 630 | break; | 636 | break; |
| 631 | } | 637 | } |
| @@ -646,7 +652,7 @@ void CopyBlock(VAddr dest_addr, VAddr src_addr, const size_t size) { | |||
| 646 | 652 | ||
| 647 | while (remaining_size > 0) { | 653 | while (remaining_size > 0) { |
| 648 | const size_t copy_amount = std::min(PAGE_SIZE - page_offset, remaining_size); | 654 | const size_t copy_amount = std::min(PAGE_SIZE - page_offset, remaining_size); |
| 649 | const VAddr current_vaddr = (page_index << PAGE_BITS) + page_offset; | 655 | const VAddr current_vaddr = static_cast<VAddr>((page_index << PAGE_BITS) + page_offset); |
| 650 | 656 | ||
| 651 | switch (current_page_table->attributes[page_index]) { | 657 | switch (current_page_table->attributes[page_index]) { |
| 652 | case PageType::Unmapped: { | 658 | case PageType::Unmapped: { |
| @@ -670,13 +676,15 @@ void CopyBlock(VAddr dest_addr, VAddr src_addr, const size_t size) { | |||
| 670 | break; | 676 | break; |
| 671 | } | 677 | } |
| 672 | case PageType::RasterizerCachedMemory: { | 678 | case PageType::RasterizerCachedMemory: { |
| 673 | RasterizerFlushVirtualRegion(current_vaddr, copy_amount, FlushMode::Flush); | 679 | RasterizerFlushVirtualRegion(current_vaddr, static_cast<u32>(copy_amount), |
| 680 | FlushMode::Flush); | ||
| 674 | WriteBlock(dest_addr, GetPointerFromVMA(current_vaddr), copy_amount); | 681 | WriteBlock(dest_addr, GetPointerFromVMA(current_vaddr), copy_amount); |
| 675 | break; | 682 | break; |
| 676 | } | 683 | } |
| 677 | case PageType::RasterizerCachedSpecial: { | 684 | case PageType::RasterizerCachedSpecial: { |
| 678 | DEBUG_ASSERT(GetMMIOHandler(current_vaddr)); | 685 | DEBUG_ASSERT(GetMMIOHandler(current_vaddr)); |
| 679 | RasterizerFlushVirtualRegion(current_vaddr, copy_amount, FlushMode::Flush); | 686 | RasterizerFlushVirtualRegion(current_vaddr, static_cast<u32>(copy_amount), |
| 687 | FlushMode::Flush); | ||
| 680 | 688 | ||
| 681 | std::vector<u8> buffer(copy_amount); | 689 | std::vector<u8> buffer(copy_amount); |
| 682 | GetMMIOHandler(current_vaddr)->ReadBlock(current_vaddr, buffer.data(), buffer.size()); | 690 | GetMMIOHandler(current_vaddr)->ReadBlock(current_vaddr, buffer.data(), buffer.size()); |
| @@ -689,8 +697,8 @@ void CopyBlock(VAddr dest_addr, VAddr src_addr, const size_t size) { | |||
| 689 | 697 | ||
| 690 | page_index++; | 698 | page_index++; |
| 691 | page_offset = 0; | 699 | page_offset = 0; |
| 692 | dest_addr += copy_amount; | 700 | dest_addr += static_cast<VAddr>(copy_amount); |
| 693 | src_addr += copy_amount; | 701 | src_addr += static_cast<VAddr>(copy_amount); |
| 694 | remaining_size -= copy_amount; | 702 | remaining_size -= copy_amount; |
| 695 | } | 703 | } |
| 696 | } | 704 | } |