20volatile u16 VoiceTransComplete[2];
21u32 VoiceTransStatus[2];
22u32 VoiceTransIoMode[2];
24extern void SetDmaWrite(s32 chan);
25extern void SetDmaRead(s32 chan);
27extern void DmaStop(u32 core);
29s32 VoiceTransDma(s16 chan, u16 mode, u8 *iop_addr, u32 *spu_addr, u32 size)
33 if(U16_REGISTER_READ(SD_CORE_ATTR(chan)) & SD_DMA_IN_PROCESS)
36 if(U32_REGISTER_READ(SD_DMA_CHCR(chan)) & SD_DMA_START)
39 U16_REGISTER_WRITE(SD_A_TSA_HI(chan), (u32)spu_addr >> 17);
40 U16_REGISTER_WRITE(SD_A_TSA_LO(chan), (u32)spu_addr >> 1);
42 if(mode == SD_TRANS_WRITE)
44 TransIntrData[chan].mode = chan;
45 direction = SD_DMA_DIR_IOP2SPU;
46 U16_REGISTER_WRITE(SD_CORE_ATTR(chan), (U16_REGISTER_READ(SD_CORE_ATTR(chan)) & ~SD_CORE_DMA) | SD_DMA_WRITE);
51 if(mode == SD_TRANS_READ)
53 TransIntrData[chan].mode = (chan << 2) | 0x200;
54 direction = SD_DMA_DIR_SPU2IOP;
55 U16_REGISTER_WRITE(SD_CORE_ATTR(chan), (U16_REGISTER_READ(SD_CORE_ATTR(chan)) & ~SD_CORE_DMA) | SD_DMA_READ);
64 U32_REGISTER_WRITE(SD_DMA_ADDR(chan), (u32)iop_addr);
65 U32_REGISTER_WRITE(SD_DMA_MSIZE(chan), (((size+63)/64) << 16) | 0x10);
66 U32_REGISTER_WRITE(SD_DMA_CHCR(chan), SD_DMA_CS | SD_DMA_START | direction);
71s32 VoiceTrans_Write_IOMode(u32 iopaddr, u32 spu_addr, s32 size, s16 chan)
73 if(U16_REGISTER_READ(SD_CORE_ATTR(chan)) & SD_DMA_IN_PROCESS)
76 if(U32_REGISTER_READ(SD_DMA_CHCR(chan)) & SD_DMA_START)
79 U16_REGISTER_WRITE(SD_A_TSA_HI(chan), (u16)spu_addr >> 17);
80 U16_REGISTER_WRITE(SD_A_TSA_LO(chan), (u16)spu_addr >> 1);
82 TransIntrData[chan].mode = chan;
87 volatile u16* iop_mem = (
volatile u16 *) iopaddr;
100 for(loop = 0; loop <
count; loop += 2)
101 U16_REGISTER_WRITE(SD_A_STD(chan), *iop_mem++);
105 U16_REGISTER_WRITE(SD_CORE_ATTR(chan), (U16_REGISTER_READ(SD_CORE_ATTR(chan)) & ~SD_CORE_DMA) | SD_DMA_IO);
107 statx = U16_REGISTER(0x344 + (chan << 10));
110 while(U16_REGISTER_READ(statx) & SD_IO_IN_PROCESS);
117 U16_REGISTER_WRITEAND(SD_CORE_ATTR(chan), ~SD_CORE_DMA);
122int sceSdVoiceTrans(s16 chan, u16 mode, u8 *iopaddr, u32 *spuaddr, u32 size)
128 if(mode & SD_TRANS_MODE_IO)
129 VoiceTransIoMode[chan] = 1;
131 VoiceTransIoMode[chan] = 0;
133 if(VoiceTransIoMode[chan] == 0)
135 res = VoiceTransDma(chan, mode & 3, iopaddr, spuaddr, size);
139 if((mode & 3) == SD_TRANS_WRITE)
141 res = VoiceTrans_Write_IOMode( (u32)iopaddr, (u32)spuaddr, size, chan);
145 VoiceTransStatus[chan] = 0;
150u32 sceSdVoiceTransStatus(s16 chan, s16 flag)
155 if((VoiceTransIoMode[chan] == 1) || (VoiceTransStatus[chan] == 1))
160 while(!VoiceTransComplete[chan]);
161 VoiceTransStatus[chan] = 1;
162 VoiceTransComplete[chan] = 0;
168 if(VoiceTransComplete[chan] == 0)
return 0;
169 VoiceTransStatus[chan] = 1;
170 VoiceTransComplete[chan] = 0;
u32 count
start sector of fragmented bd/file