annotate cpuinfo.c @ 33534:22c3241467b3

Remove function Normalize(). This function changed ARGB data as if it had been RGB24 data (not quite correctly) converted to ARGB with all colors transparent. Instead now, set the alpha channel for RGB24 data and leave ARGB data untouched. For X11, the alpha channel is disregarded, so both approaches are equal, but the new one is more intelligible as we get correct ARGB PNG data. For legacy reasons, all kind of fuchsia/magenta must be treated as transparent, because some skins are using at least both full opaque and full transparent fuchsia/magenta for transparency.
author ib
date Thu, 16 Jun 2011 11:19:15 +0000
parents dd7f15a3fb1b
children 514016233368
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
30429
c1a3f1bbba26 Add license header to all top-level files missing them.
diego
parents: 29072
diff changeset
1 /*
c1a3f1bbba26 Add license header to all top-level files missing them.
diego
parents: 29072
diff changeset
2 * small utility to extract CPU information
c1a3f1bbba26 Add license header to all top-level files missing them.
diego
parents: 29072
diff changeset
3 * Used by configure to set CPU optimization levels on some operating
c1a3f1bbba26 Add license header to all top-level files missing them.
diego
parents: 29072
diff changeset
4 * systems where /proc/cpuinfo is non-existent or unreliable.
c1a3f1bbba26 Add license header to all top-level files missing them.
diego
parents: 29072
diff changeset
5 *
c1a3f1bbba26 Add license header to all top-level files missing them.
diego
parents: 29072
diff changeset
6 * This file is part of MPlayer.
c1a3f1bbba26 Add license header to all top-level files missing them.
diego
parents: 29072
diff changeset
7 *
c1a3f1bbba26 Add license header to all top-level files missing them.
diego
parents: 29072
diff changeset
8 * MPlayer is free software; you can redistribute it and/or modify
c1a3f1bbba26 Add license header to all top-level files missing them.
diego
parents: 29072
diff changeset
9 * it under the terms of the GNU General Public License as published by
c1a3f1bbba26 Add license header to all top-level files missing them.
diego
parents: 29072
diff changeset
10 * the Free Software Foundation; either version 2 of the License, or
c1a3f1bbba26 Add license header to all top-level files missing them.
diego
parents: 29072
diff changeset
11 * (at your option) any later version.
c1a3f1bbba26 Add license header to all top-level files missing them.
diego
parents: 29072
diff changeset
12 *
c1a3f1bbba26 Add license header to all top-level files missing them.
diego
parents: 29072
diff changeset
13 * MPlayer is distributed in the hope that it will be useful,
c1a3f1bbba26 Add license header to all top-level files missing them.
diego
parents: 29072
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
c1a3f1bbba26 Add license header to all top-level files missing them.
diego
parents: 29072
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
c1a3f1bbba26 Add license header to all top-level files missing them.
diego
parents: 29072
diff changeset
16 * GNU General Public License for more details.
c1a3f1bbba26 Add license header to all top-level files missing them.
diego
parents: 29072
diff changeset
17 *
c1a3f1bbba26 Add license header to all top-level files missing them.
diego
parents: 29072
diff changeset
18 * You should have received a copy of the GNU General Public License along
c1a3f1bbba26 Add license header to all top-level files missing them.
diego
parents: 29072
diff changeset
19 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
c1a3f1bbba26 Add license header to all top-level files missing them.
diego
parents: 29072
diff changeset
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
c1a3f1bbba26 Add license header to all top-level files missing them.
diego
parents: 29072
diff changeset
21 */
22932
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
22
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
23 #include <stdio.h>
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
24 #include <sys/time.h>
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
25 #include <stdlib.h>
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
26 #include <string.h>
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
27 #include <unistd.h>
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
28
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
29 #ifdef __MINGW32__
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
30 #define MISSING_USLEEP
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
31 #include <windows.h>
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
32 #define sleep(t) Sleep(1000*t);
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
33 #endif
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
34
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
35 #ifdef __BEOS__
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
36 #define usleep(t) snooze(t)
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
37 #endif
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
38
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
39 #ifdef M_UNIX
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
40 typedef long long int64_t;
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
41 #define MISSING_USLEEP
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
42 #else
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
43 #include <inttypes.h>
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
44 #endif
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
45
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
46 #define CPUID_FEATURE_DEF(bit, desc, description) \
31077
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
47 { bit, desc }
22932
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
48
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
49 typedef struct cpuid_regs {
31077
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
50 unsigned int eax;
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
51 unsigned int ebx;
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
52 unsigned int ecx;
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
53 unsigned int edx;
22932
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
54 } cpuid_regs_t;
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
55
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
56 static cpuid_regs_t
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
57 cpuid(int func) {
31077
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
58 cpuid_regs_t regs;
22932
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
59 #define CPUID ".byte 0x0f, 0xa2; "
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
60 #ifdef __x86_64__
31077
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
61 __asm__("mov %%rbx, %%rsi\n\t"
22932
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
62 #else
31077
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
63 __asm__("mov %%ebx, %%esi\n\t"
22932
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
64 #endif
31077
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
65 CPUID"\n\t"
22932
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
66 #ifdef __x86_64__
31077
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
67 "xchg %%rsi, %%rbx\n\t"
22932
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
68 #else
31077
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
69 "xchg %%esi, %%ebx\n\t"
22932
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
70 #endif
31077
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
71 : "=a" (regs.eax), "=S" (regs.ebx), "=c" (regs.ecx), "=d" (regs.edx)
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
72 : "0" (func));
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
73 return regs;
22932
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
74 }
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 int64_t
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
78 rdtsc(void)
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
79 {
31077
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
80 uint32_t hi, lo;
22932
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
81 #define RDTSC ".byte 0x0f, 0x31; "
31077
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
82 __asm__ volatile (RDTSC : "=a"(lo), "=d"(hi) : );
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
83 return (uint64_t) hi << 32 | lo;
22932
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
84 }
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
85
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
86 static const char*
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
87 brandname(int i)
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
88 {
31077
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
89 static const char* brandmap[] = {
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
90 NULL,
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
91 "Intel(R) Celeron(R) processor",
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
92 "Intel(R) Pentium(R) III processor",
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
93 "Intel(R) Pentium(R) III Xeon(tm) processor",
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
94 "Intel(R) Pentium(R) III processor",
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
95 NULL,
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
96 "Mobile Intel(R) Pentium(R) III processor-M",
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
97 "Mobile Intel(R) Celeron(R) processor"
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
98 };
22932
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
99
31077
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
100 if (i >= sizeof(brandmap))
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
101 return NULL;
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
102 else
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
103 return brandmap[i];
22932
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 static void
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
107 store32(char *d, unsigned int v)
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
108 {
31077
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
109 d[0] = v & 0xff;
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
110 d[1] = (v >> 8) & 0xff;
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
111 d[2] = (v >> 16) & 0xff;
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
112 d[3] = (v >> 24) & 0xff;
22932
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
113 }
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
114
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
115
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
116 int
28599
3ff0da40013d cosmetics: Replace unused 'argc/argv' in main declarations by 'void'.
diego
parents: 28597
diff changeset
117 main(void)
22932
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
118 {
31077
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
119 cpuid_regs_t regs, regs_ext;
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
120 char idstr[13];
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
121 unsigned max_cpuid;
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
122 unsigned max_ext_cpuid;
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
123 unsigned int amd_flags;
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
124 unsigned int amd_flags2;
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
125 const char *model_name = NULL;
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
126 int i;
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
127 char processor_name[49];
22932
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
128
31077
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
129 regs = cpuid(0);
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
130 max_cpuid = regs.eax;
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
131 /* printf("%d CPUID function codes\n", max_cpuid+1); */
22932
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
132
31077
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
133 store32(idstr+0, regs.ebx);
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
134 store32(idstr+4, regs.edx);
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
135 store32(idstr+8, regs.ecx);
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
136 idstr[12] = 0;
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
137 printf("vendor_id\t: %s\n", idstr);
22932
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
138
31077
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
139 regs_ext = cpuid((1<<31) + 0);
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
140 max_ext_cpuid = regs_ext.eax;
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
141 if (max_ext_cpuid >= (1<<31) + 1) {
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
142 regs_ext = cpuid((1<<31) + 1);
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
143 amd_flags = regs_ext.edx;
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
144 amd_flags2 = regs_ext.ecx;
22932
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
145
31077
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
146 if (max_ext_cpuid >= (1<<31) + 4) {
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
147 for (i = 2; i <= 4; i++) {
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
148 regs_ext = cpuid((1<<31) + i);
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
149 store32(processor_name + (i-2)*16, regs_ext.eax);
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
150 store32(processor_name + (i-2)*16 + 4, regs_ext.ebx);
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
151 store32(processor_name + (i-2)*16 + 8, regs_ext.ecx);
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
152 store32(processor_name + (i-2)*16 + 12, regs_ext.edx);
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
153 }
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
154 processor_name[48] = 0;
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
155 model_name = processor_name;
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
156 while (*model_name == ' ') {
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
157 model_name++;
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
158 }
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
159 }
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
160 } else {
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
161 amd_flags = 0;
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
162 amd_flags2 = 0;
23346
932c22238e5d 10l: cosmetic: more trailing whitespaces removed
zuxy
parents: 23345
diff changeset
163 }
22932
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
164
31077
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
165 if (max_cpuid >= 1) {
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
166 static struct {
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
167 int bit;
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
168 char *desc;
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
169 } cap[] = {
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
170 CPUID_FEATURE_DEF(0, "fpu", "Floating-point unit on-chip"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
171 CPUID_FEATURE_DEF(1, "vme", "Virtual Mode Enhancements"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
172 CPUID_FEATURE_DEF(2, "de", "Debugging Extension"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
173 CPUID_FEATURE_DEF(3, "pse", "Page Size Extension"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
174 CPUID_FEATURE_DEF(4, "tsc", "Time Stamp Counter"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
175 CPUID_FEATURE_DEF(5, "msr", "Pentium Processor MSR"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
176 CPUID_FEATURE_DEF(6, "pae", "Physical Address Extension"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
177 CPUID_FEATURE_DEF(7, "mce", "Machine Check Exception"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
178 CPUID_FEATURE_DEF(8, "cx8", "CMPXCHG8B Instruction Supported"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
179 CPUID_FEATURE_DEF(9, "apic", "On-chip APIC Hardware Enabled"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
180 CPUID_FEATURE_DEF(11, "sep", "SYSENTER and SYSEXIT"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
181 CPUID_FEATURE_DEF(12, "mtrr", "Memory Type Range Registers"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
182 CPUID_FEATURE_DEF(13, "pge", "PTE Global Bit"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
183 CPUID_FEATURE_DEF(14, "mca", "Machine Check Architecture"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
184 CPUID_FEATURE_DEF(15, "cmov", "Conditional Move/Compare Instruction"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
185 CPUID_FEATURE_DEF(16, "pat", "Page Attribute Table"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
186 CPUID_FEATURE_DEF(17, "pse36", "Page Size Extension 36-bit"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
187 CPUID_FEATURE_DEF(18, "pn", "Processor Serial Number"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
188 CPUID_FEATURE_DEF(19, "clflush", "CFLUSH instruction"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
189 CPUID_FEATURE_DEF(21, "dts", "Debug Store"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
190 CPUID_FEATURE_DEF(22, "acpi", "Thermal Monitor and Clock Ctrl"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
191 CPUID_FEATURE_DEF(23, "mmx", "MMX Technology"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
192 CPUID_FEATURE_DEF(24, "fxsr", "FXSAVE/FXRSTOR"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
193 CPUID_FEATURE_DEF(25, "sse", "SSE Extensions"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
194 CPUID_FEATURE_DEF(26, "sse2", "SSE2 Extensions"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
195 CPUID_FEATURE_DEF(27, "ss", "Self Snoop"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
196 CPUID_FEATURE_DEF(28, "ht", "Multi-threading"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
197 CPUID_FEATURE_DEF(29, "tm", "Therm. Monitor"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
198 CPUID_FEATURE_DEF(30, "ia64", "IA-64 Processor"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
199 CPUID_FEATURE_DEF(31, "pbe", "Pend. Brk. EN."),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
200 { -1 }
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
201 };
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
202 static struct {
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
203 int bit;
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
204 char *desc;
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
205 } cap2[] = {
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
206 CPUID_FEATURE_DEF(0, "pni", "SSE3 Extensions"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
207 CPUID_FEATURE_DEF(1, "pclmulqdq", "Carryless Multiplication"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
208 CPUID_FEATURE_DEF(2, "dtes64", "64-bit Debug Store"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
209 CPUID_FEATURE_DEF(3, "monitor", "MONITOR/MWAIT"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
210 CPUID_FEATURE_DEF(4, "ds_cpl", "CPL Qualified Debug Store"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
211 CPUID_FEATURE_DEF(5, "vmx", "Virtual Machine Extensions"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
212 CPUID_FEATURE_DEF(6, "smx", "Safer Mode Extensions"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
213 CPUID_FEATURE_DEF(7, "est", "Enhanced Intel SpeedStep Technology"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
214 CPUID_FEATURE_DEF(8, "tm2", "Thermal Monitor 2"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
215 CPUID_FEATURE_DEF(9, "ssse3", "Supplemental SSE3"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
216 CPUID_FEATURE_DEF(10, "cid", "L1 Context ID"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
217 CPUID_FEATURE_DEF(12, "fma", "Fused Multiply Add"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
218 CPUID_FEATURE_DEF(13, "cx16", "CMPXCHG16B Available"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
219 CPUID_FEATURE_DEF(14, "xtpr", "xTPR Disable"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
220 CPUID_FEATURE_DEF(15, "pdcm", "Perf/Debug Capability MSR"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
221 CPUID_FEATURE_DEF(18, "dca", "Direct Cache Access"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
222 CPUID_FEATURE_DEF(19, "sse4_1", "SSE4.1 Extensions"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
223 CPUID_FEATURE_DEF(20, "sse4_2", "SSE4.2 Extensions"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
224 CPUID_FEATURE_DEF(21, "x2apic", "x2APIC Feature"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
225 CPUID_FEATURE_DEF(22, "movbe", "MOVBE Instruction"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
226 CPUID_FEATURE_DEF(23, "popcnt", "Pop Count Instruction"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
227 CPUID_FEATURE_DEF(25, "aes", "AES Instruction"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
228 CPUID_FEATURE_DEF(26, "xsave", "XSAVE/XRSTOR Extensions"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
229 CPUID_FEATURE_DEF(27, "osxsave", "XSAVE/XRSTOR Enabled in the OS"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
230 CPUID_FEATURE_DEF(28, "avx", "Advanced Vector Extension"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
231 { -1 }
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
232 };
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
233 static struct {
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
234 int bit;
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
235 char *desc;
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
236 } cap_amd[] = {
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
237 CPUID_FEATURE_DEF(11, "syscall", "SYSCALL and SYSRET"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
238 CPUID_FEATURE_DEF(19, "mp", "MP Capable"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
239 CPUID_FEATURE_DEF(20, "nx", "No-Execute Page Protection"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
240 CPUID_FEATURE_DEF(22, "mmxext", "MMX Technology (AMD Extensions)"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
241 CPUID_FEATURE_DEF(25, "fxsr_opt", "Fast FXSAVE/FXRSTOR"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
242 CPUID_FEATURE_DEF(26, "pdpe1gb", "PDP Entry for 1GiB Page"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
243 CPUID_FEATURE_DEF(27, "rdtscp", "RDTSCP Instruction"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
244 CPUID_FEATURE_DEF(29, "lm", "Long Mode Capable"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
245 CPUID_FEATURE_DEF(30, "3dnowext", "3DNow! Extensions"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
246 CPUID_FEATURE_DEF(31, "3dnow", "3DNow!"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
247 { -1 }
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
248 };
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
249 static struct {
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
250 int bit;
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
251 char *desc;
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
252 } cap_amd2[] = {
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
253 CPUID_FEATURE_DEF(0, "lahf_lm", "LAHF/SAHF Supported in 64-bit Mode"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
254 CPUID_FEATURE_DEF(1, "cmp_legacy", "Chip Multi-Core"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
255 CPUID_FEATURE_DEF(2, "svm", "Secure Virtual Machine"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
256 CPUID_FEATURE_DEF(3, "extapic", "Extended APIC Space"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
257 CPUID_FEATURE_DEF(4, "cr8_legacy", "CR8 Available in Legacy Mode"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
258 CPUID_FEATURE_DEF(5, "abm", "Advanced Bit Manipulation"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
259 CPUID_FEATURE_DEF(6, "sse4a", "SSE4A Extensions"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
260 CPUID_FEATURE_DEF(7, "misalignsse", "Misaligned SSE Mode"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
261 CPUID_FEATURE_DEF(8, "3dnowprefetch", "3DNow! Prefetch/PrefetchW"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
262 CPUID_FEATURE_DEF(9, "osvw", "OS Visible Workaround"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
263 CPUID_FEATURE_DEF(10, "ibs", "Instruction Based Sampling"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
264 CPUID_FEATURE_DEF(11, "sse5", "SSE5 Extensions"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
265 CPUID_FEATURE_DEF(12, "skinit", "SKINIT, STGI, and DEV Support"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
266 CPUID_FEATURE_DEF(13, "wdt", "Watchdog Timer Support"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
267 { -1 }
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
268 };
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
269 unsigned int family, model, stepping;
23346
932c22238e5d 10l: cosmetic: more trailing whitespaces removed
zuxy
parents: 23345
diff changeset
270
31077
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
271 regs = cpuid(1);
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
272 family = (regs.eax >> 8) & 0xf;
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
273 model = (regs.eax >> 4) & 0xf;
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
274 stepping = regs.eax & 0xf;
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
275
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
276 if (family == 0xf)
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
277 family += (regs.eax >> 20) & 0xff;
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
278 if (family == 0xf || family == 6)
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
279 model += ((regs.eax >> 16) & 0xf) << 4;
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
280
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
281 printf("cpu family\t: %d\n"
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
282 "model\t\t: %d\n"
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
283 "stepping\t: %d\n" ,
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
284 family,
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
285 model,
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
286 stepping);
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
287
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
288 if (strstr(idstr, "Intel") && !model_name) {
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
289 if (family == 6 && model == 0xb && stepping == 1)
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
290 model_name = "Intel (R) Celeron (R) processor";
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
291 else
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
292 model_name = brandname(regs.ebx & 0xf);
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
293 }
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
294
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
295 printf("flags\t\t:");
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
296 for (i = 0; cap[i].bit >= 0; i++) {
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
297 if (regs.edx & (1 << cap[i].bit)) {
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
298 printf(" %s", cap[i].desc);
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
299 }
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
300 }
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
301 for (i = 0; cap2[i].bit >= 0; i++) {
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
302 if (regs.ecx & (1 << cap2[i].bit)) {
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
303 printf(" %s", cap2[i].desc);
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
304 }
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
305 }
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
306 /* k6_mtrr is supported by some AMD K6-2/K6-III CPUs but
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
307 it is not indicated by a CPUID feature bit, so we
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
308 have to check the family, model and stepping instead. */
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
309 if (strstr(idstr, "AMD") &&
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
310 family == 5 &&
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
311 (model >= 9 || (model == 8 && stepping >= 8)))
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
312 printf(" %s", "k6_mtrr");
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
313 /* similar for cyrix_arr. */
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
314 if (strstr(idstr, "Cyrix") &&
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
315 (family == 5 && (model < 4 || family == 6)))
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
316 printf(" %s", "cyrix_arr");
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
317 /* as well as centaur_mcr. */
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
318 if (strstr(idstr, "Centaur") &&
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
319 family == 5)
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
320 printf(" %s", "centaur_mcr");
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
321
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
322 for (i = 0; cap_amd[i].bit >= 0; i++) {
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
323 if (amd_flags & (1 << cap_amd[i].bit)) {
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
324 printf(" %s", cap_amd[i].desc);
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
325 }
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
326 }
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
327 for (i = 0; cap_amd2[i].bit >= 0; i++) {
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
328 if (amd_flags2 & (1 << cap_amd2[i].bit)) {
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
329 printf(" %s", cap_amd2[i].desc);
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
330 }
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
331 }
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
332 printf("\n");
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
333
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
334 if (regs.edx & (1 << 4)) {
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
335 int64_t tsc_start, tsc_end;
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
336 struct timeval tv_start, tv_end;
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
337 int usec_delay;
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
338
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
339 tsc_start = rdtsc();
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
340 gettimeofday(&tv_start, NULL);
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
341 #ifdef MISSING_USLEEP
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
342 sleep(1);
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
343 #else
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
344 usleep(100000);
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
345 #endif
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
346 tsc_end = rdtsc();
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
347 gettimeofday(&tv_end, NULL);
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
348
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
349 usec_delay = 1000000 * (tv_end.tv_sec - tv_start.tv_sec)
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
350 + (tv_end.tv_usec - tv_start.tv_usec);
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
351
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
352 printf("cpu MHz\t\t: %.3f\n",
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
353 (double)(tsc_end-tsc_start) / usec_delay);
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
354 }
22932
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
355 }
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
356
31077
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
357 printf("model name\t: ");
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
358 if (model_name)
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
359 printf("%s\n", model_name);
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
360 else
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
361 printf("Unknown %s CPU\n", idstr);
22932
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
362 }