]> git.ozlabs.org Git - ccan/blobdiff - ccan/cpuid/test/run.c
cpuid: parse additional feature information for pCPU_PROCINFO_AND_FEATUREBITS
[ccan] / ccan / cpuid / test / run.c
index 65741f144920f6487e27de8de04803fd7c9f3ce0..39a7af95ed4073765e451cb87f94a35e35e6ce8c 100644 (file)
@@ -1,47 +1,47 @@
-#include "cpuid.h"
+#include "../cpuid.c"
 
 #include <stdio.h>
+#include <stdint.h>
 
-int main()
+int main(void)
 {
        if (!cpuid_is_supported()) {
                printf ("CPUID instruction is not supported by this CPU\n");
                return 1;
        }
 
-       printf ("MMX:  %s\n", cpuid_has_mmx()  ? "Yes" : "No");
-       printf ("SSE:  %s\n", cpuid_has_sse()  ? "Yes" : "No");
-       printf ("SSE2: %s\n", cpuid_has_sse2() ? "Yes" : "No");
-       printf ("SSE3: %s\n", cpuid_has_sse3() ? "Yes" : "No");
-       printf ("x64:  %s\n", cpuid_has_x64()  ? "Yes" : "No");
+       char cputype[12];
+       if (cpuid_sprintf_cputype(cpuid_get_cpu_type(), cputype))
+               printf ("Vendor ID: %s\n", cputype);
 
-       char buf[128];
-       cpuid(CPU_VENDORID, buf);
-       printf ("Vendor ID: %s\n", buf);
-
-       cpuid(CPU_PROC_BRAND_STRING, buf);
+       char buf[48];
+       cpuid(CPU_PROC_BRAND_STRING, (uint32_t *)buf);
        printf ("Processor Brand: %s\n", buf);
 
-       int addr;
-       cpuid(CPU_HIGHEST_EXTENDED_FUNCTION_SUPPORTED, &addr);
-       printf ("Highest extended function supported: %#010x\n", addr);
+       uint32_t procinfo[11];
+       cpuid(CPU_PROCINFO_AND_FEATUREBITS, procinfo);
+       printf("Stepping: %d Model: 0x%X Family: %d extended model: %d extended family: %d\n",
+               procinfo[0], procinfo[1], procinfo[2], procinfo[3], procinfo[4]);
+       printf("Brand Index: %d CL Flush Line Size: %d Logical Processors: %d Initial APICID: %d\n",
+               procinfo[7], procinfo[8], procinfo[9], procinfo[10]);
+
+       printf ("Highest extended function supported: %#010x\n", cpuid_highest_ext_func_supported());
 
-       int virtphys_size;
-       cpuid(CPU_VIRT_PHYS_ADDR_SIZES, &virtphys_size);
-       printf ("Virtual and physical address sizes: %d\n", virtphys_size);
+       uint32_t phys_virt[2];
+       cpuid(CPU_VIRT_PHYS_ADDR_SIZES, phys_virt);
+       printf ("Physical address size: %d\nVirtual address size: %d\n", phys_virt[0], phys_virt[1]);
 
-       int extfeatures[2];
+       uint32_t extfeatures[2];
        cpuid(CPU_EXTENDED_PROC_INFO_FEATURE_BITS, extfeatures);
        printf ("Extended processor info and feature bits: %d %d\n", extfeatures[0], extfeatures[1]);
 
-       int l2features[3];
-       cpuid(CPU_EXTENDED_L2_CACHE_FEATURES, l2features);
-       printf ("L2 Cache Size: %u KB\tLine Size: %u bytes\tAssociativity: %02xh\n",
-                       l2features[0], l2features[1], l2features[2]);
+       uint32_t l2c[3];
+       cpuid(CPU_EXTENDED_L2_CACHE_FEATURES, l2c);
+       printf("L2 Line size: %u bytes\tAssociativity: %02xh\tCache Size: %u KB\n",
+               l2c[0], l2c[1], l2c[2]);
 
-       int invalid;
+       uint32_t invalid;
        cpuid(0x0ffffffUL, &invalid);
        printf ("Testing invalid: %#010x\n", invalid);
        return 0;
 }
-