summaryrefslogtreecommitdiff
path: root/src/cpu/base.cc
diff options
context:
space:
mode:
authorDavid Guillen Fandos <david.guillen@arm.com>2016-06-06 17:16:43 +0100
committerDavid Guillen Fandos <david.guillen@arm.com>2016-06-06 17:16:43 +0100
commitfb5fc11da49938660ea22c336964677cdba890e1 (patch)
tree321c3c2a60e6e5f317904cc89971700d939cc5ec /src/cpu/base.cc
parentd4342aff4ce347ad8ab5a01fdd41993106cd3ece (diff)
downloadgem5-fb5fc11da49938660ea22c336964677cdba890e1.tar.xz
pwr: Low-power idle power state for idle CPUs
Add functionality to the BaseCPU that will put the entire CPU into a low-power idle state whenever all threads in it are idle. Change-Id: I984d1656eb0a4863c87ceacd773d2d10de5cfd2b
Diffstat (limited to 'src/cpu/base.cc')
-rw-r--r--src/cpu/base.cc29
1 files changed, 28 insertions, 1 deletions
diff --git a/src/cpu/base.cc b/src/cpu/base.cc
index fbd8af99a..aaf5a7a93 100644
--- a/src/cpu/base.cc
+++ b/src/cpu/base.cc
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011-2012 ARM Limited
+ * Copyright (c) 2011-2012,2016 ARM Limited
* All rights reserved
*
* The license below extends only to copyright in the software and shall
@@ -64,6 +64,7 @@
#include "debug/SyscallVerbose.hh"
#include "mem/page_table.hh"
#include "params/BaseCPU.hh"
+#include "sim/clocked_object.hh"
#include "sim/full_system.hh"
#include "sim/process.hh"
#include "sim/sim_events.hh"
@@ -355,6 +356,11 @@ BaseCPU::startup()
if (params()->progress_interval) {
new CPUProgressEvent(this, params()->progress_interval);
}
+
+ // Assumption CPU start to operate instantaneously without any latency
+ if (ClockedObject::pwrState() == Enums::PwrState::UNDEFINED)
+ ClockedObject::pwrState(Enums::PwrState::ON);
+
}
ProbePoints::PMUUPtr
@@ -475,6 +481,27 @@ BaseCPU::findContext(ThreadContext *tc)
}
void
+BaseCPU::activateContext(ThreadID thread_num)
+{
+ // For any active thread running, update CPU power state to active (ON)
+ ClockedObject::pwrState(Enums::PwrState::ON);
+}
+
+void
+BaseCPU::suspendContext(ThreadID thread_num)
+{
+ // Check if all threads are suspended
+ for (auto t : threadContexts) {
+ if (t->status() != ThreadContext::Suspended) {
+ return;
+ }
+ }
+
+ // All CPU threads suspended, enter lower power state for the CPU
+ ClockedObject::pwrState(Enums::PwrState::CLK_GATED);
+}
+
+void
BaseCPU::switchOut()
{
assert(!_switchedOut);