base.cc (5704:98224505352a) base.cc (5712:199d31b47f7b)
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;

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

89const char *
90CPUProgressEvent::description() const
91{
92 return "CPU Progress";
93}
94
95#if FULL_SYSTEM
96BaseCPU::BaseCPU(Params *p)
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;

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

89const char *
90CPUProgressEvent::description() const
91{
92 return "CPU Progress";
93}
94
95#if FULL_SYSTEM
96BaseCPU::BaseCPU(Params *p)
97 : MemObject(p), clock(p->clock), instCnt(0), interrupts(p->interrupts),
97 : MemObject(p), clock(p->clock), instCnt(0), _cpuId(p->cpu_id),
98 interrupts(p->interrupts),
98 number_of_threads(p->numThreads), system(p->system),
99 phase(p->phase)
100#else
101BaseCPU::BaseCPU(Params *p)
99 number_of_threads(p->numThreads), system(p->system),
100 phase(p->phase)
101#else
102BaseCPU::BaseCPU(Params *p)
102 : MemObject(p), clock(p->clock),
103 : MemObject(p), clock(p->clock), _cpuId(p->cpu_id),
103 number_of_threads(p->numThreads), system(p->system),
104 phase(p->phase)
105#endif
106{
107// currentTick = curTick;
108
104 number_of_threads(p->numThreads), system(p->system),
105 phase(p->phase)
106#endif
107{
108// currentTick = curTick;
109
110 // if Python did not provide a valid ID, do it here
111 if (_cpuId == -1 ) {
112 _cpuId = cpuList.size();
113 }
114
109 // add self to global list of CPUs
110 cpuList.push_back(this);
111
115 // add self to global list of CPUs
116 cpuList.push_back(this);
117
118 DPRINTF(SyscallVerbose, "Constructing CPU with id %d\n", _cpuId);
119
112 if (number_of_threads > maxThreadsPerCPU)
113 maxThreadsPerCPU = number_of_threads;
114
115 // allocate per-thread instruction-based event queues
116 comInstEventQueue = new EventQueue *[number_of_threads];
117 for (int i = 0; i < number_of_threads; ++i)
118 comInstEventQueue[i] = new EventQueue("instruction-based event queue");
119

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

273
274void
275BaseCPU::registerThreadContexts()
276{
277 for (int i = 0; i < threadContexts.size(); ++i) {
278 ThreadContext *tc = threadContexts[i];
279
280#if FULL_SYSTEM
120 if (number_of_threads > maxThreadsPerCPU)
121 maxThreadsPerCPU = number_of_threads;
122
123 // allocate per-thread instruction-based event queues
124 comInstEventQueue = new EventQueue *[number_of_threads];
125 for (int i = 0; i < number_of_threads; ++i)
126 comInstEventQueue[i] = new EventQueue("instruction-based event queue");
127

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

281
282void
283BaseCPU::registerThreadContexts()
284{
285 for (int i = 0; i < threadContexts.size(); ++i) {
286 ThreadContext *tc = threadContexts[i];
287
288#if FULL_SYSTEM
281 int id = params()->cpu_id;
282 if (id != -1)
283 id += i;
284
285 tc->setCpuId(system->registerThreadContext(tc, id));
289 system->registerThreadContext(tc);
286#else
290#else
287 tc->setCpuId(tc->getProcessPtr()->registerThreadContext(tc));
291 tc->getProcessPtr()->registerThreadContext(tc);
288#endif
289 }
290}
291
292
293int
294BaseCPU::findContext(ThreadContext *tc)
295{

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

310#endif
311}
312
313void
314BaseCPU::takeOverFrom(BaseCPU *oldCPU, Port *ic, Port *dc)
315{
316 assert(threadContexts.size() == oldCPU->threadContexts.size());
317
292#endif
293 }
294}
295
296
297int
298BaseCPU::findContext(ThreadContext *tc)
299{

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

314#endif
315}
316
317void
318BaseCPU::takeOverFrom(BaseCPU *oldCPU, Port *ic, Port *dc)
319{
320 assert(threadContexts.size() == oldCPU->threadContexts.size());
321
322 _cpuId = oldCPU->cpuId();
323
318 for (int i = 0; i < threadContexts.size(); ++i) {
319 ThreadContext *newTC = threadContexts[i];
320 ThreadContext *oldTC = oldCPU->threadContexts[i];
321
322 newTC->takeOverFrom(oldTC);
323
324 CpuEvent::replaceThreadContext(oldTC, newTC);
325
324 for (int i = 0; i < threadContexts.size(); ++i) {
325 ThreadContext *newTC = threadContexts[i];
326 ThreadContext *oldTC = oldCPU->threadContexts[i];
327
328 newTC->takeOverFrom(oldTC);
329
330 CpuEvent::replaceThreadContext(oldTC, newTC);
331
326 assert(newTC->readCpuId() == oldTC->readCpuId());
332 assert(newTC->cpuId() == oldTC->cpuId());
327#if FULL_SYSTEM
333#if FULL_SYSTEM
328 system->replaceThreadContext(newTC, newTC->readCpuId());
334 system->replaceThreadContext(newTC, newTC->cpuId());
329#else
330 assert(newTC->getProcessPtr() == oldTC->getProcessPtr());
335#else
336 assert(newTC->getProcessPtr() == oldTC->getProcessPtr());
331 newTC->getProcessPtr()->replaceThreadContext(newTC, newTC->readCpuId());
337 newTC->getProcessPtr()->replaceThreadContext(newTC, newTC->cpuId());
332#endif
333
334 if (DTRACE(Context))
335 ThreadContext::compare(oldTC, newTC);
336 }
337
338#if FULL_SYSTEM
339 interrupts = oldCPU->interrupts;

--- 101 unchanged lines hidden ---
338#endif
339
340 if (DTRACE(Context))
341 ThreadContext::compare(oldTC, newTC);
342 }
343
344#if FULL_SYSTEM
345 interrupts = oldCPU->interrupts;

--- 101 unchanged lines hidden ---