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