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

📄 nicmedia.c

📁 3com3c905网卡驱动程序
💻 C
📖 第 1 页 / 共 2 页
字号:
 
	/* Try 100MB Connectors */
    /* For 10Base-T and 100Base-TX, select autonegotiation instead of autoselect before calling trymii*/
 	if ( (Options & MEDIA_OPTIONS_100BASETX_AVAILABLE ) ||
   	     (Options & MEDIA_OPTIONS_10BASET_AVAILABLE   ) ) 
	{ 	       	  
		 pAdapter->LinkInfo.Connector = CONNECTOR_AUTONEGOTIATION;
		if (! NIC_MIITryIt(pAdapter, Options) )	       
			pAdapter->LinkInfo.Connector = CONNECTOR_UNKNOWN;
	}

	/* else */
 	if (pAdapter->LinkInfo.Connector == CONNECTOR_UNKNOWN) 
	{
		pAdapter->LinkInfo.Connector = pAdapter->LinkInfo.ConfigConnector;
		pAdapter->LinkInfo.LinkSpeed = LINK_SPEED_10;
		DebugMsg(" AutoSelection failed! Using default.\n");
		pAdapter->LinkInfo.LinkState = LINK_DOWN_AT_INIT;
	}

	NIC_MediaSetupConnector(pAdapter, 	pAdapter->LinkInfo.Connector);

    return NIC_STATUS_SUCCESS;
}


/******************************************************************************************
***	Setup new transceiver type in InternalConfig. Determine whether to 
***	set JabberGuardEnable, enableSQEStats and linkBeatEnable in MediaStatus.
***	Determine if the coax transceiver also needs to be enabled/disabled.
**/
VOID  NIC_MediaSetupConnector(IN PNIC_INFORMATION pAdapter,IN CONNECTOR_TYPE NewConnector) 
{
    ULONG InternalConfig = 0;
    ULONG OldInternalConfig = 0;
    USHORT MediaStatus = 0;
	
	NIC_COMMAND(pAdapter->IoBaseAddress,COMMAND_SELECT_REGISTER_WINDOW | REGISTER_WINDOW_3);

	InternalConfig = NIC_READ_PORT_ULONG(pAdapter->IoBaseAddress,INTERNAL_CONFIG_REGISTER);
	OldInternalConfig = InternalConfig;

	/* Save old choice
	*OldConnector =(InternalConfig & INTERNAL_CONFIG_TRANSCEIVER_MASK) >> 20;  */

	/* Program the MII registers if forcing the configuration to 10/100BaseT. */
	if ( (NewConnector == CONNECTOR_10BASET) || (NewConnector == CONNECTOR_100BASETX))
	{
		/* Clear transceiver type and change to new transceiver type. */
   		InternalConfig &= ~(INTERNAL_CONFIG_TRANSCEIVER_MASK);
   		InternalConfig |= (CONNECTOR_AUTONEGOTIATION << 20);

		/* Update the internal config register. Only do this if the value has
	        changed to avoid dropping link. */
		if (OldInternalConfig != InternalConfig)
		{
			NIC_WRITE_PORT_ULONG(pAdapter->IoBaseAddress,INTERNAL_CONFIG_REGISTER,	InternalConfig);
		}

		/* Force the MII registers to the correct settings. */
		if ( !NIC_MIICheckConfg(pAdapter,
				(USHORT)((NewConnector == CONNECTOR_100BASETX) 
							? MEDIA_OPTIONS_100BASETX_AVAILABLE
							: MEDIA_OPTIONS_10BASET_AVAILABLE)) ) 
		{
			/*If the forced configuration didn't work, check the results and see why. */
			NIC_MIICheckErrorReason(pAdapter);
			return;
		}
	}
	else
    {
		/* Clear transceiver type and change to new transceiver type */
   		InternalConfig = InternalConfig & (~INTERNAL_CONFIG_TRANSCEIVER_MASK);
   		InternalConfig |= (NewConnector << 20);

		/* Update the internal config register. Only do this if the value has
		    changed to avoid dropping link. */
		if (OldInternalConfig != InternalConfig)
		{
			NIC_WRITE_PORT_ULONG(pAdapter->IoBaseAddress,INTERNAL_CONFIG_REGISTER,InternalConfig);
		}
	}

    /* Determine whether to set enableSQEStats and linkBeatEnable 
        Automatically set JabberGuardEnable in MediaStatus register.
	NIC_COMMAND(pAdapter->IOBaseAddress,COMMAND_SELECT_REGISTER_WINDOW | REGISTER_WINDOW_4);

	MediaStatus = NIC_READ_PORT_USHORT(pAdapter->IOBaseAddress, MEDIA_STATUS_REGISTER);

	MediaStatus &= ~(  MEDIA_STATUS_SQE_STATISTICS_ENABLE 
                       |MEDIA_STATUS_LINK_BEAT_ENABLE |MEDIA_STATUS_JABBER_GUARD_ENABLE);
	MediaStatus |= MEDIA_STATUS_JABBER_GUARD_ENABLE;

    if (NewConnector == CONNECTOR_10AUI)
		MediaStatus |= MEDIA_STATUS_SQE_STATISTICS_ENABLE;

   	if (NewConnector == CONNECTOR_AUTONEGOTIATION)
		MediaStatus |= MEDIA_STATUS_LINK_BEAT_ENABLE;
	else 
    {
		if ((NewConnector == CONNECTOR_10BASET) ||
			(NewConnector == CONNECTOR_100BASETX) ||
			(NewConnector == CONNECTOR_100BASEFX))
           {
			if (!pAdapter->Hardware.LinkBeatDisable)
				MediaStatus |= MEDIA_STATUS_LINK_BEAT_ENABLE;
    	   }
	}

	NIC_WRITE_PORT_USHORT(pAdapter->IOBaseAddress,MEDIA_STATUS_REGISTER, MediaStatus);*/

	/* If configured for coax we must start the internal transceiver. 
	    If not, we stop it (in case the configuration changed across a warm boot).  * 
    if (NewConnector == CONNECTOR_10BASE2)
    {
		NIC_COMMAND(pAdapter, COMMAND_ENABLE_DC_CONVERTER);
		* Check if DC convertor has been enabled *
		tc90x_CheckDCConverter(pAdapter, TRUE);
	}
	else 
    {
		NIC_COMMAND(pAdapter, COMMAND_DISABLE_DC_CONVERTER);
		* Check if DC convertor has been disabled *
		tc90x_CheckDCConverter(pAdapter, FALSE);
	} */


}

