📄 lan91c111end.c
字号:
int endMultiLstCnt(END_OBJ* pEnd);
USHORT MakeHash(unsigned char *Address);
LOCAL void lan91c111AddrFilterSet(LAN91C111END_DEVICE *pDrvCtrl);
/*
* Declare our function table. This is static across all driver
* instances.
*/
LOCAL NET_FUNCS lan91c111FuncTable =
{
(FUNCPTR) lan91c111Start, /* Function to start the device. */
(FUNCPTR) lan91c111Stop, /* Function to stop the device. */
(FUNCPTR) lan91c111Unload, /* Unloading function for the driver. */
(FUNCPTR) lan91c111Ioctl, /* Ioctl function for the driver. */
(FUNCPTR) lan91c111Send, /* Send function for the driver. */
(FUNCPTR) lan91c111MCastAddrAdd, /* Multicast add function for the */
/* driver. */
(FUNCPTR) lan91c111MCastAddrDel, /* Multicast delete function for */
/* the driver. */
(FUNCPTR) lan91c111MCastAddrGet, /* Multicast retrieve function for */
/* the driver. */
(FUNCPTR) lan91c111PollStart, /* Polling send function */
(FUNCPTR) lan91c111PollStop, /* Polling receive function */
endEtherAddressForm, /* put address info into a NET_BUFFER */
endEtherPacketDataGet, /* get pointer to data in NET_BUFFER */
endEtherPacketAddrGet /* Get packet addresses. */
};
LAN91C111END_DEVICE *pGDrvCtrl;
char mCastAddr[6];
/******************************************************************************
*
* lan91C111Load - initialize the driver and device
*
* This routine initializes the driver and the device to the operational state.
* All of the device-specific parameters are passed in <initString>, which
* expects a string of the following format:
*
* This routine can be called in two modes. If it is called with an empty but
* allocated string, it places the name of this device (that is, "ln") into
* the <initString> and returns 0.
*
* If the string is allocated and not empty, the routine attempts to load
* the driver using the values specified in the string.
*
* RETURNS: An END object pointer, or NULL on error, or 0 and the name of the
* device if the <initString> was NULL.
*/
STATUS lan91c111CheckString(char* initString)
{
/*"0x28000300:(11) 0x2:(15)0x2:0x2:(23)0x31f0:(30)00:10:ec:00:3a:(45)1f"*/
int i;
if(initString[12]!=':')
{
printf("%d ",initString[10]);
return -1;
}
for(i=16;i<25;i=i+4)
{
if(initString[i]!=':')
{
printf("%d ",initString[i]);
return -1;
}
}
for(i=31;i<47;i=i+3)
{
if(initString[i]!=':')
{
printf("%d ",initString[i]);
return -1;
}
}
return 1;
}
END_OBJ* lan91c111Load
(
char* initString /* string to be parse by the driver */
)
{
UINT val;
LAN91C111END_DEVICE *Adapter;
LAN91C111END_DEVICE *pDrvCtrl;
int Temp;
STATUS result;
if (initString == NULL) {
printf ("Loading lan...str=is null\n");
}
else {
if((lan91c111CheckString(initString))<0)
{
printf("lan91c111CheckString .... \n");
}
}
if (initString == NULL)
return (NULL);
if (initString[0] == '\0')
{
bcopy((char *)LAN91C111_DEV_NAME, initString, LAN91C111_DEV_NAME_LEN);
return (0);
}
/* allocate the device structure */
pDrvCtrl = Adapter = (LAN91C111END_DEVICE *)calloc (sizeof (LAN91C111END_DEVICE), 1);
if (pDrvCtrl == NULL)
goto errorExit;
pGDrvCtrl = pDrvCtrl;
/* parse the init string, filling in the device structure */
if (lan91c111InitParse (pDrvCtrl, initString) == ERROR)
goto errorExit;
/* Callout to perform adapter init */
SYS_INT_CONNECT (pDrvCtrl,(VOIDFUNCPTR) lan91c111Int, (int)pDrvCtrl, &result);
if (result == ERROR)
return NULL;
DRV_LOG (DRV_DEBUG_LOAD, "lan91c111Start: Interrupt connected.\n",
1, 2, 3, 4, 5, 6);
SYS_INT_ENABLE (pDrvCtrl);
#if 0
printf("lan91c111Start: iLev = %x, iVector = %x\n", pDrvCtrl->ilevel, pDrvCtrl->ivec, 3,4,5,6);
#endif
/* If there is any problem, code exits immediately; so no need to check
for return values */
if (ConfigureAdapter(Adapter) == ERROR)
{
printf("ConfigureAdapter Problem\n");
goto errorExit;;
}
/*
* Initialize the device
*
*/
if(!AdapterReset(Adapter))
{
DRV_LOG(DRV_DEBUG_LOAD, "Memory Allocation Problem for Adapter\n",1,2,3,4,5,6);
goto errorExit;
}
/* Have the BSP hand us our address. */
SYS_ENET_ADDR_GET(pDrvCtrl);
/* initialize the END and MIB2 parts of the structure */
if (END_OBJ_INIT (&pDrvCtrl->endObj, (DEV_OBJ *)pDrvCtrl, LAN91C111_DEV_NAME,
pDrvCtrl->unit, &lan91c111FuncTable,
"SMSC LAN91C111 Network Driver") == ERROR
|| END_MIB_INIT (&pDrvCtrl->endObj, M2_ifType_ethernet_csmacd,
&pDrvCtrl->enetAddr[0], 6, ETHERMTU,
LAN91C111_SPEED)
== ERROR)
goto errorExit;
/* Perform memory allocation */
if (lan91c111MemInit (pDrvCtrl) == ERROR)
goto errorExit;
/* Read TCR to see if device is working */
SYS_OUT_SHORT( Adapter->IOBase + BANK_SELECT, (USHORT) 0 );
SYS_IN_SHORT((Adapter->IOBase + BANK0_TCR),(USHORT*)&Temp);
DRV_LOG(DRV_DEBUG_LOAD,"VALUE OF TCR=%x",Temp,2,3,4,5,6);
/* set the flags to indicate readiness */
END_OBJ_READY (&pDrvCtrl->endObj,
IFF_UP | IFF_RUNNING | IFF_NOTRAILERS | IFF_BROADCAST
| IFF_MULTICAST | IFF_SIMPLEX);
DRV_LOG (DRV_DEBUG_LOAD, "Done loading lan91c111...\n", 1, 2, 3, 4, 5, 6);
DRV_LOG(DRV_DEBUG_LOAD, "IOBase 0x%x Ivec 0x%x ILevel 0x%x Offset %d InitConfig 0x%x\n",pDrvCtrl->IOBase,pDrvCtrl->ivec, pDrvCtrl->ilevel, pDrvCtrl->offset, pDrvCtrl->InitConfigVal, 6);
return (&pDrvCtrl->endObj);
errorExit:
if (pDrvCtrl != NULL)
free ((char *)pDrvCtrl);
return NULL;
}
/*******************************************************************************
* lan91c111InitParse - parse the initialization string
*
* Parse the input string. Fill in values in the driver control structure.
* The initialization string format is:
* "<unit>:<IOBase>:<interruptVector>:<interruptLevel>:<offset>:<configValue>
*
* RETURNS: OK, or ERROR if any arguments are invalid.
*/
STATUS lan91c111InitParse
(
LAN91C111END_DEVICE * pDrvCtrl,
char * initString
)
{
char * tok;
char * pHolder = NULL;
long address;
/* Parse the initString */
/* Unit number. */
tok = strtok_r (initString, ":", &pHolder);
if (tok == NULL)
return ERROR;
pDrvCtrl->unit = atoi (tok);
/* IO Base */
tok = strtok_r (NULL, ":", &pHolder);
if (tok == NULL)
return ERROR;
address = strtoul (tok, NULL, 16);
pDrvCtrl->IOBase = (UINT)address;
#if DUMP_BANKS
myIOBase = pDrvCtrl->IOBase;
#endif
/* Interrupt vector. */
tok = strtok_r (NULL, ":", &pHolder);
if (tok == NULL)
return ERROR;
pDrvCtrl->ivec = (UINT)strtoul(tok,NULL,16);
/* Interrupt level. */
tok = strtok_r (NULL, ":", &pHolder);
if (tok == NULL)
return ERROR;
pDrvCtrl->ilevel = (UINT)strtoul (tok,NULL,16);
/* Caller supplied alignment offset. */
tok = strtok_r (NULL, ":", &pHolder);
if (tok == NULL)
return ERROR;
pDrvCtrl->offset = (UINT)strtoul (tok,NULL,16);
/* Config string */
tok = strtok_r (NULL, ":", &pHolder);
if (tok == NULL)
return ERROR;
pDrvCtrl->InitConfigVal = (UINT)strtoul (tok, NULL, 16);
pDrvCtrl->userNetAddrOverRide = FALSE;
/* MAC Address[0] */
tok = strtok_r (NULL, ":", &pHolder);
if (tok == NULL)
goto parse_exit;
address = strtoul (tok, NULL, 16);
if (address != 0) pDrvCtrl->userNetAddrOverRide = TRUE;
pDrvCtrl->userNetAddr.Address[0] = (unsigned char)address;
/* MAC Address[1] */
tok = strtok_r (NULL, ":", &pHolder);
if (tok == NULL)
return ERROR;
address = strtoul (tok, NULL, 16);
if (address != 0) pDrvCtrl->userNetAddrOverRide = TRUE;
pDrvCtrl->userNetAddr.Address[1] = (unsigned char)address;
/* MAC Address[2] */
tok = strtok_r (NULL, ":", &pHolder);
if (tok == NULL)
return ERROR;
address = strtoul (tok, NULL, 16);
if (address != 0) pDrvCtrl->userNetAddrOverRide = TRUE;
pDrvCtrl->userNetAddr.Address[2] = (unsigned char)address;
/* MAC Address[3] */
tok = strtok_r (NULL, ":", &pHolder);
if (tok == NULL)
return ERROR;
address = strtoul (tok, NULL, 16);
if (address != 0) pDrvCtrl->userNetAddrOverRide = TRUE;
pDrvCtrl->userNetAddr.Address[3] = (unsigned char)address;
/* MAC Address[4] */
tok = strtok_r (NULL, ":", &pHolder);
if (tok == NULL)
return ERROR;
address = strtoul (tok, NULL, 16);
if (address != 0) pDrvCtrl->userNetAddrOverRide = TRUE;
pDrvCtrl->userNetAddr.Address[4] = (unsigned char)address;
/* MAC Address[5] */
tok = strtok_r (NULL, ":", &pHolder);
if (tok == NULL)
return ERROR;
address = strtoul (tok, NULL, 16);
if (address != 0) pDrvCtrl->userNetAddrOverRide = TRUE;
pDrvCtrl->userNetAddr.Address[5] = (unsigned char)address;
DRV_LOG(DRV_DEBUG_LOAD, "MAC Addr : %2x:%2x:%2x:%2x:%2x:%2x\n",
pDrvCtrl->userNetAddr.Address[0],
pDrvCtrl->userNetAddr.Address[1],
pDrvCtrl->userNetAddr.Address[2],
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -