亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? lan91c111_phy.c

?? This driver was developed to ARM SMSC LAN91C11 (PXA CPU)
?? C
字號:
/*
 *
 *    Copyright (c) Standard MicroSystems Corporation.  All Rights Reserved.
 *
 *				    LAN91C111 Driver for Windows CE .NET
 *
 *							 Revision History
 *_______________________________________________________________________________
 *     Author		  Date		Version		Description
 *_______________________________________________________________________________
 * Pramod Bhardwaj  6/18/2002	  0.1		Beta Release
 * Pramod Bhardwaj	7/15/2002	  1.0       Release 
 * Pramod Bhardwaj  1/22/2003     1.1		Removed some platform dependencies
 * Pramod Bhardwaj  4/15/2003     2.0		Added support for alloc interrupt
 *_______________________________________________________________________________
 *
 *
 *Description:
 *            Functions for accessing the phy. And contains the Autonegotiating
 *  procedure for establishing the link
 *
 *
 */
#include <Ndis.h>
#include "LAN91C111_Adapter.h"

/*
 Function Name : InputMDO
 Description   :
                 Reads MII serial data bit, using the Management Interface reg.
 Parameters    :    
                 UINT IOAddress - IOAddress to read (or the IOAddr, for Manag. Intr. Reg
 Return Value  :
                 Value in the Management Interface register. Note that this is the 
                 value of the complete register not just the MDI
 */

USHORT	InputMDO			( ULONG IOAddress )
{
	USHORT phydat;
	//PrintDebugMsg(ZONE_INIT, (TEXT("LAN91C111==> InputMDO\r\n")));	
	NdisRawWritePortUshort( IOAddress, (USHORT) 0 );
	NdisRawWritePortUshort( IOAddress, (USHORT) MGMT_MCLK );
	NdisRawReadPortUshort( IOAddress, &phydat );
	NdisRawWritePortUshort( IOAddress, (USHORT) 0 );
	//PrintDebugMsg(ZONE_INIT, (TEXT("LAN91C111 <== InputMDO\r\n")));
	return( phydat );
}


/*
 Function Name : OutputMDO
 Description   :
                 Write a bit to the MII. The value to write is based on the second
   Parameter. If the second parameter is 0 then 0 is written to the MII, similarly 1 
   if the second parameter is 1. When the second parameter is 2 the output is tristated
   on the MII.
 Parameters    :    ULONG IOAddress - Address to write
                    UCHAR lev - if 0 - write 0
                                if 1 - write 1
                                if 2 - write Z (tristate)
 Return Value  :
                 VOID
 */

VOID	OutputMDO			( ULONG IOAddress, UCHAR lev )
{
	//PrintDebugMsg(ZONE_INIT, (TEXT("LAN91C111 ==> OutputMDO  \r\n")));
    if( lev == 0 ) 
	{
        NdisRawWritePortUshort( IOAddress, (USHORT) MGMT_MDOE );
        NdisRawWritePortUshort( IOAddress, (USHORT) ( MGMT_MCLK + MGMT_MDOE ) );
        NdisRawWritePortUshort( IOAddress, (USHORT) MGMT_MDOE );
    }
    else 
	{
		if( lev == 1 )
		{
			NdisRawWritePortUshort( IOAddress, (USHORT) ( MGMT_MDO + MGMT_MDOE ) );
			NdisRawWritePortUshort( IOAddress, (USHORT) ( MGMT_MCLK + MGMT_MDO + MGMT_MDOE ) );
			NdisRawWritePortUshort( IOAddress, (USHORT) ( MGMT_MDO + MGMT_MDOE ) );
		}
		if (lev==2)
		{
			NdisRawWritePortUshort( IOAddress, (USHORT) 0 );
			NdisRawWritePortUshort( IOAddress, (USHORT) (MGMT_MCLK) );
			NdisRawWritePortUshort( IOAddress, (USHORT) 0 );
		}
	}
	//PrintDebugMsg(ZONE_INIT, (TEXT("LAN91C111 <<= OutputMDO  \r\n")));
}



