KallistiOS git master
Independent SDK for the Sega Dreamcast
|
G2 bus memory interface. More...
#include <sys/cdefs.h>
#include <stdint.h>
#include <arch/irq.h>
#include <arch/types.h>
#include <dc/fifo.h>
Go to the source code of this file.
Data Structures | |
struct | g2_ctx_t |
G2 context. More... | |
Macros | |
#define | G2_DMA_TO_G2 0 |
G2Bus DMA direction. | |
#define | G2_DMA_TO_SH4 1 |
List of G2 Bus channels | |
AICA (SPU) is channel 0, BBA uses channel 1. CH2_DMA_G2CHN and CH3_DMA_G2CHN are not currently tied to any specific device.
In the current implementation, *_DMA_MODE should always be set to zero (representing CPU_TRIGGER). There is also no involvement of SH4-DMA with G2-DMA; therefore, the *_DMA_SHCHN values have been deprecated. | |
#define | G2_DMA_CHAN_SPU 0 |
AICA: G2 channel 0. | |
#define | G2_DMA_CHAN_BBA 1 |
BBA: G2 channel 1. | |
#define | G2_DMA_CHAN_CH2 2 |
CH2: G2 channel 2. | |
#define | G2_DMA_CHAN_CH3 3 |
CH3: G2 channel 3. | |
Typedefs | |
typedef void(* | g2_dma_callback_t) (void *data) |
G2Bus DMA interrupt callback type. | |
Functions | |
int | g2_dma_transfer (void *sh4, void *g2bus, size_t length, uint32_t block, g2_dma_callback_t callback, void *cbdata, uint32_t dir, uint32_t mode, uint32_t g2chn, uint32_t sh4chn) |
Perform a DMA transfer between SH-4 RAM and G2 Bus. | |
int | g2_dma_init (void) |
Initialize DMA support. | |
void | g2_dma_shutdown (void) |
Shutdown DMA support. | |
static g2_ctx_t | g2_lock (void) |
Disable IRQs and G2 DMA. | |
static void | g2_unlock (g2_ctx_t ctx) |
Enable IRQs and G2 DMA. | |
uint8_t | g2_read_8 (uintptr_t address) |
Read one byte from G2. | |
void | g2_write_8 (uintptr_t address, uint8_t value) |
Write a single byte to G2. | |
uint16 | g2_read_16 (uintptr_t address) |
Read one 16-bit word from G2. | |
void | g2_write_16 (uintptr_t address, uint16_t value) |
Write a 16-bit word to G2. | |
uint32_t | g2_read_32 (uintptr_t address) |
Read one 32-bit dword from G2. | |
void | g2_write_32 (uintptr_t address, uint32_t value) |
Write a 32-bit dword to G2. | |
void | g2_read_block_8 (uint8_t *output, uintptr_t address, size_t amt) |
Read a block of bytes from G2. | |
void | g2_write_block_8 (const uint8_t *input, uintptr_t address, size_t amt) |
Write a block of bytes to G2. | |
void | g2_read_block_16 (uint16_t *output, uintptr_t address, size_t amt) |
Read a block of words from G2. | |
void | g2_write_block_16 (const uint16_t *input, uintptr_t address, size_t amt) |
Write a block of words to G2. | |
void | g2_read_block_32 (uint32_t *output, uintptr_t address, size_t amt) |
Read a block of dwords from G2. | |
void | g2_write_block_32 (const uint32_t *input, uintptr_t address, size_t amt) |
Write a block of dwords to G2. | |
void | g2_memset_8 (uintptr_t address, uint8_t c, size_t amt) |
Set a block of bytes to G2. | |
void | g2_fifo_wait (void) |
Wait for the G2 write FIFO to empty. | |
G2 bus memory interface.
This file provides low-level support for accessing devices on the G2 bus in the Dreamcast. The G2 bus contains the AICA, as well as the expansion port. Generally, you won't be dealing with things at this level, but rather on the level of the device you're actually interested in working with. Most of the expansion port devices (the modem, bba, and lan adapter) all have their own drivers that work off of this functionality.
The G2 bus is notoroiously picky about a lot of things. You have to be careful to use the right access size for whatever you're working with. Also you can't be doing PIO and DMA at the same time. Finally, there's a FIFO to contend with when you're doing PIO stuff as well. Generally, G2 is a pain in the rear, so you really do want to be using the higher-level stuff related to each device if at all possible!