comparison src/cpuinfo/SDL_cpuinfo.c @ 1229:1430f5fe092a

Patch from Michael Bonfils to add CPUID support for x86 Solaris.
author Ryan C. Gordon <icculus@icculus.org>
date Thu, 05 Jan 2006 08:17:35 +0000
parents b616ac4f39d1
children c9b51268668f
comparison
equal deleted inserted replaced
1228:f4a3a4129d04 1229:1430f5fe092a
114 xor eax, ecx ; Can not toggle ID bit, 114 xor eax, ecx ; Can not toggle ID bit,
115 jz done ; Processor=80486 115 jz done ; Processor=80486
116 mov has_CPUID,1 ; We have CPUID support 116 mov has_CPUID,1 ; We have CPUID support
117 done: 117 done:
118 } 118 }
119 #elif defined(__sun) && defined(__x86)
120 __asm (
121 " pushfl \n"
122 " popl %eax \n"
123 " movl %eax,%ecx \n"
124 " xorl $0x200000,%eax \n"
125 " pushl %eax \n"
126 " popfl \n"
127 " pushfl \n"
128 " popl %eax \n"
129 " xorl %ecx,%eax \n"
130 " jz 1f \n"
131 " movl $1,-8(%ebp) \n"
132 "1: \n"
133 );
134 #elif defined(__sun) && defined(__amd64)
135 __asm (
136 " pushfq \n"
137 " popq %rax \n"
138 " movq %rax,%rcx \n"
139 " xorl $0x200000,%eax \n"
140 " pushq %rax \n"
141 " popfq \n"
142 " pushfq \n"
143 " popq %rax \n"
144 " xorl %ecx,%eax \n"
145 " jz 1f \n"
146 " movl $1,-8(%rbp) \n"
147 "1: \n"
148 );
119 #endif 149 #endif
120 return has_CPUID; 150 return has_CPUID;
121 } 151 }
122 152
123 static __inline__ int CPU_getCPUIDFeatures() 153 static __inline__ int CPU_getCPUIDFeatures()
150 inc eax 180 inc eax
151 cpuid ; Get family/model/stepping/features 181 cpuid ; Get family/model/stepping/features
152 mov features, edx 182 mov features, edx
153 done: 183 done:
154 } 184 }
185 #elif defined(__sun) && (defined(__x86) || defined(__amd64))
186 __asm(
187 " movl %ebx,%edi\n"
188 " xorl %eax,%eax \n"
189 " cpuid \n"
190 " cmpl $1,%eax \n"
191 " jl 1f \n"
192 " xorl %eax,%eax \n"
193 " incl %eax \n"
194 " cpuid \n"
195 #ifdef __i386
196 " movl %edx,-8(%ebp) \n"
197 #else
198 " movl %edx,-8(%rbp) \n"
199 #endif
200 "1: \n"
201 " movl %edi,%ebx\n" );
155 #endif 202 #endif
156 return features; 203 return features;
157 } 204 }
158 205
159 static __inline__ int CPU_getCPUIDFeaturesExt() 206 static __inline__ int CPU_getCPUIDFeaturesExt()
184 mov eax,80000001h ; Setup extended function 800000001h 231 mov eax,80000001h ; Setup extended function 800000001h
185 cpuid ; and get the information 232 cpuid ; and get the information
186 mov features,edx 233 mov features,edx
187 done: 234 done:
188 } 235 }
236 #elif defined(__sun) && ( defined(__i386) || defined(__amd64) )
237 __asm (
238 " movl %ebx,%edi\n"
239 " movl $0x80000000,%eax \n"
240 " cpuid \n"
241 " cmpl $0x80000001,%eax \n"
242 " jl 1f \n"
243 " movl $0x80000001,%eax \n"
244 " cpuid \n"
245 #ifdef __i386
246 " movl %edx,-8(%ebp) \n"
247 #else
248 " movl %edx,-8(%rbp) \n"
249 #endif
250 "1: \n"
251 " movl %edi,%ebx\n"
252 );
189 #endif 253 #endif
190 return features; 254 return features;
191 } 255 }
192 256
193 static __inline__ int CPU_haveRDTSC() 257 static __inline__ int CPU_haveRDTSC()