dmi: check both the AC and ID flags at the same time
[syslinux.git] / com32 / modules / cpuid.c
blob452c9e6d492dc11af84b2a352d53f37bfd50e6d6
1 /* ----------------------------------------------------------------------- *
3 * Copyright 2010 Intel Corporation; author: H. Peter Anvin
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
8 * Boston MA 02110-1301, USA; either version 2 of the License, or
9 * (at your option) any later version; incorporated herein by reference.
11 * ----------------------------------------------------------------------- */
13 #include <stdio.h>
14 #include <stdlib.h>
15 #include <x86/cpu.h>
16 #include <console.h>
17 #include <com32.h>
19 static void dump_reg(const char *name, uint32_t val)
21 int i;
23 printf("%-3s : %10u 0x%08x ", name, val, val);
25 for (i = 3; i >= 0; i--) {
26 uint8_t c = val >> (i*8);
27 putchar((c >= ' ' && c <= '~') ? c : '.');
29 putchar('\n');
32 int main(int argc, char *argv[])
34 uint32_t leaf, counter;
35 uint32_t eax, ebx, ecx, edx;
37 if (argc < 2 || argc > 4) {
38 printf("Usage: %s leaf [counter]\n", argv[0]);
39 exit(1);
42 leaf = strtoul(argv[1], NULL, 0);
43 counter = (argc > 2) ? strtoul(argv[2], NULL, 0) : 0;
45 if (!cpu_has_eflag(EFLAGS_ID)) {
46 printf("The CPUID instruction is not supported\n");
47 exit(1);
50 cpuid_count(leaf, counter, &eax, &ebx, &ecx, &edx);
52 dump_reg("eax", eax);
53 dump_reg("ebx", ebx);
54 dump_reg("ecx", ecx);
55 dump_reg("edx", edx);
57 return 0;