diff options
author | Nathan Binkert <binkertn@umich.edu> | 2005-06-29 01:20:41 -0400 |
---|---|---|
committer | Nathan Binkert <binkertn@umich.edu> | 2005-06-29 01:20:41 -0400 |
commit | 8a0bc840221cf7af4845f4ee44de11bc7271ff10 (patch) | |
tree | 96800ff9b98a6bc32bdb5a443974bb8c2994ebc4 /sim | |
parent | 036a8ceb8da8aff10b819b4aab32584d41282a64 (diff) | |
download | gem5-8a0bc840221cf7af4845f4ee44de11bc7271ff10.tar.xz |
Allow CPUs to specify their own CPU ids.
Make the AlphaConsole calculate the number of CPUs instead
of passing that in as a parameter.
cpu/base.cc:
pass the desired cpu_id into registerExecContext, offsetting it
by the thread number. a cpu_id of -1 means that it should be
generated for you.
cpu/base.hh:
Take the cpu_id as a parameter
cpu/o3/alpha_cpu_builder.cc:
cpu/simple/cpu.cc:
Accept the cpu_id as a parameter
while we're here, let's remove the multiplier since it is
not used.
dev/alpha_console.cc:
don't take the number of CPUs as a parameter. Calculate it from
the system based on the number of CPUs that have been registered.
move init() code to startup() to ensure that all CPUs are registerd.
dev/alpha_console.hh:
python/m5/objects/AlphaConsole.py:
don't take the number of CPUs as a parameter.
move init() code to startup() to ensure that all CPUs are registerd.
python/m5/objects/BaseCPU.py:
take the cpu_id as a parameter. Default it to -1 which means
that it will be generated.
sim/system.cc:
allow the registerExecContext functioin to take a desired
cpu_id as a parameter. Check to ensure that the id isn't
already used. Accept -1 as a request to have an id assigned.
sim/system.hh:
keep track of the number of registered exec contexts.
provide a function for accessing the number of exec contexts
that checks to ensure that they are all registered correctly.
--HG--
extra : convert_revision : 8e12f96ff8a49fa16cdbbdb4c05c651376c35788
Diffstat (limited to 'sim')
-rw-r--r-- | sim/system.cc | 43 | ||||
-rw-r--r-- | sim/system.hh | 11 |
2 files changed, 38 insertions, 16 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 diff --git a/sim/system.hh b/sim/system.hh index ab6d264ea..870805e4c 100644 --- a/sim/system.hh +++ b/sim/system.hh @@ -58,6 +58,15 @@ class System : public SimObject uint64_t init_param; std::vector<ExecContext *> execContexts; + int numcpus; + + int getNumCPUs() + { + if (numcpus != execContexts.size()) + panic("cpu array not fully populated!"); + + return numcpus; + } /** kernel Symbol table */ SymbolTable *kernelSymtab; @@ -150,7 +159,7 @@ class System : public SimObject */ Addr getKernelEntry() const { return kernelEntry; } - int registerExecContext(ExecContext *xc); + int registerExecContext(ExecContext *xc, int xcIndex); void replaceExecContext(ExecContext *xc, int xcIndex); void regStats(); |