6 static const char *cpuname(struct cpuid_info *cpu);
7 static const char *cpuvendor(struct cpuid_info *cpu);
9 struct cpuid_info cpuid;
11 void print_cpuid(struct cpuid_info *cpu)
14 static const char *featstr[32] = {
15 "fpu", "vme", "dbgext", "pse", "tsc", "msr", "pae", "mce",
16 "cx8", "apic", "?", "sep", "mtrr", "pge", "mca", "cmov",
17 "pat", "pse36", "psn", "clf", "?", "dtes", "acpi", "mmx",
18 "fxsr", "sse", "sse2", "ss", "htt", "tm1", "ia64", "pbe"};
19 static const char *feat2str[32] = {
20 "sse3", "pclmul", "dtes64", "monitor", "ds-cpl", "vmx", "smx", "est",
21 "tm2", "ssse3", "cid", "sdbg", "fma", "cx16", "etprd", "pdcm",
22 "?", "pcid", "dca", "sse41", "sse42", "x2apic", "movbe", "popcnt",
23 "?", "aes", "xsave", "osxsave", "avx", "f16c", "rdrand", "?"};
25 infomsg("CPU: %s - %s\n", cpuvendor(cpu), cpuname(cpu));
26 infomsg("features:\n ");
29 if(cpu->feat & (1 << i)) {
30 len = strlen(featstr[i]) + 1;
35 infomsg(" %s", featstr[i]);
36 col += strlen(featstr[i]) + 1;
40 if(cpu->feat2 & (1 << i)) {
41 len = strlen(feat2str[i]) + 1;
46 infomsg(" %s", feat2str[i]);
47 col += strlen(feat2str[i]) + 1;
53 static const char *fam4_models[16] = {
54 "486 DX 25/33", "486 DX 50", "486 SX", "486 DX/2", "486 SL", "486 SX/2",
55 0, "486 DX/2-WB", "486 DX/4", "486 DX/4-WB"
57 static const char *fam5_models[16] = {
58 "Pentium 60/66", "Pentium 60/66", "Pentium 75-200", "OverDrive", "Pentium MMX",
59 0, 0, "Mobile Pentium 75-200", "Mobile Pentium MMX", "Quark"
61 static const char *fam6_models[16] = {
62 "Pentium Pro", "Pentium Pro", 0, "Pentium 2", "Pentium 2", "Pentium 2",
63 "Mobile Pentium 2", "Pentium 3", "Pentium 3", 0, "Pentium 3", "Pentium 3"
67 static const char *cpuname(struct cpuid_info *cpu)
73 /* unwank the string */
74 rd = wr = cpu->brandstr;
76 if(rd[0] == '(' && rd[1] == 'T' && rd[2] == 'M' && rd[3] == ')')
78 else if(rd[0] == '(' && rd[1] == 'R' && rd[2] == ')')
80 if(rd != wr) *wr = *rd;
88 if(CPUID_EXTMODEL(cpu->id)) {
89 /* processors new enough to have an extended model, should also provide
90 * a brand string. If we end up here, we don't know what it is
95 model = CPUID_MODEL(cpu->id);
96 family = CPUID_FAMILY(cpu->id) | (CPUID_EXTFAMILY(cpu->id) << 4);
100 case 4: return fam4_models[model] ? fam4_models[model] : "486";
101 case 5: return fam5_models[model] ? fam5_models[model] : "Pentium";
102 case 6: return fam6_models[model] ? fam6_models[model] : "unknown";
103 case 15: return "Pentium 4";
110 static const char *cpuvendor(struct cpuid_info *cpu)
112 static char other[16];
113 static const struct { const char *wank, *vendor; } unwanktab[] = {
114 {"GenuineIntel", "intel"},
115 {"AuthenticAMD", "AMD"},
116 {"AMDisbetter!", "AMD"},
117 {"CentaurHauls", "IDT"},
118 {"CyrixInstead", "Cyrix"},
119 {"TransmetaCPU", "Transmeta"},
120 {"GenuineTMx86", "Transmeta"},
121 {"Geode by NSC", "NatSemi"},
122 {"NexGenDriven", "NexGen"},
123 {"RiseRiseRise", "Rise"},
124 {"SiS SiS SiS ", "SiS"},
125 {"UMC UMC UMC ", "UMC"},
126 {"VIA VIA VIA ", "VIA"},
127 {"Vortex86 SoC", "DM&P"},
128 {" Shanghai ", "Zhaoxin"},
129 {"HygonGenuine", "Hygon"},
130 {"E2K MACHINE", "MCST Elbrus"},
131 {"MiSTer A0486", "ao486"},
132 {"bhyve bhyve ", "bhyve"},
133 {" KVMKVMKVM ", "KVM"},
134 {"TCGTCGTCGTCG", "qemu"},
135 {"Microsoft Hv", "MS Hyper-V"},
136 {" lrpepyh vr", "Parallels"},
137 {"VMwareVMware", "VMware"},
138 {"XenVMMXenVMM", "Xen"},
139 {"ACRNACRNACRN", "ACRN"},
140 {" QNXQVMBSQG ", "QNX Hypervisor"},
145 for(i=0; unwanktab[i].wank; i++) {
146 if(memcmp(cpu->vendor, unwanktab[i].wank, 12) == 0) {
147 return unwanktab[i].vendor;
151 memcpy(other, cpu->vendor, 12);