annotate cpuinfo.c @ 22949:6613c5397aba

Remove the .norecurse hack. It bloats the Makefile, adds maintenance burden, likely has no users and most of all does not work correctly anyway.
author diego
date Wed, 11 Apr 2007 07:16:04 +0000
parents d8cfd3a1300e
children 41d042563508
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
22932
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
1 /* small utility to extract CPU information
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
2 Used by configure to set CPU optimization levels on some operating
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
3 systems where /proc/cpuinfo is non-existent or unreliable. */
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
4
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
5 #include <stdio.h>
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
6 #include <sys/time.h>
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
7 #include <stdlib.h>
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
8 #include <string.h>
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
9 #include <unistd.h>
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
10
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
11 #if defined(__MINGW32__) && (__MINGW32_MAJOR_VERSION <= 3) && (__MINGW32_MINOR_VERSION < 10)
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
12 #include <sys/timeb.h>
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
13 void gettimeofday(struct timeval* t,void* timezone) {
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
14 struct timeb timebuffer;
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
15 ftime( &timebuffer );
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
16 t->tv_sec=timebuffer.time;
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
17 t->tv_usec=1000*timebuffer.millitm;
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
18 }
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
19 #endif
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
20 #ifdef __MINGW32__
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
21 #define MISSING_USLEEP
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
22 #include <windows.h>
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
23 #define sleep(t) Sleep(1000*t);
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
24 #endif
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
25
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
26 #ifdef __BEOS__
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
27 #define usleep(t) snooze(t)
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
28 #endif
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
29
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
30 #ifdef M_UNIX
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
31 typedef long long int64_t;
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
32 #define MISSING_USLEEP
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
33 #else
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
34 #include <inttypes.h>
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
35 #endif
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
36
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
37 #define CPUID_FEATURE_DEF(bit, desc, description) \
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
38 { bit, desc }
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
39
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
40 typedef struct cpuid_regs {
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
41 unsigned int eax;
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
42 unsigned int ebx;
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
43 unsigned int ecx;
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
44 unsigned int edx;
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
45 } cpuid_regs_t;
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
46
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
47 static cpuid_regs_t
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
48 cpuid(int func) {
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
49 cpuid_regs_t regs;
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
50 #define CPUID ".byte 0x0f, 0xa2; "
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
51 #ifdef __x86_64__
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
52 asm("mov %%rbx, %%rsi\n\t"
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
53 #else
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
54 asm("mov %%ebx, %%esi\n\t"
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
55 #endif
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
56 CPUID"\n\t"
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
57 #ifdef __x86_64__
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
58 "xchg %%rsi, %%rbx\n\t"
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
59 #else
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
60 "xchg %%esi, %%ebx\n\t"
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
61 #endif
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
62 : "=a" (regs.eax), "=S" (regs.ebx), "=c" (regs.ecx), "=d" (regs.edx)
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
63 : "0" (func));
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
64 return regs;
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
65 }
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
66
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
67
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
68 static int64_t
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
69 rdtsc(void)
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
70 {
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
71 uint64_t i;
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
72 #define RDTSC ".byte 0x0f, 0x31; "
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
73 asm volatile (RDTSC : "=A"(i) : );
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
74 return i;
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
75 }
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
76
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
77 static const char*
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
78 brandname(int i)
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
79 {
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
80 const static char* brandmap[] = {
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
81 NULL,
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
82 "Intel(R) Celeron(R) processor",
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
83 "Intel(R) Pentium(R) III processor",
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
84 "Intel(R) Pentium(R) III Xeon(tm) processor",
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
85 "Intel(R) Pentium(R) III processor",
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
86 NULL,
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
87 "Mobile Intel(R) Pentium(R) III processor-M",
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
88 "Mobile Intel(R) Celeron(R) processor"
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
89 };
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
90
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
91 if (i >= sizeof(brandmap))
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
92 return NULL;
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
93 else
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
94 return brandmap[i];
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
95 }
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
96
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
97 static void
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
98 store32(char *d, unsigned int v)
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
99 {
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
100 d[0] = v & 0xff;
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
101 d[1] = (v >> 8) & 0xff;
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
102 d[2] = (v >> 16) & 0xff;
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
103 d[3] = (v >> 24) & 0xff;
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
104 }
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
105
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
106
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
107 int
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
108 main(int argc, char **argv)
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
109 {
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
110 cpuid_regs_t regs, regs_ext;
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
111 char idstr[13];
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
112 unsigned max_cpuid;
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
113 unsigned max_ext_cpuid;
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
114 unsigned int amd_flags;
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
115 unsigned int amd_flags2;
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
116 const char *model_name = NULL;
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
117 int i;
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
118 char processor_name[49];
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
119
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
120 regs = cpuid(0);
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
121 max_cpuid = regs.eax;
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
122 /* printf("%d CPUID function codes\n", max_cpuid+1); */
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
123
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
124 store32(idstr+0, regs.ebx);
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
125 store32(idstr+4, regs.edx);
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
126 store32(idstr+8, regs.ecx);
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
127 idstr[12] = 0;
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
128 printf("vendor_id\t: %s\n", idstr);
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
129
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
130 regs_ext = cpuid((1<<31) + 0);
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
131 max_ext_cpuid = regs_ext.eax;
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
132 if (max_ext_cpuid >= (1<<31) + 1) {
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
133 regs_ext = cpuid((1<<31) + 1);
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
134 amd_flags = regs_ext.edx;
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
135 amd_flags2 = regs_ext.ecx;
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
136
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
137 if (max_ext_cpuid >= (1<<31) + 4) {
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
138 for (i = 2; i <= 4; i++) {
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
139 regs_ext = cpuid((1<<31) + i);
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
140 store32(processor_name + (i-2)*16, regs_ext.eax);
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
141 store32(processor_name + (i-2)*16 + 4, regs_ext.ebx);
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
142 store32(processor_name + (i-2)*16 + 8, regs_ext.ecx);
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
143 store32(processor_name + (i-2)*16 + 12, regs_ext.edx);
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
144 }
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
145 processor_name[48] = 0;
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
146 model_name = processor_name;
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
147 while (*model_name == ' ') {
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
148 model_name++;
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
149 }
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
150 }
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
151 } else {
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
152 amd_flags = 0;
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
153 amd_flags2 = 0;
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
154 }
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
155
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
156 if (max_cpuid >= 1) {
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
157 static struct {
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
158 int bit;
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
159 char *desc;
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
160 } cap[] = {
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
161 CPUID_FEATURE_DEF(0, "fpu", "Floating-point unit on-chip"),
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
162 CPUID_FEATURE_DEF(1, "vme", "Virtual Mode Enhancements"),
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
163 CPUID_FEATURE_DEF(2, "de", "Debugging Extension"),
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
164 CPUID_FEATURE_DEF(3, "pse", "Page Size Extension"),
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
165 CPUID_FEATURE_DEF(4, "tsc", "Time Stamp Counter"),
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
166 CPUID_FEATURE_DEF(5, "msr", "Pentium Processor MSR"),
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
167 CPUID_FEATURE_DEF(6, "pae", "Physical Address Extension"),
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
168 CPUID_FEATURE_DEF(7, "mce", "Machine Check Exception"),
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
169 CPUID_FEATURE_DEF(8, "cx8", "CMPXCHG8B Instruction Supported"),
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
170 CPUID_FEATURE_DEF(9, "apic", "On-chip APIC Hardware Enabled"),
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
171 CPUID_FEATURE_DEF(11, "sep", "SYSENTER and SYSEXIT"),
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
172 CPUID_FEATURE_DEF(12, "mtrr", "Memory Type Range Registers"),
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
173 CPUID_FEATURE_DEF(13, "pge", "PTE Global Bit"),
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
174 CPUID_FEATURE_DEF(14, "mca", "Machine Check Architecture"),
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
175 CPUID_FEATURE_DEF(15, "cmov", "Conditional Move/Compare Instruction"),
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
176 CPUID_FEATURE_DEF(16, "pat", "Page Attribute Table"),
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
177 CPUID_FEATURE_DEF(17, "pse36", "Page Size Extension 36-bit"),
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
178 CPUID_FEATURE_DEF(18, "pn", "Processor Serial Number"),
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
179 CPUID_FEATURE_DEF(19, "clflush", "CFLUSH instruction"),
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
180 CPUID_FEATURE_DEF(21, "dts", "Debug Store"),
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
181 CPUID_FEATURE_DEF(22, "acpi", "Thermal Monitor and Clock Ctrl"),
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
182 CPUID_FEATURE_DEF(23, "mmx", "MMX Technology"),
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
183 CPUID_FEATURE_DEF(24, "fxsr", "FXSAVE/FXRSTOR"),
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
184 CPUID_FEATURE_DEF(25, "sse", "SSE Extensions"),
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
185 CPUID_FEATURE_DEF(26, "sse2", "SSE2 Extensions"),
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
186 CPUID_FEATURE_DEF(27, "ss", "Self Snoop"),
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
187 CPUID_FEATURE_DEF(28, "ht", "Multi-threading"),
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
188 CPUID_FEATURE_DEF(29, "tm", "Therm. Monitor"),
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
189 CPUID_FEATURE_DEF(30, "ia64", "IA-64 Processor"),
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
190 CPUID_FEATURE_DEF(31, "pbe", "Pend. Brk. EN."),
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
191 { -1 }
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
192 };
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
193 static struct {
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
194 int bit;
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
195 char *desc;
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
196 } cap2[] = {
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
197 CPUID_FEATURE_DEF(0, "pni", "SSE3 Extensions"),
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
198 CPUID_FEATURE_DEF(3, "monitor", "MONITOR/MWAIT"),
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
199 CPUID_FEATURE_DEF(4, "ds_cpl", "CPL Qualified Debug Store"),
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
200 CPUID_FEATURE_DEF(5, "vmx", "Virtual Machine Extensions"),
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
201 CPUID_FEATURE_DEF(6, "smx", "Safer Mode Extensions"),
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
202 CPUID_FEATURE_DEF(7, "est", "Enhanced Intel SpeedStep Technology"),
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
203 CPUID_FEATURE_DEF(8, "tm2", "Thermal Monitor 2"),
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
204 CPUID_FEATURE_DEF(9, "ssse3", "Supplemental SSE3"),
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
205 CPUID_FEATURE_DEF(10, "cid", "L1 Context ID"),
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
206 CPUID_FEATURE_DEF(13, "cx16", "CMPXCHG16B Available"),
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
207 CPUID_FEATURE_DEF(14, "xtpr", "xTPR Disable"),
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
208 CPUID_FEATURE_DEF(18, "dca", "Direct Cache Access"),
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
209 { -1 }
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
210 };
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
211 static struct {
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
212 int bit;
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
213 char *desc;
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
214 } cap_amd[] = {
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
215 CPUID_FEATURE_DEF(11, "syscall", "SYSCALL and SYSRET"),
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
216 CPUID_FEATURE_DEF(19, "mp", "MP Capable"),
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
217 CPUID_FEATURE_DEF(20, "nx", "No-Execute Page Protection"),
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
218 CPUID_FEATURE_DEF(22, "mmxext", "MMX Technology (AMD Extensions)"),
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
219 CPUID_FEATURE_DEF(25, "fxsr_opt", "Fast FXSAVE/FXRSTOR"),
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
220 CPUID_FEATURE_DEF(27, "rdtscp", "RDTSCP Instruction"),
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
221 CPUID_FEATURE_DEF(29, "lm", "Long Mode Capable"),
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
222 CPUID_FEATURE_DEF(30, "3dnowext", "3DNow! Extensions"),
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
223 CPUID_FEATURE_DEF(31, "3dnow", "3DNow!"),
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
224 { -1 }
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
225 };
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
226 static struct {
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
227 int bit;
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
228 char *desc;
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
229 } cap_amd2[] = {
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
230 CPUID_FEATURE_DEF(0, "lahf_lm", "LAHF/SAHF Supported in 64-bit Mode"),
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
231 CPUID_FEATURE_DEF(1, "cmp_legacy", "Chip Multi-Core"),
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
232 CPUID_FEATURE_DEF(2, "svm", "Secure Virtual Machine"),
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
233 CPUID_FEATURE_DEF(4, "cr8legacy", "CR8 Available in Legacy Mode"),
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
234 { -1 }
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
235 };
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
236 unsigned int family, model, stepping;
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
237
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
238 regs = cpuid(1);
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
239 family = (regs.eax >> 8) & 0xf;
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
240 model = (regs.eax >> 4) & 0xf;
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
241 stepping = regs.eax & 0xf;
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
242
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
243 if (family == 0xf)
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
244 {
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
245 family += (regs.eax >> 20) & 0xff;
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
246 model += ((regs.eax >> 16) & 0xf) << 4;
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
247 }
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
248
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
249 printf("cpu family\t: %d\n"
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
250 "model\t\t: %d\n"
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
251 "stepping\t: %d\n" ,
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
252 family,
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
253 model,
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
254 stepping);
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
255
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
256 if (strstr(idstr, "Intel") && !model_name) {
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
257 if (family == 6 && model == 0xb && stepping == 1)
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
258 model_name = "Intel (R) Celeron (R) processor";
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
259 else
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
260 model_name = brandname(regs.ebx & 0xf);
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
261 }
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
262
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
263 printf("flags\t\t:");
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
264 for (i = 0; cap[i].bit >= 0; i++) {
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
265 if (regs.edx & (1 << cap[i].bit)) {
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
266 printf(" %s", cap[i].desc);
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
267 }
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
268 }
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
269 for (i = 0; cap2[i].bit >= 0; i++) {
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
270 if (regs.ecx & (1 << cap2[i].bit)) {
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
271 printf(" %s", cap2[i].desc);
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
272 }
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
273 }
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
274 /* k6_mtrr is supported by some AMD K6-2/K6-III CPUs but
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
275 it is not indicated by a CPUID feature bit, so we
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
276 have to check the family, model and stepping instead. */
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
277 if (strstr(idstr, "AMD") &&
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
278 family == 5 &&
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
279 (model >= 9 || model == 8 && stepping >= 8))
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
280 printf(" %s", "k6_mtrr");
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
281 /* similar for cyrix_arr. */
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
282 if (strstr(idstr, "Cyrix") &&
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
283 (family == 5 && model < 4 || family == 6))
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
284 printf(" %s", "cyrix_arr");
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
285 /* as well as centaur_mcr. */
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
286 if (strstr(idstr, "Centaur") &&
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
287 family == 5)
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
288 printf(" %s", "centaur_mcr");
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
289
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
290 for (i = 0; cap_amd[i].bit >= 0; i++) {
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
291 if (amd_flags & (1 << cap_amd[i].bit)) {
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
292 printf(" %s", cap_amd[i].desc);
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
293 }
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
294 }
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
295 for (i = 0; cap_amd2[i].bit >= 0; i++) {
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
296 if (amd_flags2 & (1 << cap_amd2[i].bit)) {
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
297 printf(" %s", cap_amd2[i].desc);
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
298 }
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
299 }
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
300 printf("\n");
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
301
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
302 if (regs.edx & (1 << 4)) {
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
303 int64_t tsc_start, tsc_end;
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
304 struct timeval tv_start, tv_end;
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
305 int usec_delay;
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
306
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
307 tsc_start = rdtsc();
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
308 gettimeofday(&tv_start, NULL);
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
309 #ifdef MISSING_USLEEP
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
310 sleep(1);
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
311 #else
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
312 usleep(100000);
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
313 #endif
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
314 tsc_end = rdtsc();
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
315 gettimeofday(&tv_end, NULL);
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
316
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
317 usec_delay = 1000000 * (tv_end.tv_sec - tv_start.tv_sec)
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
318 + (tv_end.tv_usec - tv_start.tv_usec);
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
319
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
320 printf("cpu MHz\t\t: %.3f\n",
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
321 (double)(tsc_end-tsc_start) / usec_delay);
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
322 }
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
323 }
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
324
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
325 printf("model name\t: ");
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
326 if (model_name)
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
327 printf("%s\n", model_name);
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
328 else
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
329 printf("Unknown %s CPU\n", idstr);
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
330 }