diff options
author | Benjamin Nash <benash@umich.edu> | 2005-06-29 11:17:12 -0400 |
---|---|---|
committer | Benjamin Nash <benash@umich.edu> | 2005-06-29 11:17:12 -0400 |
commit | eaeb1b6ff084b4797a31908fa5fb1d688c55dd60 (patch) | |
tree | 7a8e4d4bcd25f2f51c1020fedeff0f47449fd0c9 /sim/system.cc | |
parent | bc76a807af2a2a874be461f0c6be9a6c5ec8bfad (diff) | |
parent | 8a0bc840221cf7af4845f4ee44de11bc7271ff10 (diff) | |
download | gem5-eaeb1b6ff084b4797a31908fa5fb1d688c55dd60.tar.xz |
Merge m5read@m5.eecs.umich.edu:/bk/m5
into zed.eecs.umich.edu:/z/benash/bk/m5
--HG--
extra : convert_revision : a27bb3737d8a7d5c1fadf27f4cb5018d0b6054da
Diffstat (limited to 'sim/system.cc')
-rw-r--r-- | sim/system.cc | 43 |
1 files changed, 28 insertions, 15 deletions
diff --git a/sim/system.cc b/sim/system.cc index 8397b8e01..6f7d53f6b 100644 --- a/sim/system.cc +++ b/sim/system.cc @@ -46,7 +46,7 @@ int System::numSystemsRunning = 0; System::System(Params *p) : SimObject(p->name), memctrl(p->memctrl), physmem(p->physmem), - init_param(p->init_param), params(p) + init_param(p->init_param), numcpus(0), params(p) { // add self to global system list systemList.push_back(this); @@ -204,13 +204,26 @@ System::breakpoint() } int -System::registerExecContext(ExecContext *xc) +System::registerExecContext(ExecContext *xc, int id) { - int xcIndex = execContexts.size(); - execContexts.push_back(xc); + if (id == -1) { + for (id = 0; id < execContexts.size(); id++) { + if (!execContexts[id]) + break; + } + } + + if (execContexts.size() <= id) + execContexts.resize(id + 1); + + if (execContexts[id]) + panic("Cannot have two CPUs with the same id (%d)\n", id); + + execContexts[id] = xc; + numcpus++; RemoteGDB *rgdb = new RemoteGDB(this, xc); - GDBListener *gdbl = new GDBListener(rgdb, 7000 + xcIndex); + GDBListener *gdbl = new GDBListener(rgdb, 7000 + id); gdbl->listen(); /** * Uncommenting this line waits for a remote debugger to connect @@ -218,13 +231,13 @@ System::registerExecContext(ExecContext *xc) */ //gdbl->accept(); - if (remoteGDB.size() <= xcIndex) { - remoteGDB.resize(xcIndex+1); + if (remoteGDB.size() <= id) { + remoteGDB.resize(id + 1); } - remoteGDB[xcIndex] = rgdb; + remoteGDB[id] = rgdb; - return xcIndex; + return id; } void @@ -238,15 +251,15 @@ System::startup() } void -System::replaceExecContext(ExecContext *xc, int xcIndex) +System::replaceExecContext(ExecContext *xc, int id) { - if (xcIndex >= execContexts.size()) { - panic("replaceExecContext: bad xcIndex, %d >= %d\n", - xcIndex, execContexts.size()); + if (id >= execContexts.size()) { + panic("replaceExecContext: bad id, %d >= %d\n", + id, execContexts.size()); } - execContexts[xcIndex] = xc; - remoteGDB[xcIndex]->replaceExecContext(xc); + execContexts[id] = xc; + remoteGDB[id]->replaceExecContext(xc); } void |