-/* $Id: common_x86.c,v 1.18 2002/06/29 19:48:17 brianp Exp $ */
+/* $Id: common_x86.c,v 1.19 2002/07/11 15:33:02 brianp Exp $ */
/*
* Mesa 3-D graphics library
#if defined(USE_SSE_ASM) && defined(__linux__)
#include <signal.h>
#endif
+#if defined(USE_SSE_ASM) && defined(__FreeBSD__)
+#include <sys/types.h>
+#include <sys/sysctl.h>
+#endif
#include "context.h"
#include "common_x86_asm.h"
message( "Cannot test OS support for SSE, disabling to be safe.\n" );
_mesa_x86_cpu_features &= ~(X86_FEATURE_XMM);
#endif /* _POSIX_SOURCE && X86_FXSR_MAGIC */
+#elif defined(__FreeBSD__)
+ {
+ int ret, len, enabled;
+ len = sizeof(enabled);
+ ret = sysctlbyname("hw.instruction_sse", &enabled, &len, NULL, 0);
+ if (ret || !enabled)
+ _mesa_x86_cpu_features &= ~(X86_FEATURE_XMM);
+ }
#else
- /* Do nothing on non-Linux platforms for now.
+ /* Do nothing on other platforms for now.
*/
message( "Not testing OS support for SSE, leaving enabled.\n" );
#endif /* __linux__ */
-/* $Id: common_x86_asm.S,v 1.10 2002/06/11 01:26:58 brianp Exp $ */
+/* $Id: common_x86_asm.S,v 1.11 2002/07/11 15:33:02 brianp Exp $ */
/*
* Mesa 3-D graphics library
* information after we verify that the extended functions are
* supported.
*/
+ /* The features we need are almost all in the extended set. The
+ * exception is SSE enable, which is in the standard set (0x1).
+ */
+ MOV_L ( CONST(0x1), EAX )
+ CPUID
+ TEST_L ( EAX, EAX )
+ JZ ( LLBL (cpuid_failed) )
+ MOV_L ( EDX, ESI )
+
MOV_L ( CONST(0x80000000), EAX )
CPUID
TEST_L ( EAX, EAX )
MOV_L ( CONST(0x80000001), EAX )
CPUID
MOV_L ( EDX, EAX )
+
+ AND_L ( CONST(0x02000000), ESI ) /* OR in the SSE bit */
+ OR_L ( ESI, EAX )
+
JMP ( LLBL (cpuid_done) )
LLBL(cpuid_other):