From: Erik van der Kouwe Date: Mon, 3 May 2010 19:41:04 +0000 (+0000) Subject: Add syslib function to obtain CPU frequency X-Git-Tag: v3.1.7~91 X-Git-Url: http://zhaoyanbai.com/repos/%22../static/icons/ChangeLog.html?a=commitdiff_plain;h=4b34ff6903521cc1550122c93d673eab257ca1a3;p=minix.git Add syslib function to obtain CPU frequency --- diff --git a/include/minix/sysutil.h b/include/minix/sysutil.h index c6e4edb33..e596e9635 100644 --- a/include/minix/sysutil.h +++ b/include/minix/sysutil.h @@ -57,6 +57,7 @@ _PROTOTYPE( void util_stacktrace_strcat, (char *)); _PROTOTYPE( int micro_delay, (u32_t micros)); _PROTOTYPE( u32_t tsc_64_to_micros, (u64_t tsc)); _PROTOTYPE( u32_t tsc_to_micros, (u32_t low, u32_t high)); +_PROTOTYPE( u32_t tsc_get_khz, (void)); _PROTOTYPE( u32_t micros_to_ticks, (u32_t micros)); _PROTOTYPE( void ser_putc, (char c)); _PROTOTYPE( void get_randomness, (struct k_randomness *, int)); diff --git a/lib/libsys/tsc_util.c b/lib/libsys/tsc_util.c index dfb1218e0..815d8840f 100644 --- a/lib/libsys/tsc_util.c +++ b/lib/libsys/tsc_util.c @@ -111,3 +111,9 @@ u32_t tsc_to_micros(u32_t low, u32_t high) return micros; } +u32_t tsc_get_khz(void) +{ + CALIBRATE; + + return calib_tsc / (CALIBRATE_TICKS(Hz) * MICROSPERTICK(Hz)) * 1000; +}