sis_301.c
来自「讲述linux的初始化过程」· C语言 代码 · 共 2,841 行 · 第 1/5 页
C
2,841 行
if(tempbh&0x01){ tempcl=tempcl|0x04; } if(tempbh&0x02){ tempcl=tempcl|0x080; } if(tempbh&0x04){ tempch=tempch|0x08; } tempax=temp2; //pop ax tempax=(tempax>>2)+1; tempbx=tempbx+tempax; tempah=(tempbx&0x0FF)&0x0F; SetReg1(Part1Port,0x0D,tempah); //0x0D vertical Retrace End tempbl=tempbx&0x0FF; if(tempbl&0x10){ tempch=tempch|0x020; } tempah=tempcl; SetReg1(Part1Port,0x0A,tempah); //0x0A CR07 tempah=tempch; SetReg1(Part1Port,0x17,tempah); //0x17 SR0A tempax=*((USHORT *)(ROMAddr+ModeIDOffset+0x01)); // si+St_ModeFlag tempah=(tempax&0xFF00)>>8; tempah=(tempah>>1)&0x09; SetReg1(Part1Port,0x16,tempah); //0x16 SR01 SetReg1(Part1Port,0x0F,0); //0x0F CR14 SetReg1(Part1Port,0x12,0); //0x12 CR17 SetReg1(Part1Port,0x1A,0); //0x1A SR0E REFIndex=OldREFIndex; //pop di}VOID SetCRT2Offset(USHORT Part1Port,ULONG ROMAddr){ USHORT offset; if(VBInfo&SetInSlaveMode){ return; } offset=GetOffset(ROMAddr); SetReg1(Part1Port,0x07,(USHORT)(offset&0xFF)); SetReg1(Part1Port,0x09,(USHORT)((offset&0xFF00)>>8)); SetReg1(Part1Port,0x03,(USHORT)(((offset>>3)&0xFF)+1));}USHORT GetOffset(ULONG ROMAddr){ USHORT tempal,temp1,colordepth; tempal=*((UCHAR *)(ROMAddr+ModeIDOffset+0x03)); // si+Ext_ModeInfo tempal=(tempal>>4)&0xFF; ScreenOffset=*((USHORT *)(ROMAddr+0x206)); // Get ScreeOffset table tempal=*((UCHAR *)(ROMAddr+ScreenOffset+tempal)); // get ScreenOffset tempal=tempal&0xFF; temp1=*((UCHAR *)(ROMAddr+REFIndex)); //di+Ext_InfoFlag if(temp1&InterlaceMode){ tempal=tempal<<1; } colordepth=GetColorDepth(ROMAddr); return(tempal*colordepth); }USHORT GetColorDepth(ULONG ROMAddr){ USHORT ColorDepth[6]={1,2,4,4,6,8}; USHORT temp; int temp1; temp=*((USHORT *)(ROMAddr+ModeIDOffset+0x01)); // si+St_ModeFlag temp1=(temp&ModeInfoFlag)-ModeEGA; if(temp1<0) temp1=0; return(ColorDepth[temp1]);}VOID SetCRT2FIFO(USHORT Part1Port,ULONG ROMAddr,USHORT ModeNo, PHW_DEVICE_EXTENSION HwDeviceExtension){ USHORT temp,temp1,temp2,temp3,flag; USHORT vclk2ptr,latencyindex; USHORT oldREFIndex,CRT1ModeNo,oldModeIDOffset; long int longtemp; USHORT LatencyFactor[48]={ 88, 80, 78, 72, 70, 00, // 64 bit BQ=2 00, 79, 77, 71, 69, 49, // 64 bit BQ=1 88, 80, 78, 72, 70, 00, // 128 bit BQ=2 00, 72, 70, 64, 62, 44, // 128 bit BQ=1 73, 65, 63, 57, 55, 00, // 64 bit BQ=2 00, 64, 62, 56, 54, 34, // 64 bit BQ=1 78, 70, 68, 62, 60, 00, // 128 bit BQ=2 00, 62, 60, 54, 52, 34}; // 128 bit BQ=1 oldREFIndex=(USHORT)REFIndex; //push REFIndex(CRT2 now) oldModeIDOffset=(USHORT)ModeIDOffset; //push ModeIDOffset CRT1ModeNo=(UCHAR)GetReg1(P3d4,0x34); //get CRT1 ModeNo SearchModeID(ROMAddr,CRT1ModeNo); //Get ModeID Table GetRatePtr(ROMAddr,CRT1ModeNo); //Set REFIndex-> for crt1 refreshrate temp1=GetVCLK(ROMAddr,CRT1ModeNo,HwDeviceExtension); temp2=GetColorTh(ROMAddr); temp3=GetMCLK(ROMAddr); temp=((USHORT)(temp1*temp2)/temp3); //temp->bx temp1=(UCHAR)GetReg1(P3c4,0x14); //SR_14 temp1=temp1>>6; temp1=temp1<<1; if(temp1==0) temp1=1; temp1=temp1<<2; //temp1->ax longtemp=temp1-temp; temp2=(USHORT)((28*16)/(int)longtemp); //temp2->cx if(!((temp2*(int)longtemp)==(28*16))) temp2++; if( HwDeviceExtension->jChipID == SIS_Glamour ){ temp1=CalcDelay(); }else{ //for Trojan and Spartan flag=(UCHAR)GetReg1(P3c4,0x14); //SR_14 if(flag&0x80){ latencyindex=12; //128 bit }else{ latencyindex=0; //64 bit } flag=GetQueueConfig(); if(!(flag&0x01)){ latencyindex+=24; //GUI timing =0 } if(flag&0x10){ latencyindex+=6; //BQ =2 } latencyindex=latencyindex + (flag>>5); temp1= LatencyFactor[latencyindex]; temp1=temp1+15; flag=(UCHAR)GetReg1(P3c4,0x14); //SR_14 if(!(flag&0x80)){ temp1=temp1+5; //64 bit } } temp2=temp2+temp1; REFIndex=oldREFIndex; //pop REFIndex(CRT2) ModeIDOffset=oldModeIDOffset; //pop ModeIDOffset vclk2ptr=GetVCLK2Ptr(ROMAddr,ModeNo); temp1=*((USHORT *)(ROMAddr+vclk2ptr+(VCLKLen-2))); temp3=GetColorTh(ROMAddr); longtemp=temp1*temp2*temp3; temp3=GetMCLK(ROMAddr); temp3=temp3<<4; temp2=(int)(longtemp/temp3); if((long int)temp2*(long int)temp3<(long int)longtemp) temp2++; //temp2->cx temp1=(UCHAR)GetReg1(Part1Port,0x01); //part1port index 01 if( (HwDeviceExtension->jChipID == SIS_Trojan ) && ((HwDeviceExtension->revision_id & 0xf0) == 0x30) ) /* 630s */ { temp1=(temp1&(~0x1F))|0x19; }else { temp1=(temp1&(~0x1F))|0x16; } SetReg1(Part1Port,0x01,temp1); if(temp2<=6) temp2=6; if(temp2>0x14) temp2=0x14; temp1=(UCHAR)GetReg1(Part1Port,0x02); //part1port index 02 temp1=(temp1&(~0x1F))|temp2; SetReg1(Part1Port,0x02,temp1);}USHORT GetVCLK(ULONG ROMAddr,USHORT ModeNo, PHW_DEVICE_EXTENSION HwDeviceExtension){ USHORT tempptr; USHORT temp1; tempptr=GetVCLKPtr(ROMAddr,ModeNo); temp1=*((USHORT *)(ROMAddr+tempptr+(VCLKLen-2))); return temp1;}USHORT GetQueueConfig(void){ USHORT tempal,tempbl; ULONG tempeax; SetReg4(0xcf8,0x80000050); tempeax=GetReg3(0xcfc); tempeax=(tempeax>>24)&0x0f; tempbl=(USHORT)tempeax; tempbl=tempbl<<4; SetReg4(0xcf8,0x800000A0); tempeax=GetReg3(0xcfc); tempeax=(tempeax>>24)&0x0f; tempal=(USHORT)tempeax; tempbl=tempbl|tempal; return(tempbl);}USHORT GetVCLKPtr(ULONG ROMAddr,USHORT ModeNo){ USHORT tempal; tempal=(UCHAR)GetReg2((USHORT)(P3ca+0x02)); // Port 3cch tempal=((tempal>>2)&0x03); if(ModeNo>0x13){ tempal=*((UCHAR *)(ROMAddr+REFIndex+0x03)); //di+Ext_CRTVCLK tempal=tempal&0x03F; } VCLKLen=GetVCLKLen(ROMAddr); tempal=tempal*VCLKLen; tempal=tempal+(*((USHORT *)(ROMAddr+0x208))); // VCLKData return ((USHORT)tempal);}USHORT GetColorTh(ULONG ROMAddr){ USHORT temp; temp=GetColorDepth(ROMAddr); temp=temp>>1; if(temp==0) temp++; return temp;}USHORT GetMCLK(ULONG ROMAddr){ USHORT tempmclkptr; USHORT tempmclk; tempmclkptr=GetMCLKPtr(ROMAddr); tempmclk=*((USHORT *)(ROMAddr+tempmclkptr+0x03)); //di+3 return tempmclk;}USHORT GetMCLKPtr(ULONG ROMAddr){ USHORT tempdi; USHORT tempdramtype,tempax; tempdi=*((USHORT *)(ROMAddr+0x20C)); // MCLKData tempdramtype=GetDRAMType(ROMAddr); tempax=5*tempdramtype; tempdi=tempdi+tempax; return (tempdi); }USHORT GetDRAMType(ULONG ROMAddr){ USHORT tsoftsetting,temp3; tsoftsetting=*((UCHAR *)(ROMAddr+0x52)); if(!(tsoftsetting&SoftDramType)){ temp3=(UCHAR)GetReg1(P3c4,0x3A); tsoftsetting=temp3; } tsoftsetting=tsoftsetting&0x07; return(tsoftsetting);}static USHORT CalcDelay(){ USHORT tempal,tempah,temp1,tempbx; USHORT ThTiming[8]={1,2,2,3,0,1,1,2}; USHORT ThLowB[24]={81,4,72,6,88,8,120,12, 55,4,54,6,66,8,90,12, 42,4,45,6,55,8,75,12}; tempah=(UCHAR)GetReg1(P3c4,0x18); //SR_18 tempah=tempah&0x62; tempah=tempah>>1; tempal=tempah; tempah=tempah>>3; tempal=tempal|tempah; tempal=tempal&0x07; temp1=ThTiming[tempal]; //temp1->cl tempbx=(UCHAR)GetReg1(P3c4,0x16); //SR_16 tempbx=tempbx>>6; tempah=(UCHAR)GetReg1(P3c4,0x14); //SR_14 tempah=((tempah>>4)&0x0C); tempbx=((tempbx|tempah)<<1); tempal=ThLowB[tempbx+1]*temp1; tempbx=ThLowB[tempbx]; tempbx=tempal+tempbx; return(tempbx); }USHORT GetVCLK2Ptr(ULONG ROMAddr,USHORT ModeNo){ USHORT tempal; USHORT LCDXlat1VCLK[4]={VCLK65,VCLK65,VCLK65,VCLK65}; USHORT LCDXlat2VCLK[4]={VCLK108_2,VCLK108_2,VCLK108_2,VCLK108_2}; if(ModeNo<=0x13){ tempal=*((UCHAR *)(ROMAddr+ModeIDOffset+0x04)); // si+St_CRT2CRTC }else{ tempal=*((UCHAR *)(ROMAddr+REFIndex+0x04)); // di+Ext_CRT2CRTC } tempal=tempal>>6; if(LCDResInfo!=Panel1024x768){ tempal=LCDXlat2VCLK[tempal]; }else{ tempal=LCDXlat1VCLK[tempal]; } if(VBInfo&SetCRT2ToLCD){ tempal=tempal; }else if(VBInfo&SetCRT2ToTV){ if(SetFlag&RPLLDIV2XO){ tempal=TVVCLKDIV2; }else{ tempal=TVVCLK; } }else{ tempal=(UCHAR)GetReg2((USHORT)(P3ca+0x02)); // Port 3cch tempal=((tempal>>2)&0x03); if(ModeNo>0x13){ tempal=*((UCHAR *)(ROMAddr+REFIndex+0x03)); //di+Ext_CRTVCLK tempal=tempal&0x03F; } } VCLKLen=GetVCLKLen(ROMAddr); tempal=tempal*VCLKLen; tempal=tempal+(*((USHORT *)(ROMAddr+0x208))); // VCLKData return ((USHORT)tempal);}USHORT GetVCLKLen(ULONG ROMAddr){ USHORT VCLKDataStart,vclklabel,temp; VCLKDataStart=*((USHORT *)(ROMAddr+0x208)); for(temp=0;;temp++){ vclklabel=*((USHORT *)(ROMAddr+VCLKDataStart+temp)); if(vclklabel==VCLKStartFreq){ temp=temp+2; return(temp); } } return(0);}VOID SetCRT2Sync(USHORT BaseAddr,ULONG ROMAddr,USHORT ModeNo){ USHORT temp1,tempah=0; USHORT temp; USHORT Part1Port; Part1Port=BaseAddr+IND_SIS_CRT2_PORT_04; if(IF_DEF_LVDS==1){ //LVDS if(VBInfo&SetCRT2ToLCD){ tempah=LCDInfo; if(!(tempah&LCDSync)){ temp=*((USHORT *)(ROMAddr+REFIndex)); //di+Ext_InfoFlag tempah=(temp>>8)&0x0C0; }else{ tempah=tempah&0x0C0; } } }else{ temp=*((USHORT *)(ROMAddr+REFIndex)); //di+Ext_InfoFlag tempah=(temp>>8)&0x0C0; } temp1=(UCHAR)GetReg1(Part1Port,0x19); //part1port index 02 temp1=(temp1&(~0x0C0))|tempah; SetReg1(Part1Port,0x19,temp1);}VOID GetCRT1Ptr(ULONG ROMAddr){ USHORT temprefcrt1; USHORT temp; temp=*((UCHAR *)(ROMAddr+REFIndex+0x02)); //di+Ext_CRT1CRTC temp=temp&0x03F; temp=temp*CRT1Len; temprefcrt1=*((USHORT *)(ROMAddr+0x204)); // Get CRT1Table REFIndex=temprefcrt1+temp; // di->CRT1Table+Ext_CRT1CRTC*CRT1Len}USHORT GetVGAHT2(){ long int temp1,temp2; temp1=(VGAVT-VGAVDE)*RVBHCMAX; temp1=temp1&0x0FFFF; temp2=(VT-VDE)*RVBHCFACT; temp2=temp2&0x0FFFF; temp2=temp2*HT; temp2=temp2/temp1; return((USHORT)temp2);}VOID SetGroup2(USHORT BaseAddr,ULONG ROMAddr){ USHORT tempah,tempbl,tempbh,tempcl,i,j,tempcx,pushcx,tempbx,tempax; USHORT tempmodeflag,tempflowflag; UCHAR *temp1; USHORT *temp2; USHORT pushbx; USHORT Part2Port; long int longtemp; Part2Port=BaseAddr+IND_SIS_CRT2_PORT_10; tempcx=VBInfo; tempah=VBInfo&0x0FF; tempbl=VBInfo&0x0FF; tempbh=VBInfo&0x0FF; tempbx=(tempbl&0xFF)|(tempbh<<8); tempbl=tempbl&0x10; tempbh=(tempbh&0x04)<<1; tempah=(tempah&0x08)>>1; tempah=tempah|tempbh; tempbl=tempbl>>3; tempah=tempah|tempbl; tempah=tempah^0x0C; if(VBInfo&SetPALTV){ temp1=(UCHAR *)(ROMAddr+0x0F1); //PALPhase temp2=PALTiming; }else{ tempah=tempah|0x10; temp1=(UCHAR *)(ROMAddr+0x0ED); //NTSCPhase temp2=NTSCTiming; } SetReg1(Part2Port,0x0,tempah); for(i=0x31;i<=0x34;i++,temp1++){ SetReg1(Part2Port,i,*(UCHAR *)temp1); } for(i=0x01,j=0;i<=0x2D;i++,j++){ SetReg1(Part2Port,i,temp2[j]); } for(i=0x39;i<=0x45;i++,j++){ SetReg1(Part2Port,i,temp2[j]); //di->temp2[j] } tempah=GetReg1(Part2Port,0x0A); tempah=tempah|NewFlickerMode; SetReg1(Part2Port,0x0A,tempah); SetReg1(Part2Port,0x35,RY1COE); SetReg1(Part2Port,0x36,RY2COE); SetReg1(Part2Port,0x37,RY3COE); SetReg1(Part2Port,0x38,RY4COE); tempcx=HT-1; tempah=tempcx&0xFF; SetReg1(Part2Port,0x1B,tempah); tempah=(tempcx&0xFF00)>>8; SetRegANDOR(Part2Port,0x1D,~0x0F,(UCHAR)tempah); tempcx=HT>>1; pushcx=tempcx; tempcx=tempcx+7; tempah=(tempcx&0xFF); tempah=(tempah<<4)&0xFF; SetRegANDOR(Part2Port,0x22,~0x0F0,tempah); tempbx=temp2[j]; tempbx=tempbx+tempcx; tempah=tempbx&0xFF; SetReg1(Part2Port,0x24,tempah); tempah=(tempbx&0xFF00)>>8; tempah=(tempah<<4)&0xFF; SetRegANDOR(Part2Port,0x25,~0x0F0,tempah); tempbx=tempbx+8; tempah=((tempbx&0xFF)<<4)&0xFF; SetRegANDOR(Part2Port,0x29,~0x0F0,tempah); tempcx=tempcx+temp2[++j]; tempah=tempcx&0xFF; SetReg1(Part2Port,0x27,tempah); tempah=(((tempcx&0xFF00)>>8)<<4)&0xFF; SetRegANDOR(Part2Port,0x28,~0x0F0,tempah); tempcx=tempcx+8; tempah=tempcx&0xFF; tempah=(tempah<<4)&0xFF; SetRegANDOR(Part2Port,0x2A,~0x0F0,tempah); tempcx=pushcx; //pop cx tempcx=tempcx-temp2[++j]; tempah=tempcx&0xFF; tempah=(tempah<<4)&0xFF; SetRegANDOR(Part2Port,0x2D,~0x0F0,tempah); tempcx=tempcx-11; if(!(VBInfo&SetCRT2ToTV)){ tempax=GetVGAHT2(); tempcx=tempax-1; } tempah=tempcx&0xFF; SetReg1(Part2Port,0x2E,tempah); tempbx=VDE; if(VGAVDE==360){ tempbx=746; } if(VGAVDE==375){ tempbx=746; } if(VGAVDE==405){ tempbx=853; } if((VBInfo&SetCRT2ToTV)){ tempbx=tempbx>>1; } tempbx=tempbx-2; tempah=tempbx&0xFF; SetReg1(Part2Port,0x2F,tempah); tempah=(tempcx&0xFF00)>>8; tempbh=(tempbx&0xFF00)>>8; tempbh=(tempbh<<6)&0xFF; tempah=tempah|tempbh; //assuming <<ifndef>> hivisiontv tempah=tempah|0x10; if(!(VBInfo&SetCRT2ToSVIDEO)){ tempah=tempah|0x20; } SetReg1(Part2Port,0x30,tempah); tempbh=0; tempbx=tempbx&0xFF; tempmodeflag=*((USHORT *)(ROMAddr+ModeIDOffset+0x01)); // si+St_ModeFlag tempflowflag=0; if(!(tempmodeflag&HalfDCLK)){ tempcx=VGAHDE; if(tempcx>=HDE){ tempbh=tempbh|0x20; tempbx=(tempbh<<8)|(tempbx&0xFF); tempah=0; } } tempcx=0x0101; if(!(tempbh&0x20)){ if(tempmodeflag&HalfDCLK){ tempcl=((tempcx&0xFF)<<1)&0xFF; tempcx=(tempcx&0xFF00)|tempcl; } pushbx=tempbx; tempax=VGAHDE; tempbx=(tempcx&0xFF00)>>8; longtemp=tempax*tempbx; tempcx=tempcx&0xFF; longtemp=longtemp/tempcx; longtemp=longtemp*8*1024; tempax=(USHORT)((longtemp)/HDE); if(tempax*HDE<longtemp){ tempax=tempax+1; }else{ tempax=tempax; } tempbx=pushbx; tempah=((tempax&0xFF00)>>8)&0x01F; tempbh=tempbh|tempah; tempah=tempax&0xFF;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?