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 * ----------------------------------------------------------------------- */
19 static void dump_reg(const char *name
, uint32_t val
)
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
: '.');
32 int main(int argc
, char *argv
[])
34 uint32_t leaf
, counter
;
35 uint32_t eax
, ebx
, ecx
, edx
;
37 openconsole(&dev_null_r
, &dev_stdcon_w
);
39 if (argc
< 2 || argc
> 4) {
40 printf("Usage: %s leaf [counter]\n", argv
[0]);
44 leaf
= strtoul(argv
[1], NULL
, 0);
45 counter
= (argc
> 2) ? strtoul(argv
[2], NULL
, 0) : 0;
47 if (!cpu_has_eflag(EFLAGS_ID
)) {
48 printf("The CPUID instruction is not supported\n");
52 cpuid_count(leaf
, counter
, &eax
, &ebx
, &ecx
, &edx
);