2006-03-21 Gwenole Beauchesne <gbeauchesne@mandriva.com> * Intel/cachesize.c (decode_Intel_caches_extended): Use cpuid(4) to get cache configuration descriptors. --- x86info-1.17/Intel/cachesize.c.intel-caches-cpuid4 2006-03-22 00:24:50.000000000 +0100 +++ x86info-1.17/Intel/cachesize.c 2006-03-22 00:55:04.000000000 +0100 @@ -179,6 +179,42 @@ static void decode_cache(struct cpudata } +void decode_Intel_caches_extended (struct cpudata *cpu, int output) +{ + int i; + unsigned long eax, ebx, ecx, edx; + + if (!output) + return; + + for (i = 0; /* break on no cache type */; i++) { + unsigned int N, T, W, P, L, S; + + cpuid_count (cpu->number, 4, i, &eax, &ebx, &ecx, &edx); + T = eax & 0x1f; + if (T == 0) + break; + + N = (eax >> 5) & 7; + W = 1 + ((ebx >> 22) & 0x3f); + P = 1 + ((ebx >> 12) & 0x1f); + L = 1 + (ebx & 0xfff); + S = (L * W * P * (1 + ecx)) / 1024; + + printf ("L%d %s cache:\n", N, + T == 1 ? "Data" : + T == 2 ? "Instruction" : + T == 3 ? "unified" : "<unknown>"); + printf ("\tSize: "); + if (S < 1024) + printf ("%dKB", S); + else + printf ("%dMB", S / 1024); + printf ("\t%d-way associative.\n", W); + printf ("\tline size=%d bytes.\n", L); + } +} + void decode_Intel_caches (struct cpudata *cpu, int output) { int i; @@ -189,10 +225,14 @@ void decode_Intel_caches (struct cpudata memset (&unknown_array, 0, sizeof(unknown_array)); decode_cache (cpu, TRACE_cache_table, output); - decode_cache (cpu, L1I_cache_table, output); - decode_cache (cpu, L1D_cache_table, output); - decode_cache (cpu, L2_cache_table, output); - decode_cache (cpu, L3_cache_table, output); + if (cpu->maxi >= 4) + decode_Intel_caches_extended (cpu, output); + else { + decode_cache (cpu, L1I_cache_table, output); + decode_cache (cpu, L1D_cache_table, output); + decode_cache (cpu, L2_cache_table, output); + decode_cache (cpu, L3_cache_table, output); + } decode_cache (cpu, ITLB_cache_table, output); if (found_unknown == 0)