⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cpuinfo.c

📁 BIOS emulator and interface to Realmode X86 Emulator Library Can emulate a PCI Graphic Controller V
💻 C
📖 第 1 页 / 共 2 页
字号:
/******************************************************************************					SciTech OS Portability Manager Library**  ========================================================================**    The contents of this file are subject to the SciTech MGL Public*    License Version 1.0 (the "License"); you may not use this file*    except in compliance with the License. You may obtain a copy of*    the License at http://www.scitechsoft.com/mgl-license.txt**    Software distributed under the License is distributed on an*    "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or*    implied. See the License for the specific language governing*    rights and limitations under the License.**    The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc.**    The Initial Developer of the Original Code is SciTech Software, Inc.*    All Rights Reserved.**  ========================================================================** Language:		ANSI C* Environment:	Any** Description:	Main module to implement the Zen Timer support functions.*****************************************************************************/#include "ztimer.h"#include "pmapi.h"#include "oshdr.h"/*----------------------------- Implementation ----------------------------*//* External Intel assembler functions */#ifdef	__INTEL__/* {secret} */ibool	_ASMAPI _CPU_haveCPUID(void);/* {secret} */ibool	_ASMAPI _CPU_check80386(void);/* {secret} */ibool	_ASMAPI _CPU_check80486(void);/* {secret} */int 	_ASMAPI _CPU_inp(int port);/* {secret} */void 	_ASMAPI _CPU_outp(int port,int value);/* {secret} */uint	_ASMAPI _CPU_checkCPUID(void);/* {secret} */uint	_ASMAPI _CPU_getCPUIDModel(void);/* {secret} */uint	_ASMAPI _CPU_getCPUIDFeatures(void);/* {secret} */uint	_ASMAPI _CPU_have3DNow(void);/* {secret} */ibool	_ASMAPI _CPU_checkClone(void);/* {secret} */ulong	_ASMAPI _CPU_quickRDTSC(void);/* {secret} */void	_ASMAPI	_CPU_runBSFLoop(ulong iterations);/* {secret} */void ZTimerQuickInit(void);#define	CPU_HaveMMX		0x00800000#define	CPU_HaveRDTSC	0x00000010#endif#if		defined(__SMX32__)#include "smx/cpuinfo.c"#elif	defined(__RTTARGET__)#include "rttarget/cpuinfo.c"#elif	defined(__REALDOS__)#include "dos/cpuinfo.c"#elif	defined(__WIN32_VXD__)#include "vxd/cpuinfo.c"#elif	defined(__WINDOWS32__)#include "win32/cpuinfo.c"#elif	defined(__OS2__)#include "os2/cpuinfo.c"#elif	defined(__LINUX__)#include "linux/cpuinfo.c"#elif	defined(__QNX__)#include "qnx/cpuinfo.c"#elif	defined(__BEOS__)#include "beos/cpuinfo.c"#else#error	CPU library not ported to this platform yet!#endif/*------------------------ Public interface routines ----------------------*//****************************************************************************REMARKS:Read an I/O port location.****************************************************************************/static uchar rdinx(	int port,	int index){	_CPU_outp(port,index);	return _CPU_inp(port+1);}/****************************************************************************REMARKS:Write an I/O port location.****************************************************************************/static void wrinx(	ushort port,	ushort index,	ushort value){	_CPU_outp(port,index);	_CPU_outp(port+1,value);}/****************************************************************************REMARKS:Enables the Cyrix CPUID instruction to properly detect MediaGX and 6x86processors.****************************************************************************/static void _CPU_enableCyrixCPUID(void){	uchar	ccr3;	PM_init();	ccr3 = rdinx(0x22,0xC3);	wrinx(0x22,0xC3,(uchar)(ccr3 | 0x10));	wrinx(0x22,0xE8,(uchar)(rdinx(0x22,0xE8) | 0x80));	wrinx(0x22,0xC3,ccr3);}/****************************************************************************DESCRIPTION:Returns the type of processor in the system.HEADER:ztimer.hRETURNS:Numerical identifier for the installed processorREMARKS:Returns the type of processor in the system. Note that if the CPU is anunknown Pentium family processor that we don't have an enumeration for,the return value will be greater than or equal to the value of CPU_UnkPentium(depending on the value returned by the CPUID instruction).SEE ALSO:CPU_getProcessorSpeed, CPU_haveMMX****************************************************************************/uint ZAPI CPU_getProcessorType(void){#if		defined(__INTEL__)	uint			cpu,vendor,model;	static ibool	firstTime = true;	if (_CPU_haveCPUID()) {		cpu = _CPU_checkCPUID();		vendor = cpu & ~CPU_mask;		if (vendor == CPU_Intel) {			/* Check for Intel processors */			switch (cpu & CPU_mask) {				case 4:	cpu = CPU_i486;			break;				case 5:	cpu = CPU_Pentium;		break;				case 6:					if ((model = _CPU_getCPUIDModel()) == 1)						cpu = CPU_PentiumPro;					else if (model <= 6)						cpu = CPU_PentiumII;					else if (model == 7)						cpu = CPU_PentiumIII;					break;				default:					cpu = CPU_UnkIntel;				}			}		else if (vendor == CPU_Cyrix) {			/* Check for Cyrix processors */			switch (cpu & CPU_mask) {				case 4:					if ((model = _CPU_getCPUIDModel()) == 4)						cpu = CPU_CyrixMediaGX;					else						cpu = CPU_UnkCyrix;					break;				case 5:					if ((model = _CPU_getCPUIDModel()) == 2)						cpu = CPU_Cyrix6x86;					else if (model == 4)						cpu = CPU_CyrixMediaGXm;					else						cpu = CPU_UnkCyrix;					break;				case 6:					if ((model = _CPU_getCPUIDModel()) <= 1)						cpu = CPU_Cyrix6x86MX;					else						cpu = CPU_UnkCyrix;					break;				default:					cpu = CPU_UnkCyrix;				}			}		else if (vendor == CPU_AMD) {			/* Check for AMD processors */			switch (cpu & CPU_mask) {				case 4:					if ((model = _CPU_getCPUIDModel()) == 0)						cpu = CPU_AMDAm5x86;					else						cpu = CPU_AMDAm486;					break;				case 5:					if ((model = _CPU_getCPUIDModel()) <= 3)						cpu = CPU_AMDK5;					else if (model <= 7)						cpu = CPU_AMDK6;					else if (model == 8)						cpu = CPU_AMDK6_2;					else if (model == 9)						cpu = CPU_AMDK6_III;					else						cpu = CPU_UnkAMD;					break;				case 6:					if ((model = _CPU_getCPUIDModel()) == 1)						cpu = CPU_AMDAthlon;					break;				default:					cpu = CPU_UnkAMD;				}			}		else if (vendor == CPU_IDT) {			/* Check for IDT WinChip processors */			switch (cpu & CPU_mask) {				case 5:					if ((model = _CPU_getCPUIDModel()) <= 4)						cpu = CPU_WinChipC6;					else if (model == 8)						cpu = CPU_WinChip2;					else						cpu = CPU_UnkIDT;					break;				default:					cpu = CPU_UnkIDT;				}			}		else {			/* Assume a Pentium compatible Intel clone */			cpu = CPU_Pentium;			}		return cpu | vendor;		}	else {		if (_CPU_check80386())			cpu = CPU_i386;		else  if (_CPU_check80486()) {			/* If we get here we may have a Cyrix processor so we can try			 * enabling the CPUID instruction and trying again.			 */			if (firstTime) {				firstTime = false;				_CPU_enableCyrixCPUID();				return CPU_getProcessorType();				}			cpu = CPU_i486;			}		else			cpu = CPU_Pentium;		if (!_CPU_checkClone())			return cpu | CPU_Intel;		return cpu;		}#elif	defined(__ALPHA__)	return CPU_Alpha;#elif	defined(__MIPS__)	return CPU_Mips;#elif	defined(__PPC__)	return CPU_PowerPC;#endif}/****************************************************************************DESCRIPTION:Returns true if the processor supports Intel MMX extensions.HEADER:ztimer.hRETURNS:True if MMX is available, false if not.REMARKS:This function determines if the processor supports the Intel MMX extendedinstruction set.SEE ALSO:CPU_getProcessorType, CPU_getProcessorSpeed, CPU_have3DNow, CPU_haveKNI****************************************************************************/ibool ZAPI CPU_haveMMX(void)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -