Mercurial > sdl-ios-xcode
comparison src/video/mmx.h @ 1668:4da1ee79c9af SDL-1.3
more tweaking indent options
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Mon, 29 May 2006 04:04:35 +0000 |
parents | 782fd950bd46 |
children |
comparison
equal
deleted
inserted
replaced
1667:1fddae038bc8 | 1668:4da1ee79c9af |
---|---|
52 short w[4]; /* 4 Word (16-bit) values */ | 52 short w[4]; /* 4 Word (16-bit) values */ |
53 unsigned short uw[4]; /* 4 Unsigned Word */ | 53 unsigned short uw[4]; /* 4 Unsigned Word */ |
54 char b[8]; /* 8 Byte (8-bit) values */ | 54 char b[8]; /* 8 Byte (8-bit) values */ |
55 unsigned char ub[8]; /* 8 Unsigned Byte */ | 55 unsigned char ub[8]; /* 8 Unsigned Byte */ |
56 float s[2]; /* Single-precision (32-bit) value */ | 56 float s[2]; /* Single-precision (32-bit) value */ |
57 } __attribute__ ((aligned (8))) mmx_t; /* On an 8-byte (64-bit) boundary */ | 57 } __attribute__ ((aligned(8))) mmx_t; /* On an 8-byte (64-bit) boundary */ |
58 | 58 |
59 | 59 |
60 #if 0 | 60 #if 0 |
61 /* Function to test if multimedia instructions are supported... | 61 /* Function to test if multimedia instructions are supported... |
62 */ | 62 */ |
63 inline extern int | 63 inline extern int |
64 mm_support (void) | 64 mm_support(void) |
65 { | 65 { |
66 /* Returns 1 if MMX instructions are supported, | 66 /* Returns 1 if MMX instructions are supported, |
67 3 if Cyrix MMX and Extended MMX instructions are supported | 67 3 if Cyrix MMX and Extended MMX instructions are supported |
68 5 if AMD MMX and 3DNow! instructions are supported | 68 5 if AMD MMX and 3DNow! instructions are supported |
69 0 if hardware does not support any of these | 69 0 if hardware does not support any of these |
70 */ | 70 */ |
71 register int rval = 0; | 71 register int rval = 0; |
72 | 72 |
73 __asm__ __volatile__ ( | 73 __asm__ __volatile__( |
74 /* See if CPUID instruction is supported ... */ | 74 /* See if CPUID instruction is supported ... */ |
75 /* ... Get copies of EFLAGS into eax and ecx */ | 75 /* ... Get copies of EFLAGS into eax and ecx */ |
76 "pushf\n\t" | 76 "pushf\n\t" |
77 "popl %%eax\n\t" "movl %%eax, %%ecx\n\t" | 77 "popl %%eax\n\t" "movl %%eax, %%ecx\n\t" |
78 /* ... Toggle the ID bit in one copy and store */ | 78 /* ... Toggle the ID bit in one copy and store */ |
79 /* to the EFLAGS reg */ | 79 /* to the EFLAGS reg */ |
80 "xorl $0x200000, %%eax\n\t" | 80 "xorl $0x200000, %%eax\n\t" |
81 "push %%eax\n\t" "popf\n\t" | 81 "push %%eax\n\t" "popf\n\t" |
82 /* ... Get the (hopefully modified) EFLAGS */ | 82 /* ... Get the (hopefully modified) EFLAGS */ |
83 "pushf\n\t" "popl %%eax\n\t" | 83 "pushf\n\t" "popl %%eax\n\t" |
84 /* ... Compare and test result */ | 84 /* ... Compare and test result */ |
85 "xorl %%eax, %%ecx\n\t" "testl $0x200000, %%ecx\n\t" "jz NotSupported1\n\t" /* CPUID not supported */ | 85 "xorl %%eax, %%ecx\n\t" "testl $0x200000, %%ecx\n\t" "jz NotSupported1\n\t" /* CPUID not supported */ |
86 /* Get standard CPUID information, and | 86 /* Get standard CPUID information, and |
87 go to a specific vendor section */ | 87 go to a specific vendor section */ |
88 "movl $0, %%eax\n\t" "cpuid\n\t" | 88 "movl $0, %%eax\n\t" "cpuid\n\t" |
89 /* Check for Intel */ | 89 /* Check for Intel */ |
90 "cmpl $0x756e6547, %%ebx\n\t" | 90 "cmpl $0x756e6547, %%ebx\n\t" |
91 "jne TryAMD\n\t" | 91 "jne TryAMD\n\t" |
92 "cmpl $0x49656e69, %%edx\n\t" | 92 "cmpl $0x49656e69, %%edx\n\t" |
93 "jne TryAMD\n\t" | 93 "jne TryAMD\n\t" |
94 "cmpl $0x6c65746e, %%ecx\n" | 94 "cmpl $0x6c65746e, %%ecx\n" |
95 "jne TryAMD\n\t" "jmp Intel\n\t" | 95 "jne TryAMD\n\t" "jmp Intel\n\t" |
96 /* Check for AMD */ | 96 /* Check for AMD */ |
97 "\nTryAMD:\n\t" | 97 "\nTryAMD:\n\t" |
98 "cmpl $0x68747541, %%ebx\n\t" | 98 "cmpl $0x68747541, %%ebx\n\t" |
99 "jne TryCyrix\n\t" | 99 "jne TryCyrix\n\t" |
100 "cmpl $0x69746e65, %%edx\n\t" | 100 "cmpl $0x69746e65, %%edx\n\t" |
101 "jne TryCyrix\n\t" | 101 "jne TryCyrix\n\t" |
102 "cmpl $0x444d4163, %%ecx\n" | 102 "cmpl $0x444d4163, %%ecx\n" |
103 "jne TryCyrix\n\t" "jmp AMD\n\t" | 103 "jne TryCyrix\n\t" "jmp AMD\n\t" |
104 /* Check for Cyrix */ | 104 /* Check for Cyrix */ |
105 "\nTryCyrix:\n\t" | 105 "\nTryCyrix:\n\t" |
106 "cmpl $0x69727943, %%ebx\n\t" | 106 "cmpl $0x69727943, %%ebx\n\t" |
107 "jne NotSupported2\n\t" | 107 "jne NotSupported2\n\t" |
108 "cmpl $0x736e4978, %%edx\n\t" | 108 "cmpl $0x736e4978, %%edx\n\t" |
109 "jne NotSupported3\n\t" | 109 "jne NotSupported3\n\t" |
110 "cmpl $0x64616574, %%ecx\n\t" | 110 "cmpl $0x64616574, %%ecx\n\t" |
111 "jne NotSupported4\n\t" | 111 "jne NotSupported4\n\t" |
112 /* Drop through to Cyrix... */ | 112 /* Drop through to Cyrix... */ |
113 /* Cyrix Section */ | 113 /* Cyrix Section */ |
114 /* See if extended CPUID level 80000001 is supported */ | 114 /* See if extended CPUID level 80000001 is supported */ |
115 /* The value of CPUID/80000001 for the 6x86MX is undefined | 115 /* The value of CPUID/80000001 for the 6x86MX is undefined |
116 according to the Cyrix CPU Detection Guide (Preliminary | 116 according to the Cyrix CPU Detection Guide (Preliminary |
117 Rev. 1.01 table 1), so we'll check the value of eax for | 117 Rev. 1.01 table 1), so we'll check the value of eax for |
118 CPUID/0 to see if standard CPUID level 2 is supported. | 118 CPUID/0 to see if standard CPUID level 2 is supported. |
119 According to the table, the only CPU which supports level | 119 According to the table, the only CPU which supports level |
120 2 is also the only one which supports extended CPUID levels. | 120 2 is also the only one which supports extended CPUID levels. |
121 */ | 121 */ |
122 "cmpl $0x2, %%eax\n\t" "jne MMXtest\n\t" /* Use standard CPUID instead */ | 122 "cmpl $0x2, %%eax\n\t" "jne MMXtest\n\t" /* Use standard CPUID instead */ |
123 /* Extended CPUID supported (in theory), so get extended | 123 /* Extended CPUID supported (in theory), so get extended |
124 features */ | 124 features */ |
125 "movl $0x80000001, %%eax\n\t" "cpuid\n\t" "testl $0x00800000, %%eax\n\t" /* Test for MMX */ | 125 "movl $0x80000001, %%eax\n\t" "cpuid\n\t" "testl $0x00800000, %%eax\n\t" /* Test for MMX */ |
126 "jz NotSupported5\n\t" /* MMX not supported */ | 126 "jz NotSupported5\n\t" /* MMX not supported */ |
127 "testl $0x01000000, %%eax\n\t" /* Test for Ext'd MMX */ | 127 "testl $0x01000000, %%eax\n\t" /* Test for Ext'd MMX */ |
128 "jnz EMMXSupported\n\t" "movl $1, %0:\n\n\t" /* MMX Supported */ | 128 "jnz EMMXSupported\n\t" "movl $1, %0:\n\n\t" /* MMX Supported */ |
129 "jmp Return\n\n" "EMMXSupported:\n\t" "movl $3, %0:\n\n\t" /* EMMX and MMX Supported */ | 129 "jmp Return\n\n" "EMMXSupported:\n\t" "movl $3, %0:\n\n\t" /* EMMX and MMX Supported */ |
130 "jmp Return\n\t" | 130 "jmp Return\n\t" |
131 /* AMD Section */ | 131 /* AMD Section */ |
132 "AMD:\n\t" | 132 "AMD:\n\t" |
133 /* See if extended CPUID is supported */ | 133 /* See if extended CPUID is supported */ |
134 "movl $0x80000000, %%eax\n\t" "cpuid\n\t" "cmpl $0x80000000, %%eax\n\t" "jl MMXtest\n\t" /* Use standard CPUID instead */ | 134 "movl $0x80000000, %%eax\n\t" "cpuid\n\t" "cmpl $0x80000000, %%eax\n\t" "jl MMXtest\n\t" /* Use standard CPUID instead */ |
135 /* Extended CPUID supported, so get extended features */ | 135 /* Extended CPUID supported, so get extended features */ |
136 "movl $0x80000001, %%eax\n\t" "cpuid\n\t" "testl $0x00800000, %%edx\n\t" /* Test for MMX */ | 136 "movl $0x80000001, %%eax\n\t" "cpuid\n\t" "testl $0x00800000, %%edx\n\t" /* Test for MMX */ |
137 "jz NotSupported6\n\t" /* MMX not supported */ | 137 "jz NotSupported6\n\t" /* MMX not supported */ |
138 "testl $0x80000000, %%edx\n\t" /* Test for 3DNow! */ | 138 "testl $0x80000000, %%edx\n\t" /* Test for 3DNow! */ |
139 "jnz ThreeDNowSupported\n\t" "movl $1, %0:\n\n\t" /* MMX Supported */ | 139 "jnz ThreeDNowSupported\n\t" "movl $1, %0:\n\n\t" /* MMX Supported */ |
140 "jmp Return\n\n" "ThreeDNowSupported:\n\t" "movl $5, %0:\n\n\t" /* 3DNow! and MMX Supported */ | 140 "jmp Return\n\n" "ThreeDNowSupported:\n\t" "movl $5, %0:\n\n\t" /* 3DNow! and MMX Supported */ |
141 "jmp Return\n\t" | 141 "jmp Return\n\t" |
142 /* Intel Section */ | 142 /* Intel Section */ |
143 "Intel:\n\t" | 143 "Intel:\n\t" |
144 /* Check for MMX */ | 144 /* Check for MMX */ |
145 "MMXtest:\n\t" "movl $1, %%eax\n\t" "cpuid\n\t" "testl $0x00800000, %%edx\n\t" /* Test for MMX */ | 145 "MMXtest:\n\t" "movl $1, %%eax\n\t" "cpuid\n\t" "testl $0x00800000, %%edx\n\t" /* Test for MMX */ |
146 "jz NotSupported7\n\t" /* MMX Not supported */ | 146 "jz NotSupported7\n\t" /* MMX Not supported */ |
147 "movl $1, %0:\n\n\t" /* MMX Supported */ | 147 "movl $1, %0:\n\n\t" /* MMX Supported */ |
148 "jmp Return\n\t" | 148 "jmp Return\n\t" |
149 /* Nothing supported */ | 149 /* Nothing supported */ |
150 "\nNotSupported1:\n\t" "#movl $101, %0:\n\n\t" "\nNotSupported2:\n\t" "#movl $102, %0:\n\n\t" "\nNotSupported3:\n\t" "#movl $103, %0:\n\n\t" "\nNotSupported4:\n\t" "#movl $104, %0:\n\n\t" "\nNotSupported5:\n\t" "#movl $105, %0:\n\n\t" "\nNotSupported6:\n\t" "#movl $106, %0:\n\n\t" "\nNotSupported7:\n\t" "#movl $107, %0:\n\n\t" "movl $0, %0:\n\n\t" "Return:\n\t":"=a" (rval): /* no input */ | 150 "\nNotSupported1:\n\t" "#movl $101, %0:\n\n\t" "\nNotSupported2:\n\t" "#movl $102, %0:\n\n\t" "\nNotSupported3:\n\t" "#movl $103, %0:\n\n\t" "\nNotSupported4:\n\t" "#movl $104, %0:\n\n\t" "\nNotSupported5:\n\t" "#movl $105, %0:\n\n\t" "\nNotSupported6:\n\t" "#movl $106, %0:\n\n\t" "\nNotSupported7:\n\t" "#movl $107, %0:\n\n\t" "movl $0, %0:\n\n\t" "Return:\n\t":"=a"(rval): /* no input */ |
151 :"eax", "ebx", "ecx", "edx"); | 151 :"eax", "ebx", "ecx", "edx"); |
152 | 152 |
153 /* Return */ | 153 /* Return */ |
154 return (rval); | 154 return (rval); |
155 } | 155 } |
156 | 156 |
157 /* Function to test if mmx instructions are supported... | 157 /* Function to test if mmx instructions are supported... |
158 */ | 158 */ |
159 inline extern int | 159 inline extern int |
160 mmx_ok (void) | 160 mmx_ok(void) |
161 { | 161 { |
162 /* Returns 1 if MMX instructions are supported, 0 otherwise */ | 162 /* Returns 1 if MMX instructions are supported, 0 otherwise */ |
163 return (mm_support () & 0x1); | 163 return (mm_support() & 0x1); |
164 } | 164 } |
165 #endif | 165 #endif |
166 | 166 |
167 /* Helper functions for the instruction macros that follow... | 167 /* Helper functions for the instruction macros that follow... |
168 (note that memory-to-register, m2r, instructions are nearly | 168 (note that memory-to-register, m2r, instructions are nearly |