DMA Driver APIs DMA State Diagram Loading Driver and Opening Channel DMA Channel Attributes Loading...
-
Upload
shannon-osborne -
Category
Documents
-
view
237 -
download
0
description
Transcript of DMA Driver APIs DMA State Diagram Loading Driver and Opening Channel DMA Channel Attributes Loading...
DMA Driver APIs
DMA State DiagramLoading Driver and Opening ChannelDMA Channel AttributesLoading Data to a ChannelUnloading Data from a Channel
DMA Driver State Diagram
Idle
Enabled Disabled
dmaLoadDriver()
dmaOpenChannel()
dmaDisableChannel()
dmaEnableChannel()
dmaCloseChannel()
dmaCloseChannel()
dmaLoadChannel()
dmaUnloadChannel()
Loading DMA Driver
prototype: int dmaLoadDriver(void)
Returns 0 always.
Opening a DMA Channelprototype: 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
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
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.
Channel Typeprototype: int dmaOpenChannel(
int *channel_ID,int channel_type,unsigned int option_flags,int ring_size,dmaReleaseType release_rtn)
PeripheralFIFO
DMA Memory “Fly-By Write”
PeripheralFIFO
DMA Memory “Fly-By Read”
DMA_FIFO_1_TX(Channel 4)
DMA_FIFO_1_RX(Channel 3)
Option Flags
• 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
These Flags Configure the DMA Channel Control Registers
prototype: int dmaOpenChannel( int *channel_ID,
int channel_type,unsigned int option_flags,
int ring_size,dmaReleaseType release_rtn)
option_flags: DMA_Operation Mode
PeripheralFIFO Memory
PeripheralFIFO Memory
Default Setting“Fly-By”
Memory DMA Memory DMA_MEM_TO_MEM
DMA
DMA
OR
option_flags : Burst Transfer Size
BCLK
TA*
TA*
TA*
Default Setting
DMA_8_BYTE_BURST
DMA_16_BYTE_BURST
1 LongWord
(4 Bytes)
2 LongWords
(8 Bytes)
4 LongWords
(16 Bytes)
option_flags : Channel Request Source
Net+ARM
DREQ* DACK* DONE*
Peripheral DMA_EXTERNAL_REQ
Net+ARM
DREQ* DACK* DONE*
Peripheral
Default SettingInternal Fly-By
peripheral*OR
Mem-to-Mem undersoftware control
*Note: Internal Fly-By hardwired to ENI RX and ENI TX
option_flags : Address Increment
Applies to Memory-to-Memory DMA only.SourceMemory
DestinationMemory
SourceRange Destination
Range DMA_DADDR_INCDMA_SRC_INCR
SourceMemory
DestinationMemory
DestinationRange DMA_DADDR_INC
Default Setting
SourceLocation
*Note: It never makes sense to NOTincrement the destination address
DMA
DMA
option_flags : DMA Transaction Operand Size
8-bitPeripheral
FIFOMemory
16-bitPeripheral
FIFOMemory
DMA_8_BIT
DMA_16_BIT
32-bitPeripheral
FIFOMemory Default Setting
DMA
DMA
DMA
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
DMA Channel ring_size
DMA Channel
Buffer Descriptor Pointer
SystemMemory
Buffer DescriptorRing Area
(CONTIGUOUS)
dmaOpenChannel() allocates BD ring area from heap, based on int ring_size.
Release Callback
prototype: void (*dmaReleaseType) (int channel_ID, dmaMessageType *request_msg)
EnableddmaLoadChannel()
The defined callback will be called when thedmaLoadChannel() request has completed, with input parameters channel_ID and *request_msg.
prototype: int dmaOpenChannel( int *channel_ID,
int channel_type,unsigned int option_flags,
int ring_size,dmaReleaseType release_rtn)
Loading a ChannelLoading a channel configures the previously allocated Buffer Descriptors.
prototype: int dmaLoadChannel(int channel_ID,dmaMessageType request_msg)
typedef struct dmaMessageStruct{
struct dmaMessageStruct *next;void *src_addr;void *dst_addr;long length;long status;long error_value;long reserved[4];
} dmaMessageType;
Fly-By Read Loading
Memory
Destination Area
PeripheralFIFO
Set up enough dmaMessageType’sto 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
Fly-By Write Loading
Memory
Source Data Area
PeripheralFIFO
Set up enough dmaMessageType’sto accommodate outgoing data.
*next Address of next dmaMessageType if more than 32Kbytes needed.
*src_addr Start of Data Buffer (incrementing)*dst_addr Not Usedlength Up to 32Kbytes
Memory to Memory Loading
Memory
Source Data Area
Memory
Set up enough dmaMessageType’sto 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
Destination
UnLoading a ChannelUnLoading 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)
DMA Channel
Buffer Descriptor Pointer
SystemMemory
Buffer Descriptors
Used
Unused
Used
UnusedUnload
Note: Each request_msg uses one buffer descriptor.
Request Processing - no Release Callback
dmaLoadChannel()
DMA Channel Request Queue
DMA ISR
DMA Channel Release Queue*
dmaUnloadChannel()
* Not built when a release callback is provided
fills
emptied by fills
emptied by
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