MCPcopy Create free account
hub / github.com/coreboot/coreboot / identify_cpu

Function identify_cpu

src/arch/x86/cpu.c:132–188  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

130}
131
132static void identify_cpu(struct device *cpu)
133{
134 char vendor_name[16];
135 int i;
136
137 vendor_name[0] = '\0'; /* Unset */
138
139#if ENV_X86_32
140 /* Find the id and vendor_name */
141 if (!cpu_have_cpuid()) {
142 /* Its a 486 if we can modify the AC flag */
143 if (flag_is_changeable_p(X86_EFLAGS_AC))
144 cpu->device = 0x00000400; /* 486 */
145 else
146 cpu->device = 0x00000300; /* 386 */
147 if (cpu->device == 0x00000400 && test_cyrix_52div())
148 memcpy(vendor_name, "CyrixInstead", 13);
149 /* If we ever care we can enable cpuid here */
150 /* Detect NexGen with old hypercode */
151 else if (deep_magic_nexgen_probe())
152 memcpy(vendor_name, "NexGenDriven", 13);
153 }
154#endif
155 if (cpu_have_cpuid()) {
156 int cpuid_level;
157 struct cpuid_result result;
158 result = cpuid(0x00000000);
159 cpuid_level = result.eax;
160 vendor_name[0] = (result.ebx >> 0) & 0xff;
161 vendor_name[1] = (result.ebx >> 8) & 0xff;
162 vendor_name[2] = (result.ebx >> 16) & 0xff;
163 vendor_name[3] = (result.ebx >> 24) & 0xff;
164 vendor_name[4] = (result.edx >> 0) & 0xff;
165 vendor_name[5] = (result.edx >> 8) & 0xff;
166 vendor_name[6] = (result.edx >> 16) & 0xff;
167 vendor_name[7] = (result.edx >> 24) & 0xff;
168 vendor_name[8] = (result.ecx >> 0) & 0xff;
169 vendor_name[9] = (result.ecx >> 8) & 0xff;
170 vendor_name[10] = (result.ecx >> 16) & 0xff;
171 vendor_name[11] = (result.ecx >> 24) & 0xff;
172 vendor_name[12] = '\0';
173
174 /* Intel-defined flags: level 0x00000001 */
175 if (cpuid_level >= 0x00000001)
176 cpu->device = cpu_get_cpuid();
177 else
178 /* Have CPUID level 0 only unheard of */
179 cpu->device = 0x00000400;
180 }
181 cpu->vendor = X86_VENDOR_UNKNOWN;
182 for (i = 0; i < ARRAY_SIZE(x86_vendors); i++) {
183 if (memcmp(vendor_name, x86_vendors[i].name, 12) == 0) {
184 cpu->vendor = x86_vendors[i].vendor;
185 break;
186 }
187 }
188}
189

Callers 1

cpu_initializeFunction · 0.85

Calls 8

cpu_have_cpuidFunction · 0.85
test_cyrix_52divFunction · 0.85
deep_magic_nexgen_probeFunction · 0.85
cpu_get_cpuidFunction · 0.85
flag_is_changeable_pFunction · 0.70
memcpyFunction · 0.70
cpuidFunction · 0.50
memcmpFunction · 0.50

Tested by

no test coverage detected