1/*
2 * Copyright (c) 2002-2005 The Regents of The University of Michigan
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;

--- 10 unchanged lines hidden (view full) ---

19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 *
28 * Authors: Steve Reinhardt
29 * Nathan Binkert
30 */
31
32#include <iostream>
33#include <string>
34#include <sstream>
35
36#include "base/cprintf.hh"
37#include "base/loader/symtab.hh"

--- 6 unchanged lines hidden (view full) ---

44#include "cpu/sampler/sampler.hh"
45#include "sim/param.hh"
46#include "sim/process.hh"
47#include "sim/sim_events.hh"
48#include "sim/system.hh"
49
50#include "base/trace.hh"
51
52#if FULL_SYSTEM
53#include "kern/kernel_stats.hh"
54#endif
55
56using namespace std;
57
58vector<BaseCPU *> BaseCPU::cpuList;
59
60// This variable reflects the max number of threads in any CPU. Be
61// careful to only use it once all the CPUs that you care about have
62// been initialized
63int maxThreadsPerCPU = 1;

--- 88 unchanged lines hidden (view full) ---

152 true);
153 e->schedule(p->functionTraceStart);
154 }
155 }
156#if FULL_SYSTEM
157 profileEvent = NULL;
158 if (params->profile)
159 profileEvent = new ProfileEvent(this, params->profile);
160
161 kernelStats = new Kernel::Statistics(system);
162#endif
163
164}
165
166BaseCPU::Params::Params()
167{
168#if FULL_SYSTEM
169 profile = false;
170#endif
162 checker = NULL;
171}
172
173void
174BaseCPU::enableFunctionTrace()
175{
176 functionTracingEnabled = true;
177}
178
179BaseCPU::~BaseCPU()
180{
181#if FULL_SYSTEM
182 if (kernelStats)
183 delete kernelStats;
184#endif
185}
186
187void
188BaseCPU::init()
189{
190 if (!params->deferRegistration)
191 registerExecContexts();
192}

--- 24 unchanged lines hidden (view full) ---

217 stringstream namestr;
218 ccprintf(namestr, "%s.ctx%d", name(), i);
219 execContexts[i]->regStats(namestr.str());
220 }
221 } else if (size == 1)
222 execContexts[0]->regStats(name());
223
224#if FULL_SYSTEM
225 if (kernelStats)
226 kernelStats->regStats(name() + ".kern");
227#endif
228}
229
230
231void
232BaseCPU::registerExecContexts()
233{
234 for (int i = 0; i < execContexts.size(); ++i) {
235 ExecContext *xc = execContexts[i];
236
237#if FULL_SYSTEM
238 int id = params->cpu_id;
239 if (id != -1)
240 id += i;
241
242 xc->setCpuId(system->registerExecContext(xc, id));
243#else
244 xc->setCpuId(xc->getProcessPtr()->registerExecContext(xc));
245#endif
232 }
246 }
247}
248
249
250void
251BaseCPU::switchOut(Sampler *sampler)
252{
253 panic("This CPU doesn't support sampling!");

--- 93 unchanged lines hidden (view full) ---

347}
348
349
350void
351BaseCPU::serialize(std::ostream &os)
352{
353 SERIALIZE_ARRAY(interrupts, TheISA::NumInterruptLevels);
354 SERIALIZE_SCALAR(intstatus);
355
356#if FULL_SYSTEM
357 if (kernelStats)
358 kernelStats->serialize(os);
359#endif
360
361}
362
363void
364BaseCPU::unserialize(Checkpoint *cp, const std::string &section)
365{
366 UNSERIALIZE_ARRAY(interrupts, TheISA::NumInterruptLevels);
367 UNSERIALIZE_SCALAR(intstatus);
368
369#if FULL_SYSTEM
370 if (kernelStats)
371 kernelStats->unserialize(cp, section);
372#endif
373}
374
375#endif // FULL_SYSTEM
376
377void
378BaseCPU::traceFunctionsInternal(Addr pc)
379{
380 if (!debugSymbolTable)

--- 25 unchanged lines hidden ---