summaryrefslogtreecommitdiff
path: root/sim
diff options
context:
space:
mode:
authorSteve Reinhardt <stever@eecs.umich.edu>2003-10-23 19:09:18 -0700
committerSteve Reinhardt <stever@eecs.umich.edu>2003-10-23 19:09:18 -0700
commitcc9a838f4c5a5bf5e8951bdb351fc7d4b74661fb (patch)
tree1bae8b1b09fcc39d04631c84beaf51f830938372 /sim
parent320540829d62f9c5a5290a8c9bd991fda297a210 (diff)
parent6e2fc8ce766d1f9cb601b4a2a15d1ba294ce97a5 (diff)
downloadgem5-cc9a838f4c5a5bf5e8951bdb351fc7d4b74661fb.tar.xz
Merge stever@zizzer:/bk/m5 into isabel.reinhardt.house:/z/stever/bk/m5
--HG-- extra : convert_revision : b0f93bd35d767fd3a520a9fed70a71d40b0056db
Diffstat (limited to 'sim')
-rw-r--r--sim/prog.cc36
-rw-r--r--sim/prog.hh18
-rw-r--r--sim/system.cc20
-rw-r--r--sim/system.hh8
4 files changed, 52 insertions, 30 deletions
diff --git a/sim/prog.cc b/sim/prog.cc
index 275e1551b..599a0ca9a 100644
--- a/sim/prog.cc
+++ b/sim/prog.cc
@@ -85,8 +85,6 @@ Process::Process(const string &name,
fd_map[i] = -1;
}
- numCpus = 0;
-
num_syscalls = 0;
// other parameters will be initialized when the program is loaded
@@ -136,30 +134,42 @@ Process::openOutputFile(const string &filename)
}
-void
-Process::registerExecContext(ExecContext *ec)
+int
+Process::registerExecContext(ExecContext *xc)
{
- if (execContexts.empty()) {
+ // add to list
+ int myIndex = execContexts.size();
+ execContexts.push_back(xc);
+
+ if (myIndex == 0) {
// first exec context for this process... initialize & enable
// copy process's initial regs struct
- ec->regs = *init_regs;
+ xc->regs = *init_regs;
// mark this context as active
- ec->setStatus(ExecContext::Active);
+ xc->initStatus(ExecContext::Active);
}
else {
- ec->setStatus(ExecContext::Unallocated);
+ xc->initStatus(ExecContext::Unallocated);
}
- // add to list
- execContexts.push_back(ec);
-
- // increment available CPU count
- ++numCpus;
+ // return CPU number to caller and increment available CPU count
+ return myIndex;
}
+void
+Process::replaceExecContext(int xcIndex, ExecContext *xc)
+{
+ if (xcIndex >= execContexts.size()) {
+ panic("replaceExecContext: bad xcIndex, %d >= %d\n",
+ xcIndex, execContexts.size());
+ }
+
+ execContexts[xcIndex] = xc;
+}
+
// map simulator fd sim_fd to target fd tgt_fd
void
Process::dup_fd(int sim_fd, int tgt_fd)
diff --git a/sim/prog.hh b/sim/prog.hh
index ee4bc59fe..e93dd684c 100644
--- a/sim/prog.hh
+++ b/sim/prog.hh
@@ -36,7 +36,7 @@
//
#ifndef FULL_SYSTEM
-#include <list>
+#include <vector>
#include "targetarch/isa_traits.hh"
#include "sim/sim_object.hh"
@@ -55,10 +55,10 @@ class Process : public SimObject
bool initialContextLoaded;
// execution contexts associated with this process
- std::list<ExecContext *> execContexts;
- // number of CPUs assigned to this process: should match number of
- // contexts in execContexts list
- unsigned numCpus;
+ std::vector<ExecContext *> execContexts;
+
+ // number of CPUs (esxec contexts, really) assigned to this process.
+ unsigned int numCpus() { return execContexts.size(); }
// record of blocked context
struct WaitRec
@@ -123,8 +123,12 @@ class Process : public SimObject
// override of virtual SimObject method: register statistics
virtual void regStats();
- // register an execution context for this process
- void registerExecContext(ExecContext *);
+ // register an execution context for this process.
+ // returns xc's cpu number (index into execContexts[])
+ int registerExecContext(ExecContext *xc);
+
+
+ void replaceExecContext(int xcIndex, ExecContext *xc);
// map simulator fd sim_fd to target fd tgt_fd
void dup_fd(int sim_fd, int tgt_fd);
diff --git a/sim/system.cc b/sim/system.cc
index 903362f0b..af4a4c151 100644
--- a/sim/system.cc
+++ b/sim/system.cc
@@ -56,16 +56,24 @@ System::~System()
}
-void
+int
System::registerExecContext(ExecContext *xc)
{
- if (xc->cpu_id >= 12/*MAX_CPUS*/)
- panic("Too many CPU's\n");
+ int myIndex = execContexts.size();
+ execContexts.push_back(xc);
+ return myIndex;
+}
+
- if (xc->cpu_id >= xcvec.size())
- xcvec.resize(xc->cpu_id + 1);
+void
+System::replaceExecContext(int xcIndex, ExecContext *xc)
+{
+ if (xcIndex >= execContexts.size()) {
+ panic("replaceExecContext: bad xcIndex, %d >= %d\n",
+ xcIndex, execContexts.size());
+ }
- xcvec[xc->cpu_id] = xc;
+ execContexts[xcIndex] = xc;
}
diff --git a/sim/system.hh b/sim/system.hh
index f10b70a4e..081aa3eb7 100644
--- a/sim/system.hh
+++ b/sim/system.hh
@@ -52,16 +52,16 @@ class System : public SimObject
PCEventQueue pcEventQueue;
- std::vector<ExecContext *> xcvec;
- void registerExecContext(ExecContext *xc);
+ std::vector<ExecContext *> execContexts;
+
+ virtual int registerExecContext(ExecContext *xc);
+ virtual void replaceExecContext(int xcIndex, ExecContext *xc);
public:
System(const std::string _name, const uint64_t _init_param,
MemoryController *, PhysicalMemory *);
~System();
- virtual void init(ExecContext *xc) = 0;
-
virtual Addr getKernelStart() const = 0;
virtual Addr getKernelEnd() const = 0;
virtual Addr getKernelEntry() const = 0;