📄 dec21x40end.c
字号:
} /* decode non-register user flags */ if (pDrvCtrl->usrFlags & DEC_USR_XEA) DRV_FLAGS_SET (DEC_BSP_EADRS); switch (pDrvCtrl->usrFlags & DEC_USR_VER_MSK) { case DEC_USR_21143 : DRV_FLAGS_SET (DEC_21143); break; case DEC_USR_21140 : DRV_FLAGS_SET (DEC_21140); break; case DEC_USR_21145 : DRV_FLAGS_SET (DEC_21145); break; default : DRV_FLAGS_SET (DEC_21040); break; } if (dec21x40EnetAddrGet (pDrvCtrl, eAdrs) == ERROR) { DRV_LOG (DRV_DEBUG_INIT, "%s%d - Failed to read ethernet address\n", (int)DRV_NAME, pDrvCtrl->unit,0,0,0,0); goto error; } DRV_LOG (DRV_DEBUG_LOAD, "ENET: %x:%x:%x:%x:%x:%x\n", eAdrs[0], eAdrs[1], eAdrs[2], eAdrs[3], eAdrs[4], eAdrs[5]);#ifdef INCLUDE_RFC_1213 /* Old RFC 1213 mib2 interface */ /* Initialize MIB-II entries */ if (END_MIB_INIT (&pDrvCtrl->endObj, M2_ifType_ethernet_csmacd, (UINT8*) eAdrs, 6, ETHERMTU, DEC_SPEED_DEF) == ERROR) { DRV_LOG (DRV_DEBUG_INIT, "%s%d - MIB-II initializations failed\n", (int)DRV_NAME, pDrvCtrl->unit,0,0,0,0); goto error; } /* Mark the device ready with default flags */ END_OBJ_READY (&pDrvCtrl->endObj, IFF_NOTRAILERS | IFF_MULTICAST | IFF_BROADCAST); #else /* New RFC 2233 mib2 interface */ /* Initialize MIB-II entries (for RFC 2233 ifXTable) */ pDrvCtrl->endObj.pMib2Tbl = m2IfAlloc(M2_ifType_ethernet_csmacd, (UINT8*) eAdrs, 6, ETHERMTU, DEC_SPEED_DEF, DRV_NAME, pDrvCtrl->unit); if (pDrvCtrl->endObj.pMib2Tbl == NULL) { printf ("%s%d - MIB-II initializations failed\n", DRV_NAME, pDrvCtrl->unit); goto error; } /* * Set the RFC2233 flag bit in the END object flags field and * install the counter update routines. */#if defined(END_MIB_2233) pDrvCtrl->endObj.flags |= END_MIB_2233;#endif /* defined(END_MIB_2233) */ m2IfPktCountRtnInstall(pDrvCtrl->endObj.pMib2Tbl, m2If8023PacketCount); /* * Make a copy of the data in mib2Tbl struct as well. We do this * mainly for backward compatibility issues. There might be some * code that might be referencing the END pointer and might * possibly do lookups on the mib2Tbl, which will cause all sorts * of problems. */ bcopy ((char *)&pDrvCtrl->endObj.pMib2Tbl->m2Data.mibIfTbl, (char *)&pDrvCtrl->endObj.mib2Tbl, sizeof (M2_INTERFACETBL)); /* Mark the device ready with default flags */#if defined(END_MIB_2233) END_OBJ_READY (&pDrvCtrl->endObj, IFF_NOTRAILERS | IFF_MULTICAST | IFF_BROADCAST | END_MIB_2233);#else /* !defined(END_MIB_2233) */ END_OBJ_READY (&pDrvCtrl->endObj, IFF_NOTRAILERS | IFF_MULTICAST | IFF_BROADCAST);#endif /* !defined(END_MIB_2233) */#endif /* INCLUDE_RFC_1213 */ return (&pDrvCtrl->endObj); /* Handle error cases */error: dec21x40Unload (pDrvCtrl); return (NULL); }/***************************************************************************** dec21x40Unload - unload a driver from the system** This routine deallocates lists, and free allocated memory.** RETURNS: OK, always.*/LOCAL STATUS dec21x40Unload ( DRV_CTRL *pDrvCtrl ) { DRV_LOG (DRV_DEBUG_LOAD, "EndUnload\n", 0, 0, 0, 0, 0, 0);#ifndef INCLUDE_RFC_1213 /* New RFC 2233 mib2 interface */ /* Free MIB-II entries */ m2IfFree(pDrvCtrl->endObj.pMib2Tbl); pDrvCtrl->endObj.pMib2Tbl = NULL;#endif /* INCLUDE_RFC_1213 */ /* deallocate lists */ END_OBJ_UNLOAD (&pDrvCtrl->endObj); /* deallocate allocated shared memory */ if (DRV_FLAGS_ISSET (DEC_MEMOWN) && pDrvCtrl->memBase) cacheDmaFree (pDrvCtrl->memBase); return (OK); }/***************************************************************************** dec21x40InitParse - parse parameter values from initString** The initialization string is modified by muxLib.o to include the unit number* as the first parameter.** Parse the input string. Fill in values in the driver control structure.** The initialization string format is:* "<device addr>:<PCI addr>:<ivec>:<ilevel>:<mem base>:<mem size>: \* <user flags>:<phyAddr>:<pPhyTbl>:<phyFlags>:<offset>:<loanBufs>:<drvFlags>"** .bS* device addr base address of hardware device registers* PCI addr main memory address over the PCI bus* ivec interrupt vector number* ilevel interrupt level* mem base base address of a DMA-able, cache free,pre-allocated memory* mem size size of the pre-allocated memory* user flags User flags control the run-time characteristics of the chip* phyAddr MII PHY address (optional)* pPhyTbl address of auto-negotiation table (optional)* phyFlags PHY configuration flags (optional)* offset Memory offset for alignment (optional)* loanBufs number of loaner clusters (optional)* drvFlags Driver flags control the runtime characteristics of the driver** The last six arguments are optional. If the PHY address is to be specified* then phyAddr, pPhyTbl, and phyFlags should all be specified together.** RETURNS: OK or ERROR for invalid arguments.*/LOCAL STATUS dec21x40InitParse ( DRV_CTRL *pDrvCtrl, char *initString ) { char * tok; /* an initString token */ char * holder=NULL; /* points to initString fragment beyond tok */ UINT32 tokValue; DRV_LOG (DRV_DEBUG_LOAD, "InitParse: Initstr=%s\n", (int) initString, 0, 0, 0, 0, 0); tok = endTok_r(initString, ":", &holder); if (tok == NULL) return ERROR; pDrvCtrl->unit = atoi(tok); tok=endTok_r(NULL, ":", &holder); if (tok == NULL) return ERROR; pDrvCtrl->devAdrs = strtoul (tok, NULL, 16); tok=endTok_r(NULL, ":", &holder); if (tok == NULL) return ERROR; pDrvCtrl->pciMemBase = strtoul (tok, NULL, 16); tok=endTok_r(NULL, ":", &holder); if (tok == NULL) return ERROR; pDrvCtrl->ivec = strtoul (tok, NULL, 16); tok=endTok_r(NULL, ":", &holder); if (tok == NULL) return ERROR; pDrvCtrl->ilevel = strtoul (tok, NULL, 16); tok = endTok_r(NULL, ":", &holder); if (tok == NULL) return ERROR; if (atoi(tok) < 0) pDrvCtrl->numRds = NUM_RDS_DEF; else pDrvCtrl->numRds = atoi(tok); tok = endTok_r(NULL, ":", &holder); if (tok == NULL) return ERROR; if (atoi(tok) < 0) pDrvCtrl->numTds = NUM_TDS_DEF; else pDrvCtrl->numTds = atoi(tok); tok=endTok_r(NULL, ":", &holder); if (tok == NULL) return ERROR; pDrvCtrl->memBase = (char *) strtoul (tok, NULL, 16); tok=endTok_r(NULL, ":", &holder); if (tok == NULL) return ERROR; pDrvCtrl->memSize = strtoul (tok, NULL, 16); tok=endTok_r(NULL, ":", &holder); if (tok == NULL) return (ERROR); pDrvCtrl->usrFlags = strtoul(tok, NULL, 16); /* * Start of optional parameters. Set each optional parameter to * its default value, so that each will have a reasonable value * if we run out of fields during the string parse. */ pDrvCtrl->phyAddr = (UINT8) 0xFF; pDrvCtrl->pMiiPhyTbl = NULL; pDrvCtrl->miiPhyFlags = (DEC_USR_MII_10MB | DEC_USR_MII_HD | DEC_USR_MII_100MB | DEC_USR_MII_FD | DEC_USR_MII_BUS_MON); pDrvCtrl->offset = 0; pDrvCtrl->loanBufs = NUM_LOAN; pDrvCtrl->drvFlags = 0; /* phyAddr */ tok = endTok_r (NULL, ":", &holder); if (tok == NULL) goto endOptionalParams; pDrvCtrl->phyAddr = (UINT8) strtoul (tok, NULL, 16); /* pMiiPhyTbl - must be supplied if phyAddr was given */ tok = endTok_r (NULL, ":", &holder); if (tok == NULL) return (ERROR); tokValue = strtoul (tok, NULL, 16); if ((INT32) tokValue != -1) pDrvCtrl->pMiiPhyTbl = (MII_AN_ORDER_TBL *) tokValue; /* miiPhyFlags - must be supplied if phyAddr was given */ tok = endTok_r (NULL, ":", &holder); if (tok == NULL) return (ERROR); tokValue = strtoul (tok, NULL, 16); if ((INT32) tokValue != -1) pDrvCtrl->miiPhyFlags = tokValue; /* offset */ tok = endTok_r (NULL, ":", &holder); if (tok == NULL) goto endOptionalParams; if (atoi(tok) >= 0) pDrvCtrl->offset = atoi (tok); /* loanBufs */ tok = endTok_r (NULL, ":", &holder); if (tok == NULL) goto endOptionalParams; tokValue = (UINT32) strtoul (tok, NULL, 16); if ((INT32) tokValue != -1) pDrvCtrl->loanBufs = tokValue; /* drvFlags */ tok = endTok_r (NULL, ":", &holder); if (tok == NULL) goto endOptionalParams; pDrvCtrl->drvFlags = (UINT32) strtoul (tok, NULL, 16); if (pDrvCtrl->drvFlags & DEC_DRV_NOSWAP_MASTER) DRV_FLAGS_SET (DEC_NOSWAP_MASTER);endOptionalParams: /* print debug info */ DRV_LOG (DRV_DEBUG_LOAD, "EndLoad: unit=%d devAdrs=0x%x ivec=0x%x ilevel=0x%x\n", pDrvCtrl->unit, pDrvCtrl->devAdrs, pDrvCtrl->ivec, pDrvCtrl->ilevel, 0, 0); DRV_LOG (DRV_DEBUG_LOAD, " membase=0x%x memSize=0x%x\n", (int)pDrvCtrl->memBase, pDrvCtrl->memSize, 0,0,0,0); DRV_LOG (DRV_DEBUG_LOAD, " pciMemBase=0x%x flags=0x%x usrFlags=0x%x offset=%d\n", (int)pDrvCtrl->pciMemBase, pDrvCtrl->flags, pDrvCtrl->usrFlags, pDrvCtrl->offset, 0, 0); DRV_LOG (DRV_DEBUG_LOAD, " phyAddr=0x%x pMiiPhyTbl=0x%x miiPhyFlags=0x%x\n", (int) pDrvCtrl->phyAddr, (int) pDrvCtrl->pMiiPhyTbl, (int) pDrvCtrl->miiPhyFlags, 0,0,0); DRV_LOG (DRV_DEBUG_LOAD, " loanBufs=%d drvFlags=0x%x\n", (int) pDrvCtrl->loanBufs, (int) pDrvCtrl->drvFlags, 0, 0, 0, 0); return OK; }/***************************************************************************** dec21x40InitMem - initialize memory** RETURNS: OK or ERROR.*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -