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

📄 halsci.c

📁 威盛 wince5.0 bsp 包 for x86 系统, 支持 VT8601 等北桥
💻 C
📖 第 1 页 / 共 3 页
字号:
           mov  edx, dwIOBase
           add  edx, 42h
           in   al, dx
           and  ax, 0f7h
           out  dx, al
       }
        SC_Sleep(100);
       // Set GPO3 High
       _asm
       {
           mov  edx, dwIOBase
           add  edx, 42h
           in   ax, dx
           or   ax, 08h
           out  dx, al
       }
    }

    // For Mr. Wu's Case, GPO10 ACK, GPI4 REQ (MVP3+686A)
    if (dwGPIOACK == 2) {
        RETAILMSG(1, (TEXT("SCIPWM: Trigger ACK signal (GPO 10)")));
        //GPIOACKInit();

        //Initialize GPO10
        _asm
        {
                ;Set GPO10 : rx74[4]=1, rx76[2]=0
                mov  eax, SB686A_configid
                mov  al,74h
                mov  edx, 0cf8h
                out  dx, eax

                mov  edx, 0cfch
                in   eax, dx
                or   ax, 0010h ; rx74[4]=1
                and  eax, 0fffbffffh ; rx76[2]=0
                out  dx,eax
        }

       // Set GPO10 Low
       _asm
       {
           mov  edx, dwIOBase
           add  edx, 4Dh
           in   al, dx
           and  ax, 0fbh
           out  dx, al
       }
        SC_Sleep(100);
       // Set GPO10 High
       _asm
       {
           mov  edx, dwIOBase
           add  edx, 4Dh
           in   ax, dx
           or   ax, 04h
           out  dx, al
       }
    }
}

void GenPurStatus(PGENPURSTATUS pGenPurStatus)
{
	WORD  FixEV_Sts, GenPurEV_Sts;
	
	 _asm
           {
               mov  edx, dwIOBase
               in   ax, dx
               mov  FixEV_Sts, ax
               out  dx, ax
           }
        
           _asm
           {
               mov  edx, dwIOBase
               add  edx, 20h
               in   ax, dx
               mov  GenPurEV_Sts, ax
               out  dx, ax
           }
      
       pGenPurStatus->FixEV_Sts=FixEV_Sts;
       pGenPurStatus->GenPurEV_Sts=GenPurEV_Sts;
           
      //RETAILMSG(1,(TEXT("sci ln1201 dwIOBase=%X,FixEV_Sts=%X,GenPurEV_Sts=%X"),dwIOBase,FixEV_Sts,GenPurEV_Sts));       
}

