annotate cpuinfo.c @ 36655:31bc4f268ac2

Cosmetic: Adjust indent.
author ib
date Sun, 26 Jan 2014 17:02:28 +0000
parents 514016233368
children
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 M_UNIX
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
36 typedef long long int64_t;
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
37 #define MISSING_USLEEP
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
38 #else
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
39 #include <inttypes.h>
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
40 #endif
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
41
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
42 #define CPUID_FEATURE_DEF(bit, desc, description) \
31077
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
43 { bit, desc }
22932
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
44
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
45 typedef struct cpuid_regs {
31077
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
46 unsigned int eax;
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
47 unsigned int ebx;
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
48 unsigned int ecx;
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
49 unsigned int edx;
22932
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
50 } cpuid_regs_t;
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
51
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
52 static cpuid_regs_t
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
53 cpuid(int func) {
31077
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
54 cpuid_regs_t regs;
22932
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
55 #define CPUID ".byte 0x0f, 0xa2; "
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
56 #ifdef __x86_64__
31077
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
57 __asm__("mov %%rbx, %%rsi\n\t"
22932
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
58 #else
31077
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
59 __asm__("mov %%ebx, %%esi\n\t"
22932
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
60 #endif
31077
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
61 CPUID"\n\t"
22932
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
62 #ifdef __x86_64__
31077
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
63 "xchg %%rsi, %%rbx\n\t"
22932
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
64 #else
31077
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
65 "xchg %%esi, %%ebx\n\t"
22932
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
66 #endif
31077
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
67 : "=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
68 : "0" (func));
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
69 return regs;
22932
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
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
72
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
73 static int64_t
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
74 rdtsc(void)
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
75 {
31077
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
76 uint32_t hi, lo;
22932
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
77 #define RDTSC ".byte 0x0f, 0x31; "
31077
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
78 __asm__ volatile (RDTSC : "=a"(lo), "=d"(hi) : );
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
79 return (uint64_t) hi << 32 | lo;
22932
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
80 }
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
81
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
82 static const char*
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
83 brandname(int i)
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
84 {
31077
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
85 static const char* brandmap[] = {
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
86 NULL,
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
87 "Intel(R) Celeron(R) processor",
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
88 "Intel(R) Pentium(R) III processor",
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
89 "Intel(R) Pentium(R) III Xeon(tm) processor",
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
90 "Intel(R) Pentium(R) III processor",
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
91 NULL,
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
92 "Mobile Intel(R) Pentium(R) III processor-M",
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
93 "Mobile Intel(R) Celeron(R) processor"
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
94 };
22932
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
95
31077
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
96 if (i >= sizeof(brandmap))
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
97 return NULL;
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
98 else
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
99 return brandmap[i];
22932
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
100 }
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
101
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
102 static void
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
103 store32(char *d, unsigned int v)
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
104 {
31077
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
105 d[0] = v & 0xff;
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
106 d[1] = (v >> 8) & 0xff;
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
107 d[2] = (v >> 16) & 0xff;
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
108 d[3] = (v >> 24) & 0xff;
22932
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
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
111
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
112 int
28599
3ff0da40013d cosmetics: Replace unused 'argc/argv' in main declarations by 'void'.
diego
parents: 28597
diff changeset
113 main(void)
22932
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
114 {
31077
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
115 cpuid_regs_t regs, regs_ext;
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
116 char idstr[13];
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
117 unsigned max_cpuid;
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
118 unsigned max_ext_cpuid;
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
119 unsigned int amd_flags;
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
120 unsigned int amd_flags2;
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
121 const char *model_name = NULL;
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
122 int i;
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
123 char processor_name[49];
22932
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
124
31077
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
125 regs = cpuid(0);
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
126 max_cpuid = regs.eax;
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
127 /* printf("%d CPUID function codes\n", max_cpuid+1); */
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 store32(idstr+0, regs.ebx);
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
130 store32(idstr+4, regs.edx);
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
131 store32(idstr+8, regs.ecx);
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
132 idstr[12] = 0;
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
133 printf("vendor_id\t: %s\n", idstr);
22932
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
134
31077
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
135 regs_ext = cpuid((1<<31) + 0);
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
136 max_ext_cpuid = regs_ext.eax;
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
137 if (max_ext_cpuid >= (1<<31) + 1) {
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
138 regs_ext = cpuid((1<<31) + 1);
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
139 amd_flags = regs_ext.edx;
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
140 amd_flags2 = regs_ext.ecx;
22932
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
141
31077
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
142 if (max_ext_cpuid >= (1<<31) + 4) {
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
143 for (i = 2; i <= 4; i++) {
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
144 regs_ext = cpuid((1<<31) + i);
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
145 store32(processor_name + (i-2)*16, regs_ext.eax);
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
146 store32(processor_name + (i-2)*16 + 4, regs_ext.ebx);
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
147 store32(processor_name + (i-2)*16 + 8, regs_ext.ecx);
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
148 store32(processor_name + (i-2)*16 + 12, regs_ext.edx);
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
149 }
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
150 processor_name[48] = 0;
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
151 model_name = processor_name;
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
152 while (*model_name == ' ') {
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
153 model_name++;
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
154 }
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
155 }
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
156 } else {
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
157 amd_flags = 0;
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
158 amd_flags2 = 0;
23346
932c22238e5d 10l: cosmetic: more trailing whitespaces removed
zuxy
parents: 23345
diff changeset
159 }
22932
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
160
31077
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
161 if (max_cpuid >= 1) {
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
162 static struct {
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
163 int bit;
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
164 char *desc;
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
165 } cap[] = {
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
166 CPUID_FEATURE_DEF(0, "fpu", "Floating-point unit on-chip"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
167 CPUID_FEATURE_DEF(1, "vme", "Virtual Mode Enhancements"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
168 CPUID_FEATURE_DEF(2, "de", "Debugging Extension"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
169 CPUID_FEATURE_DEF(3, "pse", "Page Size Extension"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
170 CPUID_FEATURE_DEF(4, "tsc", "Time Stamp Counter"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
171 CPUID_FEATURE_DEF(5, "msr", "Pentium Processor MSR"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
172 CPUID_FEATURE_DEF(6, "pae", "Physical Address Extension"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
173 CPUID_FEATURE_DEF(7, "mce", "Machine Check Exception"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
174 CPUID_FEATURE_DEF(8, "cx8", "CMPXCHG8B Instruction Supported"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
175 CPUID_FEATURE_DEF(9, "apic", "On-chip APIC Hardware Enabled"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
176 CPUID_FEATURE_DEF(11, "sep", "SYSENTER and SYSEXIT"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
177 CPUID_FEATURE_DEF(12, "mtrr", "Memory Type Range Registers"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
178 CPUID_FEATURE_DEF(13, "pge", "PTE Global Bit"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
179 CPUID_FEATURE_DEF(14, "mca", "Machine Check Architecture"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
180 CPUID_FEATURE_DEF(15, "cmov", "Conditional Move/Compare Instruction"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
181 CPUID_FEATURE_DEF(16, "pat", "Page Attribute Table"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
182 CPUID_FEATURE_DEF(17, "pse36", "Page Size Extension 36-bit"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
183 CPUID_FEATURE_DEF(18, "pn", "Processor Serial Number"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
184 CPUID_FEATURE_DEF(19, "clflush", "CFLUSH instruction"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
185 CPUID_FEATURE_DEF(21, "dts", "Debug Store"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
186 CPUID_FEATURE_DEF(22, "acpi", "Thermal Monitor and Clock Ctrl"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
187 CPUID_FEATURE_DEF(23, "mmx", "MMX Technology"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
188 CPUID_FEATURE_DEF(24, "fxsr", "FXSAVE/FXRSTOR"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
189 CPUID_FEATURE_DEF(25, "sse", "SSE Extensions"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
190 CPUID_FEATURE_DEF(26, "sse2", "SSE2 Extensions"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
191 CPUID_FEATURE_DEF(27, "ss", "Self Snoop"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
192 CPUID_FEATURE_DEF(28, "ht", "Multi-threading"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
193 CPUID_FEATURE_DEF(29, "tm", "Therm. Monitor"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
194 CPUID_FEATURE_DEF(30, "ia64", "IA-64 Processor"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
195 CPUID_FEATURE_DEF(31, "pbe", "Pend. Brk. EN."),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
196 { -1 }
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
197 };
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
198 static struct {
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
199 int bit;
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
200 char *desc;
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
201 } cap2[] = {
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
202 CPUID_FEATURE_DEF(0, "pni", "SSE3 Extensions"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
203 CPUID_FEATURE_DEF(1, "pclmulqdq", "Carryless Multiplication"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
204 CPUID_FEATURE_DEF(2, "dtes64", "64-bit Debug Store"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
205 CPUID_FEATURE_DEF(3, "monitor", "MONITOR/MWAIT"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
206 CPUID_FEATURE_DEF(4, "ds_cpl", "CPL Qualified Debug Store"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
207 CPUID_FEATURE_DEF(5, "vmx", "Virtual Machine Extensions"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
208 CPUID_FEATURE_DEF(6, "smx", "Safer Mode Extensions"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
209 CPUID_FEATURE_DEF(7, "est", "Enhanced Intel SpeedStep Technology"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
210 CPUID_FEATURE_DEF(8, "tm2", "Thermal Monitor 2"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
211 CPUID_FEATURE_DEF(9, "ssse3", "Supplemental SSE3"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
212 CPUID_FEATURE_DEF(10, "cid", "L1 Context ID"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
213 CPUID_FEATURE_DEF(12, "fma", "Fused Multiply Add"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
214 CPUID_FEATURE_DEF(13, "cx16", "CMPXCHG16B Available"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
215 CPUID_FEATURE_DEF(14, "xtpr", "xTPR Disable"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
216 CPUID_FEATURE_DEF(15, "pdcm", "Perf/Debug Capability MSR"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
217 CPUID_FEATURE_DEF(18, "dca", "Direct Cache Access"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
218 CPUID_FEATURE_DEF(19, "sse4_1", "SSE4.1 Extensions"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
219 CPUID_FEATURE_DEF(20, "sse4_2", "SSE4.2 Extensions"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
220 CPUID_FEATURE_DEF(21, "x2apic", "x2APIC Feature"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
221 CPUID_FEATURE_DEF(22, "movbe", "MOVBE Instruction"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
222 CPUID_FEATURE_DEF(23, "popcnt", "Pop Count Instruction"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
223 CPUID_FEATURE_DEF(25, "aes", "AES Instruction"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
224 CPUID_FEATURE_DEF(26, "xsave", "XSAVE/XRSTOR Extensions"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
225 CPUID_FEATURE_DEF(27, "osxsave", "XSAVE/XRSTOR Enabled in the OS"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
226 CPUID_FEATURE_DEF(28, "avx", "Advanced Vector Extension"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
227 { -1 }
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
228 };
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
229 static struct {
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
230 int bit;
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
231 char *desc;
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
232 } cap_amd[] = {
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
233 CPUID_FEATURE_DEF(11, "syscall", "SYSCALL and SYSRET"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
234 CPUID_FEATURE_DEF(19, "mp", "MP Capable"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
235 CPUID_FEATURE_DEF(20, "nx", "No-Execute Page Protection"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
236 CPUID_FEATURE_DEF(22, "mmxext", "MMX Technology (AMD Extensions)"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
237 CPUID_FEATURE_DEF(25, "fxsr_opt", "Fast FXSAVE/FXRSTOR"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
238 CPUID_FEATURE_DEF(26, "pdpe1gb", "PDP Entry for 1GiB Page"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
239 CPUID_FEATURE_DEF(27, "rdtscp", "RDTSCP Instruction"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
240 CPUID_FEATURE_DEF(29, "lm", "Long Mode Capable"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
241 CPUID_FEATURE_DEF(30, "3dnowext", "3DNow! Extensions"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
242 CPUID_FEATURE_DEF(31, "3dnow", "3DNow!"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
243 { -1 }
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
244 };
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
245 static struct {
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
246 int bit;
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
247 char *desc;
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
248 } cap_amd2[] = {
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
249 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
250 CPUID_FEATURE_DEF(1, "cmp_legacy", "Chip Multi-Core"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
251 CPUID_FEATURE_DEF(2, "svm", "Secure Virtual Machine"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
252 CPUID_FEATURE_DEF(3, "extapic", "Extended APIC Space"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
253 CPUID_FEATURE_DEF(4, "cr8_legacy", "CR8 Available in Legacy Mode"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
254 CPUID_FEATURE_DEF(5, "abm", "Advanced Bit Manipulation"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
255 CPUID_FEATURE_DEF(6, "sse4a", "SSE4A Extensions"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
256 CPUID_FEATURE_DEF(7, "misalignsse", "Misaligned SSE Mode"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
257 CPUID_FEATURE_DEF(8, "3dnowprefetch", "3DNow! Prefetch/PrefetchW"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
258 CPUID_FEATURE_DEF(9, "osvw", "OS Visible Workaround"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
259 CPUID_FEATURE_DEF(10, "ibs", "Instruction Based Sampling"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
260 CPUID_FEATURE_DEF(11, "sse5", "SSE5 Extensions"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
261 CPUID_FEATURE_DEF(12, "skinit", "SKINIT, STGI, and DEV Support"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
262 CPUID_FEATURE_DEF(13, "wdt", "Watchdog Timer Support"),
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
263 { -1 }
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
264 };
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
265 unsigned int family, model, stepping;
23346
932c22238e5d 10l: cosmetic: more trailing whitespaces removed
zuxy
parents: 23345
diff changeset
266
31077
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
267 regs = cpuid(1);
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
268 family = (regs.eax >> 8) & 0xf;
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
269 model = (regs.eax >> 4) & 0xf;
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
270 stepping = regs.eax & 0xf;
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
271
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
272 if (family == 0xf)
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
273 family += (regs.eax >> 20) & 0xff;
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
274 if (family == 0xf || family == 6)
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
275 model += ((regs.eax >> 16) & 0xf) << 4;
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
276
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
277 printf("cpu family\t: %d\n"
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
278 "model\t\t: %d\n"
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
279 "stepping\t: %d\n" ,
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
280 family,
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
281 model,
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
282 stepping);
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
283
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
284 if (strstr(idstr, "Intel") && !model_name) {
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
285 if (family == 6 && model == 0xb && stepping == 1)
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
286 model_name = "Intel (R) Celeron (R) processor";
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
287 else
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
288 model_name = brandname(regs.ebx & 0xf);
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
289 }
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
290
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
291 printf("flags\t\t:");
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
292 for (i = 0; cap[i].bit >= 0; i++) {
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
293 if (regs.edx & (1 << cap[i].bit)) {
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
294 printf(" %s", cap[i].desc);
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
295 }
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
296 }
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
297 for (i = 0; cap2[i].bit >= 0; i++) {
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
298 if (regs.ecx & (1 << cap2[i].bit)) {
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
299 printf(" %s", cap2[i].desc);
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 }
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
302 /* 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
303 it is not indicated by a CPUID feature bit, so we
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
304 have to check the family, model and stepping instead. */
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
305 if (strstr(idstr, "AMD") &&
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
306 family == 5 &&
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
307 (model >= 9 || (model == 8 && stepping >= 8)))
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
308 printf(" %s", "k6_mtrr");
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
309 /* similar for cyrix_arr. */
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
310 if (strstr(idstr, "Cyrix") &&
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
311 (family == 5 && (model < 4 || family == 6)))
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
312 printf(" %s", "cyrix_arr");
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
313 /* as well as centaur_mcr. */
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
314 if (strstr(idstr, "Centaur") &&
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
315 family == 5)
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
316 printf(" %s", "centaur_mcr");
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
317
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
318 for (i = 0; cap_amd[i].bit >= 0; i++) {
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
319 if (amd_flags & (1 << cap_amd[i].bit)) {
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
320 printf(" %s", cap_amd[i].desc);
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 }
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
323 for (i = 0; cap_amd2[i].bit >= 0; i++) {
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
324 if (amd_flags2 & (1 << cap_amd2[i].bit)) {
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
325 printf(" %s", cap_amd2[i].desc);
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 }
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
328 printf("\n");
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
329
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
330 if (regs.edx & (1 << 4)) {
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
331 int64_t tsc_start, tsc_end;
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
332 struct timeval tv_start, tv_end;
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
333 int usec_delay;
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
334
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
335 tsc_start = rdtsc();
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
336 gettimeofday(&tv_start, NULL);
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
337 #ifdef MISSING_USLEEP
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
338 sleep(1);
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
339 #else
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
340 usleep(100000);
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
341 #endif
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
342 tsc_end = rdtsc();
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
343 gettimeofday(&tv_end, NULL);
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
344
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
345 usec_delay = 1000000 * (tv_end.tv_sec - tv_start.tv_sec)
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
346 + (tv_end.tv_usec - tv_start.tv_usec);
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
347
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
348 printf("cpu MHz\t\t: %.3f\n",
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
349 (double)(tsc_end-tsc_start) / usec_delay);
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
350 }
22932
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
351 }
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
352
31077
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
353 printf("model name\t: ");
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
354 if (model_name)
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
355 printf("%s\n", model_name);
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
356 else
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30715
diff changeset
357 printf("Unknown %s CPU\n", idstr);
22932
d8cfd3a1300e Move TOOLS/cpuinfo.c into the root directory.
diego
parents:
diff changeset
358 }