/*
 Function Name : ReadPhyRegister
 Description   :
                 Reads the PHY register using the PHY read procedure, described in 
                 the Application Notes/Tech. Ref. Manual
 Parameters    :    
                  UINT IOBase - Base address of the chip
                  UCHAR PhyReg - Register to read
 Return Value  :
                   UINT - Value read from the phy register specified by PhyReg
 */
UINT	ReadPhyRegister		( ULONG IOBase, UCHAR  PhyReg)
{
	UINT Counter;
	USHORT PhyVal, PhyData;
	
	//PrintDebugMsg(ZONE_INIT, (TEXT("LAN91C111 ==> ReadPhyRegister  \r\n")));
	
	// 32 consecutive ones on MDO to establish sync
	NdisRawWritePortUshort( IOBase + BANK_SELECT, (USHORT) 3 );
    NdisRawWritePortUshort( IOBase + BANK3_MGMT,  (USHORT) ( MGMT_MDOE + MGMT_MDO ) );
    for( Counter = 1; Counter <= 32; Counter++ ) 
	{
        NdisRawWritePortUshort( IOBase + BANK3_MGMT,(USHORT) ( MGMT_MDOE + MGMT_MDO ) );
        NdisRawWritePortUshort( IOBase + BANK3_MGMT,(USHORT) ( MGMT_MCLK + MGMT_MDOE + MGMT_MDO ) );
    }
    NdisRawWritePortUshort( IOBase + BANK3_MGMT, (USHORT) MGMT_MDOE );
	
	// start code <01>
    OutputMDO( (ULONG)( IOBase + BANK3_MGMT ), 0 );
    OutputMDO( (ULONG)( IOBase + BANK3_MGMT ), 1 );
	
	// read command <10>
    OutputMDO( (ULONG)( IOBase + BANK3_MGMT ), 1 );
    OutputMDO( (ULONG)( IOBase + BANK3_MGMT ), 0 );
	
	// write the phyaddress - which is five 0s for LAN91C111
	for ( Counter = 1; Counter <= 5; Counter++)
		OutputMDO( (ULONG)( IOBase + BANK3_MGMT ), 0 );
	
	//Write the phy register to read
	//Highest bit goes out first..... :)
	for (Counter = 1; Counter <= 5; Counter++)
	{
        if( ( PhyReg & 0x10 ) != 0 )  // outmdo(1); 
			OutputMDO( (ULONG)( IOBase + BANK3_MGMT ), 1 );
		else
			OutputMDO( (ULONG)( IOBase + BANK3_MGMT ), 0 );
		PhyReg <<= 1;
	}
	
	// turnaround mdo is tristated
    OutputMDO( (ULONG)( IOBase + BANK3_MGMT ), 2 ); 
	
	//Read the data...
	PhyData	=	0; // Stores the bit value
	PhyVal	=	0; // Stores the complete value of the phy register
	for( Counter = 0; Counter <= 0xf; Counter++ ) 
	{
		PhyVal <<= 1;
        PhyData = InputMDO( (ULONG)( IOBase + BANK3_MGMT ) );
        if(0x2 & PhyData)		
			PhyVal |= 1;
    }
	
	// turnaround mdo is tristated
    OutputMDO( (ULONG)( IOBase + BANK3_MGMT ), 2 );
	//PrintDebugMsg(ZONE_INIT, (TEXT("LAN91C111 <== ReadPhyRegister  \r\n")));
	return (PhyVal);	
}



/*
 Function Name : WritePhyRegister
 Description   :
                 Writes the PHY register using the PHY Write procedure, described in 
                 the Application Notes/Tech. Ref. Manual
 Parameters    :    
                 UINT IOBase - Base address of the chip
                 UCHAR PhyReg - Register to Write
                 USHORT value - Value to write
 Return Value  :
                   void
 */