void ACPowerLoss(DWORD dwALAR)
{
	unsigned char cTestByte1, cTestByte2;
        unsigned long lTestByte1, lTestByte2;
        if(F0CFGID == 0 || F4CFGID == 0 || CHIP == NOT_SUPPORT)
    {
    }
    else
    {
    	//
    	// Step 1 : Disable CMOS 0xd write protect
    	//          
    	//
    	    	
    	if(CHIP == VT686)
    	{
    	    //
    	    //    For VT686
    	    //    Set rx77 bit1 to 0
    	    //
    	    _asm
            {                
                mov    eax, F0CFGID
                add    ax, 074h
                mov    edx, 0cf8h
       	        out    dx, eax

                mov    edx, 0cfch
                in     eax, dx               
                and    eax, 0fdffffffh
                out    dx, eax
                
            }
        }
        else
        {
            //
            //   For VT8231, VT8233, VT8235,VT8237
            //   Set rx58 bit1 to 0
            //
            //
    	    _asm
            {                
                mov    eax, F0CFGID
                add    ax, 058h
                mov    edx, 0cf8h
       	        out    dx, eax

                mov    edx, 0cfch
                in     eax, dx               
                and    eax, 0fffffffdh
                out    dx, eax
                
            }                    
        }        
                
        if(dwALAR == 0)  //Disable AC Loss Auto Restart
        {
            if(CHIP == VT8231 || CHIP == VT686)            
            {
            	//
            	// Set rx41 bit2 to 0
            	//
            	_asm
                {                       
                    mov    eax, F4CFGID
                    add    ax, 040h
                    mov    edx, 0cf8h
       	            out    dx, eax

                    mov    edx, 0cfch
                    in     eax, dx                
                    and     eax, 0fffffbffh
                    out    dx, eax
                }
            }
            else if(CHIP == VT8233 || CHIP == VT8235|| CHIP == VT8237)
            {
            	//
            	// Set rx81 bit2 to 0
            	//
            	_asm
                {                       
                    mov    eax, F4CFGID
                    add    ax, 080h
                    mov    edx, 0cf8h
       	            out    dx, eax

                    mov    edx, 0cfch
                    in     eax, dx                
                    and     eax, 0fffffbffh
                    out    dx, eax
                }
            }        
        }
       
        if(dwALAR == 1)  // Enable AC Loss Auto Restart
        {
           if(CHIP == VT8231 || CHIP == VT686)
            {
            	//
            	// Set rx41 bit2 to 1
            	//
            	_asm
                {                    
                    mov    eax, F4CFGID
                    add    ax, 040h
                    mov    edx, 0cf8h
       	            out    dx, eax

                    mov    edx, 0cfch
                    in     eax, dx                
                    or     eax, 00000400h
                    out    dx, eax
                }
            }
            else if(CHIP == VT8233 || CHIP == VT8235|| CHIP == VT8237)
            {
            	//
            	// Set rx81 bit2 to 1
            	//
            	_asm
                {                    
                    mov    eax, F4CFGID
                    add    ax, 080h
                    mov    edx, 0cf8h
       	            out    dx, eax

                    mov    edx, 0cfch
                    in     eax, dx                
                    or     eax, 00000400h
                    out    dx, eax
                }
            }
        }
        
        //Step3
        //
        //For VT686, VT8231, VT8233, VT8235,VT8237
        //Set NMI & VRT
        // 
     
               
        if(dwALAR == 1)  //Enable AC Loss Auto Restart
       
        {
        	//RETAILMSG(1,(TEXT("dwALAR=%X"),dwALAR));
            _asm
            {
                mov      al,08dh
                out      70h,al
                in       al,71h
                and      al,07fh
                out      71h,al
            }
        }
        else             //Disable AC Loss Auto Restart
        {
            _asm
            {
                mov      al,00dh
                out      70h,al
                in       al,71h
                or      al,080h
                out      71h,al
            }
        }
                
        //
    	// Step 4 : Enable CMOS 0xd write protect
    	//          
    	//
    	    	
    	if(CHIP == VT686)
    	{
    	    //
    	    //    For VT868
    	    //    Set rx77 bit1 to 0
    	    //
    	    _asm
            {                
                mov    eax, F0CFGID
                add    ax, 074h
                mov    edx, 0cf8h
       	        out    dx, eax

                mov    edx, 0cfch
                in     eax, dx               
               
                or     eax, 02000000h
                out    dx, eax
                
            }
        }
        else
        {
            //
            //   For VT8231, VT8233, VT8235,VT8237
            //   Set rx58 bit1 to 0
            //
            //
    	    _asm
            {                
                mov    eax, F0CFGID
                add    ax, 058h
                mov    edx, 0cf8h
       	        out    dx, eax

                mov    edx, 0cfch
                in     eax, dx               
               
                or     eax, 00000002h
                out    dx, eax
            }                    
        }            
          
        
	if(dwALAR==2)
	{
		if(CHIP == VT686)
		{
		   _asm
			{
			   mov  eax, F0CFGID
			   add  eax, 074h
			   mov  edx, 0cf8h
			   out  dx, eax
			   
			   mov  edx, 0cfch
			   in   eax, dx
			   mov  lTestByte1, eax
			   and	eax, 0fdffffffh
			   out  dx, eax
			   in   eax, dx
			   mov  lTestByte2, eax
			}
			
			_asm
			{
			   ;disable CMOS 0D bit 7
			   mov	al, 0dh
			   out	70h, al
			   
			   in   al, 71h
			   mov	cTestByte1, al
			   or	al, 80h			
			   out	71h, al			   
			   in   al, 71h
			   mov	cTestByte2, al
			}
			//RETAILMSG( 1, (TEXT("Lock = 0x%08x to 0x%08x\r\n"), lTestByte1, lTestByte2));
			//RETAILMSG( 1, (TEXT("CMOS 0D = 0x%0x to 0x%0x\r\n"), cTestByte1, cTestByte2));
		}
		if( CHIP == VT8231 ||CHIP == VT8233 || CHIP == VT8235|| CHIP == VT8237)
		{
			_asm
			{
			   mov  eax, F0CFGID
			   add  eax, 058h
			   mov  edx, 0cf8h
			   out  dx, eax
			   
			   mov  edx, 0cfch
			   in   eax, dx
			   mov  lTestByte1, eax
			   and	eax, 0fffffffdh
			   out  dx, eax
			   in   eax, dx
			   mov  lTestByte2, eax
			}
			
			_asm
			{
			   ;disable CMOS 0D bit 7
			   mov	al, 0dh
			   out	70h, al
			   
			   in   al, 71h
			   mov	cTestByte1, al
			  
			   and  al,7fh
			   out	71h, al			   
			   in   al, 71h
			   mov	cTestByte2, al
			}
			//RETAILMSG( 1, (TEXT(" sci ln2273 Lock = 0x%08x to 0x%08x\r\n"), lTestByte1, lTestByte2));
			//RETAILMSG( 1, (TEXT("CMOS 0D = 0x%0x to 0x%0x\r\n"), cTestByte1, cTestByte2));
		}
	    }
	}
}



