From 8610dafaa730eb25f3414366775d5cca1f011491 Mon Sep 17 00:00:00 2001 From: Kloen Date: Mon, 23 Jan 2017 18:04:03 +0100 Subject: [PATCH] core: fix memory.cpp size_t to u32 or VAddrs warnings --- src/core/memory.cpp | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/src/core/memory.cpp b/src/core/memory.cpp index 65e4bba85..ea19476df 100644 --- a/src/core/memory.cpp +++ b/src/core/memory.cpp @@ -392,7 +392,7 @@ void ReadBlock(const VAddr src_addr, void* dest_buffer, const size_t size) { 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; + const VAddr current_vaddr = static_cast((page_index << PAGE_BITS) + page_offset); switch (current_page_table->attributes[page_index]) { case PageType::Unmapped: { @@ -415,7 +415,8 @@ void ReadBlock(const VAddr src_addr, void* dest_buffer, const size_t size) { break; } case PageType::RasterizerCachedMemory: { - RasterizerFlushRegion(VirtualToPhysicalAddress(current_vaddr), copy_amount); + RasterizerFlushRegion(VirtualToPhysicalAddress(current_vaddr), + static_cast(copy_amount)); std::memcpy(dest_buffer, GetPointerFromVMA(current_vaddr), copy_amount); break; @@ -423,7 +424,8 @@ void ReadBlock(const VAddr src_addr, void* dest_buffer, const size_t size) { case PageType::RasterizerCachedSpecial: { DEBUG_ASSERT(GetMMIOHandler(current_vaddr)); - RasterizerFlushRegion(VirtualToPhysicalAddress(current_vaddr), copy_amount); + RasterizerFlushRegion(VirtualToPhysicalAddress(current_vaddr), + static_cast(copy_amount)); GetMMIOHandler(current_vaddr)->ReadBlock(current_vaddr, dest_buffer, copy_amount); break; @@ -462,7 +464,7 @@ void WriteBlock(const VAddr dest_addr, const void* src_buffer, const size_t size 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; + const VAddr current_vaddr = static_cast((page_index << PAGE_BITS) + page_offset); switch (current_page_table->attributes[page_index]) { case PageType::Unmapped: { @@ -486,7 +488,7 @@ void WriteBlock(const VAddr dest_addr, const void* src_buffer, const size_t size } case PageType::RasterizerCachedMemory: { RasterizerFlushAndInvalidateRegion(VirtualToPhysicalAddress(current_vaddr), - copy_amount); + static_cast(copy_amount)); std::memcpy(GetPointerFromVMA(current_vaddr), src_buffer, copy_amount); break; @@ -495,7 +497,7 @@ void WriteBlock(const VAddr dest_addr, const void* src_buffer, const size_t size DEBUG_ASSERT(GetMMIOHandler(current_vaddr)); RasterizerFlushAndInvalidateRegion(VirtualToPhysicalAddress(current_vaddr), - copy_amount); + static_cast(copy_amount)); GetMMIOHandler(current_vaddr)->WriteBlock(current_vaddr, src_buffer, copy_amount); break; @@ -520,7 +522,7 @@ void ZeroBlock(const VAddr dest_addr, const size_t size) { 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; + const VAddr current_vaddr = static_cast((page_index << PAGE_BITS) + page_offset); switch (current_page_table->attributes[page_index]) { case PageType::Unmapped: { @@ -543,7 +545,7 @@ void ZeroBlock(const VAddr dest_addr, const size_t size) { } case PageType::RasterizerCachedMemory: { RasterizerFlushAndInvalidateRegion(VirtualToPhysicalAddress(current_vaddr), - copy_amount); + static_cast(copy_amount)); std::memset(GetPointerFromVMA(current_vaddr), 0, copy_amount); break; @@ -552,7 +554,7 @@ void ZeroBlock(const VAddr dest_addr, const size_t size) { DEBUG_ASSERT(GetMMIOHandler(current_vaddr)); RasterizerFlushAndInvalidateRegion(VirtualToPhysicalAddress(current_vaddr), - copy_amount); + static_cast(copy_amount)); GetMMIOHandler(current_vaddr)->WriteBlock(current_vaddr, zeros.data(), copy_amount); break; @@ -574,7 +576,7 @@ void CopyBlock(VAddr dest_addr, VAddr src_addr, const size_t size) { 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; + const VAddr current_vaddr = static_cast((page_index << PAGE_BITS) + page_offset); switch (current_page_table->attributes[page_index]) { case PageType::Unmapped: { @@ -598,7 +600,8 @@ void CopyBlock(VAddr dest_addr, VAddr src_addr, const size_t size) { break; } case PageType::RasterizerCachedMemory: { - RasterizerFlushRegion(VirtualToPhysicalAddress(current_vaddr), copy_amount); + RasterizerFlushRegion(VirtualToPhysicalAddress(current_vaddr), + static_cast(copy_amount)); WriteBlock(dest_addr, GetPointerFromVMA(current_vaddr), copy_amount); break; @@ -606,7 +609,8 @@ void CopyBlock(VAddr dest_addr, VAddr src_addr, const size_t size) { case PageType::RasterizerCachedSpecial: { DEBUG_ASSERT(GetMMIOHandler(current_vaddr)); - RasterizerFlushRegion(VirtualToPhysicalAddress(current_vaddr), copy_amount); + RasterizerFlushRegion(VirtualToPhysicalAddress(current_vaddr), + static_cast(copy_amount)); std::vector buffer(copy_amount); GetMMIOHandler(current_vaddr)->ReadBlock(current_vaddr, buffer.data(), buffer.size()); @@ -619,8 +623,8 @@ void CopyBlock(VAddr dest_addr, VAddr src_addr, const size_t size) { page_index++; page_offset = 0; - dest_addr += copy_amount; - src_addr += copy_amount; + dest_addr += static_cast(copy_amount); + src_addr += static_cast(copy_amount); remaining_size -= copy_amount; } }