21static u32 dma_chcr[10] = { 0x10008000, 0x10009000, 0x1000A000, 0x1000B000, 0x1000B400, 0x1000C000, 0x1000C400, 0x1000C800, 0x1000D000, 0x1000D400 };
23static u32 dma_qwc[10] = { 0x10008020, 0x10009020, 0x1000A020, 0x1000B020, 0x1000B420, 0x1000C020, 0x1000C420, 0x1000C820, 0x1000D020, 0x1000D420 };
25static u32 dma_madr[10] = { 0x10008010, 0x10009010, 0x1000A010, 0x1000B010, 0x1000B410, 0x1000C010, 0x1000C410, 0x1000C810, 0x1000D010, 0x1000D410 };
27static u32 dma_tadr[10] = { 0x10008030, 0x10009030, 0x1000A030, 0x1000B030, 0x1000B430, 0x1000C030, 0x1000C430, 0x1000C830, 0x1000D030, 0x1000D430 };
29static u32 dma_asr0[10] = { 0x10008040, 0x10009040, 0x1000A040, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 };
31static u32 dma_asr1[10] = { 0x10008050, 0x10009050, 0x1000A050, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 };
33static u32 dma_sadr[10] = { 0x10008080, 0x10009080, 0x1000A080, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x1000D080, 0x1000D480 };
35static int dma_handler_id[10] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
37static int dma_channel_initialized[10] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
45 for(i = 0; i < 10; i++)
68 if (dma_asr0[channel])
70 *(vu32 *)dma_asr0[channel] = 0;
71 *(vu32 *)dma_asr1[channel] = 0;
75 if (dma_sadr[channel])
77 *(vu32 *)dma_sadr[channel] = 0;
85 dma_handler_id[channel] = AddDmacHandler(channel, handler, 0);
88 if (flags & DMA_FLAG_INTERRUPTSAFE)
100 dma_channel_initialized[channel] = 1;
134 while (*((vu32 *)dma_chcr[channel]) & 0x00000100)
161 if (packet2->
mode == P2_MODE_CHAIN)
168 (
void *)((u32)packet2->base & 0x0FFFFFFF),
170 packet2->
tte ? DMA_FLAG_TRANSFERTAG : 0,
177 (
void *)((u32)packet2->base & 0x0FFFFFFF),
178 ((u32)packet2->
next - (u32)packet2->base) >> 4,
191 if (flags & DMA_FLAG_INTERRUPTSAFE)
193 iSyncDCache(data, (
void *)((u8 *)data + (data_size<<4)));
197 SyncDCache(data, (
void *)((u8 *)data + (data_size<<4)));
201 *(vu32 *)dma_qwc[channel] = DMA_SET_QWC(0);
204 *(vu32 *)dma_madr[channel] = DMA_SET_MADR(0, 0);
207 *(vu32 *)dma_tadr[channel] = DMA_SET_TADR((u32)data, spr);
210 *(vu32 *)dma_chcr[channel] =
DMA_SET_CHCR(1, 1, 0, flags & DMA_FLAG_TRANSFERTAG, 1, 1, 0);
224 *(vu32 *)dma_qwc[channel] = DMA_SET_QWC(0);
227 *(vu32 *)dma_madr[channel] = DMA_SET_MADR(0, 0);
230 *(vu32 *)dma_tadr[channel] = DMA_SET_TADR((u32)data - 0x30000000, 0);
233 *(vu32 *)dma_chcr[channel] =
DMA_SET_CHCR(1, 1, 0, flags & DMA_FLAG_TRANSFERTAG, 1, 1, 0);
247 if (flags & DMA_FLAG_INTERRUPTSAFE)
249 iSyncDCache(data, (
void *)((u8 *)data + (qwc<<4)));
253 SyncDCache(data, (
void *)((u8 *)data + (qwc<<4)));
257 *(vu32 *)dma_qwc[channel] = DMA_SET_QWC(qwc);
260 *(vu32 *)dma_madr[channel] = DMA_SET_MADR((u32)data, spr);
263 *(vu32 *)dma_chcr[channel] =
DMA_SET_CHCR(1, 0, 0, flags & DMA_FLAG_TRANSFERTAG, 1, 1, 0);
276 if (flags & DMA_FLAG_INTERRUPTSAFE)
278 iSyncDCache(data, (
void *)((u8 *)data + (qwc<<4)));
282 SyncDCache(data, (
void *)((u8 *)data + (qwc<<4)));
286 *(vu32 *)dma_qwc[channel] = DMA_SET_QWC(qwc);
289 *(vu32 *)dma_madr[channel] = DMA_SET_MADR((u32)data - 0x30000000, 0);
292 *(vu32 *)dma_chcr[channel] =
DMA_SET_CHCR(1, 0, 0, flags & DMA_FLAG_TRANSFERTAG, 1, 1, 0);
302 if (dma_channel_initialized[channel] < 0)
314 *(vu32 *)dma_qwc[channel] = DMA_SET_QWC((data_size + 15) >> 4);
317 *(vu32 *)dma_madr[channel] = DMA_SET_MADR((u32)data, spr);
320 *(vu32 *)dma_chcr[channel] =
DMA_SET_CHCR(0, 1, 0, 0, 0, 1, 0);
331 if (dma_channel_initialized[channel] < 0)
343 *(vu32 *)dma_qwc[channel] = DMA_SET_QWC((data_size + 15) >> 4);
346 *(vu32 *)dma_madr[channel] = DMA_SET_MADR((u32)data, spr);
349 *(vu32 *)dma_chcr[channel] =
DMA_SET_CHCR(0, 0, 0, 0, 0, 1, 0);
360 if (dma_channel_initialized[channel] < 0)
366 if (dma_handler_id[channel] != 0)
370 if (flags & DMA_FLAG_INTERRUPTSAFE)
372 iDisableDmac(channel);
376 DisableDmac(channel);
380 RemoveDmacHandler(channel, dma_handler_id[channel]);
383 dma_handler_id[channel] = 0;
388 dma_channel_initialized[channel] = 0;
int dma_channel_send_normal(int channel, void *data, int qwc, int flags, int spr)
int dma_channel_receive_normal(int channel, void *data, int data_size, int flags, int spr)
int dma_channel_wait(int channel, int timeout)
int dma_channel_initialize(int channel, void *handler, int flags)
int dma_channel_receive_chain(int channel, void *data, int data_size, int flags, int spr)
void dma_channel_send_packet2(packet2_t *packet2, int channel, u8 flush_cache)
void dma_channel_fast_waits(int channel)
int dma_channel_send_chain_ucab(int channel, void *data, int qwc, int flags)
int dma_channel_send_chain(int channel, void *data, int qwc, int flags, int spr)
int dma_channel_send_normal_ucab(int channel, void *data, int qwc, int flags)
int dma_channel_shutdown(int channel, int flags)
#define DMA_SET_CHCR(DIR, MODE, ASP, TTE, TIE, STR, TAG)