/** * \brief Disable TX & reset registers and descriptor list * \param pDrv Pointer to GMAC Driver instance. */ static void GMACD_ResetTx(sGmacd *pDrv, gmacQueList_t queIdx) { Gmac *pHw = pDrv->pHw; uint8_t *pTxBuffer = pDrv->queueList[queIdx].pTxBuffer; sGmacTxDescriptor *pTd = pDrv->queueList[queIdx].pTxD; uint32_t Index; uint32_t Address; /* Disable TX */ GMAC_TransmitEnable(pHw, 0); /* Setup the TX descriptors. */ GCIRC_CLEAR(pDrv->queueList[queIdx].wTxHead, pDrv->queueList[queIdx].wTxTail); for(Index = 0; Index < pDrv->queueList[queIdx].wTxListSize; Index++) { Address = (uint32_t)(&(pTxBuffer[Index * pDrv->queueList[queIdx].wTxBufferSize])); pTd[Index].addr = Address; pTd[Index].status.val = (uint32_t)GMAC_TX_USED_BIT; } pTd[pDrv->queueList[queIdx].wTxListSize - 1].status.val = GMAC_TX_USED_BIT | GMAC_TX_WRAP_BIT; /* Transmit Buffer Queue Pointer Register */ GMAC_SetTxQueue(pHw, (uint32_t)pTd, queIdx); }
/////////////////////////////////////////////////////////////////////////////// // ============================================================================= //Function :Initialize necessary allocated buffer lists for GMAC Driver to transfer // data.Must be invoked after GMACD_Init() but before RX/TX start. //Paramters:pDrive, Pointer to GMAC Driver instance. // pInit, Pointer to sGmacInit. // queIdx, Pointer to gmacQueList_t for different queue. //Returns :void //Notification:If input address is not 8-byte aligned the address is automatically // adjusted and the list size is reduced by one. // ============================================================================= //this function to do the bd initialize,create the buffer describe with the memory static void __MacBdSndInit(u32 qindex) { tagQueue *queue; volatile tagSndBD *sndbd; u32 i; u32 address; u32 status; queue = &gMacDriver.queueList[qindex]; //initialize the send bd status = GMAC_TX_USED_BIT; for(i =0;i < queue->sndbdlen;i++) { sndbd = queue->sndbdtab + i; address = (u32)(queue->sndmem + queue->sndbuflen*i); sndbd->addr = address&GMAC_ADDRESS_MASK; sndbd->status.val = status; } sndbd->status.val = status|GMAC_TX_WRAP_BIT; //the last one must be wrap queue->sndbdcur = 0; queue->sndbdlast = 0; //set the address to the register GMAC_SetTxQueue(gMacDriver.pHw, (u32)queue->sndbdtab, qindex); return; }