annotate TOOLS/cpuinfo.c @ 15308:e9865b828a89

LIBAVFORMAT_BUILD >= 4624
author michael
date Sun, 01 May 2005 02:03:58 +0000
parents c0bde085511c
children 0bfb87188015
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
12960
a85bfb689e62 Some explanation what the tool is good for added.
diego
parents: 11113
diff changeset
1 /* small utility to extract CPU information
a85bfb689e62 Some explanation what the tool is good for added.
diego
parents: 11113
diff changeset
2 Used by configure to set CPU optimization levels on some operating
a85bfb689e62 Some explanation what the tool is good for added.
diego
parents: 11113
diff changeset
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>
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
7
9764
f5c4c9bb9451 MINGW32 port
faust3
parents: 6686
diff changeset
8 #ifdef __MINGW32__
f5c4c9bb9451 MINGW32 port
faust3
parents: 6686
diff changeset
9 #include <sys/timeb.h>
f5c4c9bb9451 MINGW32 port
faust3
parents: 6686
diff changeset
10 void gettimeofday(struct timeval* t,void* timezone)
f5c4c9bb9451 MINGW32 port
faust3
parents: 6686
diff changeset
11 { struct timeb timebuffer;
f5c4c9bb9451 MINGW32 port
faust3
parents: 6686
diff changeset
12 ftime( &timebuffer );
f5c4c9bb9451 MINGW32 port
faust3
parents: 6686
diff changeset
13 t->tv_sec=timebuffer.time;
f5c4c9bb9451 MINGW32 port
faust3
parents: 6686
diff changeset
14 t->tv_usec=1000*timebuffer.millitm;
f5c4c9bb9451 MINGW32 port
faust3
parents: 6686
diff changeset
15 }
f5c4c9bb9451 MINGW32 port
faust3
parents: 6686
diff changeset
16 #define MISSING_USLEEP
f5c4c9bb9451 MINGW32 port
faust3
parents: 6686
diff changeset
17 #define sleep(t) _sleep(1000*t);
f5c4c9bb9451 MINGW32 port
faust3
parents: 6686
diff changeset
18 #endif
f5c4c9bb9451 MINGW32 port
faust3
parents: 6686
diff changeset
19
13612
c0bde085511c Zeta OS support, mostly working.
reimar
parents: 12960
diff changeset
20 #ifdef __BEOS__
c0bde085511c Zeta OS support, mostly working.
reimar
parents: 12960
diff changeset
21 #define usleep(t) snooze(t)
c0bde085511c Zeta OS support, mostly working.
reimar
parents: 12960
diff changeset
22 #endif
c0bde085511c Zeta OS support, mostly working.
reimar
parents: 12960
diff changeset
23
1038
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
24 #ifdef M_UNIX
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
25 typedef long long int64_t;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
26 #define MISSING_USLEEP
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
27 #else
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
28 #include <inttypes.h>
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
29 #endif
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
30
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
31
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
32 typedef struct cpuid_regs {
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
33 unsigned int eax;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
34 unsigned int ebx;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
35 unsigned int ecx;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
36 unsigned int edx;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
37 } cpuid_regs_t;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
38
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
39 static cpuid_regs_t
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
40 cpuid(int func) {
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
41 cpuid_regs_t regs;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
42 #define CPUID ".byte 0x0f, 0xa2; "
13612
c0bde085511c Zeta OS support, mostly working.
reimar
parents: 12960
diff changeset
43 asm("push %%ebx; "
c0bde085511c Zeta OS support, mostly working.
reimar
parents: 12960
diff changeset
44 "movl %4,%%eax; " CPUID
c0bde085511c Zeta OS support, mostly working.
reimar
parents: 12960
diff changeset
45 "movl %%eax,%0; movl %%ebx,%1; movl %%ecx,%2; movl %%edx,%3; "
c0bde085511c Zeta OS support, mostly working.
reimar
parents: 12960
diff changeset
46 "pop %%ebx"
1038
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
47 : "=m" (regs.eax), "=m" (regs.ebx), "=m" (regs.ecx), "=m" (regs.edx)
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
48 : "g" (func)
13612
c0bde085511c Zeta OS support, mostly working.
reimar
parents: 12960
diff changeset
49 : "%eax", "%ecx", "%edx");
1038
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
50 return regs;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
51 }
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
52
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
53
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
54 static int64_t
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
55 rdtsc(void)
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
56 {
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
57 unsigned int i, j;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
58 #define RDTSC ".byte 0x0f, 0x31; "
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
59 asm(RDTSC : "=a"(i), "=d"(j) : );
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
60 return ((int64_t)j<<32) + (int64_t)i;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
61 }
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 static void
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
65 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
66 {
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
67 d[0] = v & 0xff;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
68 d[1] = (v >> 8) & 0xff;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
69 d[2] = (v >> 16) & 0xff;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
70 d[3] = (v >> 24) & 0xff;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
71 }
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
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
74 int
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
75 main(int argc, char **argv)
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
76 {
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
77 cpuid_regs_t regs, regs_ext;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
78 char idstr[13];
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
79 unsigned max_cpuid;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
80 unsigned max_ext_cpuid;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
81 unsigned int amd_flags;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
82 char *model_name = "Unknown CPU";
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
83 int i;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
84 char processor_name[49];
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
85
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
86 regs = cpuid(0);
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
87 max_cpuid = regs.eax;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
88 /* printf("%d CPUID function codes\n", max_cpuid+1); */
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
89
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
90 store32(idstr+0, regs.ebx);
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
91 store32(idstr+4, regs.edx);
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
92 store32(idstr+8, regs.ecx);
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
93 idstr[12] = 0;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
94 printf("vendor_id\t: %s\n", idstr);
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
95
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
96 if (strcmp(idstr, "GenuineIntel") == 0)
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
97 model_name = "Unknown Intel CPU";
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
98 else if (strcmp(idstr, "AuthenticAMD") == 0)
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
99 model_name = "Unknown AMD CPU";
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
100
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
101 regs_ext = cpuid((1<<31) + 0);
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
102 max_ext_cpuid = regs_ext.eax;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
103 if (max_ext_cpuid >= (1<<31) + 1) {
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
104 regs_ext = cpuid((1<<31) + 1);
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
105 amd_flags = regs_ext.edx;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
106
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
107 if (max_ext_cpuid >= (1<<31) + 4) {
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
108 for (i = 2; i <= 4; i++) {
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
109 regs_ext = cpuid((1<<31) + i);
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
110 store32(processor_name + (i-2)*16, regs_ext.eax);
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
111 store32(processor_name + (i-2)*16 + 4, regs_ext.ebx);
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
112 store32(processor_name + (i-2)*16 + 8, regs_ext.ecx);
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
113 store32(processor_name + (i-2)*16 + 12, regs_ext.edx);
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
114 }
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
115 processor_name[48] = 0;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
116 model_name = processor_name;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
117 }
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
118 } else {
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
119 amd_flags = 0;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
120 }
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
121
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
122 if (max_cpuid >= 1) {
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
123 static struct {
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
124 int bit;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
125 char *desc;;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
126 char *description;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
127 } cap[] = {
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
128 { 0, "fpu", "Floating-point unit on-chip" },
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
129 { 1, "vme", "Virtual Mode Enhancements" },
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
130 { 2, "de", "Debugging Extension" },
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
131 { 3, "pse", "Page Size Extension" },
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
132 { 4, "tsc", "Time Stamp Counter" },
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
133 { 5, "msr", "Pentium Processor MSR" },
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
134 { 6, "pae", "Physical Address Extension" },
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
135 { 7, "mce", "Machine Check Exception" },
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
136 { 8, "cx8", "CMPXCHG8B Instruction Supported" },
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
137 { 9, "apic", "On-chip CPIC Hardware Enabled" },
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
138 { 11, "sep", "SYSENTER and SYSEXIT" },
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
139 { 12, "mtrr", "Memory Type Range Registers" },
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
140 { 13, "pge", "PTE Global Bit" },
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
141 { 14, "mca", "Machine Check Architecture" },
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
142 { 15, "cmov", "Conditional Move/Compare Instruction" },
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
143 { 16, "pat", "Page Attribute Table" },
6686
d7a83bb5fec9 minor fixes week at mcdonals: small fix pse->pse36
atmos4
parents: 1038
diff changeset
144 { 17, "pse36", "Page Size Extension 36-bit" },
1038
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
145 { 18, "psn", "Processor Serial Number" },
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
146 { 19, "cflsh", "CFLUSH instruction" },
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
147 { 21, "ds", "Debug Store" },
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
148 { 22, "acpi", "Thermal Monitor and Clock Ctrl" },
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
149 { 23, "mmx", "MMX Technology" },
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
150 { 24, "fxsr", "FXSAVE/FXRSTOR" },
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
151 { 25, "sse", "SSE Extensions" },
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
152 { 26, "sse2", "SSE2 Extensions" },
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
153 { 27, "ss", "Self Snoop" },
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
154 { 29, "tm", "Therm. Monitor" },
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
155 { -1 }
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
156 };
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
157 static struct {
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
158 int bit;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
159 char *desc;;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
160 char *description;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
161 } cap_amd[] = {
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
162 { 22, "mmxext","MMX Technology (AMD Extensions)" },
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
163 { 30, "3dnowext","3Dnow! Extensions" },
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
164 { 31, "3dnow", "3Dnow!" },
11113
d1a941c25b4d K6 MTRR support with a little help from Alex.
diego
parents: 9764
diff changeset
165 { 32, "k6_mtrr", "Memory Type Range Registers" },
1038
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
166 { -1 }
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
167 };
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
168 int i;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
169
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
170 regs = cpuid(1);
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
171 printf("cpu family\t: %d\n"
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
172 "model\t\t: %d\n"
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
173 "stepping\t: %d\n" ,
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
174 (regs.eax >> 8) & 0xf,
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
175 (regs.eax >> 4) & 0xf,
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
176 regs.eax & 0xf);
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
177
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
178 printf("flags\t\t:");
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
179 for (i = 0; cap[i].bit >= 0; i++) {
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
180 if (regs.edx & (1 << cap[i].bit)) {
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
181 printf(" %s", cap[i].desc);
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
182 }
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
183 }
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
184 for (i = 0; cap_amd[i].bit >= 0; i++) {
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
185 if (amd_flags & (1 << cap_amd[i].bit)) {
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
186 printf(" %s", cap_amd[i].desc);
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
187 }
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
188 }
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
189 printf("\n");
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
190
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
191 if (regs.edx & (1 << 4)) {
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
192 int64_t tsc_start, tsc_end;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
193 struct timeval tv_start, tv_end;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
194 int usec_delay;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
195
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
196 tsc_start = rdtsc();
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
197 gettimeofday(&tv_start, NULL);
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
198 #ifdef MISSING_USLEEP
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
199 sleep(1);
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
200 #else
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
201 usleep(100000);
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
202 #endif
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
203 tsc_end = rdtsc();
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
204 gettimeofday(&tv_end, NULL);
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
205
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
206 usec_delay = 1000000 * (tv_end.tv_sec - tv_start.tv_sec)
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
207 + (tv_end.tv_usec - tv_start.tv_usec);
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
208
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
209 printf("cpu MHz\t\t: %.3f\n",
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
210 (double)(tsc_end-tsc_start) / usec_delay);
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
211 }
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
212 }
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
213
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
214 printf("model name\t: %s\n", model_name);
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
215
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
216 exit(0);
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
diff changeset
217 }