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

📄 fei82557end.c

📁 此代码主要完成在vxworks 环境下的网络编程
💻 C
📖 第 1 页 / 共 5 页
字号:
    /* get CSR address from the FEI_BOARD_INFO structure */    if ((pDrvCtrl->pCSR = (CSR_ID) pDrvCtrl->board.baseAddr) == NULL)	goto errorExit;    /* probe for memory-mapped CSR */    CACHE_PIPE_FLUSH();    CSR_WORD_RD (CSR_STAT_OFFSET, scbStatus);    if (vxMemProbe ((char *) &scbStatus, VX_READ, 2,		    &bucket[0]) != OK)	{	DRV_LOG (DRV_DEBUG_LOAD,		   (": need MMU mapping for address 0x%x\n"),		   (UINT32) pDrvCtrl->pCSR, 2, 3, 4, 5, 6);	goto errorExit;	}    /* memory initialization */    if (fei82557InitMem (pDrvCtrl) == ERROR)	goto errorExit;    I82557_INT_DISABLE(SCB_C_M);    /* initialize the Physical medium layer */    if (fei82557PhyInit (pDrvCtrl) != OK)	{        DRV_LOG (DRV_DEBUG_LOAD,"Check line connection.\n",0,0,0,0,0,0); 	}    speed = ((((int) pDrvCtrl->board.phySpeed) == PHY_100MBS) ?		FEI_100MBS : FEI_10MBS);    if (fei82557ClkRate == 0)	fei82557ClkRate = sysClkRateGet ();    /* Create TX restart watchdog ID */    pDrvCtrl->txRetryWDId = wdCreate();    if(pDrvCtrl->txRetryWDId == NULL)        {	DRV_LOG (DRV_DEBUG_LOAD, "failed to create TX watchdog ID\n",                 0, 0, 0, 0, 0, 0);        goto errorExit;        }    /*      * reset the chip: this should be replaced by a true      * adapter reset routine, once the init code is here.     */    if (fei82557Reset (pDrvCtrl) != OK)	goto errorExit;    /* CU and RU should be idle following fei82557Reset() */    if (fei82557SCBCommand (pDrvCtrl, SCB_C_CULDBASE, TRUE, 0x0) == ERROR)	goto errorExit;    if (fei82557SCBCommand (pDrvCtrl, SCB_C_RULDBASE, TRUE, 0x0) == ERROR)	goto errorExit;    pDrvCtrl->attached = TRUE;    /* get our ethernet hardware address */    bcopy ((char *)&pDrvCtrl->board.enetAddr,	   (char *)&enetAddr[0],	   FEI_ADDR_LEN);    DRV_LOG (DRV_DEBUG_LOAD, ("fei82557Load...\n			 ADRR: 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x \n "), 			enetAddr[0],			enetAddr[1],			enetAddr[2],			enetAddr[3],			enetAddr[4],			enetAddr[5]);    /* endObj initializations */    if (END_OBJ_INIT (&pDrvCtrl->endObj, (DEV_OBJ*) pDrvCtrl,		      DEV_NAME, pDrvCtrl->unit, &netFuncs,		      "Intel 82557 Ethernet Enhanced Network Driver") == ERROR)	goto errorExit;#ifdef INCLUDE_RFC_2233    /* Initialize MIB-II entries (for RFC 2233 ifXTable) */    pDrvCtrl->endObj.pMib2Tbl = m2IfAlloc(M2_ifType_ethernet_csmacd,                                          (UINT8*) enetAddr, 6,                                          ETHERMTU, speed,                                          DEV_NAME, pDrvCtrl->unit);    if (pDrvCtrl->endObj.pMib2Tbl == NULL)        {        logMsg ("%s%d - MIB-II initializations failed\n",                (int)DEV_NAME, pDrvCtrl->unit,0,0,0,0);        goto errorExit;        }            /*      * Set the RFC2233 flag bit in the END object flags field and     * install the counter update routines.     */    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 */    END_OBJ_READY (&pDrvCtrl->endObj,                   IFF_NOTRAILERS | IFF_MULTICAST | IFF_BROADCAST |                   END_MIB_2233);#else    /* Old RFC 1213 mib2 interface */    if (END_MIB_INIT (&pDrvCtrl->endObj, M2_ifType_ethernet_csmacd,                      (u_char *) &enetAddr[0], FEI_ADDR_LEN,                      ETHERMTU, speed) == ERROR)        goto errorExit;    /* Mark the device ready */    END_OBJ_READY (&pDrvCtrl->endObj,                   IFF_NOTRAILERS | IFF_MULTICAST | IFF_BROADCAST);#endif /* INCLUDE_RFC_2233 */    DRV_LOG (DRV_DEBUG_LOAD, ("fei82557Load... Done \n"), 1, 2, 3, 4, 5, 6);    return (&pDrvCtrl->endObj);errorExit:    DRV_LOG (DRV_DEBUG_LOAD, "fei82557Load failed\n", 0,0,0,0,0,0);    fei82557Unload (pDrvCtrl);    free ((char *) pDrvCtrl);    return NULL;    }/********************************************************************************* fei82557Unload - unload a driver from the system** RETURNS: N/A*/LOCAL STATUS fei82557Unload    (    DRV_CTRL *pDrvCtrl       /* pointer to DRV_CTRL structure */    )    {        DRV_LOG (DRV_DEBUG_LOAD, ("Unloading end..."), 1, 2, 3, 4, 5, 6);#ifdef INCLUDE_RFC_2233    /* Free MIB-II entries */    m2IfFree(pDrvCtrl->endObj.pMib2Tbl);    pDrvCtrl->endObj.pMib2Tbl = NULL;#endif /* INCLUDE_RFC_2233 */    pDrvCtrl->attached = FALSE;    /* free lists */    END_OBJECT_UNLOAD (&pDrvCtrl->endObj);    /* free allocated memory if necessary */    if ((FEI_FLAG_ISSET (FEI_OWN_MEM)) && 	(pDrvCtrl->pClusterBase != NULL))	cacheDmaFree (pDrvCtrl->pClusterBase);    /* free allocated memory if necessary */    cfree (pDrvCtrl->pMclBlkMemArea);    DRV_LOG (DRV_DEBUG_LOAD, ("fei82557Unload... Done\n"), 1, 2, 3, 4, 5, 6);    return (OK);    }/********************************************************************************* fei82557InitParse - parse parameter values from initString** RETURNS: OK or ERROR*/LOCAL STATUS fei82557InitParse    (    DRV_CTRL *	pDrvCtrl,      		/* pointer to DRV_CTRL structure */    char *	initString		/* parameter string */    )    {    char *  tok;		/* an initString token */    char *  holder = NULL;	/* points to initString fragment beyond tok */    tok = strtok_r (initString, ":", &holder);    if (tok == NULL)	return ERROR;    pDrvCtrl->unit = atoi (tok);    tok = strtok_r (NULL, ":", &holder);    if (tok == NULL)	return ERROR;    pDrvCtrl->pClusterBase = (char *)strtoul (tok, NULL, 16);    tok = strtok_r (NULL, ":", &holder);    if (tok == NULL)	return ERROR;    pDrvCtrl->clMemSize = strtoul (tok, NULL, 16);    /* passing nCFDs is optional. The default is 64 */         pDrvCtrl->nCFDs = 64;    tok = strtok_r (NULL, ":", &holder);    if ((tok != NULL) && (tok != (char *)-1))        pDrvCtrl->nCFDs = strtoul (tok, NULL, 16);    /* passing nRFDs is optional. The default is 128 */         pDrvCtrl->nRFDs = 128;    tok = strtok_r (NULL, ":", &holder);    if ((tok != NULL) && (tok != (char *)-1))        pDrvCtrl->nRFDs = strtoul (tok, NULL, 16);    pDrvCtrl->nRBDs = pDrvCtrl->nRFDs;    tok = strtok_r (NULL, ":", &holder);    if (tok == NULL)	return ERROR;    pDrvCtrl->flags = atoi (tok);    /* offset value is optional, default is zero */    pDrvCtrl->offset = 0;    tok = strtok_r (NULL, ":", &holder);    if (tok != NULL)	pDrvCtrl->offset = atoi (tok);    /* device ID is optional, default is zero */    pDrvCtrl->deviceId = 0;    tok = strtok_r (NULL, ":", &holder);    if (tok != NULL)	pDrvCtrl->deviceId = atoi (tok);    /* passing maxRxFrames is optional. The default is 128  */    pDrvCtrl->maxRxFrames = pDrvCtrl->nRFDs * 2;       tok = strtok_r (NULL, ":", &holder);    if ((tok != NULL) && (tok != (char *)-1))        pDrvCtrl->maxRxFrames = strtoul (tok, NULL, 16);    /* passing clToRfdRatio is optional. The default is 5  */    pDrvCtrl->clToRfdRatio = 5;    tok = strtok_r (NULL, ":", &holder);    if ((tok != NULL) && (tok != (char *)-1))        pDrvCtrl->clToRfdRatio = strtoul (tok, NULL, 16);    if (pDrvCtrl->clToRfdRatio < 2 )        pDrvCtrl->clToRfdRatio = 2;    /* passing nClusters is optional. The default is  nRFDs * clToRfdRatio */    pDrvCtrl->nClusters = pDrvCtrl->nRFDs * pDrvCtrl->clToRfdRatio;    tok = strtok_r (NULL, ":", &holder);    if ((tok != NULL) && (tok != (char *)-1))        pDrvCtrl->nClusters = strtoul (tok, NULL, 16);    if (!pDrvCtrl->nCFDs || pDrvCtrl->nCFDs <= 2)	{	FEI_FLAG_SET (FEI_INV_NCFD);	pDrvCtrl->nCFDs = DEF_NUM_CFDS;	}    if (!pDrvCtrl->nRFDs || pDrvCtrl->nRFDs <= 2)	{	FEI_FLAG_SET (FEI_INV_NRFD);	pDrvCtrl->nRFDs = DEF_NUM_RFDS;	}    if (pDrvCtrl->nClusters < (pDrvCtrl->nRFDs * 2))        pDrvCtrl->nClusters = pDrvCtrl->nRFDs * 2;    DRV_LOG (DRV_DEBUG_LOAD,	    "fei82557EndLoad: unit=%d pClusterBase=0x%x memSize=0x%x\n",	    pDrvCtrl->unit, (int) pDrvCtrl->pClusterBase,	    (int) pDrvCtrl->clMemSize, 0,0,0);    DRV_LOG (DRV_DEBUG_LOAD,	    "fei82557EndLoad: nCFDs=%d nRFDs=%d flags=%d offset=%d\n",	    pDrvCtrl->nCFDs, pDrvCtrl->nRFDs, pDrvCtrl->flags,	    pDrvCtrl->offset, 0, 0);    return (OK);    }/********************************************************************************* fei82557InitMem - initialize memory** RETURNS: OK or ERROR*/LOCAL STATUS fei82557InitMem    (    DRV_CTRL *  pDrvCtrl       /* pointer to DRV_CTRL structure */    )    {    CFD_ID		pCFD;	   	/* pointer to CFDs */    RFD_ID		pRFD;	   	/* pointer to RFDs */    RFD_TAG *   	pRfdTag;    RBD_ID		pRBD;	   	/* pointer to RFDs */    RBD_TAG *   	pRbdTag;    UINT32		clSize;	   	/* size of allocation for clusters */    UINT32		clusterSize;   	/* size of allocation for clusters */    UINT32		memSize;   	/* size of allocation passed by BSP */    UINT32		nSubtract = 1; 	/* number of RFDs to subtract */    UINT32		rfdSize;   	/* size of allocation for RFDs */    UINT32		rbdSize;   	/* size of allocation for RBDs */    UINT32		cfdSize;   	/* size of allocation for CFDs */    int			ix;		/* index counter */    BOOL		firstCFD = TRUE;/* the first CFD? */    int                 firstOrLast;         M_CL_CONFIG	 fei82557MclBlkConfig =    {	/*	 *  mBlkNum  	clBlkNum     	memArea     memSize	 *  -----------  	----		-------     -------	 */	    0,		0, 		NULL, 	    0    };    CL_DESC	 fei82557ClDescTbl [] =    {	/*	 *  clusterSize  		num    	memArea     memSize	 *  -----------  		----	-------     -------	 */	{CLUSTER_SIZE,			0,  	NULL,       0}        };

⌨️ 快捷键说明

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