cpu.cc (13632:483aaa00c69c) cpu.cc (13966:3189413c5894)
1/*
2 * Copyright (c) 2012-2014, 2017 ARM Limited
3 * All rights reserved
4 *
5 * The license below extends only to copyright in the software and shall
6 * not be construed as granting a license to any other intellectual
7 * property including but not limited to intellectual property relating
8 * to a hardware implementation of the functionality of the software

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

44#include "cpu/minor/fetch1.hh"
45#include "cpu/minor/pipeline.hh"
46#include "debug/Drain.hh"
47#include "debug/MinorCPU.hh"
48#include "debug/Quiesce.hh"
49
50MinorCPU::MinorCPU(MinorCPUParams *params) :
51 BaseCPU(params),
1/*
2 * Copyright (c) 2012-2014, 2017 ARM Limited
3 * All rights reserved
4 *
5 * The license below extends only to copyright in the software and shall
6 * not be construed as granting a license to any other intellectual
7 * property including but not limited to intellectual property relating
8 * to a hardware implementation of the functionality of the software

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

44#include "cpu/minor/fetch1.hh"
45#include "cpu/minor/pipeline.hh"
46#include "debug/Drain.hh"
47#include "debug/MinorCPU.hh"
48#include "debug/Quiesce.hh"
49
50MinorCPU::MinorCPU(MinorCPUParams *params) :
51 BaseCPU(params),
52 pipelineStartupEvent([this]{ wakeupPipeline(); }, name()),
53 threadPolicy(params->threadPolicy)
54{
55 /* This is only written for one thread at the moment */
56 Minor::MinorThread *thread;
57
58 for (ThreadID i = 0; i < numThreads; i++) {
59 if (FullSystem) {
60 thread = new Minor::MinorThread(this, i, params->system,

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

275 DPRINTF(MinorCPU, "MinorCPU takeOverFrom\n");
276
277 BaseCPU::takeOverFrom(old_cpu);
278}
279
280void
281MinorCPU::activateContext(ThreadID thread_id)
282{
52 threadPolicy(params->threadPolicy)
53{
54 /* This is only written for one thread at the moment */
55 Minor::MinorThread *thread;
56
57 for (ThreadID i = 0; i < numThreads; i++) {
58 if (FullSystem) {
59 thread = new Minor::MinorThread(this, i, params->system,

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

274 DPRINTF(MinorCPU, "MinorCPU takeOverFrom\n");
275
276 BaseCPU::takeOverFrom(old_cpu);
277}
278
279void
280MinorCPU::activateContext(ThreadID thread_id)
281{
283 /* Remember to wake up this thread_id by scheduling the
284 * pipelineStartup event.
285 * We can't wakeupFetch the thread right away because its context may
286 * not have been fully initialized. For example, in the case of clone
287 * syscall, this activateContext function is called in the middle of
288 * the syscall and before the new thread context is initialized.
289 * If we start fetching right away, the new thread will fetch from an
290 * invalid address (i.e., pc is not initialized yet), which could lead
291 * to a page fault. Instead, we remember which threads to wake up and
292 * schedule an event to wake all them up after their contexts are
293 * fully initialized */
294 readyThreads.push_back(thread_id);
295 if (!pipelineStartupEvent.scheduled())
296 schedule(pipelineStartupEvent, clockEdge(Cycles(0)));
297}
282 DPRINTF(MinorCPU, "ActivateContext thread: %d\n", thread_id);
298
283
299void
300MinorCPU::wakeupPipeline()
301{
302 for (auto thread_id : readyThreads) {
303 DPRINTF(MinorCPU, "ActivateContext thread: %d\n", thread_id);
284 /* Do some cycle accounting. lastStopped is reset to stop the
285 * wakeup call on the pipeline from adding the quiesce period
286 * to BaseCPU::numCycles */
287 stats.quiesceCycles += pipeline->cyclesSinceLastStopped();
288 pipeline->resetLastStopped();
304
289
305 /* Do some cycle accounting. lastStopped is reset to stop the
306 * wakeup call on the pipeline from adding the quiesce period
307 * to BaseCPU::numCycles */
308 stats.quiesceCycles += pipeline->cyclesSinceLastStopped();
309 pipeline->resetLastStopped();
290 /* Wake up the thread, wakeup the pipeline tick */
291 threads[thread_id]->activate();
292 wakeupOnEvent(Minor::Pipeline::CPUStageId);
293 pipeline->wakeupFetch(thread_id);
310
294
311 /* Wake up the thread, wakeup the pipeline tick */
312 threads[thread_id]->activate();
313 wakeupOnEvent(Minor::Pipeline::CPUStageId);
314
315 pipeline->wakeupFetch(thread_id);
316 BaseCPU::activateContext(thread_id);
317 }
318
319 readyThreads.clear();
295 BaseCPU::activateContext(thread_id);
320}
321
322void
323MinorCPU::suspendContext(ThreadID thread_id)
324{
325 DPRINTF(MinorCPU, "SuspendContext %d\n", thread_id);
326
327 threads[thread_id]->suspend();

--- 51 unchanged lines hidden ---
296}
297
298void
299MinorCPU::suspendContext(ThreadID thread_id)
300{
301 DPRINTF(MinorCPU, "SuspendContext %d\n", thread_id);
302
303 threads[thread_id]->suspend();

--- 51 unchanged lines hidden ---