libteak
Loading...
Searching...
No Matches
Macros | Functions
dma.h File Reference

DMA helpers. More...

Macros

#define REG_DMA_CH_CONTROL   (*(vu16 *)0x81DE)
 DMA Channel: Start/Stop/Control (R/W)
 
#define REG_DMA_CH_DIM0_DST_STEP   (*(vs16 *)0x81D0)
 DMA Channel: Source Step1 (signed) (R/W)
 
#define REG_DMA_CH_DIM0_LEN   (*(vu16 *)0x81C8)
 DMA Channel: Size0 (inner dimension) (R/W)
 
#define REG_DMA_CH_DIM0_SRC_STEP   (*(vs16 *)0x81CE)
 DMA Channel: Source Step0 (signed) (R/W)
 
#define REG_DMA_CH_DIM1_DST_STEP   (*(vs16 *)0x81D4)
 DMA Channel: Destination Step0 (signed) (R/W)
 
#define REG_DMA_CH_DIM1_LEN   (*(vu16 *)0x81CA)
 DMA Channel: Size1 (middle dimension) (R/W)
 
#define REG_DMA_CH_DIM1_SRC_STEP   (*(vs16 *)0x81D2)
 DMA Channel: Source Step2 (signed) (R/W)
 
#define REG_DMA_CH_DIM2_DST_STEP   (*(vs16 *)0x81D8)
 DMA Channel: Destination Step2 (signed) (R/W)
 
#define REG_DMA_CH_DIM2_LEN   (*(vu16 *)0x81CC)
 DMA Channel: Size2 (outer dimension) (R/W)
 
#define REG_DMA_CH_DIM2_SRC_STEP   (*(vs16 *)0x81D6)
 DMA Channel: Destination Step1 (signed) (R/W)
 
#define REG_DMA_CH_DST_HI   (*(vu16 *)0x81C6)
 DMA Channel: Destination Address, bit16-31 (R/W)
 
#define REG_DMA_CH_DST_LO   (*(vu16 *)0x81C4)
 DMA Channel: Destination Address, bit0-15 (R/W)
 
#define REG_DMA_CH_SRC_HI   (*(vu16 *)0x81C2)
 DMA Channel: Source Address, bit16-31 (R/W)
 
#define REG_DMA_CH_UNK_81DC   (*(vu16 *)0x81DC)
 DMA Channel: Unknown (R/W)
 
#define REG_DMA_CH_XFER_CONFIG   (*(vu16 *)0x81DA)
 DMA Channel: Memory Area Config (R/W)
 
#define REG_DMA_CHANNEL_SEL   (*(vu16 *)0x81BE)
 DMA Select Channel (0 to 7) (R/W)
 
#define REG_DMA_DIM0_END   (*(vu16 *)0x8188)
 DMA Channel End Flags for Size0 (R)
 
#define REG_DMA_DIM1_END   (*(vu16 *)0x818A)
 DMA Channel End Flags for Size1 (R)
 
#define REG_DMA_DIM2_END   (*(vu16 *)0x818C)
 DMA Channel End Flags for Size2 (R) (all done)
 
#define REG_DMA_PAUSE   (*(vu16 *)0x8186)
 DMA Channel Pause Flags (R/W)
 
#define REG_DMA_START   (*(vu16 *)0x8184)
 DMA Channel Start Flags (R/W)
 

Functions

void dmaInit (void)
 Initializes the DMA system.
 
s16 dmaTransferArm9ToDsp (u16 dma_channel, u32 src, void *dst, u16 len)
 Transfer data from the ARM9 memory map to the DSP data memory.
 
s16 dmaTransferArm9ToDspAsync (u16 dma_channel, u32 src, void *dst, u16 len)
 Starts a transfer of data from the ARM9 memory map to the DSP data memory.
 
s16 dmaTransferDspToArm9 (u16 dma_channel, const void *src, u32 dst, u16 len)
 Transfer data from DSP data memory to the ARM9 memory map.
 
s16 dmaTransferDspToArm9Async (u16 dma_channel, const void *src, u32 dst, u16 len)
 Starts a transfer of data from DSP data memory to the ARM9 memory map.
 
