aboutsummaryrefslogtreecommitdiff
path: root/src/core/memory.cpp
diff options
context:
space:
mode:
authorLioncash <mathew1800@gmail.com>2018-09-24 20:01:45 -0400
committerLioncash <mathew1800@gmail.com>2018-09-24 22:16:03 -0400
commit83377113bfe7791483a1b67e06dd0f51620c04ec (patch)
treed766a2d2f20d247e8663c1a76d5c41fcf7f643d4 /src/core/memory.cpp
parent6c6f95d071b25f2743fcb6652f4389c9e25a7506 (diff)
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 674ef08291..6430daad4b 100644
--- a/src/core/memory.cpp
+++ b/src/core/memory.cpp
@@ -14,11 +14,11 @@
#include "core/arm/arm_interface.h"
#include "core/core.h"
#include "core/hle/kernel/process.h"
+#include "core/hle/kernel/vm_manager.h"
#include "core/hle/lock.h"
#include "core/memory.h"
#include "core/memory_setup.h"
#include "video_core/renderer_base.h"
-#include "video_core/video_core.h"
namespace Memory {
@@ -337,7 +337,7 @@ void RasterizerFlushVirtualRegion(VAddr start, u64 size, FlushMode mode) {
return;
}
- VAddr end = start + size;
+ const VAddr end = start + size;
const auto CheckRegion = [&](VAddr region_start, VAddr region_end) {
if (start >= region_end || end <= region_start) {
@@ -347,7 +347,7 @@ void RasterizerFlushVirtualRegion(VAddr start, u64 size, FlushMode mode) {
const VAddr overlap_start = std::max(start, region_start);
const VAddr overlap_end = std::min(end, region_end);
- const u64 overlap_size = overlap_end - overlap_start;
+ const VAddr overlap_size = overlap_end - overlap_start;
auto& rasterizer = system_instance.Renderer().Rasterizer();
switch (mode) {
@@ -363,8 +363,10 @@ void RasterizerFlushVirtualRegion(VAddr start, u64 size, FlushMode mode) {
}
};
- CheckRegion(PROCESS_IMAGE_VADDR, PROCESS_IMAGE_VADDR_END);
- CheckRegion(HEAP_VADDR, HEAP_VADDR_END);
+ const auto& vm_manager = Core::CurrentProcess()->vm_manager;
+
+ CheckRegion(vm_manager.GetCodeRegionBaseAddress(), vm_manager.GetCodeRegionEndAddress());
+ CheckRegion(vm_manager.GetHeapRegionBaseAddress(), vm_manager.GetHeapRegionEndAddress());
}
u8 Read8(const VAddr addr) {