/*
- * Copyright (c) 2000-2006 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2000-2012 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* CPU identification routines.
*/
-static i386_cpu_info_t *cpuid_cpu_infop = NULL;
static i386_cpu_info_t cpuid_cpu_info;
+static i386_cpu_info_t *cpuid_cpu_infop = NULL;
-#if defined(__x86_64__)
static void cpuid_fn(uint32_t selector, uint32_t *result)
{
do_cpuid(selector, result);
DBG("cpuid_fn(0x%08x) eax:0x%08x ebx:0x%08x ecx:0x%08x edx:0x%08x\n",
selector, result[0], result[1], result[2], result[3]);
}
-#else
-static void cpuid_fn(uint32_t selector, uint32_t *result)
-{
- if (get_is64bit()) {
- asm("call _cpuid64"
- : "=a" (result[0]),
- "=b" (result[1]),
- "=c" (result[2]),
- "=d" (result[3])
- : "a"(selector),
- "b" (0),
- "c" (0),
- "d" (0));
- } else {
- do_cpuid(selector, result);
- }
- DBG("cpuid_fn(0x%08x) eax:0x%08x ebx:0x%08x ecx:0x%08x edx:0x%08x\n",
- selector, result[0], result[1], result[2], result[3]);
-}
-#endif
static const char *cache_type_str[LCACHE_MAX] = {
"Lnone", "L1I", "L1D", "L2U", "L3U"
switch (info_p->cpuid_family) {
case 6:
switch (info_p->cpuid_model) {
-#if CONFIG_YONAH
- case 14:
- cpufamily = CPUFAMILY_INTEL_YONAH;
- break;
-#endif
case 15:
cpufamily = CPUFAMILY_INTEL_MEROM;
break;
cpufamily = CPUFAMILY_INTEL_SANDYBRIDGE;
break;
case CPUID_MODEL_IVYBRIDGE:
+ case CPUID_MODEL_IVYBRIDGE_EP:
cpufamily = CPUFAMILY_INTEL_IVYBRIDGE;
break;
case CPUID_MODEL_HASWELL:
{
i386_cpu_info_t *info_p = &cpuid_cpu_info;
- PE_parse_boot_argn("-cpuid", &cpuid_dbg, sizeof(cpuid_dbg));
-
- bzero((void *)info_p, sizeof(cpuid_cpu_info));
-
cpuid_set_generic_info(info_p);
/* verify we are running on a supported CPU */
info_p->cpuid_cpu_type = CPU_TYPE_X86;
info_p->cpuid_cpu_subtype = CPU_SUBTYPE_X86_ARCH1;
/* Must be invoked after set_generic_info */
- cpuid_set_cache_info(&cpuid_cpu_info);
+ cpuid_set_cache_info(info_p);
/*
* Find the number of enabled cores and threads
DBG(" core_count : %d\n", info_p->core_count);
DBG(" thread_count : %d\n", info_p->thread_count);
- cpuid_cpu_info.cpuid_model_string = ""; /* deprecated */
+ info_p->cpuid_model_string = ""; /* deprecated */
}
static struct table {
},
leaf7_feature_map[] = {
+ {CPUID_LEAF7_FEATURE_SMEP, "SMEP"},
+ {CPUID_LEAF7_FEATURE_ENFSTRG, "ENFSTRG"},
{CPUID_LEAF7_FEATURE_RDWRFSGS, "RDWRFSGS"},
{CPUID_LEAF7_FEATURE_TSCOFF, "TSC_THREAD_OFFSET"},
{CPUID_LEAF7_FEATURE_BMI1, "BMI1"},
{CPUID_LEAF7_FEATURE_HLE, "HLE"},
- {CPUID_LEAF7_FEATURE_SMEP, "SMEP"},
{CPUID_LEAF7_FEATURE_AVX2, "AVX2"},
{CPUID_LEAF7_FEATURE_BMI2, "BMI2"},
- {CPUID_LEAF7_FEATURE_ENFSTRG, "ENFSTRG"},
{CPUID_LEAF7_FEATURE_INVPCID, "INVPCID"},
{CPUID_LEAF7_FEATURE_RTM, "RTM"},
{0, 0}
{
/* Set-up the cpuid_info stucture lazily */
if (cpuid_cpu_infop == NULL) {
+ PE_parse_boot_argn("-cpuid", &cpuid_dbg, sizeof(cpuid_dbg));
cpuid_set_info();
cpuid_cpu_infop = &cpuid_cpu_info;
}
#define s_if_plural(n) ((n > 1) ? "s" : "")
kprintf(" HTT: %d core%s per package;"
" %d logical cpu%s per package\n",
- cpuid_cpu_info.cpuid_cores_per_package,
- s_if_plural(cpuid_cpu_info.cpuid_cores_per_package),
- cpuid_cpu_info.cpuid_logical_per_package,
- s_if_plural(cpuid_cpu_info.cpuid_logical_per_package));
+ cpuid_cpu_infop->cpuid_cores_per_package,
+ s_if_plural(cpuid_cpu_infop->cpuid_cores_per_package),
+ cpuid_cpu_infop->cpuid_logical_per_package,
+ s_if_plural(cpuid_cpu_infop->cpuid_logical_per_package));
}
}
cpuid_cpu_display(
const char *header)
{
- if (cpuid_cpu_info.cpuid_brand_string[0] != '\0') {
- kprintf("%s: %s\n", header, cpuid_cpu_info.cpuid_brand_string);
+ if (cpuid_cpu_infop->cpuid_brand_string[0] != '\0') {
+ kprintf("%s: %s\n", header, cpuid_cpu_infop->cpuid_brand_string);
}
}
printf("limiting fpu features to: %s\n", fpu_arg);
if (!strncmp("387", fpu_arg, sizeof("387")) || !strncmp("mmx", fpu_arg, sizeof("mmx"))) {
printf("no sse or sse2\n");
- cpuid_cpu_info.cpuid_features &= ~(CPUID_FEATURE_SSE | CPUID_FEATURE_SSE2 | CPUID_FEATURE_FXSR);
+ cpuid_cpu_infop->cpuid_features &= ~(CPUID_FEATURE_SSE | CPUID_FEATURE_SSE2 | CPUID_FEATURE_FXSR);
} else if (!strncmp("sse", fpu_arg, sizeof("sse"))) {
printf("no sse2\n");
- cpuid_cpu_info.cpuid_features &= ~(CPUID_FEATURE_SSE2);
+ cpuid_cpu_infop->cpuid_features &= ~(CPUID_FEATURE_SSE2);
}
}
checked = 1;
}
- return cpuid_cpu_info.cpuid_features;
+ return cpuid_cpu_infop->cpuid_features;
}
uint64_t
{
return cpuid_vmm_info()->cpuid_vmm_family;
}
+