comparison cpuinfo.c @ 23346:932c22238e5d

10l: cosmetic: more trailing whitespaces removed
author zuxy
date Mon, 21 May 2007 07:47:53 +0000
parents ec89cf1d721e
children 10ac5a193118
comparison
equal deleted inserted replaced
23345:ec89cf1d721e 23346:932c22238e5d
49 cpuid_regs_t regs; 49 cpuid_regs_t regs;
50 #define CPUID ".byte 0x0f, 0xa2; " 50 #define CPUID ".byte 0x0f, 0xa2; "
51 #ifdef __x86_64__ 51 #ifdef __x86_64__
52 asm("mov %%rbx, %%rsi\n\t" 52 asm("mov %%rbx, %%rsi\n\t"
53 #else 53 #else
54 asm("mov %%ebx, %%esi\n\t" 54 asm("mov %%ebx, %%esi\n\t"
55 #endif 55 #endif
56 CPUID"\n\t" 56 CPUID"\n\t"
57 #ifdef __x86_64__ 57 #ifdef __x86_64__
58 "xchg %%rsi, %%rbx\n\t" 58 "xchg %%rsi, %%rbx\n\t"
59 #else 59 #else
123 123
124 store32(idstr+0, regs.ebx); 124 store32(idstr+0, regs.ebx);
125 store32(idstr+4, regs.edx); 125 store32(idstr+4, regs.edx);
126 store32(idstr+8, regs.ecx); 126 store32(idstr+8, regs.ecx);
127 idstr[12] = 0; 127 idstr[12] = 0;
128 printf("vendor_id\t: %s\n", idstr); 128 printf("vendor_id\t: %s\n", idstr);
129 129
130 regs_ext = cpuid((1<<31) + 0); 130 regs_ext = cpuid((1<<31) + 0);
131 max_ext_cpuid = regs_ext.eax; 131 max_ext_cpuid = regs_ext.eax;
132 if (max_ext_cpuid >= (1<<31) + 1) { 132 if (max_ext_cpuid >= (1<<31) + 1) {
133 regs_ext = cpuid((1<<31) + 1); 133 regs_ext = cpuid((1<<31) + 1);
267 if (strstr(idstr, "Intel") && !model_name) { 267 if (strstr(idstr, "Intel") && !model_name) {
268 if (family == 6 && model == 0xb && stepping == 1) 268 if (family == 6 && model == 0xb && stepping == 1)
269 model_name = "Intel (R) Celeron (R) processor"; 269 model_name = "Intel (R) Celeron (R) processor";
270 else 270 else
271 model_name = brandname(regs.ebx & 0xf); 271 model_name = brandname(regs.ebx & 0xf);
272 } 272 }
273 273
274 printf("flags\t\t:"); 274 printf("flags\t\t:");
275 for (i = 0; cap[i].bit >= 0; i++) { 275 for (i = 0; cap[i].bit >= 0; i++) {
276 if (regs.edx & (1 << cap[i].bit)) { 276 if (regs.edx & (1 << cap[i].bit)) {
277 printf(" %s", cap[i].desc); 277 printf(" %s", cap[i].desc);
284 } 284 }
285 /* k6_mtrr is supported by some AMD K6-2/K6-III CPUs but 285 /* k6_mtrr is supported by some AMD K6-2/K6-III CPUs but
286 it is not indicated by a CPUID feature bit, so we 286 it is not indicated by a CPUID feature bit, so we
287 have to check the family, model and stepping instead. */ 287 have to check the family, model and stepping instead. */
288 if (strstr(idstr, "AMD") && 288 if (strstr(idstr, "AMD") &&
289 family == 5 && 289 family == 5 &&
290 (model >= 9 || model == 8 && stepping >= 8)) 290 (model >= 9 || model == 8 && stepping >= 8))
291 printf(" %s", "k6_mtrr"); 291 printf(" %s", "k6_mtrr");
292 /* similar for cyrix_arr. */ 292 /* similar for cyrix_arr. */
293 if (strstr(idstr, "Cyrix") && 293 if (strstr(idstr, "Cyrix") &&
294 (family == 5 && model < 4 || family == 6)) 294 (family == 5 && model < 4 || family == 6))
295 printf(" %s", "cyrix_arr"); 295 printf(" %s", "cyrix_arr");
296 /* as well as centaur_mcr. */ 296 /* as well as centaur_mcr. */
297 if (strstr(idstr, "Centaur") && 297 if (strstr(idstr, "Centaur") &&
298 family == 5) 298 family == 5)
299 printf(" %s", "centaur_mcr"); 299 printf(" %s", "centaur_mcr");
300 300
301 for (i = 0; cap_amd[i].bit >= 0; i++) { 301 for (i = 0; cap_amd[i].bit >= 0; i++) {
302 if (amd_flags & (1 << cap_amd[i].bit)) { 302 if (amd_flags & (1 << cap_amd[i].bit)) {
303 printf(" %s", cap_amd[i].desc); 303 printf(" %s", cap_amd[i].desc);
304 } 304 }
305 } 305 }
335 335
336 printf("model name\t: "); 336 printf("model name\t: ");
337 if (model_name) 337 if (model_name)
338 printf("%s\n", model_name); 338 printf("%s\n", model_name);
339 else 339 else
340 printf("Unknown %s CPU\n", idstr); 340 printf("Unknown %s CPU\n", idstr);
341 } 341 }