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 *arg),
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 unsigned int stm_iop_read_timeout_alarm_cb(
void *userdata)
172 KPRINTF(
"Stm Iop Read Time Out %d(msec)\n", sys_clock->lo / 0x9000);
176static int sceCdStream0_inner(
unsigned int rdsize,
char *addrarg,
int modearg,
int *error_ptr)
179 unsigned int streamres;
184 VERBOSE_KPRINTF(1,
"sceCdStream0 call read size= %d mode= %d addr= %08x\n", rdsize, modearg, addrarg);
186 if ( !sceCdSC(0xFFFFFFFF, &last_error) )
190 return iop_stream_handler(0, rdsize, addrarg, 2, &g_rmode_for_stream0, error_ptr);
194 while ( (!err || streamres) )
196 WaitEventFlag(g_cdvdman_intr_efid, 8, WEF_AND, &efbits);
197 streamres = iop_stream_handler(0, rdsize - cur_size, &addrarg[cur_size], 2, &g_rmode_for_stream0, &err);
198 if ( rdsize - cur_size != streamres )
200 cur_size += streamres;
203 VERBOSE_KPRINTF(1,
"sceCdStream0 BLK cur_size= %d req_size= %d err 0x%x\n", cur_size, rdsize, err);
204 if ( (
unsigned int)cur_size == rdsize )
210static int sceCdStream0(
int rdsize_sectors,
char *addrarg,
int modearg,
int *error_ptr)
212 return sceCdStream0_inner(rdsize_sectors << 11, addrarg, modearg, error_ptr) / 0x800;
215static unsigned int iop_stream_handler(
216 unsigned int posszarg1,
unsigned int posszarg2,
void *buffer,
int cmdid,
const sceCdRMode *rmode,
int *error_ptr)
221 unsigned int written_chunk_size_tmp;
222 int bankcur_next_tmp1;
224 int bankcur_next_tmp2;
228 VERBOSE_KPRINTF(1,
"CD Stream Call mode= %d\n", cmdid);
230 if ( g_cdvdstm_stmstart_iop == 2 && cmdid != 9 && cmdid != 3 )
237 sceCdSC(1, &g_cdvdstm_last_error_for_iop);
240 sceCdSC(0, &g_cdvdstm_last_error_for_iop);
244 vCancelAlarm(iop_stream_intr_cb, &g_cdvdstm_curclk_iop);
245 sceCdSC(0, &g_cdvdstm_last_error_for_iop);
248 vCancelAlarm(stm_iop_read_timeout_alarm_cb, &g_cdvdstm_curclk_iop);
251 bankcur_tmp = g_cdvdstm_bankcur_iop;
252 if ( !g_cdvdstm_usedmap_iop[bankcur_tmp] )
255 if ( (
unsigned int)bankcur_tmp >= (
unsigned int)g_cdvdstm_bankmax )
257 if ( !g_cdvdstm_usedmap_iop[bankcur_tmp] )
258 bankcur_tmp = g_cdvdstm_bankcur_iop;
260 for ( i = 0; (i < (
unsigned int)g_cdvdstm_bankmax) && g_cdvdstm_usedmap_iop[bankcur_tmp]
261 && (g_cdvdstm_bankgp_iop != bankcur_tmp);
265 if ( (
unsigned int)bankcur_tmp >= (
unsigned int)g_cdvdstm_bankmax )
268 return i * ((
unsigned int)g_cdvdstm_numbytes >> 11);
270 sceCdstm0Cb(iop_stream_intr_cb_thunk);
271 g_cdvdstm_bufmax = posszarg1;
272 g_cdvdstm_sectorcount = posszarg1 / posszarg2;
273 g_cdvdstm_numbytes = g_cdvdstm_sectorcount << 11;
274 g_cdvdstm_buffer = buffer;
275 g_cdvdstm_bankmax = posszarg2;
277 "Stream Buffer 1Bank %dbyte %dbanks addr:%08x %dbyte used.\n",
281 g_cdvdstm_numbytes * posszarg2);
285 g_cdvdstm_stmstart_iop = 0;
286 vCancelAlarm(iop_stream_intr_cb, &g_cdvdstm_curclk_iop);
287 sceCdSC(0, &g_cdvdstm_last_error_for_iop);
290 for ( i = 0; i < (
unsigned int)g_cdvdstm_bankmax; i += 1 )
291 g_cdvdstm_usedmap_iop[i] = 0;
292 g_cdvdstm_bankoffs_iop = 0;
293 g_cdvdstm_bankcur_iop = 0;
294 g_cdvdstm_bankgp_iop = 0;
296 g_cdvdstm_last_error_for_iop = 0;
297 sceCdSC(0xFFFFFFFE, &g_cdvdstm_last_error_for_iop);
298 vCancelAlarm(stm_iop_read_timeout_alarm_cb, &g_cdvdstm_curclk_iop);
301 if ( sceCdSC(0xFFFFFFFF, &g_cdvdstm_last_error_for_iop) )
304 g_cdvdstm_lsn_iop = posszarg1;
305 for ( i = 0; i < (
unsigned int)g_cdvdstm_bankmax; i += 1 )
306 g_cdvdstm_usedmap_iop[i] = 0;
307 g_cdvdstm_stmstart_iop = 2;
316 g_cdvdstm_retryerr_iop = 0;
320 vCancelAlarm(iop_stream_intr_cb, &g_cdvdstm_curclk_iop);
321 sceCdSC(0, &g_cdvdstm_last_error_for_iop);
326 g_cdvdstm_lsn_iop = posszarg1;
327 g_cdvdstm_bankoffs_iop = 0;
328 g_cdvdstm_bankcur_iop = 0;
329 g_cdvdstm_bankgp_iop = 0;
331 vCancelAlarm(stm_iop_read_timeout_alarm_cb, &g_cdvdstm_curclk_iop);
338 vCancelAlarm(iop_stream_intr_cb, &g_cdvdstm_curclk_iop);
339 sceCdSC(0, &g_cdvdstm_last_error_for_iop);
341 for ( i = 0; i < (
unsigned int)g_cdvdstm_bankmax; i += 1 )
342 g_cdvdstm_usedmap_iop[i] = 0;
343 g_cdvdstm_lsn_iop = posszarg1;
344 sceCdSC(0xFFFFFFE9, (
int *)&g_cdvdstm_lsn_iop);
345 g_cdvdstm_bankoffs_iop = 0;
346 g_cdvdstm_bankcur_iop = 0;
347 g_cdvdstm_bankgp_iop = 0;
349 vCancelAlarm(stm_iop_read_timeout_alarm_cb, &g_cdvdstm_curclk_iop);
350 g_cdvdstm_stmstart_iop = 1;
351 sceCdSC(1, &g_cdvdstm_last_error_for_iop);
354 sceCdSC(0, &g_cdvdstm_last_error_for_iop);
359 written_chunk_size_tmp = -1;
360 for ( i = 0; i < posszarg2; i += chunk_size )
362 if ( !g_cdvdstm_usedmap_iop[g_cdvdstm_bankcur_iop] )
366 "CD read buffer over run %d %d %d %d %d gp %d pp %d\n",
367 (u8)g_cdvdstm_usedmap_iop[0],
368 (u8)g_cdvdstm_usedmap_iop[1],
369 (u8)g_cdvdstm_usedmap_iop[2],
370 (u8)g_cdvdstm_usedmap_iop[3],
371 (u8)g_cdvdstm_usedmap_iop[4],
372 g_cdvdstm_bankgp_iop,
373 g_cdvdstm_bankcur_iop);
374 bankcur_next_tmp1 = g_cdvdstm_bankcur_iop;
375 g_cdvdstm_bankcur_iop += 1;
376 if ( (
unsigned int)g_cdvdstm_bankcur_iop >= (
unsigned int)g_cdvdstm_bankmax )
377 g_cdvdstm_bankcur_iop = 0;
378 written_chunk_size_tmp = i;
379 if ( !g_cdvdstm_usedmap_iop[g_cdvdstm_bankcur_iop] )
381 g_cdvdstm_bankcur_iop = bankcur_next_tmp1;
385 if ( (
unsigned int)g_cdvdstm_bankoffs_iop >= (
unsigned int)g_cdvdstm_numbytes )
387 g_cdvdstm_bankoffs_iop = 0;
388 g_cdvdstm_usedmap_iop[g_cdvdstm_bankcur_iop] = 0;
389 bankcur_next_tmp2 = g_cdvdstm_bankcur_iop;
390 g_cdvdstm_bankcur_iop += 1;
391 if ( (
unsigned int)g_cdvdstm_bankcur_iop >= (
unsigned int)g_cdvdstm_bankmax )
392 g_cdvdstm_bankcur_iop = 0;
393 if ( !g_cdvdstm_usedmap_iop[g_cdvdstm_bankcur_iop] || g_cdvdstm_bankgp_iop == g_cdvdstm_bankcur_iop )
395 g_cdvdstm_bankcur_iop = bankcur_next_tmp2;
396 written_chunk_size_tmp = i;
399 "CD read buffer over run %d %d %d %d %d gp %d pp %d\n",
400 (u8)g_cdvdstm_usedmap_iop[0],
401 (u8)g_cdvdstm_usedmap_iop[1],
402 (u8)g_cdvdstm_usedmap_iop[2],
403 (u8)g_cdvdstm_usedmap_iop[3],
404 (u8)g_cdvdstm_usedmap_iop[4],
405 g_cdvdstm_bankgp_iop,
406 g_cdvdstm_bankcur_iop);
411 &((
char *)buffer)[i],
412 &((
char *)g_cdvdstm_buffer)[g_cdvdstm_bankcur_iop * g_cdvdstm_numbytes + g_cdvdstm_bankoffs_iop],
414 chunk_size = ((
unsigned int)0x800 > posszarg2 - i) ? (posszarg2 - i) : 0x800;
415 g_cdvdstm_bankoffs_iop += chunk_size;
417 if ( written_chunk_size_tmp == 0xFFFFFFFF )
418 written_chunk_size_tmp = posszarg2;
422 if ( sceCdSC(0xFFFFFFFF, &g_cdvdstm_last_error_for_iop) != 1 && !written_chunk_size_tmp && !g_cdvdstm_retryerr_iop )
424 g_cdvdstm_retryerr_iop = 273;
426 *error_ptr = g_cdvdstm_retryerr_iop;
427 g_cdvdstm_retryerr_iop = 0;
428 return written_chunk_size_tmp;
433static unsigned int iop_stream_intr_cb(
void *userdata)
440 VERBOSE_KPRINTF(1,
"Intr Read call\n");
441 iCancelAlarm(stm_iop_read_timeout_alarm_cb, &g_cdvdstm_curclk_iop);
442 iCancelAlarm(iop_stream_intr_cb, &g_cdvdstm_curclk_iop);
443 sceCdSC(0xFFFFFFFF, &last_error);
446#ifdef CDVD_VARIANT_XOSD
447 switch ( sceCdSC(0xFFFFFFDA, &scres_unused) )
463 g_cdvdstm_curclk_iop.hi = 0;
464 if ( g_cdvdstm_stmstart_iop )
465 g_cdvdstm_retrycnt_iop = 0;
466 if ( g_cdvdstm_stmstart_iop || last_error || g_cdvdstm_retrycnt_iop )
469 1,
"Stm Rtry stmstart:%d err:%02x retry:%d\n", g_cdvdstm_stmstart_iop, last_error, g_cdvdstm_retrycnt_iop);
471 g_cdvdstm_curclk_iop.lo = (g_cdvdstm_stmstart_iop || last_error || g_cdvdstm_retrycnt_iop) ?
473 (0x9000 * sceCdSC(0xFFFFFFEF, &scres_unused));
476 VERBOSE_KPRINTF(1,
"IOP Stream read Error code= 0x%02x retry= %d\n", last_error, g_cdvdstm_retrycnt_iop);
479 VERBOSE_KPRINTF(1,
"On err %08x\n", last_error);
480 if ( g_cdvdstm_retrycnt_iop )
481 g_cdvdstm_retryerr_iop = last_error;
482 g_cdvdstm_retrycnt_iop = 3;
486 g_cdvdstm_retryerr_iop = last_error;
487 g_cdvdstm_retrycnt_iop = 1;
490 if ( g_cdvdstm_retrycnt_iop )
494 g_cdvdstm_retrycnt_iop -= 1;
495 tgttmp = ((
unsigned int)g_cdvdstm_tgt >= (
unsigned int)(0x10 * g_cdvdstm_retrycnt_iop)) ?
496 (g_cdvdstm_tgt - 0x10 * g_cdvdstm_retrycnt_iop) :
497 (g_cdvdstm_tgt + 0x10 * g_cdvdstm_retrycnt_iop);
498 VERBOSE_KPRINTF(1,
"Stm Rtry Start Tgt=%d Cur= %d\n", g_cdvdstm_tgt, tgttmp);
501 g_cdvdstm_sectorcount,
502 (
char *)g_cdvdstm_buffer + g_cdvdstm_bankgp_iop * g_cdvdstm_numbytes,
503 &g_cdvdstm_mode_iop) )
505 iSetAlarm(&g_cdvdstm_curclk_iop, stm_iop_read_timeout_alarm_cb, &g_cdvdstm_curclk_iop);
509 g_cdvdstm_curclk_iop.lo = 0x708000;
511 iSetAlarm(&g_cdvdstm_curclk_iop, iop_stream_intr_cb, &g_cdvdstm_curclk_iop)
514 sceCdSC(0, &last_error);
516 g_cdvdstm_retrycnt_iop += 1;
524 if ( !g_cdvdstm_stmstart_iop )
526 g_cdvdstm_usedmap_iop[g_cdvdstm_bankgp_iop] = 1;
527 gptmp = g_cdvdstm_bankgp_iop;
528 g_cdvdstm_bankgp_iop += 1;
529 if ( (
unsigned int)g_cdvdstm_bankgp_iop >= (
unsigned int)g_cdvdstm_bankmax )
530 g_cdvdstm_bankgp_iop = 0;
533 !g_cdvdstm_stmstart_iop
534 && (g_cdvdstm_usedmap_iop[g_cdvdstm_bankgp_iop] || g_cdvdstm_bankcur_iop == g_cdvdstm_bankgp_iop) )
536 g_cdvdstm_bankgp_iop = gptmp;
537 g_cdvdstm_usedmap_iop[gptmp] = 0;
540 "read Full %d %d %d %d %d gp %d pp %d spn %d\n",
541 (u8)g_cdvdstm_usedmap_iop[0],
542 (u8)g_cdvdstm_usedmap_iop[1],
543 (u8)g_cdvdstm_usedmap_iop[2],
544 (u8)g_cdvdstm_usedmap_iop[3],
545 (u8)g_cdvdstm_usedmap_iop[4],
546 g_cdvdstm_bankgp_iop,
547 g_cdvdstm_bankcur_iop,
549 g_cdvdstm_curclk_iop.lo = 0x48000;
551 iSetAlarm(&g_cdvdstm_curclk_iop, iop_stream_intr_cb, &g_cdvdstm_curclk_iop)
554 sceCdSC(0, &last_error);
559 if ( g_cdvdstm_stmstart_iop == 2 )
563 g_cdvdstm_bankoffs_iop = 0;
564 g_cdvdstm_bankcur_iop = 0;
565 g_cdvdstm_bankgp_iop = 0;
566 for ( i = 0; i < (
unsigned int)g_cdvdstm_bankmax; i += 1 )
567 g_cdvdstm_usedmap_iop[i] = 0;
569 g_cdvdstm_stmstart_iop = 0;
570 g_cdvdstm_tgt = g_cdvdstm_lsn_iop;
573 g_cdvdstm_sectorcount,
574 (
char *)g_cdvdstm_buffer + g_cdvdstm_bankgp_iop * g_cdvdstm_numbytes,
575 &g_cdvdstm_mode_iop) )
578 &g_cdvdstm_curclk_iop, stm_iop_read_timeout_alarm_cb, &g_cdvdstm_curclk_iop);
582 g_cdvdstm_curclk_iop.lo = 0x708000;
584 iSetAlarm(&g_cdvdstm_curclk_iop, iop_stream_intr_cb, &g_cdvdstm_curclk_iop)
587 sceCdSC(0, &last_error);
589 g_cdvdstm_retrycnt_iop = 1;
591 g_cdvdstm_lsn_iop += g_cdvdstm_sectorcount;
602 semaparam.attr = SA_THPRI;
603 semaparam.initial = 1;
605 semaparam.option = 0;
606 g_cdvdstm_semid = CreateSema(&semaparam);
613 SignalSema(g_cdvdstm_semid);
614 DeleteSema(g_cdvdstm_semid);
618static int cdrom_stm_devctl(
619 iop_file_t *f,
const char *name,
int cmd,
void *inbuf,
unsigned int inbuf_len,
void *outbuf,
unsigned int outbuf_len)
631 WaitSema(g_cdvdstm_semid);
633 if ( g_cdvdstm_in_deldrv )
635 SignalSema(g_cdvdstm_semid);
641 if ( instruct->m_cmdid == 5 || instruct->m_cmdid == 3 || instruct->m_cmdid - 7 < 2 )
645 *outres_ptr = iop_stream_handler(
646 instruct->m_posszarg1,
647 instruct->m_posszarg2,
651 (
int *)&instruct->m_error);
655 sceCdStream0(instruct->m_posszarg2, (
char *)instruct->m_buffer, instruct->m_cmdid, (
int *)&instruct->m_error);
658 ee_stream_handler_normal(instruct, inbuf_len, outres_ptr);
661 ee_stream_handler_cdda(instruct, inbuf_len, outres_ptr);
665 PRINTF(
"Un-support devctl %08x\n", cmd);
669 SignalSema(g_cdvdstm_semid);
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) )
708 cdrom_stm_deinit(&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 vsceSifDmaStat(
int dmat)
723#ifdef CDVD_VARIANT_XOSD
728 return sceSifDmaStat(dmat);
730 st = sceSifDmaStat(dmat);
734 return sceSifDmaStat(dmat);
738static unsigned int stm_ee_read_timeout_alarm_cb(
void *userdata)
744 read_timeout = sys_clock->lo / 0x9000;
745 KPRINTF(
"Stm EE Read Time Out %d(msec)\n", read_timeout);
746 sceCdSC(0xFFFFFFEE, &read_timeout);
750static void ee_stream_handler_normal(
cdrom_stm_devctl_t *instruct,
int inbuf_len,
int *outres_ptr)
756 unsigned int chunks_sectors;
757 int bankcur_next_tmp1;
758 int posszarg2_bytes_clamped;
760 int bankcur_next_tmp2;
761 int posszarg2_bytes_overrun;
769 cmdid = instruct->m_cmdid;
770 if ( g_cdvdstm_stmstart_ee == 2 && (cmdid != 9 && cmdid != 3) )
778 sceCdSC(2, &g_cdvdstm_last_error_for_ee);
781 sceCdSC(0, &g_cdvdstm_last_error_for_ee);
789 CancelAlarm(ee_stream_intr_cb_normal, &g_cdvdstm_curclk_ee);
790 sceCdSC(0, &g_cdvdstm_last_error_for_ee);
794 CancelAlarm(stm_ee_read_timeout_alarm_cb, &g_cdvdstm_curclk_ee);
797 bankcur_tmp = g_cdvdstm_bankcur_ee;
798 if ( !g_cdvdstm_usedmap_ee[bankcur_tmp] )
801 if ( (
unsigned int)bankcur_tmp >= (
unsigned int)g_cdvdstm_bankcnt2 )
803 if ( !g_cdvdstm_usedmap_ee[bankcur_tmp] )
804 bankcur_tmp = g_cdvdstm_bankcur_ee;
806 for ( i = 0; (i < (
unsigned int)g_cdvdstm_bankcnt2) && g_cdvdstm_usedmap_ee[bankcur_tmp]
807 && (g_cdvdstm_bankgp_ee != bankcur_tmp);
811 if ( (
unsigned int)bankcur_tmp >= (
unsigned int)g_cdvdstm_bankcnt2 )
814 *outres_ptr = i * ((
unsigned int)g_cdvdstm_chunksz2 >> 11);
817 sceCdstm1Cb(ee_stream_intr_cb_normal_thunk);
818 if ( !instruct->m_posszarg2 )
820 chunks_sectors = instruct->m_posszarg1 / instruct->m_posszarg2;
821 g_cdvdstm_bufsz2 = instruct->m_posszarg1;
822 g_cdvdstm_sectorcount2 = chunks_sectors;
823 g_cdvdstm_chunksz2 = chunks_sectors << 11;
824 g_cdvdstm_buffer2 = (
char *)instruct->m_buffer;
825 g_cdvdstm_bankcnt2 = instruct->m_posszarg2;
827 "Stream Buffer 1Bank %dbyte %dbanks %dbyte used\n",
828 (
int)(chunks_sectors << 11),
829 (
int)(instruct->m_posszarg2),
830 (
int)((chunks_sectors << 11) * (instruct->m_posszarg2)));
835 g_cdvdstm_stmstart_ee = 0;
836 CancelAlarm(ee_stream_intr_cb_normal, &g_cdvdstm_curclk_ee);
837 sceCdSC(0, &g_cdvdstm_last_error_for_ee);
840 for ( i = 0; i < (
unsigned int)g_cdvdstm_bankcnt2; i += 1 )
842 g_cdvdstm_usedmap_ee[i] = 0;
844 g_cdvdstm_bankoffs_ee = 0;
845 g_cdvdstm_bankcur_ee = 0;
846 g_cdvdstm_bankgp_ee = 0;
849 g_cdvdstm_last_error_for_ee = 0;
850 sceCdSC(0xFFFFFFFE, &g_cdvdstm_last_error_for_ee);
851 CancelAlarm(stm_ee_read_timeout_alarm_cb, &g_cdvdstm_curclk_ee);
857 g_cdvdstm_retryerr_ee = 0;
860 posszarg2_bytes = instruct->m_posszarg2 << 11;
863 if ( sceCdSC(0xFFFFFFFF, &g_cdvdstm_last_error_for_ee) )
866 g_cdvdstm_lsn_ee = instruct->m_posszarg1;
867 for ( i = 0; i < (
unsigned int)g_cdvdstm_bankcnt2; i += 1 )
869 g_cdvdstm_usedmap_ee[i] = 0;
871 g_cdvdstm_stmstart_ee = 2;
883 CancelAlarm(ee_stream_intr_cb_normal, &g_cdvdstm_curclk_ee);
884 sceCdSC(0, &g_cdvdstm_last_error_for_ee);
888 g_cdvdstm_lsn_ee = instruct->m_posszarg1;
889 g_cdvdstm_bankoffs_ee = 0;
890 g_cdvdstm_bankcur_ee = 0;
891 g_cdvdstm_bankgp_ee = 0;
893 CancelAlarm(stm_ee_read_timeout_alarm_cb, &g_cdvdstm_curclk_ee);
898 CancelAlarm(ee_stream_intr_cb_normal, &g_cdvdstm_curclk_ee);
899 sceCdSC(0, &g_cdvdstm_last_error_for_ee);
902 for ( i = 0; i < (
unsigned int)g_cdvdstm_bankcnt2; i += 1 )
904 g_cdvdstm_usedmap_ee[i] = 0;
906 g_cdvdstm_lsn_ee = instruct->m_posszarg1;
907 sceCdSC(0xFFFFFFE9, (
int *)&g_cdvdstm_lsn_ee);
908 g_cdvdstm_bankoffs_ee = 0;
909 g_cdvdstm_bankcur_ee = 0;
911 CancelAlarm(stm_ee_read_timeout_alarm_cb, &g_cdvdstm_curclk_ee);
912 g_cdvdstm_stmstart_ee = 1;
913 sceCdSC(2, &g_cdvdstm_last_error_for_ee);
916 sceCdSC(0, &g_cdvdstm_last_error_for_ee);
921 posszarg2_bytes_overrun = -1;
922 for ( i = 0; i < posszarg2_bytes; i += posszarg2_bytes_clamped )
924 unsigned int posszarg2_bytes_remain;
926 posszarg2_bytes_remain = posszarg2_bytes - i;
927 if ( !g_cdvdstm_usedmap_ee[g_cdvdstm_bankcur_ee] )
931 "CD read buffer over run %d %d %d %d %d gp %d pp %d\n",
932 (u8)g_cdvdstm_usedmap_ee[0],
933 (u8)g_cdvdstm_usedmap_ee[1],
934 (u8)g_cdvdstm_usedmap_ee[2],
935 (u8)g_cdvdstm_usedmap_ee[3],
936 (u8)g_cdvdstm_usedmap_ee[4],
938 g_cdvdstm_bankcur_ee);
940 bankcur_next_tmp1 = g_cdvdstm_bankcur_ee;
941 g_cdvdstm_bankcur_ee += 1;
942 if ( (
unsigned int)g_cdvdstm_bankcur_ee >= (
unsigned int)g_cdvdstm_bankcnt2 )
943 g_cdvdstm_bankcur_ee = 0;
944 if ( !g_cdvdstm_usedmap_ee[g_cdvdstm_bankcur_ee] )
945 g_cdvdstm_bankcur_ee = bankcur_next_tmp1;
946 posszarg2_bytes_overrun = posszarg2_bytes - posszarg2_bytes_remain;
950 posszarg2_bytes_clamped = ((
unsigned int)(g_cdvdstm_chunksz2 - g_cdvdstm_bankoffs_ee) < posszarg2_bytes_remain) ?
951 (
unsigned int)(g_cdvdstm_chunksz2 - g_cdvdstm_bankoffs_ee) :
952 posszarg2_bytes_remain;
953 g_cdvdstm_dmat.dest = ((
char *)instruct->m_buffer) + i;
954 g_cdvdstm_dmat.size = posszarg2_bytes_clamped;
955 g_cdvdstm_dmat.attr = 0;
956 g_cdvdstm_dmat.src = (
char *)g_cdvdstm_buffer2 + g_cdvdstm_bankcur_ee * g_cdvdstm_chunksz2 + g_cdvdstm_bankoffs_ee;
957 if ( posszarg2_bytes_clamped )
962 dmat1 = sceSifSetDma(&g_cdvdstm_dmat, 1);
968 g_cdvdstm_bankoffs_ee += posszarg2_bytes_clamped;
969 while ( vsceSifDmaStat(dmat1) >= 0 )
972 if ( (
unsigned int)g_cdvdstm_bankoffs_ee >= (
unsigned int)g_cdvdstm_chunksz2 )
975 g_cdvdstm_bankoffs_ee = 0;
976 g_cdvdstm_usedmap_ee[g_cdvdstm_bankcur_ee] = 0;
977 bankcur_next_tmp2 = g_cdvdstm_bankcur_ee;
978 g_cdvdstm_bankcur_ee += 1;
979 if ( (
unsigned int)g_cdvdstm_bankcur_ee >= (
unsigned int)g_cdvdstm_bankcnt2 )
980 g_cdvdstm_bankcur_ee = 0;
981 if ( g_cdvdstm_usedmap_ee[g_cdvdstm_bankcur_ee] && g_cdvdstm_bankgp_ee != g_cdvdstm_bankcur_ee )
987 g_cdvdstm_bankcur_ee = bankcur_next_tmp2;
991 "CD read buffer over run %d %d %d %d %d gp %d pp %d\n",
992 (u8)g_cdvdstm_usedmap_ee[0],
993 (u8)g_cdvdstm_usedmap_ee[1],
994 (u8)g_cdvdstm_usedmap_ee[2],
995 (u8)g_cdvdstm_usedmap_ee[3],
996 (u8)g_cdvdstm_usedmap_ee[4],
998 g_cdvdstm_bankcur_ee);
999 posszarg2_bytes_overrun = posszarg2_bytes - (posszarg2_bytes_remain - posszarg2_bytes_clamped);
1004 if ( posszarg2_bytes_overrun == -1 )
1005 posszarg2_bytes_overrun = posszarg2_bytes;
1006 outres_tmp2 = (retryflag) ? 1 : (posszarg2_bytes_overrun / 0x800);
1009 if ( sceCdSC(0xFFFFFFFF, &g_cdvdstm_last_error_for_ee) != 2 && !outres_tmp2 && !g_cdvdstm_retryerr_ee )
1010 g_cdvdstm_retryerr_ee = 273;
1011 if ( g_cdvdstm_retryerr_ee )
1013 outres_tmp2 = (u16)outres_tmp2 | (g_cdvdstm_retryerr_ee << 16);
1014 g_cdvdstm_retryerr_ee = 0;
1017 *outres_ptr = outres_tmp2;
1021static unsigned int ee_stream_intr_cb_normal(
void *userdata)
1027 VERBOSE_KPRINTF(1,
"Intr EE Stm Read call\n");
1028 iCancelAlarm(stm_ee_read_timeout_alarm_cb, &g_cdvdstm_curclk_ee);
1029 iCancelAlarm(ee_stream_intr_cb_normal, &g_cdvdstm_curclk_ee);
1030 sceCdSC(0xFFFFFFFF, &g_cdvdstm_last_error_for_ee);
1031 if ( !g_cdvdstm_last_error_for_ee )
1033#ifdef CDVD_VARIANT_XOSD
1034 switch ( sceCdSC(0xFFFFFFDA, &scres_unused) )
1050 g_cdvdstm_curclk_ee.hi = 0;
1051 if ( g_cdvdstm_stmstart_ee )
1052 g_cdvdstm_retrycnt_ee_normal = 0;
1053 g_cdvdstm_curclk_ee.lo = (g_cdvdstm_stmstart_ee || g_cdvdstm_last_error_for_ee || g_cdvdstm_retrycnt_ee_normal) ?
1055 (0x9000 * sceCdSC(0xFFFFFFEF, &scres_unused));
1056 if ( g_cdvdstm_last_error_for_ee )
1060 "EE Stream read LBN= %d Error code= 0x%02x retry= %d\n",
1061 g_cdvdstm_readlbn_ee_normal,
1062 g_cdvdstm_last_error_for_ee,
1063 g_cdvdstm_retrycnt_ee_normal);
1066 if ( g_cdvdstm_retrycnt_ee_normal )
1068 VERBOSE_KPRINTF(1,
"On Retry retry %d err %08x\n", g_cdvdstm_retrycnt_ee_normal, g_cdvdstm_last_error_for_ee);
1070 g_cdvdstm_retrycnt_ee_normal = 3;
1074 g_cdvdstm_retrycnt_ee_normal = 1;
1076 g_cdvdstm_retryerr_ee = g_cdvdstm_last_error_for_ee;
1078 if ( g_cdvdstm_retrycnt_ee_normal )
1080 g_cdvdstm_retrycnt_ee_normal -= 1;
1082 ((
unsigned int)g_cdvdstm_readlbn_ee_normal >= (
unsigned int)(0x10 * g_cdvdstm_retrycnt_ee_normal)) ?
1083 (g_cdvdstm_readlbn_ee_normal - 0x10 * g_cdvdstm_retrycnt_ee_normal) :
1084 (g_cdvdstm_readlbn_ee_normal + 0x10 * g_cdvdstm_retrycnt_ee_normal),
1085 g_cdvdstm_sectorcount2,
1086 (
char *)g_cdvdstm_buffer2 + g_cdvdstm_bankgp_ee * g_cdvdstm_chunksz2,
1087 &g_cdvdstm_mode_ee) )
1089 iSetAlarm(&g_cdvdstm_curclk_ee, stm_ee_read_timeout_alarm_cb, &g_cdvdstm_curclk_ee);
1093 VERBOSE_KPRINTF(1,
"Stm Read Call fail\n");
1094 g_cdvdstm_curclk_ee.lo = 0x708000;
1096 iSetAlarm(&g_cdvdstm_curclk_ee, ee_stream_intr_cb_normal, &g_cdvdstm_curclk_ee)
1099 sceCdSC(0, &g_cdvdstm_last_error_for_ee);
1101 g_cdvdstm_retrycnt_ee_normal += 1;
1108 if ( !g_cdvdstm_stmstart_ee )
1110 g_cdvdstm_usedmap_ee[g_cdvdstm_bankgp_ee] = 1;
1111 gptmp = g_cdvdstm_bankgp_ee;
1112 g_cdvdstm_bankgp_ee += 1;
1113 if ( (
unsigned int)g_cdvdstm_bankgp_ee >= (
unsigned int)g_cdvdstm_bankcnt2 )
1114 g_cdvdstm_bankgp_ee = 0;
1117 !g_cdvdstm_stmstart_ee
1118 && (g_cdvdstm_usedmap_ee[g_cdvdstm_bankgp_ee] || g_cdvdstm_bankcur_ee == g_cdvdstm_bankgp_ee) )
1120 g_cdvdstm_bankgp_ee = gptmp;
1121 g_cdvdstm_usedmap_ee[gptmp] = 0;
1124 "read Full %d %d %d %d %d gp %d pp %d spn %d\n",
1125 (u8)g_cdvdstm_usedmap_ee[0],
1126 (u8)g_cdvdstm_usedmap_ee[1],
1127 (u8)g_cdvdstm_usedmap_ee[2],
1128 (u8)g_cdvdstm_usedmap_ee[3],
1129 (u8)g_cdvdstm_usedmap_ee[4],
1130 g_cdvdstm_bankgp_ee,
1131 g_cdvdstm_bankcur_ee,
1133 g_cdvdstm_curclk_ee.lo = 0x48000;
1135 iSetAlarm(&g_cdvdstm_curclk_ee, ee_stream_intr_cb_normal, &g_cdvdstm_curclk_ee)
1138 sceCdSC(0, &g_cdvdstm_last_error_for_ee);
1143 if ( g_cdvdstm_stmstart_ee == 2 )
1147 g_cdvdstm_bankoffs_ee = 0;
1148 g_cdvdstm_bankcur_ee = 0;
1149 g_cdvdstm_bankgp_ee = 0;
1150 for ( i = 0; i < (
unsigned int)g_cdvdstm_bankcnt2; i += 1 )
1151 g_cdvdstm_usedmap_ee[i] = 0;
1153 g_cdvdstm_stmstart_ee = 0;
1154 g_cdvdstm_readlbn_ee_normal = g_cdvdstm_lsn_ee;
1157 g_cdvdstm_sectorcount2,
1158 (
char *)g_cdvdstm_buffer2 + g_cdvdstm_bankgp_ee * g_cdvdstm_chunksz2,
1159 &g_cdvdstm_mode_ee) )
1161 iSetAlarm(&g_cdvdstm_curclk_ee, stm_ee_read_timeout_alarm_cb, &g_cdvdstm_curclk_ee);
1165 VERBOSE_KPRINTF(1,
"Stm Read Call1 fail\n");
1166 g_cdvdstm_curclk_ee.lo = 0x708000;
1168 iSetAlarm(&g_cdvdstm_curclk_ee, ee_stream_intr_cb_normal, &g_cdvdstm_curclk_ee)
1171 sceCdSC(0, &g_cdvdstm_last_error_for_ee);
1173 g_cdvdstm_retrycnt_ee_normal = 1;
1175 g_cdvdstm_lsn_ee += g_cdvdstm_sectorcount2;
1181static void ee_stream_handler_cdda(
cdrom_stm_devctl_t *instruct,
int inbuf_len,
int *outres_ptr)
1184 u32 posszarg2_bytes;
1188 int bankcur_next_tmp1;
1189 int posszarg2_bytes_clamped;
1191 int bankcur_next_tmp2;
1192 int posszarg2_overrun_chunks2;
1193 unsigned int posszarg2_bytes_overrun;
1199 cmdid = instruct->m_cmdid;
1200 posszarg2_bytes = instruct->m_posszarg2 * g_cdvdstm_usedchunksize2;
1202 if ( g_cdvdstm_stmstart_ee == 2 && (cmdid != 9 && cmdid != 3) )
1210 sceCdSC(2, &g_cdvdstm_last_error_for_ee);
1216 sceCdSC(0, &g_cdvdstm_last_error_for_ee);
1221 CancelAlarm(ee_stream_intr_cb_cdda, &g_cdvdstm_curclk_ee);
1222 sceCdSC(0, &g_cdvdstm_last_error_for_ee);
1226 CancelAlarm(stm_ee_read_timeout_alarm_cb, &g_cdvdstm_curclk_ee);
1229 bankcur_tmp = g_cdvdstm_bankcur_ee;
1230 if ( !g_cdvdstm_usedmap_ee[bankcur_tmp] )
1233 if ( (
unsigned int)bankcur_tmp >= (
unsigned int)g_cdvdstm_bankcnt2 )
1235 if ( !g_cdvdstm_usedmap_ee[bankcur_tmp] )
1236 bankcur_tmp = g_cdvdstm_bankcur_ee;
1238 for ( i = 0; (i < (
unsigned int)g_cdvdstm_bankcnt2) && g_cdvdstm_usedmap_ee[bankcur_tmp]
1239 && (g_cdvdstm_bankgp_ee != bankcur_tmp);
1243 if ( (
unsigned int)(bankcur_tmp) >= (
unsigned int)g_cdvdstm_bankcnt2 )
1246 if ( !g_cdvdstm_usedchunksize2 )
1248 *outres_ptr = i * (g_cdvdstm_chunksz2 / (
unsigned int)g_cdvdstm_usedchunksize2);
1251 sceCdstm1Cb(ee_stream_intr_cb_cdda_thunk);
1255 g_cdvdstm_usedchunksize2 = 2368;
1258 g_cdvdstm_usedchunksize2 = 2448;
1262 g_cdvdstm_usedchunksize2 = 0x930;
1265 if ( !instruct->m_posszarg2 )
1267 chunks_sectors = instruct->m_posszarg1 / instruct->m_posszarg2;
1268 g_cdvdstm_bufsz2 = instruct->m_posszarg1;
1269 g_cdvdstm_sectorcount2 = chunks_sectors;
1270 g_cdvdstm_chunksz2 = chunks_sectors * g_cdvdstm_usedchunksize2;
1271 g_cdvdstm_buffer2 = (
char *)instruct->m_buffer;
1272 g_cdvdstm_bankcnt2 = instruct->m_posszarg2;
1274 "DA Stream Buffer 1Bank %dbyte %dbanks %dbyte used\n",
1275 (
int)(chunks_sectors * g_cdvdstm_usedchunksize2),
1276 (
int)instruct->m_posszarg2,
1277 (
int)(chunks_sectors * g_cdvdstm_usedchunksize2 * instruct->m_posszarg2));
1282 g_cdvdstm_stmstart_ee = 0;
1283 CancelAlarm(ee_stream_intr_cb_cdda, &g_cdvdstm_curclk_ee);
1284 sceCdSC(0, &g_cdvdstm_last_error_for_ee);
1287 for ( i = 0; i < (
unsigned int)g_cdvdstm_bankcnt2; i += 1 )
1289 g_cdvdstm_usedmap_ee[i] = 0;
1291 g_cdvdstm_bankoffs_ee = 0;
1292 g_cdvdstm_bankcur_ee = 0;
1293 g_cdvdstm_bankgp_ee = 0;
1296 g_cdvdstm_last_error_for_ee = 0;
1297 sceCdSC(0xFFFFFFFE, &g_cdvdstm_last_error_for_ee);
1298 CancelAlarm(stm_ee_read_timeout_alarm_cb, &g_cdvdstm_curclk_ee);
1304 g_cdvdstm_retryerr_ee = 0;
1309 if ( sceCdSC(0xFFFFFFFF, &g_cdvdstm_last_error_for_ee) )
1312 g_cdvdstm_lsn_ee = instruct->m_posszarg1;
1313 for ( i = 0; i < (
unsigned int)g_cdvdstm_bankcnt2; i += 1 )
1315 g_cdvdstm_usedmap_ee[i] = 0;
1317 g_cdvdstm_stmstart_ee = 2;
1329 CancelAlarm(ee_stream_intr_cb_cdda, &g_cdvdstm_curclk_ee);
1330 sceCdSC(0, &g_cdvdstm_last_error_for_ee);
1331 posszarg2_bytes = 0;
1334 g_cdvdstm_lsn_ee = instruct->m_posszarg1;
1335 g_cdvdstm_bankoffs_ee = 0;
1336 g_cdvdstm_bankcur_ee = 0;
1337 g_cdvdstm_bankgp_ee = 0;
1339 CancelAlarm(stm_ee_read_timeout_alarm_cb, &g_cdvdstm_curclk_ee);
1343 signed int posszarg2_chunks;
1346 CancelAlarm(ee_stream_intr_cb_cdda, &g_cdvdstm_curclk_ee);
1347 sceCdSC(0, &g_cdvdstm_last_error_for_ee);
1350 for ( i = 0; i < (
unsigned int)g_cdvdstm_bankcnt2; i += 1 )
1352 g_cdvdstm_usedmap_ee[i] = 0;
1354 g_cdvdstm_lsn_ee = instruct->m_posszarg1;
1355 g_cdvdstm_bankoffs_ee = 0;
1356 g_cdvdstm_bankcur_ee = 0;
1358 CancelAlarm(stm_ee_read_timeout_alarm_cb, &g_cdvdstm_curclk_ee);
1359 if ( !g_cdvdstm_chunksz2 )
1361 posszarg2_chunks = (posszarg2_bytes / g_cdvdstm_chunksz2) + (!!(posszarg2_bytes % g_cdvdstm_chunksz2));
1362 for ( g_cdvdstm_bankgp_ee = 0; g_cdvdstm_bankgp_ee < posszarg2_chunks; g_cdvdstm_bankgp_ee += 1 )
1366 outres_tmp2 = sceCdReadCDDA(g_cdvdstm_lsn_ee, g_cdvdstm_sectorcount2, g_cdvdstm_buffer2, &g_cdvdstm_mode_ee);
1368 sceCdSC(0xFFFFFFFF, &g_cdvdstm_last_error_for_ee);
1369 if ( g_cdvdstm_last_error_for_ee || !outres_tmp2 )
1371 sceCdSC(0, &g_cdvdstm_last_error_for_ee);
1375 g_cdvdstm_lsn_ee += g_cdvdstm_sectorcount2;
1376 g_cdvdstm_usedmap_ee[g_cdvdstm_bankgp_ee] = 1;
1378 g_cdvdstm_stmstart_ee = 1;
1379 sceCdSC(2, &g_cdvdstm_last_error_for_ee);
1382 sceCdSC(0, &g_cdvdstm_last_error_for_ee);
1387 posszarg2_bytes_overrun = -1;
1388 for ( i = 0; i < posszarg2_bytes; i += posszarg2_bytes_clamped )
1390 unsigned int posszarg2_bytes_remain;
1392 posszarg2_bytes_remain = posszarg2_bytes - i;
1393 if ( !g_cdvdstm_usedmap_ee[g_cdvdstm_bankcur_ee] )
1397 "CD read buffer over run %d %d %d %d %d gp %d pp %d\n",
1398 (u8)g_cdvdstm_usedmap_ee[0],
1399 (u8)g_cdvdstm_usedmap_ee[1],
1400 (u8)g_cdvdstm_usedmap_ee[2],
1401 (u8)g_cdvdstm_usedmap_ee[3],
1402 (u8)g_cdvdstm_usedmap_ee[4],
1403 g_cdvdstm_bankgp_ee,
1404 g_cdvdstm_bankcur_ee);
1406 bankcur_next_tmp1 = g_cdvdstm_bankcur_ee;
1407 g_cdvdstm_bankcur_ee += 1;
1408 if ( (
unsigned int)g_cdvdstm_bankcur_ee >= (
unsigned int)g_cdvdstm_bankcnt2 )
1409 g_cdvdstm_bankcur_ee = 0;
1410 if ( !g_cdvdstm_usedmap_ee[g_cdvdstm_bankcur_ee] )
1411 g_cdvdstm_bankcur_ee = bankcur_next_tmp1;
1412 posszarg2_bytes_overrun = posszarg2_bytes - posszarg2_bytes_remain;
1416 posszarg2_bytes_clamped = ((
unsigned int)(g_cdvdstm_chunksz2 - g_cdvdstm_bankoffs_ee) < posszarg2_bytes_remain) ?
1417 (
unsigned int)(g_cdvdstm_chunksz2 - g_cdvdstm_bankoffs_ee) :
1418 posszarg2_bytes_remain;
1419 g_cdvdstm_dmat2.dest = ((
char *)instruct->m_buffer) + i;
1420 g_cdvdstm_dmat2.size = posszarg2_bytes_clamped;
1421 g_cdvdstm_dmat2.attr = 0;
1422 g_cdvdstm_dmat2.src = (
char *)g_cdvdstm_buffer2 + g_cdvdstm_bankcur_ee * g_cdvdstm_chunksz2 + g_cdvdstm_bankoffs_ee;
1423 if ( posszarg2_bytes_clamped )
1428 dmat2 = sceSifSetDma(&g_cdvdstm_dmat2, 1);
1434 g_cdvdstm_bankoffs_ee += posszarg2_bytes_clamped;
1435 while ( vsceSifDmaStat(dmat2) >= 0 )
1438 if ( (
unsigned int)g_cdvdstm_bankoffs_ee >= (
unsigned int)g_cdvdstm_chunksz2 )
1441 g_cdvdstm_bankoffs_ee = 0;
1442 g_cdvdstm_usedmap_ee[g_cdvdstm_bankcur_ee] = 0;
1443 bankcur_next_tmp2 = g_cdvdstm_bankcur_ee;
1444 g_cdvdstm_bankcur_ee += 1;
1445 if ( (
unsigned int)g_cdvdstm_bankcur_ee >= (
unsigned int)g_cdvdstm_bankcnt2 )
1446 g_cdvdstm_bankcur_ee = 0;
1447 if ( g_cdvdstm_usedmap_ee[g_cdvdstm_bankcur_ee] && g_cdvdstm_bankgp_ee != g_cdvdstm_bankcur_ee )
1453 g_cdvdstm_bankcur_ee = bankcur_next_tmp2;
1457 "CD read buffer over run %d %d %d %d %d gp %d pp %d\n",
1458 (u8)g_cdvdstm_usedmap_ee[0],
1459 (u8)g_cdvdstm_usedmap_ee[1],
1460 (u8)g_cdvdstm_usedmap_ee[2],
1461 (u8)g_cdvdstm_usedmap_ee[3],
1462 (u8)g_cdvdstm_usedmap_ee[4],
1463 g_cdvdstm_bankgp_ee,
1464 g_cdvdstm_bankcur_ee);
1465 posszarg2_bytes_overrun = posszarg2_bytes - (posszarg2_bytes_remain - posszarg2_bytes_clamped);
1470 if ( posszarg2_bytes_overrun == 0xFFFFFFFF )
1471 posszarg2_bytes_overrun = posszarg2_bytes;
1472 if ( !g_cdvdstm_usedchunksize2 )
1474 posszarg2_overrun_chunks2 = posszarg2_bytes_overrun / g_cdvdstm_usedchunksize2;
1480 if ( sceCdSC(0xFFFFFFFF, &g_cdvdstm_last_error_for_ee) != 2 && !posszarg2_overrun_chunks2 && !g_cdvdstm_retryerr_ee )
1481 g_cdvdstm_retryerr_ee = 273;
1482 if ( g_cdvdstm_retryerr_ee )
1484 posszarg2_overrun_chunks2 = (u16)posszarg2_overrun_chunks2 | (g_cdvdstm_retryerr_ee << 16);
1485 g_cdvdstm_retryerr_ee = 0;
1487 *outres_ptr = posszarg2_overrun_chunks2;
1490static unsigned int ee_stream_intr_cb_cdda(
void *userdata)
1496 VERBOSE_KPRINTF(1,
"Intr EE DA Stm Read call\n");
1497 iCancelAlarm(stm_ee_read_timeout_alarm_cb, &g_cdvdstm_curclk_ee);
1498 iCancelAlarm(ee_stream_intr_cb_cdda, &g_cdvdstm_curclk_ee);
1499 sceCdSC(0xFFFFFFFF, &g_cdvdstm_last_error_for_ee);
1500 if ( !g_cdvdstm_last_error_for_ee )
1502#ifdef CDVD_VARIANT_XOSD
1503 switch ( sceCdSC(0xFFFFFFDA, &scres_unused) )
1518 g_cdvdstm_curclk_ee.hi = 0;
1519 if ( g_cdvdstm_stmstart_ee )
1520 g_cdvdstm_retrycnt_ee_cdda = 0;
1521 g_cdvdstm_curclk_ee.lo = (g_cdvdstm_stmstart_ee || g_cdvdstm_last_error_for_ee || g_cdvdstm_retrycnt_ee_cdda) ?
1523 (0x9000 * sceCdSC(0xFFFFFFEF, &scres_unused));
1524 if ( g_cdvdstm_last_error_for_ee )
1528 "EE Stream read LBN= %d Error code= 0x%02x retry= %d\n",
1529 g_cdvdstm_readlbn_ee_cdda,
1530 g_cdvdstm_last_error_for_ee,
1531 g_cdvdstm_retrycnt_ee_cdda);
1534 if ( g_cdvdstm_retrycnt_ee_cdda )
1536 VERBOSE_KPRINTF(1,
"On Retry retry %d err %08x\n", g_cdvdstm_retrycnt_ee_cdda, g_cdvdstm_last_error_for_ee);
1538 g_cdvdstm_retrycnt_ee_cdda = 4;
1542 g_cdvdstm_retrycnt_ee_cdda = 1;
1544 g_cdvdstm_retryerr_ee = g_cdvdstm_last_error_for_ee;
1548 g_cdvdstm_retrycnt_ee_cdda = 0;
1550 if ( g_cdvdstm_retrycnt_ee_cdda )
1552 g_cdvdstm_retrycnt_ee_cdda -= 1;
1554 !g_cdvdstm_retrycnt_ee_cdda
1557 g_cdvdstm_readlbn_ee_cdda =
1558 g_cdvdstm_lsn_ee + ((g_cdvdstm_sectorcount2 < 0x1D) ? (0x1D - g_cdvdstm_sectorcount2) : 0);
1559 g_cdvdstm_lsn_ee = g_cdvdstm_readlbn_ee_cdda + g_cdvdstm_sectorcount2;
1562 g_cdvdstm_readlbn_ee_cdda,
1563 g_cdvdstm_sectorcount2,
1564 (
char *)g_cdvdstm_buffer2 + g_cdvdstm_bankgp_ee * g_cdvdstm_chunksz2,
1565 &g_cdvdstm_mode_ee) )
1567 iSetAlarm(&g_cdvdstm_curclk_ee, stm_ee_read_timeout_alarm_cb, &g_cdvdstm_curclk_ee);
1571 VERBOSE_KPRINTF(1,
"Stm Read Call fail\n");
1572 g_cdvdstm_curclk_ee.lo = 0x708000;
1574 iSetAlarm(&g_cdvdstm_curclk_ee, ee_stream_intr_cb_cdda, &g_cdvdstm_curclk_ee)
1577 sceCdSC(0, &g_cdvdstm_last_error_for_ee);
1579 g_cdvdstm_retrycnt_ee_cdda += 1;
1586 if ( !g_cdvdstm_stmstart_ee )
1588 g_cdvdstm_usedmap_ee[g_cdvdstm_bankgp_ee] = 1;
1589 gptmp = g_cdvdstm_bankgp_ee;
1590 g_cdvdstm_bankgp_ee += 1;
1591 if ( (
unsigned int)g_cdvdstm_bankgp_ee >= (
unsigned int)g_cdvdstm_bankcnt2 )
1592 g_cdvdstm_bankgp_ee = 0;
1595 !g_cdvdstm_stmstart_ee
1596 && (g_cdvdstm_usedmap_ee[g_cdvdstm_bankgp_ee] || g_cdvdstm_bankcur_ee == g_cdvdstm_bankgp_ee) )
1598 g_cdvdstm_bankgp_ee = gptmp;
1599 g_cdvdstm_usedmap_ee[gptmp] = 0;
1602 "read Full %d %d %d %d %d gp %d pp %d spn %d\n",
1603 (u8)g_cdvdstm_usedmap_ee[0],
1604 (u8)g_cdvdstm_usedmap_ee[1],
1605 (u8)g_cdvdstm_usedmap_ee[2],
1606 (u8)g_cdvdstm_usedmap_ee[3],
1607 (u8)g_cdvdstm_usedmap_ee[4],
1608 g_cdvdstm_bankgp_ee,
1609 g_cdvdstm_bankcur_ee,
1611 g_cdvdstm_curclk_ee.lo = 0x48000;
1613 iSetAlarm(&g_cdvdstm_curclk_ee, ee_stream_intr_cb_cdda, &g_cdvdstm_curclk_ee)
1616 sceCdSC(0, &g_cdvdstm_last_error_for_ee);
1621 if ( g_cdvdstm_stmstart_ee == 2 )
1625 g_cdvdstm_bankoffs_ee = 0;
1626 g_cdvdstm_bankcur_ee = 0;
1627 g_cdvdstm_bankgp_ee = 0;
1628 for ( i = 0; i < (
unsigned int)g_cdvdstm_bankcnt2; i += 1 )
1629 g_cdvdstm_usedmap_ee[i] = 0;
1631 g_cdvdstm_stmstart_ee = 0;
1632 g_cdvdstm_readlbn_ee_cdda = g_cdvdstm_lsn_ee;
1635 g_cdvdstm_sectorcount2,
1636 (
char *)g_cdvdstm_buffer2 + g_cdvdstm_bankgp_ee * g_cdvdstm_chunksz2,
1637 &g_cdvdstm_mode_ee) )
1639 iSetAlarm(&g_cdvdstm_curclk_ee, stm_ee_read_timeout_alarm_cb, &g_cdvdstm_curclk_ee);
1643 VERBOSE_KPRINTF(1,
"Stm Read Call1 fail\n");
1644 g_cdvdstm_curclk_ee.lo = 0x708000;
1646 iSetAlarm(&g_cdvdstm_curclk_ee, ee_stream_intr_cb_cdda, &g_cdvdstm_curclk_ee)
1649 sceCdSC(0, &g_cdvdstm_last_error_for_ee);
1651 g_cdvdstm_retrycnt_ee_cdda = 1;
1653 g_cdvdstm_lsn_ee += g_cdvdstm_sectorcount2;
1661 "\t" ".set push" "\n"
1662 "\t" ".set noat" "\n"
1663 "\t" ".set noreorder" "\n"
1664 "\t" ".global optimized_memcpy" "\n"
1665 "\t" "optimized_memcpy:" "\n"
1666 "\t" " srl $a3, $a2, 2" "\n"
1667 "\t" " beqz $a3, .Loptimized_memcpy_12" "\n"
1668 "\t" " or $a3, $a0, $a1" "\n"
1669 "\t" " andi $a3, $a3, 0x3" "\n"
1670 "\t" " bnez $a3, .Loptimized_memcpy_3" "\n"
1672 "\t" " srl $a3, $a2, 2" "\n"
1673 "\t" " addiu $at, $zero, 0xC" "\n"
1674 "\t" " div $zero, $a3, $at" "\n"
1675 "\t" " mflo $a3" "\n"
1676 "\t" " mfhi $v1" "\n"
1677 "\t" " beqz $v1, .Loptimized_memcpy_2" "\n"
1679 "\t" ".Loptimized_memcpy_1:" "\n"
1680 "\t" " lw $v0, 0x0($a1)" "\n"
1681 "\t" " addiu $v1, $v1, -0x1" "\n"
1682 "\t" " sw $v0, 0x0($a0)" "\n"
1683 "\t" " addiu $a1, $a1, 0x4" "\n"
1684 "\t" " bnez $v1, .Loptimized_memcpy_1" "\n"
1685 "\t" " addiu $a0, $a0, 0x4" "\n"
1686 "\t" " beqz $a3, .Loptimized_memcpy_12" "\n"
1688 "\t" ".Loptimized_memcpy_2:" "\n"
1689 "\t" " lw $v0, 0x0($a1)" "\n"
1690 "\t" " lw $v1, 0x4($a1)" "\n"
1691 "\t" " lw $t0, 0x8($a1)" "\n"
1692 "\t" " lw $t1, 0xC($a1)" "\n"
1693 "\t" " lw $t2, 0x10($a1)" "\n"
1694 "\t" " lw $t3, 0x14($a1)" "\n"
1695 "\t" " lw $t4, 0x18($a1)" "\n"
1696 "\t" " lw $t5, 0x1C($a1)" "\n"
1697 "\t" " lw $t6, 0x20($a1)" "\n"
1698 "\t" " lw $t7, 0x24($a1)" "\n"
1699 "\t" " lw $t8, 0x28($a1)" "\n"
1700 "\t" " lw $t9, 0x2C($a1)" "\n"
1701 "\t" " addiu $a3, $a3, -0x1" "\n"
1702 "\t" " sw $v0, 0x0($a0)" "\n"
1703 "\t" " sw $v1, 0x4($a0)" "\n"
1704 "\t" " sw $t0, 0x8($a0)" "\n"
1705 "\t" " sw $t1, 0xC($a0)" "\n"
1706 "\t" " sw $t2, 0x10($a0)" "\n"
1707 "\t" " sw $t3, 0x14($a0)" "\n"
1708 "\t" " sw $t4, 0x18($a0)" "\n"
1709 "\t" " sw $t5, 0x1C($a0)" "\n"
1710 "\t" " sw $t6, 0x20($a0)" "\n"
1711 "\t" " sw $t7, 0x24($a0)" "\n"
1712 "\t" " sw $t8, 0x28($a0)" "\n"
1713 "\t" " sw $t9, 0x2C($a0)" "\n"
1714 "\t" " addiu $a1, $a1, 0x30" "\n"
1715 "\t" " bnez $a3, .Loptimized_memcpy_2" "\n"
1716 "\t" " addiu $a0, $a0, 0x30" "\n"
1717 "\t" " j .Loptimized_memcpy_12" "\n"
1719 "\t" ".Loptimized_memcpy_3:" "\n"
1720 "\t" " andi $a3, $a0, 0x3" "\n"
1721 "\t" " beqz $a3, .Loptimized_memcpy_6" "\n"
1722 "\t" " andi $a3, $a1, 0x3" "\n"
1723 "\t" " beqz $a3, .Loptimized_memcpy_6" "\n"
1725 "\t" " srl $a3, $a2, 2" "\n"
1726 "\t" " addiu $at, $zero, 0xC" "\n"
1727 "\t" " div $zero, $a3, $at" "\n"
1728 "\t" " mflo $a3" "\n"
1729 "\t" " mfhi $v1" "\n"
1730 "\t" " beqz $v1, .Loptimized_memcpy_5" "\n"
1732 "\t" ".Loptimized_memcpy_4:" "\n"
1733 "\t" " lwl $v0, 0x3($a1)" "\n"
1734 "\t" " lwr $v0, 0x0($a1)" "\n"
1735 "\t" " addiu $v1, $v1, -0x1" "\n"
1736 "\t" " swl $v0, 0x3($a0)" "\n"
1737 "\t" " swr $v0, 0x0($a0)" "\n"
1738 "\t" " addiu $a1, $a1, 0x4" "\n"
1739 "\t" " bnez $v1, .Loptimized_memcpy_4" "\n"
1740 "\t" " addiu $a0, $a0, 0x4" "\n"
1741 "\t" " beqz $a3, .Loptimized_memcpy_12" "\n"
1743 "\t" ".Loptimized_memcpy_5:" "\n"
1744 "\t" " lwl $v0, 0x3($a1)" "\n"
1745 "\t" " lwr $v0, 0x0($a1)" "\n"
1746 "\t" " lwl $v1, 0x7($a1)" "\n"
1747 "\t" " lwr $v1, 0x4($a1)" "\n"
1748 "\t" " lwl $t0, 0xB($a1)" "\n"
1749 "\t" " lwr $t0, 0x8($a1)" "\n"
1750 "\t" " lwl $t1, 0xF($a1)" "\n"
1751 "\t" " lwr $t1, 0xC($a1)" "\n"
1752 "\t" " lwl $t2, 0x13($a1)" "\n"
1753 "\t" " lwr $t2, 0x10($a1)" "\n"
1754 "\t" " lwl $t3, 0x17($a1)" "\n"
1755 "\t" " lwr $t3, 0x14($a1)" "\n"
1756 "\t" " lwl $t4, 0x1B($a1)" "\n"
1757 "\t" " lwr $t4, 0x18($a1)" "\n"
1758 "\t" " lwl $t5, 0x1F($a1)" "\n"
1759 "\t" " lwr $t5, 0x1C($a1)" "\n"
1760 "\t" " lwl $t6, 0x23($a1)" "\n"
1761 "\t" " lwr $t6, 0x20($a1)" "\n"
1762 "\t" " lwl $t7, 0x27($a1)" "\n"
1763 "\t" " lwr $t7, 0x24($a1)" "\n"
1764 "\t" " lwl $t8, 0x2B($a1)" "\n"
1765 "\t" " lwr $t8, 0x28($a1)" "\n"
1766 "\t" " lwl $t9, 0x2F($a1)" "\n"
1767 "\t" " lwr $t9, 0x2C($a1)" "\n"
1768 "\t" " addiu $a3, $a3, -0x1" "\n"
1769 "\t" " swl $v0, 0x3($a0)" "\n"
1770 "\t" " swr $v0, 0x0($a0)" "\n"
1771 "\t" " swl $v1, 0x7($a0)" "\n"
1772 "\t" " swr $v1, 0x4($a0)" "\n"
1773 "\t" " swl $t0, 0xB($a0)" "\n"
1774 "\t" " swr $t0, 0x8($a0)" "\n"
1775 "\t" " swl $t1, 0xF($a0)" "\n"
1776 "\t" " swr $t1, 0xC($a0)" "\n"
1777 "\t" " swl $t2, 0x13($a0)" "\n"
1778 "\t" " swr $t2, 0x10($a0)" "\n"
1779 "\t" " swl $t3, 0x17($a0)" "\n"
1780 "\t" " swr $t3, 0x14($a0)" "\n"
1781 "\t" " swl $t4, 0x1B($a0)" "\n"
1782 "\t" " swr $t4, 0x18($a0)" "\n"
1783 "\t" " swl $t5, 0x1F($a0)" "\n"
1784 "\t" " swr $t5, 0x1C($a0)" "\n"
1785 "\t" " swl $t6, 0x23($a0)" "\n"
1786 "\t" " swr $t6, 0x20($a0)" "\n"
1787 "\t" " swl $t7, 0x27($a0)" "\n"
1788 "\t" " swr $t7, 0x24($a0)" "\n"
1789 "\t" " swl $t8, 0x2B($a0)" "\n"
1790 "\t" " swr $t8, 0x28($a0)" "\n"
1791 "\t" " swl $t9, 0x2F($a0)" "\n"
1792 "\t" " swr $t9, 0x2C($a0)" "\n"
1793 "\t" " addiu $a1, $a1, 0x30" "\n"
1794 "\t" " bnez $a3, .Loptimized_memcpy_5" "\n"
1795 "\t" " addiu $a0, $a0, 0x30" "\n"
1796 "\t" " j .Loptimized_memcpy_12" "\n"
1798 "\t" ".Loptimized_memcpy_6:" "\n"
1799 "\t" " andi $a3, $a0, 0x3" "\n"
1800 "\t" " beqz $a3, .Loptimized_memcpy_9" "\n"
1802 "\t" " srl $a3, $a2, 2" "\n"
1803 "\t" " addiu $at, $zero, 0xC" "\n"
1804 "\t" " div $zero, $a3, $at" "\n"
1805 "\t" " mflo $a3" "\n"
1806 "\t" " mfhi $v1" "\n"
1807 "\t" " beqz $v1, .Loptimized_memcpy_8" "\n"
1809 "\t" ".Loptimized_memcpy_7:" "\n"
1810 "\t" " lw $v0, 0x0($a1)" "\n"
1811 "\t" " addiu $v1, $v1, -0x1" "\n"
1812 "\t" " swl $v0, 0x3($a0)" "\n"
1813 "\t" " swr $v0, 0x0($a0)" "\n"
1814 "\t" " addiu $a1, $a1, 0x4" "\n"
1815 "\t" " bnez $v1, .Loptimized_memcpy_7" "\n"
1816 "\t" " addiu $a0, $a0, 0x4" "\n"
1817 "\t" " beqz $a3, .Loptimized_memcpy_12" "\n"
1819 "\t" ".Loptimized_memcpy_8:" "\n"
1820 "\t" " lw $v0, 0x0($a1)" "\n"
1821 "\t" " lw $v1, 0x4($a1)" "\n"
1822 "\t" " lw $t0, 0x8($a1)" "\n"
1823 "\t" " lw $t1, 0xC($a1)" "\n"
1824 "\t" " lw $t2, 0x10($a1)" "\n"
1825 "\t" " lw $t3, 0x14($a1)" "\n"
1826 "\t" " lw $t4, 0x18($a1)" "\n"
1827 "\t" " lw $t5, 0x1C($a1)" "\n"
1828 "\t" " lw $t6, 0x20($a1)" "\n"
1829 "\t" " lw $t7, 0x24($a1)" "\n"
1830 "\t" " lw $t8, 0x28($a1)" "\n"
1831 "\t" " lw $t9, 0x2C($a1)" "\n"
1832 "\t" " addiu $a3, $a3, -0x1" "\n"
1833 "\t" " swl $v0, 0x3($a0)" "\n"
1834 "\t" " swr $v0, 0x0($a0)" "\n"
1835 "\t" " swl $v1, 0x7($a0)" "\n"
1836 "\t" " swr $v1, 0x4($a0)" "\n"
1837 "\t" " swl $t0, 0xB($a0)" "\n"
1838 "\t" " swr $t0, 0x8($a0)" "\n"
1839 "\t" " swl $t1, 0xF($a0)" "\n"
1840 "\t" " swr $t1, 0xC($a0)" "\n"
1841 "\t" " swl $t2, 0x13($a0)" "\n"
1842 "\t" " swr $t2, 0x10($a0)" "\n"
1843 "\t" " swl $t3, 0x17($a0)" "\n"
1844 "\t" " swr $t3, 0x14($a0)" "\n"
1845 "\t" " swl $t4, 0x1B($a0)" "\n"
1846 "\t" " swr $t4, 0x18($a0)" "\n"
1847 "\t" " swl $t5, 0x1F($a0)" "\n"
1848 "\t" " swr $t5, 0x1C($a0)" "\n"
1849 "\t" " swl $t6, 0x23($a0)" "\n"
1850 "\t" " swr $t6, 0x20($a0)" "\n"
1851 "\t" " swl $t7, 0x27($a0)" "\n"
1852 "\t" " swr $t7, 0x24($a0)" "\n"
1853 "\t" " swl $t8, 0x2B($a0)" "\n"
1854 "\t" " swr $t8, 0x28($a0)" "\n"
1855 "\t" " swl $t9, 0x2F($a0)" "\n"
1856 "\t" " swr $t9, 0x2C($a0)" "\n"
1857 "\t" " addiu $a1, $a1, 0x30" "\n"
1858 "\t" " bnez $a3, .Loptimized_memcpy_8" "\n"
1859 "\t" " addiu $a0, $a0, 0x30" "\n"
1860 "\t" " j .Loptimized_memcpy_12" "\n"
1862 "\t" ".Loptimized_memcpy_9:" "\n"
1863 "\t" " srl $a3, $a2, 2" "\n"
1864 "\t" " addiu $at, $zero, 0xC" "\n"
1865 "\t" " div $zero, $a3, $at" "\n"
1866 "\t" " mflo $a3" "\n"
1867 "\t" " mfhi $v1" "\n"
1868 "\t" " beqz $v1, .Loptimized_memcpy_11" "\n"
1870 "\t" ".Loptimized_memcpy_10:" "\n"
1871 "\t" " lwl $v0, 0x3($a1)" "\n"
1872 "\t" " lwr $v0, 0x0($a1)" "\n"
1873 "\t" " addiu $v1, $v1, -0x1" "\n"
1874 "\t" " sw $v0, 0x0($a0)" "\n"
1875 "\t" " addiu $a1, $a1, 0x4" "\n"
1876 "\t" " bnez $v1, .Loptimized_memcpy_10" "\n"
1877 "\t" " addiu $a0, $a0, 0x4" "\n"
1878 "\t" " beqz $a3, .Loptimized_memcpy_12" "\n"
1880 "\t" ".Loptimized_memcpy_11:" "\n"
1881 "\t" " lwl $v0, 0x3($a1)" "\n"
1882 "\t" " lwr $v0, 0x0($a1)" "\n"
1883 "\t" " lwl $v1, 0x7($a1)" "\n"
1884 "\t" " lwr $v1, 0x4($a1)" "\n"
1885 "\t" " lwl $t0, 0xB($a1)" "\n"
1886 "\t" " lwr $t0, 0x8($a1)" "\n"
1887 "\t" " lwl $t1, 0xF($a1)" "\n"
1888 "\t" " lwr $t1, 0xC($a1)" "\n"
1889 "\t" " lwl $t2, 0x13($a1)" "\n"
1890 "\t" " lwr $t2, 0x10($a1)" "\n"
1891 "\t" " lwl $t3, 0x17($a1)" "\n"
1892 "\t" " lwr $t3, 0x14($a1)" "\n"
1893 "\t" " lwl $t4, 0x1B($a1)" "\n"
1894 "\t" " lwr $t4, 0x18($a1)" "\n"
1895 "\t" " lwl $t5, 0x1F($a1)" "\n"
1896 "\t" " lwr $t5, 0x1C($a1)" "\n"
1897 "\t" " lwl $t6, 0x23($a1)" "\n"
1898 "\t" " lwr $t6, 0x20($a1)" "\n"
1899 "\t" " lwl $t7, 0x27($a1)" "\n"
1900 "\t" " lwr $t7, 0x24($a1)" "\n"
1901 "\t" " lwl $t8, 0x2B($a1)" "\n"
1902 "\t" " lwr $t8, 0x28($a1)" "\n"
1903 "\t" " lwl $t9, 0x2F($a1)" "\n"
1904 "\t" " lwr $t9, 0x2C($a1)" "\n"
1905 "\t" " addiu $a3, $a3, -0x1" "\n"
1906 "\t" " sw $v0, 0x0($a0)" "\n"
1907 "\t" " sw $v1, 0x4($a0)" "\n"
1908 "\t" " sw $t0, 0x8($a0)" "\n"
1909 "\t" " sw $t1, 0xC($a0)" "\n"
1910 "\t" " sw $t2, 0x10($a0)" "\n"
1911 "\t" " sw $t3, 0x14($a0)" "\n"
1912 "\t" " sw $t4, 0x18($a0)" "\n"
1913 "\t" " sw $t5, 0x1C($a0)" "\n"
1914 "\t" " sw $t6, 0x20($a0)" "\n"
1915 "\t" " sw $t7, 0x24($a0)" "\n"
1916 "\t" " sw $t8, 0x28($a0)" "\n"
1917 "\t" " sw $t9, 0x2C($a0)" "\n"
1918 "\t" " addiu $a1, $a1, 0x30" "\n"
1919 "\t" " bnez $a3, .Loptimized_memcpy_11" "\n"
1920 "\t" " addiu $a0, $a0, 0x30" "\n"
1921 "\t" ".Loptimized_memcpy_12:" "\n"
1922 "\t" " andi $v1, $a2, 0x3" "\n"
1923 "\t" " beqz $v1, .Loptimized_memcpy_14" "\n"
1925 "\t" ".Loptimized_memcpy_13:" "\n"
1926 "\t" " lb $v0, 0x0($a1)" "\n"
1927 "\t" " addiu $v1, $v1, -0x1" "\n"
1928 "\t" " sb $v0, 0x0($a0)" "\n"
1929 "\t" " addiu $a1, $a1, 0x1" "\n"
1930 "\t" " bnez $v1, .Loptimized_memcpy_13" "\n"
1931 "\t" " addiu $a0, $a0, 0x1" "\n"
1932 "\t" ".Loptimized_memcpy_14:" "\n"
1933 "\t" " addu $v0, $a2, $zero" "\n"
1936 "\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)