1 / 23

DMA Driver APIs

DMA Driver APIs. DMA State Diagram Loading Driver and Opening Channel DMA Channel Attributes Loading Data to a Channel Unloading Data from a Channel. DMA Driver State Diagram. dmaLoadDriver(). Idle. dmaCloseChannel(). dmaUnloadChannel(). dmaOpenChannel(). dmaCloseChannel(). Enabled.

yazid
Télécharger la présentation

DMA Driver APIs

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. DMA Driver APIs DMA State Diagram Loading Driver and Opening Channel DMA Channel Attributes Loading Data to a Channel Unloading Data from a Channel

  2. DMA Driver State Diagram dmaLoadDriver() Idle dmaCloseChannel() dmaUnloadChannel() dmaOpenChannel() dmaCloseChannel() Enabled Disabled dmaDisableChannel() dmaEnableChannel() dmaLoadChannel()

  3. Loading DMA Driver prototype: int dmaLoadDriver(void) Returns 0 always.

  4. Opening a DMA Channel prototype: int dmaOpenChannel( int *channel_ID, int channel_type, unsigned int option_flags, int ring_size, dmaReleaseType release_rtn) example: rc = dmaOpenChannel ( &channel_id, DMA_FIFO_1_TX, (DMA_MEM_TO_MEM_MODE | DMA_DADDR_INCR | DMA_SADDR_INCR), 64, releaseFunction); Returns Error Code

  5. dmaOpenChannel Return Codes Possible Return Values for dmaOpenChannel() DMA_SUCCESS DMA_DRIVER_UNLOADED DMA_INVALID_FLAG DMA_CHANNEL_INUSE DMA_INVALID_RING_SIZE DMA_CALLBACK_UNDEFINED MA_INVALID_STATE DMA_SYSTEM_ERROR DMA_CHANNEL_UNSUPPORTED

  6. Channel ID prototype: int dmaOpenChannel( int *channel_ID, int channel_type, unsigned int option_flags, int ring_size, dmaReleaseType (release_rtn) Handle for opened channel, used in various DMA APIs.

  7. Channel Type prototype: int dmaOpenChannel( int *channel_ID, int channel_type, unsigned int option_flags, int ring_size, dmaReleaseType release_rtn) Peripheral FIFO Memory “Fly-By Write” DMA DMA_FIFO_1_TX (Channel 4) Peripheral FIFO Memory “Fly-By Read” DMA DMA_FIFO_1_RX (Channel 3)

  8. DMA Operation Mode DMA_MEM_TO_MEM Burst Transfer Size DMA_8_BYTE_BURST DMA_16_BYTE_BURST Channel Request Source DMA_EXTERNAL_REQ Source Address Increment DMA_SRC_INCR Destination Address Increment DMA_DADDR_INC DMA Transaction Operand Size DMA_8_BIT DMA_16_BIT Option Flags • prototype: int dmaOpenChannel( • int *channel_ID, • int channel_type, • unsigned int option_flags, • int ring_size, • dmaReleaseType release_rtn) These Flags Configure the DMA Channel Control Registers

  9. option_flags: DMA_Operation Mode Peripheral FIFO Memory DMA Default Setting “Fly-By” OR Peripheral FIFO Memory DMA Memory Memory DMA • DMA_MEM_TO_MEM

  10. option_flags : Burst Transfer Size BCLK Default Setting TA* • DMA_8_BYTE_BURST TA* • DMA_16_BYTE_BURST TA* 1 Long Word (4 Bytes) 2 Long Words (8 Bytes) 4 Long Words (16 Bytes)

  11. option_flags : Channel Request Source Net+ARM DREQ* DACK* DONE* Default Setting Internal Fly-By peripheral* OR Mem-to-Mem under software control Peripheral Net+ARM DREQ* DACK* DONE* Peripheral • DMA_EXTERNAL_REQ *Note: Internal Fly-By hardwired to ENI RX and ENI TX

  12. option_flags : Address Increment Applies to Memory-to-Memory DMA only. Source Memory Destination Memory Source Range DMA_SRC_INCR DMA Destination Range • DMA_DADDR_INC Source Memory Destination Memory Default Setting DMA Destination Range • DMA_DADDR_INC Source Location *Note: It never makes sense to NOT increment the destination address

  13. option_flags : DMA Transaction Operand Size 32-bit Peripheral FIFO Memory Default Setting DMA 8-bit Peripheral FIFO Memory DMA DMA_8_BIT 16-bit Peripheral FIFO Memory DMA DMA_16_BIT

  14. DMA Channel Ring Size prototype: int dmaOpenChannel( int *channel_ID, int channel_type, unsigned int option_flags, int ring_size, dmaReleaseType release_rtn) • Ring Size = Number of Buffer Descriptors: • Max 64 for Mem-to-Mem • Max 128 for Fly-By

  15. DMA Channel ring_size System Memory DMA Channel Buffer Descriptor Pointer Buffer Descriptor Ring Area (CONTIGUOUS) dmaOpenChannel() allocates BD ring area from heap, based on int ring_size.

  16. Release Callback prototype: int dmaOpenChannel( int *channel_ID, int channel_type, unsigned int option_flags, int ring_size, dmaReleaseType release_rtn) prototype: void (*dmaReleaseType) (int channel_ID, dmaMessageType *request_msg) Enabled The defined callback will be called when the dmaLoadChannel() request has completed, with input parameters channel_ID and *request_msg. dmaLoadChannel()

  17. Loading a Channel Loading a channel configures the previously allocated Buffer Descriptors. prototype: int dmaLoadChannel( int channel_ID, dmaMessageType request_msg) typedef structdmaMessageStruct { struct dmaMessageStruct *next; void *src_addr; void *dst_addr; long length; long status; long error_value; long reserved[4]; } dmaMessageType;

  18. Fly-By Read Loading Memory Peripheral FIFO Destination Area Set up enough dmaMessageType’s to accommodate all expected data. *next  Address of next dmaMessageType if more than 32Kbytes needed. *src_addr  Not Used *dst_addr  Start of Destination (incrementing) length  Up to 32Kbytes

  19. Fly-By Write Loading Memory Peripheral FIFO Source Data Area Set up enough dmaMessageType’s to accommodate outgoing data. *next  Address of next dmaMessageType if more than 32Kbytes needed. *src_addr  Start of Data Buffer (incrementing) *dst_addr  Not Used length  Up to 32Kbytes

  20. Memory to Memory Loading Memory Memory Destination Source Data Area Set up enough dmaMessageType’s to accommodate outgoing data. *next  Address of next dmaMessageType if more than 32Kbytes needed. *src_addr  Start of Source Data Buffer (incrementing) *dst_addr  Start of Destination Buffer (incrementing) length  Up to 32Kbytes

  21. UnLoading a Channel UnLoading a channel is called to remove a processed request from the DMA’s queue when no release callback is supplied. prototype: int dmaUnloadChannel( int channel_ID, dmaMessageType *request_msg, int wait_time) System Memory DMA Channel Unused Unused Unload Buffer Descriptor Pointer Used Buffer Descriptors Used Note: Each request_msg uses one buffer descriptor.

  22. Request Processing - no Release Callback dmaLoadChannel() dmaUnloadChannel() fills emptied by DMA Channel Release Queue* DMA Channel Request Queue emptied by fills DMA ISR * Not built when a release callback is provided

  23. DMA API SUmmary • Load the driver - dmaLoadDriver • Open a channel - dmaOpenChannel • Set channel ID, type, options, buffer ring size, release callback • Load the channel • Flyby – source or destination address • Memory to memory – both source and dest • Unload the channel if no release callback supplied

More Related