summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Reinauer <reinauer@chromium.org>2013-07-31 15:44:37 -0700
committerRonald G. Minnich <rminnich@gmail.com>2013-12-05 19:23:40 +0100
commitd8ef9e9e9b8f7e4685fc1cbad0b1f6d82799712c (patch)
tree369f62ea9e7f3e12ffda4edd9f1425594f44af0b
parent274c6c2177979ba471f61f03d2ea76df673ff925 (diff)
downloadcoreboot-d8ef9e9e9b8f7e4685fc1cbad0b1f6d82799712c.tar.xz
Fix timestamp output in cbmem utility on ARM
On ARM the timestamps are already in micro seconds, so no need to convert them. Signed-off-by: Stefan Reinauer <reinauer@google.com> Change-Id: If7363b0703e144bde62d9dab4ba845e1ace5bd18 Reviewed-on: https://gerrit.chromium.org/gerrit/63991 Reviewed-by: Vadim Bendebury <vbendeb@chromium.org> Commit-Queue: Stefan Reinauer <reinauer@chromium.org> Tested-by: Stefan Reinauer <reinauer@chromium.org> Reviewed-on: http://review.coreboot.org/4313 Tested-by: build bot (Jenkins) Reviewed-by: Ronald G. Minnich <rminnich@gmail.com>
-rw-r--r--util/cbmem/cbmem.c35
1 files changed, 30 insertions, 5 deletions
diff --git a/util/cbmem/cbmem.c b/util/cbmem/cbmem.c
index 48918b3877..520a4866e7 100644
--- a/util/cbmem/cbmem.c
+++ b/util/cbmem/cbmem.c
@@ -243,6 +243,7 @@ static int parse_cbtable(u64 address)
return found;
}
+#if defined(__i386__) || defined(__x86_64__)
/*
* read CPU frequency from a sysfs file, return an frequency in Kilohertz as
* an int or exit on any error.
@@ -282,6 +283,32 @@ static u64 get_cpu_freq_KHz(void)
exit(1);
}
+/* On x86 platforms timestamps are stored
+ * in CPU cycles (from rdtsc). Hence the
+ * timestamp divider is the CPU frequency
+ * in MHz.
+ */
+u64 arch_convert_raw_ts_entry(u64 ts)
+{
+ static u64 cpu_freq_mhz = 0;
+
+ if (!cpu_freq_mhz)
+ cpu_freq_mhz = get_cpu_freq_KHz() / 1000;
+
+ return ts / cpu_freq_mhz;
+}
+
+#else
+
+/* On non-x86 platforms the timestamp entries
+ * are not in clock cycles but in usecs
+ */
+u64 arch_convert_raw_ts_entry(u64 ts)
+{
+ return ts;
+}
+#endif
+
/*
* Print an integer in 'normalized' form - with commas separating every three
* decimal orders. The 'comma' parameter indicates if a comma is needed after
@@ -308,7 +335,6 @@ static void print_norm(u64 v, int comma)
static void dump_timestamps(void)
{
int i;
- u64 cpu_freq_MHz = get_cpu_freq_KHz() / 1000;
struct timestamp_table *tst_p;
if (timestamps.tag != LB_TAG_TIMESTAMPS) {
@@ -324,12 +350,11 @@ static void dump_timestamps(void)
const struct timestamp_entry *tse_p = tst_p->entries + i;
printf("%4d:", tse_p->entry_id);
- print_norm(tse_p->entry_stamp / cpu_freq_MHz, 0);
+ print_norm(arch_convert_raw_ts_entry(tse_p->entry_stamp), 0);
if (i) {
printf(" (");
- print_norm((tse_p->entry_stamp -
- tse_p[-1].entry_stamp) /
- cpu_freq_MHz, 0);
+ print_norm(arch_convert_raw_ts_entry(tse_p->entry_stamp
+ - tse_p[-1].entry_stamp), 0);
printf(")");
}
printf("\n");