X-Git-Url: https://git.ozlabs.org/?a=blobdiff_plain;f=ccan%2Fcpuid%2Fcpuid.h;h=bf6c5113fb589a1de54071be8a7fa5b21a2e5c1e;hb=0e528772db367034b41b693336ffee8bc765a62f;hp=8988949e553ccf47f67f059531450752fe1be923;hpb=e9a04de2da6fc022151e08904ce2a3d49b8ead27;p=ccan diff --git a/ccan/cpuid/cpuid.h b/ccan/cpuid/cpuid.h index 8988949e..bf6c5113 100644 --- a/ccan/cpuid/cpuid.h +++ b/ccan/cpuid/cpuid.h @@ -26,7 +26,7 @@ #include /** - * enum cpuid - stuff to get information on from the CPU. + * enum cpuid - stuff to get information about from the CPU. * * This is used as a parameter in cpuid(). * @@ -69,7 +69,7 @@ typedef enum cpuid { CPU_HIGHEST_EXTENDED_FUNCTION_SUPPORTED = 0x80000000, CPU_EXTENDED_PROC_INFO_FEATURE_BITS = 0x80000001, - CPU_PROC_BRAND_STRING = 0x80000002, + CPU_PROC_BRAND_STRING = 0x80000002, CPU_L1_CACHE_AND_TLB_IDS = 0x80000005, CPU_EXTENDED_L2_CACHE_FEATURES = 0x80000006, CPU_ADV_POWER_MGT_INFO = 0x80000007, @@ -124,14 +124,17 @@ typedef enum cputype { * * See also: cpuid_get_cpu_type_string() */ +#define is_intel_cpu() cpuid_get_cpu_type() == CT_INTEL +#define is_amd_cpu() cpuid_get_cpu_type() == CT_AMDK5 || cpuid_get_cpu_type() == CT_AMD cputype_t cpuid_get_cpu_type(void); /** - * cpuid_get_cpu_type_string - Get CPU Type string + * cpuid_sprintf_cputype - Get CPU Type string + * @cputype: a char of atleast 12 bytes in it. * - * Returns the CPU type string based off cputype_t. + * Returns true on success, false on failure */ -const char *cpuid_get_cpu_type_string(const cputype_t cputype); +bool cpuid_sprintf_cputype(const cputype_t cputype, char *buf); /** * cpuid_is_supported - test if the CPUID instruction is supported @@ -170,30 +173,54 @@ uint32_t cpuid_highest_ext_func_supported(void); * Returns a string into buf. * * For CPU_PROCINFO_AND_FEATUREBITS: - * buf[0]: - * - 3:0 - Stepping - * - 7:4 - Model - * - 11:8 - Family - * - 13:12 - Processor Type - * - 19:16 - Extended Model - * - 27:20 - Extended family - * buf[1] and buf[2]: + * buf[0]: Stepping + * buf[1]: Model + * buf[2]: Family + * buf[3]: Extended Model + * buf[4]: Extended Family + * buf[5] and buf[6]: * Feature flags - * buf[3]: + * buf[7]: * Additional feature information. * + * For CPU_L1_CACHE_AND_TLB_IDS: + * buf[0]: (eax): + * - 7..0 Number of times to exec cpuid to get all descriptors. + * - 15..8 Instruction TLB: 4K Pages, 4-way set associtive, 128 entries. + * - 23..16 Data TLB: 4k Pages, 4-way set associtive, 128 entries. + * - 24..31 Instruction TLB: 4K Pages, 4-way set associtive, 2 entries. + * buf[1]: (ebx): + * - 7..0 64-byte prefetching + * - 8..31 Null descriptor + * buf[2]: (ecx): + * - 0..31 Null descriptor + * buf[3]: (edx): + * - 7..0 2nd-level cache, 2M, 8-way set associtive, 64-byte line size + * - 15..8 1st-level instruction cache: 32K, 8-way set associtive, 64 byte line size + * - 16..23 Data TLB: 4M Pages, 4-way set associtive, 8 entires. + * - 24..31 1st-level data cache: 32K, 8-way set associtive, 64 byte line size + * * For CPU_HIGHEST_EXTENDED_FUNCTION_SUPPORTED: * Returns the highest supported function in *buf (expects an integer ofc) * * For CPU_EXTENDED_PROC_INFO_FEATURE_BITS: * Returns them in buf[0] and buf[1]. * + * For CPU_EXTENDED_L2_CACHE_FEATURES: + * buf[0]: Line size + * buf[1]: Associativity + * buf[2]: Cache size. + * * For CPU_VIRT_PHYS_ADDR_SIZES: - * Returns it as an integer in *buf. + * buf[0]: Physical + * buf[1]: Virtual * * For CPU_PROC_BRAND_STRING: * Have a char array with at least 48 bytes assigned to it. * + * Here's a page which will help you parse the data provided by this function. + * http://www.flounder.com/cpuid_explorer2.htm + * * If an invalid flag has been passed a 0xbaadf00d is returned in *buf. */ void cpuid(cpuid_t info, uint32_t *buf); @@ -249,4 +276,3 @@ bool cpuid_has_feature(int feature, bool extended); #endif #endif -