aboutsummaryrefslogtreecommitdiff
path: root/src/cpu/abstract_cpu.cpp
diff options
context:
space:
mode:
authorIvan Shapovalov <intelfx100@gmail.com>2012-12-24 17:58:03 +0400
committerKristen Carlson Accardi <kristen@linux.intel.com>2013-01-31 13:55:41 -0800
commit7e8f43e477e02842801454125060b6d9f01bb75a (patch)
treed02f8672396d6925c834b98493b20fd9baf79d60 /src/cpu/abstract_cpu.cpp
parenta1fc69738a4b2137e5e3ea22893308abac847cbb (diff)
Deduplication: move all instances of account_freq() to abstract_cpu::account_freq()
Trivial: unify identical in-class private definitions in the common base class. The only override left is nhm_cpu::account_freq() which is almost identical but ignores the "Turbo Mode" state. Seems like a hidden bug to me, but will remove it in a separate commit so one can revert it easily in case something goes wrong. Signed-off-by: Ivan Shapovalov <intelfx100@gmail.com>
Diffstat (limited to 'src/cpu/abstract_cpu.cpp')
-rw-r--r--src/cpu/abstract_cpu.cpp39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/cpu/abstract_cpu.cpp b/src/cpu/abstract_cpu.cpp
index 537f3cb..5618761 100644
--- a/src/cpu/abstract_cpu.cpp
+++ b/src/cpu/abstract_cpu.cpp
@@ -28,7 +28,46 @@
#include <stdio.h>
#include <stdlib.h>
#include "cpu.h"
+#include "../lib.h"
+void abstract_cpu::account_freq(uint64_t freq, uint64_t duration)
+{
+ struct frequency *state = NULL;
+ unsigned int i;
+
+ for (i = 0; i < pstates.size(); i++) {
+ if (freq == pstates[i]->freq) {
+ state = pstates[i];
+ break;
+ }
+ }
+
+
+ if (!state) {
+ state = new(std::nothrow) struct frequency;
+
+ if (!state)
+ return;
+
+ memset(state, 0, sizeof(*state));
+
+ pstates.push_back(state);
+
+ state->freq = freq;
+ hz_to_human(freq, state->human_name);
+ if (freq == 0)
+ strcpy(state->human_name, _("Idle"));
+ if (is_turbo(freq, max_frequency, max_minus_one_frequency))
+ sprintf(state->human_name, _("Turbo Mode"));
+
+ state->after_count = 1;
+ }
+
+
+ state->time_after += duration;
+
+
+}
void abstract_cpu::measurement_start(void)
{