void	WritePhyRegister		( ULONG IOBase, UCHAR  PhyReg, USHORT Value)
{
	UINT Counter;
	USHORT PhyVal, PhyData;
	
	//PrintDebugMsg(ZONE_INIT, (TEXT("LAN91C111 ==> WritePhyRegister  \r\n")));
	// 32 consecutive ones on MDO to establish sync
	NdisRawWritePortUshort( IOBase + BANK_SELECT, (USHORT) 3 );
    NdisRawWritePortUshort( IOBase + BANK3_MGMT,  (USHORT) ( MGMT_MDOE + MGMT_MDO ) );
    for( Counter = 1; Counter <= 32; Counter++ ) 
	{
        NdisRawWritePortUshort( IOBase + BANK3_MGMT,(USHORT) ( MGMT_MDOE + MGMT_MDO ) );
        NdisRawWritePortUshort( IOBase + BANK3_MGMT,(USHORT) ( MGMT_MCLK + MGMT_MDOE + MGMT_MDO ) );
    }
    NdisRawWritePortUshort( IOBase + BANK3_MGMT, (USHORT) MGMT_MDOE );
	
	// start code <01>
    OutputMDO( (ULONG)( IOBase + BANK3_MGMT ), 0 );
    OutputMDO( (ULONG)( IOBase + BANK3_MGMT ), 1 );
	
	// write command <01>
    OutputMDO( (ULONG)( IOBase + BANK3_MGMT ), 0 );
    OutputMDO( (ULONG)( IOBase + BANK3_MGMT ), 1 );
	
	// write the phyaddress - which is five 0s for LAN91C111
	for ( Counter = 1; Counter <= 5; Counter++)
		OutputMDO( (ULONG)( IOBase + BANK3_MGMT ), 0 );
	
	//Write the phy register to read
	//Highest bit goes out first..... :)
	for (Counter = 1; Counter <= 5; Counter++)
	{
        if( ( PhyReg & 0x10 ) != 0 )
			OutputMDO( (ULONG)( IOBase + BANK3_MGMT ), 1 );
		else
			OutputMDO( (ULONG)( IOBase + BANK3_MGMT ), 0 );
		PhyReg <<= 1;
	}
	
	// turnaround mdo
    OutputMDO( (ULONG) ( IOBase + BANK3_MGMT ), 1 );
    OutputMDO( (ULONG) ( IOBase + BANK3_MGMT ), 0 );
	
	//Read the data...
	PhyData	=	0; // Stores the bit value
	PhyVal	=	0; // Stores the complete value of the phy register
	for( Counter = 0; Counter <= 0xf; Counter++ ) 
	{
		if (Value & 0x8000)
			OutputMDO( (ULONG) ( IOBase + BANK3_MGMT ), 1 );
		else
			OutputMDO( (ULONG) ( IOBase + BANK3_MGMT ), 0 );
		Value <<= 1;		
    }
	
	// turnaround mdo is tristated
    OutputMDO( (ULONG)( IOBase + BANK3_MGMT ), 2 );
}


/*
 Function Name : EstablishLink
 Description   : 
                 This function establishes a link based on the Auto_Negotiation variable
                 in the adapter structure. If the variable is true then auto negotiation is
                 enabled. If the variable is false then the link is manually established
                 by setting the speed and duplex bits. Note that the manual mode can only
                 select speed but the duplex is always half duplex.
                 
 Parameters    :    
                 MINIPORT_ADAPTER *Adapter - Pointer to the adapter structure
 Return Value  :
                 BOOLEAN - True is succesful, else false
 */
