summaryrefslogtreecommitdiff
path: root/src/core/memory.cpp
diff options
context:
space:
mode:
authorGravatar Lioncash2018-09-24 20:01:45 -0400
committerGravatar Lioncash2018-09-24 22:16:03 -0400
commit83377113bfe7791483a1b67e06dd0f51620c04ec (patch)
treed766a2d2f20d247e8663c1a76d5c41fcf7f643d4 /src/core/memory.cpp
parentsvc: Report correct memory-related values within some of the cases in svcGetI... (diff)
downloadyuzu-83377113bfe7791483a1b67e06dd0f51620c04ec.tar.gz
yuzu-83377113bfe7791483a1b67e06dd0f51620c04ec.tar.xz
yuzu-83377113bfe7791483a1b67e06dd0f51620c04ec.zip
memory: Dehardcode the use of fixed memory range constants
The locations of these can actually vary depending on the address space layout, so we shouldn't be using these when determining where to map memory or be using them as offsets for calculations. This keeps all the memory ranges flexible and malleable based off of the virtual memory manager instance state.
Diffstat (limited to 'src/core/memory.cpp')
-rw-r--r--src/core/memory.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/core/memory.cpp b/src/core/memory.cpp
index 674ef0829..6430daad4 100644
--- a/src/core/memory.cpp
+++ b/src/core/memory.cpp
@@ -14,11 +14,11 @@
14#include "core/arm/arm_interface.h" 14#include "core/arm/arm_interface.h"
15#include "core/core.h" 15#include "core/core.h"
16#include "core/hle/kernel/process.h" 16#include "core/hle/kernel/process.h"
17#include "core/hle/kernel/vm_manager.h"
17#include "core/hle/lock.h" 18#include "core/hle/lock.h"
18#include "core/memory.h" 19#include "core/memory.h"
19#include "core/memory_setup.h" 20#include "core/memory_setup.h"
20#include "video_core/renderer_base.h" 21#include "video_core/renderer_base.h"
21#include "video_core/video_core.h"
22 22
23namespace Memory { 23namespace Memory {
24 24
@@ -337,7 +337,7 @@ void RasterizerFlushVirtualRegion(VAddr start, u64 size, FlushMode mode) {
337 return; 337 return;
338 } 338 }
339 339
340 VAddr end = start + size; 340 const VAddr end = start + size;
341 341
342 const auto CheckRegion = [&](VAddr region_start, VAddr region_end) { 342 const auto CheckRegion = [&](VAddr region_start, VAddr region_end) {
343 if (start >= region_end || end <= region_start) { 343 if (start >= region_end || end <= region_start) {
@@ -347,7 +347,7 @@ void RasterizerFlushVirtualRegion(VAddr start, u64 size, FlushMode mode) {
347 347
348 const VAddr overlap_start = std::max(start, region_start); 348 const VAddr overlap_start = std::max(start, region_start);
349 const VAddr overlap_end = std::min(end, region_end); 349 const VAddr overlap_end = std::min(end, region_end);
350 const u64 overlap_size = overlap_end - overlap_start; 350 const VAddr overlap_size = overlap_end - overlap_start;
351 351
352 auto& rasterizer = system_instance.Renderer().Rasterizer(); 352 auto& rasterizer = system_instance.Renderer().Rasterizer();
353 switch (mode) { 353 switch (mode) {
@@ -363,8 +363,10 @@ void RasterizerFlushVirtualRegion(VAddr start, u64 size, FlushMode mode) {
363 } 363 }
364 }; 364 };
365 365
366 CheckRegion(PROCESS_IMAGE_VADDR, PROCESS_IMAGE_VADDR_END); 366 const auto& vm_manager = Core::CurrentProcess()->vm_manager;
367 CheckRegion(HEAP_VADDR, HEAP_VADDR_END); 367
368 CheckRegion(vm_manager.GetCodeRegionBaseAddress(), vm_manager.GetCodeRegionEndAddress());
369 CheckRegion(vm_manager.GetHeapRegionBaseAddress(), vm_manager.GetHeapRegionEndAddress());
368} 370}
369 371
370u8 Read8(const VAddr addr) { 372u8 Read8(const VAddr addr) {