[coreboot-gerrit] New patch to review for coreboot: f364f67 Fix timestamp output in cbmem utility on ARM

Stefan Reinauer (stefan.reinauer@coreboot.org) gerrit at coreboot.org
Tue Dec 3 20:26:37 CET 2013


Stefan Reinauer (stefan.reinauer at coreboot.org) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/4313

-gerrit

commit f364f671f4c692d2bee89052ee9ee3fd2bb25421
Author: Stefan Reinauer <reinauer at chromium.org>
Date:   Wed Jul 31 15:44:37 2013 -0700

    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 at google.com>
    
    Change-Id: If7363b0703e144bde62d9dab4ba845e1ace5bd18
    Reviewed-on: https://gerrit.chromium.org/gerrit/63991
    Reviewed-by: Vadim Bendebury <vbendeb at chromium.org>
    Commit-Queue: Stefan Reinauer <reinauer at chromium.org>
    Tested-by: Stefan Reinauer <reinauer at chromium.org>
---
 util/cbmem/cbmem.c | 35 ++++++++++++++++++++++++++++++-----
 1 file changed, 30 insertions(+), 5 deletions(-)

diff --git a/util/cbmem/cbmem.c b/util/cbmem/cbmem.c
index 48918b3..520a486 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");



More information about the coreboot-gerrit mailing list