libdragon
Files | Functions | Variables
DMA Controller
Low Level Hardware Interfaces

DMA functionality for transfers between cartridge space and RDRAM. More...

Files

file  dma.c
 

DMA Controller.


file  dma.h
 

DMA Controller.


Functions

volatile int dma_busy ()
 Return whether the DMA controller is currently busy.
void dma_read (void *ram_address, unsigned long pi_address, unsigned long len)
 Read from a peripheral.
void dma_write (void *ram_address, unsigned long pi_address, unsigned long len)
 Write to a peripheral.
uint32_t io_read (uint32_t pi_address)
 Read a 32 bit integer from a peripheral.
void io_write (uint32_t pi_address, uint32_t data)
 Write a 32 bit integer to a peripheral.

Variables

static struct PI_regs_s *const PI_regs = (struct PI_regs_s *)0xa4600000
 Structure used to interact with the PI registers.

PI Status Register Bit Definitions

#define PI_STATUS_DMA_BUSY   ( 1 << 0 )
 PI DMA Busy.
#define PI_STATUS_IO_BUSY   ( 1 << 1 )
 PI IO Busy.
#define PI_STATUS_ERROR   ( 1 << 2 )
 PI Error.

Detailed Description

DMA functionality for transfers between cartridge space and RDRAM.

The DMA controller is responsible for handling block and word accesses from the catridge domain. Because of the nature of the catridge interface, code cannot use memcpy or standard pointer accesses on memory mapped to the catridge. Consequently, the peripheral interface (PI) provides a DMA controller for accessing data.

The DMA controller requires no initialization. Using dma_read and dma_write will allow reading from the cartridge and writing to the catridge respectively in block mode. io_read and io_write will allow a single 32-bit integer to be read from or written to the cartridge. These are especially useful for manipulating registers on a cartridge such as a gameshark. Code should never make raw 32-bit reads or writes in the cartridge domain as it could collide with an in-progress DMA transfer or run into caching issues.


Function Documentation

volatile int dma_busy ( )

Return whether the DMA controller is currently busy.

Returns:
nonzero if the DMA controller is busy or 0 otherwise
void dma_read ( void *  ram_address,
unsigned long  pi_address,
unsigned long  len 
)

Read from a peripheral.

This function should be used when reading from the cartridge.

Parameters:
[out]ram_addressPointer to a buffer to place read data
[in]pi_addressMemory address of the peripheral to read from
[in]lenLength in bytes to read into ram_address
void dma_write ( void *  ram_address,
unsigned long  pi_address,
unsigned long  len 
)

Write to a peripheral.

This function should be used when writing to the cartridge.

Parameters:
[in]ram_addressPointer to a buffer to read data from
[in]pi_addressMemory address of the peripheral to write to
[in]lenLength in bytes to write to peripheral
uint32_t io_read ( uint32_t  pi_address)

Read a 32 bit integer from a peripheral.

Parameters:
[in]pi_addressMemory address of the peripheral to read from
Returns:
The 32 bit value read from the peripheral
void io_write ( uint32_t  pi_address,
uint32_t  data 
)

Write a 32 bit integer to a peripheral.

Parameters:
[in]pi_addressMemory address of the peripheral to write to
[in]data32 bit value to write to peripheral
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines