23#define BANNER "FREESD %s\n"
24#define VERSION "v1.01"
26#define MODNAME "freesd"
34#define M_PRINTF(format, args...) printf(MODNAME ": " format, ## args)
37extern u32 BlockTransBuff[2];
38extern u32 BlockTransAddr[2];
39extern u32 BlockTransSize[2];
42extern u32 EffectSizes[10];
43extern void SetESA(s32 core, u32 value);
44extern u32 GetEEA(
int chan);
46extern u32 EffectAddr[2];
49extern u32 VoiceTransStatus[2];
50extern volatile u16 VoiceTransComplete[2];
51extern u32 VoiceTransIoMode[2];
56sceSdTransIntrHandler TransIntrHandlers[2];
57SdIntrCallback TransIntrCallbacks[2];
58sceSdSpu2IntrHandler Spu2IntrHandler;
59SdIntrCallback Spu2IrqCallback;
63volatile u16 *ParamRegList[] =
65 SD_VP_VOLL(0, 0), SD_VP_VOLR(0, 0), SD_VP_PITCH(0, 0), SD_VP_ADSR1(0, 0),
66 SD_VP_ADSR2(0, 0), SD_VP_ENVX(0, 0), SD_VP_VOLXL(0, 0), SD_VP_VOLXR(0, 0),
67 SD_P_MMIX(0), SD_P_MVOLL(0), SD_P_MVOLR(0), SD_P_EVOLL(0),
68 SD_P_EVOLR(0), SD_P_AVOLL(0), SD_P_AVOLR(0), SD_P_BVOLL(0),
69 SD_P_BVOLR(0), SD_P_MVOLXL(0), SD_P_MVOLXR(0), SD_S_PMON_HI(0),
70 SD_S_NON_HI(0), SD_A_KON_HI(0), SD_A_KOFF_HI(0), SD_S_ENDX_HI(0),
71 SD_S_VMIXL_HI(0), SD_S_VMIXEL_HI(0), SD_S_VMIXR_HI(0), SD_S_VMIXER_HI(0),
72 SD_A_ESA_HI(0), SD_A_EEA_HI(0), SD_A_TSA_HI(0), SD_CORE_IRQA(0),
73 SD_VA_SSA_HI(0, 0), SD_VA_LSAX(0,0), SD_VA_NAX(0, 0), SD_CORE_ATTR(0),
74 SD_A_TSA_HI(0), SD_A_STD(0),
76 U16_REGISTER(0x1AE), U16_REGISTER(0x1B0),
83 0x8000, 0x879C, 0x8FAC, 0x9837, 0xA145, 0xAADC, 0xB504,
84 0xBFC8, 0xCB2F, 0xD744, 0xE411, 0xF1A1, 0x8000, 0x800E,
85 0x801D, 0x802C, 0x803B, 0x804A, 0x8058, 0x8067, 0x8076,
86 0x8085, 0x8094, 0x80A3, 0x80B1, 0x80C0, 0x80CF, 0x80DE,
87 0x80ED, 0x80FC, 0x810B, 0x811A, 0x8129, 0x8138, 0x8146,
88 0x8155, 0x8164, 0x8173, 0x8182, 0x8191, 0x81A0, 0x81AF,
89 0x81BE, 0x81CD, 0x81DC, 0x81EB, 0x81FA, 0x8209, 0x8218,
90 0x8227, 0x8236, 0x8245, 0x8254, 0x8263, 0x8272, 0x8282,
91 0x8291, 0x82A0, 0x82AF, 0x82BE, 0x82CD, 0x82DC, 0x82EB,
92 0x82FA, 0x830A, 0x8319, 0x8328, 0x8337, 0x8346, 0x8355,
93 0x8364, 0x8374, 0x8383, 0x8392, 0x83A1, 0x83B0, 0x83C0,
94 0x83CF, 0x83DE, 0x83ED, 0x83FD, 0x840C, 0x841B, 0x842A,
95 0x843A, 0x8449, 0x8458, 0x8468, 0x8477, 0x8486, 0x8495,
96 0x84A5, 0x84B4, 0x84C3, 0x84D3, 0x84E2, 0x84F1, 0x8501,
97 0x8510, 0x8520, 0x852F, 0x853E, 0x854E, 0x855D, 0x856D,
98 0x857C, 0x858B, 0x859B, 0x85AA, 0x85BA, 0x85C9, 0x85D9,
99 0x85E8, 0x85F8, 0x8607, 0x8617, 0x8626, 0x8636, 0x8645,
100 0x8655, 0x8664, 0x8674, 0x8683, 0x8693, 0x86A2, 0x86B2,
101 0x86C1, 0x86D1, 0x86E0, 0x86F0, 0x8700, 0x870F, 0x871F,
102 0x872E, 0x873E, 0x874E, 0x875D, 0x876D, 0x877D, 0x878C
109 for(i=0; i < 0x10000; i++)
110 asm volatile(
"nop\nnop\nnop\nnop\nnop");
116 U32_REGISTER_WRITE(U32_REGISTER(0x1404), 0xBF900000);
117 U32_REGISTER_WRITE(U32_REGISTER(0x140C), 0xBF900800);
118 U32_REGISTER_WRITEOR(U32_REGISTER(0x10F0), 0x80000);
119 U32_REGISTER_WRITEOR(U32_REGISTER(0x1570), 8);
120 U32_REGISTER_WRITE(U32_REGISTER(0x1014), 0x200B31E1);
121 U32_REGISTER_WRITE(U32_REGISTER(0x1414), 0x200B31E1);
125int _start(
int argc,
char *argv[])
130 printf(BANNER, VERSION);
132 if(RegisterLibraryEntries(&_exp_libsd) != 0)
return MODULE_NO_RESIDENT_END;
136 return MODULE_RESIDENT_END;
139int TransInterrupt(
void *data)
145 dir = ((intr->mode & 0x200) < 1);
146 core = intr->mode & 0xFF;
149 if((intr->mode & 0x100) == 0)
153 volatile u16 *statx = U16_REGISTER(0x344 + (core * 1024));
155 while((U16_REGISTER_READ(statx) & 0x80) == 0);
157 U16_REGISTER_WRITEAND(SD_CORE_ATTR(core), ~SD_CORE_DMA);
159 while((U16_REGISTER_READ(SD_CORE_ATTR(core)) & 0x30) != 0);
162 if(TransIntrCallbacks[core])
goto SdIntrCallback;
164 VoiceTransComplete[core] = 1;
168 if(intr->mode & (SD_TRANS_LOOP << 8))
171 BlockTransBuff[core] = 1 - BlockTransBuff[core];
173 U32_REGISTER_WRITE(SD_DMA_ADDR(core), (BlockTransSize[core] * BlockTransBuff[core])+BlockTransAddr[core]);
174 U16_REGISTER_WRITE(SD_DMA_SIZE(core), (BlockTransSize[core]/64)+((BlockTransSize[core]&63)>0));
175 U32_REGISTER_WRITE(SD_DMA_CHCR(core), SD_DMA_START | SD_DMA_CS | dir);
179 U16_REGISTER_WRITEAND(SD_CORE_ATTR(core), ~SD_CORE_DMA);
180 U16_REGISTER_WRITEAND(SD_P_MMIX(core), 0xFF3F);
181 U16_REGISTER_WRITE(U16_REGISTER(0x1B0 + (core * 1024)), 0);
184 if(TransIntrHandlers[core])
187 TransIntrHandlers[core](core, intr->data);
191 if(TransIntrCallbacks[core])
194 TransIntrCallbacks[core](0);
199 if(dir == SD_DMA_DIR_SPU2IOP) FlushDcache();
204int Spu2Interrupt(
void *data)
210 val = ((U16_REGISTER_READ(SD_C_IRQINFO))&0xc)>>2;
215 U16_REGISTER_WRITE(SD_CORE_ATTR(0), U16_REGISTER_READ(SD_CORE_ATTR(0)) & 0xffbf);
218 U16_REGISTER_WRITE(SD_CORE_ATTR(1), U16_REGISTER_READ(SD_CORE_ATTR(1)) & 0xffbf);
220 if(Spu2IntrHandler != NULL)
222 Spu2IntrHandler(val, Spu2IntrData);
226 if(Spu2IrqCallback) Spu2IrqCallback(0);
232void RegisterInterrupts()
246 VoiceTransComplete[0] = 0;
247 VoiceTransComplete[1] = 0;
257 U16_REGISTER_WRITE(SD_C_SPDIF_OUT, 0);
259 U16_REGISTER_WRITE(SD_C_SPDIF_OUT, 0x8000);
262 U32_REGISTER_WRITEOR(U32_REGISTER(0x10F0), 0xB0000);
264 for(core=0; core < 2; core++)
268 VoiceTransIoMode[core] = 0;
269 U16_REGISTER_WRITE(U16_REGISTER(0x1B0), 0);
270 U16_REGISTER_WRITE(SD_CORE_ATTR(core), 0);
272 U16_REGISTER_WRITE(SD_CORE_ATTR(core), SD_SPU2_ON);
274 U16_REGISTER_WRITE(SD_P_MVOLL(core), 0);
275 U16_REGISTER_WRITE(SD_P_MVOLR(core), 0);
277 statx = U16_REGISTER(0x344 + (core * 1024));
279 while(U16_REGISTER_READ(statx) & 0x7FF);
281 U16_REGISTER_WRITE(SD_A_KOFF_HI(core), 0xFFFF);
282 U16_REGISTER_WRITE(SD_A_KOFF_LO(core), 0xFFFF);
285 U16_REGISTER_WRITE(SD_S_PMON_HI(1), 0);
286 U16_REGISTER_WRITE(SD_S_PMON_LO(1), 0);
287 U16_REGISTER_WRITE(SD_S_NON_HI(1), 0);
288 U16_REGISTER_WRITE(SD_S_NON_LO(1), 0);
297 if(flag == 0) ResetAll();
299 VoiceTransStatus[0] = 1;
300 VoiceTransStatus[1] = 1;
301 TransIntrCallbacks[0] = NULL;
302 TransIntrCallbacks[1] = NULL;
303 TransIntrHandlers[0] = NULL;
304 TransIntrHandlers[1] = NULL;
305 TransIntrData[0].mode = 0;
306 TransIntrData[1].mode = 1;
307 TransIntrData[0].data = NULL;
308 TransIntrData[1].data = NULL;
309 VoiceTransIoMode[0] = 0;
310 VoiceTransIoMode[1] = 0;
311 Spu2IntrHandler = NULL;
312 Spu2IrqCallback = NULL;
315 RegisterInterrupts();
317 for(core = 0; core < 2; core++)
319 EffectAttr[core].core = core;
320 EffectAttr[core].mode = 0;
321 EffectAttr[core].depth_L = 0;
322 EffectAttr[core].depth_R = 0;
323 EffectAttr[core].delay = 0;
324 EffectAttr[core].feedback = 0;
329 for(core = 0; core < 2; core++)
331 EffectAddr[core] = GetEEA(core) - ((EffectSizes[0] << 4) - 2);
332 SetESA(core, EffectAddr[core]);
337sceSdSpu2IntrHandler sceSdSetSpu2IntrHandler(sceSdSpu2IntrHandler handler,
void *data)
339 sceSdSpu2IntrHandler old_handler;
341 old_handler = Spu2IntrHandler;
342 Spu2IntrHandler = handler;
348u16 VoiceDataInit[16] = { 0x707, 0x707, 0x707, 0x707, 0x707, 0x707, 0x707, 0x707,
349 0, 0, 0, 0, 0, 0, 0, 0 };
357 U16_REGISTER_WRITE(SD_A_TSA_HI(0), 0);
358 U16_REGISTER_WRITE(SD_A_TSA_LO(0), 0x5000 >> 1);
362 for(i = 0; i < 16; i++) U16_REGISTER_WRITE(SD_A_STD(0), VoiceDataInit[i]);
365 U16_REGISTER_WRITE(SD_CORE_ATTR(0), (U16_REGISTER_READ(SD_CORE_ATTR(0)) & ~SD_CORE_DMA) | SD_DMA_IO);
367 statx = U16_REGISTER(0x344);
370 while(U16_REGISTER_READ(statx) & SD_IO_IN_PROCESS);
373 U16_REGISTER_WRITEAND(SD_CORE_ATTR(0), ~SD_CORE_DMA);
376 for(voice = 0; voice < 24; voice++)
378 U16_REGISTER_WRITE(SD_VP_VOLL(0, voice), 0);
379 U16_REGISTER_WRITE(SD_VP_VOLR(0, voice), 0);
380 U16_REGISTER_WRITE(SD_VP_PITCH(0, voice), 0x3FFF);
381 U16_REGISTER_WRITE(SD_VP_ADSR1(0, voice), 0);
382 U16_REGISTER_WRITE(SD_VP_ADSR2(0, voice), 0);
384 U16_REGISTER_WRITE(SD_VP_VOLL(1, voice), 0);
385 U16_REGISTER_WRITE(SD_VP_VOLR(1, voice), 0);
386 U16_REGISTER_WRITE(SD_VP_PITCH(1, voice), 0x3FFF);
387 U16_REGISTER_WRITE(SD_VP_ADSR1(1, voice), 0);
388 U16_REGISTER_WRITE(SD_VP_ADSR2(1, voice), 0);
391 U16_REGISTER_WRITE(SD_VA_SSA_HI(0, voice), 0);
392 U16_REGISTER_WRITE(SD_VA_SSA_LO(0, voice), 0x5000 >> 1);
393 U16_REGISTER_WRITE(SD_VA_SSA_HI(1, voice), 0);
394 U16_REGISTER_WRITE(SD_VA_SSA_LO(1, voice), 0x5000 >> 1);
398 U16_REGISTER_WRITE(SD_A_KON_HI(0), 0xFFFF);
399 U16_REGISTER_WRITE(SD_A_KON_LO(0), 0xFF);
400 U16_REGISTER_WRITE(SD_A_KON_HI(1), 0xFFFF);
401 U16_REGISTER_WRITE(SD_A_KON_LO(1), 0xFF);
408 U16_REGISTER_WRITE(SD_A_KOFF_HI(0), 0xFFFF);
409 U16_REGISTER_WRITE(SD_A_KOFF_LO(0), 0xFF);
410 U16_REGISTER_WRITE(SD_A_KOFF_HI(1), 0xFFFF);
411 U16_REGISTER_WRITE(SD_A_KOFF_LO(1), 0xFF);
417 U16_REGISTER_WRITE(SD_S_ENDX_HI(0), 0);
418 U16_REGISTER_WRITE(SD_S_ENDX_LO(0), 0);
422void InitCoreVolume(s32 flag)
424 U16_REGISTER_WRITE(SD_C_SPDIF_OUT, 0xC032);
428 U16_REGISTER_WRITE(SD_CORE_ATTR(0), SD_SPU2_ON | SD_ENABLE_EFFECTS | SD_MUTE);
429 U16_REGISTER_WRITE(SD_CORE_ATTR(1), SD_SPU2_ON | SD_ENABLE_EFFECTS | SD_MUTE | SD_ENABLE_EX_INPUT);
433 U16_REGISTER_WRITE(SD_CORE_ATTR(0), SD_SPU2_ON | SD_MUTE);
434 U16_REGISTER_WRITE(SD_CORE_ATTR(1), SD_SPU2_ON | SD_MUTE | SD_ENABLE_EX_INPUT);
438 U16_REGISTER_WRITE(SD_S_VMIXL_HI(0), 0xFFFF);
439 U16_REGISTER_WRITE(SD_S_VMIXL_LO(0), 0xFF);
440 U16_REGISTER_WRITE(SD_S_VMIXR_HI(0), 0xFFFF);
441 U16_REGISTER_WRITE(SD_S_VMIXR_LO(0), 0xFF);
442 U16_REGISTER_WRITE(SD_S_VMIXEL_HI(0), 0xFFFF);
443 U16_REGISTER_WRITE(SD_S_VMIXEL_LO(0), 0xFF);
444 U16_REGISTER_WRITE(SD_S_VMIXER_HI(0), 0xFFFF);
445 U16_REGISTER_WRITE(SD_S_VMIXER_LO(0), 0xFF);
447 U16_REGISTER_WRITE(SD_S_VMIXL_HI(1), 0xFFFF);
448 U16_REGISTER_WRITE(SD_S_VMIXL_LO(1), 0xFF);
449 U16_REGISTER_WRITE(SD_S_VMIXR_HI(1), 0xFFFF);
450 U16_REGISTER_WRITE(SD_S_VMIXR_LO(1), 0xFF);
451 U16_REGISTER_WRITE(SD_S_VMIXEL_HI(1), 0xFFFF);
452 U16_REGISTER_WRITE(SD_S_VMIXEL_LO(1), 0xFF);
453 U16_REGISTER_WRITE(SD_S_VMIXER_HI(1), 0xFFFF);
454 U16_REGISTER_WRITE(SD_S_VMIXER_LO(1), 0xFF);
456 U16_REGISTER_WRITE(SD_P_MMIX(0), 0xFF0);
457 U16_REGISTER_WRITE(SD_P_MMIX(1), 0xFFC);
461 U16_REGISTER_WRITE(SD_P_MVOLL(0), 0);
462 U16_REGISTER_WRITE(SD_P_MVOLR(0), 0);
463 U16_REGISTER_WRITE(SD_P_MVOLL(1), 0);
464 U16_REGISTER_WRITE(SD_P_MVOLR(1), 0);
466 U16_REGISTER_WRITE(SD_P_EVOLL(0), 0);
467 U16_REGISTER_WRITE(SD_P_EVOLL(1), 0);
469 U16_REGISTER_WRITE(SD_P_EVOLR(0), 0);
470 U16_REGISTER_WRITE(SD_P_EVOLR(1), 0);
473 U16_REGISTER_WRITE(SD_A_EEA_HI(0), 0xE);
474 U16_REGISTER_WRITE(SD_A_EEA_HI(1), 0xF);
477 U16_REGISTER_WRITE(SD_P_AVOLL(0), 0);
478 U16_REGISTER_WRITE(SD_P_AVOLR(0), 0);
481 U16_REGISTER_WRITE(SD_P_AVOLL(1), 0x7FFF);
482 U16_REGISTER_WRITE(SD_P_AVOLR(1), 0x7FFF);
484 U16_REGISTER_WRITE(SD_P_BVOLL(0), 0);
485 U16_REGISTER_WRITE(SD_P_BVOLR(0), 0);
486 U16_REGISTER_WRITE(SD_P_BVOLL(1), 0);
487 U16_REGISTER_WRITE(SD_P_BVOLR(1), 0);
492 U16_REGISTER_WRITE(SD_C_SPDIF_MODE, 0x900);
493 U16_REGISTER_WRITE(SD_C_SPDIF_MEDIA, 0x200);
494 U16_REGISTER_WRITE(U16_REGISTER(0x7CA), 8);
497int sceSdInit(
int flag)
507 InitCoreVolume(flag);
516void sceSdSetParam(u16 reg, u16 val)
528 offs = (40 * core) >> 1;
530 offs = (1024 * core) >> 1;
532 reg_index = (reg >> 8) & 0xFF;
533 voice = (reg & 0x3E) << 2;
534 reg_p = ParamRegList[reg_index] + offs + voice;
536 U16_REGISTER_WRITE(reg_p, val);
539u16 sceSdGetParam(u16 reg)
551 offs = (40 * core) >> 1;
553 offs = (1024 * core) >> 1;
555 reg_index = (reg >> 8) & 0xFF;
556 voice = (reg & 0x3E) << 2;
557 reg_p = ParamRegList[reg_index] + offs + voice;
559 return U16_REGISTER_READ(reg_p);
562void sceSdSetSwitch(u16 reg, u32 val)
567 reg_index = (reg >> 8) & 0xFF;
568 reg_p = ParamRegList[reg_index] + ((reg & 1) << 9);
570 U16_REGISTER_WRITE(reg_p + 0, (u16)val);
571 U16_REGISTER_WRITE(reg_p + 1, (u16)((val >> 16) & 0xFF));
574u32 sceSdGetSwitch(u16 reg)
580 reg_index = (reg >> 8) & 0xFF;
581 reg_p = ParamRegList[reg_index] + ((reg & 1) << 9);
583 ret = U16_REGISTER_READ(reg_p + 0);
584 ret |= U16_REGISTER_READ(reg_p + 1) << 16;
596 if(U16_REGISTER_READ(U16_REGISTER(0x1B0 + (core * 1024))) == 0)
599 retval = U32_REGISTER_READ(SD_DMA_ADDR(core));
601 U32_REGISTER_WRITEAND(SD_DMA_CHCR(core), ~SD_DMA_START);
602 U16_REGISTER_WRITE(U16_REGISTER(0x1B0 + (core * 1024)), 0);
604 retval = (BlockTransBuff[core] << 24) | (retval & 0xFFFFFF);
609void SetDmaWrite(s32 chan)
611 volatile u32 *reg = U32_REGISTER(0x1014 + (chan << 10));
612 U32_REGISTER_WRITEOR(reg, (U32_REGISTER_READ(reg) & 0xF0FFFFFF) | 0x20000000);
615void SetDmaRead(s32 chan)
617 volatile u32 *reg = U32_REGISTER(0x1014 + (chan << 10));
618 U32_REGISTER_WRITEOR(reg, (U32_REGISTER_READ(reg) & 0xF0FFFFFF) | 0x22000000);
621u16 sceSdNote2Pitch (u16 center_note, u16 center_fine, u16 note,
short fine)
626 s32 offset1, offset2;
632 _fine = fine + (u16)center_fine;
635 if(_fine < 0) _fine2 = _fine + 127;
637 _fine2 = _fine2 / 128;
638 _note = note + _fine2 - center_note;
641 if(_note < 0) val3--;
643 offset2 = _fine - _fine2 * 128;
645 if(_note < 0) val2 = -1;
else val2 = 0;
648 val2 = (val3 / 2) - val2;
650 offset1 = _note - (val2 * 12);
652 if((offset1 < 0) || ((offset1 == 0) && (offset2 < 0)))
654 offset1 = offset1 + 12;
660 offset1 = (offset1-1) + _fine2;
661 offset2 += (_fine2+1) * 128;
664 ret = (NotePitchTable[offset1] * NotePitchTable[offset2 + 12]) / 0x10000;
666 if(val < 0) ret = (ret + (1 << (-val -1))) >> -val;
671u16 sceSdPitch2Note(u16 center_note, u16 center_fine, u16 pitch)
681 if(((u16)pitch) >= 0x4000) pitch = 0x3FFF;
687 if((_pitch & 1) == 1) bit = i;
693 val = (u16)pitch << (15 - bit);
698 if((u16)val >= NotePitchTable[i])
707 val = ((u16)val * 0x8000) / NotePitchTable[(u16)offset1];
712 if((u16)val >= NotePitchTable[12 + i])
722 val = (u16)(center_fine + offset2 +1);
723 ret = (center_note + offset1 + ((bit - 12) * 12) + (val/128)) * 256;
724 ret = (ret + (val & 0x7E)) & 0xFFFE;
730void SetSpdifMode(u16 val)
734 out = U16_REGISTER_READ(SD_C_SPDIF_OUT);
735 mode = U16_REGISTER_READ(SD_C_SPDIF_MODE);
741 out = (val & 0xFEF7) | 0x20;
745 out = (out & 0xFFD7) | 0x100;
751 out = (out & 0xFEDF) | 8;
764 U16_REGISTER_WRITE(SD_C_SPDIF_MEDIA, 0x200);
768 U16_REGISTER_WRITE(SD_C_SPDIF_MEDIA, 0);
772 U16_REGISTER_WRITE(SD_C_SPDIF_MEDIA, 0x200);
773 mode = (mode & 0xE7FF) | 0x800;
777 U16_REGISTER_WRITE(SD_C_SPDIF_OUT, out);
778 U16_REGISTER_WRITE(SD_C_SPDIF_MODE, mode);
784u8 CoreAttrShifts[4] = {7, 6, 14, 8};
786void sceSdSetCoreAttr(u16 entry, u16 val)
788 u16 core_attr = U16_REGISTER_READ(SD_CORE_ATTR(entry & 1));
792 case SD_CORE_NOISE_CLK:
793 U16_REGISTER_WRITE(SD_CORE_ATTR(entry & 1), (core_attr-0x3F01) | ((val & 0x3F) << 8));
795 case SD_CORE_SPDIF_MODE:
800 u32 core = entry & 1;
801 entry = (entry >> 1)-1;
802 core_attr &= ~(1 << CoreAttrShifts[entry]);
803 core_attr |= (val & 1) << CoreAttrShifts[entry];
804 U16_REGISTER_WRITE(SD_CORE_ATTR(core), core_attr);
810u16 sceSdGetCoreAttr(u16 entry)
814 case SD_CORE_NOISE_CLK:
815 return (U16_REGISTER_READ(SD_CORE_ATTR(entry & 1)) >> 8) & 0x3F;
816 case SD_CORE_SPDIF_MODE:
817 return SpdifSettings;
820 u32 core = entry & 1;
821 entry = (entry >> 1)-1;
822 return (U16_REGISTER_READ(SD_CORE_ATTR(core)) >> CoreAttrShifts[entry]) & 1;
828sceSdTransIntrHandler sceSdSetTransIntrHandler(
int chan, sceSdTransIntrHandler func,
void *data)
830 sceSdTransIntrHandler old_handler;
832 old_handler = TransIntrHandlers[chan & 1];
833 TransIntrHandlers[chan & 1] = func;
834 TransIntrData[chan & 1].data = data;
858void sceSdSetAddr(u16 reg, u32 val)
863 reg1 = ParamRegList[(reg >> 8) & 0xFF] + ((reg & 1) << 9);
866 reg1 += ((voice << 1) + voice);
868 U16_REGISTER_WRITE(reg1++, (val >> 17) & 0xFFFF);
870 if((reg & 0xFF00) != 0x1D00)
872 U16_REGISTER_WRITE(reg1, (val >> 1) & 0xFFF8);
876u32 sceSdGetAddr(u16 reg)
883 reg1 = ParamRegList[(reg >> 8) & 0xFF] + ((reg & 1) << 9);
885 reg1 += ((voice << 1) + voice);
886 rethi = U16_REGISTER_READ(reg1) << 17;
893 retlo = U16_REGISTER_READ(reg1 + 1) << 1;
895 if((reg == 0x2100) || (reg == 0x2200))
899 hi = U16_REGISTER_READ(reg1) << 17;
900 lo = U16_REGISTER_READ(reg1 + 1) << 1;
902 if((rethi == hi) || (retlo != lo))
910 return rethi | retlo;
913SdIntrCallback sceSdSetTransCallback(s32 core, SdIntrCallback cb)
915 SdIntrCallback old_cb;
917 old_cb = TransIntrCallbacks[core & 1];
918 TransIntrCallbacks[core & 1] = cb;
923SdIntrCallback sceSdSetIRQCallback(SdIntrCallback cb)
925 SdIntrCallback old_cb;
927 old_cb = Spu2IrqCallback;
928 Spu2IrqCallback = cb;
int RegisterIntrHandler(int irq, int mode, int(*handler)(void *), void *arg)
int ReleaseIntrHandler(int irq)
int DisableIntr(int irq, int *res)