[syslinux:master] cpuid.c32: very simple low-level CPUID info CLI routine
syslinux-bot for H. Peter Anvin
hpa at linux.intel.com
Tue Mar 30 15:06:18 PDT 2010
Commit-ID: d71b34b80fbee1df019129971d1cec2568705213
Gitweb: http://syslinux.zytor.com/commit/d71b34b80fbee1df019129971d1cec2568705213
Author: H. Peter Anvin <hpa at linux.intel.com>
AuthorDate: Tue, 30 Mar 2010 15:05:17 -0700
Committer: H. Peter Anvin <hpa at linux.intel.com>
CommitDate: Tue, 30 Mar 2010 15:05:17 -0700
cpuid.c32: very simple low-level CPUID info CLI routine
Add a very simple com32 program to dump a single CPUID leaf.
Signed-off-by: H. Peter Anvin <hpa at linux.intel.com>
---
com32/modules/Makefile | 3 +-
com32/modules/cpuid.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 62 insertions(+), 1 deletions(-)
diff --git a/com32/modules/Makefile b/com32/modules/Makefile
index 3590658..44bc1df 100644
--- a/com32/modules/Makefile
+++ b/com32/modules/Makefile
@@ -21,7 +21,8 @@ include ../MCONFIG
MODULES = chain.c32 config.c32 ethersel.c32 dmitest.c32 cpuidtest.c32 \
disk.c32 pcitest.c32 elf.c32 linux.c32 reboot.c32 pmload.c32 \
meminfo.c32 sdi.c32 sanboot.c32 ifcpu64.c32 vesainfo.c32 \
- kbdmap.c32 cmd.c32 vpdtest.c32 gpxecmd.c32 ifcpu.c32
+ kbdmap.c32 cmd.c32 vpdtest.c32 gpxecmd.c32 ifcpu.c32 \
+ cpuid.c32
TESTFILES =
diff --git a/com32/modules/cpuid.c b/com32/modules/cpuid.c
new file mode 100644
index 0000000..4758fba
--- /dev/null
+++ b/com32/modules/cpuid.c
@@ -0,0 +1,60 @@
+/* ----------------------------------------------------------------------- *
+ *
+ * Copyright 2010 Intel Corporation; author: H. Peter Anvin
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston MA 02110-1301, USA; either version 2 of the License, or
+ * (at your option) any later version; incorporated herein by reference.
+ *
+ * ----------------------------------------------------------------------- */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/cpu.h>
+#include <console.h>
+#include <com32.h>
+
+static void dump_reg(const char *name, uint32_t val)
+{
+ int i;
+
+ printf("%-3s : %10d 0x%08x ", name, val, val);
+
+ for (i = 3; i >= 0; i--) {
+ uint8_t c = val >> (i*8);
+ putchar((c >= ' ' && c <= '~') ? c : '.');
+ }
+ putchar('\n');
+}
+
+int main(int argc, char *argv[])
+{
+ uint32_t leaf, counter;
+ uint32_t eax, ebx, ecx, edx;
+
+ openconsole(&dev_null_r, &dev_stdcon_w);
+
+ if (argc < 2 || argc > 4) {
+ printf("Usage: %s leaf [counter]\n", argv[0]);
+ exit(1);
+ }
+
+ leaf = strtoul(argv[1], NULL, 0);
+ counter = (argv > 2) ? strtoul(argv[2], NULL, 0) : 0;
+
+ if (!cpu_has_eflag(EFLAGS_ID)) {
+ printf("The CPUID instruction is not supported\n");
+ exit(1);
+ }
+
+ cpuid_count(leaf, counter, &eax, &ebx, &ecx, &edx);
+
+ dump_reg("eax", eax);
+ dump_reg("eax", ebx);
+ dump_reg("eax", ecx);
+ dump_reg("eax", edx);
+
+ return 0;
+}
More information about the Syslinux-commits
mailing list