RTEMS 7.0-rc1
Loading...
Searching...
No Matches
Data Structures | Macros | Functions
raspberrypi-dma.c File Reference

Raspberry Pi specific DMA definitions. More...

#include <bsp/raspberrypi-dma.h>

Data Structures

struct  rpi_dma_control_block
 
struct  rpi_dma_lite_control_block
 
struct  rpi_dma4_control_block
 

Macros

#define DMA4_AD_SHIFT(addr)   ( addr >> 5 )
 
#define DMA4_AD_UNSHIFT(addr)   ( addr << 5 )
 
#define ADDRESS_LOW(addr)   ( (uintptr_t) ( addr ) & 0xFFFFFFFF )
 
#define ADDRESS_HIGH(addr)   ( ( (uintptr_t) ( addr ) >> 32 ) & 0xFF )
 
#define BUS_ADDR(addr)   ( ( ( addr ) & ~0xC0000000 ) | 0xC0000000 )
 

Functions

rtems_status_code rpi_dma_start_transfer (rpi_dma_channel channel)
 Start a previously initialized DMA transfer on channel.
 
rtems_status_code rpi_dma_wait (rpi_dma_channel channel)
 Block until the current DMA transfer on channel completes.
 
rtems_status_code rpi_dma_mem_to_mem_init (rpi_dma_channel channel, void *source_address, void *destination_address, uint32_t transfer_length)
 Initialize a memcpy-style DMA transfer from source_address to destination_address of transfer_length bytes on channel.
 

Detailed Description

Raspberry Pi specific DMA definitions.

Function Documentation

◆ rpi_dma_mem_to_mem_init()

rtems_status_code rpi_dma_mem_to_mem_init ( rpi_dma_channel  channel,
void *  source_address,
void *  destination_address,
uint32_t  transfer_length 
)

Initialize a memcpy-style DMA transfer from source_address to destination_address of transfer_length bytes on channel.

Allocates and prepares the channel-specific control block, performs required cache maintenance (flush control block and source; invalidate destination), issues CS reset/abort, and writes CONBLK_AD (with DMA4 address packing via DMA4_AD_SHIFT). This function does not start the transfer; call rpi_dma_start_transfer() and then rpi_dma_wait().

Parameters
channelDMA channel to use (0–6 noarmal DMA, 7–10 lite, 11–14 DMA4).
source_addressSource buffer (must be CPU_CACHE_LINE_BYTES aligned).
destination_addressDestination buffer (must be CPU_CACHE_LINE_BYTES aligned).
transfer_lengthNumber of bytes to copy.
Return values
RTEMS_SUCCESSFULon success.
RTEMS_INVALID_NUMBERif channel is invalid/unsupported or has no base address.
RTEMS_INVALID_ADDRESSif source_address or destination_address are misaligned.
RTEMS_NO_MEMORYif control block allocation failed.

◆ rpi_dma_start_transfer()

rtems_status_code rpi_dma_start_transfer ( rpi_dma_channel  channel)

Start a previously initialized DMA transfer on channel.

Expects the channel's CONBLK_AD to point to a valid control block. Sets ACTIVE and required priorities.

Parameters
channelDMA channel to start.
Return values
RTEMS_SUCCESSFULon success.
RTEMS_INVALID_NUMBERif channel is invalid.

◆ rpi_dma_wait()

rtems_status_code rpi_dma_wait ( rpi_dma_channel  channel)

Block until the current DMA transfer on channel completes.

Busy-waits for ACTIVE to clear and frees the control block previously programmed into CONBLK_AD (including DMA4 address unshifting). Does not invalidate/flush user buffers beyond setup done by the init helpers.

Parameters
channelDMA channel to wait on.
Return values
RTEMS_SUCCESSFULon success.
RTEMS_INVALID_NUMBERif channel is invalid.
RTEMS_UNSATISFIEDif the channel reports an error.