📄 mallib.c
字号:
} return(OK); }/********************************************************************************* malChannelStop()- Stops a MAL channel.** This routine stops an active MAL channel.** RETURNS: N/A**/STATUS malChannelStop ( MAL_DATA * pMalData, UINT channelType, UINT channelNum ) { UINT channelBit; channelBit = 1 << (32 - channelNum - 1); /* * Check to make sure the channel has been defined with a call to * MalChannelInit(). If so, set the bit for the channel in the appropriate * Channel Active Reset register. */ switch (channelType) { case MAL_TX_TYPE : if (pMalData->malInitializedChannels[MAL_TX_TYPE] & channelBit) sysDcrOutLong(MAL_BASE_REG + MAL_TXCARR, channelBit); break; case MAL_RX_TYPE : if (pMalData->malInitializedChannels[MAL_RX_TYPE] & channelBit) sysDcrOutLong(MAL_BASE_REG + MAL_RXCARR, channelBit); break; default : return(ERROR); } return(OK); }/********************************************************************************* malChannelIntMaskGet()- Returns the interrupt mask for a channel.** This routine returns the interrupt mask for a channel.** RETURNS: N/A**/STATUS malChannelIntMaskGet ( MAL_DATA * pMalData, UINT channelType, UINT channelNum, UINT * intMask ) { UINT channelBit; channelBit = 1 << (32 - channelNum - 1); /* * Check to make sure the channel has been defined with a call to * MalChannelInit(). If so, return the interrupt mask for the channel. */ if (pMalData->malInitializedChannels[channelType] & channelBit) *intMask = pMalData->malChannelArray[channelType][channelNum].channelIntMask; else return(ERROR); return(OK); }/********************************************************************************* malChannelIntMaskSet()- Sets the interrupt mask for a channel.** This routine sets the interrupt mask for a channel.** RETURNS: N/A**/STATUS malChannelIntMaskSet ( MAL_DATA * pMalData, UINT channelType, UINT channelNum, UINT intMask ) { UINT channelBit; channelBit = 1 << (32 - channelNum - 1); /* * Check to make sure the channel has been defined with a call to * MalChannelInit(). If so, set the interrupt mask for the channel. */ if (pMalData->malInitializedChannels[channelType] & channelBit) pMalData->malChannelArray[channelType][channelNum].channelIntMask = intMask; else return(ERROR); return(OK); }/********************************************************************************* malChannelDescTblPtrGet()- Get address of the descriptor table for a channel** This routine returns the address of the descriptor table array that was* allocated for the channel in the malInit() function.** RETURNS: N/A**/STATUS malChannelDescTblPtrGet ( MAL_DATA * pMalData, UINT channelType, UINT channelNum, MAL_BD ** descTblPtr ) { UINT channelBit; channelBit = 1 << (32 - channelNum - 1); /* * If MAL initialization has been performed, and the channel is a valid * one, then the descriptor table array pointer is valid. */ if ((channelBit & pMalData->malInit.validChannels[channelType]) == 0) return(ERROR); /* not a valid channel */ /* Return the contents of the channel descriptor table pointer regsiter */ switch (channelType) { case MAL_TX_TYPE : *descTblPtr = (MAL_BD *)sysDcrInLong(MAL_BASE_REG + MAL_TXCTPxR + channelNum); break; case MAL_RX_TYPE : *descTblPtr = (MAL_BD *)sysDcrInLong(MAL_BASE_REG + MAL_RXCTPxR + channelNum); break; default : return(ERROR); } return(OK); }/********************************************************************************* malSerrInt() - MAL System ERRor interrupt handler.** This routine is called when a MAL system interrupt occurs.** RETURNS: N/A**/LOCAL void malSerrInt ( void ) { /* ZZZZZZZZZZZZ TBD */ /* check if SERR ints are enabled in the mask */ return; }/********************************************************************************* malTXEobInt() - MAL Transmit End-of-Buffer Interrupt handler.** This routine is called when a MAL Transmit End-of-Buffer Interrupt occurs* for any of the active channels that have the "Interrupt" bit set in* the descriptor control/status field. This routine will determine which* transmit channel caused the interrupt, and then will call the routine that* was specified when the channel was initialized.** RETURNS: N/A**/LOCAL void malTXEobInt ( MAL_DATA * pMalData ) { UINT txeobisr; VOIDFUNCPTR function; UINT parm; UINT mask; UINT i; UINT eobMask; /* Read the Transmit End-Of-Buffer Interrupt Status Register */ txeobisr = sysDcrInLong(MAL_BASE_REG + MAL_TXEOBISR); /* AND it with the set of channels we know are initialized. */ txeobisr &= pMalData->malInitializedChannels[MAL_TX_TYPE]; while (txeobisr != 0) { i = vxFirstBit(txeobisr); eobMask = (UINT)0x80000000 >> i; if (i < MAL_MAX_CHANNELS) { /* Clear the interrupt in the TXEOB status reg */ sysDcrOutLong(MAL_BASE_REG + MAL_TXEOBISR, eobMask); function = pMalData->malChannelArray[MAL_TX_TYPE][i].functionEOB; parm = pMalData->malChannelArray[MAL_TX_TYPE][i].parmEOB; mask = pMalData->malChannelArray[MAL_TX_TYPE][i].channelIntMask; /* * If the driver for this channel has enabled EOB interrupts and * the EOB int function ptr is not NULL, call it */ if ((mask & MAL_EOB_INT_EN) && (function != NULL)) function(parm); /* Clear the bit for the interrupt just handled in txeobisr */ txeobisr &= ~eobMask; } else { break; } } return; }/********************************************************************************* malRXEobInt() - MAL Receive End-of-Buffer Interrupt handler.** This routine is called when a MAL Receive End-of-Buffer Interrupt occurs.** RETURNS: N/A**/LOCAL void malRXEobInt ( MAL_DATA * pMalData ) { UINT rxeobisr; VOIDFUNCPTR function; UINT parm; UINT mask; UINT i; UINT eobMask; /* Read the Receive End-Of-Buffer Interrupt Status Register */ rxeobisr = sysDcrInLong(MAL_BASE_REG + MAL_RXEOBISR); /* AND it with the set of channels we know are initialized. */ rxeobisr &= pMalData->malInitializedChannels[MAL_RX_TYPE]; while (rxeobisr != 0) { i = vxFirstBit(rxeobisr); eobMask = (UINT)0x80000000 >> i; if (i < MAL_MAX_CHANNELS) { /* Clear the interrupt in the RXEOB status reg */ sysDcrOutLong(MAL_BASE_REG + MAL_RXEOBISR, eobMask); function = pMalData->malChannelArray[MAL_RX_TYPE][i].functionEOB; parm = pMalData->malChannelArray[MAL_RX_TYPE][i].parmEOB; mask = pMalData-> malChannelArray[MAL_RX_TYPE][i].channelIntMask; /* * If the driver for this channel has enabled EOB interrupts and * the EOB int function ptr is not NULL, call it */ if ((mask & MAL_EOB_INT_EN) && (function != NULL)) function(parm); /* Clear the bit for the interrupt just handled in rxeobisr */ rxeobisr &= ~eobMask; } else { break; } } return; }/********************************************************************************* malTXDeInt() - MAL Transmit Descriptor Error Interrupt handler.** This routine is called when a MAL Transmit Descriptor Error Interrupt occurs.** RETURNS: N/A**/LOCAL void malTXDeInt ( MAL_DATA * pMalData ) { UINT txdeir; VOIDFUNCPTR function; UINT parm; UINT mask; int i; /* Read the Transmit Descriptor Error Interrupt Status Register */ txdeir = sysDcrInLong(MAL_BASE_REG + MAL_TXDEIR); /* AND it with the set of channels we know are initialized. */ txdeir &= pMalData->malInitializedChannels[MAL_TX_TYPE]; for (i=0; i < MAL_MAX_CHANNELS; i++) { if (txdeir & ((UINT)0x80000000 >> i)) { function = pMalData->malChannelArray[MAL_TX_TYPE][i].functionDescErr; parm = pMalData->malChannelArray[MAL_TX_TYPE][i].parmDescErr; mask = pMalData->malChannelArray[MAL_TX_TYPE][i].channelIntMask; /* * If the driver for this channel has enabled DE interrupts and * the DE int function ptr is not NULL, call it */ if ((mask & MAL_DE_INT_EN) && (function != NULL)) function(parm); /* Clear the interrupt in the TXDEIR status reg */ sysDcrOutLong(MAL_BASE_REG + MAL_TXDEIR, (UINT)0x80000000 >> i); } } return; }/********************************************************************************* malRXDeInt() - MAL Receive Descriptor Error Interrupt handler.** This routine is called when a MAL Receive Descriptor Error Interrupt occurs.** RETURNS: N/A**/LOCAL void malRXDeInt ( MAL_DATA * pMalData ) { UINT rxdeir; VOIDFUNCPTR function; UINT parm; UINT mask; int i; /* Read the Receive Descriptor Error Interrupt Status Register */ rxdeir = sysDcrInLong(MAL_BASE_REG + MAL_RXDEIR); /* AND it with the set of channels we know are initialized. */ rxdeir &= pMalData->malInitializedChannels[MAL_RX_TYPE]; for (i=0; i < MAL_MAX_CHANNELS; i++) { if (rxdeir & ((UINT)0x80000000 >> i)) { function = pMalData->malChannelArray[MAL_RX_TYPE][i].functionDescErr; parm = pMalData->malChannelArray[MAL_RX_TYPE][i].parmDescErr; mask = pMalData->malChannelArray[MAL_RX_TYPE][i].channelIntMask; /* * If the driver for this channel has enabled DE interrupts and * the DE int function ptr is not NULL, call it */ if ((mask & MAL_DE_INT_EN) && (function != NULL)) function(parm); /* Clear the interrupt in the RXDEIR status reg */ sysDcrOutLong(MAL_BASE_REG + MAL_RXDEIR, (UINT)0x80000000 >> i); } } return; }/********************************************************************************* malShutDown() - shut down the entire MAL and the MAL driver.** This routine stops the MAL if all channels have been deleted, then frees* the MAL driver resources.** RETURNS: OK if successful, ERROR is any MAL channels are still initialized.**/STATUS malShutDown ( MAL_DATA * pMalData ) { if (pMalData == NULL) return(ERROR); /* Check first to be sure there are no initialized channels. */ if (pMalData->malInitializedChannels[MAL_TX_TYPE] || pMalData->malInitializedChannels[MAL_RX_TYPE]) return(ERROR); /* Disable MAL interrupts */ intDisable(pMalData->malInit.intLvlSerr); intDisable(pMalData->malInit.intLvlTxeob); intDisable(pMalData->malInit.intLvlRxeob); intDisable(pMalData->malInit.intLvlTxde); intDisable(pMalData->malInit.intLvlRxde); /* Soft reset MAL */ malReset(pMalData->malInit.dcrBaseReg); /* Free descriptor table memory */ if (CACHE_DMA_IS_WRITE_COHERENT() && (pMalData->descTablesAlloc != NULL)) cacheDmaFree(pMalData->descTablesAlloc); else free(pMalData->descTablesAlloc); /* Free MAL driver control structure */ free(pMalData); pMalData = NULL; return(OK); }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -