summaryrefslogtreecommitdiff
path: root/src/sim/process.cc
diff options
context:
space:
mode:
authorAndreas Hansson <andreas.hansson@arm.com>2012-02-24 11:45:30 -0500
committerAndreas Hansson <andreas.hansson@arm.com>2012-02-24 11:45:30 -0500
commit9e3c8de30bafe33f35e4b9e82fb49418941f8cb7 (patch)
tree016c65f8060c49b31d3fd3c064b97ae09279d689 /src/sim/process.cc
parent1031b824b975cec999c37cabc8c05c485a4ae5ca (diff)
downloadgem5-9e3c8de30bafe33f35e4b9e82fb49418941f8cb7.tar.xz
MEM: Make port proxies use references rather than pointers
This patch is adding a clearer design intent to all objects that would not be complete without a port proxy by making the proxies members rathen than dynamically allocated. In essence, if NULL would not be a valid value for the proxy, then we avoid using a pointer to make this clear. The same approach is used for the methods using these proxies, such as loadSections, that now use references rather than pointers to better reflect the fact that NULL would not be an acceptable value (in fact the code would break and that is how this patch started out). Overall the concept of "using a reference to express unconditional composition where a NULL pointer is never valid" could be done on a much broader scale throughout the code base, but for now it is only done in the locations affected by the proxies.
Diffstat (limited to 'src/sim/process.cc')
-rw-r--r--src/sim/process.cc24
1 files changed, 17 insertions, 7 deletions
diff --git a/src/sim/process.cc b/src/sim/process.cc
index 8f3b3be79..39b2d0777 100644
--- a/src/sim/process.cc
+++ b/src/sim/process.cc
@@ -1,4 +1,16 @@
/*
+ * Copyright (c) 2012 ARM Limited
+ * All rights reserved
+ *
+ * The license below extends only to copyright in the software and shall
+ * not be construed as granting a license to any other intellectual
+ * property including but not limited to intellectual property relating
+ * to a hardware implementation of the functionality of the software
+ * licensed hereunder. You may use the software subject to the license
+ * terms below provided that you ensure that this notice is replicated
+ * unmodified and in its entirety in all distributions of the software,
+ * modified or unmodified, in source code or in binary form.
+ *
* Copyright (c) 2001-2005 The Regents of The University of Michigan
* All rights reserved.
*
@@ -43,7 +55,6 @@
#include "config/the_isa.hh"
#include "cpu/thread_context.hh"
#include "mem/page_table.hh"
-#include "mem/physical.hh"
#include "mem/se_translating_port_proxy.hh"
#include "params/LiveProcess.hh"
#include "params/Process.hh"
@@ -91,7 +102,11 @@ template struct AuxVector<uint64_t>;
Process::Process(ProcessParams * params)
: SimObject(params), system(params->system),
- max_stack_size(params->max_stack_size)
+ max_stack_size(params->max_stack_size),
+ M5_pid(system->allocatePID()),
+ pTable(new PageTable(name(), M5_pid)),
+ initVirtMem(system->getSystemPort(), this,
+ SETranslatingPortProxy::Always)
{
string in = params->input;
string out = params->output;
@@ -127,7 +142,6 @@ Process::Process(ProcessParams * params)
else
stderr_fd = Process::openOutputFile(err);
- M5_pid = system->allocatePID();
// initialize first 3 fds (stdin, stdout, stderr)
Process::FdMap *fdo = &fd_map[STDIN_FILENO];
fdo->fd = stdin_fd;
@@ -159,7 +173,6 @@ Process::Process(ProcessParams * params)
mmap_start = mmap_end = 0;
nxm_start = nxm_end = 0;
- pTable = new PageTable(name(), M5_pid);
// other parameters will be initialized when the program is loaded
}
@@ -233,9 +246,6 @@ Process::initState()
// mark this context as active so it will start ticking.
tc->activate(0);
-
- initVirtMem = new SETranslatingPortProxy(*system->getSystemPort(), this,
- SETranslatingPortProxy::Always);
}
// map simulator fd sim_fd to target fd tgt_fd