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

📄 init.c

📁 内核linux2.4.20,可跟rtlinux3.2打补丁 组成实时linux系统,编译内核
💻 C
📖 第 1 页 / 共 5 页
字号:
	SiS_SetReg1 (SiS_P3c4, 0x21, (USHORT) (data | 0x20));	/* enable read cache */}#endifvoidSiS_SetMemoryClock (ULONG ROMAddr){	SiS_SetReg1 (SiS_P3c4, 0x28, SiS_MCLKData[SiS_RAMType].SR28);	SiS_SetReg1 (SiS_P3c4, 0x29, SiS_MCLKData[SiS_RAMType].SR29);	SiS_SetReg1 (SiS_P3c4, 0x2A, SiS_MCLKData[SiS_RAMType].SR2A);	SiS_SetReg1 (SiS_P3c4, 0x2E, SiS_ECLKData[SiS_RAMType].SR2E);	SiS_SetReg1 (SiS_P3c4, 0x2F, SiS_ECLKData[SiS_RAMType].SR2F);	SiS_SetReg1 (SiS_P3c4, 0x30, SiS_ECLKData[SiS_RAMType].SR30);#ifdef CONFIG_FB_SIS_315	if (Is315E ()) {		SiS_SetReg1 (SiS_P3c4, 0x28, 0x3B);	/* 143 */		SiS_SetReg1 (SiS_P3c4, 0x29, 0x22);		SiS_SetReg1 (SiS_P3c4, 0x2E, 0x3B);	/* 143 */		SiS_SetReg1 (SiS_P3c4, 0x2F, 0x22);	}#endif}/*========================================= ======== SiS SetMode Function  ===================================================*/BOOLEANSiSSetMode (PSIS_HW_DEVICE_INFO HwDeviceExtension, USHORT ModeNo){	ULONG temp;	USHORT ModeIdIndex, KeepLockReg;	ULONG ROMAddr = (ULONG) HwDeviceExtension->pjVirtualRomBase;	/*ULONG   FBAddr   = (ULONG)HwDeviceExtension->pjVideoMemoryAddress; */	USHORT BaseAddr = (USHORT) HwDeviceExtension->ulIOAddress;#ifdef CONFIG_FB_SIS_315	if ((HwDeviceExtension->jChipType == SIS_315H) ||	/* 05/02/01 ynlai for sis550 */	    (HwDeviceExtension->jChipType == SIS_315PRO) ||	    (HwDeviceExtension->jChipType == SIS_550) ||	    (HwDeviceExtension->jChipType == SIS_640) ||	/* 08/20/01 chiawen for 640/740 */	    (HwDeviceExtension->jChipType == SIS_740))	/* 09/03/01 chiawen for 650 */		InitTo310Pointer ();#endif#ifdef CONFIG_FB_SIS_300	if ((HwDeviceExtension->jChipType == SIS_540) ||	    (HwDeviceExtension->jChipType == SIS_630) ||	    (HwDeviceExtension->jChipType == SIS_730) ||	    (HwDeviceExtension->jChipType == SIS_300))		InitTo300Pointer ();#endif	SiS_P3c4 = BaseAddr + 0x14;	SiS_P3d4 = BaseAddr + 0x24;	SiS_P3c0 = BaseAddr + 0x10;	SiS_P3ce = BaseAddr + 0x1e;	SiS_P3c2 = BaseAddr + 0x12;	SiS_P3ca = BaseAddr + 0x1a;	SiS_P3c6 = BaseAddr + 0x16;	SiS_P3c7 = BaseAddr + 0x17;	SiS_P3c8 = BaseAddr + 0x18;	SiS_P3c9 = BaseAddr + 0x19;	SiS_P3da = BaseAddr + 0x2A;	SiS_Part1Port = BaseAddr + SIS_CRT2_PORT_04;	SiS_Part2Port = BaseAddr + SIS_CRT2_PORT_10;	SiS_Part3Port = BaseAddr + SIS_CRT2_PORT_12;	SiS_Part4Port = BaseAddr + SIS_CRT2_PORT_14;	SiS_Part5Port = BaseAddr + SIS_CRT2_PORT_14 + 2;	SiS_IF_DEF_LVDS = 0;	SiS_IF_DEF_CH7005 = 0;	SiS_IF_DEF_HiVision = 0;	SiS_IF_DEF_DSTN = 0;	/*for 550 dstn */	if ((HwDeviceExtension->jChipType == SIS_540) ||	    (HwDeviceExtension->jChipType == SIS_630) ||	    (HwDeviceExtension->jChipType == SIS_730) ||	    (HwDeviceExtension->jChipType == SIS_550) ||	    (HwDeviceExtension->jChipType == SIS_640) ||	/* 08/20/01 chiawen for 640/740 */	    (HwDeviceExtension->jChipType == SIS_740)) {	/* 09/03/01 chiawen for 650 */		temp = SiS_GetReg1 (SiS_P3d4, 0x37);		temp = (temp & 0x0E) >> 1;		if ((temp == 0) || (temp == 1)) {	/* for 301 */			SiS_IF_DEF_LVDS = 0;			SiS_IF_DEF_CH7005 = 0;			SiS_IF_DEF_TRUMPION = 0;		}		if ((temp >= 2) && (temp <= 5)) {			SiS_IF_DEF_LVDS = 1;		}		if (temp == 3)			SiS_IF_DEF_TRUMPION = 1;		if ((temp == 4) || (temp == 5))			SiS_IF_DEF_CH7005 = 1;	} else {		SiS_IF_DEF_LVDS = 0;		SiS_IF_DEF_TRUMPION = 0;		SiS_IF_DEF_CH7005 = 0;	}	if (ModeNo & 0x80) {		ModeNo = ModeNo & 0x7F;		flag_clearbuffer = 0;	} else {		flag_clearbuffer = 1;	}	SiS_PresetScratchregister (SiS_P3d4, HwDeviceExtension);	/*add for CRT2  */	KeepLockReg = SiS_GetReg1 (SiS_P3c4, 0x05);	SiS_SetReg1 (SiS_P3c4, 0x05, 0x86);	/* 1.Openkey */	temp = SiS_SearchModeID (ROMAddr, ModeNo, &ModeIdIndex);	/* 2.Get ModeID Table  */	if (temp == 0)		return (0);	/*301b */	SiS_GetVBType (BaseAddr);	/*end 301b */	SiS_GetVBInfo301 (BaseAddr, ROMAddr, ModeNo, ModeIdIndex, HwDeviceExtension);	/*add for CRT2 */	SiS_GetLCDResInfo301 (ROMAddr, SiS_P3d4, ModeNo, ModeIdIndex);	/*add for CRT2 */	temp = SiS_CheckMemorySize (ROMAddr, HwDeviceExtension, ModeNo, ModeIdIndex);	/*3.Check memory size */	if (temp == 0)		return (0);	if (SiS_VBInfo & (SetSimuScanMode | SetCRT2ToLCDA)) {	/*301b */		SiS_SetCRT1Group (ROMAddr, HwDeviceExtension, ModeNo,				  ModeIdIndex);	} else {		if (!(SiS_VBInfo & SwitchToCRT2)) {			SiS_SetCRT1Group (ROMAddr, HwDeviceExtension, ModeNo,					  ModeIdIndex);		}	}	if (SiS_VBInfo & (SetSimuScanMode | SwitchToCRT2 | SetCRT2ToLCDA)) {	/*301b */		switch (HwDeviceExtension->ujVBChipID) {/*karl*/		case VB_CHIP_301:		case VB_CHIP_301B:			SiS_SetCRT2Group301 (BaseAddr, ROMAddr, ModeNo, HwDeviceExtension);	/*add for CRT2 */			break;		case VB_CHIP_302:			SiS_SetCRT2Group301 (BaseAddr, ROMAddr, ModeNo,					     HwDeviceExtension);			break;		case VB_CHIP_303:/*        SetCRT2Group302(BaseAddr,ROMAddr,ModeNo, HwDeviceExtension);                       add for CRT2   */			break;		case VB_CHIP_UNKNOWN:	/*add for lvds ch7005 */			temp = SiS_GetReg1 (SiS_P3d4, 0x37);			if (temp &			    (ExtChipLVDS | ExtChipTrumpion | ExtChipCH7005)) {				SiS_SetCRT2Group301 (BaseAddr, ROMAddr, ModeNo,						     HwDeviceExtension);			}			break;		}	}	if (KeepLockReg == 0xA1)		SiS_SetReg1 (SiS_P3c4, 0x05, 0x86);	/* 05/02/01 ynlai */	else		SiS_SetReg1 (SiS_P3c4, 0x05, 0x00);	return TRUE;}voidSiS_SetCRT1Group (ULONG ROMAddr, PSIS_HW_DEVICE_INFO HwDeviceExtension,		  USHORT ModeNo, USHORT ModeIdIndex){	USHORT StandTableIndex, RefreshRateTableIndex;	USHORT temp;	/*SiS_SetReg1(SiS_P3d4,0x34,ModeNo); */	SiS_CRT1Mode = ModeNo;	/* set CR34->CRT1 ModeNofor CRT2 FIFO */	StandTableIndex = SiS_GetModePtr (ROMAddr, ModeNo, ModeIdIndex);	/* 4.GetModePtr  */	SiS_SetSeqRegs (ROMAddr, StandTableIndex);	/* 5.SetSeqRegs  */	SiS_SetMiscRegs (ROMAddr, StandTableIndex);	/* 6.SetMiscRegs */	SiS_SetCRTCRegs (ROMAddr, HwDeviceExtension, StandTableIndex);	/* 7.SetCRTCRegs */	SiS_SetATTRegs (ROMAddr, StandTableIndex);	/* 8.SetATTRegs  */	SiS_SetGRCRegs (ROMAddr, StandTableIndex);	/* 9.SetGRCRegs  */	SiS_ClearExt1Regs ();	/* 10.Clear Ext1Regs */	temp = ~ProgrammingCRT2;	/*       11.GetRatePtr  */	SiS_SetFlag = SiS_SetFlag & temp;	SiS_SelectCRT2Rate = 0;	/*301b */	if ((SiS_VBType & VB_SIS301B) || (SiS_VBType & VB_SIS302B)) {		if (SiS_VBInfo & SetCRT2ToLCDA) {			SiS_SetFlag = SiS_SetFlag | ProgrammingCRT2;			/*   SiS_SelectCRT2Rate=4; */		}	}	/*end 301b */	RefreshRateTableIndex = SiS_GetRatePtrCRT2 (ROMAddr, ModeNo, ModeIdIndex);	/* 11.GetRatePtr */	/*301b */	if ((SiS_VBType & VB_SIS301B) || (SiS_VBType & VB_SIS302B)) {		if (!(SiS_VBInfo & SetCRT2ToLCDA)) {			SiS_SetFlag = SiS_SetFlag & (~ProgrammingCRT2);		}	}	/*end 301b */	if (RefreshRateTableIndex != 0xFFFF) {		SiS_SetSync (ROMAddr, RefreshRateTableIndex);	/* 12.SetSync */		SiS_SetCRT1CRTC (ROMAddr, ModeNo, ModeIdIndex, RefreshRateTableIndex);	/* 13.SetCRT1CRTC  */		SiS_SetCRT1Offset (ROMAddr, ModeNo, ModeIdIndex,				   RefreshRateTableIndex, HwDeviceExtension);	/* 14.SetCRT1Offset */		SiS_SetCRT1VCLK (ROMAddr, ModeNo, ModeIdIndex,				 HwDeviceExtension, RefreshRateTableIndex);	/* 15.SetCRT1VCLK  */	}#ifdef CONFIG_FB_SIS_300	if ((HwDeviceExtension->jChipType == SIS_630) ||	    (HwDeviceExtension->jChipType == SIS_540)) {		SiS_SetCRT1FIFO2 (ROMAddr, ModeNo, HwDeviceExtension,				  RefreshRateTableIndex);	}#endif#ifdef CONFIG_FB_SIS_315	if (HwDeviceExtension->jChipType >= SIS_315H) {		SiS_SetCRT1FIFO (ROMAddr, ModeNo, HwDeviceExtension);	}#endif	SiS_SetCRT1ModeRegs (ROMAddr, HwDeviceExtension, ModeNo, ModeIdIndex,			     RefreshRateTableIndex);	SiS_SetVCLKState (ROMAddr, HwDeviceExtension, ModeNo,			  RefreshRateTableIndex);#ifdef CONFIG_FB_SIS_315	if (HwDeviceExtension->jChipType > SIS_315H)		SiS_SetInterlace (ROMAddr, ModeNo, RefreshRateTableIndex);#endif	SiS_LoadDAC (ROMAddr, ModeNo, ModeIdIndex);	if (flag_clearbuffer)		SiS_ClearBuffer (HwDeviceExtension, ModeNo);	if (!(SiS_VBInfo & (SetSimuScanMode | SwitchToCRT2 | SetCRT2ToLCDA))) {	/*301b */		SiS_LongWait ();		SiS_DisplayOn ();	}}voidSiS_GetVBType (USHORT BaseAddr){	USHORT flag;	flag = SiS_GetReg1 (SiS_Part4Port, 0x00);	if (flag >= 2)		SiS_VBType = VB_SIS302B;	else {		flag = SiS_GetReg1 (SiS_Part4Port, 0x01);		if (flag >= 0xB0)			SiS_VBType = VB_SIS301B;		else			SiS_VBType = VB_SIS301;		flag = SiS_GetReg1 (SiS_Part4Port, 0x23);	/*301dlvds */		if (!(flag & 0x02))			SiS_VBType = SiS_VBType | VB_NoLCD;	}}/* win2000 MM adapter not support standard mode  */BOOLEANSiS_SearchModeID (ULONG ROMAddr, USHORT ModeNo, USHORT * ModeIdIndex){	PUCHAR VGA_INFO = "\0x11";	if (ModeNo <= 5)		ModeNo |= 1;	if (ModeNo <= 0x13) {		/* for (*ModeIdIndex=0;*ModeIdIndex<sizeof(SiS_SModeIDTable)/sizeof(SiS_StStruct);(*ModeIdIndex)++) */		for (*ModeIdIndex = 0;; (*ModeIdIndex)++) {			if (SiS_SModeIDTable[*ModeIdIndex].St_ModeID == ModeNo)				break;			if (SiS_SModeIDTable[*ModeIdIndex].St_ModeID == 0xFF)				return FALSE;		}#ifdef TC		VGA_INFO = (PUCHAR) MK_FP (0, 0x489);#endif		if (ModeNo == 0x07) {			if ((*VGA_INFO & 0x10) != 0)				(*ModeIdIndex)++;	/* 400 lines */			/* else 350 lines */		}		if (ModeNo <= 3) {			if ((*VGA_INFO & 0x80) == 0) {				(*ModeIdIndex)++;				if ((*VGA_INFO & 0x10) != 0)					(*ModeIdIndex)++;;	/* 400 lines  */				/* else 350 lines  */			}			/* else 200 lines  */		}	} else {		/* for (*ModeIdIndex=0;*ModeIdIndex<sizeof(SiS_EModeIDTable)/sizeof(SiS_ExtStruct);(*ModeIdIndex)++) */		for (*ModeIdIndex = 0;; (*ModeIdIndex)++) {			if (SiS_EModeIDTable[*ModeIdIndex].Ext_ModeID == ModeNo)				break;			if (SiS_EModeIDTable[*ModeIdIndex].Ext_ModeID == 0xFF)				return FALSE;		}	}	return TRUE;}/*add for 300 oem util for search VBModeID*/BOOLEANSiS_SearchVBModeID (ULONG ROMAddr, USHORT ModeNo){	USHORT ModeIdIndex;	// PUCHAR VGA_INFO;	if (ModeNo <= 5)		ModeNo |= 1;	/* for (ModeIdIndex=0;ModeIdIndex<sizeof(SiS_SModeIDTable)/sizeof(SiS_StStruct);(*ModeIdIndex)++) */	for (ModeIdIndex = 0;; (ModeIdIndex)++) {		if (SiS_VBModeIDTable[ModeIdIndex].ModeID == ModeNo)			break;		if (SiS_VBModeIDTable[ModeIdIndex].ModeID == 0xFF)			return FALSE;	}#ifdef TC	VGA_INFO = (PUCHAR) MK_FP (0, 0x489);	if (ModeNo == 0x07) {		if ((*VGA_INFO & 0x10) != 0)			(ModeIdIndex)++;	/* 400 lines */		/* else 350 lines */	}	if (ModeNo <= 3) {		if ((*VGA_INFO & 0x80) == 0) {			(ModeIdIndex)++;			if ((*VGA_INFO & 0x10) != 0)				(ModeIdIndex)++;;	/* 400 lines  */			/* else 350 lines  */		}		/* else 200 lines  */	}#endif	return ((BOOLEAN) ModeIdIndex);}/*end*//* win2000 MM adapter not support standard mode!  */BOOLEANSiS_CheckMemorySize (ULONG ROMAddr, PSIS_HW_DEVICE_INFO HwDeviceExtension,		     USHORT ModeNo, USHORT ModeIdIndex){	USHORT memorysize;	USHORT modeflag;	USHORT temp;	if (ModeNo <= 0x13) {		modeflag = SiS_SModeIDTable[ModeIdIndex].St_ModeFlag;	} else {		modeflag = SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag;	}/*  ModeType=modeflag&ModeInfoFlag;                           Get mode type  */	memorysize = modeflag & MemoryInfoFlag;	memorysize = memorysize > MemorySizeShift;	memorysize++;		/* Get memory size */	temp = SiS_GetReg1 (SiS_P3c4, 0x14);	/* Get DRAM Size    */	if ((HwDeviceExtension->jChipType == SIS_315H) ||	    (HwDeviceExtension->jChipType == SIS_315PRO)) {		temp = 1 << ((temp & 0x0F0) >> 4);		if ((temp & 0x0c) == 0x08) {	/* DDR asymetric */			temp += temp / 2;		} else {			if ((temp & 0x0c) != 0) {				temp <<= 1;			}		}	} else {		/* 300, 540 , 630 */		temp = temp & 0x3F;		temp++;		/*  temp=1 << ((temp&0x0F0)>>4); */	}	if ((HwDeviceExtension->jChipType == SIS_550) ||	/* 05/02/01 ynlai for sis550 */	    (HwDeviceExtension->jChipType == SIS_640) ||	/* 08/20/01 chiawen for 640/740 */	    (HwDeviceExtension->jChipType == SIS_740)) {	/* 09/03/01 chiawen for 650 */		return (TRUE);	}	if (temp < memorysize)		return (FALSE);	else		return (TRUE);}UCHARSiS_GetModePtr (ULONG ROMAddr, USHORT ModeNo, USHORT ModeIdIndex){	UCHAR index;	if (ModeNo <= 0x13) {		index = SiS_SModeIDTable[ModeIdIndex].St_StTableIndex;	} else {		if (SiS_ModeType <= 0x02)			index = 0x1B;	/* 02 -> ModeEGA  */		else			index = 0x0F;	}	return index;		/* Get SiS_StandTable index  */}voidSiS_SetSeqRegs (ULONG ROMAddr, USHORT StandTableIndex){	UCHAR SRdata;	USHORT i;	SiS_SetReg1 (SiS_P3c4, 0x00, 0x03);	/* Set SR0  */	SRdata = SiS_StandTable[StandTableIndex].SR[0];	/*301b */	if ((SiS_VBType & VB_SIS301B) || (SiS_VBType & VB_SIS302B)) {		if (SiS_VBInfo & SetCRT2ToLCDA) {			SRdata = SRdata | 0x01;		}	}	/*end

⌨️ 快捷键说明

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