Parent Directory | Revision Log
Revision 1.13 - (view) (download)
1 : | edgomez | 1.5 | ;/**************************************************************************** |
2 : | ; * | ||
3 : | ; * XVID MPEG-4 VIDEO CODEC | ||
4 : | ; * - CPUID check processors capabilities - | ||
5 : | ; * | ||
6 : | ; * Copyright (C) 2001 Michael Militzer <isibaar@xvid.org> | ||
7 : | ; * | ||
8 : | ; * This program is free software ; you can redistribute it and/or modify | ||
9 : | ; * it under the terms of the GNU General Public License as published by | ||
10 : | ; * the Free Software Foundation ; either version 2 of the License, or | ||
11 : | ; * (at your option) any later version. | ||
12 : | ; * | ||
13 : | ; * This program is distributed in the hope that it will be useful, | ||
14 : | ; * but WITHOUT ANY WARRANTY ; without even the implied warranty of | ||
15 : | ; * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
16 : | ; * GNU General Public License for more details. | ||
17 : | ; * | ||
18 : | ; * You should have received a copy of the GNU General Public License | ||
19 : | ; * along with this program ; if not, write to the Free Software | ||
20 : | ; * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
21 : | ; * | ||
22 : | Isibaar | 1.13 | ; * $Id: cpuid.asm,v 1.12 2008/08/19 09:06:48 Isibaar Exp $ |
23 : | edgomez | 1.5 | ; * |
24 : | ; ***************************************************************************/ | ||
25 : | Isibaar | 1.1 | |
26 : | edgomez | 1.5 | BITS 32 |
27 : | Isibaar | 1.1 | |
28 : | suxen_drol | 1.2 | %macro cglobal 1 |
29 : | Isibaar | 1.1 | %ifdef PREFIX |
30 : | edgomez | 1.8 | %ifdef MARK_FUNCS |
31 : | edgomez | 1.9 | global _%1:function %1.endfunc-%1 |
32 : | %define %1 _%1:function %1.endfunc-%1 | ||
33 : | Isibaar | 1.13 | %define ENDFUNC .endfunc |
34 : | edgomez | 1.8 | %else |
35 : | global _%1 | ||
36 : | %define %1 _%1 | ||
37 : | Isibaar | 1.13 | %define ENDFUNC |
38 : | edgomez | 1.8 | %endif |
39 : | Isibaar | 1.1 | %else |
40 : | edgomez | 1.8 | %ifdef MARK_FUNCS |
41 : | edgomez | 1.9 | global %1:function %1.endfunc-%1 |
42 : | Isibaar | 1.13 | %define ENDFUNC .endfunc |
43 : | edgomez | 1.8 | %else |
44 : | global %1 | ||
45 : | Isibaar | 1.13 | %define ENDFUNC |
46 : | edgomez | 1.8 | %endif |
47 : | Isibaar | 1.1 | %endif |
48 : | %endmacro | ||
49 : | |||
50 : | edgomez | 1.5 | ;============================================================================= |
51 : | ; Constants | ||
52 : | ;============================================================================= | ||
53 : | |||
54 : | %define CPUID_TSC 0x00000010 | ||
55 : | %define CPUID_MMX 0x00800000 | ||
56 : | %define CPUID_SSE 0x02000000 | ||
57 : | %define CPUID_SSE2 0x04000000 | ||
58 : | Isibaar | 1.10 | %define CPUID_SSE3 0x00000001 |
59 : | edgomez | 1.5 | |
60 : | %define EXT_CPUID_3DNOW 0x80000000 | ||
61 : | %define EXT_CPUID_AMD_3DNOWEXT 0x40000000 | ||
62 : | %define EXT_CPUID_AMD_MMXEXT 0x00400000 | ||
63 : | |||
64 : | ;;; NB: Make sure these defines match the ones defined in xvid.h | ||
65 : | %define XVID_CPU_MMX (1<< 0) | ||
66 : | %define XVID_CPU_MMXEXT (1<< 1) | ||
67 : | %define XVID_CPU_SSE (1<< 2) | ||
68 : | %define XVID_CPU_SSE2 (1<< 3) | ||
69 : | Isibaar | 1.10 | %define XVID_CPU_SSE3 (1<< 8) |
70 : | edgomez | 1.5 | %define XVID_CPU_3DNOW (1<< 4) |
71 : | %define XVID_CPU_3DNOWEXT (1<< 5) | ||
72 : | %define XVID_CPU_TSC (1<< 6) | ||
73 : | |||
74 : | ;============================================================================= | ||
75 : | ; Read only data | ||
76 : | ;============================================================================= | ||
77 : | |||
78 : | Isibaar | 1.1 | ALIGN 32 |
79 : | edgomez | 1.5 | %ifdef FORMAT_COFF |
80 : | edgomez | 1.7 | SECTION .rodata |
81 : | edgomez | 1.5 | %else |
82 : | edgomez | 1.7 | SECTION .rodata align=16 |
83 : | edgomez | 1.5 | %endif |
84 : | |||
85 : | vendorAMD: | ||
86 : | db "AuthenticAMD" | ||
87 : | |||
88 : | ;============================================================================= | ||
89 : | ; Macros | ||
90 : | ;============================================================================= | ||
91 : | Isibaar | 1.1 | |
92 : | Isibaar | 1.11 | %macro CHECK_FEATURE 4 |
93 : | mov eax, %1 | ||
94 : | and eax, %4 | ||
95 : | neg eax | ||
96 : | sbb eax, eax | ||
97 : | and eax, %2 | ||
98 : | or %3, eax | ||
99 : | edgomez | 1.5 | %endmacro |
100 : | Isibaar | 1.1 | |
101 : | edgomez | 1.5 | ;============================================================================= |
102 : | ; Code | ||
103 : | ;============================================================================= | ||
104 : | Isibaar | 1.1 | |
105 : | edgomez | 1.5 | SECTION .text |
106 : | Isibaar | 1.1 | |
107 : | ; int check_cpu_feature(void) | ||
108 : | |||
109 : | cglobal check_cpu_features | ||
110 : | check_cpu_features: | ||
111 : | suxen_drol | 1.2 | |
112 : | edgomez | 1.5 | push ebx |
113 : | push esi | ||
114 : | push edi | ||
115 : | push ebp | ||
116 : | suxen_drol | 1.2 | |
117 : | edgomez | 1.6 | sub esp, 12 ; Stack space for vendor name |
118 : | |||
119 : | edgomez | 1.5 | xor ebp, ebp |
120 : | Isibaar | 1.1 | |
121 : | ; CPUID command ? | ||
122 : | edgomez | 1.5 | pushfd |
123 : | pop eax | ||
124 : | mov ecx, eax | ||
125 : | xor eax, 0x200000 | ||
126 : | push eax | ||
127 : | popfd | ||
128 : | pushfd | ||
129 : | pop eax | ||
130 : | cmp eax, ecx | ||
131 : | Isibaar | 1.1 | |
132 : | edgomez | 1.5 | jz near .cpu_quit ; no CPUID command -> exit |
133 : | Isibaar | 1.1 | |
134 : | |||
135 : | ; get vendor string, used later | ||
136 : | edgomez | 1.5 | xor eax, eax |
137 : | cpuid | ||
138 : | edgomez | 1.6 | mov [esp], ebx ; vendor string |
139 : | mov [esp+4], edx | ||
140 : | mov [esp+8], ecx | ||
141 : | edgomez | 1.5 | test eax, eax |
142 : | |||
143 : | jz near .cpu_quit | ||
144 : | |||
145 : | mov eax, 1 | ||
146 : | cpuid | ||
147 : | |||
148 : | ; RDTSC command ? | ||
149 : | Isibaar | 1.11 | CHECK_FEATURE CPUID_TSC, XVID_CPU_TSC, ebp, edx |
150 : | edgomez | 1.5 | |
151 : | ; MMX support ? | ||
152 : | Isibaar | 1.11 | CHECK_FEATURE CPUID_MMX, XVID_CPU_MMX, ebp, edx |
153 : | edgomez | 1.5 | |
154 : | ; SSE support ? | ||
155 : | Isibaar | 1.11 | CHECK_FEATURE CPUID_SSE, (XVID_CPU_MMXEXT|XVID_CPU_SSE), ebp, edx |
156 : | edgomez | 1.5 | |
157 : | ; SSE2 support? | ||
158 : | Isibaar | 1.11 | CHECK_FEATURE CPUID_SSE2, XVID_CPU_SSE2, ebp, edx |
159 : | edgomez | 1.5 | |
160 : | Isibaar | 1.10 | ; SSE3 support? |
161 : | Isibaar | 1.11 | CHECK_FEATURE CPUID_SSE3, XVID_CPU_SSE3, ebp, ecx |
162 : | Isibaar | 1.10 | |
163 : | edgomez | 1.5 | ; extended functions? |
164 : | mov eax, 0x80000000 | ||
165 : | cpuid | ||
166 : | cmp eax, 0x80000000 | ||
167 : | jbe near .cpu_quit | ||
168 : | |||
169 : | mov eax, 0x80000001 | ||
170 : | cpuid | ||
171 : | |||
172 : | ; AMD cpu ? | ||
173 : | lea esi, [vendorAMD] | ||
174 : | edgomez | 1.6 | lea edi, [esp] |
175 : | edgomez | 1.5 | mov ecx, 12 |
176 : | cld | ||
177 : | repe cmpsb | ||
178 : | jnz .cpu_quit | ||
179 : | Isibaar | 1.1 | |
180 : | edgomez | 1.5 | ; 3DNow! support ? |
181 : | Isibaar | 1.11 | CHECK_FEATURE EXT_CPUID_3DNOW, XVID_CPU_3DNOW, ebp, edx |
182 : | suxen_drol | 1.2 | |
183 : | edgomez | 1.5 | ; 3DNOW extended ? |
184 : | Isibaar | 1.11 | CHECK_FEATURE EXT_CPUID_AMD_3DNOWEXT, XVID_CPU_3DNOWEXT, ebp, edx |
185 : | Isibaar | 1.1 | |
186 : | edgomez | 1.5 | ; extended MMX ? |
187 : | Isibaar | 1.11 | CHECK_FEATURE EXT_CPUID_AMD_MMXEXT, XVID_CPU_MMXEXT, ebp, edx |
188 : | suxen_drol | 1.2 | |
189 : | .cpu_quit: | ||
190 : | |||
191 : | edgomez | 1.5 | mov eax, ebp |
192 : | suxen_drol | 1.2 | |
193 : | edgomez | 1.6 | add esp, 12 |
194 : | |||
195 : | edgomez | 1.5 | pop ebp |
196 : | pop edi | ||
197 : | pop esi | ||
198 : | pop ebx | ||
199 : | suxen_drol | 1.2 | |
200 : | edgomez | 1.5 | ret |
201 : | Isibaar | 1.13 | ENDFUNC |
202 : | suxen_drol | 1.2 | |
203 : | ; sse/sse2 operating support detection routines | ||
204 : | ; these will trigger an invalid instruction signal if not supported. | ||
205 : | edgomez | 1.5 | ALIGN 16 |
206 : | suxen_drol | 1.2 | cglobal sse_os_trigger |
207 : | sse_os_trigger: | ||
208 : | edgomez | 1.5 | xorps xmm0, xmm0 |
209 : | ret | ||
210 : | Isibaar | 1.13 | ENDFUNC |
211 : | suxen_drol | 1.2 | |
212 : | |||
213 : | edgomez | 1.5 | ALIGN 16 |
214 : | suxen_drol | 1.2 | cglobal sse2_os_trigger |
215 : | sse2_os_trigger: | ||
216 : | edgomez | 1.5 | xorpd xmm0, xmm0 |
217 : | ret | ||
218 : | Isibaar | 1.13 | ENDFUNC |
219 : | suxen_drol | 1.2 | |
220 : | edgomez | 1.4 | |
221 : | ; enter/exit mmx state | ||
222 : | edgomez | 1.5 | ALIGN 16 |
223 : | edgomez | 1.4 | cglobal emms_mmx |
224 : | emms_mmx: | ||
225 : | edgomez | 1.5 | emms |
226 : | ret | ||
227 : | Isibaar | 1.13 | ENDFUNC |
228 : | edgomez | 1.4 | |
229 : | ; faster enter/exit mmx state | ||
230 : | edgomez | 1.5 | ALIGN 16 |
231 : | edgomez | 1.4 | cglobal emms_3dn |
232 : | emms_3dn: | ||
233 : | edgomez | 1.5 | femms |
234 : | ret | ||
235 : | Isibaar | 1.13 | ENDFUNC |
236 : | edgomez | 1.9 | |
237 : | |||
238 : | Isibaar | 1.12 | |
239 : | %ifidn __OUTPUT_FORMAT__,elf | ||
240 : | section ".note.GNU-stack" noalloc noexec nowrite progbits | ||
241 : | %endif | ||
242 : |
No admin address has been configured | ViewVC Help |
Powered by ViewVC 1.0.4 |