1 |
;/****************************************************************************** |
;/**************************************************************************** |
2 |
; * * |
; * |
3 |
; * This file is part of XviD, a free MPEG-4 video encoder/decoder * |
; * XVID MPEG-4 VIDEO CODEC |
4 |
; * * |
; * - CPUID check processors capabilities - |
5 |
; * XviD is an implementation of a part of one or more MPEG-4 Video tools * |
; * |
6 |
; * as specified in ISO/IEC 14496-2 standard. Those intending to use this * |
; * Copyright (C) 2001 Michael Militzer <isibaar@xvid.org> |
7 |
; * software module in hardware or software products are advised that its * |
; * |
8 |
; * use may infringe existing patents or copyrights, and any such use * |
; * This program is free software ; you can redistribute it and/or modify |
9 |
; * would be at such party's own risk. The original developer of this * |
; * it under the terms of the GNU General Public License as published by |
10 |
; * software module and his/her company, and subsequent editors and their * |
; * the Free Software Foundation ; either version 2 of the License, or |
11 |
; * companies, will have no liability for use of this software or * |
; * (at your option) any later version. |
12 |
; * modifications or derivatives thereof. * |
; * |
13 |
; * * |
; * This program is distributed in the hope that it will be useful, |
14 |
; * XviD is free software; you can redistribute it and/or modify it * |
; * but WITHOUT ANY WARRANTY ; without even the implied warranty of |
15 |
; * under the terms of the GNU General Public License as published by * |
; * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 |
; * the Free Software Foundation; either version 2 of the License, or * |
; * GNU General Public License for more details. |
17 |
; * (at your option) any later version. * |
; * |
18 |
; * * |
; * You should have received a copy of the GNU General Public License |
19 |
; * XviD is distributed in the hope that it will be useful, but * |
; * along with this program ; if not, write to the Free Software |
20 |
; * WITHOUT ANY WARRANTY; without even the implied warranty of * |
; * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
21 |
; * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
; * |
22 |
; * GNU General Public License for more details. * |
; * $Id$ |
23 |
; * * |
; * |
24 |
; * You should have received a copy of the GNU General Public License * |
; ***************************************************************************/ |
|
; * along with this program; if not, write to the Free Software * |
|
|
; * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * |
|
|
; * * |
|
|
; ******************************************************************************/ |
|
|
; |
|
|
;/****************************************************************************** |
|
|
; * * |
|
|
; * cpuid.asm, check cpu features * |
|
|
; * * |
|
|
; * Copyright (C) 2001 - Michael Militzer <isibaar@xvid.org>, * |
|
|
; * * |
|
|
; * For more information visit the XviD homepage: http://www.xvid.org * |
|
|
; * * |
|
|
; ******************************************************************************/ |
|
|
; |
|
|
;/****************************************************************************** |
|
|
; * * |
|
|
; * Revision history: * |
|
|
; * * |
|
|
; * 17.12.2001 initial version (Isibaar) * |
|
|
; * * |
|
|
; ******************************************************************************/ |
|
25 |
|
|
26 |
bits 32 |
BITS 32 |
27 |
|
|
28 |
|
%macro cglobal 1 |
29 |
|
%ifdef PREFIX |
30 |
|
%ifdef MARK_FUNCS |
31 |
|
global _%1:function %1.endfunc-%1 |
32 |
|
%define %1 _%1:function %1.endfunc-%1 |
33 |
|
%else |
34 |
|
global _%1 |
35 |
|
%define %1 _%1 |
36 |
|
%endif |
37 |
|
%else |
38 |
|
%ifdef MARK_FUNCS |
39 |
|
global %1:function %1.endfunc-%1 |
40 |
|
%else |
41 |
|
global %1 |
42 |
|
%endif |
43 |
|
%endif |
44 |
|
%endmacro |
45 |
|
|
46 |
|
;============================================================================= |
47 |
|
; Constants |
48 |
|
;============================================================================= |
49 |
|
|
50 |
%define CPUID_TSC 0x00000010 |
%define CPUID_TSC 0x00000010 |
51 |
%define CPUID_MMX 0x00800000 |
%define CPUID_MMX 0x00800000 |
56 |
%define EXT_CPUID_AMD_3DNOWEXT 0x40000000 |
%define EXT_CPUID_AMD_3DNOWEXT 0x40000000 |
57 |
%define EXT_CPUID_AMD_MMXEXT 0x00400000 |
%define EXT_CPUID_AMD_MMXEXT 0x00400000 |
58 |
|
|
59 |
%define XVID_CPU_MMX 0x00000001 |
;;; NB: Make sure these defines match the ones defined in xvid.h |
60 |
%define XVID_CPU_MMXEXT 0x00000002 |
%define XVID_CPU_MMX (1<< 0) |
61 |
%define XVID_CPU_SSE 0x00000004 |
%define XVID_CPU_MMXEXT (1<< 1) |
62 |
%define XVID_CPU_SSE2 0x00000008 |
%define XVID_CPU_SSE (1<< 2) |
63 |
%define XVID_CPU_3DNOW 0x00000010 |
%define XVID_CPU_SSE2 (1<< 3) |
64 |
%define XVID_CPU_3DNOWEXT 0x00000020 |
%define XVID_CPU_3DNOW (1<< 4) |
65 |
%define XVID_CPU_TSC 0x00000040 |
%define XVID_CPU_3DNOWEXT (1<< 5) |
66 |
|
%define XVID_CPU_TSC (1<< 6) |
67 |
|
|
68 |
|
;============================================================================= |
69 |
|
; Read only data |
70 |
|
;============================================================================= |
71 |
|
|
72 |
|
ALIGN 32 |
73 |
%macro cglobal 1 |
%ifdef FORMAT_COFF |
74 |
%ifdef PREFIX |
SECTION .rodata |
|
global _%1 |
|
|
%define %1 _%1 |
|
75 |
%else |
%else |
76 |
global %1 |
SECTION .rodata align=16 |
77 |
%endif |
%endif |
|
%endmacro |
|
78 |
|
|
79 |
ALIGN 32 |
vendorAMD: |
80 |
|
db "AuthenticAMD" |
81 |
|
|
82 |
section .data |
;============================================================================= |
83 |
|
; Macros |
84 |
vendorAMD db "AuthenticAMD" |
;============================================================================= |
85 |
|
|
86 |
%macro CHECK_FEATURE 3 |
%macro CHECK_FEATURE 3 |
|
|
|
87 |
mov ecx, %1 |
mov ecx, %1 |
88 |
and ecx, edx |
and ecx, edx |
89 |
neg ecx |
neg ecx |
90 |
sbb ecx, ecx |
sbb ecx, ecx |
91 |
and ecx, %2 |
and ecx, %2 |
92 |
or %3, ecx |
or %3, ecx |
|
|
|
93 |
%endmacro |
%endmacro |
94 |
|
|
95 |
section .text |
;============================================================================= |
96 |
|
; Code |
97 |
|
;============================================================================= |
98 |
|
|
99 |
|
SECTION .text |
100 |
|
|
101 |
; int check_cpu_feature(void) |
; int check_cpu_feature(void) |
102 |
|
|
108 |
push edi |
push edi |
109 |
push ebp |
push ebp |
110 |
|
|
111 |
|
sub esp, 12 ; Stack space for vendor name |
112 |
|
|
113 |
xor ebp,ebp |
xor ebp,ebp |
114 |
|
|
115 |
; CPUID command ? |
; CPUID command ? |
129 |
; get vendor string, used later |
; get vendor string, used later |
130 |
xor eax, eax |
xor eax, eax |
131 |
cpuid |
cpuid |
132 |
mov [esp-12], ebx ; vendor string |
mov [esp], ebx ; vendor string |
133 |
mov [esp-12+4], edx |
mov [esp+4], edx |
134 |
mov [esp-12+8], ecx |
mov [esp+8], ecx |
135 |
test eax, eax |
test eax, eax |
136 |
|
|
137 |
jz near .cpu_quit |
jz near .cpu_quit |
162 |
|
|
163 |
; AMD cpu ? |
; AMD cpu ? |
164 |
lea esi, [vendorAMD] |
lea esi, [vendorAMD] |
165 |
lea edi, [esp-12] |
lea edi, [esp] |
166 |
mov ecx, 12 |
mov ecx, 12 |
167 |
cld |
cld |
168 |
repe cmpsb |
repe cmpsb |
181 |
|
|
182 |
mov eax, ebp |
mov eax, ebp |
183 |
|
|
184 |
|
add esp, 12 |
185 |
|
|
186 |
pop ebp |
pop ebp |
187 |
pop edi |
pop edi |
188 |
pop esi |
pop esi |
189 |
pop ebx |
pop ebx |
190 |
|
|
191 |
ret |
ret |
192 |
|
.endfunc |
|
|
|
193 |
|
|
194 |
; sse/sse2 operating support detection routines |
; sse/sse2 operating support detection routines |
195 |
; these will trigger an invalid instruction signal if not supported. |
; these will trigger an invalid instruction signal if not supported. |
196 |
|
ALIGN 16 |
197 |
cglobal sse_os_trigger |
cglobal sse_os_trigger |
|
align 16 |
|
198 |
sse_os_trigger: |
sse_os_trigger: |
199 |
xorps xmm0, xmm0 |
xorps xmm0, xmm0 |
200 |
ret |
ret |
201 |
|
.endfunc |
202 |
|
|
203 |
|
|
204 |
|
ALIGN 16 |
205 |
cglobal sse2_os_trigger |
cglobal sse2_os_trigger |
|
align 16 |
|
206 |
sse2_os_trigger: |
sse2_os_trigger: |
207 |
xorpd xmm0, xmm0 |
xorpd xmm0, xmm0 |
208 |
ret |
ret |
209 |
|
.endfunc |
210 |
|
|
211 |
|
|
212 |
; enter/exit mmx state |
; enter/exit mmx state |
213 |
|
ALIGN 16 |
214 |
cglobal emms_mmx |
cglobal emms_mmx |
|
align 16 |
|
215 |
emms_mmx: |
emms_mmx: |
216 |
emms |
emms |
217 |
ret |
ret |
218 |
|
.endfunc |
219 |
|
|
220 |
; faster enter/exit mmx state |
; faster enter/exit mmx state |
221 |
|
ALIGN 16 |
222 |
cglobal emms_3dn |
cglobal emms_3dn |
|
align 16 |
|
223 |
emms_3dn: |
emms_3dn: |
224 |
femms |
femms |
225 |
ret |
ret |
226 |
|
.endfunc |
227 |
|
|
228 |
|
|