static u16 dmaTransferIsRunning (u16 dma_channel)
 Checks whether a DMA channel is active or not.
 
static void dmaTransferWaitDone (u16 dma_channel)
 Waits until a DMA channel is no longer active because the copy has finished.
 

Detailed Description

DMA helpers.

The DMA registers don't seem to be understood well enough, the functions may be unstable.

Function Documentation

◆ dmaTransferArm9ToDsp()

s16 dmaTransferArm9ToDsp ( u16  dma_channel,
u32  src,
void *  dst,
u16  len 
)

Transfer data from the ARM9 memory map to the DSP data memory.

This function uses AHBM channel 1.

DMA channel 0 is required to transfer data with the FIFO functions, so it can't be used by this function.

This function can't copy data crossing a 1KB boundary on the ARM9 side because of limitations of the AHBM bus.

Parameters
dma_channelThe DMA channel to use (1 to 7, 0 isn't allowed).
srcSource address in the ARM9 memory map.
dstDestination address in the DSP data memory.
lenLength of the copy in DSP words.
Returns
It returns 0 on success, other values on error.

◆ dmaTransferArm9ToDspAsync()

s16 dmaTransferArm9ToDspAsync ( u16  dma_channel,
u32  src,
void *  dst,
u16  len 
)

Starts a transfer of data from the ARM9 memory map to the DSP data memory.

This function uses AHBM channel 1.

DMA channel 0 is required to transfer data with the FIFO functions, so it can't be used by this function.

This function can't copy data crossing a 1KB boundary on the ARM9 side because of limitations of the AHBM bus.

Use dmaTransferIsRunning() to verify if the transfer has finished or not, or dmaTransferWaitDone() to wait until it's done.

Parameters
dma_channelThe DMA channel to use (1 to 7, 0 isn't allowed).
srcSource address in the ARM9 memory map.
dstDestination address in the DSP data memory.
lenLength of the copy in DSP words.
Returns
It returns 0 on success, other values on error.

◆ dmaTransferDspToArm9()

s16 dmaTransferDspToArm9 ( u16  dma_channel,
const void *  src,
u32  dst,
u16  len 
)

Transfer data from DSP data memory to the ARM9 memory map.

This function uses AHBM channel 2.

DMA channel 0 is required to transfer data with the FIFO functions, so it can't be used by this function.

This function can't copy data crossing a 1KB boundary on the ARM9 side because of limitations of the AHBM bus.

Parameters
dma_channelThe DMA channel to use (1 to 7, 0 isn't allowed).
srcSource address in the DSP data memory.
dstDestination address in the ARM9 memory map.
lenLength of the copy in DSP words.
Returns
It returns 0 on success, other values on error.

◆ dmaTransferDspToArm9Async()

s16 dmaTransferDspToArm9Async ( u16  dma_channel,
const void *  src,
u32  dst,
u16  len 
)

Starts a transfer of data from DSP data memory to the ARM9 memory map.

This function uses AHBM channel 2.

DMA channel 0 is required to transfer data with the FIFO functions, so it can't be used by this function.

This function can't copy data crossing a 1KB boundary on the ARM9 side because of limitations of the AHBM bus.

Use dmaTransferIsRunning() to verify if the transfer has finished or not, or dmaTransferWaitDone() to wait until it's done.

Parameters
dma_channelThe DMA channel to use (1 to 7, 0 isn't allowed).
srcSource address in the DSP data memory.
dstDestination address in the ARM9 memory map.
lenLength of the copy in DSP words.
Returns
It returns 0 on success, other values on error.

◆ dmaTransferIsRunning()

static u16 dmaTransferIsRunning ( u16  dma_channel)
inlinestatic

Checks whether a DMA channel is active or not.

Parameters
dma_channelThe DMA channel to check (1 to 7, 0 isn't allowed).
Returns
It returns 1 if the DMA channel is busy, 0 if not.

◆ dmaTransferWaitDone()

static void dmaTransferWaitDone ( u16  dma_channel)
inlinestatic

Waits until a DMA channel is no longer active because the copy has finished.

Parameters
dma_channelThe DMA channel to check (1 to 7, 0 isn't allowed).