From 1c9612b79155de9538d4b71ff71938786adcea11 Mon Sep 17 00:00:00 2001 From: wwylele Date: Fri, 15 Jul 2016 09:17:01 +0300 Subject: LDR: Implement CRO --- src/core/hle/service/ldr_ro/memory_synchronizer.h | 44 +++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 src/core/hle/service/ldr_ro/memory_synchronizer.h (limited to 'src/core/hle/service/ldr_ro/memory_synchronizer.h') diff --git a/src/core/hle/service/ldr_ro/memory_synchronizer.h b/src/core/hle/service/ldr_ro/memory_synchronizer.h new file mode 100644 index 000000000..92f267912 --- /dev/null +++ b/src/core/hle/service/ldr_ro/memory_synchronizer.h @@ -0,0 +1,44 @@ +// Copyright 2016 Citra Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#pragma once + +#include + +#include "core/memory.h" + +//////////////////////////////////////////////////////////////////////////////////////////////////// +// Namespace LDR_RO + +namespace LDR_RO { + +/** + * This is a work-around before we implement memory aliasing. + * CRS and CRO are mapped (aliased) to another memory when loading. Games can read + * from both the original buffer and the mapping memory. So we use this to synchronize + * all original buffers with mapping memory after modifying the content. + */ +class MemorySynchronizer { +public: + void Clear(); + + void AddMemoryBlock(VAddr mapping, VAddr original, u32 size); + void ResizeMemoryBlock(VAddr mapping, VAddr original, u32 size); + void RemoveMemoryBlock(VAddr mapping, VAddr original); + + void SynchronizeOriginalMemory(); + +private: + struct MemoryBlock { + VAddr mapping; + VAddr original; + u32 size; + }; + + std::vector memory_blocks; + + auto FindMemoryBlock(VAddr mapping, VAddr original); +}; + +} // namespace -- cgit v1.2.3