summaryrefslogtreecommitdiffstats
path: root/c/src/lib/libcpu/i386
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2008-12-03 17:29:05 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2008-12-03 17:29:05 +0000
commitb2d7d165666e554da8055e5f09882f9a43c9cdec (patch)
treeeab94120e998c9cc015f79e6ccf2d9e56cf1b2c8 /c/src/lib/libcpu/i386
parent2008-12-03 Joel Sherrill <joel.sherrill@OARcorp.com> (diff)
downloadrtems-b2d7d165666e554da8055e5f09882f9a43c9cdec.tar.bz2
2008-12-03 Joel Sherrill <joel.sherrill@OARcorp.com>
Michael South <msouth@msouth.org> PR 1344/bsps * cpuModel.h: Add use of TSC for nanoseconds granularity. i8254 is very slow on some systems. TSC use is auto-detected by default.
Diffstat (limited to 'c/src/lib/libcpu/i386')
-rw-r--r--c/src/lib/libcpu/i386/ChangeLog7
-rw-r--r--c/src/lib/libcpu/i386/cpuModel.h14
2 files changed, 21 insertions, 0 deletions
diff --git a/c/src/lib/libcpu/i386/ChangeLog b/c/src/lib/libcpu/i386/ChangeLog
index a4bac69fe5..9c11972f70 100644
--- a/c/src/lib/libcpu/i386/ChangeLog
+++ b/c/src/lib/libcpu/i386/ChangeLog
@@ -1,3 +1,10 @@
+2008-12-03 Joel Sherrill <joel.sherrill@OARcorp.com>
+ Michael South <msouth@msouth.org>
+
+ PR 1344/bsps
+ * cpuModel.h: Add use of TSC for nanoseconds granularity. i8254 is very
+ slow on some systems. TSC use is auto-detected by default.
+
2008-08-16 Ralf Corsépius <ralf.corsepius@rtems.org>
* cache.c, displayCpu.c, page.c: Add missing prototypes.
diff --git a/c/src/lib/libcpu/i386/cpuModel.h b/c/src/lib/libcpu/i386/cpuModel.h
index fb0c90fcfc..c5451d851b 100644
--- a/c/src/lib/libcpu/i386/cpuModel.h
+++ b/c/src/lib/libcpu/i386/cpuModel.h
@@ -31,4 +31,18 @@ extern unsigned char Cx86_step; /* cyrix processor identification */
extern void printCpuInfo(); /* Display this information on console in ascii form */
+/* determine if the CPU has a TSC */
+#define x86_has_tsc() \
+ (x86_capability & (1 << 4))
+
+static inline unsigned long long
+rdtsc(void)
+{
+ /* Return the value of the on-chip cycle counter. */
+ unsigned long long result;
+ asm volatile(".byte 0x0F, 0x31" : "=A" (result));
+ return result;
+} /* rdtsc */
+
+
#endif