summaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorPatrick Georgi <patrick@georgi-clan.de>2015-07-13 16:53:50 +0200
committerPatrick Georgi <pgeorgi@google.com>2015-07-14 12:23:05 +0200
commitd00f180812279144ce09e2ad046973f3a384456c (patch)
tree9ea1ac1f12aeeb5ecc62e6fd1ef0dc4168f7813b /util
parent3162a1db7a723f3fb2c598386d85abbc1c04e5f9 (diff)
downloadcoreboot-d00f180812279144ce09e2ad046973f3a384456c.tar.gz
coreboot-d00f180812279144ce09e2ad046973f3a384456c.tar.bz2
coreboot-d00f180812279144ce09e2ad046973f3a384456c.zip
cbmem: convert x86 timestamps on OpenBSD
Change-Id: I16bfe42a00d73209307655601edaa3a8ffc9c902 Signed-off-by: Patrick Georgi <patrick@georgi-clan.de> Reviewed-on: http://review.coreboot.org/10905 Tested-by: build bot (Jenkins) Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
Diffstat (limited to 'util')
-rw-r--r--util/cbmem/cbmem.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/util/cbmem/cbmem.c b/util/cbmem/cbmem.c
index 3bc0fcd1a794..aa73c6a67a4d 100644
--- a/util/cbmem/cbmem.c
+++ b/util/cbmem/cbmem.c
@@ -35,6 +35,11 @@
#include <libgen.h>
#include <assert.h>
+#ifdef __OpenBSD__
+#include <sys/param.h>
+#include <sys/sysctl.h>
+#endif
+
#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
#define MAP_BYTES (1024*1024)
#define IS_ENABLED(x) (defined (x) && (x))
@@ -294,7 +299,7 @@ static int parse_cbtable(u64 address, size_t table_size)
return found;
}
-#if defined(__i386__) || defined(__x86_64__)
+#if defined(linux) && (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.
@@ -349,6 +354,18 @@ u64 arch_convert_raw_ts_entry(u64 ts)
return ts / cpu_freq_mhz;
}
+#elif defined(__OpenBSD__) && (defined(__i386__) || defined(__x86_64__))
+u64 arch_convert_raw_ts_entry(u64 ts)
+{
+ int mib[2] = { CTL_HW, HW_CPUSPEED };
+ static int value = 0;
+ size_t value_len = sizeof(value);
+
+ if ((value == 0) && (sysctl(mib, 2, &value, &value_len, NULL, 0) == -1))
+ return ts;
+
+ return ts / value;
+}
#else
/* On non-x86 platforms the timestamp entries