summaryrefslogtreecommitdiffstats
path: root/src/core
diff options
context:
space:
mode:
authorMerryMage <MerryMage@users.noreply.github.com>2016-04-16 11:21:41 +0200
committerSubv <subv2112@gmail.com>2016-05-21 18:14:09 +0200
commitca17df5757f08c7bb673aec19e0fdd4698dd904f (patch)
tree4f767cec3763de660a3fed6c2b9110f8124a0d0f /src/core
parentFileSys/Path: Replace Memory::GetPointer with Memory::ReadBlock (diff)
downloadyuzu-ca17df5757f08c7bb673aec19e0fdd4698dd904f.tar
yuzu-ca17df5757f08c7bb673aec19e0fdd4698dd904f.tar.gz
yuzu-ca17df5757f08c7bb673aec19e0fdd4698dd904f.tar.bz2
yuzu-ca17df5757f08c7bb673aec19e0fdd4698dd904f.tar.lz
yuzu-ca17df5757f08c7bb673aec19e0fdd4698dd904f.tar.xz
yuzu-ca17df5757f08c7bb673aec19e0fdd4698dd904f.tar.zst
yuzu-ca17df5757f08c7bb673aec19e0fdd4698dd904f.zip
Diffstat (limited to '')
-rw-r--r--src/core/memory.cpp38
-rw-r--r--src/core/memory.h1
2 files changed, 39 insertions, 0 deletions
diff --git a/src/core/memory.cpp b/src/core/memory.cpp
index c7b99a467..1604a7da5 100644
--- a/src/core/memory.cpp
+++ b/src/core/memory.cpp
@@ -457,6 +457,44 @@ void WriteBlock(const VAddr dest_addr, const u8* src_buffer, const size_t size)
}
}
+void ZeroBlock(const VAddr dest_addr, const size_t size) {
+ size_t remaining_size = size;
+ size_t page_index = dest_addr >> PAGE_BITS;
+ size_t page_offset = dest_addr & PAGE_MASK;
+
+ while (remaining_size > 0) {
+ const size_t copy_amount = std::min(PAGE_SIZE - page_offset, remaining_size);
+ const VAddr current_vaddr = (page_index << PAGE_BITS) + page_offset;
+
+ switch (current_page_table->attributes[page_index]) {
+ case PageType::Unmapped: {
+ LOG_ERROR(HW_Memory, "unmapped ZeroBlock @ 0x%08X (start address = 0x%08X, size = %zu)", current_vaddr, dest_addr, size);
+ break;
+ }
+ case PageType::Memory: {
+ DEBUG_ASSERT(current_page_table->pointers[page_index]);
+
+ u8* dest_ptr = current_page_table->pointers[page_index] + page_offset;
+ std::memset(dest_ptr, 0, copy_amount);
+ break;
+ }
+ case PageType::Special: {
+ DEBUG_ASSERT(GetMMIOHandler(current_vaddr));
+
+ static const std::array<u8, PAGE_SIZE> zeros = {};
+ GetMMIOHandler(current_vaddr)->WriteBlock(current_vaddr, zeros.data(), copy_amount);
+ break;
+ }
+ default:
+ UNREACHABLE();
+ }
+
+ page_index++;
+ page_offset = 0;
+ remaining_size -= copy_amount;
+ }
+}
+
template<>
u8 ReadMMIO<u8>(MMIORegionPointer mmio_handler, VAddr addr) {
return mmio_handler->Read8(addr);
diff --git a/src/core/memory.h b/src/core/memory.h
index 35bd5eb0c..713cdfb2f 100644
--- a/src/core/memory.h
+++ b/src/core/memory.h
@@ -126,6 +126,7 @@ void Write32(VAddr addr, u32 data);
void Write64(VAddr addr, u64 data);
void WriteBlock(const VAddr dest_addr, const u8* src_buffer, size_t size);
+void ZeroBlock(const VAddr dest_addr, const size_t size);
u8* GetPointer(VAddr virtual_address);