X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/bd504ef0e0b883cdd7917b73b3574eb9ce669905..22ba694c5857e62b5a553b1505dcf2e509177f28:/osfmk/i386/cpuid.c diff --git a/osfmk/i386/cpuid.c b/osfmk/i386/cpuid.c index 3ca38be8b..fb171c4dc 100644 --- a/osfmk/i386/cpuid.c +++ b/osfmk/i386/cpuid.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000-2006 Apple Computer, Inc. All rights reserved. + * Copyright (c) 2000-2012 Apple Inc. All rights reserved. * * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ * @@ -229,36 +229,15 @@ cpuid_leaf2_find(uint8_t value) * 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" @@ -752,11 +731,6 @@ cpuid_set_cpufamily(i386_cpu_info_t *info_p) 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; @@ -779,6 +753,7 @@ cpuid_set_cpufamily(i386_cpu_info_t *info_p) cpufamily = CPUFAMILY_INTEL_SANDYBRIDGE; break; case CPUID_MODEL_IVYBRIDGE: + case CPUID_MODEL_IVYBRIDGE_EP: cpufamily = CPUFAMILY_INTEL_IVYBRIDGE; break; case CPUID_MODEL_HASWELL: @@ -803,10 +778,6 @@ cpuid_set_info(void) { 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 */ @@ -819,7 +790,7 @@ cpuid_set_info(void) 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 @@ -850,7 +821,7 @@ cpuid_set_info(void) 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 { @@ -930,14 +901,14 @@ extfeature_map[] = { }, 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} @@ -970,6 +941,7 @@ cpuid_info(void) { /* 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; } @@ -1010,10 +982,10 @@ cpuid_feature_display( #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)); } } @@ -1032,8 +1004,8 @@ void 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); } } @@ -1074,15 +1046,15 @@ cpuid_features(void) 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 @@ -1163,3 +1135,4 @@ cpuid_vmm_family(void) { return cpuid_vmm_info()->cpuid_vmm_family; } +