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

📄 fei82557end.c

📁 这是ARM在Vxworks的驱动源代码
💻 C
📖 第 1 页 / 共 5 页
字号:
	DRV_LOG (DRV_DEBUG_TX, ("fei82557Send...NO CFDS \n"), 1, 2, 3, 4, 5, 6);	/* set to stall condition */	pDrvCtrl->txStall = TRUE;               CSR_WORD_RD (CSR_STAT_OFFSET, scbStatus);        if ((scbStatus & SCB_S_CUMASK) == SCB_S_CUSUSP)	    {	    if (fei82557SCBCommand (pDrvCtrl, SCB_C_CUSTART, TRUE, pCFD)             	== ERROR)		{		DRV_LOG (DRV_DEBUG_TX,("CU Start failed \n"), 0, 0, 0, 0, 0, 0);		} 	    }	END_TX_SEM_GIVE (&pDrvCtrl->endObj);	return (END_ERR_BLOCK);	}    pEnetHdr = (char *) (CFD_PKT_ADDR (pCFD));    len = netMblkToBufCopy (pMblk, (char *) pEnetHdr, NULL);    netMblkClChainFree (pMblk);    len = max (ETHERSMALL, len); #if 0    	{		int i;		UCHAR *p;		Print("send length=%d\n",len);		p=(UCHAR*)pMblk->mBlkHdr.mData;		for (i=0;i<len;i++)			Print("%02x ",p[i]);		Print("\n");    	}#endif#ifndef INCLUDE_RFC_1213    /* New RFC 2233 mib2 interface */    /* RFC 2233 mib2 counter update for outgoing packet */    if (pDrvCtrl->endObj.pMib2Tbl != NULL)        {        pDrvCtrl->endObj.pMib2Tbl->m2PktCountRtn(pDrvCtrl->endObj.pMib2Tbl,                                                 M2_PACKET_OUT, pEnetHdr, len);        }#endif /* INCLUDE_RFC_1213 */    /* set up the current CFD */    CFD_WORD_WR (pCFD, CFD_COUNT_OFFSET, ((len & 0x3fff) | TCB_CNT_EOF));    CFD_WORD_WR (pCFD, CFD_COMM_OFFSET, (CFD_C_XMIT | CFD_C_SUSP));    CFD_WORD_WR (pCFD, CFD_STAT_OFFSET, 0);    /* set the thresh value */    CFD_BYTE_WR (pCFD, CFD_THRESH_OFFSET, 		 pDrvCtrl->board.tcbTxThresh);    /* no TBDs used */    CFD_BYTE_WR (pCFD, CFD_NUM_OFFSET, 0);    /* this is a transmit command */    CFD_BYTE_WR (pCFD, CFD_ACTION_OFFSET, CFD_TX);    /* tie to the previous CFD */    CFD_LONG_RD (pCFD, CFD_PREV_OFFSET, pPrevCFD);    CFD_WORD_RD (pPrevCFD, CFD_COMM_OFFSET, command);    CFD_WORD_WR (pPrevCFD, CFD_COMM_OFFSET, (command & (~CFD_C_SUSP)));    /* Flush the write pipe */    CACHE_PIPE_FLUSH ();    /* advance the current free CFD pointer */    fei82557FDUpdate (pDrvCtrl, CFD_FREE);#ifdef INCLUDE_RFC_1213    /* Old RFC 1213 mib2 interface */    END_ERR_ADD (&pDrvCtrl->endObj, MIB2_OUT_UCAST, +1); #endif /* INCLUDE_RFC_1213 */     /* kick the CU if needed */    if (fei82557SCBCommand (pDrvCtrl, SCB_C_CURESUME, FALSE,(UINT32) 0)         == ERROR)        {        DRV_LOG (DRV_DEBUG_TX, ("Could not send packet\n"), 			          1, 2, 3, 4, 5, 6);        END_TX_SEM_GIVE (&pDrvCtrl->endObj);        return (ERROR);        }    /* interlock with fei82557CFDFree */    END_TX_SEM_GIVE (&pDrvCtrl->endObj);    DRV_LOG (DRV_DEBUG_TX, ("fei82557Send...Done\n"), 1, 2, 3, 4, 5, 6);    return (OK);    }/********************************************************************************* fei82557Int - entry point for handling interrupts from the 82557** The interrupting events are acknowledged to the device, so that the device* will de-assert its interrupt signal.  The amount of work done here is kept* to a minimum; the bulk of the work is deferred to the netTask.** RETURNS: N/A*/LOCAL void fei82557Int    (    DRV_CTRL *  pDrvCtrl       /* pointer to DRV_CTRL structure */    )    {    UINT16  event;    /* read and save CSR status word */    CACHE_PIPE_FLUSH();     CSR_WORD_RD (CSR_STAT_OFFSET, event);    if ((event & SCB_S_STATMASK) == 0)	{	/* This device was not the cause of the shared int */	return;  	}    /* clear chip level interrupt pending, use byte access */    CSR_BYTE_WR (CSR_ACK_OFFSET, ((event & SCB_S_STATMASK) >> 8));    /* board level interrupt acknowledge */    SYS_INT_ACK (pDrvCtrl);    /* handle transmit interrupts */    if ((event & SCB_S_CNA) && (pDrvCtrl->txHandle == FALSE))	{	pDrvCtrl->txHandle = TRUE;	netJobAdd ((FUNCPTR) fei82557CFDFree, (int) pDrvCtrl, 0, 0, 0, 0);	}    /* handle receive interrupts only if fei82557Receive is not running */    if (event & (SCB_S_FR | SCB_S_RNR))	{        /* Disable receive interrupts in the device for now */        if (pDrvCtrl->deviceId == 0 || pDrvCtrl->deviceId == FEI82557_DEVICE_ID)            {            /* This is an 82557 mask all interrupts */            I82557_INT_DISABLE(SCB_C_M);            }        else            {            /* This is not an 82557 mask only read and no resource interrupts */            I82557_INT_DISABLE(SCB_C_FR | SCB_C_RNR);            }	netJobAdd ((FUNCPTR) fei82557HandleRecvInt, (int) pDrvCtrl,			    0, 0, 0, 0);	}    }/******************************************************************************** fei82557HandleRecvInt - service task-level interrupts for receive frames** This routine is run in netTask's context.  The ISR scheduled* this routine so that it could handle receive packets at task level.** RETURNS: N/A*/LOCAL void fei82557HandleRecvInt    (    DRV_CTRL *  pDrvCtrl       /* pointer to DRV_CTRL structure */    )    {    volatile RFD_ID	pRFD;    UINT16  		status = 0;    UINT16		scbStatus;    UINT16		scbCommand;    int	ix;    DRV_LOG (DRV_DEBUG_RX, "fei82557HandleRecvInt\n", 0, 0, 0, 0, 0, 0);    /* while RFDs to be processed */    FOREVER	{	/* check for RFDs availability */	/* get the first used RFD */	RFD_GET (pRFD);	/* Make cache consistent with memory */	FEI_CACHE_INVALIDATE (pRFD, RFD_SIZE);					    	/* read the RFD status word */			RFD_WORD_RD (pRFD, RFD_STAT_OFFSET, status);	DRV_LOG (DRV_DEBUG_RX, "Checking RFD @ %#x status = %#x\n",		(int) pRFD, (int) status ,0,0,0,0);	if (!(FD_FLAG_ISSET (status, RFD_S_COMPLETE)))	    {	    /* No more RFDs, so break out of the inner loop */	    break;	    }	fei82557Receive (pDrvCtrl, pRFD);	}    /* Flush the write pipe */    CACHE_PIPE_FLUSH ();    /* kick receiver (if needed) */    CSR_WORD_RD (CSR_STAT_OFFSET, scbStatus);    if ((scbStatus & SCB_S_RUMASK) != SCB_S_RURDY)        {        DRV_LOG (DRV_DEBUG_RX, ("HandleRecvInt: ********* RU NOT READY\n"),                                0, 0, 0, 0, 0, 0);	/* get the first used RFD */	RFD_GET (pRFD);        if (fei82557SCBCommand (pDrvCtrl, SCB_C_RUSTART, TRUE, pRFD)            == ERROR)            {            DRV_LOG (DRV_DEBUG_RX,		     "fei82557HandleRecvInt: command %d failed\n",		     SCB_C_RUSTART, 0, 0, 0, 0, 0);	    }        else	    {	    /* read CSR command word */	    CSR_WORD_RD (CSR_COMM_OFFSET, scbCommand);	    DRV_LOG (DRV_DEBUG_RX,		     "fei82557HandleRecvInt: CSR command word 0x%x\n",	             (int) scbCommand, 0, 0, 0, 0, 0);            /* wait for RUSTART accept */	    for (ix = (FEI_INIT_TMO * fei82557ClkRate); --ix;)		{		/* read CSR command word */		CSR_WORD_RD (CSR_COMM_OFFSET, scbCommand);		if (!(scbCommand & SCB_C_RUMASK))		    {		    DRV_LOG (DRV_DEBUG_RX,			     "fei82557HandleRecvInt: RUSTART accepted\n",			     0, 0, 0, 0, 0, 0);		    break;		    }		taskDelay (max (1, sysClkRateGet()/60));		}	    if (!ix)		{		DRV_LOG (DRV_DEBUG_RX,			 "fei82557HandleRecvInt: RUSTART FAILED #######\n",			 0, 0, 0, 0, 0, 0);		}	    }        }    if (pDrvCtrl->deviceId == 0 || pDrvCtrl->deviceId == FEI82557_DEVICE_ID)        {        /* This is an 82557 mask all interrupts */        I82557_INT_ENABLE(SCB_C_M);        }    else        {        /* This is not an 82557 mask only read and no resource interrupts */        I82557_INT_ENABLE ((SCB_C_FR | SCB_C_RNR));        }    DRV_LOG (DRV_DEBUG_RX, ("fei82557HandleRecvInt... Done, \n"),                             0, 0, 0, 0, 0, 0);    }/******************************************************************************** fei82557Receive - pass a received frame to the next layer up** RETURNS: N/A*/LOCAL void fei82557Receive    (    DRV_CTRL *  pDrvCtrl,       /* pointer to DRV_CTRL structure */    RFD_ID      pRFD        	/* pointer to a RFD */    )    {    volatile RFD_ID     pNewRFD         = NULL;    M_BLK_ID            pMblk           = NULL;    CL_BLK_ID           pClBlk          = NULL;    volatile UINT16     status;    volatile UINT16     count;    char *		pData;    static UINT         noClusters = 0;    RFD_WORD_RD (pRFD, RFD_STAT_OFFSET, status);    if (!(FD_FLAG_ISSET (status, RFD_S_OK)))	{        DRV_LOG (DRV_DEBUG_RX, "fei82557Receive: NOT OK\n", 0,0,0,0,0,0);        goto fei82557RecvError;        }    if ((pMblk = netMblkGet (pDrvCtrl->endObj.pNetPool,                            M_DONTWAIT, MT_DATA)) == NULL)	{	DRV_LOG (DRV_DEBUG_RX, "fei82557Receive: netMblkGet failed\n",		 0,0,0,0,0,0);        goto fei82557RecvError;	}    if ((pClBlk = netClBlkGet (pDrvCtrl->endObj.pNetPool,                               M_DONTWAIT)) == NULL)	{	DRV_LOG (DRV_DEBUG_RX, "fei82557Receive: netClBlkGet failed\n",		 0,0,0,0,0,0);        goto fei82557RecvError;	}    if ((pNewRFD = (RFD_ID) netClusterGet (pDrvCtrl->endObj.pNetPool,                                          pDrvCtrl->pClPoolId)) == NULL)	{	DRV_LOG (DRV_DEBUG_RX, "fei82557Receive: netClusterGet failed\n",		 0,0,0,0,0,0);        /* Tell the mux to give back some clusters */               pDrvCtrl->lastError.errCode = END_ERR_NO_BUF;        muxError(&pDrvCtrl->endObj, &pDrvCtrl->lastError);	logMsg ("fei82557Receive: netClusterGet failed\n",noClusters,0,0,0,0,0);        goto fei82557RecvError;	}    /* is the RFD to be given back?? */    if (netClBlkJoin (pClBlk, (char *) pRFD, RFD_SIZE,                      NULL, 0, 0, 0) == NULL)	{	DRV_LOG (DRV_DEBUG_RX, "fei82557Receive: netClBlkJoin failed\n",		 0,0,0,0,0,0);        goto fei82557RecvError;	}    if (netMblkClJoin (pMblk, pClBlk) == NULL)	{	DRV_LOG (DRV_DEBUG_RX, "fei82557Receive: netMblkClJoin failed\n",		 0,0,0,0,0,0);        goto fei82557RecvError;	}	#ifdef INCLUDE_RFC_1213     /* Old RFC 1213 mib2 interface */    END_ERR_ADD (&pDrvCtrl->endObj, MIB2_IN_UCAST, +1);#endif /* INCLUDE_RFC_1213 */     /* get the actual received bytes number */    DRV_LOG (DRV_DEBUG_RX, "pRFD = %p\n", pRFD, 0,0,0,0,0);    RFD_WORD_RD (pRFD, RFD_COUNT_OFFSET, count);    pData = (char *) (RFD_PKT_ADDR (pRFD));    if (pDrvCtrl->offset > 0)	{	bcopy (pData, pData+pDrvCtrl->offset, count & ~0xc000);	pData += pDrvCtrl->offset;	}	    pMblk->mBlkHdr.mFlags	|= M_PKTHDR;    pMblk->mBlkHdr.mData	= (char*)pData;    pMblk->mBlkHdr.mLen		= (count & ~0xc000);        pMblk->mBlkPktHdr.len	= pMblk->mBlkHdr.mLen;#ifndef INCLU

⌨️ 快捷键说明

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