Revision fe4bce09 target-i386/helper.c
b/target-i386/helper.c | ||
---|---|---|
273 | 273 |
{ |
274 | 274 |
.name = "athlon", |
275 | 275 |
.level = 2, |
276 |
.vendor1 = 0x68747541, /* "Auth" */
|
|
277 |
.vendor2 = 0x69746e65, /* "enti" */
|
|
278 |
.vendor3 = 0x444d4163, /* "cAMD" */
|
|
276 |
.vendor1 = CPUID_VENDOR_AMD_1,
|
|
277 |
.vendor2 = CPUID_VENDOR_AMD_2,
|
|
278 |
.vendor3 = CPUID_VENDOR_AMD_3,
|
|
279 | 279 |
.family = 6, |
280 | 280 |
.model = 2, |
281 | 281 |
.stepping = 3, |
... | ... | |
308 | 308 |
}, |
309 | 309 |
}; |
310 | 310 |
|
311 |
static void host_cpuid(uint32_t function, uint32_t count, uint32_t *eax, |
|
312 |
uint32_t *ebx, uint32_t *ecx, uint32_t *edx); |
|
313 |
|
|
314 |
static int cpu_x86_fill_model_id(char *str) |
|
315 |
{ |
|
316 |
uint32_t eax, ebx, ecx, edx; |
|
317 |
int i; |
|
318 |
|
|
319 |
for (i = 0; i < 3; i++) { |
|
320 |
host_cpuid(0x80000002 + i, 0, &eax, &ebx, &ecx, &edx); |
|
321 |
memcpy(str + i * 16 + 0, &eax, 4); |
|
322 |
memcpy(str + i * 16 + 4, &ebx, 4); |
|
323 |
memcpy(str + i * 16 + 8, &ecx, 4); |
|
324 |
memcpy(str + i * 16 + 12, &edx, 4); |
|
325 |
} |
|
326 |
return 0; |
|
327 |
} |
|
328 |
|
|
329 |
static int cpu_x86_fill_host(x86_def_t *x86_cpu_def) |
|
330 |
{ |
|
331 |
uint32_t eax, ebx, ecx, edx; |
|
332 |
|
|
333 |
x86_cpu_def->name = "host"; |
|
334 |
host_cpuid(0x0, 0, &eax, &ebx, &ecx, &edx); |
|
335 |
x86_cpu_def->level = eax; |
|
336 |
x86_cpu_def->vendor1 = ebx; |
|
337 |
x86_cpu_def->vendor2 = edx; |
|
338 |
x86_cpu_def->vendor3 = ecx; |
|
339 |
|
|
340 |
host_cpuid(0x1, 0, &eax, &ebx, &ecx, &edx); |
|
341 |
x86_cpu_def->family = ((eax >> 8) & 0x0F) + ((eax >> 20) & 0xFF); |
|
342 |
x86_cpu_def->model = ((eax >> 4) & 0x0F) | ((eax & 0xF0000) >> 12); |
|
343 |
x86_cpu_def->stepping = eax & 0x0F; |
|
344 |
x86_cpu_def->ext_features = ecx; |
|
345 |
x86_cpu_def->features = edx; |
|
346 |
|
|
347 |
host_cpuid(0x80000000, 0, &eax, &ebx, &ecx, &edx); |
|
348 |
x86_cpu_def->xlevel = eax; |
|
349 |
|
|
350 |
host_cpuid(0x80000001, 0, &eax, &ebx, &ecx, &edx); |
|
351 |
x86_cpu_def->ext2_features = edx; |
|
352 |
x86_cpu_def->ext3_features = ecx; |
|
353 |
cpu_x86_fill_model_id(x86_cpu_def->model_id); |
|
354 |
x86_cpu_def->vendor_override = 0; |
|
355 |
|
|
356 |
return 0; |
|
357 |
} |
|
358 |
|
|
311 | 359 |
static int cpu_x86_find_by_name(x86_def_t *x86_cpu_def, const char *cpu_model) |
312 | 360 |
{ |
313 | 361 |
unsigned int i; |
... | ... | |
326 | 374 |
break; |
327 | 375 |
} |
328 | 376 |
} |
329 |
if (!def) |
|
330 |
goto error; |
|
331 |
memcpy(x86_cpu_def, def, sizeof(*def)); |
|
377 |
if (!def) { |
|
378 |
if (strcmp(name, "host") != 0) { |
|
379 |
goto error; |
|
380 |
} |
|
381 |
cpu_x86_fill_host(x86_cpu_def); |
|
382 |
} else { |
|
383 |
memcpy(x86_cpu_def, def, sizeof(*def)); |
|
384 |
} |
|
332 | 385 |
|
333 | 386 |
add_flagname_to_bitmaps("hypervisor", &plus_features, |
334 | 387 |
&plus_ext_features, &plus_ext2_features, &plus_ext3_features); |
Also available in: Unified diff