11#include "irx_imports.h"
17IRX_ID(
"cdvd_st_driver", 2, 2);
22int cdvdstm_dummyentry();
23int cdvdstm_termcall();
24static unsigned int iop_stream_handler(
25 unsigned int posszarg1,
unsigned int posszarg2,
void *buffer,
int cmdid,
const sceCdRMode *rmode,
int *error_ptr);
26static unsigned int iop_stream_intr_cb(
void *userdata);
27static int cdrom_stm_init();
28static int cdrom_stm_deinit();
29static int cdrom_stm_devctl(
30 iop_file_t *f,
const char *name,
int cmd,
void *inbuf,
unsigned int inbuf_len,
void *outbuf,
unsigned int outbuf_len);
31static int cdrom_stm_nulldev();
32static s64 cdrom_stm_nulldev64();
33static void ee_stream_handler_normal(
cdrom_stm_devctl_t *instruct,
int inbuf_len,
int *outres_ptr);
34static unsigned int ee_stream_intr_cb_normal(
void *userdata);
35static void ee_stream_handler_cdda(
cdrom_stm_devctl_t *instruct,
int inbuf_len,
int *outres_ptr);
36static unsigned int ee_stream_intr_cb_cdda(
void *userdata);
37unsigned int optimized_memcpy(
char *dst,
const char *src,
unsigned int n);
39static void iop_stream_intr_cb_thunk(
int userdata)
41 iop_stream_intr_cb((
void *)userdata);
44static void ee_stream_intr_cb_normal_thunk(
int userdata)
46 ee_stream_intr_cb_normal((
void *)userdata);
49static void ee_stream_intr_cb_cdda_thunk(
int userdata)
51 ee_stream_intr_cb_cdda((
void *)userdata);
54static int g_verbose_level = 0;
55static int g_cdvdstm_in_deldrv = 0;
56static int g_cdvdstm_bufmax = 0;
57static int g_cdvdstm_numbytes = 0;
58static int g_cdvdstm_bankmax = 0;
59static void *g_cdvdstm_buffer = NULL;
60static unsigned int g_cdvdstm_sectorcount = 0;
61static int g_cdvdstm_last_error_for_iop = 0;
62static int g_cdvdstm_retryerr_iop = 0;
63static int g_cdvdstm_retrycnt_iop = 0;
67 (
void *)&cdrom_stm_nulldev,
68 (
void *)&cdrom_stm_nulldev,
69 (
void *)&cdrom_stm_nulldev,
70 (
void *)&cdrom_stm_nulldev,
71 (
void *)&cdrom_stm_nulldev,
72 (
void *)&cdrom_stm_nulldev,
74 (
void *)&cdrom_stm_nulldev,
75 (
void *)&cdrom_stm_nulldev,
76 (
void *)&cdrom_stm_nulldev,
77 (
void *)&cdrom_stm_nulldev,
78 (
void *)&cdrom_stm_nulldev,
79 (
void *)&cdrom_stm_nulldev,
80 (
void *)&cdrom_stm_nulldev,
81 (
void *)&cdrom_stm_nulldev,
82 (
void *)&cdrom_stm_nulldev,
83 (
void *)&cdrom_stm_nulldev,
84 (
void *)&cdrom_stm_nulldev,
85 (
void *)&cdrom_stm_nulldev,
86 (
void *)&cdrom_stm_nulldev,
87 (
void *)&cdrom_stm_nulldev64,
89 (
void *)&cdrom_stm_nulldev,
90 (
void *)&cdrom_stm_nulldev,
93static iop_device_t g_cdrom_stm_dev = {
"cdrom_stm",
IOP_DT_FSEXT | IOP_DT_FS, 1,
"CD-ROM_STM ", &g_cdrom_stm_dev_ops};
94static int g_cdvdstm_last_error_for_ee = 0;
95static int g_cdvdstm_bufsz2 = 0;
96static int g_cdvdstm_chunksz2 = 0;
97static int g_cdvdstm_bankcnt2 = 0;
98static void *g_cdvdstm_buffer2 = NULL;
99static u32 g_cdvdstm_sectorcount2 = 0;
100static int g_cdvdstm_retryerr_ee = 0;
101static int g_cdvdstm_retrycnt_ee_normal = 0;
102static int g_cdvdstm_usedchunksize2 = 0x930;
103static u32 g_cdvdstm_retrycnt_ee_cdda = 0;
105static int g_cdvdstm_tgt;
106static int g_cdvdstm_semid;
107static int g_cdvdman_intr_efid;
108static char g_cdvdstm_usedmap_iop[512];
109static unsigned int g_cdvdstm_lsn_iop;
110static int g_cdvdstm_bankgp_iop;
111static int g_cdvdstm_bankcur_iop;
112static int g_cdvdstm_bankoffs_iop;
114static int g_cdvdstm_stmstart_iop;
117static int g_cdvdstm_readlbn_ee_normal;
119static u32 g_cdvdstm_readlbn_ee_cdda;
120static char g_cdvdstm_usedmap_ee[512];
121static u32 g_cdvdstm_lsn_ee;
122static int g_cdvdstm_bankgp_ee;
123static int g_cdvdstm_bankcur_ee;
124static int g_cdvdstm_bankoffs_ee;
126static int g_cdvdstm_stmstart_ee;
129static int vCancelAlarm(
unsigned int (*alarm_cb)(
void *),
void *arg)
134static int vSetEventFlag()
136 return (
QueryIntrContext() ? iSetEventFlag : SetEventFlag)(g_cdvdman_intr_efid, 8);
139static int vClearEventFlag()
141 return (
QueryIntrContext() ? iClearEventFlag : ClearEventFlag)(g_cdvdman_intr_efid, ~8);
144int cdvdstm_dummyentry()
146 VERBOSE_PRINTF(1,
"Dummy Entry Called\n");
150int cdvdstm_termcall()
155 memset(&instruct, 0,
sizeof(instruct));
156 instruct.m_cmdid = 3;
160 ee_stream_handler_normal(&instruct, 0x14, &outres);
165static int stm_iop_read_timeout_alarm_cb(
const iop_sys_clock_t *sys_clock)
167 KPRINTF(
"Stm Iop Read Time Out %d(msec)\n", sys_clock->lo / 0x9000);
171static int sceCdStream0_inner(
unsigned int rdsize,
char *addrarg,
int modearg,
int *error_ptr)
174 unsigned int streamres;
179 VERBOSE_KPRINTF(1,
"sceCdStream0 call read size= %d mode= %d addr= %08x\n", rdsize, modearg, addrarg);
181 if ( !sceCdSC(0xFFFFFFFF, &last_error) )
185 return iop_stream_handler(0, rdsize, addrarg, 2, &g_rmode_for_stream0, error_ptr);
189 while ( (!err || streamres) )
191 WaitEventFlag(g_cdvdman_intr_efid, 8, WEF_AND, &efbits);
192 streamres = iop_stream_handler(0, rdsize - cur_size, &addrarg[cur_size], 2, &g_rmode_for_stream0, &err);
193 if ( rdsize - cur_size != streamres )
195 cur_size += streamres;
198 VERBOSE_KPRINTF(1,
"sceCdStream0 BLK cur_size= %d req_size= %d err 0x%x\n", cur_size, rdsize, err);
199 if ( (
unsigned int)cur_size == rdsize )
205static int sceCdStream0(
int rdsize_sectors,
char *addrarg,
int modearg,
int *error_ptr)
207 return sceCdStream0_inner(rdsize_sectors << 11, addrarg, modearg, error_ptr) / 0x800;
210static unsigned int iop_stream_handler(
211 unsigned int posszarg1,
unsigned int posszarg2,
void *buffer,
int cmdid,
const sceCdRMode *rmode,
int *error_ptr)
216 unsigned int written_chunk_size_tmp;
217 int bankcur_next_tmp1;
219 int bankcur_next_tmp2;
223 VERBOSE_KPRINTF(1,
"CD Stream Call mode= %d\n", cmdid);
225 if ( g_cdvdstm_stmstart_iop == 2 && cmdid != 9 && cmdid != 3 )
232 sceCdSC(1, &g_cdvdstm_last_error_for_iop);
235 sceCdSC(0, &g_cdvdstm_last_error_for_iop);
239 vCancelAlarm((
unsigned int (*)(
void *))iop_stream_intr_cb, &g_cdvdstm_curclk_iop);
240 sceCdSC(0, &g_cdvdstm_last_error_for_iop);
243 vCancelAlarm((
unsigned int (*)(
void *))stm_iop_read_timeout_alarm_cb, &g_cdvdstm_curclk_iop);
246 bankcur_tmp = g_cdvdstm_bankcur_iop;
247 if ( !g_cdvdstm_usedmap_iop[bankcur_tmp] )
250 if ( (
unsigned int)bankcur_tmp >= (
unsigned int)g_cdvdstm_bankmax )
252 if ( !g_cdvdstm_usedmap_iop[bankcur_tmp] )
253 bankcur_tmp = g_cdvdstm_bankcur_iop;
255 for ( i = 0; (i < (
unsigned int)g_cdvdstm_bankmax) && g_cdvdstm_usedmap_iop[bankcur_tmp]
256 && (g_cdvdstm_bankgp_iop != bankcur_tmp);
260 if ( (
unsigned int)bankcur_tmp >= (
unsigned int)g_cdvdstm_bankmax )
263 return i * ((
unsigned int)g_cdvdstm_numbytes >> 11);
265 sceCdstm0Cb((
void (*)(
int))iop_stream_intr_cb_thunk);
266 g_cdvdstm_bufmax = posszarg1;
267 g_cdvdstm_sectorcount = posszarg1 / posszarg2;
268 g_cdvdstm_numbytes = g_cdvdstm_sectorcount << 11;
269 g_cdvdstm_buffer = buffer;
270 g_cdvdstm_bankmax = posszarg2;
272 "Stream Buffer 1Bank %dbyte %dbanks addr:%08x %dbyte used.\n",
276 g_cdvdstm_numbytes * posszarg2);
280 g_cdvdstm_stmstart_iop = 0;
281 vCancelAlarm((
unsigned int (*)(
void *))iop_stream_intr_cb, &g_cdvdstm_curclk_iop);
282 sceCdSC(0, &g_cdvdstm_last_error_for_iop);
285 for ( i = 0; i < (
unsigned int)g_cdvdstm_bankmax; i += 1 )
286 g_cdvdstm_usedmap_iop[i] = 0;
287 g_cdvdstm_bankoffs_iop = 0;
288 g_cdvdstm_bankcur_iop = 0;
289 g_cdvdstm_bankgp_iop = 0;
291 g_cdvdstm_last_error_for_iop = 0;
292 sceCdSC(0xFFFFFFFE, &g_cdvdstm_last_error_for_iop);
293 vCancelAlarm((
unsigned int (*)(
void *))stm_iop_read_timeout_alarm_cb, &g_cdvdstm_curclk_iop);
296 if ( sceCdSC(0xFFFFFFFF, &g_cdvdstm_last_error_for_iop) )
299 g_cdvdstm_lsn_iop = posszarg1;
300 for ( i = 0; i < (
unsigned int)g_cdvdstm_bankmax; i += 1 )
301 g_cdvdstm_usedmap_iop[i] = 0;
302 g_cdvdstm_stmstart_iop = 2;
311 g_cdvdstm_retryerr_iop = 0;
315 vCancelAlarm((
unsigned int (*)(
void *))iop_stream_intr_cb, &g_cdvdstm_curclk_iop);
316 sceCdSC(0, &g_cdvdstm_last_error_for_iop);
321 g_cdvdstm_lsn_iop = posszarg1;
322 g_cdvdstm_bankoffs_iop = 0;
323 g_cdvdstm_bankcur_iop = 0;
324 g_cdvdstm_bankgp_iop = 0;
326 vCancelAlarm((
unsigned int (*)(
void *))stm_iop_read_timeout_alarm_cb, &g_cdvdstm_curclk_iop);
333 vCancelAlarm((
unsigned int (*)(
void *))iop_stream_intr_cb, &g_cdvdstm_curclk_iop);
334 sceCdSC(0, &g_cdvdstm_last_error_for_iop);
336 for ( i = 0; i < (
unsigned int)g_cdvdstm_bankmax; i += 1 )
337 g_cdvdstm_usedmap_iop[i] = 0;
338 g_cdvdstm_lsn_iop = posszarg1;
339 sceCdSC(0xFFFFFFE9, (
int *)&g_cdvdstm_lsn_iop);
340 g_cdvdstm_bankoffs_iop = 0;
341 g_cdvdstm_bankcur_iop = 0;
342 g_cdvdstm_bankgp_iop = 0;
344 vCancelAlarm((
unsigned int (*)(
void *))stm_iop_read_timeout_alarm_cb, &g_cdvdstm_curclk_iop);
345 g_cdvdstm_stmstart_iop = 1;
346 sceCdSC(1, &g_cdvdstm_last_error_for_iop);
349 sceCdSC(0, &g_cdvdstm_last_error_for_iop);
354 written_chunk_size_tmp = -1;
355 for ( i = 0; i < posszarg2; i += chunk_size )
357 if ( !g_cdvdstm_usedmap_iop[g_cdvdstm_bankcur_iop] )
361 "CD read buffer over run %d %d %d %d %d gp %d pp %d\n",
362 (u8)g_cdvdstm_usedmap_iop[0],
363 (u8)g_cdvdstm_usedmap_iop[1],
364 (u8)g_cdvdstm_usedmap_iop[2],
365 (u8)g_cdvdstm_usedmap_iop[3],
366 (u8)g_cdvdstm_usedmap_iop[4],
367 g_cdvdstm_bankgp_iop,
368 g_cdvdstm_bankcur_iop);
369 bankcur_next_tmp1 = g_cdvdstm_bankcur_iop;
370 g_cdvdstm_bankcur_iop += 1;
371 if ( (
unsigned int)g_cdvdstm_bankcur_iop >= (
unsigned int)g_cdvdstm_bankmax )
372 g_cdvdstm_bankcur_iop = 0;
373 written_chunk_size_tmp = i;
374 if ( !g_cdvdstm_usedmap_iop[g_cdvdstm_bankcur_iop] )
376 g_cdvdstm_bankcur_iop = bankcur_next_tmp1;
380 if ( (
unsigned int)g_cdvdstm_bankoffs_iop >= (
unsigned int)g_cdvdstm_numbytes )
382 g_cdvdstm_bankoffs_iop = 0;
383 g_cdvdstm_usedmap_iop[g_cdvdstm_bankcur_iop] = 0;
384 bankcur_next_tmp2 = g_cdvdstm_bankcur_iop;
385 g_cdvdstm_bankcur_iop += 1;
386 if ( (
unsigned int)g_cdvdstm_bankcur_iop >= (
unsigned int)g_cdvdstm_bankmax )
387 g_cdvdstm_bankcur_iop = 0;
388 if ( !g_cdvdstm_usedmap_iop[g_cdvdstm_bankcur_iop] || g_cdvdstm_bankgp_iop == g_cdvdstm_bankcur_iop )
390 g_cdvdstm_bankcur_iop = bankcur_next_tmp2;
391 written_chunk_size_tmp = i;
394 "CD read buffer over run %d %d %d %d %d gp %d pp %d\n",
395 (u8)g_cdvdstm_usedmap_iop[0],
396 (u8)g_cdvdstm_usedmap_iop[1],
397 (u8)g_cdvdstm_usedmap_iop[2],
398 (u8)g_cdvdstm_usedmap_iop[3],
399 (u8)g_cdvdstm_usedmap_iop[4],
400 g_cdvdstm_bankgp_iop,
401 g_cdvdstm_bankcur_iop);
406 &((
char *)buffer)[i],
407 &((
char *)g_cdvdstm_buffer)[g_cdvdstm_bankcur_iop * g_cdvdstm_numbytes + g_cdvdstm_bankoffs_iop],
409 chunk_size = ((
unsigned int)0x800 > posszarg2 - i) ? (posszarg2 - i) : 0x800;
410 g_cdvdstm_bankoffs_iop += chunk_size;
412 if ( written_chunk_size_tmp == 0xFFFFFFFF )
413 written_chunk_size_tmp = posszarg2;
417 if ( sceCdSC(0xFFFFFFFF, &g_cdvdstm_last_error_for_iop) != 1 && !written_chunk_size_tmp && !g_cdvdstm_retryerr_iop )
419 g_cdvdstm_retryerr_iop = 273;
421 *error_ptr = g_cdvdstm_retryerr_iop;
422 g_cdvdstm_retryerr_iop = 0;
423 return written_chunk_size_tmp;
428static unsigned int iop_stream_intr_cb(
void *userdata)
435 VERBOSE_KPRINTF(1,
"Intr Read call\n");
436 iCancelAlarm((
unsigned int (*)(
void *))stm_iop_read_timeout_alarm_cb, &g_cdvdstm_curclk_iop);
437 iCancelAlarm((
unsigned int (*)(
void *))iop_stream_intr_cb, &g_cdvdstm_curclk_iop);
438 sceCdSC(0xFFFFFFFF, &last_error);
454 g_cdvdstm_curclk_iop.hi = 0;
455 if ( g_cdvdstm_stmstart_iop )
456 g_cdvdstm_retrycnt_iop = 0;
457 if ( g_cdvdstm_stmstart_iop || last_error || g_cdvdstm_retrycnt_iop )
460 1,
"Stm Rtry stmstart:%d err:%02x retry:%d\n", g_cdvdstm_stmstart_iop, last_error, g_cdvdstm_retrycnt_iop);
462 g_cdvdstm_curclk_iop.lo = (g_cdvdstm_stmstart_iop || last_error || g_cdvdstm_retrycnt_iop) ?
464 (0x9000 * sceCdSC(0xFFFFFFEF, &scres_unused));
467 VERBOSE_KPRINTF(1,
"IOP Stream read Error code= 0x%02x retry= %d\n", last_error, g_cdvdstm_retrycnt_iop);
470 VERBOSE_KPRINTF(1,
"On err %08x\n", last_error);
471 if ( g_cdvdstm_retrycnt_iop )
472 g_cdvdstm_retryerr_iop = last_error;
473 g_cdvdstm_retrycnt_iop = 3;
477 g_cdvdstm_retryerr_iop = last_error;
478 g_cdvdstm_retrycnt_iop = 1;
481 if ( g_cdvdstm_retrycnt_iop )
485 g_cdvdstm_retrycnt_iop -= 1;
486 tgttmp = ((
unsigned int)g_cdvdstm_tgt >= (
unsigned int)(0x10 * g_cdvdstm_retrycnt_iop)) ?
487 (g_cdvdstm_tgt - 0x10 * g_cdvdstm_retrycnt_iop) :
488 (g_cdvdstm_tgt + 0x10 * g_cdvdstm_retrycnt_iop);
489 VERBOSE_KPRINTF(1,
"Stm Rtry Start Tgt=%d Cur= %d\n", g_cdvdstm_tgt, tgttmp);
492 g_cdvdstm_sectorcount,
493 (
char *)g_cdvdstm_buffer + g_cdvdstm_bankgp_iop * g_cdvdstm_numbytes,
494 &g_cdvdstm_mode_iop) )
496 iSetAlarm(&g_cdvdstm_curclk_iop, (
unsigned int (*)(
void *))stm_iop_read_timeout_alarm_cb, &g_cdvdstm_curclk_iop);
500 g_cdvdstm_curclk_iop.lo = 0x708000;
502 iSetAlarm(&g_cdvdstm_curclk_iop, (
unsigned int (*)(
void *))iop_stream_intr_cb, &g_cdvdstm_curclk_iop)
505 sceCdSC(0, &last_error);
507 g_cdvdstm_retrycnt_iop += 1;
515 if ( !g_cdvdstm_stmstart_iop )
517 g_cdvdstm_usedmap_iop[g_cdvdstm_bankgp_iop] = 1;
518 gptmp = g_cdvdstm_bankgp_iop;
519 g_cdvdstm_bankgp_iop += 1;
520 if ( (
unsigned int)g_cdvdstm_bankgp_iop >= (
unsigned int)g_cdvdstm_bankmax )
521 g_cdvdstm_bankgp_iop = 0;
524 !g_cdvdstm_stmstart_iop
525 && (g_cdvdstm_usedmap_iop[g_cdvdstm_bankgp_iop] || g_cdvdstm_bankcur_iop == g_cdvdstm_bankgp_iop) )
527 g_cdvdstm_bankgp_iop = gptmp;
528 g_cdvdstm_usedmap_iop[gptmp] = 0;
531 "read Full %d %d %d %d %d gp %d pp %d spn %d\n",
532 (u8)g_cdvdstm_usedmap_iop[0],
533 (u8)g_cdvdstm_usedmap_iop[1],
534 (u8)g_cdvdstm_usedmap_iop[2],
535 (u8)g_cdvdstm_usedmap_iop[3],
536 (u8)g_cdvdstm_usedmap_iop[4],
537 g_cdvdstm_bankgp_iop,
538 g_cdvdstm_bankcur_iop,
540 g_cdvdstm_curclk_iop.lo = 0x48000;
542 iSetAlarm(&g_cdvdstm_curclk_iop, (
unsigned int (*)(
void *))iop_stream_intr_cb, &g_cdvdstm_curclk_iop)
545 sceCdSC(0, &last_error);
550 if ( g_cdvdstm_stmstart_iop == 2 )
554 g_cdvdstm_bankoffs_iop = 0;
555 g_cdvdstm_bankcur_iop = 0;
556 g_cdvdstm_bankgp_iop = 0;
557 for ( i = 0; i < (
unsigned int)g_cdvdstm_bankmax; i += 1 )
558 g_cdvdstm_usedmap_iop[i] = 0;
560 g_cdvdstm_stmstart_iop = 0;
561 g_cdvdstm_tgt = g_cdvdstm_lsn_iop;
564 g_cdvdstm_sectorcount,
565 (
char *)g_cdvdstm_buffer + g_cdvdstm_bankgp_iop * g_cdvdstm_numbytes,
566 &g_cdvdstm_mode_iop) )
569 &g_cdvdstm_curclk_iop, (
unsigned int (*)(
void *))stm_iop_read_timeout_alarm_cb, &g_cdvdstm_curclk_iop);
573 g_cdvdstm_curclk_iop.lo = 0x708000;
575 iSetAlarm(&g_cdvdstm_curclk_iop, (
unsigned int (*)(
void *))iop_stream_intr_cb, &g_cdvdstm_curclk_iop)
578 sceCdSC(0, &last_error);
580 g_cdvdstm_retrycnt_iop = 1;
582 g_cdvdstm_lsn_iop += g_cdvdstm_sectorcount;
588static int cdrom_stm_init()
592 semaparam.attr = SA_THPRI;
593 semaparam.initial = 1;
595 semaparam.option = 0;
596 g_cdvdstm_semid = CreateSema(&semaparam);
600static int cdrom_stm_deinit()
602 SignalSema(g_cdvdstm_semid);
603 DeleteSema(g_cdvdstm_semid);
607static int cdrom_stm_devctl(
608 iop_file_t *f,
const char *name,
int cmd,
void *inbuf,
unsigned int inbuf_len,
void *outbuf,
unsigned int outbuf_len)
620 WaitSema(g_cdvdstm_semid);
622 if ( g_cdvdstm_in_deldrv )
624 SignalSema(g_cdvdstm_semid);
630 if ( instruct->m_cmdid == 5 || instruct->m_cmdid == 3 || instruct->m_cmdid - 7 < 2 )
634 *outres_ptr = iop_stream_handler(
635 instruct->m_posszarg1,
636 instruct->m_posszarg2,
640 (
int *)&instruct->m_error);
644 sceCdStream0(instruct->m_posszarg2, (
char *)instruct->m_buffer, instruct->m_cmdid, (
int *)&instruct->m_error);
647 ee_stream_handler_normal(instruct, inbuf_len, outres_ptr);
650 ee_stream_handler_cdda(instruct, inbuf_len, outres_ptr);
653 PRINTF(
"Un-support devctl %08x\n", cmd);
657 SignalSema(g_cdvdstm_semid);
661static int cdrom_stm_nulldev()
663 PRINTF(
"nulldev0 call\n");
667static s64 cdrom_stm_nulldev64()
669 PRINTF(
"nulldev0 call\n");
673int _start(
int ac,
char *av[],
void *startaddr,
ModuleInfo_t *mi)
686 if ( !sceCdSC(0xFFFFFFFF, &last_error) )
688 return MODULE_REMOVABLE_END;
690 g_cdvdstm_in_deldrv = 1;
691 DelDrv(g_cdrom_stm_dev.name);
693 relres = ReleaseLibraryEntries(&_exp_cdvdstm);
695 g_cdvdstm_in_deldrv = 0;
696 if ( relres && relres != KE_LIBRARY_NOTFOUND )
698 g_cdvdstm_in_deldrv = 0;
699 return MODULE_REMOVABLE_END;
701 return MODULE_NO_RESIDENT_END;
703 if ( RegisterLibraryEntries(&_exp_cdvdstm) )
704 return MODULE_NO_RESIDENT_END;
705 DelDrv(g_cdrom_stm_dev.name);
706 if ( AddDrv(&g_cdrom_stm_dev) )
709 return MODULE_NO_RESIDENT_END;
711 g_cdvdman_intr_efid = sceCdSC(0xFFFFFFF5, &scres_unused);
713 return MODULE_REMOVABLE_END;
715 if ( mi && ((mi->
newflags & 2) != 0) )
717 return MODULE_RESIDENT_END;
721static int stm_ee_read_timeout_alarm_cb(
const iop_sys_clock_t *sys_clock)
725 read_timeout = sys_clock->lo / 0x9000;
726 KPRINTF(
"Stm EE Read Time Out %d(msec)\n", read_timeout);
727 sceCdSC(0xFFFFFFEE, &read_timeout);
731static void ee_stream_handler_normal(
cdrom_stm_devctl_t *instruct,
int inbuf_len,
int *outres_ptr)
737 unsigned int chunks_sectors;
738 int bankcur_next_tmp1;
739 int posszarg2_bytes_clamped;
741 int bankcur_next_tmp2;
742 int posszarg2_bytes_overrun;
750 cmdid = instruct->m_cmdid;
751 if ( g_cdvdstm_stmstart_ee == 2 && (cmdid != 9 && cmdid != 3) )
759 sceCdSC(2, &g_cdvdstm_last_error_for_ee);
762 sceCdSC(0, &g_cdvdstm_last_error_for_ee);
770 CancelAlarm((
unsigned int (*)(
void *))ee_stream_intr_cb_normal, &g_cdvdstm_curclk_ee);
771 sceCdSC(0, &g_cdvdstm_last_error_for_ee);
775 CancelAlarm((
unsigned int (*)(
void *))stm_ee_read_timeout_alarm_cb, &g_cdvdstm_curclk_ee);
778 bankcur_tmp = g_cdvdstm_bankcur_ee;
779 if ( !g_cdvdstm_usedmap_ee[bankcur_tmp] )
782 if ( (
unsigned int)bankcur_tmp >= (
unsigned int)g_cdvdstm_bankcnt2 )
784 if ( !g_cdvdstm_usedmap_ee[bankcur_tmp] )
785 bankcur_tmp = g_cdvdstm_bankcur_ee;
787 for ( i = 0; (i < (
unsigned int)g_cdvdstm_bankcnt2) && g_cdvdstm_usedmap_ee[bankcur_tmp]
788 && (g_cdvdstm_bankgp_ee != bankcur_tmp);
792 if ( (
unsigned int)bankcur_tmp >= (
unsigned int)g_cdvdstm_bankcnt2 )
795 *outres_ptr = i * ((
unsigned int)g_cdvdstm_chunksz2 >> 11);
798 sceCdstm1Cb((
void (*)(
int))ee_stream_intr_cb_normal_thunk);
799 if ( !instruct->m_posszarg2 )
801 chunks_sectors = instruct->m_posszarg1 / instruct->m_posszarg2;
802 g_cdvdstm_bufsz2 = instruct->m_posszarg1;
803 g_cdvdstm_sectorcount2 = chunks_sectors;
804 g_cdvdstm_chunksz2 = chunks_sectors << 11;
805 g_cdvdstm_buffer2 = (
char *)instruct->m_buffer;
806 g_cdvdstm_bankcnt2 = instruct->m_posszarg2;
808 "Stream Buffer 1Bank %dbyte %dbanks %dbyte used\n",
809 (
int)(chunks_sectors << 11),
810 (
int)(instruct->m_posszarg2),
811 (
int)((chunks_sectors << 11) * (instruct->m_posszarg2)));
816 g_cdvdstm_stmstart_ee = 0;
817 CancelAlarm((
unsigned int (*)(
void *))ee_stream_intr_cb_normal, &g_cdvdstm_curclk_ee);
818 sceCdSC(0, &g_cdvdstm_last_error_for_ee);
821 for ( i = 0; i < (
unsigned int)g_cdvdstm_bankcnt2; i += 1 )
823 g_cdvdstm_usedmap_ee[i] = 0;
825 g_cdvdstm_bankoffs_ee = 0;
826 g_cdvdstm_bankcur_ee = 0;
827 g_cdvdstm_bankgp_ee = 0;
830 g_cdvdstm_last_error_for_ee = 0;
831 sceCdSC(0xFFFFFFFE, &g_cdvdstm_last_error_for_ee);
832 CancelAlarm((
unsigned int (*)(
void *))stm_ee_read_timeout_alarm_cb, &g_cdvdstm_curclk_ee);
838 g_cdvdstm_retryerr_ee = 0;
841 posszarg2_bytes = instruct->m_posszarg2 << 11;
844 if ( sceCdSC(0xFFFFFFFF, &g_cdvdstm_last_error_for_ee) )
847 g_cdvdstm_lsn_ee = instruct->m_posszarg1;
848 for ( i = 0; i < (
unsigned int)g_cdvdstm_bankcnt2; i += 1 )
850 g_cdvdstm_usedmap_ee[i] = 0;
852 g_cdvdstm_stmstart_ee = 2;
864 CancelAlarm((
unsigned int (*)(
void *))ee_stream_intr_cb_normal, &g_cdvdstm_curclk_ee);
865 sceCdSC(0, &g_cdvdstm_last_error_for_ee);
869 g_cdvdstm_lsn_ee = instruct->m_posszarg1;
870 g_cdvdstm_bankoffs_ee = 0;
871 g_cdvdstm_bankcur_ee = 0;
872 g_cdvdstm_bankgp_ee = 0;
874 CancelAlarm((
unsigned int (*)(
void *))stm_ee_read_timeout_alarm_cb, &g_cdvdstm_curclk_ee);
879 CancelAlarm((
unsigned int (*)(
void *))ee_stream_intr_cb_normal, &g_cdvdstm_curclk_ee);
880 sceCdSC(0, &g_cdvdstm_last_error_for_ee);
883 for ( i = 0; i < (
unsigned int)g_cdvdstm_bankcnt2; i += 1 )
885 g_cdvdstm_usedmap_ee[i] = 0;
887 g_cdvdstm_lsn_ee = instruct->m_posszarg1;
888 sceCdSC(0xFFFFFFE9, (
int *)&g_cdvdstm_lsn_ee);
889 g_cdvdstm_bankoffs_ee = 0;
890 g_cdvdstm_bankcur_ee = 0;
892 CancelAlarm((
unsigned int (*)(
void *))stm_ee_read_timeout_alarm_cb, &g_cdvdstm_curclk_ee);
893 g_cdvdstm_stmstart_ee = 1;
894 sceCdSC(2, &g_cdvdstm_last_error_for_ee);
897 sceCdSC(0, &g_cdvdstm_last_error_for_ee);
902 posszarg2_bytes_overrun = -1;
903 for ( i = 0; i < posszarg2_bytes; i += posszarg2_bytes_clamped )
905 unsigned int posszarg2_bytes_remain;
907 posszarg2_bytes_remain = posszarg2_bytes - i;
908 if ( !g_cdvdstm_usedmap_ee[g_cdvdstm_bankcur_ee] )
912 "CD read buffer over run %d %d %d %d %d gp %d pp %d\n",
913 (u8)g_cdvdstm_usedmap_ee[0],
914 (u8)g_cdvdstm_usedmap_ee[1],
915 (u8)g_cdvdstm_usedmap_ee[2],
916 (u8)g_cdvdstm_usedmap_ee[3],
917 (u8)g_cdvdstm_usedmap_ee[4],
919 g_cdvdstm_bankcur_ee);
921 bankcur_next_tmp1 = g_cdvdstm_bankcur_ee;
922 g_cdvdstm_bankcur_ee += 1;
923 if ( (
unsigned int)g_cdvdstm_bankcur_ee >= (
unsigned int)g_cdvdstm_bankcnt2 )
924 g_cdvdstm_bankcur_ee = 0;
925 if ( !g_cdvdstm_usedmap_ee[g_cdvdstm_bankcur_ee] )
926 g_cdvdstm_bankcur_ee = bankcur_next_tmp1;
927 posszarg2_bytes_overrun = posszarg2_bytes - posszarg2_bytes_remain;
931 posszarg2_bytes_clamped = ((
unsigned int)(g_cdvdstm_chunksz2 - g_cdvdstm_bankoffs_ee) < posszarg2_bytes_remain) ?
932 (
unsigned int)(g_cdvdstm_chunksz2 - g_cdvdstm_bankoffs_ee) :
933 posszarg2_bytes_remain;
934 g_cdvdstm_dmat.dest = ((
char *)instruct->m_buffer) + i;
935 g_cdvdstm_dmat.size = posszarg2_bytes_clamped;
936 g_cdvdstm_dmat.attr = 0;
937 g_cdvdstm_dmat.src = (
char *)g_cdvdstm_buffer2 + g_cdvdstm_bankcur_ee * g_cdvdstm_chunksz2 + g_cdvdstm_bankoffs_ee;
938 if ( posszarg2_bytes_clamped )
943 dmat1 = sceSifSetDma(&g_cdvdstm_dmat, 1);
949 g_cdvdstm_bankoffs_ee += posszarg2_bytes_clamped;
950 while ( sceSifDmaStat(dmat1) >= 0 )
953 if ( (
unsigned int)g_cdvdstm_bankoffs_ee >= (
unsigned int)g_cdvdstm_chunksz2 )
956 g_cdvdstm_bankoffs_ee = 0;
957 g_cdvdstm_usedmap_ee[g_cdvdstm_bankcur_ee] = 0;
958 bankcur_next_tmp2 = g_cdvdstm_bankcur_ee;
959 g_cdvdstm_bankcur_ee += 1;
960 if ( (
unsigned int)g_cdvdstm_bankcur_ee >= (
unsigned int)g_cdvdstm_bankcnt2 )
961 g_cdvdstm_bankcur_ee = 0;
962 if ( g_cdvdstm_usedmap_ee[g_cdvdstm_bankcur_ee] && g_cdvdstm_bankgp_ee != g_cdvdstm_bankcur_ee )
968 g_cdvdstm_bankcur_ee = bankcur_next_tmp2;
972 "CD read buffer over run %d %d %d %d %d gp %d pp %d\n",
973 (u8)g_cdvdstm_usedmap_ee[0],
974 (u8)g_cdvdstm_usedmap_ee[1],
975 (u8)g_cdvdstm_usedmap_ee[2],
976 (u8)g_cdvdstm_usedmap_ee[3],
977 (u8)g_cdvdstm_usedmap_ee[4],
979 g_cdvdstm_bankcur_ee);
980 posszarg2_bytes_overrun = posszarg2_bytes - (posszarg2_bytes_remain - posszarg2_bytes_clamped);
985 if ( posszarg2_bytes_overrun == -1 )
986 posszarg2_bytes_overrun = posszarg2_bytes;
987 outres_tmp2 = (retryflag) ? 1 : (posszarg2_bytes_overrun / 0x800);
990 if ( sceCdSC(0xFFFFFFFF, &g_cdvdstm_last_error_for_ee) != 2 && !outres_tmp2 && !g_cdvdstm_retryerr_ee )
991 g_cdvdstm_retryerr_ee = 273;
992 if ( g_cdvdstm_retryerr_ee )
994 outres_tmp2 = (u16)outres_tmp2 | (g_cdvdstm_retryerr_ee << 16);
995 g_cdvdstm_retryerr_ee = 0;
998 *outres_ptr = outres_tmp2;
1002static unsigned int ee_stream_intr_cb_normal(
void *userdata)
1008 VERBOSE_KPRINTF(1,
"Intr EE Stm Read call\n");
1009 iCancelAlarm((
unsigned int (*)(
void *))stm_ee_read_timeout_alarm_cb, &g_cdvdstm_curclk_ee);
1010 iCancelAlarm((
unsigned int (*)(
void *))ee_stream_intr_cb_normal, &g_cdvdstm_curclk_ee);
1011 sceCdSC(0xFFFFFFFF, &g_cdvdstm_last_error_for_ee);
1012 if ( !g_cdvdstm_last_error_for_ee )
1027 g_cdvdstm_curclk_ee.hi = 0;
1028 if ( g_cdvdstm_stmstart_ee )
1029 g_cdvdstm_retrycnt_ee_normal = 0;
1030 g_cdvdstm_curclk_ee.lo = (g_cdvdstm_stmstart_ee || g_cdvdstm_last_error_for_ee || g_cdvdstm_retrycnt_ee_normal) ?
1032 (0x9000 * sceCdSC(0xFFFFFFEF, &scres_unused));
1033 if ( g_cdvdstm_last_error_for_ee )
1037 "EE Stream read LBN= %d Error code= 0x%02x retry= %d\n",
1038 g_cdvdstm_readlbn_ee_normal,
1039 g_cdvdstm_last_error_for_ee,
1040 g_cdvdstm_retrycnt_ee_normal);
1043 if ( g_cdvdstm_retrycnt_ee_normal )
1045 VERBOSE_KPRINTF(1,
"On Retry retry %d err %08x\n", g_cdvdstm_retrycnt_ee_normal, g_cdvdstm_last_error_for_ee);
1047 g_cdvdstm_retrycnt_ee_normal = 3;
1051 g_cdvdstm_retrycnt_ee_normal = 1;
1053 g_cdvdstm_retryerr_ee = g_cdvdstm_last_error_for_ee;
1055 if ( g_cdvdstm_retrycnt_ee_normal )
1057 g_cdvdstm_retrycnt_ee_normal -= 1;
1059 ((
unsigned int)g_cdvdstm_readlbn_ee_normal >= (
unsigned int)(0x10 * g_cdvdstm_retrycnt_ee_normal)) ?
1060 (g_cdvdstm_readlbn_ee_normal - 0x10 * g_cdvdstm_retrycnt_ee_normal) :
1061 (g_cdvdstm_readlbn_ee_normal + 0x10 * g_cdvdstm_retrycnt_ee_normal),
1062 g_cdvdstm_sectorcount2,
1063 (
char *)g_cdvdstm_buffer2 + g_cdvdstm_bankgp_ee * g_cdvdstm_chunksz2,
1064 &g_cdvdstm_mode_ee) )
1066 iSetAlarm(&g_cdvdstm_curclk_ee, (
unsigned int (*)(
void *))stm_ee_read_timeout_alarm_cb, &g_cdvdstm_curclk_ee);
1070 VERBOSE_KPRINTF(1,
"Stm Read Call fail\n");
1071 g_cdvdstm_curclk_ee.lo = 0x708000;
1073 iSetAlarm(&g_cdvdstm_curclk_ee, (
unsigned int (*)(
void *))ee_stream_intr_cb_normal, &g_cdvdstm_curclk_ee)
1076 sceCdSC(0, &g_cdvdstm_last_error_for_ee);
1078 g_cdvdstm_retrycnt_ee_normal += 1;
1085 if ( !g_cdvdstm_stmstart_ee )
1087 g_cdvdstm_usedmap_ee[g_cdvdstm_bankgp_ee] = 1;
1088 gptmp = g_cdvdstm_bankgp_ee;
1089 g_cdvdstm_bankgp_ee += 1;
1090 if ( (
unsigned int)g_cdvdstm_bankgp_ee >= (
unsigned int)g_cdvdstm_bankcnt2 )
1091 g_cdvdstm_bankgp_ee = 0;
1094 !g_cdvdstm_stmstart_ee
1095 && (g_cdvdstm_usedmap_ee[g_cdvdstm_bankgp_ee] || g_cdvdstm_bankcur_ee == g_cdvdstm_bankgp_ee) )
1097 g_cdvdstm_bankgp_ee = gptmp;
1098 g_cdvdstm_usedmap_ee[gptmp] = 0;
1101 "read Full %d %d %d %d %d gp %d pp %d spn %d\n",
1102 (u8)g_cdvdstm_usedmap_ee[0],
1103 (u8)g_cdvdstm_usedmap_ee[1],
1104 (u8)g_cdvdstm_usedmap_ee[2],
1105 (u8)g_cdvdstm_usedmap_ee[3],
1106 (u8)g_cdvdstm_usedmap_ee[4],
1107 g_cdvdstm_bankgp_ee,
1108 g_cdvdstm_bankcur_ee,
1110 g_cdvdstm_curclk_ee.lo = 0x48000;
1112 iSetAlarm(&g_cdvdstm_curclk_ee, (
unsigned int (*)(
void *))ee_stream_intr_cb_normal, &g_cdvdstm_curclk_ee)
1115 sceCdSC(0, &g_cdvdstm_last_error_for_ee);
1120 if ( g_cdvdstm_stmstart_ee == 2 )
1124 g_cdvdstm_bankoffs_ee = 0;
1125 g_cdvdstm_bankcur_ee = 0;
1126 g_cdvdstm_bankgp_ee = 0;
1127 for ( i = 0; i < (
unsigned int)g_cdvdstm_bankcnt2; i += 1 )
1128 g_cdvdstm_usedmap_ee[i] = 0;
1130 g_cdvdstm_stmstart_ee = 0;
1131 g_cdvdstm_readlbn_ee_normal = g_cdvdstm_lsn_ee;
1134 g_cdvdstm_sectorcount2,
1135 (
char *)g_cdvdstm_buffer2 + g_cdvdstm_bankgp_ee * g_cdvdstm_chunksz2,
1136 &g_cdvdstm_mode_ee) )
1138 iSetAlarm(&g_cdvdstm_curclk_ee, (
unsigned int (*)(
void *))stm_ee_read_timeout_alarm_cb, &g_cdvdstm_curclk_ee);
1142 VERBOSE_KPRINTF(1,
"Stm Read Call1 fail\n");
1143 g_cdvdstm_curclk_ee.lo = 0x708000;
1145 iSetAlarm(&g_cdvdstm_curclk_ee, (
unsigned int (*)(
void *))ee_stream_intr_cb_normal, &g_cdvdstm_curclk_ee)
1148 sceCdSC(0, &g_cdvdstm_last_error_for_ee);
1150 g_cdvdstm_retrycnt_ee_normal = 1;
1152 g_cdvdstm_lsn_ee += g_cdvdstm_sectorcount2;
1158static void ee_stream_handler_cdda(
cdrom_stm_devctl_t *instruct,
int inbuf_len,
int *outres_ptr)
1161 u32 posszarg2_bytes;
1165 int bankcur_next_tmp1;
1166 int posszarg2_bytes_clamped;
1168 int bankcur_next_tmp2;
1169 int posszarg2_overrun_chunks2;
1170 unsigned int posszarg2_bytes_overrun;
1176 cmdid = instruct->m_cmdid;
1177 posszarg2_bytes = instruct->m_posszarg2 * g_cdvdstm_usedchunksize2;
1179 if ( g_cdvdstm_stmstart_ee == 2 && (cmdid != 9 && cmdid != 3) )
1187 sceCdSC(2, &g_cdvdstm_last_error_for_ee);
1193 sceCdSC(0, &g_cdvdstm_last_error_for_ee);
1198 CancelAlarm((
unsigned int (*)(
void *))ee_stream_intr_cb_cdda, &g_cdvdstm_curclk_ee);
1199 sceCdSC(0, &g_cdvdstm_last_error_for_ee);
1203 CancelAlarm((
unsigned int (*)(
void *))stm_ee_read_timeout_alarm_cb, &g_cdvdstm_curclk_ee);
1206 bankcur_tmp = g_cdvdstm_bankcur_ee;
1207 if ( !g_cdvdstm_usedmap_ee[bankcur_tmp] )
1210 if ( (
unsigned int)bankcur_tmp >= (
unsigned int)g_cdvdstm_bankcnt2 )
1212 if ( !g_cdvdstm_usedmap_ee[bankcur_tmp] )
1213 bankcur_tmp = g_cdvdstm_bankcur_ee;
1215 for ( i = 0; (i < (
unsigned int)g_cdvdstm_bankcnt2) && g_cdvdstm_usedmap_ee[bankcur_tmp]
1216 && (g_cdvdstm_bankgp_ee != bankcur_tmp);
1220 if ( (
unsigned int)(bankcur_tmp) >= (
unsigned int)g_cdvdstm_bankcnt2 )
1223 if ( !g_cdvdstm_usedchunksize2 )
1225 *outres_ptr = i * (g_cdvdstm_chunksz2 / (
unsigned int)g_cdvdstm_usedchunksize2);
1228 sceCdstm1Cb((
void (*)(
int))ee_stream_intr_cb_cdda_thunk);
1232 g_cdvdstm_usedchunksize2 = 2368;
1235 g_cdvdstm_usedchunksize2 = 2448;
1239 g_cdvdstm_usedchunksize2 = 0x930;
1242 if ( !instruct->m_posszarg2 )
1244 chunks_sectors = instruct->m_posszarg1 / instruct->m_posszarg2;
1245 g_cdvdstm_bufsz2 = instruct->m_posszarg1;
1246 g_cdvdstm_sectorcount2 = chunks_sectors;
1247 g_cdvdstm_chunksz2 = chunks_sectors * g_cdvdstm_usedchunksize2;
1248 g_cdvdstm_buffer2 = (
char *)instruct->m_buffer;
1249 g_cdvdstm_bankcnt2 = instruct->m_posszarg2;
1251 "DA Stream Buffer 1Bank %dbyte %dbanks %dbyte used\n",
1252 (
int)(chunks_sectors * g_cdvdstm_usedchunksize2),
1253 (
int)instruct->m_posszarg2,
1254 (
int)(chunks_sectors * g_cdvdstm_usedchunksize2 * instruct->m_posszarg2));
1259 g_cdvdstm_stmstart_ee = 0;
1260 CancelAlarm((
unsigned int (*)(
void *))ee_stream_intr_cb_cdda, &g_cdvdstm_curclk_ee);
1261 sceCdSC(0, &g_cdvdstm_last_error_for_ee);
1264 for ( i = 0; i < (
unsigned int)g_cdvdstm_bankcnt2; i += 1 )
1266 g_cdvdstm_usedmap_ee[i] = 0;
1268 g_cdvdstm_bankoffs_ee = 0;
1269 g_cdvdstm_bankcur_ee = 0;
1270 g_cdvdstm_bankgp_ee = 0;
1273 g_cdvdstm_last_error_for_ee = 0;
1274 sceCdSC(0xFFFFFFFE, &g_cdvdstm_last_error_for_ee);
1275 CancelAlarm((
unsigned int (*)(
void *))stm_ee_read_timeout_alarm_cb, &g_cdvdstm_curclk_ee);
1281 g_cdvdstm_retryerr_ee = 0;
1286 if ( sceCdSC(0xFFFFFFFF, &g_cdvdstm_last_error_for_ee) )
1289 g_cdvdstm_lsn_ee = instruct->m_posszarg1;
1290 for ( i = 0; i < (
unsigned int)g_cdvdstm_bankcnt2; i += 1 )
1292 g_cdvdstm_usedmap_ee[i] = 0;
1294 g_cdvdstm_stmstart_ee = 2;
1306 CancelAlarm((
unsigned int (*)(
void *))ee_stream_intr_cb_cdda, &g_cdvdstm_curclk_ee);
1307 sceCdSC(0, &g_cdvdstm_last_error_for_ee);
1308 posszarg2_bytes = 0;
1311 g_cdvdstm_lsn_ee = instruct->m_posszarg1;
1312 g_cdvdstm_bankoffs_ee = 0;
1313 g_cdvdstm_bankcur_ee = 0;
1314 g_cdvdstm_bankgp_ee = 0;
1316 CancelAlarm((
unsigned int (*)(
void *))stm_ee_read_timeout_alarm_cb, &g_cdvdstm_curclk_ee);
1320 signed int posszarg2_chunks;
1323 CancelAlarm((
unsigned int (*)(
void *))ee_stream_intr_cb_cdda, &g_cdvdstm_curclk_ee);
1324 sceCdSC(0, &g_cdvdstm_last_error_for_ee);
1327 for ( i = 0; i < (
unsigned int)g_cdvdstm_bankcnt2; i += 1 )
1329 g_cdvdstm_usedmap_ee[i] = 0;
1331 g_cdvdstm_lsn_ee = instruct->m_posszarg1;
1332 g_cdvdstm_bankoffs_ee = 0;
1333 g_cdvdstm_bankcur_ee = 0;
1335 CancelAlarm((
unsigned int (*)(
void *))stm_ee_read_timeout_alarm_cb, &g_cdvdstm_curclk_ee);
1336 if ( !g_cdvdstm_chunksz2 )
1338 posszarg2_chunks = (posszarg2_bytes / g_cdvdstm_chunksz2) + (!!(posszarg2_bytes % g_cdvdstm_chunksz2));
1339 for ( g_cdvdstm_bankgp_ee = 0; g_cdvdstm_bankgp_ee < posszarg2_chunks; g_cdvdstm_bankgp_ee += 1 )
1343 outres_tmp2 = sceCdReadCDDA(g_cdvdstm_lsn_ee, g_cdvdstm_sectorcount2, g_cdvdstm_buffer2, &g_cdvdstm_mode_ee);
1345 sceCdSC(0xFFFFFFFF, &g_cdvdstm_last_error_for_ee);
1346 if ( g_cdvdstm_last_error_for_ee || !outres_tmp2 )
1348 sceCdSC(0, &g_cdvdstm_last_error_for_ee);
1352 g_cdvdstm_lsn_ee += g_cdvdstm_sectorcount2;
1353 g_cdvdstm_usedmap_ee[g_cdvdstm_bankgp_ee] = 1;
1355 g_cdvdstm_stmstart_ee = 1;
1356 sceCdSC(2, &g_cdvdstm_last_error_for_ee);
1359 sceCdSC(0, &g_cdvdstm_last_error_for_ee);
1364 posszarg2_bytes_overrun = -1;
1365 for ( i = 0; i < posszarg2_bytes; i += posszarg2_bytes_clamped )
1367 unsigned int posszarg2_bytes_remain;
1369 posszarg2_bytes_remain = posszarg2_bytes - i;
1370 if ( !g_cdvdstm_usedmap_ee[g_cdvdstm_bankcur_ee] )
1374 "CD read buffer over run %d %d %d %d %d gp %d pp %d\n",
1375 (u8)g_cdvdstm_usedmap_ee[0],
1376 (u8)g_cdvdstm_usedmap_ee[1],
1377 (u8)g_cdvdstm_usedmap_ee[2],
1378 (u8)g_cdvdstm_usedmap_ee[3],
1379 (u8)g_cdvdstm_usedmap_ee[4],
1380 g_cdvdstm_bankgp_ee,
1381 g_cdvdstm_bankcur_ee);
1383 bankcur_next_tmp1 = g_cdvdstm_bankcur_ee;
1384 g_cdvdstm_bankcur_ee += 1;
1385 if ( (
unsigned int)g_cdvdstm_bankcur_ee >= (
unsigned int)g_cdvdstm_bankcnt2 )
1386 g_cdvdstm_bankcur_ee = 0;
1387 if ( !g_cdvdstm_usedmap_ee[g_cdvdstm_bankcur_ee] )
1388 g_cdvdstm_bankcur_ee = bankcur_next_tmp1;
1389 posszarg2_bytes_overrun = posszarg2_bytes - posszarg2_bytes_remain;
1393 posszarg2_bytes_clamped = ((
unsigned int)(g_cdvdstm_chunksz2 - g_cdvdstm_bankoffs_ee) < posszarg2_bytes_remain) ?
1394 (
unsigned int)(g_cdvdstm_chunksz2 - g_cdvdstm_bankoffs_ee) :
1395 posszarg2_bytes_remain;
1396 g_cdvdstm_dmat2.dest = ((
char *)instruct->m_buffer) + i;
1397 g_cdvdstm_dmat2.size = posszarg2_bytes_clamped;
1398 g_cdvdstm_dmat2.attr = 0;
1399 g_cdvdstm_dmat2.src = (
char *)g_cdvdstm_buffer2 + g_cdvdstm_bankcur_ee * g_cdvdstm_chunksz2 + g_cdvdstm_bankoffs_ee;
1400 if ( posszarg2_bytes_clamped )
1405 dmat2 = sceSifSetDma(&g_cdvdstm_dmat2, 1);
1411 g_cdvdstm_bankoffs_ee += posszarg2_bytes_clamped;
1412 while ( sceSifDmaStat(dmat2) >= 0 )
1415 if ( (
unsigned int)g_cdvdstm_bankoffs_ee >= (
unsigned int)g_cdvdstm_chunksz2 )
1418 g_cdvdstm_bankoffs_ee = 0;
1419 g_cdvdstm_usedmap_ee[g_cdvdstm_bankcur_ee] = 0;
1420 bankcur_next_tmp2 = g_cdvdstm_bankcur_ee;
1421 g_cdvdstm_bankcur_ee += 1;
1422 if ( (
unsigned int)g_cdvdstm_bankcur_ee >= (
unsigned int)g_cdvdstm_bankcnt2 )
1423 g_cdvdstm_bankcur_ee = 0;
1424 if ( g_cdvdstm_usedmap_ee[g_cdvdstm_bankcur_ee] && g_cdvdstm_bankgp_ee != g_cdvdstm_bankcur_ee )
1430 g_cdvdstm_bankcur_ee = bankcur_next_tmp2;
1434 "CD read buffer over run %d %d %d %d %d gp %d pp %d\n",
1435 (u8)g_cdvdstm_usedmap_ee[0],
1436 (u8)g_cdvdstm_usedmap_ee[1],
1437 (u8)g_cdvdstm_usedmap_ee[2],
1438 (u8)g_cdvdstm_usedmap_ee[3],
1439 (u8)g_cdvdstm_usedmap_ee[4],
1440 g_cdvdstm_bankgp_ee,
1441 g_cdvdstm_bankcur_ee);
1442 posszarg2_bytes_overrun = posszarg2_bytes - (posszarg2_bytes_remain - posszarg2_bytes_clamped);
1447 if ( posszarg2_bytes_overrun == 0xFFFFFFFF )
1448 posszarg2_bytes_overrun = posszarg2_bytes;
1449 if ( !g_cdvdstm_usedchunksize2 )
1451 posszarg2_overrun_chunks2 = posszarg2_bytes_overrun / g_cdvdstm_usedchunksize2;
1457 if ( sceCdSC(0xFFFFFFFF, &g_cdvdstm_last_error_for_ee) != 2 && !posszarg2_overrun_chunks2 && !g_cdvdstm_retryerr_ee )
1458 g_cdvdstm_retryerr_ee = 273;
1459 if ( g_cdvdstm_retryerr_ee )
1461 posszarg2_overrun_chunks2 = (u16)posszarg2_overrun_chunks2 | (g_cdvdstm_retryerr_ee << 16);
1462 g_cdvdstm_retryerr_ee = 0;
1464 *outres_ptr = posszarg2_overrun_chunks2;
1467static unsigned int ee_stream_intr_cb_cdda(
void *userdata)
1473 VERBOSE_KPRINTF(1,
"Intr EE DA Stm Read call\n");
1474 iCancelAlarm((
unsigned int (*)(
void *))stm_ee_read_timeout_alarm_cb, &g_cdvdstm_curclk_ee);
1475 iCancelAlarm((
unsigned int (*)(
void *))ee_stream_intr_cb_cdda, &g_cdvdstm_curclk_ee);
1476 sceCdSC(0xFFFFFFFF, &g_cdvdstm_last_error_for_ee);
1477 if ( !g_cdvdstm_last_error_for_ee )
1491 g_cdvdstm_curclk_ee.hi = 0;
1492 if ( g_cdvdstm_stmstart_ee )
1493 g_cdvdstm_retrycnt_ee_cdda = 0;
1494 g_cdvdstm_curclk_ee.lo = (g_cdvdstm_stmstart_ee || g_cdvdstm_last_error_for_ee || g_cdvdstm_retrycnt_ee_cdda) ?
1496 (0x9000 * sceCdSC(0xFFFFFFEF, &scres_unused));
1497 if ( g_cdvdstm_last_error_for_ee )
1501 "EE Stream read LBN= %d Error code= 0x%02x retry= %d\n",
1502 g_cdvdstm_readlbn_ee_cdda,
1503 g_cdvdstm_last_error_for_ee,
1504 g_cdvdstm_retrycnt_ee_cdda);
1507 if ( g_cdvdstm_retrycnt_ee_cdda )
1509 VERBOSE_KPRINTF(1,
"On Retry retry %d err %08x\n", g_cdvdstm_retrycnt_ee_cdda, g_cdvdstm_last_error_for_ee);
1511 g_cdvdstm_retrycnt_ee_cdda = 4;
1515 g_cdvdstm_retrycnt_ee_cdda = 1;
1517 g_cdvdstm_retryerr_ee = g_cdvdstm_last_error_for_ee;
1521 g_cdvdstm_retrycnt_ee_cdda = 0;
1523 if ( g_cdvdstm_retrycnt_ee_cdda )
1525 g_cdvdstm_retrycnt_ee_cdda -= 1;
1527 !g_cdvdstm_retrycnt_ee_cdda
1530 g_cdvdstm_readlbn_ee_cdda =
1531 g_cdvdstm_lsn_ee + ((g_cdvdstm_sectorcount2 < 0x1D) ? (0x1D - g_cdvdstm_sectorcount2) : 0);
1532 g_cdvdstm_lsn_ee = g_cdvdstm_readlbn_ee_cdda + g_cdvdstm_sectorcount2;
1535 g_cdvdstm_readlbn_ee_cdda,
1536 g_cdvdstm_sectorcount2,
1537 (
char *)g_cdvdstm_buffer2 + g_cdvdstm_bankgp_ee * g_cdvdstm_chunksz2,
1538 &g_cdvdstm_mode_ee) )
1540 iSetAlarm(&g_cdvdstm_curclk_ee, (
unsigned int (*)(
void *))stm_ee_read_timeout_alarm_cb, &g_cdvdstm_curclk_ee);
1544 VERBOSE_KPRINTF(1,
"Stm Read Call fail\n");
1545 g_cdvdstm_curclk_ee.lo = 0x708000;
1547 iSetAlarm(&g_cdvdstm_curclk_ee, (
unsigned int (*)(
void *))ee_stream_intr_cb_cdda, &g_cdvdstm_curclk_ee)
1550 sceCdSC(0, &g_cdvdstm_last_error_for_ee);
1552 g_cdvdstm_retrycnt_ee_cdda += 1;
1559 if ( !g_cdvdstm_stmstart_ee )
1561 g_cdvdstm_usedmap_ee[g_cdvdstm_bankgp_ee] = 1;
1562 gptmp = g_cdvdstm_bankgp_ee;
1563 g_cdvdstm_bankgp_ee += 1;
1564 if ( (
unsigned int)g_cdvdstm_bankgp_ee >= (
unsigned int)g_cdvdstm_bankcnt2 )
1565 g_cdvdstm_bankgp_ee = 0;
1568 !g_cdvdstm_stmstart_ee
1569 && (g_cdvdstm_usedmap_ee[g_cdvdstm_bankgp_ee] || g_cdvdstm_bankcur_ee == g_cdvdstm_bankgp_ee) )
1571 g_cdvdstm_bankgp_ee = gptmp;
1572 g_cdvdstm_usedmap_ee[gptmp] = 0;
1575 "read Full %d %d %d %d %d gp %d pp %d spn %d\n",
1576 (u8)g_cdvdstm_usedmap_ee[0],
1577 (u8)g_cdvdstm_usedmap_ee[1],
1578 (u8)g_cdvdstm_usedmap_ee[2],
1579 (u8)g_cdvdstm_usedmap_ee[3],
1580 (u8)g_cdvdstm_usedmap_ee[4],
1581 g_cdvdstm_bankgp_ee,
1582 g_cdvdstm_bankcur_ee,
1584 g_cdvdstm_curclk_ee.lo = 0x48000;
1586 iSetAlarm(&g_cdvdstm_curclk_ee, (
unsigned int (*)(
void *))ee_stream_intr_cb_cdda, &g_cdvdstm_curclk_ee)
1589 sceCdSC(0, &g_cdvdstm_last_error_for_ee);
1594 if ( g_cdvdstm_stmstart_ee == 2 )
1598 g_cdvdstm_bankoffs_ee = 0;
1599 g_cdvdstm_bankcur_ee = 0;
1600 g_cdvdstm_bankgp_ee = 0;
1601 for ( i = 0; i < (
unsigned int)g_cdvdstm_bankcnt2; i += 1 )
1602 g_cdvdstm_usedmap_ee[i] = 0;
1604 g_cdvdstm_stmstart_ee = 0;
1605 g_cdvdstm_readlbn_ee_cdda = g_cdvdstm_lsn_ee;
1608 g_cdvdstm_sectorcount2,
1609 (
char *)g_cdvdstm_buffer2 + g_cdvdstm_bankgp_ee * g_cdvdstm_chunksz2,
1610 &g_cdvdstm_mode_ee) )
1612 iSetAlarm(&g_cdvdstm_curclk_ee, (
unsigned int (*)(
void *))stm_ee_read_timeout_alarm_cb, &g_cdvdstm_curclk_ee);
1616 VERBOSE_KPRINTF(1,
"Stm Read Call1 fail\n");
1617 g_cdvdstm_curclk_ee.lo = 0x708000;
1619 iSetAlarm(&g_cdvdstm_curclk_ee, (
unsigned int (*)(
void *))ee_stream_intr_cb_cdda, &g_cdvdstm_curclk_ee)
1622 sceCdSC(0, &g_cdvdstm_last_error_for_ee);
1624 g_cdvdstm_retrycnt_ee_cdda = 1;
1626 g_cdvdstm_lsn_ee += g_cdvdstm_sectorcount2;
1634 "\t" ".set push" "\n"
1635 "\t" ".set noat" "\n"
1636 "\t" ".set noreorder" "\n"
1637 "\t" ".global optimized_memcpy" "\n"
1638 "\t" "optimized_memcpy:" "\n"
1639 "\t" " srl $a3, $a2, 2" "\n"
1640 "\t" " beqz $a3, .Loptimized_memcpy_12" "\n"
1641 "\t" " or $a3, $a0, $a1" "\n"
1642 "\t" " andi $a3, $a3, 0x3" "\n"
1643 "\t" " bnez $a3, .Loptimized_memcpy_3" "\n"
1645 "\t" " srl $a3, $a2, 2" "\n"
1646 "\t" " addiu $at, $zero, 0xC" "\n"
1647 "\t" " div $zero, $a3, $at" "\n"
1648 "\t" " mflo $a3" "\n"
1649 "\t" " mfhi $v1" "\n"
1650 "\t" " beqz $v1, .Loptimized_memcpy_2" "\n"
1652 "\t" ".Loptimized_memcpy_1:" "\n"
1653 "\t" " lw $v0, 0x0($a1)" "\n"
1654 "\t" " addiu $v1, $v1, -0x1" "\n"
1655 "\t" " sw $v0, 0x0($a0)" "\n"
1656 "\t" " addiu $a1, $a1, 0x4" "\n"
1657 "\t" " bnez $v1, .Loptimized_memcpy_1" "\n"
1658 "\t" " addiu $a0, $a0, 0x4" "\n"
1659 "\t" " beqz $a3, .Loptimized_memcpy_12" "\n"
1661 "\t" ".Loptimized_memcpy_2:" "\n"
1662 "\t" " lw $v0, 0x0($a1)" "\n"
1663 "\t" " lw $v1, 0x4($a1)" "\n"
1664 "\t" " lw $t0, 0x8($a1)" "\n"
1665 "\t" " lw $t1, 0xC($a1)" "\n"
1666 "\t" " lw $t2, 0x10($a1)" "\n"
1667 "\t" " lw $t3, 0x14($a1)" "\n"
1668 "\t" " lw $t4, 0x18($a1)" "\n"
1669 "\t" " lw $t5, 0x1C($a1)" "\n"
1670 "\t" " lw $t6, 0x20($a1)" "\n"
1671 "\t" " lw $t7, 0x24($a1)" "\n"
1672 "\t" " lw $t8, 0x28($a1)" "\n"
1673 "\t" " lw $t9, 0x2C($a1)" "\n"
1674 "\t" " addiu $a3, $a3, -0x1" "\n"
1675 "\t" " sw $v0, 0x0($a0)" "\n"
1676 "\t" " sw $v1, 0x4($a0)" "\n"
1677 "\t" " sw $t0, 0x8($a0)" "\n"
1678 "\t" " sw $t1, 0xC($a0)" "\n"
1679 "\t" " sw $t2, 0x10($a0)" "\n"
1680 "\t" " sw $t3, 0x14($a0)" "\n"
1681 "\t" " sw $t4, 0x18($a0)" "\n"
1682 "\t" " sw $t5, 0x1C($a0)" "\n"
1683 "\t" " sw $t6, 0x20($a0)" "\n"
1684 "\t" " sw $t7, 0x24($a0)" "\n"
1685 "\t" " sw $t8, 0x28($a0)" "\n"
1686 "\t" " sw $t9, 0x2C($a0)" "\n"
1687 "\t" " addiu $a1, $a1, 0x30" "\n"
1688 "\t" " bnez $a3, .Loptimized_memcpy_2" "\n"
1689 "\t" " addiu $a0, $a0, 0x30" "\n"
1690 "\t" " j .Loptimized_memcpy_12" "\n"
1692 "\t" ".Loptimized_memcpy_3:" "\n"
1693 "\t" " andi $a3, $a0, 0x3" "\n"
1694 "\t" " beqz $a3, .Loptimized_memcpy_6" "\n"
1695 "\t" " andi $a3, $a1, 0x3" "\n"
1696 "\t" " beqz $a3, .Loptimized_memcpy_6" "\n"
1698 "\t" " srl $a3, $a2, 2" "\n"
1699 "\t" " addiu $at, $zero, 0xC" "\n"
1700 "\t" " div $zero, $a3, $at" "\n"
1701 "\t" " mflo $a3" "\n"
1702 "\t" " mfhi $v1" "\n"
1703 "\t" " beqz $v1, .Loptimized_memcpy_5" "\n"
1705 "\t" ".Loptimized_memcpy_4:" "\n"
1706 "\t" " lwl $v0, 0x3($a1)" "\n"
1707 "\t" " lwr $v0, 0x0($a1)" "\n"
1708 "\t" " addiu $v1, $v1, -0x1" "\n"
1709 "\t" " swl $v0, 0x3($a0)" "\n"
1710 "\t" " swr $v0, 0x0($a0)" "\n"
1711 "\t" " addiu $a1, $a1, 0x4" "\n"
1712 "\t" " bnez $v1, .Loptimized_memcpy_4" "\n"
1713 "\t" " addiu $a0, $a0, 0x4" "\n"
1714 "\t" " beqz $a3, .Loptimized_memcpy_12" "\n"
1716 "\t" ".Loptimized_memcpy_5:" "\n"
1717 "\t" " lwl $v0, 0x3($a1)" "\n"
1718 "\t" " lwr $v0, 0x0($a1)" "\n"
1719 "\t" " lwl $v1, 0x7($a1)" "\n"
1720 "\t" " lwr $v1, 0x4($a1)" "\n"
1721 "\t" " lwl $t0, 0xB($a1)" "\n"
1722 "\t" " lwr $t0, 0x8($a1)" "\n"
1723 "\t" " lwl $t1, 0xF($a1)" "\n"
1724 "\t" " lwr $t1, 0xC($a1)" "\n"
1725 "\t" " lwl $t2, 0x13($a1)" "\n"
1726 "\t" " lwr $t2, 0x10($a1)" "\n"
1727 "\t" " lwl $t3, 0x17($a1)" "\n"
1728 "\t" " lwr $t3, 0x14($a1)" "\n"
1729 "\t" " lwl $t4, 0x1B($a1)" "\n"
1730 "\t" " lwr $t4, 0x18($a1)" "\n"
1731 "\t" " lwl $t5, 0x1F($a1)" "\n"
1732 "\t" " lwr $t5, 0x1C($a1)" "\n"
1733 "\t" " lwl $t6, 0x23($a1)" "\n"
1734 "\t" " lwr $t6, 0x20($a1)" "\n"
1735 "\t" " lwl $t7, 0x27($a1)" "\n"
1736 "\t" " lwr $t7, 0x24($a1)" "\n"
1737 "\t" " lwl $t8, 0x2B($a1)" "\n"
1738 "\t" " lwr $t8, 0x28($a1)" "\n"
1739 "\t" " lwl $t9, 0x2F($a1)" "\n"
1740 "\t" " lwr $t9, 0x2C($a1)" "\n"
1741 "\t" " addiu $a3, $a3, -0x1" "\n"
1742 "\t" " swl $v0, 0x3($a0)" "\n"
1743 "\t" " swr $v0, 0x0($a0)" "\n"
1744 "\t" " swl $v1, 0x7($a0)" "\n"
1745 "\t" " swr $v1, 0x4($a0)" "\n"
1746 "\t" " swl $t0, 0xB($a0)" "\n"
1747 "\t" " swr $t0, 0x8($a0)" "\n"
1748 "\t" " swl $t1, 0xF($a0)" "\n"
1749 "\t" " swr $t1, 0xC($a0)" "\n"
1750 "\t" " swl $t2, 0x13($a0)" "\n"
1751 "\t" " swr $t2, 0x10($a0)" "\n"
1752 "\t" " swl $t3, 0x17($a0)" "\n"
1753 "\t" " swr $t3, 0x14($a0)" "\n"
1754 "\t" " swl $t4, 0x1B($a0)" "\n"
1755 "\t" " swr $t4, 0x18($a0)" "\n"
1756 "\t" " swl $t5, 0x1F($a0)" "\n"
1757 "\t" " swr $t5, 0x1C($a0)" "\n"
1758 "\t" " swl $t6, 0x23($a0)" "\n"
1759 "\t" " swr $t6, 0x20($a0)" "\n"
1760 "\t" " swl $t7, 0x27($a0)" "\n"
1761 "\t" " swr $t7, 0x24($a0)" "\n"
1762 "\t" " swl $t8, 0x2B($a0)" "\n"
1763 "\t" " swr $t8, 0x28($a0)" "\n"
1764 "\t" " swl $t9, 0x2F($a0)" "\n"
1765 "\t" " swr $t9, 0x2C($a0)" "\n"
1766 "\t" " addiu $a1, $a1, 0x30" "\n"
1767 "\t" " bnez $a3, .Loptimized_memcpy_5" "\n"
1768 "\t" " addiu $a0, $a0, 0x30" "\n"
1769 "\t" " j .Loptimized_memcpy_12" "\n"
1771 "\t" ".Loptimized_memcpy_6:" "\n"
1772 "\t" " andi $a3, $a0, 0x3" "\n"
1773 "\t" " beqz $a3, .Loptimized_memcpy_9" "\n"
1775 "\t" " srl $a3, $a2, 2" "\n"
1776 "\t" " addiu $at, $zero, 0xC" "\n"
1777 "\t" " div $zero, $a3, $at" "\n"
1778 "\t" " mflo $a3" "\n"
1779 "\t" " mfhi $v1" "\n"
1780 "\t" " beqz $v1, .Loptimized_memcpy_8" "\n"
1782 "\t" ".Loptimized_memcpy_7:" "\n"
1783 "\t" " lw $v0, 0x0($a1)" "\n"
1784 "\t" " addiu $v1, $v1, -0x1" "\n"
1785 "\t" " swl $v0, 0x3($a0)" "\n"
1786 "\t" " swr $v0, 0x0($a0)" "\n"
1787 "\t" " addiu $a1, $a1, 0x4" "\n"
1788 "\t" " bnez $v1, .Loptimized_memcpy_7" "\n"
1789 "\t" " addiu $a0, $a0, 0x4" "\n"
1790 "\t" " beqz $a3, .Loptimized_memcpy_12" "\n"
1792 "\t" ".Loptimized_memcpy_8:" "\n"
1793 "\t" " lw $v0, 0x0($a1)" "\n"
1794 "\t" " lw $v1, 0x4($a1)" "\n"
1795 "\t" " lw $t0, 0x8($a1)" "\n"
1796 "\t" " lw $t1, 0xC($a1)" "\n"
1797 "\t" " lw $t2, 0x10($a1)" "\n"
1798 "\t" " lw $t3, 0x14($a1)" "\n"
1799 "\t" " lw $t4, 0x18($a1)" "\n"
1800 "\t" " lw $t5, 0x1C($a1)" "\n"
1801 "\t" " lw $t6, 0x20($a1)" "\n"
1802 "\t" " lw $t7, 0x24($a1)" "\n"
1803 "\t" " lw $t8, 0x28($a1)" "\n"
1804 "\t" " lw $t9, 0x2C($a1)" "\n"
1805 "\t" " addiu $a3, $a3, -0x1" "\n"
1806 "\t" " swl $v0, 0x3($a0)" "\n"
1807 "\t" " swr $v0, 0x0($a0)" "\n"
1808 "\t" " swl $v1, 0x7($a0)" "\n"
1809 "\t" " swr $v1, 0x4($a0)" "\n"
1810 "\t" " swl $t0, 0xB($a0)" "\n"
1811 "\t" " swr $t0, 0x8($a0)" "\n"
1812 "\t" " swl $t1, 0xF($a0)" "\n"
1813 "\t" " swr $t1, 0xC($a0)" "\n"
1814 "\t" " swl $t2, 0x13($a0)" "\n"
1815 "\t" " swr $t2, 0x10($a0)" "\n"
1816 "\t" " swl $t3, 0x17($a0)" "\n"
1817 "\t" " swr $t3, 0x14($a0)" "\n"
1818 "\t" " swl $t4, 0x1B($a0)" "\n"
1819 "\t" " swr $t4, 0x18($a0)" "\n"
1820 "\t" " swl $t5, 0x1F($a0)" "\n"
1821 "\t" " swr $t5, 0x1C($a0)" "\n"
1822 "\t" " swl $t6, 0x23($a0)" "\n"
1823 "\t" " swr $t6, 0x20($a0)" "\n"
1824 "\t" " swl $t7, 0x27($a0)" "\n"
1825 "\t" " swr $t7, 0x24($a0)" "\n"
1826 "\t" " swl $t8, 0x2B($a0)" "\n"
1827 "\t" " swr $t8, 0x28($a0)" "\n"
1828 "\t" " swl $t9, 0x2F($a0)" "\n"
1829 "\t" " swr $t9, 0x2C($a0)" "\n"
1830 "\t" " addiu $a1, $a1, 0x30" "\n"
1831 "\t" " bnez $a3, .Loptimized_memcpy_8" "\n"
1832 "\t" " addiu $a0, $a0, 0x30" "\n"
1833 "\t" " j .Loptimized_memcpy_12" "\n"
1835 "\t" ".Loptimized_memcpy_9:" "\n"
1836 "\t" " srl $a3, $a2, 2" "\n"
1837 "\t" " addiu $at, $zero, 0xC" "\n"
1838 "\t" " div $zero, $a3, $at" "\n"
1839 "\t" " mflo $a3" "\n"
1840 "\t" " mfhi $v1" "\n"
1841 "\t" " beqz $v1, .Loptimized_memcpy_11" "\n"
1843 "\t" ".Loptimized_memcpy_10:" "\n"
1844 "\t" " lwl $v0, 0x3($a1)" "\n"
1845 "\t" " lwr $v0, 0x0($a1)" "\n"
1846 "\t" " addiu $v1, $v1, -0x1" "\n"
1847 "\t" " sw $v0, 0x0($a0)" "\n"
1848 "\t" " addiu $a1, $a1, 0x4" "\n"
1849 "\t" " bnez $v1, .Loptimized_memcpy_10" "\n"
1850 "\t" " addiu $a0, $a0, 0x4" "\n"
1851 "\t" " beqz $a3, .Loptimized_memcpy_12" "\n"
1853 "\t" ".Loptimized_memcpy_11:" "\n"
1854 "\t" " lwl $v0, 0x3($a1)" "\n"
1855 "\t" " lwr $v0, 0x0($a1)" "\n"
1856 "\t" " lwl $v1, 0x7($a1)" "\n"
1857 "\t" " lwr $v1, 0x4($a1)" "\n"
1858 "\t" " lwl $t0, 0xB($a1)" "\n"
1859 "\t" " lwr $t0, 0x8($a1)" "\n"
1860 "\t" " lwl $t1, 0xF($a1)" "\n"
1861 "\t" " lwr $t1, 0xC($a1)" "\n"
1862 "\t" " lwl $t2, 0x13($a1)" "\n"
1863 "\t" " lwr $t2, 0x10($a1)" "\n"
1864 "\t" " lwl $t3, 0x17($a1)" "\n"
1865 "\t" " lwr $t3, 0x14($a1)" "\n"
1866 "\t" " lwl $t4, 0x1B($a1)" "\n"
1867 "\t" " lwr $t4, 0x18($a1)" "\n"
1868 "\t" " lwl $t5, 0x1F($a1)" "\n"
1869 "\t" " lwr $t5, 0x1C($a1)" "\n"
1870 "\t" " lwl $t6, 0x23($a1)" "\n"
1871 "\t" " lwr $t6, 0x20($a1)" "\n"
1872 "\t" " lwl $t7, 0x27($a1)" "\n"
1873 "\t" " lwr $t7, 0x24($a1)" "\n"
1874 "\t" " lwl $t8, 0x2B($a1)" "\n"
1875 "\t" " lwr $t8, 0x28($a1)" "\n"
1876 "\t" " lwl $t9, 0x2F($a1)" "\n"
1877 "\t" " lwr $t9, 0x2C($a1)" "\n"
1878 "\t" " addiu $a3, $a3, -0x1" "\n"
1879 "\t" " sw $v0, 0x0($a0)" "\n"
1880 "\t" " sw $v1, 0x4($a0)" "\n"
1881 "\t" " sw $t0, 0x8($a0)" "\n"
1882 "\t" " sw $t1, 0xC($a0)" "\n"
1883 "\t" " sw $t2, 0x10($a0)" "\n"
1884 "\t" " sw $t3, 0x14($a0)" "\n"
1885 "\t" " sw $t4, 0x18($a0)" "\n"
1886 "\t" " sw $t5, 0x1C($a0)" "\n"
1887 "\t" " sw $t6, 0x20($a0)" "\n"
1888 "\t" " sw $t7, 0x24($a0)" "\n"
1889 "\t" " sw $t8, 0x28($a0)" "\n"
1890 "\t" " sw $t9, 0x2C($a0)" "\n"
1891 "\t" " addiu $a1, $a1, 0x30" "\n"
1892 "\t" " bnez $a3, .Loptimized_memcpy_11" "\n"
1893 "\t" " addiu $a0, $a0, 0x30" "\n"
1894 "\t" ".Loptimized_memcpy_12:" "\n"
1895 "\t" " andi $v1, $a2, 0x3" "\n"
1896 "\t" " beqz $v1, .Loptimized_memcpy_14" "\n"
1898 "\t" ".Loptimized_memcpy_13:" "\n"
1899 "\t" " lb $v0, 0x0($a1)" "\n"
1900 "\t" " addiu $v1, $v1, -0x1" "\n"
1901 "\t" " sb $v0, 0x0($a0)" "\n"
1902 "\t" " addiu $a1, $a1, 0x1" "\n"
1903 "\t" " bnez $v1, .Loptimized_memcpy_13" "\n"
1904 "\t" " addiu $a0, $a0, 0x1" "\n"
1905 "\t" ".Loptimized_memcpy_14:" "\n"
1906 "\t" " addu $v0, $a2, $zero" "\n"
1909 "\t" ".set pop" "\n"
int CpuResumeIntr(int state)
int QueryIntrContext(void)
int CpuSuspendIntr(int *state)
int sceCdGetDiskType(void)
int sceCdRE(unsigned int lsn, unsigned int sectors, void *buf, sceCdRMode *mode)