Deleted Added
sdiff udiff text old ( 8737:770ccf3af571 ) new ( 8745:575cab0db076 )
full compact
1/*
2 * Copyright (c) 2002-2005 The Regents of The University of Michigan
3 * Copyright (c) 2011 Regents of the University of California
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are
8 * met: redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer;

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

36#include <string>
37
38#include "arch/tlb.hh"
39#include "base/loader/symtab.hh"
40#include "base/cprintf.hh"
41#include "base/misc.hh"
42#include "base/output.hh"
43#include "base/trace.hh"
44#include "cpu/base.hh"
45#include "cpu/cpuevent.hh"
46#include "cpu/profile.hh"
47#include "cpu/thread_context.hh"
48#include "debug/SyscallVerbose.hh"
49#include "params/BaseCPU.hh"
50#include "sim/process.hh"
51#include "sim/sim_events.hh"
52#include "sim/sim_exit.hh"
53#include "sim/system.hh"
54
55// Hack
56#include "sim/stat_control.hh"
57
58using namespace std;
59
60vector<BaseCPU *> BaseCPU::cpuList;
61
62// This variable reflects the max number of threads in any CPU. Be

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

95}
96
97const char *
98CPUProgressEvent::description() const
99{
100 return "CPU Progress";
101}
102
103BaseCPU::BaseCPU(Params *p)
104 : MemObject(p), clock(p->clock), instCnt(0), _cpuId(p->cpu_id),
105 interrupts(p->interrupts),
106 numThreads(p->numThreads), system(p->system),
107 phase(p->phase)
108{
109// currentTick = curTick();
110
111 // if Python did not provide a valid ID, do it here
112 if (_cpuId == -1 ) {
113 _cpuId = cpuList.size();
114 }
115

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

178 for (ThreadID tid = 0; tid < numThreads; ++tid) {
179 Event *event = new CountedExitEvent(cause, *counter);
180 comLoadEventQueue[tid]->schedule(event, p->max_loads_all_threads);
181 }
182 }
183
184 functionTracingEnabled = false;
185 if (p->function_trace) {
186 functionTraceStream = simout.find(csprintf("ftrace.%s", name()));
187 currentFunctionStart = currentFunctionEnd = 0;
188 functionEntryTick = p->function_trace_start;
189
190 if (p->function_trace_start == 0) {
191 functionTracingEnabled = true;
192 } else {
193 typedef EventWrapper<BaseCPU, &BaseCPU::enableFunctionTrace> wrap;
194 Event *event = new wrap(this, true);
195 schedule(event, p->function_trace_start);
196 }
197 }
198 interrupts->setCPU(this);
199
200#if FULL_SYSTEM
201 profileEvent = NULL;
202 if (params()->profile)
203 profileEvent = new ProfileEvent(this, params()->profile);
204#endif
205 tracer = params()->tracer;
206}
207
208void

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

228#if FULL_SYSTEM
229 if (!params()->defer_registration && profileEvent)
230 schedule(profileEvent, curTick());
231#endif
232
233 if (params()->progress_interval) {
234 Tick num_ticks = ticks(params()->progress_interval);
235
236 Event *event;
237 event = new CPUProgressEvent(this, num_ticks);
238 }
239}
240
241
242void
243BaseCPU::regStats()
244{
245 using namespace Stats;

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

336// panic("This CPU doesn't support sampling!");
337#if FULL_SYSTEM
338 if (profileEvent && profileEvent->scheduled())
339 deschedule(profileEvent);
340#endif
341}
342
343void
344BaseCPU::takeOverFrom(BaseCPU *oldCPU, Port *ic, Port *dc)
345{
346 assert(threadContexts.size() == oldCPU->threadContexts.size());
347
348 _cpuId = oldCPU->cpuId();
349
350 ThreadID size = threadContexts.size();
351 for (ThreadID i = 0; i < size; ++i) {
352 ThreadContext *newTC = threadContexts[i];
353 ThreadContext *oldTC = oldCPU->threadContexts[i];

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

381 peer->setPeer(new_itb_port);
382 }
383 if (new_dtb_port && !new_dtb_port->isConnected()) {
384 assert(old_dtb_port);
385 Port *peer = old_dtb_port->getPeer();;
386 new_dtb_port->setPeer(peer);
387 peer->setPeer(new_dtb_port);
388 }
389 }
390
391 interrupts = oldCPU->interrupts;
392 interrupts->setCPU(this);
393
394#if FULL_SYSTEM
395 for (ThreadID i = 0; i < size; ++i)
396 threadContexts[i]->profileClear();
397
398 if (profileEvent)
399 schedule(profileEvent, curTick());
400#endif
401
402 // Connect new CPU to old CPU's memory only if new CPU isn't

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

428 for (ThreadID i = 0; i < size; ++i) {
429 ThreadContext *tc = cpu->threadContexts[i];
430 tc->profileSample();
431 }
432
433 cpu->schedule(this, curTick() + interval);
434}
435
436#endif // FULL_SYSTEM
437
438void
439BaseCPU::serialize(std::ostream &os)
440{
441 SERIALIZE_SCALAR(instCnt);
442 interrupts->serialize(os);
443}
444
445void
446BaseCPU::unserialize(Checkpoint *cp, const std::string &section)
447{
448 UNSERIALIZE_SCALAR(instCnt);
449 interrupts->unserialize(cp, section);
450}
451
452void
453BaseCPU::traceFunctionsInternal(Addr pc)
454{
455 if (!debugSymbolTable)
456 return;
457
458 // if pc enters different function, print new function symbol and
459 // update saved range. Otherwise do nothing.

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

470 currentFunctionEnd = pc + 1;
471 }
472
473 ccprintf(*functionTraceStream, " (%d)\n%d: %s",
474 curTick() - functionEntryTick, curTick(), sym_str);
475 functionEntryTick = curTick();
476 }
477}