summaryrefslogtreecommitdiffstats
path: root/src/kernel/tests/include/old/ltp_cpuid.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/kernel/tests/include/old/ltp_cpuid.h')
-rw-r--r--src/kernel/tests/include/old/ltp_cpuid.h35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/kernel/tests/include/old/ltp_cpuid.h b/src/kernel/tests/include/old/ltp_cpuid.h
new file mode 100644
index 0000000..6bd5537
--- /dev/null
+++ b/src/kernel/tests/include/old/ltp_cpuid.h
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2012-2013 The Chromium OS Authors. All rights reserved.
+ *
+ * Licensed under the BSD 3-clause.
+ */
+
+#ifndef __LTP_CPUID_H__
+#define __LTP_CPUID_H__
+
+static inline void cpuid(unsigned int info, unsigned int *eax, unsigned int *ebx,
+ unsigned int *ecx, unsigned int *edx)
+{
+#if defined(__i386__) || defined(__x86_64__)
+ unsigned int _eax = info, _ebx, _ecx, _edx;
+ asm volatile(
+# ifdef __i386__
+ "xchg %%ebx, %%esi;" /* save ebx (for PIC) */
+ "cpuid;"
+ "xchg %%esi, %%ebx;" /* restore ebx & pass to caller */
+ : "=S" (_ebx),
+# else
+ "cpuid;"
+ : "=b" (_ebx),
+# endif
+ "+a" (_eax), "=c" (_ecx), "=d" (_edx)
+ : /* inputs: eax is handled above */
+ );
+ if (eax) *eax = _eax;
+ if (ebx) *ebx = _ebx;
+ if (ecx) *ecx = _ecx;
+ if (edx) *edx = _edx;
+#endif
+}
+
+#endif