void SetGPIO()
{
 	
     if ( ChipSetID == 0x30401106 && dwGPIOACK == 1 )
     {
        // Ack GPO 3
        // Set GPO3 Low
        _asm
        {
            mov  edx, dwIOBase
            add  edx, 42h
            in   al, dx
            and  ax, 0f7h
            out  dx, al
        }
         SC_Sleep(10);
        // Set GPO3 High
        _asm
        {
            mov  edx, dwIOBase
            add  edx, 42h
            in   ax, dx
            or   ax, 08h
            out  dx, al
        }
     }


     if (ChipSetID == 0x30571106 && dwGPIOACK == 2)
     {
       // Set GPO10 Low
       _asm
       {
           mov  edx, dwIOBase
           add  edx, 4Dh
           in   al, dx
           and  ax, 0fbh
           out  dx, al
       }
        SC_Sleep(100);
       // Set GPO10 High
       _asm
       {
           mov  edx, dwIOBase
           add  edx, 4Dh
           in   ax, dx
           or   ax, 04h
           out  dx, al
       }
     }
}

void ClearStatusBit(DWORD dwIOBase)
{
	WORD  FixEV_Sts, GenPurEV_Sts;
		
	do {
	        _asm
	        {
	            mov  edx, dwIOBase
	            in   ax, dx
	            mov  FixEV_Sts, ax
	            out  dx, ax
	
	            add  edx, 20h
	            in   ax, dx
	            mov  GenPurEV_Sts, ax
	            out  dx, ax
	        }
	        FixEV_Sts =(FixEV_Sts & 0xEE); //vic 2004/07/08/ add, because cannot clear 0x11,resume failed 
     } while( GenPurEV_Sts ||FixEV_Sts );
     
}


void SusToRAM(DWORD dwIOBase )
{
/*    int i;
    BOOL DriverMode;
    PULONG  pBootArgs;

    DEBUGMSG(ZONE_IO, (TEXT("SCIPWM: STR\r\n")));
    

    DriverMode = SetKMode(TRUE);
    pBootArgs = (PULONG)(BOOT_ARG_PTR_LOCATION);
    *pBootArgs = 0x19650815;
    SetKMode(DriverMode);

    _asm
    {
              mov    dx, 70h
              in     al, dx

              and    al, 80h
              or     al, 0fh
              out    dx, al

              mov    dx, 71h
              mov    al, 49h
              out    dx, al

              ;; PMU Control 1
              mov    dx, 0cf8h
              mov    eax, 80000078h
              out    dx, eax

              mov    dx, 0cfch
              in     eax, dx
              or     eax, 041h
              out    dx, eax

              ;; Power Well Control
              mov    dx, 0cf8h
              mov    eax, PWM_Config
              add    eax, 054h
              out    dx, eax

              mov    dx, 0cfch
              and    eax, 0ffffffefh
              out    dx, eax
              
              ;; enable SMI
              mov  edx, dwIOBase
              add  edx, 24h
              in   ax, dx              
              or   ax, dwGPIOSTS
              ;or   ax, 0ffffh
              out  dx, ax
              

    }

    for ( i = 0; i < 5; i++ )
    {
        _asm
        {
              mov    eax, 0ffffffffh;
              ;; General Status (Offset 28, 29)
              mov    edx, dwIOBase
              add    edx, 028h
              out    dx, ax

              ;; General Purpose Status (Offset 30-33)
              mov    edx, dwIOBase
              add    edx, 030h
              out    dx, eax
        }

        CacheSync(CACHE_SYNC_DISCARD);

        _asm
        {
              mov    edx, dwIOBase
              add    edx, 05h
              mov    al, 24h
              out    dx, al
        }
         SC_Sleep(200);
    }*/
}

⌨️ 快捷键说明

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