11#include "irx_imports.h"
18IRX_ID(
"cdvd_st_driver", 2, 2);
23extern int cdvdstm_dummyentry(
void);
24extern int cdvdstm_termcall(
void);
25static unsigned int iop_stream_handler(
26 unsigned int posszarg1,
unsigned int posszarg2,
void *buffer,
int cmdid,
const sceCdRMode *rmode,
int *error_ptr);
27static unsigned int iop_stream_intr_cb(
void *userdata);
30static int cdrom_stm_devctl(
31 iop_file_t *f,
const char *name,
int cmd,
void *inbuf,
unsigned int inbuf_len,
void *outbuf,
unsigned int outbuf_len);
32static void ee_stream_handler_normal(
cdrom_stm_devctl_t *instruct,
int inbuf_len,
int *outres_ptr);
33static unsigned int ee_stream_intr_cb_normal(
void *userdata);
34static void ee_stream_handler_cdda(
cdrom_stm_devctl_t *instruct,
int inbuf_len,
int *outres_ptr);
35static unsigned int ee_stream_intr_cb_cdda(
void *userdata);
36extern unsigned int optimized_memcpy(
char *dst,
const char *src,
unsigned int n);
38static void iop_stream_intr_cb_thunk(
int userdata)
40 iop_stream_intr_cb((
void *)userdata);
43static void ee_stream_intr_cb_normal_thunk(
int userdata)
45 ee_stream_intr_cb_normal((
void *)userdata);
48static void ee_stream_intr_cb_cdda_thunk(
int userdata)
50 ee_stream_intr_cb_cdda((
void *)userdata);
53static int g_verbose_level = 0;
54static int g_cdvdstm_in_deldrv = 0;
55static int g_cdvdstm_bufmax = 0;
56static int g_cdvdstm_numbytes = 0;
57static int g_cdvdstm_bankmax = 0;
58static void *g_cdvdstm_buffer = NULL;
59static unsigned int g_cdvdstm_sectorcount = 0;
60static int g_cdvdstm_last_error_for_iop = 0;
61static int g_cdvdstm_retryerr_iop = 0;
62static int g_cdvdstm_retrycnt_iop = 0;
64IOMANX_RETURN_VALUE_IMPL(
EIO);
69 IOMANX_RETURN_VALUE(
EIO),
70 IOMANX_RETURN_VALUE(
EIO),
71 IOMANX_RETURN_VALUE(
EIO),
72 IOMANX_RETURN_VALUE(
EIO),
73 IOMANX_RETURN_VALUE(
EIO),
74 IOMANX_RETURN_VALUE(
EIO),
75 IOMANX_RETURN_VALUE(
EIO),
76 IOMANX_RETURN_VALUE(
EIO),
77 IOMANX_RETURN_VALUE(
EIO),
78 IOMANX_RETURN_VALUE(
EIO),
79 IOMANX_RETURN_VALUE(
EIO),
80 IOMANX_RETURN_VALUE(
EIO),
81 IOMANX_RETURN_VALUE(
EIO),
82 IOMANX_RETURN_VALUE(
EIO),
83 IOMANX_RETURN_VALUE(
EIO),
84 IOMANX_RETURN_VALUE(
EIO),
85 IOMANX_RETURN_VALUE(
EIO),
86 IOMANX_RETURN_VALUE(
EIO),
87 IOMANX_RETURN_VALUE(
EIO),
88 IOMANX_RETURN_VALUE(
EIO),
89 IOMANX_RETURN_VALUE_S64(
EIO),
91 IOMANX_RETURN_VALUE(
EIO),
92 IOMANX_RETURN_VALUE(
EIO),
93 IOMANX_RETURN_VALUE(
EIO),
95static iop_device_t g_cdrom_stm_dev = {
"cdrom_stm",
IOP_DT_FSEXT | IOP_DT_FS, 1,
"CD-ROM_STM ", &g_cdrom_stm_dev_ops};
96static int g_cdvdstm_last_error_for_ee = 0;
97static int g_cdvdstm_bufsz2 = 0;
98static int g_cdvdstm_chunksz2 = 0;
99static int g_cdvdstm_bankcnt2 = 0;
100static void *g_cdvdstm_buffer2 = NULL;
101static u32 g_cdvdstm_sectorcount2 = 0;
102static int g_cdvdstm_retryerr_ee = 0;
103static int g_cdvdstm_retrycnt_ee_normal = 0;
104static int g_cdvdstm_usedchunksize2 = 0x930;
105static u32 g_cdvdstm_retrycnt_ee_cdda = 0;
107static int g_cdvdstm_tgt;
108static int g_cdvdstm_semid;
109static int g_cdvdman_intr_efid;
110static char g_cdvdstm_usedmap_iop[512];
111static unsigned int g_cdvdstm_lsn_iop;
112static int g_cdvdstm_bankgp_iop;
113static int g_cdvdstm_bankcur_iop;
114static int g_cdvdstm_bankoffs_iop;
116static int g_cdvdstm_stmstart_iop;
119static int g_cdvdstm_readlbn_ee_normal;
121static u32 g_cdvdstm_readlbn_ee_cdda;
122static char g_cdvdstm_usedmap_ee[512];
123static u32 g_cdvdstm_lsn_ee;
124static int g_cdvdstm_bankgp_ee;
125static int g_cdvdstm_bankcur_ee;
126static int g_cdvdstm_bankoffs_ee;
128static int g_cdvdstm_stmstart_ee;
131static int vCancelAlarm(
unsigned int (*alarm_cb)(
void *),
void *arg)
136static int vSetEventFlag(
void)
138 return (
QueryIntrContext() ? iSetEventFlag : SetEventFlag)(g_cdvdman_intr_efid, 8);
141static int vClearEventFlag(
void)
143 return (
QueryIntrContext() ? iClearEventFlag : ClearEventFlag)(g_cdvdman_intr_efid, ~8);
146int cdvdstm_dummyentry(
void)
148 VERBOSE_PRINTF(1,
"Dummy Entry Called\n");
152int cdvdstm_termcall(
void)
157 memset(&instruct, 0,
sizeof(instruct));
158 instruct.m_cmdid = 3;
162 ee_stream_handler_normal(&instruct, 0x14, &outres);
167static int stm_iop_read_timeout_alarm_cb(
const iop_sys_clock_t *sys_clock)
169 KPRINTF(
"Stm Iop Read Time Out %d(msec)\n", sys_clock->lo / 0x9000);
173static int sceCdStream0_inner(
unsigned int rdsize,
char *addrarg,
int modearg,
int *error_ptr)
176 unsigned int streamres;
181 VERBOSE_KPRINTF(1,
"sceCdStream0 call read size= %d mode= %d addr= %08x\n", rdsize, modearg, addrarg);
183 if ( !sceCdSC(0xFFFFFFFF, &last_error) )
187 return iop_stream_handler(0, rdsize, addrarg, 2, &g_rmode_for_stream0, error_ptr);
191 while ( (!err || streamres) )
193 WaitEventFlag(g_cdvdman_intr_efid, 8, WEF_AND, &efbits);
194 streamres = iop_stream_handler(0, rdsize - cur_size, &addrarg[cur_size], 2, &g_rmode_for_stream0, &err);
195 if ( rdsize - cur_size != streamres )
197 cur_size += streamres;
200 VERBOSE_KPRINTF(1,
"sceCdStream0 BLK cur_size= %d req_size= %d err 0x%x\n", cur_size, rdsize, err);
201 if ( (
unsigned int)cur_size == rdsize )
207static int sceCdStream0(
int rdsize_sectors,
char *addrarg,
int modearg,
int *error_ptr)
209 return sceCdStream0_inner(rdsize_sectors << 11, addrarg, modearg, error_ptr) / 0x800;
212static unsigned int iop_stream_handler(
213 unsigned int posszarg1,
unsigned int posszarg2,
void *buffer,
int cmdid,
const sceCdRMode *rmode,
int *error_ptr)
218 unsigned int written_chunk_size_tmp;
219 int bankcur_next_tmp1;
221 int bankcur_next_tmp2;
225 VERBOSE_KPRINTF(1,
"CD Stream Call mode= %d\n", cmdid);
227 if ( g_cdvdstm_stmstart_iop == 2 && cmdid != 9 && cmdid != 3 )
234 sceCdSC(1, &g_cdvdstm_last_error_for_iop);
237 sceCdSC(0, &g_cdvdstm_last_error_for_iop);
241 vCancelAlarm((
unsigned int (*)(
void *))iop_stream_intr_cb, &g_cdvdstm_curclk_iop);
242 sceCdSC(0, &g_cdvdstm_last_error_for_iop);
245 vCancelAlarm((
unsigned int (*)(
void *))stm_iop_read_timeout_alarm_cb, &g_cdvdstm_curclk_iop);
248 bankcur_tmp = g_cdvdstm_bankcur_iop;
249 if ( !g_cdvdstm_usedmap_iop[bankcur_tmp] )
252 if ( (
unsigned int)bankcur_tmp >= (
unsigned int)g_cdvdstm_bankmax )
254 if ( !g_cdvdstm_usedmap_iop[bankcur_tmp] )
255 bankcur_tmp = g_cdvdstm_bankcur_iop;
257 for ( i = 0; (i < (
unsigned int)g_cdvdstm_bankmax) && g_cdvdstm_usedmap_iop[bankcur_tmp]
258 && (g_cdvdstm_bankgp_iop != bankcur_tmp);
262 if ( (
unsigned int)bankcur_tmp >= (
unsigned int)g_cdvdstm_bankmax )
265 return i * ((
unsigned int)g_cdvdstm_numbytes >> 11);
267 sceCdstm0Cb((
void (*)(
int))iop_stream_intr_cb_thunk);
268 g_cdvdstm_bufmax = posszarg1;
269 g_cdvdstm_sectorcount = posszarg1 / posszarg2;
270 g_cdvdstm_numbytes = g_cdvdstm_sectorcount << 11;
271 g_cdvdstm_buffer = buffer;
272 g_cdvdstm_bankmax = posszarg2;
274 "Stream Buffer 1Bank %dbyte %dbanks addr:%08x %dbyte used.\n",
278 g_cdvdstm_numbytes * posszarg2);
282 g_cdvdstm_stmstart_iop = 0;
283 vCancelAlarm((
unsigned int (*)(
void *))iop_stream_intr_cb, &g_cdvdstm_curclk_iop);
284 sceCdSC(0, &g_cdvdstm_last_error_for_iop);
287 for ( i = 0; i < (
unsigned int)g_cdvdstm_bankmax; i += 1 )
288 g_cdvdstm_usedmap_iop[i] = 0;
289 g_cdvdstm_bankoffs_iop = 0;
290 g_cdvdstm_bankcur_iop = 0;
291 g_cdvdstm_bankgp_iop = 0;
293 g_cdvdstm_last_error_for_iop = 0;
294 sceCdSC(0xFFFFFFFE, &g_cdvdstm_last_error_for_iop);
295 vCancelAlarm((
unsigned int (*)(
void *))stm_iop_read_timeout_alarm_cb, &g_cdvdstm_curclk_iop);
298 if ( sceCdSC(0xFFFFFFFF, &g_cdvdstm_last_error_for_iop) )
301 g_cdvdstm_lsn_iop = posszarg1;
302 for ( i = 0; i < (
unsigned int)g_cdvdstm_bankmax; i += 1 )
303 g_cdvdstm_usedmap_iop[i] = 0;
304 g_cdvdstm_stmstart_iop = 2;
313 g_cdvdstm_retryerr_iop = 0;
317 vCancelAlarm((
unsigned int (*)(
void *))iop_stream_intr_cb, &g_cdvdstm_curclk_iop);
318 sceCdSC(0, &g_cdvdstm_last_error_for_iop);
323 g_cdvdstm_lsn_iop = posszarg1;
324 g_cdvdstm_bankoffs_iop = 0;
325 g_cdvdstm_bankcur_iop = 0;
326 g_cdvdstm_bankgp_iop = 0;
328 vCancelAlarm((
unsigned int (*)(
void *))stm_iop_read_timeout_alarm_cb, &g_cdvdstm_curclk_iop);
335 vCancelAlarm((
unsigned int (*)(
void *))iop_stream_intr_cb, &g_cdvdstm_curclk_iop);
336 sceCdSC(0, &g_cdvdstm_last_error_for_iop);
338 for ( i = 0; i < (
unsigned int)g_cdvdstm_bankmax; i += 1 )
339 g_cdvdstm_usedmap_iop[i] = 0;
340 g_cdvdstm_lsn_iop = posszarg1;
341 sceCdSC(0xFFFFFFE9, (
int *)&g_cdvdstm_lsn_iop);
342 g_cdvdstm_bankoffs_iop = 0;
343 g_cdvdstm_bankcur_iop = 0;
344 g_cdvdstm_bankgp_iop = 0;
346 vCancelAlarm((
unsigned int (*)(
void *))stm_iop_read_timeout_alarm_cb, &g_cdvdstm_curclk_iop);
347 g_cdvdstm_stmstart_iop = 1;
348 sceCdSC(1, &g_cdvdstm_last_error_for_iop);
351 sceCdSC(0, &g_cdvdstm_last_error_for_iop);
356 written_chunk_size_tmp = -1;
357 for ( i = 0; i < posszarg2; i += chunk_size )
359 if ( !g_cdvdstm_usedmap_iop[g_cdvdstm_bankcur_iop] )
363 "CD read buffer over run %d %d %d %d %d gp %d pp %d\n",
364 (u8)g_cdvdstm_usedmap_iop[0],
365 (u8)g_cdvdstm_usedmap_iop[1],
366 (u8)g_cdvdstm_usedmap_iop[2],
367 (u8)g_cdvdstm_usedmap_iop[3],
368 (u8)g_cdvdstm_usedmap_iop[4],
369 g_cdvdstm_bankgp_iop,
370 g_cdvdstm_bankcur_iop);
371 bankcur_next_tmp1 = g_cdvdstm_bankcur_iop;
372 g_cdvdstm_bankcur_iop += 1;
373 if ( (
unsigned int)g_cdvdstm_bankcur_iop >= (
unsigned int)g_cdvdstm_bankmax )
374 g_cdvdstm_bankcur_iop = 0;
375 written_chunk_size_tmp = i;
376 if ( !g_cdvdstm_usedmap_iop[g_cdvdstm_bankcur_iop] )
378 g_cdvdstm_bankcur_iop = bankcur_next_tmp1;
382 if ( (
unsigned int)g_cdvdstm_bankoffs_iop >= (
unsigned int)g_cdvdstm_numbytes )
384 g_cdvdstm_bankoffs_iop = 0;
385 g_cdvdstm_usedmap_iop[g_cdvdstm_bankcur_iop] = 0;
386 bankcur_next_tmp2 = g_cdvdstm_bankcur_iop;
387 g_cdvdstm_bankcur_iop += 1;
388 if ( (
unsigned int)g_cdvdstm_bankcur_iop >= (
unsigned int)g_cdvdstm_bankmax )
389 g_cdvdstm_bankcur_iop = 0;
390 if ( !g_cdvdstm_usedmap_iop[g_cdvdstm_bankcur_iop] || g_cdvdstm_bankgp_iop == g_cdvdstm_bankcur_iop )
392 g_cdvdstm_bankcur_iop = bankcur_next_tmp2;
393 written_chunk_size_tmp = i;
396 "CD read buffer over run %d %d %d %d %d gp %d pp %d\n",
397 (u8)g_cdvdstm_usedmap_iop[0],
398 (u8)g_cdvdstm_usedmap_iop[1],
399 (u8)g_cdvdstm_usedmap_iop[2],
400 (u8)g_cdvdstm_usedmap_iop[3],
401 (u8)g_cdvdstm_usedmap_iop[4],
402 g_cdvdstm_bankgp_iop,
403 g_cdvdstm_bankcur_iop);
408 &((
char *)buffer)[i],
409 &((
char *)g_cdvdstm_buffer)[g_cdvdstm_bankcur_iop * g_cdvdstm_numbytes + g_cdvdstm_bankoffs_iop],
411 chunk_size = ((
unsigned int)0x800 > posszarg2 - i) ? (posszarg2 - i) : 0x800;
412 g_cdvdstm_bankoffs_iop += chunk_size;
414 if ( written_chunk_size_tmp == 0xFFFFFFFF )
415 written_chunk_size_tmp = posszarg2;
419 if ( sceCdSC(0xFFFFFFFF, &g_cdvdstm_last_error_for_iop) != 1 && !written_chunk_size_tmp && !g_cdvdstm_retryerr_iop )
421 g_cdvdstm_retryerr_iop = 273;
423 *error_ptr = g_cdvdstm_retryerr_iop;
424 g_cdvdstm_retryerr_iop = 0;
425 return written_chunk_size_tmp;
430static unsigned int iop_stream_intr_cb(
void *userdata)
437 VERBOSE_KPRINTF(1,
"Intr Read call\n");
438 iCancelAlarm((
unsigned int (*)(
void *))stm_iop_read_timeout_alarm_cb, &g_cdvdstm_curclk_iop);
439 iCancelAlarm((
unsigned int (*)(
void *))iop_stream_intr_cb, &g_cdvdstm_curclk_iop);
440 sceCdSC(0xFFFFFFFF, &last_error);
443#ifdef CDVD_VARIANT_XOSD
444 switch ( sceCdSC(0xFFFFFFDA, &scres_unused) )
460 g_cdvdstm_curclk_iop.hi = 0;
461 if ( g_cdvdstm_stmstart_iop )
462 g_cdvdstm_retrycnt_iop = 0;
463 if ( g_cdvdstm_stmstart_iop || last_error || g_cdvdstm_retrycnt_iop )
466 1,
"Stm Rtry stmstart:%d err:%02x retry:%d\n", g_cdvdstm_stmstart_iop, last_error, g_cdvdstm_retrycnt_iop);
468 g_cdvdstm_curclk_iop.lo = (g_cdvdstm_stmstart_iop || last_error || g_cdvdstm_retrycnt_iop) ?
470 (0x9000 * sceCdSC(0xFFFFFFEF, &scres_unused));
473 VERBOSE_KPRINTF(1,
"IOP Stream read Error code= 0x%02x retry= %d\n", last_error, g_cdvdstm_retrycnt_iop);
476 VERBOSE_KPRINTF(1,
"On err %08x\n", last_error);
477 if ( g_cdvdstm_retrycnt_iop )
478 g_cdvdstm_retryerr_iop = last_error;
479 g_cdvdstm_retrycnt_iop = 3;
483 g_cdvdstm_retryerr_iop = last_error;
484 g_cdvdstm_retrycnt_iop = 1;
487 if ( g_cdvdstm_retrycnt_iop )
491 g_cdvdstm_retrycnt_iop -= 1;
492 tgttmp = ((
unsigned int)g_cdvdstm_tgt >= (
unsigned int)(0x10 * g_cdvdstm_retrycnt_iop)) ?
493 (g_cdvdstm_tgt - 0x10 * g_cdvdstm_retrycnt_iop) :
494 (g_cdvdstm_tgt + 0x10 * g_cdvdstm_retrycnt_iop);
495 VERBOSE_KPRINTF(1,
"Stm Rtry Start Tgt=%d Cur= %d\n", g_cdvdstm_tgt, tgttmp);
498 g_cdvdstm_sectorcount,
499 (
char *)g_cdvdstm_buffer + g_cdvdstm_bankgp_iop * g_cdvdstm_numbytes,
500 &g_cdvdstm_mode_iop) )
502 iSetAlarm(&g_cdvdstm_curclk_iop, (
unsigned int (*)(
void *))stm_iop_read_timeout_alarm_cb, &g_cdvdstm_curclk_iop);
506 g_cdvdstm_curclk_iop.lo = 0x708000;
508 iSetAlarm(&g_cdvdstm_curclk_iop, (
unsigned int (*)(
void *))iop_stream_intr_cb, &g_cdvdstm_curclk_iop)
511 sceCdSC(0, &last_error);
513 g_cdvdstm_retrycnt_iop += 1;
521 if ( !g_cdvdstm_stmstart_iop )
523 g_cdvdstm_usedmap_iop[g_cdvdstm_bankgp_iop] = 1;
524 gptmp = g_cdvdstm_bankgp_iop;
525 g_cdvdstm_bankgp_iop += 1;
526 if ( (
unsigned int)g_cdvdstm_bankgp_iop >= (
unsigned int)g_cdvdstm_bankmax )
527 g_cdvdstm_bankgp_iop = 0;
530 !g_cdvdstm_stmstart_iop
531 && (g_cdvdstm_usedmap_iop[g_cdvdstm_bankgp_iop] || g_cdvdstm_bankcur_iop == g_cdvdstm_bankgp_iop) )
533 g_cdvdstm_bankgp_iop = gptmp;
534 g_cdvdstm_usedmap_iop[gptmp] = 0;
537 "read Full %d %d %d %d %d gp %d pp %d spn %d\n",
538 (u8)g_cdvdstm_usedmap_iop[0],
539 (u8)g_cdvdstm_usedmap_iop[1],
540 (u8)g_cdvdstm_usedmap_iop[2],
541 (u8)g_cdvdstm_usedmap_iop[3],
542 (u8)g_cdvdstm_usedmap_iop[4],
543 g_cdvdstm_bankgp_iop,
544 g_cdvdstm_bankcur_iop,
546 g_cdvdstm_curclk_iop.lo = 0x48000;
548 iSetAlarm(&g_cdvdstm_curclk_iop, (
unsigned int (*)(
void *))iop_stream_intr_cb, &g_cdvdstm_curclk_iop)
551 sceCdSC(0, &last_error);
556 if ( g_cdvdstm_stmstart_iop == 2 )
560 g_cdvdstm_bankoffs_iop = 0;
561 g_cdvdstm_bankcur_iop = 0;
562 g_cdvdstm_bankgp_iop = 0;
563 for ( i = 0; i < (
unsigned int)g_cdvdstm_bankmax; i += 1 )
564 g_cdvdstm_usedmap_iop[i] = 0;
566 g_cdvdstm_stmstart_iop = 0;
567 g_cdvdstm_tgt = g_cdvdstm_lsn_iop;
570 g_cdvdstm_sectorcount,
571 (
char *)g_cdvdstm_buffer + g_cdvdstm_bankgp_iop * g_cdvdstm_numbytes,
572 &g_cdvdstm_mode_iop) )
575 &g_cdvdstm_curclk_iop, (
unsigned int (*)(
void *))stm_iop_read_timeout_alarm_cb, &g_cdvdstm_curclk_iop);
579 g_cdvdstm_curclk_iop.lo = 0x708000;
581 iSetAlarm(&g_cdvdstm_curclk_iop, (
unsigned int (*)(
void *))iop_stream_intr_cb, &g_cdvdstm_curclk_iop)
584 sceCdSC(0, &last_error);
586 g_cdvdstm_retrycnt_iop = 1;
588 g_cdvdstm_lsn_iop += g_cdvdstm_sectorcount;
599 semaparam.attr = SA_THPRI;
600 semaparam.initial = 1;
602 semaparam.option = 0;
603 g_cdvdstm_semid = CreateSema(&semaparam);
610 SignalSema(g_cdvdstm_semid);
611 DeleteSema(g_cdvdstm_semid);
615static int cdrom_stm_devctl(
616 iop_file_t *f,
const char *name,
int cmd,
void *inbuf,
unsigned int inbuf_len,
void *outbuf,
unsigned int outbuf_len)
628 WaitSema(g_cdvdstm_semid);
630 if ( g_cdvdstm_in_deldrv )
632 SignalSema(g_cdvdstm_semid);
638 if ( instruct->m_cmdid == 5 || instruct->m_cmdid == 3 || instruct->m_cmdid - 7 < 2 )
642 *outres_ptr = iop_stream_handler(
643 instruct->m_posszarg1,
644 instruct->m_posszarg2,
648 (
int *)&instruct->m_error);
652 sceCdStream0(instruct->m_posszarg2, (
char *)instruct->m_buffer, instruct->m_cmdid, (
int *)&instruct->m_error);
655 ee_stream_handler_normal(instruct, inbuf_len, outres_ptr);
658 ee_stream_handler_cdda(instruct, inbuf_len, outres_ptr);
662 PRINTF(
"Un-support devctl %08x\n", cmd);
666 SignalSema(g_cdvdstm_semid);
670int _start(
int ac,
char *av[],
void *startaddr,
ModuleInfo_t *mi)
683 if ( !sceCdSC(0xFFFFFFFF, &last_error) )
685 return MODULE_REMOVABLE_END;
687 g_cdvdstm_in_deldrv = 1;
688 DelDrv(g_cdrom_stm_dev.name);
690 relres = ReleaseLibraryEntries(&_exp_cdvdstm);
692 g_cdvdstm_in_deldrv = 0;
693 if ( relres && relres != KE_LIBRARY_NOTFOUND )
695 g_cdvdstm_in_deldrv = 0;
696 return MODULE_REMOVABLE_END;
698 return MODULE_NO_RESIDENT_END;
700 if ( RegisterLibraryEntries(&_exp_cdvdstm) )
701 return MODULE_NO_RESIDENT_END;
702 DelDrv(g_cdrom_stm_dev.name);
703 if ( AddDrv(&g_cdrom_stm_dev) )
705 cdrom_stm_deinit(&g_cdrom_stm_dev);
706 return MODULE_NO_RESIDENT_END;
708 g_cdvdman_intr_efid = sceCdSC(0xFFFFFFF5, &scres_unused);
710 return MODULE_REMOVABLE_END;
712 if ( mi && ((mi->
newflags & 2) != 0) )
714 return MODULE_RESIDENT_END;
718static int vsceSifDmaStat(
int dmat)
720#ifdef CDVD_VARIANT_XOSD
725 return sceSifDmaStat(dmat);
727 st = sceSifDmaStat(dmat);
731 return sceSifDmaStat(dmat);
735static int stm_ee_read_timeout_alarm_cb(
const iop_sys_clock_t *sys_clock)
739 read_timeout = sys_clock->lo / 0x9000;
740 KPRINTF(
"Stm EE Read Time Out %d(msec)\n", read_timeout);
741 sceCdSC(0xFFFFFFEE, &read_timeout);
745static void ee_stream_handler_normal(
cdrom_stm_devctl_t *instruct,
int inbuf_len,
int *outres_ptr)
751 unsigned int chunks_sectors;
752 int bankcur_next_tmp1;
753 int posszarg2_bytes_clamped;
755 int bankcur_next_tmp2;
756 int posszarg2_bytes_overrun;
764 cmdid = instruct->m_cmdid;
765 if ( g_cdvdstm_stmstart_ee == 2 && (cmdid != 9 && cmdid != 3) )
773 sceCdSC(2, &g_cdvdstm_last_error_for_ee);
776 sceCdSC(0, &g_cdvdstm_last_error_for_ee);
784 CancelAlarm((
unsigned int (*)(
void *))ee_stream_intr_cb_normal, &g_cdvdstm_curclk_ee);
785 sceCdSC(0, &g_cdvdstm_last_error_for_ee);
789 CancelAlarm((
unsigned int (*)(
void *))stm_ee_read_timeout_alarm_cb, &g_cdvdstm_curclk_ee);
792 bankcur_tmp = g_cdvdstm_bankcur_ee;
793 if ( !g_cdvdstm_usedmap_ee[bankcur_tmp] )
796 if ( (
unsigned int)bankcur_tmp >= (
unsigned int)g_cdvdstm_bankcnt2 )
798 if ( !g_cdvdstm_usedmap_ee[bankcur_tmp] )
799 bankcur_tmp = g_cdvdstm_bankcur_ee;
801 for ( i = 0; (i < (
unsigned int)g_cdvdstm_bankcnt2) && g_cdvdstm_usedmap_ee[bankcur_tmp]
802 && (g_cdvdstm_bankgp_ee != bankcur_tmp);
806 if ( (
unsigned int)bankcur_tmp >= (
unsigned int)g_cdvdstm_bankcnt2 )
809 *outres_ptr = i * ((
unsigned int)g_cdvdstm_chunksz2 >> 11);
812 sceCdstm1Cb((
void (*)(
int))ee_stream_intr_cb_normal_thunk);
813 if ( !instruct->m_posszarg2 )
815 chunks_sectors = instruct->m_posszarg1 / instruct->m_posszarg2;
816 g_cdvdstm_bufsz2 = instruct->m_posszarg1;
817 g_cdvdstm_sectorcount2 = chunks_sectors;
818 g_cdvdstm_chunksz2 = chunks_sectors << 11;
819 g_cdvdstm_buffer2 = (
char *)instruct->m_buffer;
820 g_cdvdstm_bankcnt2 = instruct->m_posszarg2;
822 "Stream Buffer 1Bank %dbyte %dbanks %dbyte used\n",
823 (
int)(chunks_sectors << 11),
824 (
int)(instruct->m_posszarg2),
825 (
int)((chunks_sectors << 11) * (instruct->m_posszarg2)));
830 g_cdvdstm_stmstart_ee = 0;
831 CancelAlarm((
unsigned int (*)(
void *))ee_stream_intr_cb_normal, &g_cdvdstm_curclk_ee);
832 sceCdSC(0, &g_cdvdstm_last_error_for_ee);
835 for ( i = 0; i < (
unsigned int)g_cdvdstm_bankcnt2; i += 1 )
837 g_cdvdstm_usedmap_ee[i] = 0;
839 g_cdvdstm_bankoffs_ee = 0;
840 g_cdvdstm_bankcur_ee = 0;
841 g_cdvdstm_bankgp_ee = 0;
844 g_cdvdstm_last_error_for_ee = 0;
845 sceCdSC(0xFFFFFFFE, &g_cdvdstm_last_error_for_ee);
846 CancelAlarm((
unsigned int (*)(
void *))stm_ee_read_timeout_alarm_cb, &g_cdvdstm_curclk_ee);
852 g_cdvdstm_retryerr_ee = 0;
855 posszarg2_bytes = instruct->m_posszarg2 << 11;
858 if ( sceCdSC(0xFFFFFFFF, &g_cdvdstm_last_error_for_ee) )
861 g_cdvdstm_lsn_ee = instruct->m_posszarg1;
862 for ( i = 0; i < (
unsigned int)g_cdvdstm_bankcnt2; i += 1 )
864 g_cdvdstm_usedmap_ee[i] = 0;
866 g_cdvdstm_stmstart_ee = 2;
878 CancelAlarm((
unsigned int (*)(
void *))ee_stream_intr_cb_normal, &g_cdvdstm_curclk_ee);
879 sceCdSC(0, &g_cdvdstm_last_error_for_ee);
883 g_cdvdstm_lsn_ee = instruct->m_posszarg1;
884 g_cdvdstm_bankoffs_ee = 0;
885 g_cdvdstm_bankcur_ee = 0;
886 g_cdvdstm_bankgp_ee = 0;
888 CancelAlarm((
unsigned int (*)(
void *))stm_ee_read_timeout_alarm_cb, &g_cdvdstm_curclk_ee);
893 CancelAlarm((
unsigned int (*)(
void *))ee_stream_intr_cb_normal, &g_cdvdstm_curclk_ee);
894 sceCdSC(0, &g_cdvdstm_last_error_for_ee);
897 for ( i = 0; i < (
unsigned int)g_cdvdstm_bankcnt2; i += 1 )
899 g_cdvdstm_usedmap_ee[i] = 0;
901 g_cdvdstm_lsn_ee = instruct->m_posszarg1;
902 sceCdSC(0xFFFFFFE9, (
int *)&g_cdvdstm_lsn_ee);
903 g_cdvdstm_bankoffs_ee = 0;
904 g_cdvdstm_bankcur_ee = 0;
906 CancelAlarm((
unsigned int (*)(
void *))stm_ee_read_timeout_alarm_cb, &g_cdvdstm_curclk_ee);
907 g_cdvdstm_stmstart_ee = 1;
908 sceCdSC(2, &g_cdvdstm_last_error_for_ee);
911 sceCdSC(0, &g_cdvdstm_last_error_for_ee);
916 posszarg2_bytes_overrun = -1;
917 for ( i = 0; i < posszarg2_bytes; i += posszarg2_bytes_clamped )
919 unsigned int posszarg2_bytes_remain;
921 posszarg2_bytes_remain = posszarg2_bytes - i;
922 if ( !g_cdvdstm_usedmap_ee[g_cdvdstm_bankcur_ee] )
926 "CD read buffer over run %d %d %d %d %d gp %d pp %d\n",
927 (u8)g_cdvdstm_usedmap_ee[0],
928 (u8)g_cdvdstm_usedmap_ee[1],
929 (u8)g_cdvdstm_usedmap_ee[2],
930 (u8)g_cdvdstm_usedmap_ee[3],
931 (u8)g_cdvdstm_usedmap_ee[4],
933 g_cdvdstm_bankcur_ee);
935 bankcur_next_tmp1 = g_cdvdstm_bankcur_ee;
936 g_cdvdstm_bankcur_ee += 1;
937 if ( (
unsigned int)g_cdvdstm_bankcur_ee >= (
unsigned int)g_cdvdstm_bankcnt2 )
938 g_cdvdstm_bankcur_ee = 0;
939 if ( !g_cdvdstm_usedmap_ee[g_cdvdstm_bankcur_ee] )
940 g_cdvdstm_bankcur_ee = bankcur_next_tmp1;
941 posszarg2_bytes_overrun = posszarg2_bytes - posszarg2_bytes_remain;
945 posszarg2_bytes_clamped = ((
unsigned int)(g_cdvdstm_chunksz2 - g_cdvdstm_bankoffs_ee) < posszarg2_bytes_remain) ?
946 (
unsigned int)(g_cdvdstm_chunksz2 - g_cdvdstm_bankoffs_ee) :
947 posszarg2_bytes_remain;
948 g_cdvdstm_dmat.dest = ((
char *)instruct->m_buffer) + i;
949 g_cdvdstm_dmat.size = posszarg2_bytes_clamped;
950 g_cdvdstm_dmat.attr = 0;
951 g_cdvdstm_dmat.src = (
char *)g_cdvdstm_buffer2 + g_cdvdstm_bankcur_ee * g_cdvdstm_chunksz2 + g_cdvdstm_bankoffs_ee;
952 if ( posszarg2_bytes_clamped )
957 dmat1 = sceSifSetDma(&g_cdvdstm_dmat, 1);
963 g_cdvdstm_bankoffs_ee += posszarg2_bytes_clamped;
964 while ( vsceSifDmaStat(dmat1) >= 0 )
967 if ( (
unsigned int)g_cdvdstm_bankoffs_ee >= (
unsigned int)g_cdvdstm_chunksz2 )
970 g_cdvdstm_bankoffs_ee = 0;
971 g_cdvdstm_usedmap_ee[g_cdvdstm_bankcur_ee] = 0;
972 bankcur_next_tmp2 = g_cdvdstm_bankcur_ee;
973 g_cdvdstm_bankcur_ee += 1;
974 if ( (
unsigned int)g_cdvdstm_bankcur_ee >= (
unsigned int)g_cdvdstm_bankcnt2 )
975 g_cdvdstm_bankcur_ee = 0;
976 if ( g_cdvdstm_usedmap_ee[g_cdvdstm_bankcur_ee] && g_cdvdstm_bankgp_ee != g_cdvdstm_bankcur_ee )
982 g_cdvdstm_bankcur_ee = bankcur_next_tmp2;
986 "CD read buffer over run %d %d %d %d %d gp %d pp %d\n",
987 (u8)g_cdvdstm_usedmap_ee[0],
988 (u8)g_cdvdstm_usedmap_ee[1],
989 (u8)g_cdvdstm_usedmap_ee[2],
990 (u8)g_cdvdstm_usedmap_ee[3],
991 (u8)g_cdvdstm_usedmap_ee[4],
993 g_cdvdstm_bankcur_ee);
994 posszarg2_bytes_overrun = posszarg2_bytes - (posszarg2_bytes_remain - posszarg2_bytes_clamped);
999 if ( posszarg2_bytes_overrun == -1 )
1000 posszarg2_bytes_overrun = posszarg2_bytes;
1001 outres_tmp2 = (retryflag) ? 1 : (posszarg2_bytes_overrun / 0x800);
1004 if ( sceCdSC(0xFFFFFFFF, &g_cdvdstm_last_error_for_ee) != 2 && !outres_tmp2 && !g_cdvdstm_retryerr_ee )
1005 g_cdvdstm_retryerr_ee = 273;
1006 if ( g_cdvdstm_retryerr_ee )
1008 outres_tmp2 = (u16)outres_tmp2 | (g_cdvdstm_retryerr_ee << 16);
1009 g_cdvdstm_retryerr_ee = 0;
1012 *outres_ptr = outres_tmp2;
1016static unsigned int ee_stream_intr_cb_normal(
void *userdata)
1022 VERBOSE_KPRINTF(1,
"Intr EE Stm Read call\n");
1023 iCancelAlarm((
unsigned int (*)(
void *))stm_ee_read_timeout_alarm_cb, &g_cdvdstm_curclk_ee);
1024 iCancelAlarm((
unsigned int (*)(
void *))ee_stream_intr_cb_normal, &g_cdvdstm_curclk_ee);
1025 sceCdSC(0xFFFFFFFF, &g_cdvdstm_last_error_for_ee);
1026 if ( !g_cdvdstm_last_error_for_ee )
1028#ifdef CDVD_VARIANT_XOSD
1029 switch ( sceCdSC(0xFFFFFFDA, &scres_unused) )
1045 g_cdvdstm_curclk_ee.hi = 0;
1046 if ( g_cdvdstm_stmstart_ee )
1047 g_cdvdstm_retrycnt_ee_normal = 0;
1048 g_cdvdstm_curclk_ee.lo = (g_cdvdstm_stmstart_ee || g_cdvdstm_last_error_for_ee || g_cdvdstm_retrycnt_ee_normal) ?
1050 (0x9000 * sceCdSC(0xFFFFFFEF, &scres_unused));
1051 if ( g_cdvdstm_last_error_for_ee )
1055 "EE Stream read LBN= %d Error code= 0x%02x retry= %d\n",
1056 g_cdvdstm_readlbn_ee_normal,
1057 g_cdvdstm_last_error_for_ee,
1058 g_cdvdstm_retrycnt_ee_normal);
1061 if ( g_cdvdstm_retrycnt_ee_normal )
1063 VERBOSE_KPRINTF(1,
"On Retry retry %d err %08x\n", g_cdvdstm_retrycnt_ee_normal, g_cdvdstm_last_error_for_ee);
1065 g_cdvdstm_retrycnt_ee_normal = 3;
1069 g_cdvdstm_retrycnt_ee_normal = 1;
1071 g_cdvdstm_retryerr_ee = g_cdvdstm_last_error_for_ee;
1073 if ( g_cdvdstm_retrycnt_ee_normal )
1075 g_cdvdstm_retrycnt_ee_normal -= 1;
1077 ((
unsigned int)g_cdvdstm_readlbn_ee_normal >= (
unsigned int)(0x10 * g_cdvdstm_retrycnt_ee_normal)) ?
1078 (g_cdvdstm_readlbn_ee_normal - 0x10 * g_cdvdstm_retrycnt_ee_normal) :
1079 (g_cdvdstm_readlbn_ee_normal + 0x10 * g_cdvdstm_retrycnt_ee_normal),
1080 g_cdvdstm_sectorcount2,
1081 (
char *)g_cdvdstm_buffer2 + g_cdvdstm_bankgp_ee * g_cdvdstm_chunksz2,
1082 &g_cdvdstm_mode_ee) )
1084 iSetAlarm(&g_cdvdstm_curclk_ee, (
unsigned int (*)(
void *))stm_ee_read_timeout_alarm_cb, &g_cdvdstm_curclk_ee);
1088 VERBOSE_KPRINTF(1,
"Stm Read Call fail\n");
1089 g_cdvdstm_curclk_ee.lo = 0x708000;
1091 iSetAlarm(&g_cdvdstm_curclk_ee, (
unsigned int (*)(
void *))ee_stream_intr_cb_normal, &g_cdvdstm_curclk_ee)
1094 sceCdSC(0, &g_cdvdstm_last_error_for_ee);
1096 g_cdvdstm_retrycnt_ee_normal += 1;
1103 if ( !g_cdvdstm_stmstart_ee )
1105 g_cdvdstm_usedmap_ee[g_cdvdstm_bankgp_ee] = 1;
1106 gptmp = g_cdvdstm_bankgp_ee;
1107 g_cdvdstm_bankgp_ee += 1;
1108 if ( (
unsigned int)g_cdvdstm_bankgp_ee >= (
unsigned int)g_cdvdstm_bankcnt2 )
1109 g_cdvdstm_bankgp_ee = 0;
1112 !g_cdvdstm_stmstart_ee
1113 && (g_cdvdstm_usedmap_ee[g_cdvdstm_bankgp_ee] || g_cdvdstm_bankcur_ee == g_cdvdstm_bankgp_ee) )
1115 g_cdvdstm_bankgp_ee = gptmp;
1116 g_cdvdstm_usedmap_ee[gptmp] = 0;
1119 "read Full %d %d %d %d %d gp %d pp %d spn %d\n",
1120 (u8)g_cdvdstm_usedmap_ee[0],
1121 (u8)g_cdvdstm_usedmap_ee[1],
1122 (u8)g_cdvdstm_usedmap_ee[2],
1123 (u8)g_cdvdstm_usedmap_ee[3],
1124 (u8)g_cdvdstm_usedmap_ee[4],
1125 g_cdvdstm_bankgp_ee,
1126 g_cdvdstm_bankcur_ee,
1128 g_cdvdstm_curclk_ee.lo = 0x48000;
1130 iSetAlarm(&g_cdvdstm_curclk_ee, (
unsigned int (*)(
void *))ee_stream_intr_cb_normal, &g_cdvdstm_curclk_ee)
1133 sceCdSC(0, &g_cdvdstm_last_error_for_ee);
1138 if ( g_cdvdstm_stmstart_ee == 2 )
1142 g_cdvdstm_bankoffs_ee = 0;
1143 g_cdvdstm_bankcur_ee = 0;
1144 g_cdvdstm_bankgp_ee = 0;
1145 for ( i = 0; i < (
unsigned int)g_cdvdstm_bankcnt2; i += 1 )
1146 g_cdvdstm_usedmap_ee[i] = 0;
1148 g_cdvdstm_stmstart_ee = 0;
1149 g_cdvdstm_readlbn_ee_normal = g_cdvdstm_lsn_ee;
1152 g_cdvdstm_sectorcount2,
1153 (
char *)g_cdvdstm_buffer2 + g_cdvdstm_bankgp_ee * g_cdvdstm_chunksz2,
1154 &g_cdvdstm_mode_ee) )
1156 iSetAlarm(&g_cdvdstm_curclk_ee, (
unsigned int (*)(
void *))stm_ee_read_timeout_alarm_cb, &g_cdvdstm_curclk_ee);
1160 VERBOSE_KPRINTF(1,
"Stm Read Call1 fail\n");
1161 g_cdvdstm_curclk_ee.lo = 0x708000;
1163 iSetAlarm(&g_cdvdstm_curclk_ee, (
unsigned int (*)(
void *))ee_stream_intr_cb_normal, &g_cdvdstm_curclk_ee)
1166 sceCdSC(0, &g_cdvdstm_last_error_for_ee);
1168 g_cdvdstm_retrycnt_ee_normal = 1;
1170 g_cdvdstm_lsn_ee += g_cdvdstm_sectorcount2;
1176static void ee_stream_handler_cdda(
cdrom_stm_devctl_t *instruct,
int inbuf_len,
int *outres_ptr)
1179 u32 posszarg2_bytes;
1183 int bankcur_next_tmp1;
1184 int posszarg2_bytes_clamped;
1186 int bankcur_next_tmp2;
1187 int posszarg2_overrun_chunks2;
1188 unsigned int posszarg2_bytes_overrun;
1194 cmdid = instruct->m_cmdid;
1195 posszarg2_bytes = instruct->m_posszarg2 * g_cdvdstm_usedchunksize2;
1197 if ( g_cdvdstm_stmstart_ee == 2 && (cmdid != 9 && cmdid != 3) )
1205 sceCdSC(2, &g_cdvdstm_last_error_for_ee);
1211 sceCdSC(0, &g_cdvdstm_last_error_for_ee);
1216 CancelAlarm((
unsigned int (*)(
void *))ee_stream_intr_cb_cdda, &g_cdvdstm_curclk_ee);
1217 sceCdSC(0, &g_cdvdstm_last_error_for_ee);
1221 CancelAlarm((
unsigned int (*)(
void *))stm_ee_read_timeout_alarm_cb, &g_cdvdstm_curclk_ee);
1224 bankcur_tmp = g_cdvdstm_bankcur_ee;
1225 if ( !g_cdvdstm_usedmap_ee[bankcur_tmp] )
1228 if ( (
unsigned int)bankcur_tmp >= (
unsigned int)g_cdvdstm_bankcnt2 )
1230 if ( !g_cdvdstm_usedmap_ee[bankcur_tmp] )
1231 bankcur_tmp = g_cdvdstm_bankcur_ee;
1233 for ( i = 0; (i < (
unsigned int)g_cdvdstm_bankcnt2) && g_cdvdstm_usedmap_ee[bankcur_tmp]
1234 && (g_cdvdstm_bankgp_ee != bankcur_tmp);
1238 if ( (
unsigned int)(bankcur_tmp) >= (
unsigned int)g_cdvdstm_bankcnt2 )
1241 if ( !g_cdvdstm_usedchunksize2 )
1243 *outres_ptr = i * (g_cdvdstm_chunksz2 / (
unsigned int)g_cdvdstm_usedchunksize2);
1246 sceCdstm1Cb((
void (*)(
int))ee_stream_intr_cb_cdda_thunk);
1250 g_cdvdstm_usedchunksize2 = 2368;
1253 g_cdvdstm_usedchunksize2 = 2448;
1257 g_cdvdstm_usedchunksize2 = 0x930;
1260 if ( !instruct->m_posszarg2 )
1262 chunks_sectors = instruct->m_posszarg1 / instruct->m_posszarg2;
1263 g_cdvdstm_bufsz2 = instruct->m_posszarg1;
1264 g_cdvdstm_sectorcount2 = chunks_sectors;
1265 g_cdvdstm_chunksz2 = chunks_sectors * g_cdvdstm_usedchunksize2;
1266 g_cdvdstm_buffer2 = (
char *)instruct->m_buffer;
1267 g_cdvdstm_bankcnt2 = instruct->m_posszarg2;
1269 "DA Stream Buffer 1Bank %dbyte %dbanks %dbyte used\n",
1270 (
int)(chunks_sectors * g_cdvdstm_usedchunksize2),
1271 (
int)instruct->m_posszarg2,
1272 (
int)(chunks_sectors * g_cdvdstm_usedchunksize2 * instruct->m_posszarg2));
1277 g_cdvdstm_stmstart_ee = 0;
1278 CancelAlarm((
unsigned int (*)(
void *))ee_stream_intr_cb_cdda, &g_cdvdstm_curclk_ee);
1279 sceCdSC(0, &g_cdvdstm_last_error_for_ee);
1282 for ( i = 0; i < (
unsigned int)g_cdvdstm_bankcnt2; i += 1 )
1284 g_cdvdstm_usedmap_ee[i] = 0;
1286 g_cdvdstm_bankoffs_ee = 0;
1287 g_cdvdstm_bankcur_ee = 0;
1288 g_cdvdstm_bankgp_ee = 0;
1291 g_cdvdstm_last_error_for_ee = 0;
1292 sceCdSC(0xFFFFFFFE, &g_cdvdstm_last_error_for_ee);
1293 CancelAlarm((
unsigned int (*)(
void *))stm_ee_read_timeout_alarm_cb, &g_cdvdstm_curclk_ee);
1299 g_cdvdstm_retryerr_ee = 0;
1304 if ( sceCdSC(0xFFFFFFFF, &g_cdvdstm_last_error_for_ee) )
1307 g_cdvdstm_lsn_ee = instruct->m_posszarg1;
1308 for ( i = 0; i < (
unsigned int)g_cdvdstm_bankcnt2; i += 1 )
1310 g_cdvdstm_usedmap_ee[i] = 0;
1312 g_cdvdstm_stmstart_ee = 2;
1324 CancelAlarm((
unsigned int (*)(
void *))ee_stream_intr_cb_cdda, &g_cdvdstm_curclk_ee);
1325 sceCdSC(0, &g_cdvdstm_last_error_for_ee);
1326 posszarg2_bytes = 0;
1329 g_cdvdstm_lsn_ee = instruct->m_posszarg1;
1330 g_cdvdstm_bankoffs_ee = 0;
1331 g_cdvdstm_bankcur_ee = 0;
1332 g_cdvdstm_bankgp_ee = 0;
1334 CancelAlarm((
unsigned int (*)(
void *))stm_ee_read_timeout_alarm_cb, &g_cdvdstm_curclk_ee);
1338 signed int posszarg2_chunks;
1341 CancelAlarm((
unsigned int (*)(
void *))ee_stream_intr_cb_cdda, &g_cdvdstm_curclk_ee);
1342 sceCdSC(0, &g_cdvdstm_last_error_for_ee);
1345 for ( i = 0; i < (
unsigned int)g_cdvdstm_bankcnt2; i += 1 )
1347 g_cdvdstm_usedmap_ee[i] = 0;
1349 g_cdvdstm_lsn_ee = instruct->m_posszarg1;
1350 g_cdvdstm_bankoffs_ee = 0;
1351 g_cdvdstm_bankcur_ee = 0;
1353 CancelAlarm((
unsigned int (*)(
void *))stm_ee_read_timeout_alarm_cb, &g_cdvdstm_curclk_ee);
1354 if ( !g_cdvdstm_chunksz2 )
1356 posszarg2_chunks = (posszarg2_bytes / g_cdvdstm_chunksz2) + (!!(posszarg2_bytes % g_cdvdstm_chunksz2));
1357 for ( g_cdvdstm_bankgp_ee = 0; g_cdvdstm_bankgp_ee < posszarg2_chunks; g_cdvdstm_bankgp_ee += 1 )
1361 outres_tmp2 = sceCdReadCDDA(g_cdvdstm_lsn_ee, g_cdvdstm_sectorcount2, g_cdvdstm_buffer2, &g_cdvdstm_mode_ee);
1363 sceCdSC(0xFFFFFFFF, &g_cdvdstm_last_error_for_ee);
1364 if ( g_cdvdstm_last_error_for_ee || !outres_tmp2 )
1366 sceCdSC(0, &g_cdvdstm_last_error_for_ee);
1370 g_cdvdstm_lsn_ee += g_cdvdstm_sectorcount2;
1371 g_cdvdstm_usedmap_ee[g_cdvdstm_bankgp_ee] = 1;
1373 g_cdvdstm_stmstart_ee = 1;
1374 sceCdSC(2, &g_cdvdstm_last_error_for_ee);
1377 sceCdSC(0, &g_cdvdstm_last_error_for_ee);
1382 posszarg2_bytes_overrun = -1;
1383 for ( i = 0; i < posszarg2_bytes; i += posszarg2_bytes_clamped )
1385 unsigned int posszarg2_bytes_remain;
1387 posszarg2_bytes_remain = posszarg2_bytes - i;
1388 if ( !g_cdvdstm_usedmap_ee[g_cdvdstm_bankcur_ee] )
1392 "CD read buffer over run %d %d %d %d %d gp %d pp %d\n",
1393 (u8)g_cdvdstm_usedmap_ee[0],
1394 (u8)g_cdvdstm_usedmap_ee[1],
1395 (u8)g_cdvdstm_usedmap_ee[2],
1396 (u8)g_cdvdstm_usedmap_ee[3],
1397 (u8)g_cdvdstm_usedmap_ee[4],
1398 g_cdvdstm_bankgp_ee,
1399 g_cdvdstm_bankcur_ee);
1401 bankcur_next_tmp1 = g_cdvdstm_bankcur_ee;
1402 g_cdvdstm_bankcur_ee += 1;
1403 if ( (
unsigned int)g_cdvdstm_bankcur_ee >= (
unsigned int)g_cdvdstm_bankcnt2 )
1404 g_cdvdstm_bankcur_ee = 0;
1405 if ( !g_cdvdstm_usedmap_ee[g_cdvdstm_bankcur_ee] )
1406 g_cdvdstm_bankcur_ee = bankcur_next_tmp1;
1407 posszarg2_bytes_overrun = posszarg2_bytes - posszarg2_bytes_remain;
1411 posszarg2_bytes_clamped = ((
unsigned int)(g_cdvdstm_chunksz2 - g_cdvdstm_bankoffs_ee) < posszarg2_bytes_remain) ?
1412 (
unsigned int)(g_cdvdstm_chunksz2 - g_cdvdstm_bankoffs_ee) :
1413 posszarg2_bytes_remain;
1414 g_cdvdstm_dmat2.dest = ((
char *)instruct->m_buffer) + i;
1415 g_cdvdstm_dmat2.size = posszarg2_bytes_clamped;
1416 g_cdvdstm_dmat2.attr = 0;
1417 g_cdvdstm_dmat2.src = (
char *)g_cdvdstm_buffer2 + g_cdvdstm_bankcur_ee * g_cdvdstm_chunksz2 + g_cdvdstm_bankoffs_ee;
1418 if ( posszarg2_bytes_clamped )
1423 dmat2 = sceSifSetDma(&g_cdvdstm_dmat2, 1);
1429 g_cdvdstm_bankoffs_ee += posszarg2_bytes_clamped;
1430 while ( vsceSifDmaStat(dmat2) >= 0 )
1433 if ( (
unsigned int)g_cdvdstm_bankoffs_ee >= (
unsigned int)g_cdvdstm_chunksz2 )
1436 g_cdvdstm_bankoffs_ee = 0;
1437 g_cdvdstm_usedmap_ee[g_cdvdstm_bankcur_ee] = 0;
1438 bankcur_next_tmp2 = g_cdvdstm_bankcur_ee;
1439 g_cdvdstm_bankcur_ee += 1;
1440 if ( (
unsigned int)g_cdvdstm_bankcur_ee >= (
unsigned int)g_cdvdstm_bankcnt2 )
1441 g_cdvdstm_bankcur_ee = 0;
1442 if ( g_cdvdstm_usedmap_ee[g_cdvdstm_bankcur_ee] && g_cdvdstm_bankgp_ee != g_cdvdstm_bankcur_ee )
1448 g_cdvdstm_bankcur_ee = bankcur_next_tmp2;
1452 "CD read buffer over run %d %d %d %d %d gp %d pp %d\n",
1453 (u8)g_cdvdstm_usedmap_ee[0],
1454 (u8)g_cdvdstm_usedmap_ee[1],
1455 (u8)g_cdvdstm_usedmap_ee[2],
1456 (u8)g_cdvdstm_usedmap_ee[3],
1457 (u8)g_cdvdstm_usedmap_ee[4],
1458 g_cdvdstm_bankgp_ee,
1459 g_cdvdstm_bankcur_ee);
1460 posszarg2_bytes_overrun = posszarg2_bytes - (posszarg2_bytes_remain - posszarg2_bytes_clamped);
1465 if ( posszarg2_bytes_overrun == 0xFFFFFFFF )
1466 posszarg2_bytes_overrun = posszarg2_bytes;
1467 if ( !g_cdvdstm_usedchunksize2 )
1469 posszarg2_overrun_chunks2 = posszarg2_bytes_overrun / g_cdvdstm_usedchunksize2;
1475 if ( sceCdSC(0xFFFFFFFF, &g_cdvdstm_last_error_for_ee) != 2 && !posszarg2_overrun_chunks2 && !g_cdvdstm_retryerr_ee )
1476 g_cdvdstm_retryerr_ee = 273;
1477 if ( g_cdvdstm_retryerr_ee )
1479 posszarg2_overrun_chunks2 = (u16)posszarg2_overrun_chunks2 | (g_cdvdstm_retryerr_ee << 16);
1480 g_cdvdstm_retryerr_ee = 0;
1482 *outres_ptr = posszarg2_overrun_chunks2;
1485static unsigned int ee_stream_intr_cb_cdda(
void *userdata)
1491 VERBOSE_KPRINTF(1,
"Intr EE DA Stm Read call\n");
1492 iCancelAlarm((
unsigned int (*)(
void *))stm_ee_read_timeout_alarm_cb, &g_cdvdstm_curclk_ee);
1493 iCancelAlarm((
unsigned int (*)(
void *))ee_stream_intr_cb_cdda, &g_cdvdstm_curclk_ee);
1494 sceCdSC(0xFFFFFFFF, &g_cdvdstm_last_error_for_ee);
1495 if ( !g_cdvdstm_last_error_for_ee )
1497#ifdef CDVD_VARIANT_XOSD
1498 switch ( sceCdSC(0xFFFFFFDA, &scres_unused) )
1513 g_cdvdstm_curclk_ee.hi = 0;
1514 if ( g_cdvdstm_stmstart_ee )
1515 g_cdvdstm_retrycnt_ee_cdda = 0;
1516 g_cdvdstm_curclk_ee.lo = (g_cdvdstm_stmstart_ee || g_cdvdstm_last_error_for_ee || g_cdvdstm_retrycnt_ee_cdda) ?
1518 (0x9000 * sceCdSC(0xFFFFFFEF, &scres_unused));
1519 if ( g_cdvdstm_last_error_for_ee )
1523 "EE Stream read LBN= %d Error code= 0x%02x retry= %d\n",
1524 g_cdvdstm_readlbn_ee_cdda,
1525 g_cdvdstm_last_error_for_ee,
1526 g_cdvdstm_retrycnt_ee_cdda);
1529 if ( g_cdvdstm_retrycnt_ee_cdda )
1531 VERBOSE_KPRINTF(1,
"On Retry retry %d err %08x\n", g_cdvdstm_retrycnt_ee_cdda, g_cdvdstm_last_error_for_ee);
1533 g_cdvdstm_retrycnt_ee_cdda = 4;
1537 g_cdvdstm_retrycnt_ee_cdda = 1;
1539 g_cdvdstm_retryerr_ee = g_cdvdstm_last_error_for_ee;
1543 g_cdvdstm_retrycnt_ee_cdda = 0;
1545 if ( g_cdvdstm_retrycnt_ee_cdda )
1547 g_cdvdstm_retrycnt_ee_cdda -= 1;
1549 !g_cdvdstm_retrycnt_ee_cdda
1552 g_cdvdstm_readlbn_ee_cdda =
1553 g_cdvdstm_lsn_ee + ((g_cdvdstm_sectorcount2 < 0x1D) ? (0x1D - g_cdvdstm_sectorcount2) : 0);
1554 g_cdvdstm_lsn_ee = g_cdvdstm_readlbn_ee_cdda + g_cdvdstm_sectorcount2;
1557 g_cdvdstm_readlbn_ee_cdda,
1558 g_cdvdstm_sectorcount2,
1559 (
char *)g_cdvdstm_buffer2 + g_cdvdstm_bankgp_ee * g_cdvdstm_chunksz2,
1560 &g_cdvdstm_mode_ee) )
1562 iSetAlarm(&g_cdvdstm_curclk_ee, (
unsigned int (*)(
void *))stm_ee_read_timeout_alarm_cb, &g_cdvdstm_curclk_ee);
1566 VERBOSE_KPRINTF(1,
"Stm Read Call fail\n");
1567 g_cdvdstm_curclk_ee.lo = 0x708000;
1569 iSetAlarm(&g_cdvdstm_curclk_ee, (
unsigned int (*)(
void *))ee_stream_intr_cb_cdda, &g_cdvdstm_curclk_ee)
1572 sceCdSC(0, &g_cdvdstm_last_error_for_ee);
1574 g_cdvdstm_retrycnt_ee_cdda += 1;
1581 if ( !g_cdvdstm_stmstart_ee )
1583 g_cdvdstm_usedmap_ee[g_cdvdstm_bankgp_ee] = 1;
1584 gptmp = g_cdvdstm_bankgp_ee;
1585 g_cdvdstm_bankgp_ee += 1;
1586 if ( (
unsigned int)g_cdvdstm_bankgp_ee >= (
unsigned int)g_cdvdstm_bankcnt2 )
1587 g_cdvdstm_bankgp_ee = 0;
1590 !g_cdvdstm_stmstart_ee
1591 && (g_cdvdstm_usedmap_ee[g_cdvdstm_bankgp_ee] || g_cdvdstm_bankcur_ee == g_cdvdstm_bankgp_ee) )
1593 g_cdvdstm_bankgp_ee = gptmp;
1594 g_cdvdstm_usedmap_ee[gptmp] = 0;
1597 "read Full %d %d %d %d %d gp %d pp %d spn %d\n",
1598 (u8)g_cdvdstm_usedmap_ee[0],
1599 (u8)g_cdvdstm_usedmap_ee[1],
1600 (u8)g_cdvdstm_usedmap_ee[2],
1601 (u8)g_cdvdstm_usedmap_ee[3],
1602 (u8)g_cdvdstm_usedmap_ee[4],
1603 g_cdvdstm_bankgp_ee,
1604 g_cdvdstm_bankcur_ee,
1606 g_cdvdstm_curclk_ee.lo = 0x48000;
1608 iSetAlarm(&g_cdvdstm_curclk_ee, (
unsigned int (*)(
void *))ee_stream_intr_cb_cdda, &g_cdvdstm_curclk_ee)
1611 sceCdSC(0, &g_cdvdstm_last_error_for_ee);
1616 if ( g_cdvdstm_stmstart_ee == 2 )
1620 g_cdvdstm_bankoffs_ee = 0;
1621 g_cdvdstm_bankcur_ee = 0;
1622 g_cdvdstm_bankgp_ee = 0;
1623 for ( i = 0; i < (
unsigned int)g_cdvdstm_bankcnt2; i += 1 )
1624 g_cdvdstm_usedmap_ee[i] = 0;
1626 g_cdvdstm_stmstart_ee = 0;
1627 g_cdvdstm_readlbn_ee_cdda = g_cdvdstm_lsn_ee;
1630 g_cdvdstm_sectorcount2,
1631 (
char *)g_cdvdstm_buffer2 + g_cdvdstm_bankgp_ee * g_cdvdstm_chunksz2,
1632 &g_cdvdstm_mode_ee) )
1634 iSetAlarm(&g_cdvdstm_curclk_ee, (
unsigned int (*)(
void *))stm_ee_read_timeout_alarm_cb, &g_cdvdstm_curclk_ee);
1638 VERBOSE_KPRINTF(1,
"Stm Read Call1 fail\n");
1639 g_cdvdstm_curclk_ee.lo = 0x708000;
1641 iSetAlarm(&g_cdvdstm_curclk_ee, (
unsigned int (*)(
void *))ee_stream_intr_cb_cdda, &g_cdvdstm_curclk_ee)
1644 sceCdSC(0, &g_cdvdstm_last_error_for_ee);
1646 g_cdvdstm_retrycnt_ee_cdda = 1;
1648 g_cdvdstm_lsn_ee += g_cdvdstm_sectorcount2;
1656 "\t" ".set push" "\n"
1657 "\t" ".set noat" "\n"
1658 "\t" ".set noreorder" "\n"
1659 "\t" ".global optimized_memcpy" "\n"
1660 "\t" "optimized_memcpy:" "\n"
1661 "\t" " srl $a3, $a2, 2" "\n"
1662 "\t" " beqz $a3, .Loptimized_memcpy_12" "\n"
1663 "\t" " or $a3, $a0, $a1" "\n"
1664 "\t" " andi $a3, $a3, 0x3" "\n"
1665 "\t" " bnez $a3, .Loptimized_memcpy_3" "\n"
1667 "\t" " srl $a3, $a2, 2" "\n"
1668 "\t" " addiu $at, $zero, 0xC" "\n"
1669 "\t" " div $zero, $a3, $at" "\n"
1670 "\t" " mflo $a3" "\n"
1671 "\t" " mfhi $v1" "\n"
1672 "\t" " beqz $v1, .Loptimized_memcpy_2" "\n"
1674 "\t" ".Loptimized_memcpy_1:" "\n"
1675 "\t" " lw $v0, 0x0($a1)" "\n"
1676 "\t" " addiu $v1, $v1, -0x1" "\n"
1677 "\t" " sw $v0, 0x0($a0)" "\n"
1678 "\t" " addiu $a1, $a1, 0x4" "\n"
1679 "\t" " bnez $v1, .Loptimized_memcpy_1" "\n"
1680 "\t" " addiu $a0, $a0, 0x4" "\n"
1681 "\t" " beqz $a3, .Loptimized_memcpy_12" "\n"
1683 "\t" ".Loptimized_memcpy_2:" "\n"
1684 "\t" " lw $v0, 0x0($a1)" "\n"
1685 "\t" " lw $v1, 0x4($a1)" "\n"
1686 "\t" " lw $t0, 0x8($a1)" "\n"
1687 "\t" " lw $t1, 0xC($a1)" "\n"
1688 "\t" " lw $t2, 0x10($a1)" "\n"
1689 "\t" " lw $t3, 0x14($a1)" "\n"
1690 "\t" " lw $t4, 0x18($a1)" "\n"
1691 "\t" " lw $t5, 0x1C($a1)" "\n"
1692 "\t" " lw $t6, 0x20($a1)" "\n"
1693 "\t" " lw $t7, 0x24($a1)" "\n"
1694 "\t" " lw $t8, 0x28($a1)" "\n"
1695 "\t" " lw $t9, 0x2C($a1)" "\n"
1696 "\t" " addiu $a3, $a3, -0x1" "\n"
1697 "\t" " sw $v0, 0x0($a0)" "\n"
1698 "\t" " sw $v1, 0x4($a0)" "\n"
1699 "\t" " sw $t0, 0x8($a0)" "\n"
1700 "\t" " sw $t1, 0xC($a0)" "\n"
1701 "\t" " sw $t2, 0x10($a0)" "\n"
1702 "\t" " sw $t3, 0x14($a0)" "\n"
1703 "\t" " sw $t4, 0x18($a0)" "\n"
1704 "\t" " sw $t5, 0x1C($a0)" "\n"
1705 "\t" " sw $t6, 0x20($a0)" "\n"
1706 "\t" " sw $t7, 0x24($a0)" "\n"
1707 "\t" " sw $t8, 0x28($a0)" "\n"
1708 "\t" " sw $t9, 0x2C($a0)" "\n"
1709 "\t" " addiu $a1, $a1, 0x30" "\n"
1710 "\t" " bnez $a3, .Loptimized_memcpy_2" "\n"
1711 "\t" " addiu $a0, $a0, 0x30" "\n"
1712 "\t" " j .Loptimized_memcpy_12" "\n"
1714 "\t" ".Loptimized_memcpy_3:" "\n"
1715 "\t" " andi $a3, $a0, 0x3" "\n"
1716 "\t" " beqz $a3, .Loptimized_memcpy_6" "\n"
1717 "\t" " andi $a3, $a1, 0x3" "\n"
1718 "\t" " beqz $a3, .Loptimized_memcpy_6" "\n"
1720 "\t" " srl $a3, $a2, 2" "\n"
1721 "\t" " addiu $at, $zero, 0xC" "\n"
1722 "\t" " div $zero, $a3, $at" "\n"
1723 "\t" " mflo $a3" "\n"
1724 "\t" " mfhi $v1" "\n"
1725 "\t" " beqz $v1, .Loptimized_memcpy_5" "\n"
1727 "\t" ".Loptimized_memcpy_4:" "\n"
1728 "\t" " lwl $v0, 0x3($a1)" "\n"
1729 "\t" " lwr $v0, 0x0($a1)" "\n"
1730 "\t" " addiu $v1, $v1, -0x1" "\n"
1731 "\t" " swl $v0, 0x3($a0)" "\n"
1732 "\t" " swr $v0, 0x0($a0)" "\n"
1733 "\t" " addiu $a1, $a1, 0x4" "\n"
1734 "\t" " bnez $v1, .Loptimized_memcpy_4" "\n"
1735 "\t" " addiu $a0, $a0, 0x4" "\n"
1736 "\t" " beqz $a3, .Loptimized_memcpy_12" "\n"
1738 "\t" ".Loptimized_memcpy_5:" "\n"
1739 "\t" " lwl $v0, 0x3($a1)" "\n"
1740 "\t" " lwr $v0, 0x0($a1)" "\n"
1741 "\t" " lwl $v1, 0x7($a1)" "\n"
1742 "\t" " lwr $v1, 0x4($a1)" "\n"
1743 "\t" " lwl $t0, 0xB($a1)" "\n"
1744 "\t" " lwr $t0, 0x8($a1)" "\n"
1745 "\t" " lwl $t1, 0xF($a1)" "\n"
1746 "\t" " lwr $t1, 0xC($a1)" "\n"
1747 "\t" " lwl $t2, 0x13($a1)" "\n"
1748 "\t" " lwr $t2, 0x10($a1)" "\n"
1749 "\t" " lwl $t3, 0x17($a1)" "\n"
1750 "\t" " lwr $t3, 0x14($a1)" "\n"
1751 "\t" " lwl $t4, 0x1B($a1)" "\n"
1752 "\t" " lwr $t4, 0x18($a1)" "\n"
1753 "\t" " lwl $t5, 0x1F($a1)" "\n"
1754 "\t" " lwr $t5, 0x1C($a1)" "\n"
1755 "\t" " lwl $t6, 0x23($a1)" "\n"
1756 "\t" " lwr $t6, 0x20($a1)" "\n"
1757 "\t" " lwl $t7, 0x27($a1)" "\n"
1758 "\t" " lwr $t7, 0x24($a1)" "\n"
1759 "\t" " lwl $t8, 0x2B($a1)" "\n"
1760 "\t" " lwr $t8, 0x28($a1)" "\n"
1761 "\t" " lwl $t9, 0x2F($a1)" "\n"
1762 "\t" " lwr $t9, 0x2C($a1)" "\n"
1763 "\t" " addiu $a3, $a3, -0x1" "\n"
1764 "\t" " swl $v0, 0x3($a0)" "\n"
1765 "\t" " swr $v0, 0x0($a0)" "\n"
1766 "\t" " swl $v1, 0x7($a0)" "\n"
1767 "\t" " swr $v1, 0x4($a0)" "\n"
1768 "\t" " swl $t0, 0xB($a0)" "\n"
1769 "\t" " swr $t0, 0x8($a0)" "\n"
1770 "\t" " swl $t1, 0xF($a0)" "\n"
1771 "\t" " swr $t1, 0xC($a0)" "\n"
1772 "\t" " swl $t2, 0x13($a0)" "\n"
1773 "\t" " swr $t2, 0x10($a0)" "\n"
1774 "\t" " swl $t3, 0x17($a0)" "\n"
1775 "\t" " swr $t3, 0x14($a0)" "\n"
1776 "\t" " swl $t4, 0x1B($a0)" "\n"
1777 "\t" " swr $t4, 0x18($a0)" "\n"
1778 "\t" " swl $t5, 0x1F($a0)" "\n"
1779 "\t" " swr $t5, 0x1C($a0)" "\n"
1780 "\t" " swl $t6, 0x23($a0)" "\n"
1781 "\t" " swr $t6, 0x20($a0)" "\n"
1782 "\t" " swl $t7, 0x27($a0)" "\n"
1783 "\t" " swr $t7, 0x24($a0)" "\n"
1784 "\t" " swl $t8, 0x2B($a0)" "\n"
1785 "\t" " swr $t8, 0x28($a0)" "\n"
1786 "\t" " swl $t9, 0x2F($a0)" "\n"
1787 "\t" " swr $t9, 0x2C($a0)" "\n"
1788 "\t" " addiu $a1, $a1, 0x30" "\n"
1789 "\t" " bnez $a3, .Loptimized_memcpy_5" "\n"
1790 "\t" " addiu $a0, $a0, 0x30" "\n"
1791 "\t" " j .Loptimized_memcpy_12" "\n"
1793 "\t" ".Loptimized_memcpy_6:" "\n"
1794 "\t" " andi $a3, $a0, 0x3" "\n"
1795 "\t" " beqz $a3, .Loptimized_memcpy_9" "\n"
1797 "\t" " srl $a3, $a2, 2" "\n"
1798 "\t" " addiu $at, $zero, 0xC" "\n"
1799 "\t" " div $zero, $a3, $at" "\n"
1800 "\t" " mflo $a3" "\n"
1801 "\t" " mfhi $v1" "\n"
1802 "\t" " beqz $v1, .Loptimized_memcpy_8" "\n"
1804 "\t" ".Loptimized_memcpy_7:" "\n"
1805 "\t" " lw $v0, 0x0($a1)" "\n"
1806 "\t" " addiu $v1, $v1, -0x1" "\n"
1807 "\t" " swl $v0, 0x3($a0)" "\n"
1808 "\t" " swr $v0, 0x0($a0)" "\n"
1809 "\t" " addiu $a1, $a1, 0x4" "\n"
1810 "\t" " bnez $v1, .Loptimized_memcpy_7" "\n"
1811 "\t" " addiu $a0, $a0, 0x4" "\n"
1812 "\t" " beqz $a3, .Loptimized_memcpy_12" "\n"
1814 "\t" ".Loptimized_memcpy_8:" "\n"
1815 "\t" " lw $v0, 0x0($a1)" "\n"
1816 "\t" " lw $v1, 0x4($a1)" "\n"
1817 "\t" " lw $t0, 0x8($a1)" "\n"
1818 "\t" " lw $t1, 0xC($a1)" "\n"
1819 "\t" " lw $t2, 0x10($a1)" "\n"
1820 "\t" " lw $t3, 0x14($a1)" "\n"
1821 "\t" " lw $t4, 0x18($a1)" "\n"
1822 "\t" " lw $t5, 0x1C($a1)" "\n"
1823 "\t" " lw $t6, 0x20($a1)" "\n"
1824 "\t" " lw $t7, 0x24($a1)" "\n"
1825 "\t" " lw $t8, 0x28($a1)" "\n"
1826 "\t" " lw $t9, 0x2C($a1)" "\n"
1827 "\t" " addiu $a3, $a3, -0x1" "\n"
1828 "\t" " swl $v0, 0x3($a0)" "\n"
1829 "\t" " swr $v0, 0x0($a0)" "\n"
1830 "\t" " swl $v1, 0x7($a0)" "\n"
1831 "\t" " swr $v1, 0x4($a0)" "\n"
1832 "\t" " swl $t0, 0xB($a0)" "\n"
1833 "\t" " swr $t0, 0x8($a0)" "\n"
1834 "\t" " swl $t1, 0xF($a0)" "\n"
1835 "\t" " swr $t1, 0xC($a0)" "\n"
1836 "\t" " swl $t2, 0x13($a0)" "\n"
1837 "\t" " swr $t2, 0x10($a0)" "\n"
1838 "\t" " swl $t3, 0x17($a0)" "\n"
1839 "\t" " swr $t3, 0x14($a0)" "\n"
1840 "\t" " swl $t4, 0x1B($a0)" "\n"
1841 "\t" " swr $t4, 0x18($a0)" "\n"
1842 "\t" " swl $t5, 0x1F($a0)" "\n"
1843 "\t" " swr $t5, 0x1C($a0)" "\n"
1844 "\t" " swl $t6, 0x23($a0)" "\n"
1845 "\t" " swr $t6, 0x20($a0)" "\n"
1846 "\t" " swl $t7, 0x27($a0)" "\n"
1847 "\t" " swr $t7, 0x24($a0)" "\n"
1848 "\t" " swl $t8, 0x2B($a0)" "\n"
1849 "\t" " swr $t8, 0x28($a0)" "\n"
1850 "\t" " swl $t9, 0x2F($a0)" "\n"
1851 "\t" " swr $t9, 0x2C($a0)" "\n"
1852 "\t" " addiu $a1, $a1, 0x30" "\n"
1853 "\t" " bnez $a3, .Loptimized_memcpy_8" "\n"
1854 "\t" " addiu $a0, $a0, 0x30" "\n"
1855 "\t" " j .Loptimized_memcpy_12" "\n"
1857 "\t" ".Loptimized_memcpy_9:" "\n"
1858 "\t" " srl $a3, $a2, 2" "\n"
1859 "\t" " addiu $at, $zero, 0xC" "\n"
1860 "\t" " div $zero, $a3, $at" "\n"
1861 "\t" " mflo $a3" "\n"
1862 "\t" " mfhi $v1" "\n"
1863 "\t" " beqz $v1, .Loptimized_memcpy_11" "\n"
1865 "\t" ".Loptimized_memcpy_10:" "\n"
1866 "\t" " lwl $v0, 0x3($a1)" "\n"
1867 "\t" " lwr $v0, 0x0($a1)" "\n"
1868 "\t" " addiu $v1, $v1, -0x1" "\n"
1869 "\t" " sw $v0, 0x0($a0)" "\n"
1870 "\t" " addiu $a1, $a1, 0x4" "\n"
1871 "\t" " bnez $v1, .Loptimized_memcpy_10" "\n"
1872 "\t" " addiu $a0, $a0, 0x4" "\n"
1873 "\t" " beqz $a3, .Loptimized_memcpy_12" "\n"
1875 "\t" ".Loptimized_memcpy_11:" "\n"
1876 "\t" " lwl $v0, 0x3($a1)" "\n"
1877 "\t" " lwr $v0, 0x0($a1)" "\n"
1878 "\t" " lwl $v1, 0x7($a1)" "\n"
1879 "\t" " lwr $v1, 0x4($a1)" "\n"
1880 "\t" " lwl $t0, 0xB($a1)" "\n"
1881 "\t" " lwr $t0, 0x8($a1)" "\n"
1882 "\t" " lwl $t1, 0xF($a1)" "\n"
1883 "\t" " lwr $t1, 0xC($a1)" "\n"
1884 "\t" " lwl $t2, 0x13($a1)" "\n"
1885 "\t" " lwr $t2, 0x10($a1)" "\n"
1886 "\t" " lwl $t3, 0x17($a1)" "\n"
1887 "\t" " lwr $t3, 0x14($a1)" "\n"
1888 "\t" " lwl $t4, 0x1B($a1)" "\n"
1889 "\t" " lwr $t4, 0x18($a1)" "\n"
1890 "\t" " lwl $t5, 0x1F($a1)" "\n"
1891 "\t" " lwr $t5, 0x1C($a1)" "\n"
1892 "\t" " lwl $t6, 0x23($a1)" "\n"
1893 "\t" " lwr $t6, 0x20($a1)" "\n"
1894 "\t" " lwl $t7, 0x27($a1)" "\n"
1895 "\t" " lwr $t7, 0x24($a1)" "\n"
1896 "\t" " lwl $t8, 0x2B($a1)" "\n"
1897 "\t" " lwr $t8, 0x28($a1)" "\n"
1898 "\t" " lwl $t9, 0x2F($a1)" "\n"
1899 "\t" " lwr $t9, 0x2C($a1)" "\n"
1900 "\t" " addiu $a3, $a3, -0x1" "\n"
1901 "\t" " sw $v0, 0x0($a0)" "\n"
1902 "\t" " sw $v1, 0x4($a0)" "\n"
1903 "\t" " sw $t0, 0x8($a0)" "\n"
1904 "\t" " sw $t1, 0xC($a0)" "\n"
1905 "\t" " sw $t2, 0x10($a0)" "\n"
1906 "\t" " sw $t3, 0x14($a0)" "\n"
1907 "\t" " sw $t4, 0x18($a0)" "\n"
1908 "\t" " sw $t5, 0x1C($a0)" "\n"
1909 "\t" " sw $t6, 0x20($a0)" "\n"
1910 "\t" " sw $t7, 0x24($a0)" "\n"
1911 "\t" " sw $t8, 0x28($a0)" "\n"
1912 "\t" " sw $t9, 0x2C($a0)" "\n"
1913 "\t" " addiu $a1, $a1, 0x30" "\n"
1914 "\t" " bnez $a3, .Loptimized_memcpy_11" "\n"
1915 "\t" " addiu $a0, $a0, 0x30" "\n"
1916 "\t" ".Loptimized_memcpy_12:" "\n"
1917 "\t" " andi $v1, $a2, 0x3" "\n"
1918 "\t" " beqz $v1, .Loptimized_memcpy_14" "\n"
1920 "\t" ".Loptimized_memcpy_13:" "\n"
1921 "\t" " lb $v0, 0x0($a1)" "\n"
1922 "\t" " addiu $v1, $v1, -0x1" "\n"
1923 "\t" " sb $v0, 0x0($a0)" "\n"
1924 "\t" " addiu $a1, $a1, 0x1" "\n"
1925 "\t" " bnez $v1, .Loptimized_memcpy_13" "\n"
1926 "\t" " addiu $a0, $a0, 0x1" "\n"
1927 "\t" ".Loptimized_memcpy_14:" "\n"
1928 "\t" " addu $v0, $a2, $zero" "\n"
1931 "\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)