diff options
author | Steve Reinhardt <stever@eecs.umich.edu> | 2003-10-23 19:07:52 -0700 |
---|---|---|
committer | Steve Reinhardt <stever@eecs.umich.edu> | 2003-10-23 19:07:52 -0700 |
commit | f5da73b6881991a28844ed59e8dcc1d154ddae7e (patch) | |
tree | bc89728af5db24ef0bf1580045c3bcd26a206e85 /cpu/base_cpu.cc | |
parent | 73b050a541b1778596f9ebffa8a9f780446365c3 (diff) | |
download | gem5-f5da73b6881991a28844ed59e8dcc1d154ddae7e.tar.xz |
Initial support for CPU switching. New SamplingCPU object encompasses a set
of CPUs that get switched round-robin (though currently we're only shooting for
two CPUs and one switch event, and even that doesn't quite work yet). Registration
of ExecContexts with System/Process object factored out so we can create two CPUs
but only register one of them at a time. Also worked at making behavior and naming
in System and Process objects more consistent.
arch/alpha/ev5.cc:
Rename ipr_init to initIPRs and get rid of unused mem arg.
arch/alpha/fake_syscall.cc:
Process:numCpus is now a function (not a data member).
base/remote_gdb.hh:
Support for ExecContext switching.
cpu/base_cpu.cc:
cpu/base_cpu.hh:
cpu/exec_context.cc:
cpu/exec_context.hh:
cpu/simple_cpu/simple_cpu.hh:
Support for ExecContext switching.
Renamed contexts array to execContexts to be consistent with Process.
CPU ID now auto-assigned by system object.
cpu/simple_cpu/simple_cpu.cc:
Support for ExecContext switching.
Renamed contexts array to execContexts to be consistent with Process.
CPU ID now auto-assigned by system object.
Cleaned up MP full-system initialization a bit.
dev/alpha_console.cc:
Renamed xcvec array to execContexts to be consistent with Process.
kern/tru64/tru64_system.cc:
kern/tru64/tru64_system.hh:
Support for ExecContext switching.
CPU ID now auto-assigned by system object.
sim/prog.cc:
sim/prog.hh:
Support for ExecContext switching.
Process:numCpus is now a function (not a data member).
sim/system.cc:
sim/system.hh:
Support for ExecContext switching.
Renamed xcvec array to execContexts to be consistent with Process.
--HG--
extra : convert_revision : 79649cffad5bf3e83de8df44236941907926d791
Diffstat (limited to 'cpu/base_cpu.cc')
-rw-r--r-- | cpu/base_cpu.cc | 64 |
1 files changed, 58 insertions, 6 deletions
diff --git a/cpu/base_cpu.cc b/cpu/base_cpu.cc index 90e090d5e..74d2ceada 100644 --- a/cpu/base_cpu.cc +++ b/cpu/base_cpu.cc @@ -52,8 +52,8 @@ BaseCPU::BaseCPU(const string &_name, int _number_of_threads, Counter max_insts_all_threads, Counter max_loads_any_thread, Counter max_loads_all_threads, - System *_system, int num, Tick freq) - : SimObject(_name), number(num), frequency(freq), + System *_system, Tick freq) + : SimObject(_name), frequency(freq), number_of_threads(_number_of_threads), system(_system) #else BaseCPU::BaseCPU(const string &_name, int _number_of_threads, @@ -120,27 +120,73 @@ BaseCPU::BaseCPU(const string &_name, int _number_of_threads, max_loads_all_threads, *counter); } - #ifdef FULL_SYSTEM memset(interrupts, 0, sizeof(interrupts)); intstatus = 0; #endif } + void BaseCPU::regStats() { - int size = contexts.size(); + int size = execContexts.size(); if (size > 1) { for (int i = 0; i < size; ++i) { stringstream namestr; ccprintf(namestr, "%s.ctx%d", name(), i); - contexts[i]->regStats(namestr.str()); + execContexts[i]->regStats(namestr.str()); } } else if (size == 1) - contexts[0]->regStats(name()); + execContexts[0]->regStats(name()); +} + + +void +BaseCPU::registerExecContexts() +{ + for (int i = 0; i < execContexts.size(); ++i) { + ExecContext *xc = execContexts[i]; + int cpu_id; + +#ifdef FULL_SYSTEM + cpu_id = system->registerExecContext(xc); +#else + cpu_id = xc->process->registerExecContext(xc); +#endif + + xc->cpu_id = cpu_id; + } +} + + +void +BaseCPU::switchOut() +{ + // default: do nothing } +void +BaseCPU::takeOverFrom(BaseCPU *oldCPU) +{ + assert(execContexts.size() == oldCPU->execContexts.size()); + + for (int i = 0; i < execContexts.size(); ++i) { + ExecContext *newXC = execContexts[i]; + ExecContext *oldXC = oldCPU->execContexts[i]; + + newXC->takeOverFrom(oldXC); + assert(newXC->cpu_id == oldXC->cpu_id); +#ifdef FULL_SYSTEM + system->replaceExecContext(newXC->cpu_id, newXC); +#else + assert(newXC->process == oldXC->process); + newXC->process->replaceExecContext(newXC->cpu_id, newXC); +#endif + } +} + + #ifdef FULL_SYSTEM void BaseCPU::post_interrupt(int int_num, int index) @@ -185,4 +231,10 @@ BaseCPU::clear_interrupts() #endif // FULL_SYSTEM +// +// This declaration is not needed now that SamplingCPU provides a +// BaseCPUBuilder object. +// +#if 0 DEFINE_SIM_OBJECT_CLASS_NAME("BaseCPU", BaseCPU) +#endif |