base.cc (2654:9559cfa91b9d) base.cc (2665:a124942bacb8)
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.
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
27 */
28
29#include <iostream>
30#include <string>
31#include <sstream>
32
33#include "base/cprintf.hh"
34#include "base/loader/symtab.hh"

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

41#include "cpu/sampler/sampler.hh"
42#include "sim/param.hh"
43#include "sim/process.hh"
44#include "sim/sim_events.hh"
45#include "sim/system.hh"
46
47#include "base/trace.hh"
48
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
49using namespace std;
50
51vector<BaseCPU *> BaseCPU::cpuList;
52
53// This variable reflects the max number of threads in any CPU. Be
54// careful to only use it once all the CPUs that you care about have
55// been initialized
56int maxThreadsPerCPU = 1;

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

145 true);
146 e->schedule(p->functionTraceStart);
147 }
148 }
149#if FULL_SYSTEM
150 profileEvent = NULL;
151 if (params->profile)
152 profileEvent = new ProfileEvent(this, params->profile);
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);
153#endif
154
155}
156
157BaseCPU::Params::Params()
158{
159#if FULL_SYSTEM
160 profile = false;
161#endif
162#endif
163
164}
165
166BaseCPU::Params::Params()
167{
168#if FULL_SYSTEM
169 profile = false;
170#endif
162 checker = NULL;
163}
164
165void
166BaseCPU::enableFunctionTrace()
167{
168 functionTracingEnabled = true;
169}
170
171BaseCPU::~BaseCPU()
172{
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
173}
174
175void
176BaseCPU::init()
177{
178 if (!params->deferRegistration)
179 registerExecContexts();
180}

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

205 stringstream namestr;
206 ccprintf(namestr, "%s.ctx%d", name(), i);
207 execContexts[i]->regStats(namestr.str());
208 }
209 } else if (size == 1)
210 execContexts[0]->regStats(name());
211
212#if FULL_SYSTEM
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");
213#endif
214}
215
216
217void
218BaseCPU::registerExecContexts()
219{
220 for (int i = 0; i < execContexts.size(); ++i) {
221 ExecContext *xc = execContexts[i];
222
223#if FULL_SYSTEM
224 int id = params->cpu_id;
225 if (id != -1)
226 id += i;
227
228 xc->setCpuId(system->registerExecContext(xc, id));
229#else
230 xc->setCpuId(xc->getProcessPtr()->registerExecContext(xc));
231#endif
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 }
233 }
234}
235
236
237void
238BaseCPU::switchOut(Sampler *sampler)
239{
240 panic("This CPU doesn't support sampling!");

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

334}
335
336
337void
338BaseCPU::serialize(std::ostream &os)
339{
340 SERIALIZE_ARRAY(interrupts, TheISA::NumInterruptLevels);
341 SERIALIZE_SCALAR(intstatus);
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
342}
343
344void
345BaseCPU::unserialize(Checkpoint *cp, const std::string &section)
346{
347 UNSERIALIZE_ARRAY(interrupts, TheISA::NumInterruptLevels);
348 UNSERIALIZE_SCALAR(intstatus);
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
349}
350
351#endif // FULL_SYSTEM
352
353void
354BaseCPU::traceFunctionsInternal(Addr pc)
355{
356 if (!debugSymbolTable)

--- 25 unchanged lines hidden ---
373}
374
375#endif // FULL_SYSTEM
376
377void
378BaseCPU::traceFunctionsInternal(Addr pc)
379{
380 if (!debugSymbolTable)

--- 25 unchanged lines hidden ---