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

📄 nicrxmode.c

📁 3com 3c905网卡驱动硬件部分源码
💻 C
字号:
/*******************************************************************************
*** Note: Copy rights resevered to Beijing Pacific Linkair Communications Co. 
***
*** File Name: NICRxMode.c
*** Purpose  : set the receive mode for the NIC Card
***
*** Author   : Guangzhao Tian
*** Modified : By Guangzhao Tian at 2000/9/11
***
**/

#include "NICMacro.h"
#include "NICWinReg.h"
#include "NICCommand.h"
#include "NICEeprom.h"
#include "NICData.h"
#include "NICHelper.h"
#include "NICExport.h"

/*****************************************************************
***This routine sets receive mode 
**/
NIC_STATUS NIC_RxModeSet(IN PNIC_INFORMATION pAdapter , IN ULONG lRxMode )
{
    pAdapter->RxMode.lReceiveMode=lRxMode ;

    DebugMsg("\n**************\nNow Set the Rx Mode ... \n");
  
    NIC_COMMAND( pAdapter->IoBaseAddress ,
		            COMMAND_SELECT_REGISTER_WINDOW |REGISTER_WINDOW_5);
	/* Write the Rx filter */
	NIC_COMMAND ( pAdapter->IoBaseAddress ,(USHORT)(COMMAND_SET_RX_FILTER | lRxMode) );

	/*if we should receive individual packets, set the station address into the registers*/

	if( lRxMode & RX_FILTER_INDIVIDUAL )
	{ 
          NIC_RxModeIndividal( pAdapter);
	}
	
	/*if we should receive the hash fileter multicast packets*/
	if	(lRxMode & RX_FILTER_MULTICAST_HASH)
	{
          NIC_RxModeMulticast(pAdapter);
	}
   
    DebugMsg("Rx Mode Set -- Done! \n*******************\n");
}


/*****************************************************************
*** Read the OEM Node Address from the EEPROM , and write into
*** Station Address Registers in Registers Window 2  
**/
void NIC_RxModeIndividal ( IN PNIC_INFORMATION pAdapter )
{ 
	/****--- Set OEM Station Address into NIC Registers ------****/
    DebugMsg("Now Set Station Addresses ! \n");

    NIC_COMMAND( pAdapter->IoBaseAddress ,
		            COMMAND_SELECT_REGISTER_WINDOW |REGISTER_WINDOW_2);
	
	NIC_WRITE_PORT_USHORT(pAdapter->IoBaseAddress ,
		                   STATION_ADDRESS_LOW_REGISTER , pAdapter->EEPROMInfo.wOEMNodeAddress[0] );

     pAdapter->RxMode.wStationAddr[0]=pAdapter->EEPROMInfo.wOEMNodeAddress[0];

	NIC_WRITE_PORT_USHORT(pAdapter->IoBaseAddress ,
		                   STATION_ADDRESS_MID_REGISTER , pAdapter->EEPROMInfo.wOEMNodeAddress[1] );
     pAdapter->RxMode.wStationAddr[1]=pAdapter->EEPROMInfo.wOEMNodeAddress[1];

	NIC_WRITE_PORT_USHORT(pAdapter->IoBaseAddress ,
		                   STATION_ADDRESS_HIGH_REGISTER , pAdapter->EEPROMInfo.wOEMNodeAddress[2] );
     pAdapter->RxMode.wStationAddr[2]=pAdapter->EEPROMInfo.wOEMNodeAddress[2];

    DebugMsg("Station Addresses Set-- Done ! \n");

    
    DebugMsg("  Rx Mode Station Address:(H) 0x%04X : 0x%04X : 0x%04X (L)\n", 
                   NIC_READ_PORT_USHORT(pAdapter->IoBaseAddress,STATION_ADDRESS_HIGH_REGISTER ) ,  
                   NIC_READ_PORT_USHORT(pAdapter->IoBaseAddress,STATION_ADDRESS_MID_REGISTER ) ,
				   NIC_READ_PORT_USHORT(pAdapter->IoBaseAddress,STATION_ADDRESS_LOW_REGISTER )               
    		); 
   
    return ;
}


/*****************************************************************
*** This routine sets up the multicast list on the adapter.
**/
NIC_STATUS NIC_RxModeMulticast ( IN PNIC_INFORMATION pAdapter   )
{
   	return NIC_STATUS_SUCCESS;
}

/****************************************************************
*** Clear all bits in hash filter and setup the multicast address bit.
**/
void NIC_RxModeHashFilter(IN PNIC_INFORMATION pAdapter)
{
}

/***********************************************************************
*** This routine returns a bit corresponding to the hash address.
**/
USHORT NIC_RxModeHashAddr(IN PUCHAR Address)
{
	ULONG crc, carry, count, bit;
	UCHAR thisByte;

	/* Intialize CRC.*/
	crc = 0xffffffff;

	for (count = 0; count < 6; count++) 
	{
        thisByte = Address[count];
        for ( bit = 0; bit < 8; bit++)
		{
            carry = ((crc & 0x80000000) ? 1 : 0) ^ 	(thisByte & 0x01);
            crc <<= 1;
            thisByte >>= 1;

            if (carry)    	crc  = ( crc ^ 0x04c11db6 ) | carry;
        }
    }

    return (USHORT) (crc & 0x000003FF) ;
}


/** about are routines about set rx filter
*** end of multi.c
***************************************************************************************/

⌨️ 快捷键说明

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