Initial community commit
This commit is contained in:
parent
537bcbc862
commit
fc06254474
16440 changed files with 4239995 additions and 2 deletions
99
Src/libvpShared/corelibs/CpuID/Win32/D9xOSSupXMM.asm
Normal file
99
Src/libvpShared/corelibs/CpuID/Win32/D9xOSSupXMM.asm
Normal file
|
@ -0,0 +1,99 @@
|
|||
;//==========================================================================
|
||||
;//
|
||||
;// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
|
||||
;// KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
|
||||
;// IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
|
||||
;// PURPOSE.
|
||||
;//
|
||||
;// Copyright (c) 1999 - 2001 On2 Technologies Inc. All Rights Reserved.
|
||||
;//
|
||||
;//--------------------------------------------------------------------------
|
||||
|
||||
|
||||
;
|
||||
; **-Does9xOSSupportXMM
|
||||
;
|
||||
; This function will verify if the operating system supports the XMM
|
||||
; instructions. According to Intel documentation
|
||||
;
|
||||
; Intel Architecture
|
||||
; Software Developer
|
||||
; Manual
|
||||
; Volume 1:
|
||||
; Basic Architecture
|
||||
;
|
||||
; The following needs to be true for the OS to suppor the XMM instructions
|
||||
;
|
||||
; CR0.EM(bit 2) = 0 (emulation disabled)
|
||||
; CR4.OSFXSR(bit 9) = 1 (OS supports saving SIMD floating-point state during context
|
||||
; switches)
|
||||
;
|
||||
; * * * N O T E * * * * * * N O T E * * * * * * N O T E * * * * * * N O T E * * * * * * N O T E * * * * * * N O T E * * *
|
||||
;
|
||||
; This function will NOT run on windows NT systems. The function reads control registers
|
||||
; which are protected under Windows NT. If you attempt to run this function under Windows NT a
|
||||
; protected mode access violation will be generated.
|
||||
;
|
||||
; * * * N O T E * * * * * * N O T E * * * * * * N O T E * * * * * * N O T E * * * * * * N O T E * * * * * * N O T E * * *
|
||||
;
|
||||
; Assumptions:
|
||||
; Access to system control registers CR0 and CR4 are not protected
|
||||
;
|
||||
; Input:
|
||||
; None
|
||||
;
|
||||
; Output:
|
||||
; 1 Returned if OS supports XMM instructions
|
||||
; 0 Returned if OS does not support XMM instructions
|
||||
;
|
||||
;
|
||||
|
||||
|
||||
.586
|
||||
.MODEL flat, SYSCALL, os_dos
|
||||
.DATA
|
||||
|
||||
NAME x86cpuid
|
||||
|
||||
PUBLIC Does9xOSSupportXMM_
|
||||
PUBLIC _Does9xOSSupportXMM
|
||||
|
||||
.CODE
|
||||
|
||||
; int Does9xOSSupportXMM( void )
|
||||
Does9xOSSupportXMM_:
|
||||
_Does9xOSSupportXMM:
|
||||
push esi ;safety sh*&
|
||||
push edi
|
||||
push ebp
|
||||
push ebx
|
||||
push ecx
|
||||
push edx
|
||||
|
||||
; check to see if OS supports SIMD instructions
|
||||
mov edx,cr0
|
||||
bt edx,2 ; ensure no emulation
|
||||
jnae NoXMMSupport
|
||||
|
||||
mov edx,cr4
|
||||
bt edx,9 ; OS support SIMD
|
||||
jnc NoXMMSupport
|
||||
|
||||
; we support XMM instructions
|
||||
mov eax,1
|
||||
jmp Exit
|
||||
|
||||
NoXMMSupport:
|
||||
; mov eax,0 ; OS does not support XMM instructions
|
||||
|
||||
Exit:
|
||||
pop edx ;safety sh*&
|
||||
pop ecx
|
||||
pop ebx
|
||||
pop ebp
|
||||
pop edi
|
||||
pop esi
|
||||
ret
|
||||
|
||||
;************************************************
|
||||
END
|
100
Src/libvpShared/corelibs/CpuID/Win32/InitXMMReg.asm
Normal file
100
Src/libvpShared/corelibs/CpuID/Win32/InitXMMReg.asm
Normal file
|
@ -0,0 +1,100 @@
|
|||
;//==========================================================================
|
||||
;//
|
||||
;// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
|
||||
;// KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
|
||||
;// IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
|
||||
;// PURPOSE.
|
||||
;//
|
||||
;// Copyright (c) 1999 - 2001 On2 Technologies Inc. All Rights Reserved.
|
||||
;//
|
||||
;//--------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
;
|
||||
; **-InitXMMReg
|
||||
;
|
||||
; This function is meant to be run on a Windows NT system to
|
||||
; try and determine if the OS supports the XMM registers or
|
||||
; not.
|
||||
;
|
||||
; This function is number 1 in a set of three. The other
|
||||
; functions are...
|
||||
;
|
||||
; TrashXMMReg
|
||||
; VerifyXMMReg
|
||||
;
|
||||
; Assumptions:
|
||||
; None
|
||||
;
|
||||
; Input:
|
||||
; None
|
||||
;
|
||||
; Output:
|
||||
; No return value. But XMM registers
|
||||
; 0, 1, 2 initilized to a predetermined
|
||||
; value
|
||||
;
|
||||
;
|
||||
.686P
|
||||
.XMM
|
||||
.MODEL flat, SYSCALL, os_dos
|
||||
.DATA
|
||||
|
||||
TORQ_CX_DATA SEGMENT PAGE PUBLIC USE32 'DATA'
|
||||
|
||||
ALIGN 32
|
||||
|
||||
PUBLIC XMM0Init
|
||||
PUBLIC XMM1Init
|
||||
PUBLIC XMM2Init
|
||||
|
||||
|
||||
XMM0Init REAL4 1.1
|
||||
REAL4 2.2
|
||||
REAL4 3.3
|
||||
REAL4 4.4
|
||||
|
||||
XMM1Init REAL4 5.5
|
||||
REAL4 6.6
|
||||
REAL4 7.7
|
||||
REAL4 8.8
|
||||
|
||||
XMM2Init REAL4 9.9
|
||||
REAL4 10.10
|
||||
REAL4 11.11
|
||||
REAL4 12.12
|
||||
|
||||
|
||||
NAME InitXMMReg
|
||||
|
||||
PUBLIC InitXMMReg_
|
||||
PUBLIC _InitXMMReg
|
||||
|
||||
.CODE
|
||||
|
||||
; void InitXMMReg( void )
|
||||
InitXMMReg_:
|
||||
_InitXMMReg:
|
||||
push esi ;safety sh*&
|
||||
push edi
|
||||
push ebp
|
||||
push ebx
|
||||
push ecx
|
||||
push edx
|
||||
|
||||
movaps xmm0,XMM0Init
|
||||
movaps xmm1,XMM1Init
|
||||
movaps xmm2,XMM2Init
|
||||
|
||||
Exit:
|
||||
pop edx ;safety sh*&
|
||||
pop ecx
|
||||
pop ebx
|
||||
pop ebp
|
||||
pop edi
|
||||
pop esi
|
||||
ret
|
||||
|
||||
;************************************************
|
||||
END
|
87
Src/libvpShared/corelibs/CpuID/Win32/TrashXMMreg.asm
Normal file
87
Src/libvpShared/corelibs/CpuID/Win32/TrashXMMreg.asm
Normal file
|
@ -0,0 +1,87 @@
|
|||
;//==========================================================================
|
||||
;//
|
||||
;// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
|
||||
;// KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
|
||||
;// IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
|
||||
;// PURPOSE.
|
||||
;//
|
||||
;// Copyright (c) 1999 - 2001 On2 Technologies Inc. All Rights Reserved.
|
||||
;//
|
||||
;//--------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
;
|
||||
; **-TrashXMMReg
|
||||
;
|
||||
; This function is meant to be run on a Windows NT system to
|
||||
; try and determine if the OS supports the XMM registers or
|
||||
; not.
|
||||
;
|
||||
; This function is number 2 in a set of three. The other
|
||||
; functions are...
|
||||
;
|
||||
; InitXMMReg
|
||||
; VerifyXMMReg
|
||||
;
|
||||
; Assumptions:
|
||||
; No necessary for this function to work properly but
|
||||
; IntiXMMReg should have been called to initilize the
|
||||
; XMM registers to a predetermined value
|
||||
;
|
||||
; Input:
|
||||
; None
|
||||
;
|
||||
; Output:
|
||||
; No return value. But XMM registers
|
||||
; 0, 1, 2 written to 0's
|
||||
;
|
||||
;
|
||||
|
||||
.686P
|
||||
.XMM
|
||||
.MODEL flat, SYSCALL, os_dos
|
||||
.DATA
|
||||
|
||||
TORQ_CX_DATA SEGMENT PAGE PUBLIC USE32 'DATA'
|
||||
|
||||
ALIGN 32
|
||||
|
||||
Zeros REAL4 0.0
|
||||
REAL4 0.0
|
||||
REAL4 0.0
|
||||
REAL4 0.0
|
||||
|
||||
|
||||
NAME TrashXMMReg
|
||||
|
||||
PUBLIC TrashXMMReg_
|
||||
PUBLIC _TrashXMMReg
|
||||
|
||||
.CODE
|
||||
|
||||
; void TrashXMMReg( void )
|
||||
TrashXMMReg_:
|
||||
_TrashXMMReg:
|
||||
push esi ;safety sh*&
|
||||
push edi
|
||||
push ebp
|
||||
push ebx
|
||||
push ecx
|
||||
push edx
|
||||
|
||||
movaps xmm0,Zeros
|
||||
movaps xmm1,Zeros
|
||||
movaps xmm2,Zeros
|
||||
|
||||
Exit:
|
||||
pop edx ;safety sh*&
|
||||
pop ecx
|
||||
pop ebx
|
||||
pop ebp
|
||||
pop edi
|
||||
pop esi
|
||||
ret
|
||||
|
||||
;************************************************
|
||||
END
|
99
Src/libvpShared/corelibs/CpuID/Win32/VerifyXMMReg.asm
Normal file
99
Src/libvpShared/corelibs/CpuID/Win32/VerifyXMMReg.asm
Normal file
|
@ -0,0 +1,99 @@
|
|||
;//==========================================================================
|
||||
;//
|
||||
;// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
|
||||
;// KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
|
||||
;// IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
|
||||
;// PURPOSE.
|
||||
;//
|
||||
;// Copyright (c) 1999 - 2001 On2 Technologies Inc. All Rights Reserved.
|
||||
;//
|
||||
;//--------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
;
|
||||
; **-VerifyXMMReg
|
||||
;
|
||||
; This function is meant to be run on a Windows NT system to
|
||||
; try and determine if the OS supports the XMM registers or
|
||||
; not.
|
||||
;
|
||||
; This function is number 3 in a set of three. The other
|
||||
; functions are...
|
||||
;
|
||||
; InitXMMReg
|
||||
; TrashXMMReg
|
||||
;
|
||||
; Assumptions:
|
||||
; Assumes that InitXMMReg was called to initilize the XMM registers.
|
||||
; Assumes that TrashXMMReg was called from a different thread to clear
|
||||
; the values in the XMM registers.
|
||||
;
|
||||
; Input:
|
||||
; None
|
||||
;
|
||||
; Output:
|
||||
; Return 1 (True) if the XMM registers are at the correct values.
|
||||
; (os supports XMM registers)
|
||||
;
|
||||
; Return 0 (False) if the XMM registers are not at the correct values.
|
||||
; (os does not support the XMM registers)
|
||||
;
|
||||
|
||||
.686P
|
||||
.XMM
|
||||
.MODEL flat, SYSCALL, os_dos
|
||||
.DATA
|
||||
|
||||
TORQ_CX_DATA SEGMENT PAGE PUBLIC USE32 'DATA'
|
||||
|
||||
ALIGN 32
|
||||
|
||||
|
||||
NAME VerifyXMMReg
|
||||
|
||||
PUBLIC VerifyXMMReg_
|
||||
PUBLIC _VerifyXMMReg
|
||||
|
||||
|
||||
EXTERN XMM0Init:REAL4
|
||||
EXTERN XMM1Init:REAL4
|
||||
EXTERN XMM2Init:REAL4
|
||||
|
||||
|
||||
.CODE
|
||||
|
||||
; int VerifyXMMReg( void )
|
||||
VerifyXMMReg_:
|
||||
_VerifyXMMReg:
|
||||
push esi ;safety sh*&
|
||||
push edi
|
||||
push ebp
|
||||
push ebx
|
||||
push ecx
|
||||
push edx
|
||||
|
||||
mov eax,0 ; assume will fail
|
||||
|
||||
comiss xmm0,XMM0Init ; check XMM0
|
||||
jne Exit
|
||||
|
||||
comiss xmm1,XMM1Init
|
||||
jne Exit
|
||||
|
||||
comiss xmm2,XMM2Init
|
||||
jne Exit
|
||||
|
||||
mov eax,1 ; OS supports XMM registers
|
||||
|
||||
Exit:
|
||||
pop edx ;safety sh*&
|
||||
pop ecx
|
||||
pop ebx
|
||||
pop ebp
|
||||
pop edi
|
||||
pop esi
|
||||
ret
|
||||
|
||||
;************************************************
|
||||
END
|
149
Src/libvpShared/corelibs/CpuID/Win32/Wmt_CpuID.cpp
Normal file
149
Src/libvpShared/corelibs/CpuID/Win32/Wmt_CpuID.cpp
Normal file
|
@ -0,0 +1,149 @@
|
|||
//==========================================================================
|
||||
//
|
||||
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
|
||||
// KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
|
||||
// PURPOSE.
|
||||
//
|
||||
// Copyright (c) 1999 - 2001 On2 Technologies Inc. All Rights Reserved.
|
||||
//
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
*
|
||||
* Module Title : Wmt_CpuID.cpp
|
||||
*
|
||||
* Description : willamette processor detection functions
|
||||
*
|
||||
*
|
||||
*****************************************************************************
|
||||
*/
|
||||
|
||||
/****************************************************************************
|
||||
* Header Files
|
||||
*****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
#include <excpt.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
extern "C" {
|
||||
|
||||
/****************************************************************************
|
||||
*
|
||||
* ROUTINE : WillametteNewInstructionSupport()
|
||||
*
|
||||
* INPUTS :
|
||||
*
|
||||
* OUTPUTS :
|
||||
*
|
||||
* RETURNS : retrun true if the processor support willamette new
|
||||
* instructions, return false otherwise
|
||||
*
|
||||
*
|
||||
* FUNCTION : detect willamette processor
|
||||
*
|
||||
* SPECIAL NOTES : None.
|
||||
*
|
||||
* ERRORS : None.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int WillametteNewInstructionHWSupport()
|
||||
{
|
||||
|
||||
int HWSupport = 0;
|
||||
char brand[12];
|
||||
|
||||
__try
|
||||
{
|
||||
__asm
|
||||
{
|
||||
|
||||
lea esi, brand
|
||||
mov eax, 0
|
||||
cpuid
|
||||
mov [esi], ebx
|
||||
mov [esi+4], edx
|
||||
mov [esi+8], ecx
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
__except(EXCEPTION_EXECUTE_HANDLER)
|
||||
{
|
||||
|
||||
if(_exception_code())
|
||||
{
|
||||
//cout<<endl<<"*******CPUID is not supported**********"<<endl;
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
if(strncmp(brand, "GenuineIntel", 12)!=0)
|
||||
{
|
||||
|
||||
//cout<<endl<<"this is not an intel processor1"<<endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
__asm
|
||||
{
|
||||
mov eax, 1
|
||||
cpuid
|
||||
test edx, 04000000h
|
||||
jz NotFound
|
||||
mov [HWSupport], 1
|
||||
|
||||
NotFound:
|
||||
nop
|
||||
|
||||
}
|
||||
|
||||
return (HWSupport);
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
*
|
||||
* ROUTINE : WillametteNewInstructionOSSupport()
|
||||
*
|
||||
* INPUTS :
|
||||
*
|
||||
* OUTPUTS :
|
||||
*
|
||||
* RETURNS : retrun true if the OS support willamette new
|
||||
* instructions, return false otherwise
|
||||
*
|
||||
*
|
||||
* FUNCTION : detect willamette processor
|
||||
*
|
||||
* SPECIAL NOTES : None.
|
||||
*
|
||||
* ERRORS : None.
|
||||
*
|
||||
****************************************************************************/
|
||||
int WillametteNewInstructionOSSupport()
|
||||
{
|
||||
__try
|
||||
{
|
||||
__asm xorpd xmm0, xmm0
|
||||
}
|
||||
__except(EXCEPTION_EXECUTE_HANDLER)
|
||||
{
|
||||
if(_exception_code())
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
}
|
152
Src/libvpShared/corelibs/CpuID/Win32/cid.c
Normal file
152
Src/libvpShared/corelibs/CpuID/Win32/cid.c
Normal file
|
@ -0,0 +1,152 @@
|
|||
//==========================================================================
|
||||
//
|
||||
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
|
||||
// KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
|
||||
// PURPOSE.
|
||||
//
|
||||
// Copyright (c) 1999 - 2001 On2 Technologies Inc. All Rights Reserved.
|
||||
//
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
|
||||
#include <windows.h>
|
||||
#include <stdarg.h>
|
||||
#include "cpuidlib.h"
|
||||
#include "cidasm.h"
|
||||
#include <process.h>
|
||||
#include <stdio.h>
|
||||
|
||||
extern int WillametteNewInstructionOSSupport();
|
||||
extern int WillametteNewInstructionHWSupport();
|
||||
|
||||
|
||||
/*
|
||||
* **-DoesOSSupportXMM
|
||||
*
|
||||
* This function will check to see if the operating supports the XMM (Pentium III) instructions
|
||||
* The XMM functionality adds 8 128-bit registers to the pentium II register set. With the addition
|
||||
* of the new registers the OS needs to preserve and restore the registers on task switches.
|
||||
*
|
||||
* Inputs:
|
||||
* None
|
||||
*
|
||||
* Outputs:
|
||||
* True returned if the OS supports the XMM instructions.
|
||||
* False returned if the OS does not suppor the XMM instructions.
|
||||
*/
|
||||
int DoesOSSupportXMM( void )
|
||||
{
|
||||
OSVERSIONINFO OSInformation; // Data structure where OS version will be filled in
|
||||
int ReturnValue = FALSE; // Preload to fail
|
||||
|
||||
// need to initilize size of OS info structure before calling GetVersionEx
|
||||
OSInformation.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
|
||||
|
||||
if( !GetVersionEx( &OSInformation ) ) // Get OS information
|
||||
{
|
||||
/*
|
||||
* having trouble getting OS information
|
||||
* to be safe will return that we do not support XMM
|
||||
* instructions
|
||||
*/
|
||||
// ReturnValue = FALSE;
|
||||
}
|
||||
|
||||
if( OSInformation.dwPlatformId == VER_PLATFORM_WIN32_NT )
|
||||
// if( 1 )
|
||||
{
|
||||
/*
|
||||
* If we are on a windows NT system we cannot directly
|
||||
* read the control registers to see if the OS supports
|
||||
* the XMM instructions. We will just check to see if
|
||||
* service pack 4 is installed.
|
||||
*/
|
||||
int ServicePackNumber;
|
||||
|
||||
if( strcmp(OSInformation.szCSDVersion, "" ) != 0 ) // is there a service pack installed?
|
||||
{
|
||||
// Yes, get service pack revision
|
||||
char Junk[132], Junk2[132];
|
||||
|
||||
sscanf( OSInformation.szCSDVersion, "%s %s %d", Junk, Junk2, &ServicePackNumber );
|
||||
}
|
||||
else
|
||||
{
|
||||
ServicePackNumber = 0;
|
||||
}
|
||||
|
||||
if( OSInformation.dwMajorVersion == 4 && // must be versio 4 or greater
|
||||
ServicePackNumber >= 4 || // must have service pack 4 or greater
|
||||
OSInformation.dwMajorVersion >=5)
|
||||
{
|
||||
ReturnValue = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
// ReturnValue = FALSE;
|
||||
}
|
||||
|
||||
#if 0
|
||||
// some handy debugging info if you are desperate
|
||||
printf("OS Major Revision %d\n", OSInformation.dwMajorVersion );
|
||||
printf("OS Minor REvision %d\n", OSInformation.dwMinorVersion );
|
||||
printf("Service Pack Number %d\n", ServicePackNumber );
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
/*
|
||||
* we are on a Windows 9x system.
|
||||
*/
|
||||
//if( Does9xOSSupportXMM()) // does the Windows 9x support the XMM instructions?
|
||||
{
|
||||
ReturnValue = TRUE; // yup
|
||||
}
|
||||
//else
|
||||
//{
|
||||
//ReturnValue = FALSE; // Nope, don't support XMM instructions
|
||||
//}
|
||||
}
|
||||
|
||||
return( ReturnValue );
|
||||
}
|
||||
|
||||
/*
|
||||
* **-findCPUId
|
||||
*
|
||||
* See cpuidlib.h for a detailed description of this function
|
||||
*/
|
||||
PROCTYPE findCPUId( void )
|
||||
{
|
||||
PROCTYPE CpuType;
|
||||
// return 0;
|
||||
// return (PII); // drop to next lowest type of CPU which should be the Pentium II processor
|
||||
|
||||
CpuType = getCPUType(); // Get version of processor
|
||||
|
||||
// The code to check whether willammete instructions are called attempts to run
|
||||
// an illegal instruction. Under 98 mplayer crashes the os as soon as the illegal
|
||||
// instruction is called, so I've disabled it.
|
||||
|
||||
if( CpuType == XMM ) // If the CPU supports XMM (Pentium III) instructions
|
||||
{
|
||||
// if( DoesOSSupportXMM()) // need to check to see if the OS supports the XMM instructions
|
||||
{
|
||||
|
||||
if( WillametteNewInstructionHWSupport()&&
|
||||
WillametteNewInstructionOSSupport())
|
||||
{
|
||||
CpuType = WMT;
|
||||
}
|
||||
}
|
||||
// else
|
||||
// {
|
||||
// os does not support the XMM instructions
|
||||
// CpuType = PII; // drop to next lowest type of CPU which should be the Pentium II processor
|
||||
// }
|
||||
}
|
||||
return( CpuType );
|
||||
}
|
||||
|
||||
|
280
Src/libvpShared/corelibs/CpuID/Win32/cpuid.asm
Normal file
280
Src/libvpShared/corelibs/CpuID/Win32/cpuid.asm
Normal file
|
@ -0,0 +1,280 @@
|
|||
;//==========================================================================
|
||||
;//
|
||||
;// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
|
||||
;// KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
|
||||
;// IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
|
||||
;// PURPOSE.
|
||||
;//
|
||||
;// Copyright (c) 1999 - 2001 On2 Technologies Inc. All Rights Reserved.
|
||||
;//
|
||||
;//--------------------------------------------------------------------------
|
||||
|
||||
|
||||
;
|
||||
; **-getCPUType
|
||||
;
|
||||
; This function will return a code indicating the type of the processor
|
||||
; that is in the system. If the processor type is unknown the generic
|
||||
; x86 (Intel 486) type is returned
|
||||
;
|
||||
; parts taken from intel's AP-485
|
||||
;
|
||||
;put checks for cmov and mmx support ????
|
||||
;
|
||||
; Assumptions:
|
||||
; None
|
||||
;
|
||||
; Input:
|
||||
; None
|
||||
;
|
||||
; Output:
|
||||
; Code for CPU type returned. See cpuidlib.h for the supported
|
||||
; types.
|
||||
;
|
||||
|
||||
|
||||
|
||||
.586
|
||||
.MODEL flat, SYSCALL, os_dos
|
||||
.DATA
|
||||
|
||||
NAME x86cpuid
|
||||
|
||||
PUBLIC getCPUType_
|
||||
PUBLIC _getCPUType
|
||||
|
||||
CPU_ID MACRO
|
||||
db 0fh ; Hardcoded CPUID instruction
|
||||
db 0a2h
|
||||
ENDM
|
||||
|
||||
;see cpuidlib.h
|
||||
X86 EQU 0 ; /* 486, Pentium plain, or any other x86 compatible */
|
||||
PMMX EQU 1 ; /* Pentium with MMX */
|
||||
PPRO EQU 2 ; /* Pentium Pro */
|
||||
PII EQU 3 ; /* Pentium II */
|
||||
C6X86 EQU 4
|
||||
C6X86MX EQU 5
|
||||
AMDK63D EQU 6
|
||||
AMDK6 EQU 7
|
||||
AMDK5 EQU 8
|
||||
XMM EQU 11
|
||||
WMT EQU 12 ;/* Willamette */
|
||||
|
||||
|
||||
_486 EQU 4h
|
||||
PENT EQU 50h
|
||||
PENTMMX EQU 54h
|
||||
PENTPRO EQU 61h
|
||||
PENTII EQU 63h
|
||||
SIMD EQU 25
|
||||
|
||||
AMD_K63D EQU 58h
|
||||
AMD_K6 EQU 56h
|
||||
AMD_K5 EQU 50h ; K5 has models 0 - 6
|
||||
|
||||
_6X86 EQU 52h
|
||||
_6X86MX EQU 60h
|
||||
|
||||
|
||||
_vendor_id db "------------"
|
||||
intel_id db "GenuineIntel"
|
||||
amd_id db "AuthenticAMD"
|
||||
cyrix_id db "CyrixInstead"
|
||||
|
||||
.CODE
|
||||
|
||||
getCPUType_:
|
||||
_getCPUType:
|
||||
push esi ;safety sh*&
|
||||
push edi
|
||||
push ebp
|
||||
push ebx
|
||||
push ecx
|
||||
push edx
|
||||
|
||||
;------------------------------------------------
|
||||
; Intel486 processor check
|
||||
; Checking for ability to set/clear ID flag (Bit 21) in EFLAGS
|
||||
; which indicates the presence of a processor with the CPUID
|
||||
; instruction.
|
||||
;------------------------------------------------
|
||||
check_80486:
|
||||
pushfd ; push original EFLAGS
|
||||
pop eax ; get original EFLAGS
|
||||
mov ebp,X86 ; rv
|
||||
mov ecx, eax ; save original EFLAGS
|
||||
xor eax, 200000h ; flip ID bit in EFLAGS
|
||||
push eax ; save new EFLAGS value on stack
|
||||
popfd ; replace current EFLAGS value
|
||||
pushfd ; get new EFLAGS
|
||||
pop eax ; store new EFLAGS in EAX
|
||||
xor eax, ecx ; can not toggle ID bit,
|
||||
je end_cpu_type486 ; processor=80486
|
||||
|
||||
;------------------------------------------------
|
||||
; Execute CPUID instruction to not determine vendor, family,
|
||||
; model, stepping and features. For the purpose of this
|
||||
; code, only the initial set of CPUID information is saved.
|
||||
;------------------------------------------------
|
||||
; push ebx ; save registers
|
||||
; push esi
|
||||
; push edi
|
||||
; push edx
|
||||
; push ecx
|
||||
|
||||
; mov ebp,X86 ; rv
|
||||
|
||||
mov eax, 0 ; set up for CPUID instruction
|
||||
CPU_ID ; get and save vendor ID
|
||||
|
||||
mov DWORD PTR _vendor_id, ebx
|
||||
mov DWORD PTR _vendor_id[+4], edx
|
||||
mov DWORD PTR _vendor_id[+8], ecx
|
||||
|
||||
cmp DWORD PTR intel_id, ebx
|
||||
jne IsProc_AMD
|
||||
cmp DWORD PTR intel_id[+4], edx
|
||||
jne end_cpuid_type
|
||||
cmp DWORD PTR intel_id[+8], ecx
|
||||
jne end_cpuid_type ; if not equal, not an Intel processor
|
||||
|
||||
cmp eax, 1 ; make sure 1 is valid input for CPUID
|
||||
jl end_cpuid_type ; if not, jump to end
|
||||
|
||||
mov eax, 1
|
||||
CPU_ID ; get family/model/stepping/features
|
||||
|
||||
mov ebp,XMM ; assume PIII
|
||||
|
||||
bt edx,SIMD ; check for SIMD support
|
||||
jnae end_cpuid_type
|
||||
|
||||
SIMDContinue:
|
||||
shr eax, 4 ; isolate family and model
|
||||
mov ebp,PII ; assume PII
|
||||
|
||||
and eax,0ffh ;mask out type and reserved
|
||||
nop
|
||||
|
||||
cmp eax,PENTII
|
||||
jge end_cpuid_type
|
||||
|
||||
mov ebp,PPRO
|
||||
|
||||
cmp eax,PENTPRO
|
||||
je end_cpuid_type
|
||||
|
||||
mov ebp,PMMX
|
||||
|
||||
cmp eax,PENTMMX
|
||||
je end_cpuid_type
|
||||
|
||||
mov ebp,X86
|
||||
|
||||
cmp eax,PENT
|
||||
jge end_cpuid_type
|
||||
|
||||
; mov ebp,X86
|
||||
|
||||
end_cpuid_type:
|
||||
mov eax,ebp
|
||||
|
||||
;remove these pops ???
|
||||
|
||||
; pop edi ; restore registers
|
||||
; pop esi
|
||||
; pop ebx
|
||||
; pop edx
|
||||
; pop ecx
|
||||
|
||||
end_cpu_type:
|
||||
pop edx ;safety sh*&
|
||||
pop ecx
|
||||
pop ebx
|
||||
pop ebp
|
||||
pop edi
|
||||
pop esi
|
||||
ret
|
||||
|
||||
end_cpu_type486:
|
||||
mov eax,ebp
|
||||
pop edx ;safety sh*&
|
||||
pop ecx
|
||||
pop ebx
|
||||
pop ebp
|
||||
pop edi
|
||||
pop esi
|
||||
ret
|
||||
|
||||
;------------------------------------------------
|
||||
IsProc_AMD:
|
||||
cmp DWORD PTR amd_id, ebx
|
||||
jne IsProc_CYRIX
|
||||
|
||||
cmp DWORD PTR amd_id[+4], edx
|
||||
jne end_cpuid_type
|
||||
|
||||
cmp DWORD PTR amd_id[+8], ecx
|
||||
jne end_cpuid_type ; if not equal, not an AMD processor
|
||||
|
||||
cmp eax, 1 ; make sure 1 is valid input for CPUID
|
||||
jl end_cpuid_type ; if not, jump to end
|
||||
|
||||
mov eax, 1
|
||||
CPU_ID ; get family/model/stepping/features
|
||||
|
||||
shr eax, 4 ; isolate family and model
|
||||
mov ebp,AMDK63D
|
||||
|
||||
and eax,0ffh ;mask out type and reserved
|
||||
nop
|
||||
|
||||
cmp eax,AMD_K63D
|
||||
jge end_cpuid_type
|
||||
|
||||
mov ebp,AMDK6
|
||||
nop
|
||||
|
||||
cmp eax,AMD_K6
|
||||
jge end_cpuid_type
|
||||
|
||||
mov ebp,X86
|
||||
nop
|
||||
|
||||
cmp eax,AMD_K5
|
||||
jge end_cpuid_type
|
||||
|
||||
mov ebp,X86
|
||||
jmp end_cpuid_type
|
||||
|
||||
;------------------------------------------------
|
||||
IsProc_CYRIX:
|
||||
cmp DWORD PTR cyrix_id, ebx
|
||||
jne end_cpuid_type
|
||||
|
||||
cmp DWORD PTR cyrix_id[+4], edx
|
||||
jne end_cpuid_type
|
||||
|
||||
cmp DWORD PTR cyrix_id[+8], ecx
|
||||
jne end_cpuid_type ; if not equal, not an CYRIX processor
|
||||
|
||||
cmp eax, 1 ; make sure 1 is valid input for CPUID
|
||||
jl end_cpuid_type ; if not, jump to end
|
||||
|
||||
mov eax, 1
|
||||
CPU_ID ; get family/model/stepping/features
|
||||
|
||||
shr eax, 4 ; isolate family and model
|
||||
mov ebp,C6X86MX
|
||||
|
||||
and eax,0ffh ;mask out type and reserved
|
||||
nop
|
||||
|
||||
cmp eax,_6X86MX
|
||||
je end_cpuid_type
|
||||
|
||||
mov ebp,X86
|
||||
jmp end_cpuid_type
|
||||
;************************************************
|
||||
END
|
Loading…
Add table
Add a link
Reference in a new issue