diff options
author | Steve Reinhardt <stever@eecs.umich.edu> | 2003-10-23 19:09:18 -0700 |
---|---|---|
committer | Steve Reinhardt <stever@eecs.umich.edu> | 2003-10-23 19:09:18 -0700 |
commit | cc9a838f4c5a5bf5e8951bdb351fc7d4b74661fb (patch) | |
tree | 1bae8b1b09fcc39d04631c84beaf51f830938372 /cpu/base_cpu.cc | |
parent | 320540829d62f9c5a5290a8c9bd991fda297a210 (diff) | |
parent | 6e2fc8ce766d1f9cb601b4a2a15d1ba294ce97a5 (diff) | |
download | gem5-cc9a838f4c5a5bf5e8951bdb351fc7d4b74661fb.tar.xz |
Merge stever@zizzer:/bk/m5 into isabel.reinhardt.house:/z/stever/bk/m5
--HG--
extra : convert_revision : b0f93bd35d767fd3a520a9fed70a71d40b0056db
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 |