home *** CD-ROM | disk | FTP | other *** search
- /* $Archive: /General Utilities/CPUID/ckcpubit.cpp $
- $Author : $
- $Date : $
- $Header : $
- $History: ckcpubit.cpp $
- *
- * ***************** Version 6 *****************
- * User: Tanb Date: 7/18/96 Time: 4:52p
- * Updated in $/General Utilities/CPUID
- * Make the display look better
- */
-
-
- #include "DEFINES.H"
-
- // This function checks the processor ID bit (bit 21) in the EFLAGS
- // register. The program abort if the processor does not implement the CPUID
- // instruction.
-
- int cpuid::chkcpubit(void)
- {
- asm {
- .486
- pushfd //save EFLAGS
- pop eax
- test eax,0x00200000 //check ID bit (bit 21)
- jz set_21 //bit 21 is not set, so jump to set_21
- and eax,0xffdfffff //clear bit 21
- push eax //save new value in register
- popfd //store new value in flags
- pushfd
- pop eax
- test eax,0x00200000 //check ID bit
- jz cpu_id_ok //if bit 21 is clear,then jump to cpu_id_ok
- jmp err //if bit 21 is set, so CPUID inst is not
- } //supporting
- set_21:
- asm {
- or eax,0x00200000 //set bit 21
- push eax //store new value
- popfd //store new value in EFLAGS
- pushfd
- pop eax
- test eax,0x00200000 //if bit 21 is on
- jnz cpu_id_ok //then jump to cpu_id_ok
- }
- err:
- asm {
- mov eax,0xffffffff //CPUID inst is not supported
- jmp exit // so exit
- }
- cpu_id_ok: //Support CPUID inst
- asm mov eax,0 // return 0
-
- exit:
- if(_EAX == 0xffffffff){
- return (-1);
- }
- if (_EAX == 0x0) {
- return (0);
- }
- }
-