about summary refs log tree commit diff stats
path: root/subx/011run.cc
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2018-09-28 23:08:27 -0700
committerKartik Agaram <vc@akkartik.com>2018-09-29 10:20:13 -0700
commit630433cd9cb97cf71d24bfc8fab6fb54ce40382a (patch)
treecf4cffae8599489e5efcbc18b965f804d5e3a8e8 /subx/011run.cc
parentfd0cf1cd07ce01c3d6fe709d55b60ff9d1d5d44f (diff)
downloadmu-630433cd9cb97cf71d24bfc8fab6fb54ce40382a.tar.gz
4614 - redo simulated RAM
Now simulated 'Memory' isn't just a single flat array. Instead it knows
about segments and VMAs.

The code segment will always be first, and the data/heap segment will always
be second. The brk() syscall knows about the data segment.

One nice side-effect is that I no longer need to mess with Memory initialization
regardless of where I place my segments.
Diffstat (limited to 'subx/011run.cc')
-rw-r--r--subx/011run.cc2
1 files changed, 2 insertions, 0 deletions
diff --git a/subx/011run.cc b/subx/011run.cc
index d3963e3e..22eaad9d 100644
--- a/subx/011run.cc
+++ b/subx/011run.cc
@@ -224,6 +224,8 @@ void load(const program& p) {
   for (int i = 0;   i < SIZE(p.segments);  ++i) {
     const segment& seg = p.segments.at(i);
     uint32_t addr = seg.start;
+    if (!already_allocated(addr))
+      Mem.push_back(vma(seg.start));
     trace(99, "load") << "loading segment " << i << " from " << HEXWORD << addr << end();
     for (int j = 0;  j < SIZE(seg.lines);  ++j) {
       const line& l = seg.lines.at(j);