summaryrefslogtreecommitdiff
path: root/src/sim/process.cc
diff options
context:
space:
mode:
authorSteve Reinhardt <steve.reinhardt@amd.com>2011-10-22 22:30:08 -0700
committerSteve Reinhardt <steve.reinhardt@amd.com>2011-10-22 22:30:08 -0700
commit6f9d294e8685f49d91af48065736ac1d67e53718 (patch)
tree1481f450d43324b79da17c80f27bdb1946b7c232 /src/sim/process.cc
parent4d5f2c28a88f83d390e80407f55a8a02ead33878 (diff)
downloadgem5-6f9d294e8685f49d91af48065736ac1d67e53718.tar.xz
SE: move page allocation from PageTable to Process
PageTable supported an allocate() call that called back through the Process to allocate memory, but did not have a method to map addresses without allocating new pages. It makes more sense for Process to do the allocation, so this method was renamed allocateMem() and moved to Process, and uses a new map() call on PageTable. The remaining uses of the process pointer in PageTable were only to get the name and the PID, so by passing these in directly in the constructor, we can make PageTable completely independent of Process.
Diffstat (limited to 'src/sim/process.cc')
-rw-r--r--src/sim/process.cc14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/sim/process.cc b/src/sim/process.cc
index 62b9b7002..ba106fb63 100644
--- a/src/sim/process.cc
+++ b/src/sim/process.cc
@@ -169,7 +169,7 @@ Process::Process(ProcessParams * params)
mmap_start = mmap_end = 0;
nxm_start = nxm_end = 0;
- pTable = new PageTable(this);
+ pTable = new PageTable(name(), M5_pid);
// other parameters will be initialized when the program is loaded
}
@@ -328,13 +328,21 @@ Process::sim_fd_obj(int tgt_fd)
return &fd_map[tgt_fd];
}
+void
+Process::allocateMem(Addr vaddr, int64_t size, bool clobber)
+{
+ int npages = divCeil(size, (int64_t)VMPageSize);
+ Addr paddr = system->allocPhysPages(npages);
+ pTable->map(vaddr, paddr, size, clobber);
+}
+
bool
Process::fixupStackFault(Addr vaddr)
{
// Check if this is already on the stack and there's just no page there
// yet.
if (vaddr >= stack_min && vaddr < stack_base) {
- pTable->allocate(roundDown(vaddr, VMPageSize), VMPageSize);
+ allocateMem(roundDown(vaddr, VMPageSize), VMPageSize);
return true;
}
@@ -347,7 +355,7 @@ Process::fixupStackFault(Addr vaddr)
fatal("Maximum stack size exceeded\n");
if (stack_base - stack_min > 8 * 1024 * 1024)
fatal("Over max stack size for one thread\n");
- pTable->allocate(stack_min, TheISA::PageBytes);
+ allocateMem(stack_min, TheISA::PageBytes);
inform("Increasing stack size by one page.");
};
return true;