📄 xbuf_descriptor.h
字号:
** DestinationAddress contains the destination address field for the buffer* descriptor.** @return** None.** @note** None.*******************************************************************************/#define XBufDescriptor_SetDestAddress(InstancePtr, Destination) \ (*((Xuint32 *)InstancePtr + XBD_DESTINATION_OFFSET) = (Xuint32)Destination)/*****************************************************************************//**** This function gets the length of the data transfer if the buffer descriptor* has been processed by the DMA channel hardware. If the buffer descriptor* has not been processed, the return value will be zero indicating that no data* has been transferred yet. This function uses both the length and requested* length fields of the buffer descriptor to determine the number of bytes* transferred by the DMA operation. The length field of the buffer descriptor* contains the number of bytes remaining from the requested length.** @param** InstancePtr points to the buffer descriptor to operate on.** @return** The number of bytes which have been transferred by a DMA operation on the* buffer descriptor.** @note** None.*******************************************************************************/#define XBufDescriptor_GetLength(InstancePtr) \ (Xuint32)(*((Xuint32 *)InstancePtr + XBD_RQSTED_LENGTH_OFFSET) - \ *((Xuint32 *)InstancePtr + XBD_LENGTH_OFFSET))/*****************************************************************************//**** This function sets the length and the requested length fields of the buffer* descriptor. The length field indicates the number of bytes to transfer for* the DMA operation and the requested length is written with the same value.* The requested length is not modified by the DMA hardware while the length* field is modified by the hardware to indicate the number of bytes remaining* in the transfer after the transfer is complete. The requested length allows* the software to calculate the actual number of bytes transferred for the DMA* operation.** @param** InstancePtr points to the buffer descriptor to operate on.** @param** Length contains the length to put in the length and requested length fields* of the buffer descriptor.** @return** None.** @note** None.*******************************************************************************/#define XBufDescriptor_SetLength(InstancePtr, Length) \{ \ (*((Xuint32 *)InstancePtr + XBD_LENGTH_OFFSET) = (Xuint32)(Length)); \ (*((Xuint32 *)InstancePtr + XBD_RQSTED_LENGTH_OFFSET) = (Xuint32)(Length));\}/*****************************************************************************//**** This function gets the status field of a buffer descriptor component. The* status field is written to the buffer descriptor by the DMA channel hardware* after processing of a buffer descriptor is complete. The status field* indicates the status of the DMA operation.** @param** InstancePtr points to the buffer descriptor to operate on.** @return** The status field contents of the buffer descriptor. One or more of the* following values may be contained the field. Each of the values are* unique bit masks.* <br><br>* - XDC_DMASR_BUSY_MASK The DMA channel is busy* <br><br>* - XDC_DMASR_BUS_ERROR_MASK A bus error occurred* <br><br>* - XDC_DMASR_BUS_TIMEOUT_MASK A bus timeout occurred* <br><br>* - XDC_DMASR_LAST_BD_MASK The last buffer descriptor of a packet** @note** None.*******************************************************************************/#define XBufDescriptor_GetStatus(InstancePtr) \ (Xuint32)(*((Xuint32 *)InstancePtr + XBD_STATUS_OFFSET))/*****************************************************************************//**** This function sets the status field of a buffer descriptor component. The* status field is written to the buffer descriptor by the DMA channel hardware* after processing of a buffer descriptor is complete. This function would* typically be used during debugging of buffer descriptor processing.** @param** InstancePtr points to the buffer descriptor to operate on.** @param** Status contains the status field for the buffer descriptor.* The status register contents of the DMA channel. One or more of the* following values may be contained the register. Each of the values are* unique bit masks.* - XDC_DMASR_BUSY_MASK The DMA channel is busy* - XDC_DMASR_BUS_ERROR_MASK A bus error occurred* - XDC_DMASR_BUS_TIMEOUT_MASK A bus timeout occurred* - XDC_DMASR_LAST_BD_MASK The last buffer descriptor of a packet** @return** None.** @note** None.*******************************************************************************/#define XBufDescriptor_SetStatus(InstancePtr, Status) \ (*((Xuint32 *)InstancePtr + XBD_STATUS_OFFSET) = (Xuint32)Status)/*****************************************************************************//**** This function determines if this buffer descriptor is marked as being the* last in the status field. A packet may be broken up across multiple* buffer descriptors such that the last buffer descriptor is the end of the* packet. The DMA channel hardware copies the status register contents to* the buffer descriptor of the DMA channel after processing of the buffer* descriptor is complete.** @param** InstancePtr points to the buffer descriptor to operate on.** @return** XTRUE if the buffer descriptor is marked as last in the status field,* otherwise, XFALSE.** @note** None.*******************************************************************************/#define XBufDescriptor_IsLastStatus(InstancePtr) \ (Xboolean)((*((Xuint32 *)InstancePtr + XBD_STATUS_OFFSET) & \ XDC_STATUS_LAST_BD_MASK) == XDC_STATUS_LAST_BD_MASK)/*****************************************************************************//**** This function gets the device status field of the buffer descriptor. The* device status is device specific such that the definition of the contents* of this field are not defined in this function. The device is defined as the* device which is using the DMA channel, such as an ethernet controller. The* DMA channel hardware copies the contents of the device status register into* the buffer descriptor when processing of the buffer descriptor is complete.* This value is typically used by the device driver for the device to determine* the status of the DMA operation with respect to the device.** @param** InstancePtr points to the buffer descriptor to operate on.** @return** The device status field of the buffer descriptor.** @note** None.*******************************************************************************/#define XBufDescriptor_GetDeviceStatus(InstancePtr) \ ((Xuint32)(*((Xuint32 *)InstancePtr + XBD_DEVICE_STATUS_OFFSET)))/*****************************************************************************//**** This function sets the device status field of the buffer descriptor. The* device status is device specific such that the definition of the contents* of this field are not defined in this function. The device is defined as the* device which is using the DMA channel, such as an ethernet controller. This* function is typically only used for debugging/testing.** The DMA channel hardware copies the contents of the device status register* into the buffer descriptor when processing of the buffer descriptor is* complete. This value is typically used by the device driver for the device* to determine the status of the DMA operation with respect to the device.** @param** InstancePtr points to the buffer descriptor to operate on.** @param** Status contains the device status field for the buffer descriptor.** @return** None.** @note** None.*******************************************************************************/#define XBufDescriptor_SetDeviceStatus(InstancePtr, Status) \{ \ Xuint32 Register; \ Register = (*((Xuint32 *)InstancePtr + XBD_DEVICE_STATUS_OFFSET)); \ Register &= XDC_DMASR_RX_CS_RAW_MASK; \ (*((Xuint32 *)InstancePtr + XBD_DEVICE_STATUS_OFFSET)) = \ Register | ((Xuint32) (Status)); \}/*****************************************************************************//**** This function gets the next pointer field of the buffer descriptor. This* field is used to link the buffer descriptors together such that multiple DMA* operations can be automated for scatter gather. It also allows a single* packet to be broken across multiple buffer descriptors. The DMA channel* hardware traverses the list of buffer descriptors using the next pointer* of each buffer descriptor.** @param** InstancePtr points to the buffer descriptor to operate on.** @return** The next pointer field of the buffer descriptor.** @note** None.*******************************************************************************/#define XBufDescriptor_GetNextPtr(InstancePtr) \ (XBufDescriptor *)(*((Xuint32 *)InstancePtr + XBD_NEXT_PTR_OFFSET))/*****************************************************************************//**** This function sets the next pointer field of the buffer descriptor. This* field is used to link the buffer descriptors together such that many DMA* operations can be automated for scatter gather. It also allows a single* packet to be broken across multiple buffer descriptors. The DMA channel* hardware traverses the list of buffer descriptors using the next pointer* of each buffer descriptor.** @param** InstancePtr points to the buffer descriptor to operate on.** @param** NextPtr contains the next pointer field for the buffer descriptor.** @return** None.** @note** None.*******************************************************************************/#define XBufDescriptor_SetNextPtr(InstancePtr, NextPtr) \ (*((Xuint32 *)InstancePtr + XBD_NEXT_PTR_OFFSET) = (Xuint32)NextPtr)/*****************************************************************************//**** This function gets the ID field of the buffer descriptor. The ID field is* provided to allow a device driver to correlate the buffer descriptor to other* data structures which may be operating system specific, such as a pointer to* a higher level memory block. The ID field is not used by the DMA channel* hardware and is application specific.** @param** InstancePtr points to the buffer descriptor to operate on.** @return** The ID field of the buffer descriptor.** @note** None.*******************************************************************************/#define XBufDescriptor_GetId(InstancePtr) \ (Xuint32)(*((Xuint32 *)InstancePtr + XBD_ID_OFFSET))/*****************************************************************************//**** This function sets the ID field of the buffer descriptor. The ID field is* provided to allow a device driver to correlate the buffer descriptor to other* data structures which may be operating system specific, such as a pointer to* a higher level memory block. The ID field is not used by the DMA channel* hardware and is application specific.** @param** InstancePtr points to the buffer descriptor to operate on.** @param** Id contains the ID field for the buffer descriptor.** @return** None.** @note** None.*******************************************************************************/#define XBufDescriptor_SetId(InstancePtr, Id) \ (*((Xuint32 *)InstancePtr + XBD_ID_OFFSET) = (Xuint32)Id)/*****************************************************************************//**** This function gets the flags field of the buffer descriptor. The flags* field is not used by the DMA channel hardware and is used for software* processing of buffer descriptors.** @param** InstancePtr points to the buffer descriptor to operate on.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -