cpuid: prefix cpuid_t enums with CPUID_* instead of CPU_*
[ccan] / ccan / cpuid / test / run.c
1 #include "../cpuid.c"
2
3 #include <stdio.h>
4 #include <stdint.h>
5
6 int main(void)
7 {
8         if (!cpuid_is_supported()) {
9                 printf ("CPUID instruction is not supported by this CPU\n");
10                 return 1;
11         }
12
13         char cputype[12];
14         if (cpuid_sprintf_cputype(cpuid_get_cpu_type(), cputype))
15                 printf ("Vendor ID: %s\n", cputype);
16
17         char buf[48];
18         cpuid(CPUID_PROC_BRAND_STRING, (uint32_t *)buf);
19         printf ("Processor Brand: %s\n", buf);
20
21         uint32_t procinfo[11];
22         cpuid(CPUID_PROCINFO_AND_FEATUREBITS, procinfo);
23         printf("Stepping: %d Model: 0x%X Family: %d extended model: %d extended family: %d\n",
24                 procinfo[0], procinfo[1], procinfo[2], procinfo[3], procinfo[4]);
25         printf("Brand Index: %d CL Flush Line Size: %d Logical Processors: %d Initial APICID: %d\n",
26                 procinfo[7], procinfo[8], procinfo[9], procinfo[10]);
27
28         printf ("Highest extended function supported: %#010x\n", cpuid_highest_ext_func_supported());
29
30         uint32_t phys_virt[2];
31         cpuid(CPUID_VIRT_PHYS_ADDR_SIZES, phys_virt);
32         printf ("Physical address size: %d\nVirtual address size: %d\n", phys_virt[0], phys_virt[1]);
33
34         uint32_t extfeatures[2];
35         cpuid(CPUID_EXTENDED_PROC_INFO_FEATURE_BITS, extfeatures);
36         printf ("Extended processor info and feature bits: %d %d\n", extfeatures[0], extfeatures[1]);
37
38         uint32_t l2c[3];
39         cpuid(CPUID_EXTENDED_L2_CACHE_FEATURES, l2c);
40         printf("L2 Line size: %u bytes\tAssociativity: %02xh\tCache Size: %u KB\n",
41                 l2c[0], l2c[1], l2c[2]);
42
43         uint32_t invalid;
44         cpuid(0x0ffffffUL, &invalid);
45         printf ("Testing invalid: %#010x\n", invalid);
46         return 0;
47 }