13static int _sif2_inited = 0;
15static u32 _sif2_xfer_addr = 0;
16static u32 _sif2_xfer_size = 0;
17static u32 _sif2_xfer_attr = 0;
18static u32 _sif2_xfer_chunk_size = 0;
19static SIF2_TransferCbFunc _sif2_xfer_cb = NULL;
21extern void do_debug(u32 val);
23int SIF2_RestartDma(
void);
25void SIF2_sync_dma(
void)
29 if ((_sif2_xfer_addr != 0) && (_sif2_xfer_size > 0)) {
30 _sif2_xfer_addr += _sif2_xfer_chunk_size;
31 _sif2_xfer_size -= _sif2_xfer_chunk_size;
34 if ((_sif2_xfer_addr != 0) && (_sif2_xfer_size > 0)) {
48int SIF2_RestartDma(
void)
52 if (!(*R_LOCAL_SBUS(PS2_SBUS_REG4) & 0x80)) {
53 *R_LOCAL_SBUS(PS2_SBUS_REG4) = 0x80;
57 (void)(*R_IOP_D2_CHCR);
59 *R_IOP_D2_MADR = (_sif2_xfer_addr & 0x00FFFFFF);
61 _sif2_xfer_chunk_size = (_sif2_xfer_size > SIF2_XFER_CHUNK_SIZE) ? SIF2_XFER_CHUNK_SIZE : _sif2_xfer_size;
63 bs = ((_sif2_xfer_chunk_size + 3) / 4);
68 bc = (_sif2_xfer_chunk_size + ((bs * 4) - 1)) / (bs * 4);
70 *R_IOP_D2_BCR_BS = bs;
71 *R_IOP_D2_BCR_BC = bc;
72 *R_IOP_D2_CHCR = _sif2_xfer_attr;
73 (void)(*R_IOP_D2_CHCR);
78int SIF2_set_dma(u32 addr, u32 size, u32 attr)
84 size = ((size + 3) / 4) * 4;
86 _sif2_xfer_addr = addr;
87 _sif2_xfer_size = size;
89 if (!(attr & PS2_DMA_FROM_MEM)) {
100int _sif2_intr_handler(
void)
102 u32 chcr = *R_IOP_D2_CHCR;
106 if ((_sif2_xfer_addr != 0) && (_sif2_xfer_size > 0)) {
107 _sif2_xfer_addr += _sif2_xfer_chunk_size;
108 _sif2_xfer_size -= _sif2_xfer_chunk_size;
111 if ((_sif2_xfer_addr != 0) && (_sif2_xfer_size > 0)) {
128 int oldStat, old_irq;
138 if (!(*R_IOP_DPCR & 0x0800)) {
139 *R_IOP_DPCR |= 0x0800;
159 int oldStat, old_irq;
170 if ((*R_IOP_DPCR & 0x0800)) {
171 *R_IOP_DPCR |= 0x0800;
int CpuResumeIntr(int state)
int RegisterIntrHandler(int irq, int mode, int(*handler)(void *), void *arg)
int DisableIntr(int irq, int *res)
int CpuSuspendIntr(int *state)