Patch from Michael Bonfils to add CPUID support for x86 Solaris.
authorRyan C. Gordon <icculus@icculus.org>
Thu, 05 Jan 2006 08:17:35 +0000
changeset 12291430f5fe092a
parent 1228 f4a3a4129d04
child 1230 88c2d6aed428
Patch from Michael Bonfils to add CPUID support for x86 Solaris.
src/cpuinfo/SDL_cpuinfo.c
     1.1 --- a/src/cpuinfo/SDL_cpuinfo.c	Thu Jan 05 07:20:12 2006 +0000
     1.2 +++ b/src/cpuinfo/SDL_cpuinfo.c	Thu Jan 05 08:17:35 2006 +0000
     1.3 @@ -116,6 +116,36 @@
     1.4          mov     has_CPUID,1         ; We have CPUID support
     1.5  done:
     1.6  	}
     1.7 +#elif defined(__sun) && defined(__x86)
     1.8 +	    __asm (
     1.9 +"       pushfl                 \n"
    1.10 +"	    popl    %eax           \n"
    1.11 +"	    movl    %eax,%ecx      \n"
    1.12 +"	    xorl    $0x200000,%eax \n"
    1.13 +"	    pushl   %eax           \n"
    1.14 +"	    popfl                  \n"
    1.15 +"	    pushfl                 \n"
    1.16 +"	    popl    %eax           \n"
    1.17 +"	    xorl    %ecx,%eax      \n"
    1.18 +"	    jz      1f             \n"
    1.19 +"	    movl    $1,-8(%ebp)    \n"
    1.20 +"1:                            \n"
    1.21 +	);
    1.22 +#elif defined(__sun) && defined(__amd64)
    1.23 +	__asm (
    1.24 +"       pushfq                 \n"
    1.25 +"       popq    %rax           \n"
    1.26 +"       movq    %rax,%rcx      \n"
    1.27 +"       xorl    $0x200000,%eax \n"
    1.28 +"       pushq   %rax           \n"
    1.29 +"       popfq                  \n"
    1.30 +"       pushfq                 \n"
    1.31 +"       popq    %rax           \n"
    1.32 +"       xorl    %ecx,%eax      \n"
    1.33 +"       jz      1f             \n"
    1.34 +"       movl    $1,-8(%rbp)    \n"
    1.35 +"1:                            \n"
    1.36 +	);
    1.37  #endif
    1.38  	return has_CPUID;
    1.39  }
    1.40 @@ -152,6 +182,23 @@
    1.41          mov     features, edx
    1.42  done:
    1.43  	}
    1.44 +#elif defined(__sun) && (defined(__x86) || defined(__amd64))
    1.45 +	    __asm(
    1.46 +"        movl    %ebx,%edi\n"
    1.47 +"        xorl    %eax,%eax         \n"
    1.48 +"        cpuid                     \n"
    1.49 +"        cmpl    $1,%eax           \n"
    1.50 +"        jl      1f                \n"
    1.51 +"        xorl    %eax,%eax         \n"
    1.52 +"        incl    %eax              \n"
    1.53 +"        cpuid                     \n"
    1.54 +#ifdef __i386
    1.55 +"        movl    %edx,-8(%ebp)     \n"
    1.56 +#else
    1.57 +"        movl    %edx,-8(%rbp)     \n"
    1.58 +#endif
    1.59 +"1:                                \n"
    1.60 +"        movl    %edi,%ebx\n" );
    1.61  #endif
    1.62  	return features;
    1.63  }
    1.64 @@ -186,6 +233,23 @@
    1.65          mov     features,edx
    1.66  done:
    1.67  	}
    1.68 +#elif defined(__sun) && ( defined(__i386) || defined(__amd64) )
    1.69 +	    __asm (
    1.70 +"        movl    %ebx,%edi\n"
    1.71 +"        movl    $0x80000000,%eax \n"
    1.72 +"        cpuid                    \n"
    1.73 +"        cmpl    $0x80000001,%eax \n"
    1.74 +"        jl      1f               \n"
    1.75 +"        movl    $0x80000001,%eax \n"
    1.76 +"        cpuid                    \n"
    1.77 +#ifdef __i386
    1.78 +"        movl    %edx,-8(%ebp)   \n"
    1.79 +#else
    1.80 +"        movl    %edx,-8(%rbp)   \n"
    1.81 +#endif
    1.82 +"1:                               \n"
    1.83 +"        movl    %edi,%ebx\n"
    1.84 +	    );
    1.85  #endif
    1.86  	return features;
    1.87  }