/*********************************************************************
*** Setup the necessary MII registers with values either 
***	read from the EEPROM or from command line
**/
BOOLEAN NIC_MediaProgramMII(IN PNIC_INFORMATION pAdapter,IN CONNECTOR_TYPE NewConnector) 
{
	BOOLEAN PhyResponding;
 	USHORT PhyControl;
    USHORT PhyStatus;
	NIC_STATUS status;
    USHORT MiiType=0, PhyModes;

	/* First see if there's anything connected to the MII */
   	if ( !NIC_MIIFindPhy(pAdapter) )return FALSE;						 
    
	/* Nowhere is it written that the register must be latched, and since reset is the last bit out,
                  the contents might not be valid.  read it one more time. */
	PhyResponding = NIC_MIIReadPhy(pAdapter, MII_PHY_CONTROL, &PhyControl);
    if (!PhyResponding) 		return FALSE;  	

	/* Now we can read the status and try to figure out what's out there.*/
   	PhyResponding = NIC_MIIReadPhy(pAdapter, MII_PHY_STATUS, &PhyStatus);
    if (!PhyResponding)		return FALSE;  	

	/* Reads the miiSelect field in EEPROM. Program MII as the default. */
    status = NIC_EEPROMRead(pAdapter,EEPROM_SOFTWARE_INFORMATION_3, &MiiType);				  	  

	/* If an override is present AND the transceiver type is available on the card, that type will be used.   */
	PhyResponding = NIC_MIIReadPhy(pAdapter, MII_PHY_STATUS, &PhyModes);
    if (!PhyResponding)	return FALSE;

	PhyResponding = NIC_MIIReadPhy(pAdapter, MII_PHY_CONTROL, &PhyControl);
    if (!PhyResponding)		return FALSE;

/*	if (!NIC_MediaOverride(pAdapter, PhyModes, &MiiType) )	return FALSE; */

	/* If full duplex selected, set it in PhyControl.  */
    if (pAdapter->LinkInfo.FullDuplexEnable) 	PhyControl |= MII_CONTROL_FULL_DUPLEX;
    else							       		PhyControl &= ~MII_CONTROL_FULL_DUPLEX;
    
    PhyControl &= ~MII_CONTROL_ENABLE_AUTO;

    if ( ( (MiiType & MIITXTYPE_MASK ) == MIISELECT_100BTX     ) ||
	     ( (MiiType & MIITXTYPE_MASK ) == MIISELECT_100BTX_ANE ) )
	{
		PhyControl |= MII_CONTROL_100MB;
		NIC_MIIWritePhy(pAdapter, MII_PHY_CONTROL, PhyControl);
		/*delay 600 milliseconds */
        NIC_DELAY(600);
		pAdapter->LinkInfo.LinkSpeed = LINK_SPEED_100;
		DebugMsg(" Set Link Speed to 100M under Forced mode !\n"); 
		return TRUE;
	}

    else if	( ( (MiiType & MIITXTYPE_MASK ) == MIISELECT_10BT    ) ||
		      ( (MiiType & MIITXTYPE_MASK ) == MIISELECT_10BT_ANE) )
	{
		PhyControl &= ~MII_CONTROL_100MB;
		NIC_MIIWritePhy(pAdapter, MII_PHY_CONTROL, PhyControl);
		/*delay 600 milliseconds */
        NIC_DELAY(600);
		pAdapter->LinkInfo.LinkSpeed = LINK_SPEED_10;
		DebugMsg(" Set Link Speed to 10M under Forced mode !\n"); 
		return TRUE;
	} 

    PhyControl &= ~MII_CONTROL_100MB;
    NIC_MIIWritePhy(pAdapter, MII_PHY_CONTROL, PhyControl);
	/*delay 600 milliseconds */
    NIC_DELAY(600);
	pAdapter->LinkInfo.LinkSpeed = LINK_SPEED_10;
	DebugMsg(" Link Speed set as Defaults to 10M !\n"); 
    
	return FALSE;
}


/** Above are routines about Media setting
***  End of Media.c
*****************************************************************************************/

⌨️ 快捷键说明

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