BOOLEAN EstablishLink(MINIPORT_ADAPTER *Adapter)
{
	USHORT	temp;
	DWORD	LocalTimer;
	if (Adapter->Auto_Negotiation)
	{
RestartAutoNegotiation:
		//Reset the PHY
		WritePhyRegister(Adapter->IOBase, 0, 0x8000);
		while ( 0x8000 & ReadPhyRegister(Adapter->IOBase, 0));
		Sleep(350);
		
		//Set the MAC Register to AutoNeg
		NdisRawWritePortUshort( Adapter->IOBase + BANK_SELECT, (USHORT) 0 );
		NdisRawWritePortUshort( Adapter->IOBase + BANK0_RPCR, RPCR_ANEG);
		
		//Set the PHY Register to AutoNeg
		WritePhyRegister(Adapter->IOBase, 0, 0x1000);
		
		temp = 1;
		LocalTimer = GetTickCount();
		do
		{
			temp = ReadPhyRegister(Adapter->IOBase, 1);
			if (temp & 0x10) goto RestartAutoNegotiation;		
			if (temp & 0x20) temp = 0;
			if ((GetTickCount() - LocalTimer) > 2000) break; //Wait for approx 3 seconds.. then break..
		}
		while (temp);
			
		//Check for the status of the autoneg
		temp = 0x4000;
		LocalTimer = GetTickCount();
		while (temp & 0x4000)
		{
			temp = ReadPhyRegister(Adapter->IOBase, 18);
			if ((GetTickCount() - LocalTimer) > 2000) break; //Wait for approx 3 seconds.. then break..
		}
		
		if (!(temp & 0x4000))
		{
			if (temp & 0x0080)
			{
				Adapter->Speed = SPEED100;
				PrintDebugMsg(ZONE_INIT, (TEXT("LAN91C111 <== 100BASE-TX Link Detected\r\n")));
			}
			else
			{
				Adapter->Speed = SPEED10;
				PrintDebugMsg(ZONE_INIT, (TEXT("LAN91C111 <== 10BASE-TX Link Detected\r\n")));
			}
			
			if (temp & 0x0040)
			{
				Adapter->Duplex = FULL_DUPLEX;
				PrintDebugMsg(ZONE_INIT, (TEXT("LAN91C111 <== FULL DUPLEX Link Detected\r\n")));
			}
			else
			{
				Adapter->Duplex = HALF_DUPLEX;
				PrintDebugMsg(ZONE_INIT, (TEXT("LAN91C111 <== HALF DUPLEX Link Detected\r\n")));
			}
			
			Adapter->LinkStatus = MEDIA_CONNECTED;
		}	
		else
		{
			PrintDebugMsg(ZONE_INIT, (TEXT("LAN91C111 <== MEDIA IS DISCONNECTED ..........\r\n")));
			Adapter->LinkStatus = MEDIA_DISCONNECTED;
		}		
	}
	else
	{
		//Clear MII_DIS if set, after the reset
		temp = ReadPhyRegister(Adapter->IOBase, 0);
		if (temp & 0x0400)
			WritePhyRegister(Adapter->IOBase, 0, (USHORT)(temp&0x0BFF));

		//Manual Selection...
		NdisRawWritePortUshort(Adapter->IOBase + BANK_SELECT, (USHORT) 0);
		NdisRawReadPortUshort(Adapter->IOBase + BANK0_RPCR, &temp);
		temp &= ~RPCR_ANEG; //Clear the ANET bit
	
		if (Adapter->Speed == SPEED100)
			temp |= RPCR_SPEED;	//Set the bit
		else
			temp &= ~RPCR_SPEED;	//Clear the bit

		if (Adapter->Duplex == FULL_DUPLEX)
			temp |= RPCR_DPLX; //Set to full duplex
		else
			temp &= ~RPCR_DPLX; //Test.. for 10hdx
		NdisRawWritePortUshort( Adapter->IOBase + BANK0_RPCR, temp);
		
		//Clear MII_DIS if set, after the reset
		temp = ReadPhyRegister(Adapter->IOBase, 0);
		if (temp & 0x0400)
			WritePhyRegister(Adapter->IOBase, 0, (USHORT)(temp&0xFBFF));
		temp = 0x4000;
		LocalTimer = GetTickCount();
		while (temp & 0x4000)
		{
			temp = ReadPhyRegister(Adapter->IOBase, 18);
			if ((GetTickCount() - LocalTimer) > 3000) break; //Wait for approx 3 seconds.. then break..
		}
		if (!(temp & 0x4000))
		{
			if (temp & 0x0080)
			{
				Adapter->Speed = SPEED100;
				PrintDebugMsg(ZONE_INIT, (TEXT("LAN91C111 <== 100BASE-TX Link Detected\r\n")));
			}
			else
			{
				Adapter->Speed = SPEED10;
				PrintDebugMsg(ZONE_INIT, (TEXT("LAN91C111 <== 10BASE-TX Link Detected\r\n")));
			}
			
			if (temp & 0x0040)
			{
				Adapter->Duplex = FULL_DUPLEX;
				PrintDebugMsg(ZONE_INIT, (TEXT("LAN91C111 <== FULL DUPLEX Link Detected\r\n")));
			}
			else
			{
				Adapter->Duplex = HALF_DUPLEX;
				PrintDebugMsg(ZONE_INIT, (TEXT("LAN91C111 <== HALF DUPLEX Link Detected\r\n")));
			}
			
			Adapter->LinkStatus = MEDIA_CONNECTED;
		}	
		else
		{
			PrintDebugMsg(ZONE_INIT, (TEXT("LAN91C111 <== MEDIA IS DISCONNECTED ..........\r\n")));
			Adapter->LinkStatus = MEDIA_DISCONNECTED;			
		}		
	}
	
	//Setup the phy for link interrupts
	WritePhyRegister(Adapter->IOBase, 19, (PHY_MASK_BASE & PHY_MASK_INT & PHY_MASK_LINK));
	ReadPhyRegister(Adapter->IOBase, 18); //To clear an pending interrupts..

	return TRUE;
}    

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产精品亚洲视频| 国产精品白丝在线| 日本欧美在线看| 欧美巨大另类极品videosbest| 1024亚洲合集| 一本大道久久a久久综合| 亚洲免费观看高清完整版在线观看熊 | 亚洲一区在线播放| 欧美日韩在线播放| 免费成人你懂的| 久久精品一级爱片| bt欧美亚洲午夜电影天堂| 中文字幕在线免费不卡| 91浏览器打开| 日韩电影在线一区二区三区| 日韩久久久精品| 国产一区不卡视频| 亚洲精品少妇30p| 制服丝袜亚洲色图| 国产成都精品91一区二区三| 亚洲男帅同性gay1069| 欧美日韩在线三级| 国产老妇另类xxxxx| 亚洲天天做日日做天天谢日日欢| 欧美日韩亚洲综合在线| 久久av资源网| 一区二区三区欧美日| 精品久久久久久亚洲综合网| 成人午夜av在线| 日韩黄色片在线观看| 国产香蕉久久精品综合网| 91久久精品日日躁夜夜躁欧美| 蜜桃久久av一区| 中文字幕一区二区三区视频| 欧美一区二区女人| 91亚洲精品一区二区乱码| 奇米综合一区二区三区精品视频| 欧美国产一区在线| 日韩片之四级片| 日本韩国精品一区二区在线观看| 久88久久88久久久| 一级日本不卡的影视| 久久久蜜桃精品| 欧美日韩国产精选| 成人av电影在线观看| 久久激情五月婷婷| 亚洲一区二区三区四区在线观看 | 亚洲码国产岛国毛片在线| 日韩一区二区三区三四区视频在线观看| 成人美女视频在线观看18| 日本三级亚洲精品| 亚洲欧美日韩小说| 国产精品色哟哟网站| 精品少妇一区二区三区视频免付费| 色网综合在线观看| 成人av网站大全| 国产高清精品在线| 精品影视av免费| 日本在线不卡一区| 亚洲综合一区在线| 自拍偷拍国产亚洲| 国产精品人人做人人爽人人添| 精品国一区二区三区| 欧美日韩免费电影| 欧美视频在线一区| 色中色一区二区| av电影天堂一区二区在线观看| 国产一区欧美二区| 国产一区二区精品在线观看| 日本不卡不码高清免费观看| 亚洲国产精品一区二区久久恐怖片| 亚洲啪啪综合av一区二区三区| 国产精品午夜久久| 国产精品美日韩| 中文字幕久久午夜不卡| 欧美国产一区在线| 国产精品污网站| 中文字幕在线一区二区三区| 欧美国产精品专区| 国产精品美日韩| 亚洲日本成人在线观看| 综合自拍亚洲综合图不卡区| 中文字幕亚洲综合久久菠萝蜜| 中文幕一区二区三区久久蜜桃| 国产精品视频第一区| 国产女人水真多18毛片18精品视频| 久久精品网站免费观看| 国产精品情趣视频| 亚洲欧美一区二区三区极速播放 | 免费观看一级欧美片| 蜜桃一区二区三区在线| 奇米777欧美一区二区| 精品一区二区三区日韩| 国产不卡视频一区| caoporen国产精品视频| 色94色欧美sute亚洲线路一ni| 欧美最猛性xxxxx直播| 6080日韩午夜伦伦午夜伦| 日韩欧美www| 欧美高清在线视频| 一区二区三区成人在线视频| 天堂va蜜桃一区二区三区漫画版| 久久精品噜噜噜成人av农村| 国产精品综合二区| 色哟哟一区二区| 欧美区在线观看| 国产亚洲欧美一级| 亚洲一区二区免费视频| 麻豆精品新av中文字幕| 国产69精品久久99不卡| 日本韩国一区二区三区视频| 欧美一卡二卡三卡四卡| 亚洲国产精品v| 性欧美疯狂xxxxbbbb| 国产乱人伦偷精品视频免下载| 99久久99久久免费精品蜜臀| 欧美日韩国产综合视频在线观看 | 免费视频一区二区| 国产+成+人+亚洲欧洲自线| 欧美伊人精品成人久久综合97 | 老司机午夜精品| 99re热视频精品| 欧美一区二区视频免费观看| 中文字幕乱码久久午夜不卡| 婷婷夜色潮精品综合在线| 国产福利精品导航| 这里只有精品99re| 国产精品不卡在线| 毛片基地黄久久久久久天堂| www.欧美.com| 精品久久久久久久久久久久久久久 | 日韩欧美资源站| 亚洲视频一区二区在线| 久久精品噜噜噜成人av农村| 在线免费av一区| 国产偷v国产偷v亚洲高清| 天堂一区二区在线免费观看| 成人免费看片app下载| 欧美一区日韩一区| 亚洲欧美另类小说视频| 国产成人午夜高潮毛片| 欧美一区三区四区| 亚洲一区二区三区免费视频| 北条麻妃一区二区三区| 精品国产露脸精彩对白| 五月婷婷另类国产| 色88888久久久久久影院按摩| 国产午夜精品一区二区三区四区| 日本亚洲三级在线| 欧美日韩的一区二区| 玉米视频成人免费看| 99精品视频在线观看免费| 久久亚洲一区二区三区四区| 日日夜夜免费精品视频| 欧美影片第一页| 亚洲精品国产视频| 91麻豆自制传媒国产之光| 日本一区免费视频| 处破女av一区二区| 国产拍揄自揄精品视频麻豆| 国产麻豆视频精品| 国产精品久久久久一区二区三区共| 日本午夜精品视频在线观看 | 欧美日本乱大交xxxxx| 亚洲综合久久av| 95精品视频在线| 亚洲日本va午夜在线电影| 北条麻妃一区二区三区| 亚洲视频小说图片| 91年精品国产| 亚洲另类在线制服丝袜| 在线免费观看成人短视频| 亚洲一区二区高清| 欧美精品精品一区| 青青草91视频| 久久影院视频免费| 成人av网站免费观看| 国产精品成人一区二区三区夜夜夜| 成人性生交大片| 日韩美女视频19| 欧美日韩一区二区三区不卡| 亚洲成人激情综合网| 欧美一区二视频| 国产成人丝袜美腿| 亚洲人成亚洲人成在线观看图片 | 国产一区二区三区免费| 久久伊人中文字幕| 成人av在线电影| 亚洲一区二区美女| 日韩一区二区三区精品视频| 国产美女娇喘av呻吟久久| 国产精品美女一区二区| 一本久道中文字幕精品亚洲嫩| 一区二区三区精密机械公司| 在线电影一区二区三区| 激情亚洲综合在线| 亚洲婷婷在线视频| 欧美一级理论片| 成人国产精品免费| 午夜精品一区二区三区免费视频|