PS2SDK
PS2 Homebrew Libraries
Loading...
Searching...
No Matches
cdvdstm.c
1/*
2# _____ ___ ____ ___ ____
3# ____| | ____| | | |____|
4# | ___| |____ ___| ____| | \ PS2DEV Open Source Project.
5#-----------------------------------------------------------------------
6# Copyright ps2dev - http://www.ps2dev.org
7# Licenced under Academic Free License version 2.0
8# Review ps2sdk README & LICENSE files for further details.
9*/
10
11#include "irx_imports.h"
12
13#include <cdvd-ioctl.h>
14#include <errno.h>
15#include <kerr.h>
16
17IRX_ID("cdvd_st_driver", 2, 2);
18// Based on the module from SCE SDK 3.1.0.
19
20extern struct irx_export_table _exp_cdvdstm;
21
22int cdvdstm_dummyentry();
23int cdvdstm_termcall();
24static unsigned int iop_stream_handler(
25 unsigned int posszarg1, unsigned int posszarg2, void *buffer, int cmdid, const sceCdRMode *rmode, int *error_ptr);
26static unsigned int iop_stream_intr_cb(void *userdata);
27static int cdrom_stm_init();
28static int cdrom_stm_deinit();
29static int cdrom_stm_devctl(
30 iop_file_t *f, const char *name, int cmd, void *inbuf, unsigned int inbuf_len, void *outbuf, unsigned int outbuf_len);
31static int cdrom_stm_nulldev();
32static s64 cdrom_stm_nulldev64();
33static void ee_stream_handler_normal(cdrom_stm_devctl_t *instruct, int inbuf_len, int *outres_ptr);
34static unsigned int ee_stream_intr_cb_normal(void *userdata);
35static void ee_stream_handler_cdda(cdrom_stm_devctl_t *instruct, int inbuf_len, int *outres_ptr);
36static unsigned int ee_stream_intr_cb_cdda(void *userdata);
37unsigned int optimized_memcpy(char *dst, const char *src, unsigned int n);
38
39static void iop_stream_intr_cb_thunk(int userdata)
40{
41 iop_stream_intr_cb((void *)userdata);
42}
43
44static void ee_stream_intr_cb_normal_thunk(int userdata)
45{
46 ee_stream_intr_cb_normal((void *)userdata);
47}
48
49static void ee_stream_intr_cb_cdda_thunk(int userdata)
50{
51 ee_stream_intr_cb_cdda((void *)userdata);
52}
53
54static int g_verbose_level = 0;
55static int g_cdvdstm_in_deldrv = 0;
56static int g_cdvdstm_bufmax = 0;
57static int g_cdvdstm_numbytes = 0;
58static int g_cdvdstm_bankmax = 0;
59static void *g_cdvdstm_buffer = NULL;
60static unsigned int g_cdvdstm_sectorcount = 0;
61static int g_cdvdstm_last_error_for_iop = 0;
62static int g_cdvdstm_retryerr_iop = 0;
63static int g_cdvdstm_retrycnt_iop = 0;
64static iop_device_ops_t g_cdrom_stm_dev_ops = {
65 &cdrom_stm_init,
66 &cdrom_stm_deinit,
67 (void *)&cdrom_stm_nulldev,
68 (void *)&cdrom_stm_nulldev,
69 (void *)&cdrom_stm_nulldev,
70 (void *)&cdrom_stm_nulldev,
71 (void *)&cdrom_stm_nulldev,
72 (void *)&cdrom_stm_nulldev,
73 &cdrom_stm_nulldev,
74 (void *)&cdrom_stm_nulldev,
75 (void *)&cdrom_stm_nulldev,
76 (void *)&cdrom_stm_nulldev,
77 (void *)&cdrom_stm_nulldev,
78 (void *)&cdrom_stm_nulldev,
79 (void *)&cdrom_stm_nulldev,
80 (void *)&cdrom_stm_nulldev,
81 (void *)&cdrom_stm_nulldev,
82 (void *)&cdrom_stm_nulldev,
83 (void *)&cdrom_stm_nulldev,
84 (void *)&cdrom_stm_nulldev,
85 (void *)&cdrom_stm_nulldev,
86 (void *)&cdrom_stm_nulldev,
87 (void *)&cdrom_stm_nulldev64,
88 &cdrom_stm_devctl,
89 (void *)&cdrom_stm_nulldev,
90 (void *)&cdrom_stm_nulldev,
91 &cdrom_stm_nulldev,
92};
93static iop_device_t g_cdrom_stm_dev = {"cdrom_stm", IOP_DT_FSEXT | IOP_DT_FS, 1, "CD-ROM_STM ", &g_cdrom_stm_dev_ops};
94static int g_cdvdstm_last_error_for_ee = 0;
95static int g_cdvdstm_bufsz2 = 0;
96static int g_cdvdstm_chunksz2 = 0;
97static int g_cdvdstm_bankcnt2 = 0;
98static void *g_cdvdstm_buffer2 = NULL;
99static u32 g_cdvdstm_sectorcount2 = 0;
100static int g_cdvdstm_retryerr_ee = 0;
101static int g_cdvdstm_retrycnt_ee_normal = 0;
102static int g_cdvdstm_usedchunksize2 = 0x930;
103static u32 g_cdvdstm_retrycnt_ee_cdda = 0;
104static sceCdRMode g_rmode_for_stream0;
105static int g_cdvdstm_tgt;
106static int g_cdvdstm_semid;
107static int g_cdvdman_intr_efid;
108static char g_cdvdstm_usedmap_iop[512];
109static unsigned int g_cdvdstm_lsn_iop;
110static int g_cdvdstm_bankgp_iop;
111static int g_cdvdstm_bankcur_iop;
112static int g_cdvdstm_bankoffs_iop;
113static sceCdRMode g_cdvdstm_mode_iop;
114static int g_cdvdstm_stmstart_iop;
115static iop_sys_clock_t g_cdvdstm_curclk_iop;
116static SifDmaTransfer_t g_cdvdstm_dmat;
117static int g_cdvdstm_readlbn_ee_normal;
118static SifDmaTransfer_t g_cdvdstm_dmat2;
119static u32 g_cdvdstm_readlbn_ee_cdda;
120static char g_cdvdstm_usedmap_ee[512];
121static u32 g_cdvdstm_lsn_ee;
122static int g_cdvdstm_bankgp_ee;
123static int g_cdvdstm_bankcur_ee;
124static int g_cdvdstm_bankoffs_ee;
125static sceCdRMode g_cdvdstm_mode_ee;
126static int g_cdvdstm_stmstart_ee;
127static iop_sys_clock_t g_cdvdstm_curclk_ee;
128
129static int vCancelAlarm(unsigned int (*alarm_cb)(void *), void *arg)
130{
131 return (QueryIntrContext() ? iCancelAlarm : CancelAlarm)(alarm_cb, arg);
132}
133
134static int vSetEventFlag()
135{
136 return (QueryIntrContext() ? iSetEventFlag : SetEventFlag)(g_cdvdman_intr_efid, 8);
137}
138
139static int vClearEventFlag()
140{
141 return (QueryIntrContext() ? iClearEventFlag : ClearEventFlag)(g_cdvdman_intr_efid, ~8);
142}
143
144int cdvdstm_dummyentry()
145{
146 VERBOSE_PRINTF(1, "Dummy Entry Called\n");
147 return 0;
148}
149
150int cdvdstm_termcall()
151{
152 cdrom_stm_devctl_t instruct;
153 int outres;
154
155 memset(&instruct, 0, sizeof(instruct));
156 instruct.m_cmdid = 3;
157 instruct.m_rmode.datapattern = SCECdSecS2048;
158 instruct.m_rmode.spindlctrl = SCECdSpinMax;
159 instruct.m_rmode.trycount = 0;
160 ee_stream_handler_normal(&instruct, 0x14, &outres);
161 sceCdStStop();
162 return 0;
163}
164
165static int stm_iop_read_timeout_alarm_cb(const iop_sys_clock_t *sys_clock)
166{
167 KPRINTF("Stm Iop Read Time Out %d(msec)\n", sys_clock->lo / 0x9000);
168 return !sceCdBreak();
169}
170
171static int sceCdStream0_inner(unsigned int rdsize, char *addrarg, int modearg, int *error_ptr)
172{
173 int cur_size;
174 unsigned int streamres;
175 int last_error;
176 u32 efbits;
177 int err;
178
179 VERBOSE_KPRINTF(1, "sceCdStream0 call read size= %d mode= %d addr= %08x\n", rdsize, modearg, addrarg);
180 cur_size = 0;
181 if ( !sceCdSC(0xFFFFFFFF, &last_error) )
182 return 0;
183 *error_ptr = 0;
184 if ( !modearg )
185 return iop_stream_handler(0, rdsize, addrarg, 2, &g_rmode_for_stream0, error_ptr);
186 vSetEventFlag();
187 err = 0;
188 streamres = 0;
189 while ( (!err || streamres) )
190 {
191 WaitEventFlag(g_cdvdman_intr_efid, 8, WEF_AND, &efbits);
192 streamres = iop_stream_handler(0, rdsize - cur_size, &addrarg[cur_size], 2, &g_rmode_for_stream0, &err);
193 if ( rdsize - cur_size != streamres )
194 vClearEventFlag();
195 cur_size += streamres;
196 if ( err )
197 *error_ptr = err;
198 VERBOSE_KPRINTF(1, "sceCdStream0 BLK cur_size= %d req_size= %d err 0x%x\n", cur_size, rdsize, err);
199 if ( (unsigned int)cur_size == rdsize )
200 break;
201 }
202 return cur_size;
203}
204
205static int sceCdStream0(int rdsize_sectors, char *addrarg, int modearg, int *error_ptr)
206{
207 return sceCdStream0_inner(rdsize_sectors << 11, addrarg, modearg, error_ptr) / 0x800;
208}
209
210static unsigned int iop_stream_handler(
211 unsigned int posszarg1, unsigned int posszarg2, void *buffer, int cmdid, const sceCdRMode *rmode, int *error_ptr)
212{
213 int retryflag;
214 int bankcur_tmp;
215 unsigned int i;
216 unsigned int written_chunk_size_tmp;
217 int bankcur_next_tmp1;
218 int chunk_size;
219 int bankcur_next_tmp2;
220 int state;
221
222 retryflag = 0;
223 VERBOSE_KPRINTF(1, "CD Stream Call mode= %d\n", cmdid);
224 *error_ptr = 0;
225 if ( g_cdvdstm_stmstart_iop == 2 && cmdid != 9 && cmdid != 3 )
226 {
227 return 0;
228 }
229 switch ( cmdid )
230 {
231 case 8:
232 sceCdSC(1, &g_cdvdstm_last_error_for_iop);
233 if ( sceCdNop() )
234 return 1;
235 sceCdSC(0, &g_cdvdstm_last_error_for_iop);
236 return 0;
237 case 7:
238 CpuSuspendIntr(&state);
239 vCancelAlarm((unsigned int (*)(void *))iop_stream_intr_cb, &g_cdvdstm_curclk_iop);
240 sceCdSC(0, &g_cdvdstm_last_error_for_iop);
241 CpuResumeIntr(state);
242 sceCdSync(0);
243 vCancelAlarm((unsigned int (*)(void *))stm_iop_read_timeout_alarm_cb, &g_cdvdstm_curclk_iop);
244 return 1;
245 case 6:
246 bankcur_tmp = g_cdvdstm_bankcur_iop;
247 if ( !g_cdvdstm_usedmap_iop[bankcur_tmp] )
248 {
249 bankcur_tmp += 1;
250 if ( (unsigned int)bankcur_tmp >= (unsigned int)g_cdvdstm_bankmax )
251 bankcur_tmp = 0;
252 if ( !g_cdvdstm_usedmap_iop[bankcur_tmp] )
253 bankcur_tmp = g_cdvdstm_bankcur_iop;
254 }
255 for ( i = 0; (i < (unsigned int)g_cdvdstm_bankmax) && g_cdvdstm_usedmap_iop[bankcur_tmp]
256 && (g_cdvdstm_bankgp_iop != bankcur_tmp);
257 i += 1 )
258 {
259 bankcur_tmp += 1;
260 if ( (unsigned int)bankcur_tmp >= (unsigned int)g_cdvdstm_bankmax )
261 bankcur_tmp = 0;
262 }
263 return i * ((unsigned int)g_cdvdstm_numbytes >> 11);
264 case 5:
265 sceCdstm0Cb((void (*)(int))iop_stream_intr_cb_thunk);
266 g_cdvdstm_bufmax = posszarg1;
267 g_cdvdstm_sectorcount = posszarg1 / posszarg2;
268 g_cdvdstm_numbytes = g_cdvdstm_sectorcount << 11;
269 g_cdvdstm_buffer = buffer;
270 g_cdvdstm_bankmax = posszarg2;
271 KPRINTF(
272 "Stream Buffer 1Bank %dbyte %dbanks addr:%08x %dbyte used.\n",
273 g_cdvdstm_numbytes,
274 posszarg2,
275 buffer,
276 g_cdvdstm_numbytes * posszarg2);
277 return 1;
278 case 3:
279 CpuSuspendIntr(&state);
280 g_cdvdstm_stmstart_iop = 0;
281 vCancelAlarm((unsigned int (*)(void *))iop_stream_intr_cb, &g_cdvdstm_curclk_iop);
282 sceCdSC(0, &g_cdvdstm_last_error_for_iop);
283 CpuResumeIntr(state);
284 sceCdBreak();
285 for ( i = 0; i < (unsigned int)g_cdvdstm_bankmax; i += 1 )
286 g_cdvdstm_usedmap_iop[i] = 0;
287 g_cdvdstm_bankoffs_iop = 0;
288 g_cdvdstm_bankcur_iop = 0;
289 g_cdvdstm_bankgp_iop = 0;
290 sceCdSync(0);
291 g_cdvdstm_last_error_for_iop = 0;
292 sceCdSC(0xFFFFFFFE, &g_cdvdstm_last_error_for_iop);
293 vCancelAlarm((unsigned int (*)(void *))stm_iop_read_timeout_alarm_cb, &g_cdvdstm_curclk_iop);
294 return 1;
295 case 9:
296 if ( sceCdSC(0xFFFFFFFF, &g_cdvdstm_last_error_for_iop) )
297 {
298 CpuSuspendIntr(&state);
299 g_cdvdstm_lsn_iop = posszarg1;
300 for ( i = 0; i < (unsigned int)g_cdvdstm_bankmax; i += 1 )
301 g_cdvdstm_usedmap_iop[i] = 0;
302 g_cdvdstm_stmstart_iop = 2;
303 CpuResumeIntr(state);
304 return 1;
305 }
306 return 0;
307 case 1:
308 g_cdvdstm_mode_iop.datapattern = rmode->datapattern;
309 g_cdvdstm_mode_iop.trycount = rmode->trycount;
310 g_cdvdstm_mode_iop.spindlctrl = rmode->spindlctrl;
311 g_cdvdstm_retryerr_iop = 0;
312 break;
313 case 4:
314 CpuSuspendIntr(&state);
315 vCancelAlarm((unsigned int (*)(void *))iop_stream_intr_cb, &g_cdvdstm_curclk_iop);
316 sceCdSC(0, &g_cdvdstm_last_error_for_iop);
317 retryflag = 1;
318 CpuResumeIntr(state);
319 posszarg2 = 0;
320 cmdid = 1;
321 g_cdvdstm_lsn_iop = posszarg1;
322 g_cdvdstm_bankoffs_iop = 0;
323 g_cdvdstm_bankcur_iop = 0;
324 g_cdvdstm_bankgp_iop = 0;
325 sceCdSync(0);
326 vCancelAlarm((unsigned int (*)(void *))stm_iop_read_timeout_alarm_cb, &g_cdvdstm_curclk_iop);
327 break;
328 }
329 if ( cmdid == 1 )
330 {
331 CpuSuspendIntr(&state);
332 retryflag = 1;
333 vCancelAlarm((unsigned int (*)(void *))iop_stream_intr_cb, &g_cdvdstm_curclk_iop);
334 sceCdSC(0, &g_cdvdstm_last_error_for_iop);
335 CpuResumeIntr(state);
336 for ( i = 0; i < (unsigned int)g_cdvdstm_bankmax; i += 1 )
337 g_cdvdstm_usedmap_iop[i] = 0;
338 g_cdvdstm_lsn_iop = posszarg1;
339 sceCdSC(0xFFFFFFE9, (int *)&g_cdvdstm_lsn_iop);
340 g_cdvdstm_bankoffs_iop = 0;
341 g_cdvdstm_bankcur_iop = 0;
342 g_cdvdstm_bankgp_iop = 0;
343 sceCdSync(0);
344 vCancelAlarm((unsigned int (*)(void *))stm_iop_read_timeout_alarm_cb, &g_cdvdstm_curclk_iop);
345 g_cdvdstm_stmstart_iop = 1;
346 sceCdSC(1, &g_cdvdstm_last_error_for_iop);
347 if ( !sceCdNop() )
348 {
349 sceCdSC(0, &g_cdvdstm_last_error_for_iop);
350 return 0;
351 }
352 }
353 CpuSuspendIntr(&state);
354 written_chunk_size_tmp = -1;
355 for ( i = 0; i < posszarg2; i += chunk_size )
356 {
357 if ( !g_cdvdstm_usedmap_iop[g_cdvdstm_bankcur_iop] )
358 {
359 VERBOSE_KPRINTF(
360 1,
361 "CD read buffer over run %d %d %d %d %d gp %d pp %d\n",
362 (u8)g_cdvdstm_usedmap_iop[0],
363 (u8)g_cdvdstm_usedmap_iop[1],
364 (u8)g_cdvdstm_usedmap_iop[2],
365 (u8)g_cdvdstm_usedmap_iop[3],
366 (u8)g_cdvdstm_usedmap_iop[4],
367 g_cdvdstm_bankgp_iop,
368 g_cdvdstm_bankcur_iop);
369 bankcur_next_tmp1 = g_cdvdstm_bankcur_iop;
370 g_cdvdstm_bankcur_iop += 1;
371 if ( (unsigned int)g_cdvdstm_bankcur_iop >= (unsigned int)g_cdvdstm_bankmax )
372 g_cdvdstm_bankcur_iop = 0;
373 written_chunk_size_tmp = i;
374 if ( !g_cdvdstm_usedmap_iop[g_cdvdstm_bankcur_iop] )
375 {
376 g_cdvdstm_bankcur_iop = bankcur_next_tmp1;
377 }
378 break;
379 }
380 if ( (unsigned int)g_cdvdstm_bankoffs_iop >= (unsigned int)g_cdvdstm_numbytes )
381 {
382 g_cdvdstm_bankoffs_iop = 0;
383 g_cdvdstm_usedmap_iop[g_cdvdstm_bankcur_iop] = 0;
384 bankcur_next_tmp2 = g_cdvdstm_bankcur_iop;
385 g_cdvdstm_bankcur_iop += 1;
386 if ( (unsigned int)g_cdvdstm_bankcur_iop >= (unsigned int)g_cdvdstm_bankmax )
387 g_cdvdstm_bankcur_iop = 0;
388 if ( !g_cdvdstm_usedmap_iop[g_cdvdstm_bankcur_iop] || g_cdvdstm_bankgp_iop == g_cdvdstm_bankcur_iop )
389 {
390 g_cdvdstm_bankcur_iop = bankcur_next_tmp2;
391 written_chunk_size_tmp = i;
392 VERBOSE_KPRINTF(
393 1,
394 "CD read buffer over run %d %d %d %d %d gp %d pp %d\n",
395 (u8)g_cdvdstm_usedmap_iop[0],
396 (u8)g_cdvdstm_usedmap_iop[1],
397 (u8)g_cdvdstm_usedmap_iop[2],
398 (u8)g_cdvdstm_usedmap_iop[3],
399 (u8)g_cdvdstm_usedmap_iop[4],
400 g_cdvdstm_bankgp_iop,
401 g_cdvdstm_bankcur_iop);
402 break;
403 }
404 }
405 optimized_memcpy(
406 &((char *)buffer)[i],
407 &((char *)g_cdvdstm_buffer)[g_cdvdstm_bankcur_iop * g_cdvdstm_numbytes + g_cdvdstm_bankoffs_iop],
408 0x800);
409 chunk_size = ((unsigned int)0x800 > posszarg2 - i) ? (posszarg2 - i) : 0x800;
410 g_cdvdstm_bankoffs_iop += chunk_size;
411 }
412 if ( written_chunk_size_tmp == 0xFFFFFFFF )
413 written_chunk_size_tmp = posszarg2;
414 CpuResumeIntr(state);
415 if ( !retryflag )
416 {
417 if ( sceCdSC(0xFFFFFFFF, &g_cdvdstm_last_error_for_iop) != 1 && !written_chunk_size_tmp && !g_cdvdstm_retryerr_iop )
418 {
419 g_cdvdstm_retryerr_iop = 273;
420 }
421 *error_ptr = g_cdvdstm_retryerr_iop;
422 g_cdvdstm_retryerr_iop = 0;
423 return written_chunk_size_tmp;
424 }
425 return 1;
426}
427
428static unsigned int iop_stream_intr_cb(void *userdata)
429{
430 int last_error;
431 int scres_unused;
432
433 (void)userdata;
434
435 VERBOSE_KPRINTF(1, "Intr Read call\n");
436 iCancelAlarm((unsigned int (*)(void *))stm_iop_read_timeout_alarm_cb, &g_cdvdstm_curclk_iop);
437 iCancelAlarm((unsigned int (*)(void *))iop_stream_intr_cb, &g_cdvdstm_curclk_iop);
438 sceCdSC(0xFFFFFFFF, &last_error);
439 if ( !last_error )
440 {
441 switch ( sceCdGetDiskType() )
442 {
443 case SCECdPSCD:
444 case SCECdPSCDDA:
445 case SCECdPS2CD:
446 case SCECdPS2CDDA:
447 case SCECdPS2DVD:
448 break;
449 default:
450 last_error = SCECdErREADCF;
451 break;
452 }
453 }
454 g_cdvdstm_curclk_iop.hi = 0;
455 if ( g_cdvdstm_stmstart_iop )
456 g_cdvdstm_retrycnt_iop = 0;
457 if ( g_cdvdstm_stmstart_iop || last_error || g_cdvdstm_retrycnt_iop )
458 {
459 VERBOSE_KPRINTF(
460 1, "Stm Rtry stmstart:%d err:%02x retry:%d\n", g_cdvdstm_stmstart_iop, last_error, g_cdvdstm_retrycnt_iop);
461 }
462 g_cdvdstm_curclk_iop.lo = (g_cdvdstm_stmstart_iop || last_error || g_cdvdstm_retrycnt_iop) ?
463 0x20f58000 :
464 (0x9000 * sceCdSC(0xFFFFFFEF, &scres_unused));
465 if ( last_error )
466 {
467 VERBOSE_KPRINTF(1, "IOP Stream read Error code= 0x%02x retry= %d\n", last_error, g_cdvdstm_retrycnt_iop);
468 if ( last_error == SCECdErREAD || last_error == SCECdErABRT )
469 {
470 VERBOSE_KPRINTF(1, "On err %08x\n", last_error);
471 if ( g_cdvdstm_retrycnt_iop )
472 g_cdvdstm_retryerr_iop = last_error;
473 g_cdvdstm_retrycnt_iop = 3;
474 }
475 else
476 {
477 g_cdvdstm_retryerr_iop = last_error;
478 g_cdvdstm_retrycnt_iop = 1;
479 }
480 }
481 if ( g_cdvdstm_retrycnt_iop )
482 {
483 unsigned int tgttmp;
484
485 g_cdvdstm_retrycnt_iop -= 1;
486 tgttmp = ((unsigned int)g_cdvdstm_tgt >= (unsigned int)(0x10 * g_cdvdstm_retrycnt_iop)) ?
487 (g_cdvdstm_tgt - 0x10 * g_cdvdstm_retrycnt_iop) :
488 (g_cdvdstm_tgt + 0x10 * g_cdvdstm_retrycnt_iop);
489 VERBOSE_KPRINTF(1, "Stm Rtry Start Tgt=%d Cur= %d\n", g_cdvdstm_tgt, tgttmp);
490 if ( sceCdRE(
491 tgttmp,
492 g_cdvdstm_sectorcount,
493 (char *)g_cdvdstm_buffer + g_cdvdstm_bankgp_iop * g_cdvdstm_numbytes,
494 &g_cdvdstm_mode_iop) )
495 {
496 iSetAlarm(&g_cdvdstm_curclk_iop, (unsigned int (*)(void *))stm_iop_read_timeout_alarm_cb, &g_cdvdstm_curclk_iop);
497 }
498 else
499 {
500 g_cdvdstm_curclk_iop.lo = 0x708000;
501 if (
502 iSetAlarm(&g_cdvdstm_curclk_iop, (unsigned int (*)(void *))iop_stream_intr_cb, &g_cdvdstm_curclk_iop)
503 && !sceCdNop() )
504 {
505 sceCdSC(0, &last_error);
506 }
507 g_cdvdstm_retrycnt_iop += 1;
508 }
509 return 0;
510 }
511 else
512 {
513 int gptmp;
514
515 if ( !g_cdvdstm_stmstart_iop )
516 {
517 g_cdvdstm_usedmap_iop[g_cdvdstm_bankgp_iop] = 1;
518 gptmp = g_cdvdstm_bankgp_iop;
519 g_cdvdstm_bankgp_iop += 1;
520 if ( (unsigned int)g_cdvdstm_bankgp_iop >= (unsigned int)g_cdvdstm_bankmax )
521 g_cdvdstm_bankgp_iop = 0;
522 }
523 if (
524 !g_cdvdstm_stmstart_iop
525 && (g_cdvdstm_usedmap_iop[g_cdvdstm_bankgp_iop] || g_cdvdstm_bankcur_iop == g_cdvdstm_bankgp_iop) )
526 {
527 g_cdvdstm_bankgp_iop = gptmp;
528 g_cdvdstm_usedmap_iop[gptmp] = 0;
529 VERBOSE_KPRINTF(
530 1,
531 "read Full %d %d %d %d %d gp %d pp %d spn %d\n",
532 (u8)g_cdvdstm_usedmap_iop[0],
533 (u8)g_cdvdstm_usedmap_iop[1],
534 (u8)g_cdvdstm_usedmap_iop[2],
535 (u8)g_cdvdstm_usedmap_iop[3],
536 (u8)g_cdvdstm_usedmap_iop[4],
537 g_cdvdstm_bankgp_iop,
538 g_cdvdstm_bankcur_iop,
539 g_cdvdstm_mode_iop.spindlctrl);
540 g_cdvdstm_curclk_iop.lo = 0x48000;
541 if (
542 iSetAlarm(&g_cdvdstm_curclk_iop, (unsigned int (*)(void *))iop_stream_intr_cb, &g_cdvdstm_curclk_iop)
543 && !sceCdNop() )
544 {
545 sceCdSC(0, &last_error);
546 }
547 }
548 else
549 {
550 if ( g_cdvdstm_stmstart_iop == 2 )
551 {
552 unsigned int i;
553
554 g_cdvdstm_bankoffs_iop = 0;
555 g_cdvdstm_bankcur_iop = 0;
556 g_cdvdstm_bankgp_iop = 0;
557 for ( i = 0; i < (unsigned int)g_cdvdstm_bankmax; i += 1 )
558 g_cdvdstm_usedmap_iop[i] = 0;
559 }
560 g_cdvdstm_stmstart_iop = 0;
561 g_cdvdstm_tgt = g_cdvdstm_lsn_iop;
562 if ( sceCdRE(
563 g_cdvdstm_lsn_iop,
564 g_cdvdstm_sectorcount,
565 (char *)g_cdvdstm_buffer + g_cdvdstm_bankgp_iop * g_cdvdstm_numbytes,
566 &g_cdvdstm_mode_iop) )
567 {
568 iSetAlarm(
569 &g_cdvdstm_curclk_iop, (unsigned int (*)(void *))stm_iop_read_timeout_alarm_cb, &g_cdvdstm_curclk_iop);
570 }
571 else
572 {
573 g_cdvdstm_curclk_iop.lo = 0x708000;
574 if (
575 iSetAlarm(&g_cdvdstm_curclk_iop, (unsigned int (*)(void *))iop_stream_intr_cb, &g_cdvdstm_curclk_iop)
576 && !sceCdNop() )
577 {
578 sceCdSC(0, &last_error);
579 }
580 g_cdvdstm_retrycnt_iop = 1;
581 }
582 g_cdvdstm_lsn_iop += g_cdvdstm_sectorcount;
583 }
584 }
585 return 0;
586}
587
588static int cdrom_stm_init()
589{
590 iop_sema_t semaparam;
591
592 semaparam.attr = SA_THPRI;
593 semaparam.initial = 1;
594 semaparam.max = 1;
595 semaparam.option = 0;
596 g_cdvdstm_semid = CreateSema(&semaparam);
597 return 0;
598}
599
600static int cdrom_stm_deinit()
601{
602 SignalSema(g_cdvdstm_semid);
603 DeleteSema(g_cdvdstm_semid);
604 return 0;
605}
606
607static int cdrom_stm_devctl(
608 iop_file_t *f, const char *name, int cmd, void *inbuf, unsigned int inbuf_len, void *outbuf, unsigned int outbuf_len)
609{
610 int retres;
611 cdrom_stm_devctl_t *instruct;
612 int *outres_ptr;
613
614 (void)f;
615 (void)name;
616 (void)outbuf_len;
617
618 instruct = inbuf;
619 outres_ptr = outbuf;
620 WaitSema(g_cdvdstm_semid);
621 retres = 0;
622 if ( g_cdvdstm_in_deldrv )
623 {
624 SignalSema(g_cdvdstm_semid);
625 return -EIO;
626 }
627 switch ( cmd )
628 {
629 case 0x4393:
630 if ( instruct->m_cmdid == 5 || instruct->m_cmdid == 3 || instruct->m_cmdid - 7 < 2 )
631 {
632 vSetEventFlag();
633 }
634 *outres_ptr = iop_stream_handler(
635 instruct->m_posszarg1,
636 instruct->m_posszarg2,
637 instruct->m_buffer,
638 instruct->m_cmdid,
639 &instruct->m_rmode,
640 (int *)&instruct->m_error);
641 break;
642 case 0x4394:
643 *outres_ptr =
644 sceCdStream0(instruct->m_posszarg2, (char *)instruct->m_buffer, instruct->m_cmdid, (int *)&instruct->m_error);
645 break;
646 case 0x4396:
647 ee_stream_handler_normal(instruct, inbuf_len, outres_ptr);
648 break;
649 case 0x4398:
650 ee_stream_handler_cdda(instruct, inbuf_len, outres_ptr);
651 break;
652 default:
653 PRINTF("Un-support devctl %08x\n", cmd);
654 retres = -EIO;
655 break;
656 }
657 SignalSema(g_cdvdstm_semid);
658 return retres;
659}
660
661static int cdrom_stm_nulldev()
662{
663 PRINTF("nulldev0 call\n");
664 return -EIO;
665}
666
667static s64 cdrom_stm_nulldev64()
668{
669 PRINTF("nulldev0 call\n");
670 return -EIO;
671}
672
673int _start(int ac, char *av[], void *startaddr, ModuleInfo_t *mi)
674{
675 int last_error;
676 int scres_unused;
677 int state;
678
679 (void)av;
680 (void)startaddr;
681
682 if ( ac < 0 )
683 {
684 int relres;
685
686 if ( !sceCdSC(0xFFFFFFFF, &last_error) )
687 {
688 return MODULE_REMOVABLE_END;
689 }
690 g_cdvdstm_in_deldrv = 1;
691 DelDrv(g_cdrom_stm_dev.name);
692 CpuSuspendIntr(&state);
693 relres = ReleaseLibraryEntries(&_exp_cdvdstm);
694 CpuResumeIntr(state);
695 g_cdvdstm_in_deldrv = 0;
696 if ( relres && relres != KE_LIBRARY_NOTFOUND )
697 {
698 g_cdvdstm_in_deldrv = 0;
699 return MODULE_REMOVABLE_END;
700 }
701 return MODULE_NO_RESIDENT_END;
702 }
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) )
707 {
708 cdrom_stm_deinit();
709 return MODULE_NO_RESIDENT_END;
710 }
711 g_cdvdman_intr_efid = sceCdSC(0xFFFFFFF5, &scres_unused);
712#if 0
713 return MODULE_REMOVABLE_END;
714#else
715 if ( mi && ((mi->newflags & 2) != 0) )
716 mi->newflags |= 0x10;
717 return MODULE_RESIDENT_END;
718#endif
719}
720
721static int stm_ee_read_timeout_alarm_cb(const iop_sys_clock_t *sys_clock)
722{
723 int read_timeout;
724
725 read_timeout = sys_clock->lo / 0x9000;
726 KPRINTF("Stm EE Read Time Out %d(msec)\n", read_timeout);
727 sceCdSC(0xFFFFFFEE, &read_timeout);
728 return !sceCdBreak();
729}
730
731static void ee_stream_handler_normal(cdrom_stm_devctl_t *instruct, int inbuf_len, int *outres_ptr)
732{
733 int retryflag;
734 u32 cmdid;
735 u32 posszarg2_bytes;
736 int bankcur_tmp;
737 unsigned int chunks_sectors;
738 int bankcur_next_tmp1;
739 int posszarg2_bytes_clamped;
740 int dmat1;
741 int bankcur_next_tmp2;
742 int posszarg2_bytes_overrun;
743 int outres_tmp2;
744 int state;
745 unsigned int i;
746
747 (void)inbuf_len;
748
749 retryflag = 0;
750 cmdid = instruct->m_cmdid;
751 if ( g_cdvdstm_stmstart_ee == 2 && (cmdid != 9 && cmdid != 3) )
752 {
753 *outres_ptr = 0;
754 return;
755 }
756 switch ( cmdid )
757 {
758 case 8:
759 sceCdSC(2, &g_cdvdstm_last_error_for_ee);
760 if ( !sceCdNop() )
761 {
762 sceCdSC(0, &g_cdvdstm_last_error_for_ee);
763 *outres_ptr = 0;
764 return;
765 }
766 *outres_ptr = 1;
767 return;
768 case 7:
769 CpuSuspendIntr(&state);
770 CancelAlarm((unsigned int (*)(void *))ee_stream_intr_cb_normal, &g_cdvdstm_curclk_ee);
771 sceCdSC(0, &g_cdvdstm_last_error_for_ee);
772 CpuResumeIntr(state);
773 sceCdSync(0);
774 *outres_ptr = 1;
775 CancelAlarm((unsigned int (*)(void *))stm_ee_read_timeout_alarm_cb, &g_cdvdstm_curclk_ee);
776 return;
777 case 6:
778 bankcur_tmp = g_cdvdstm_bankcur_ee;
779 if ( !g_cdvdstm_usedmap_ee[bankcur_tmp] )
780 {
781 bankcur_tmp += 1;
782 if ( (unsigned int)bankcur_tmp >= (unsigned int)g_cdvdstm_bankcnt2 )
783 bankcur_tmp = 0;
784 if ( !g_cdvdstm_usedmap_ee[bankcur_tmp] )
785 bankcur_tmp = g_cdvdstm_bankcur_ee;
786 }
787 for ( i = 0; (i < (unsigned int)g_cdvdstm_bankcnt2) && g_cdvdstm_usedmap_ee[bankcur_tmp]
788 && (g_cdvdstm_bankgp_ee != bankcur_tmp);
789 i += 1 )
790 {
791 bankcur_tmp += 1;
792 if ( (unsigned int)bankcur_tmp >= (unsigned int)g_cdvdstm_bankcnt2 )
793 bankcur_tmp = 0;
794 }
795 *outres_ptr = i * ((unsigned int)g_cdvdstm_chunksz2 >> 11);
796 return;
797 case 5:
798 sceCdstm1Cb((void (*)(int))ee_stream_intr_cb_normal_thunk);
799 if ( !instruct->m_posszarg2 )
800 __builtin_trap();
801 chunks_sectors = instruct->m_posszarg1 / instruct->m_posszarg2;
802 g_cdvdstm_bufsz2 = instruct->m_posszarg1;
803 g_cdvdstm_sectorcount2 = chunks_sectors;
804 g_cdvdstm_chunksz2 = chunks_sectors << 11;
805 g_cdvdstm_buffer2 = (char *)instruct->m_buffer;
806 g_cdvdstm_bankcnt2 = instruct->m_posszarg2;
807 PRINTF(
808 "Stream Buffer 1Bank %dbyte %dbanks %dbyte used\n",
809 (int)(chunks_sectors << 11),
810 (int)(instruct->m_posszarg2),
811 (int)((chunks_sectors << 11) * (instruct->m_posszarg2)));
812 *outres_ptr = 1;
813 return;
814 case 3:
815 CpuSuspendIntr(&state);
816 g_cdvdstm_stmstart_ee = 0;
817 CancelAlarm((unsigned int (*)(void *))ee_stream_intr_cb_normal, &g_cdvdstm_curclk_ee);
818 sceCdSC(0, &g_cdvdstm_last_error_for_ee);
819 CpuResumeIntr(state);
820 sceCdBreak();
821 for ( i = 0; i < (unsigned int)g_cdvdstm_bankcnt2; i += 1 )
822 {
823 g_cdvdstm_usedmap_ee[i] = 0;
824 }
825 g_cdvdstm_bankoffs_ee = 0;
826 g_cdvdstm_bankcur_ee = 0;
827 g_cdvdstm_bankgp_ee = 0;
828 *outres_ptr = 1;
829 sceCdSync(0);
830 g_cdvdstm_last_error_for_ee = 0;
831 sceCdSC(0xFFFFFFFE, &g_cdvdstm_last_error_for_ee);
832 CancelAlarm((unsigned int (*)(void *))stm_ee_read_timeout_alarm_cb, &g_cdvdstm_curclk_ee);
833 return;
834 case 1:
835 g_cdvdstm_mode_ee.datapattern = instruct->m_rmode.datapattern;
836 g_cdvdstm_mode_ee.trycount = instruct->m_rmode.trycount;
837 g_cdvdstm_mode_ee.spindlctrl = instruct->m_rmode.spindlctrl;
838 g_cdvdstm_retryerr_ee = 0;
839 break;
840 }
841 posszarg2_bytes = instruct->m_posszarg2 << 11;
842 if ( cmdid == 9 )
843 {
844 if ( sceCdSC(0xFFFFFFFF, &g_cdvdstm_last_error_for_ee) )
845 {
846 CpuSuspendIntr(&state);
847 g_cdvdstm_lsn_ee = instruct->m_posszarg1;
848 for ( i = 0; i < (unsigned int)g_cdvdstm_bankcnt2; i += 1 )
849 {
850 g_cdvdstm_usedmap_ee[i] = 0;
851 }
852 g_cdvdstm_stmstart_ee = 2;
853 CpuResumeIntr(state);
854 *outres_ptr = 1;
855 return;
856 }
857 *outres_ptr = 0;
858 return;
859 }
860 if ( cmdid == 4 )
861 {
862 retryflag = 1;
863 CpuSuspendIntr(&state);
864 CancelAlarm((unsigned int (*)(void *))ee_stream_intr_cb_normal, &g_cdvdstm_curclk_ee);
865 sceCdSC(0, &g_cdvdstm_last_error_for_ee);
866 posszarg2_bytes = 0;
867 cmdid = 1;
868 CpuResumeIntr(state);
869 g_cdvdstm_lsn_ee = instruct->m_posszarg1;
870 g_cdvdstm_bankoffs_ee = 0;
871 g_cdvdstm_bankcur_ee = 0;
872 g_cdvdstm_bankgp_ee = 0;
873 sceCdSync(0);
874 CancelAlarm((unsigned int (*)(void *))stm_ee_read_timeout_alarm_cb, &g_cdvdstm_curclk_ee);
875 }
876 if ( cmdid == 1 )
877 {
878 CpuSuspendIntr(&state);
879 CancelAlarm((unsigned int (*)(void *))ee_stream_intr_cb_normal, &g_cdvdstm_curclk_ee);
880 sceCdSC(0, &g_cdvdstm_last_error_for_ee);
881 CpuResumeIntr(state);
882 retryflag = 1;
883 for ( i = 0; i < (unsigned int)g_cdvdstm_bankcnt2; i += 1 )
884 {
885 g_cdvdstm_usedmap_ee[i] = 0;
886 }
887 g_cdvdstm_lsn_ee = instruct->m_posszarg1;
888 sceCdSC(0xFFFFFFE9, (int *)&g_cdvdstm_lsn_ee);
889 g_cdvdstm_bankoffs_ee = 0;
890 g_cdvdstm_bankcur_ee = 0;
891 sceCdSync(0);
892 CancelAlarm((unsigned int (*)(void *))stm_ee_read_timeout_alarm_cb, &g_cdvdstm_curclk_ee);
893 g_cdvdstm_stmstart_ee = 1;
894 sceCdSC(2, &g_cdvdstm_last_error_for_ee);
895 if ( !sceCdNop() )
896 {
897 sceCdSC(0, &g_cdvdstm_last_error_for_ee);
898 *outres_ptr = 0;
899 return;
900 }
901 }
902 posszarg2_bytes_overrun = -1;
903 for ( i = 0; i < posszarg2_bytes; i += posszarg2_bytes_clamped )
904 {
905 unsigned int posszarg2_bytes_remain;
906
907 posszarg2_bytes_remain = posszarg2_bytes - i;
908 if ( !g_cdvdstm_usedmap_ee[g_cdvdstm_bankcur_ee] )
909 {
910 VERBOSE_KPRINTF(
911 1,
912 "CD read buffer over run %d %d %d %d %d gp %d pp %d\n",
913 (u8)g_cdvdstm_usedmap_ee[0],
914 (u8)g_cdvdstm_usedmap_ee[1],
915 (u8)g_cdvdstm_usedmap_ee[2],
916 (u8)g_cdvdstm_usedmap_ee[3],
917 (u8)g_cdvdstm_usedmap_ee[4],
918 g_cdvdstm_bankgp_ee,
919 g_cdvdstm_bankcur_ee);
920 CpuSuspendIntr(&state);
921 bankcur_next_tmp1 = g_cdvdstm_bankcur_ee;
922 g_cdvdstm_bankcur_ee += 1;
923 if ( (unsigned int)g_cdvdstm_bankcur_ee >= (unsigned int)g_cdvdstm_bankcnt2 )
924 g_cdvdstm_bankcur_ee = 0;
925 if ( !g_cdvdstm_usedmap_ee[g_cdvdstm_bankcur_ee] )
926 g_cdvdstm_bankcur_ee = bankcur_next_tmp1;
927 posszarg2_bytes_overrun = posszarg2_bytes - posszarg2_bytes_remain;
928 CpuResumeIntr(state);
929 break;
930 }
931 posszarg2_bytes_clamped = ((unsigned int)(g_cdvdstm_chunksz2 - g_cdvdstm_bankoffs_ee) < posszarg2_bytes_remain) ?
932 (unsigned int)(g_cdvdstm_chunksz2 - g_cdvdstm_bankoffs_ee) :
933 posszarg2_bytes_remain;
934 g_cdvdstm_dmat.dest = ((char *)instruct->m_buffer) + i;
935 g_cdvdstm_dmat.size = posszarg2_bytes_clamped;
936 g_cdvdstm_dmat.attr = 0;
937 g_cdvdstm_dmat.src = (char *)g_cdvdstm_buffer2 + g_cdvdstm_bankcur_ee * g_cdvdstm_chunksz2 + g_cdvdstm_bankoffs_ee;
938 if ( posszarg2_bytes_clamped )
939 {
940 while ( 1 )
941 {
942 CpuSuspendIntr(&state);
943 dmat1 = sceSifSetDma(&g_cdvdstm_dmat, 1);
944 CpuResumeIntr(state);
945 if ( dmat1 )
946 break;
947 DelayThread(500);
948 }
949 g_cdvdstm_bankoffs_ee += posszarg2_bytes_clamped;
950 while ( sceSifDmaStat(dmat1) >= 0 )
951 ;
952 }
953 if ( (unsigned int)g_cdvdstm_bankoffs_ee >= (unsigned int)g_cdvdstm_chunksz2 )
954 {
955 CpuSuspendIntr(&state);
956 g_cdvdstm_bankoffs_ee = 0;
957 g_cdvdstm_usedmap_ee[g_cdvdstm_bankcur_ee] = 0;
958 bankcur_next_tmp2 = g_cdvdstm_bankcur_ee;
959 g_cdvdstm_bankcur_ee += 1;
960 if ( (unsigned int)g_cdvdstm_bankcur_ee >= (unsigned int)g_cdvdstm_bankcnt2 )
961 g_cdvdstm_bankcur_ee = 0;
962 if ( g_cdvdstm_usedmap_ee[g_cdvdstm_bankcur_ee] && g_cdvdstm_bankgp_ee != g_cdvdstm_bankcur_ee )
963 {
964 CpuResumeIntr(state);
965 }
966 else
967 {
968 g_cdvdstm_bankcur_ee = bankcur_next_tmp2;
969 CpuResumeIntr(state);
970 VERBOSE_KPRINTF(
971 1,
972 "CD read buffer over run %d %d %d %d %d gp %d pp %d\n",
973 (u8)g_cdvdstm_usedmap_ee[0],
974 (u8)g_cdvdstm_usedmap_ee[1],
975 (u8)g_cdvdstm_usedmap_ee[2],
976 (u8)g_cdvdstm_usedmap_ee[3],
977 (u8)g_cdvdstm_usedmap_ee[4],
978 g_cdvdstm_bankgp_ee,
979 g_cdvdstm_bankcur_ee);
980 posszarg2_bytes_overrun = posszarg2_bytes - (posszarg2_bytes_remain - posszarg2_bytes_clamped);
981 break;
982 }
983 }
984 }
985 if ( posszarg2_bytes_overrun == -1 )
986 posszarg2_bytes_overrun = posszarg2_bytes;
987 outres_tmp2 = (retryflag) ? 1 : (posszarg2_bytes_overrun / 0x800);
988 if ( !retryflag )
989 {
990 if ( sceCdSC(0xFFFFFFFF, &g_cdvdstm_last_error_for_ee) != 2 && !outres_tmp2 && !g_cdvdstm_retryerr_ee )
991 g_cdvdstm_retryerr_ee = 273;
992 if ( g_cdvdstm_retryerr_ee )
993 {
994 outres_tmp2 = (u16)outres_tmp2 | (g_cdvdstm_retryerr_ee << 16);
995 g_cdvdstm_retryerr_ee = 0;
996 }
997 }
998 *outres_ptr = outres_tmp2;
999 return;
1000}
1001
1002static unsigned int ee_stream_intr_cb_normal(void *userdata)
1003{
1004 int scres_unused;
1005
1006 (void)userdata;
1007
1008 VERBOSE_KPRINTF(1, "Intr EE Stm Read call\n");
1009 iCancelAlarm((unsigned int (*)(void *))stm_ee_read_timeout_alarm_cb, &g_cdvdstm_curclk_ee);
1010 iCancelAlarm((unsigned int (*)(void *))ee_stream_intr_cb_normal, &g_cdvdstm_curclk_ee);
1011 sceCdSC(0xFFFFFFFF, &g_cdvdstm_last_error_for_ee);
1012 if ( !g_cdvdstm_last_error_for_ee )
1013 {
1014 switch ( sceCdGetDiskType() )
1015 {
1016 case SCECdPSCD:
1017 case SCECdPSCDDA:
1018 case SCECdPS2CD:
1019 case SCECdPS2CDDA:
1020 case SCECdPS2DVD:
1021 break;
1022 default:
1023 g_cdvdstm_last_error_for_ee = SCECdErREADCF;
1024 break;
1025 }
1026 }
1027 g_cdvdstm_curclk_ee.hi = 0;
1028 if ( g_cdvdstm_stmstart_ee )
1029 g_cdvdstm_retrycnt_ee_normal = 0;
1030 g_cdvdstm_curclk_ee.lo = (g_cdvdstm_stmstart_ee || g_cdvdstm_last_error_for_ee || g_cdvdstm_retrycnt_ee_normal) ?
1031 0x20f58000 :
1032 (0x9000 * sceCdSC(0xFFFFFFEF, &scres_unused));
1033 if ( g_cdvdstm_last_error_for_ee )
1034 {
1035 VERBOSE_KPRINTF(
1036 1,
1037 "EE Stream read LBN= %d Error code= 0x%02x retry= %d\n",
1038 g_cdvdstm_readlbn_ee_normal,
1039 g_cdvdstm_last_error_for_ee,
1040 g_cdvdstm_retrycnt_ee_normal);
1041 if ( g_cdvdstm_last_error_for_ee == SCECdErREAD || g_cdvdstm_last_error_for_ee == SCECdErABRT )
1042 {
1043 if ( g_cdvdstm_retrycnt_ee_normal )
1044 {
1045 VERBOSE_KPRINTF(1, "On Retry retry %d err %08x\n", g_cdvdstm_retrycnt_ee_normal, g_cdvdstm_last_error_for_ee);
1046 }
1047 g_cdvdstm_retrycnt_ee_normal = 3;
1048 }
1049 else
1050 {
1051 g_cdvdstm_retrycnt_ee_normal = 1;
1052 }
1053 g_cdvdstm_retryerr_ee = g_cdvdstm_last_error_for_ee;
1054 }
1055 if ( g_cdvdstm_retrycnt_ee_normal )
1056 {
1057 g_cdvdstm_retrycnt_ee_normal -= 1;
1058 if ( sceCdRE(
1059 ((unsigned int)g_cdvdstm_readlbn_ee_normal >= (unsigned int)(0x10 * g_cdvdstm_retrycnt_ee_normal)) ?
1060 (g_cdvdstm_readlbn_ee_normal - 0x10 * g_cdvdstm_retrycnt_ee_normal) :
1061 (g_cdvdstm_readlbn_ee_normal + 0x10 * g_cdvdstm_retrycnt_ee_normal),
1062 g_cdvdstm_sectorcount2,
1063 (char *)g_cdvdstm_buffer2 + g_cdvdstm_bankgp_ee * g_cdvdstm_chunksz2,
1064 &g_cdvdstm_mode_ee) )
1065 {
1066 iSetAlarm(&g_cdvdstm_curclk_ee, (unsigned int (*)(void *))stm_ee_read_timeout_alarm_cb, &g_cdvdstm_curclk_ee);
1067 }
1068 else
1069 {
1070 VERBOSE_KPRINTF(1, "Stm Read Call fail\n");
1071 g_cdvdstm_curclk_ee.lo = 0x708000;
1072 if (
1073 iSetAlarm(&g_cdvdstm_curclk_ee, (unsigned int (*)(void *))ee_stream_intr_cb_normal, &g_cdvdstm_curclk_ee)
1074 && !sceCdNop() )
1075 {
1076 sceCdSC(0, &g_cdvdstm_last_error_for_ee);
1077 }
1078 g_cdvdstm_retrycnt_ee_normal += 1;
1079 }
1080 }
1081 else
1082 {
1083 int gptmp;
1084
1085 if ( !g_cdvdstm_stmstart_ee )
1086 {
1087 g_cdvdstm_usedmap_ee[g_cdvdstm_bankgp_ee] = 1;
1088 gptmp = g_cdvdstm_bankgp_ee;
1089 g_cdvdstm_bankgp_ee += 1;
1090 if ( (unsigned int)g_cdvdstm_bankgp_ee >= (unsigned int)g_cdvdstm_bankcnt2 )
1091 g_cdvdstm_bankgp_ee = 0;
1092 }
1093 if (
1094 !g_cdvdstm_stmstart_ee
1095 && (g_cdvdstm_usedmap_ee[g_cdvdstm_bankgp_ee] || g_cdvdstm_bankcur_ee == g_cdvdstm_bankgp_ee) )
1096 {
1097 g_cdvdstm_bankgp_ee = gptmp;
1098 g_cdvdstm_usedmap_ee[gptmp] = 0;
1099 VERBOSE_KPRINTF(
1100 1,
1101 "read Full %d %d %d %d %d gp %d pp %d spn %d\n",
1102 (u8)g_cdvdstm_usedmap_ee[0],
1103 (u8)g_cdvdstm_usedmap_ee[1],
1104 (u8)g_cdvdstm_usedmap_ee[2],
1105 (u8)g_cdvdstm_usedmap_ee[3],
1106 (u8)g_cdvdstm_usedmap_ee[4],
1107 g_cdvdstm_bankgp_ee,
1108 g_cdvdstm_bankcur_ee,
1109 g_cdvdstm_mode_ee.spindlctrl);
1110 g_cdvdstm_curclk_ee.lo = 0x48000;
1111 if (
1112 iSetAlarm(&g_cdvdstm_curclk_ee, (unsigned int (*)(void *))ee_stream_intr_cb_normal, &g_cdvdstm_curclk_ee)
1113 && !sceCdNop() )
1114 {
1115 sceCdSC(0, &g_cdvdstm_last_error_for_ee);
1116 }
1117 }
1118 else
1119 {
1120 if ( g_cdvdstm_stmstart_ee == 2 )
1121 {
1122 unsigned int i;
1123
1124 g_cdvdstm_bankoffs_ee = 0;
1125 g_cdvdstm_bankcur_ee = 0;
1126 g_cdvdstm_bankgp_ee = 0;
1127 for ( i = 0; i < (unsigned int)g_cdvdstm_bankcnt2; i += 1 )
1128 g_cdvdstm_usedmap_ee[i] = 0;
1129 }
1130 g_cdvdstm_stmstart_ee = 0;
1131 g_cdvdstm_readlbn_ee_normal = g_cdvdstm_lsn_ee;
1132 if ( sceCdRE(
1133 g_cdvdstm_lsn_ee,
1134 g_cdvdstm_sectorcount2,
1135 (char *)g_cdvdstm_buffer2 + g_cdvdstm_bankgp_ee * g_cdvdstm_chunksz2,
1136 &g_cdvdstm_mode_ee) )
1137 {
1138 iSetAlarm(&g_cdvdstm_curclk_ee, (unsigned int (*)(void *))stm_ee_read_timeout_alarm_cb, &g_cdvdstm_curclk_ee);
1139 }
1140 else
1141 {
1142 VERBOSE_KPRINTF(1, "Stm Read Call1 fail\n");
1143 g_cdvdstm_curclk_ee.lo = 0x708000;
1144 if (
1145 iSetAlarm(&g_cdvdstm_curclk_ee, (unsigned int (*)(void *))ee_stream_intr_cb_normal, &g_cdvdstm_curclk_ee)
1146 && !sceCdNop() )
1147 {
1148 sceCdSC(0, &g_cdvdstm_last_error_for_ee);
1149 }
1150 g_cdvdstm_retrycnt_ee_normal = 1;
1151 }
1152 g_cdvdstm_lsn_ee += g_cdvdstm_sectorcount2;
1153 }
1154 }
1155 return 0;
1156}
1157
1158static void ee_stream_handler_cdda(cdrom_stm_devctl_t *instruct, int inbuf_len, int *outres_ptr)
1159{
1160 u32 cmdid;
1161 u32 posszarg2_bytes;
1162 int retryflag;
1163 int bankcur_tmp;
1164 u32 chunks_sectors;
1165 int bankcur_next_tmp1;
1166 int posszarg2_bytes_clamped;
1167 int dmat2;
1168 int bankcur_next_tmp2;
1169 int posszarg2_overrun_chunks2;
1170 unsigned int posszarg2_bytes_overrun;
1171 int state;
1172 unsigned int i;
1173
1174 (void)inbuf_len;
1175
1176 cmdid = instruct->m_cmdid;
1177 posszarg2_bytes = instruct->m_posszarg2 * g_cdvdstm_usedchunksize2;
1178 retryflag = 0;
1179 if ( g_cdvdstm_stmstart_ee == 2 && (cmdid != 9 && cmdid != 3) )
1180 {
1181 *outres_ptr = 0;
1182 return;
1183 }
1184 switch ( cmdid )
1185 {
1186 case 8:
1187 sceCdSC(2, &g_cdvdstm_last_error_for_ee);
1188 if ( sceCdNop() )
1189 {
1190 *outres_ptr = 1;
1191 return;
1192 }
1193 sceCdSC(0, &g_cdvdstm_last_error_for_ee);
1194 *outres_ptr = 0;
1195 return;
1196 case 7:
1197 CpuSuspendIntr(&state);
1198 CancelAlarm((unsigned int (*)(void *))ee_stream_intr_cb_cdda, &g_cdvdstm_curclk_ee);
1199 sceCdSC(0, &g_cdvdstm_last_error_for_ee);
1200 CpuResumeIntr(state);
1201 sceCdSync(0);
1202 *outres_ptr = 1;
1203 CancelAlarm((unsigned int (*)(void *))stm_ee_read_timeout_alarm_cb, &g_cdvdstm_curclk_ee);
1204 return;
1205 case 6:
1206 bankcur_tmp = g_cdvdstm_bankcur_ee;
1207 if ( !g_cdvdstm_usedmap_ee[bankcur_tmp] )
1208 {
1209 bankcur_tmp += 1;
1210 if ( (unsigned int)bankcur_tmp >= (unsigned int)g_cdvdstm_bankcnt2 )
1211 bankcur_tmp = 0;
1212 if ( !g_cdvdstm_usedmap_ee[bankcur_tmp] )
1213 bankcur_tmp = g_cdvdstm_bankcur_ee;
1214 }
1215 for ( i = 0; (i < (unsigned int)g_cdvdstm_bankcnt2) && g_cdvdstm_usedmap_ee[bankcur_tmp]
1216 && (g_cdvdstm_bankgp_ee != bankcur_tmp);
1217 i += 1 )
1218 {
1219 bankcur_tmp += 1;
1220 if ( (unsigned int)(bankcur_tmp) >= (unsigned int)g_cdvdstm_bankcnt2 )
1221 bankcur_tmp = 0;
1222 }
1223 if ( !g_cdvdstm_usedchunksize2 )
1224 __builtin_trap();
1225 *outres_ptr = i * (g_cdvdstm_chunksz2 / (unsigned int)g_cdvdstm_usedchunksize2);
1226 return;
1227 case 5:
1228 sceCdstm1Cb((void (*)(int))ee_stream_intr_cb_cdda_thunk);
1229 switch ( instruct->m_rmode.datapattern )
1230 {
1231 case SCECdSecS2368:
1232 g_cdvdstm_usedchunksize2 = 2368;
1233 break;
1234 case SCECdSecS2448:
1235 g_cdvdstm_usedchunksize2 = 2448;
1236 break;
1237 case SCECdSecS2352:
1238 default:
1239 g_cdvdstm_usedchunksize2 = 0x930;
1240 break;
1241 }
1242 if ( !instruct->m_posszarg2 )
1243 __builtin_trap();
1244 chunks_sectors = instruct->m_posszarg1 / instruct->m_posszarg2;
1245 g_cdvdstm_bufsz2 = instruct->m_posszarg1;
1246 g_cdvdstm_sectorcount2 = chunks_sectors;
1247 g_cdvdstm_chunksz2 = chunks_sectors * g_cdvdstm_usedchunksize2;
1248 g_cdvdstm_buffer2 = (char *)instruct->m_buffer;
1249 g_cdvdstm_bankcnt2 = instruct->m_posszarg2;
1250 PRINTF(
1251 "DA Stream Buffer 1Bank %dbyte %dbanks %dbyte used\n",
1252 (int)(chunks_sectors * g_cdvdstm_usedchunksize2),
1253 (int)instruct->m_posszarg2,
1254 (int)(chunks_sectors * g_cdvdstm_usedchunksize2 * instruct->m_posszarg2));
1255 *outres_ptr = 1;
1256 return;
1257 case 3:
1258 CpuSuspendIntr(&state);
1259 g_cdvdstm_stmstart_ee = 0;
1260 CancelAlarm((unsigned int (*)(void *))ee_stream_intr_cb_cdda, &g_cdvdstm_curclk_ee);
1261 sceCdSC(0, &g_cdvdstm_last_error_for_ee);
1262 CpuResumeIntr(state);
1263 sceCdBreak();
1264 for ( i = 0; i < (unsigned int)g_cdvdstm_bankcnt2; i += 1 )
1265 {
1266 g_cdvdstm_usedmap_ee[i] = 0;
1267 }
1268 g_cdvdstm_bankoffs_ee = 0;
1269 g_cdvdstm_bankcur_ee = 0;
1270 g_cdvdstm_bankgp_ee = 0;
1271 *outres_ptr = 1;
1272 sceCdSync(0);
1273 g_cdvdstm_last_error_for_ee = 0;
1274 sceCdSC(0xFFFFFFFE, &g_cdvdstm_last_error_for_ee);
1275 CancelAlarm((unsigned int (*)(void *))stm_ee_read_timeout_alarm_cb, &g_cdvdstm_curclk_ee);
1276 return;
1277 case 1:
1278 g_cdvdstm_mode_ee.datapattern = instruct->m_rmode.datapattern;
1279 g_cdvdstm_mode_ee.trycount = instruct->m_rmode.trycount;
1280 g_cdvdstm_mode_ee.spindlctrl = instruct->m_rmode.spindlctrl;
1281 g_cdvdstm_retryerr_ee = 0;
1282 break;
1283 }
1284 if ( cmdid == 9 )
1285 {
1286 if ( sceCdSC(0xFFFFFFFF, &g_cdvdstm_last_error_for_ee) )
1287 {
1288 CpuSuspendIntr(&state);
1289 g_cdvdstm_lsn_ee = instruct->m_posszarg1;
1290 for ( i = 0; i < (unsigned int)g_cdvdstm_bankcnt2; i += 1 )
1291 {
1292 g_cdvdstm_usedmap_ee[i] = 0;
1293 }
1294 g_cdvdstm_stmstart_ee = 2;
1295 CpuResumeIntr(state);
1296 *outres_ptr = 1;
1297 return;
1298 }
1299 *outres_ptr = 0;
1300 return;
1301 }
1302 if ( cmdid == 4 )
1303 {
1304 retryflag = 1;
1305 CpuSuspendIntr(&state);
1306 CancelAlarm((unsigned int (*)(void *))ee_stream_intr_cb_cdda, &g_cdvdstm_curclk_ee);
1307 sceCdSC(0, &g_cdvdstm_last_error_for_ee);
1308 posszarg2_bytes = 0;
1309 cmdid = 1;
1310 CpuResumeIntr(state);
1311 g_cdvdstm_lsn_ee = instruct->m_posszarg1;
1312 g_cdvdstm_bankoffs_ee = 0;
1313 g_cdvdstm_bankcur_ee = 0;
1314 g_cdvdstm_bankgp_ee = 0;
1315 sceCdSync(0);
1316 CancelAlarm((unsigned int (*)(void *))stm_ee_read_timeout_alarm_cb, &g_cdvdstm_curclk_ee);
1317 }
1318 if ( cmdid == 1 )
1319 {
1320 signed int posszarg2_chunks;
1321
1322 CpuSuspendIntr(&state);
1323 CancelAlarm((unsigned int (*)(void *))ee_stream_intr_cb_cdda, &g_cdvdstm_curclk_ee);
1324 sceCdSC(0, &g_cdvdstm_last_error_for_ee);
1325 CpuResumeIntr(state);
1326 retryflag = 1;
1327 for ( i = 0; i < (unsigned int)g_cdvdstm_bankcnt2; i += 1 )
1328 {
1329 g_cdvdstm_usedmap_ee[i] = 0;
1330 }
1331 g_cdvdstm_lsn_ee = instruct->m_posszarg1;
1332 g_cdvdstm_bankoffs_ee = 0;
1333 g_cdvdstm_bankcur_ee = 0;
1334 sceCdSync(0);
1335 CancelAlarm((unsigned int (*)(void *))stm_ee_read_timeout_alarm_cb, &g_cdvdstm_curclk_ee);
1336 if ( !g_cdvdstm_chunksz2 )
1337 __builtin_trap();
1338 posszarg2_chunks = (posszarg2_bytes / g_cdvdstm_chunksz2) + (!!(posszarg2_bytes % g_cdvdstm_chunksz2));
1339 for ( g_cdvdstm_bankgp_ee = 0; g_cdvdstm_bankgp_ee < posszarg2_chunks; g_cdvdstm_bankgp_ee += 1 )
1340 {
1341 int outres_tmp2;
1342
1343 outres_tmp2 = sceCdReadCDDA(g_cdvdstm_lsn_ee, g_cdvdstm_sectorcount2, g_cdvdstm_buffer2, &g_cdvdstm_mode_ee);
1344 sceCdSync(3);
1345 sceCdSC(0xFFFFFFFF, &g_cdvdstm_last_error_for_ee);
1346 if ( g_cdvdstm_last_error_for_ee || !outres_tmp2 )
1347 {
1348 sceCdSC(0, &g_cdvdstm_last_error_for_ee);
1349 *outres_ptr = 0;
1350 return;
1351 }
1352 g_cdvdstm_lsn_ee += g_cdvdstm_sectorcount2;
1353 g_cdvdstm_usedmap_ee[g_cdvdstm_bankgp_ee] = 1;
1354 }
1355 g_cdvdstm_stmstart_ee = 1;
1356 sceCdSC(2, &g_cdvdstm_last_error_for_ee);
1357 if ( !sceCdNop() )
1358 {
1359 sceCdSC(0, &g_cdvdstm_last_error_for_ee);
1360 *outres_ptr = 0;
1361 return;
1362 }
1363 }
1364 posszarg2_bytes_overrun = -1;
1365 for ( i = 0; i < posszarg2_bytes; i += posszarg2_bytes_clamped )
1366 {
1367 unsigned int posszarg2_bytes_remain;
1368
1369 posszarg2_bytes_remain = posszarg2_bytes - i;
1370 if ( !g_cdvdstm_usedmap_ee[g_cdvdstm_bankcur_ee] )
1371 {
1372 VERBOSE_KPRINTF(
1373 1,
1374 "CD read buffer over run %d %d %d %d %d gp %d pp %d\n",
1375 (u8)g_cdvdstm_usedmap_ee[0],
1376 (u8)g_cdvdstm_usedmap_ee[1],
1377 (u8)g_cdvdstm_usedmap_ee[2],
1378 (u8)g_cdvdstm_usedmap_ee[3],
1379 (u8)g_cdvdstm_usedmap_ee[4],
1380 g_cdvdstm_bankgp_ee,
1381 g_cdvdstm_bankcur_ee);
1382 CpuSuspendIntr(&state);
1383 bankcur_next_tmp1 = g_cdvdstm_bankcur_ee;
1384 g_cdvdstm_bankcur_ee += 1;
1385 if ( (unsigned int)g_cdvdstm_bankcur_ee >= (unsigned int)g_cdvdstm_bankcnt2 )
1386 g_cdvdstm_bankcur_ee = 0;
1387 if ( !g_cdvdstm_usedmap_ee[g_cdvdstm_bankcur_ee] )
1388 g_cdvdstm_bankcur_ee = bankcur_next_tmp1;
1389 posszarg2_bytes_overrun = posszarg2_bytes - posszarg2_bytes_remain;
1390 CpuResumeIntr(state);
1391 break;
1392 }
1393 posszarg2_bytes_clamped = ((unsigned int)(g_cdvdstm_chunksz2 - g_cdvdstm_bankoffs_ee) < posszarg2_bytes_remain) ?
1394 (unsigned int)(g_cdvdstm_chunksz2 - g_cdvdstm_bankoffs_ee) :
1395 posszarg2_bytes_remain;
1396 g_cdvdstm_dmat2.dest = ((char *)instruct->m_buffer) + i;
1397 g_cdvdstm_dmat2.size = posszarg2_bytes_clamped;
1398 g_cdvdstm_dmat2.attr = 0;
1399 g_cdvdstm_dmat2.src = (char *)g_cdvdstm_buffer2 + g_cdvdstm_bankcur_ee * g_cdvdstm_chunksz2 + g_cdvdstm_bankoffs_ee;
1400 if ( posszarg2_bytes_clamped )
1401 {
1402 while ( 1 )
1403 {
1404 CpuSuspendIntr(&state);
1405 dmat2 = sceSifSetDma(&g_cdvdstm_dmat2, 1);
1406 CpuResumeIntr(state);
1407 if ( dmat2 )
1408 break;
1409 DelayThread(500);
1410 }
1411 g_cdvdstm_bankoffs_ee += posszarg2_bytes_clamped;
1412 while ( sceSifDmaStat(dmat2) >= 0 )
1413 ;
1414 }
1415 if ( (unsigned int)g_cdvdstm_bankoffs_ee >= (unsigned int)g_cdvdstm_chunksz2 )
1416 {
1417 CpuSuspendIntr(&state);
1418 g_cdvdstm_bankoffs_ee = 0;
1419 g_cdvdstm_usedmap_ee[g_cdvdstm_bankcur_ee] = 0;
1420 bankcur_next_tmp2 = g_cdvdstm_bankcur_ee;
1421 g_cdvdstm_bankcur_ee += 1;
1422 if ( (unsigned int)g_cdvdstm_bankcur_ee >= (unsigned int)g_cdvdstm_bankcnt2 )
1423 g_cdvdstm_bankcur_ee = 0;
1424 if ( g_cdvdstm_usedmap_ee[g_cdvdstm_bankcur_ee] && g_cdvdstm_bankgp_ee != g_cdvdstm_bankcur_ee )
1425 {
1426 CpuResumeIntr(state);
1427 }
1428 else
1429 {
1430 g_cdvdstm_bankcur_ee = bankcur_next_tmp2;
1431 CpuResumeIntr(state);
1432 VERBOSE_KPRINTF(
1433 1,
1434 "CD read buffer over run %d %d %d %d %d gp %d pp %d\n",
1435 (u8)g_cdvdstm_usedmap_ee[0],
1436 (u8)g_cdvdstm_usedmap_ee[1],
1437 (u8)g_cdvdstm_usedmap_ee[2],
1438 (u8)g_cdvdstm_usedmap_ee[3],
1439 (u8)g_cdvdstm_usedmap_ee[4],
1440 g_cdvdstm_bankgp_ee,
1441 g_cdvdstm_bankcur_ee);
1442 posszarg2_bytes_overrun = posszarg2_bytes - (posszarg2_bytes_remain - posszarg2_bytes_clamped);
1443 break;
1444 }
1445 }
1446 }
1447 if ( posszarg2_bytes_overrun == 0xFFFFFFFF )
1448 posszarg2_bytes_overrun = posszarg2_bytes;
1449 if ( !g_cdvdstm_usedchunksize2 )
1450 __builtin_trap();
1451 posszarg2_overrun_chunks2 = posszarg2_bytes_overrun / g_cdvdstm_usedchunksize2;
1452 if ( retryflag )
1453 {
1454 *outres_ptr = 1;
1455 return;
1456 }
1457 if ( sceCdSC(0xFFFFFFFF, &g_cdvdstm_last_error_for_ee) != 2 && !posszarg2_overrun_chunks2 && !g_cdvdstm_retryerr_ee )
1458 g_cdvdstm_retryerr_ee = 273;
1459 if ( g_cdvdstm_retryerr_ee )
1460 {
1461 posszarg2_overrun_chunks2 = (u16)posszarg2_overrun_chunks2 | (g_cdvdstm_retryerr_ee << 16);
1462 g_cdvdstm_retryerr_ee = 0;
1463 }
1464 *outres_ptr = posszarg2_overrun_chunks2;
1465}
1466
1467static unsigned int ee_stream_intr_cb_cdda(void *userdata)
1468{
1469 int scres_unused;
1470
1471 (void)userdata;
1472
1473 VERBOSE_KPRINTF(1, "Intr EE DA Stm Read call\n");
1474 iCancelAlarm((unsigned int (*)(void *))stm_ee_read_timeout_alarm_cb, &g_cdvdstm_curclk_ee);
1475 iCancelAlarm((unsigned int (*)(void *))ee_stream_intr_cb_cdda, &g_cdvdstm_curclk_ee);
1476 sceCdSC(0xFFFFFFFF, &g_cdvdstm_last_error_for_ee);
1477 if ( !g_cdvdstm_last_error_for_ee )
1478 {
1479 switch ( sceCdGetDiskType() )
1480 {
1481 case SCECdPSCDDA:
1482 case SCECdPS2CDDA:
1483 case 0x21:
1484 case SCECdCDDA:
1485 break;
1486 default:
1487 g_cdvdstm_last_error_for_ee = SCECdErREADCF;
1488 break;
1489 }
1490 }
1491 g_cdvdstm_curclk_ee.hi = 0;
1492 if ( g_cdvdstm_stmstart_ee )
1493 g_cdvdstm_retrycnt_ee_cdda = 0;
1494 g_cdvdstm_curclk_ee.lo = (g_cdvdstm_stmstart_ee || g_cdvdstm_last_error_for_ee || g_cdvdstm_retrycnt_ee_cdda) ?
1495 0x20f58000 :
1496 (0x9000 * sceCdSC(0xFFFFFFEF, &scres_unused));
1497 if ( g_cdvdstm_last_error_for_ee )
1498 {
1499 VERBOSE_KPRINTF(
1500 1,
1501 "EE Stream read LBN= %d Error code= 0x%02x retry= %d\n",
1502 g_cdvdstm_readlbn_ee_cdda,
1503 g_cdvdstm_last_error_for_ee,
1504 g_cdvdstm_retrycnt_ee_cdda);
1505 if ( g_cdvdstm_last_error_for_ee == SCECdErREAD || g_cdvdstm_last_error_for_ee == SCECdErABRT )
1506 {
1507 if ( g_cdvdstm_retrycnt_ee_cdda )
1508 {
1509 VERBOSE_KPRINTF(1, "On Retry retry %d err %08x\n", g_cdvdstm_retrycnt_ee_cdda, g_cdvdstm_last_error_for_ee);
1510 }
1511 g_cdvdstm_retrycnt_ee_cdda = 4;
1512 }
1513 else
1514 {
1515 g_cdvdstm_retrycnt_ee_cdda = 1;
1516 }
1517 g_cdvdstm_retryerr_ee = g_cdvdstm_last_error_for_ee;
1518 }
1519 else
1520 {
1521 g_cdvdstm_retrycnt_ee_cdda = 0;
1522 }
1523 if ( g_cdvdstm_retrycnt_ee_cdda )
1524 {
1525 g_cdvdstm_retrycnt_ee_cdda -= 1;
1526 if (
1527 !g_cdvdstm_retrycnt_ee_cdda
1528 && (g_cdvdstm_last_error_for_ee == SCECdErREAD || g_cdvdstm_last_error_for_ee == SCECdErABRT) )
1529 {
1530 g_cdvdstm_readlbn_ee_cdda =
1531 g_cdvdstm_lsn_ee + ((g_cdvdstm_sectorcount2 < 0x1D) ? (0x1D - g_cdvdstm_sectorcount2) : 0);
1532 g_cdvdstm_lsn_ee = g_cdvdstm_readlbn_ee_cdda + g_cdvdstm_sectorcount2;
1533 }
1534 if ( sceCdReadCDDA(
1535 g_cdvdstm_readlbn_ee_cdda,
1536 g_cdvdstm_sectorcount2,
1537 (char *)g_cdvdstm_buffer2 + g_cdvdstm_bankgp_ee * g_cdvdstm_chunksz2,
1538 &g_cdvdstm_mode_ee) )
1539 {
1540 iSetAlarm(&g_cdvdstm_curclk_ee, (unsigned int (*)(void *))stm_ee_read_timeout_alarm_cb, &g_cdvdstm_curclk_ee);
1541 }
1542 else
1543 {
1544 VERBOSE_KPRINTF(1, "Stm Read Call fail\n");
1545 g_cdvdstm_curclk_ee.lo = 0x708000;
1546 if (
1547 iSetAlarm(&g_cdvdstm_curclk_ee, (unsigned int (*)(void *))ee_stream_intr_cb_cdda, &g_cdvdstm_curclk_ee)
1548 && !sceCdNop() )
1549 {
1550 sceCdSC(0, &g_cdvdstm_last_error_for_ee);
1551 }
1552 g_cdvdstm_retrycnt_ee_cdda += 1;
1553 }
1554 }
1555 else
1556 {
1557 int gptmp;
1558
1559 if ( !g_cdvdstm_stmstart_ee )
1560 {
1561 g_cdvdstm_usedmap_ee[g_cdvdstm_bankgp_ee] = 1;
1562 gptmp = g_cdvdstm_bankgp_ee;
1563 g_cdvdstm_bankgp_ee += 1;
1564 if ( (unsigned int)g_cdvdstm_bankgp_ee >= (unsigned int)g_cdvdstm_bankcnt2 )
1565 g_cdvdstm_bankgp_ee = 0;
1566 }
1567 if (
1568 !g_cdvdstm_stmstart_ee
1569 && (g_cdvdstm_usedmap_ee[g_cdvdstm_bankgp_ee] || g_cdvdstm_bankcur_ee == g_cdvdstm_bankgp_ee) )
1570 {
1571 g_cdvdstm_bankgp_ee = gptmp;
1572 g_cdvdstm_usedmap_ee[gptmp] = 0;
1573 VERBOSE_KPRINTF(
1574 1,
1575 "read Full %d %d %d %d %d gp %d pp %d spn %d\n",
1576 (u8)g_cdvdstm_usedmap_ee[0],
1577 (u8)g_cdvdstm_usedmap_ee[1],
1578 (u8)g_cdvdstm_usedmap_ee[2],
1579 (u8)g_cdvdstm_usedmap_ee[3],
1580 (u8)g_cdvdstm_usedmap_ee[4],
1581 g_cdvdstm_bankgp_ee,
1582 g_cdvdstm_bankcur_ee,
1583 g_cdvdstm_mode_ee.spindlctrl);
1584 g_cdvdstm_curclk_ee.lo = 0x48000;
1585 if (
1586 iSetAlarm(&g_cdvdstm_curclk_ee, (unsigned int (*)(void *))ee_stream_intr_cb_cdda, &g_cdvdstm_curclk_ee)
1587 && !sceCdNop() )
1588 {
1589 sceCdSC(0, &g_cdvdstm_last_error_for_ee);
1590 }
1591 }
1592 else
1593 {
1594 if ( g_cdvdstm_stmstart_ee == 2 )
1595 {
1596 unsigned int i;
1597
1598 g_cdvdstm_bankoffs_ee = 0;
1599 g_cdvdstm_bankcur_ee = 0;
1600 g_cdvdstm_bankgp_ee = 0;
1601 for ( i = 0; i < (unsigned int)g_cdvdstm_bankcnt2; i += 1 )
1602 g_cdvdstm_usedmap_ee[i] = 0;
1603 }
1604 g_cdvdstm_stmstart_ee = 0;
1605 g_cdvdstm_readlbn_ee_cdda = g_cdvdstm_lsn_ee;
1606 if ( sceCdReadCDDA(
1607 g_cdvdstm_lsn_ee,
1608 g_cdvdstm_sectorcount2,
1609 (char *)g_cdvdstm_buffer2 + g_cdvdstm_bankgp_ee * g_cdvdstm_chunksz2,
1610 &g_cdvdstm_mode_ee) )
1611 {
1612 iSetAlarm(&g_cdvdstm_curclk_ee, (unsigned int (*)(void *))stm_ee_read_timeout_alarm_cb, &g_cdvdstm_curclk_ee);
1613 }
1614 else
1615 {
1616 VERBOSE_KPRINTF(1, "Stm Read Call1 fail\n");
1617 g_cdvdstm_curclk_ee.lo = 0x708000;
1618 if (
1619 iSetAlarm(&g_cdvdstm_curclk_ee, (unsigned int (*)(void *))ee_stream_intr_cb_cdda, &g_cdvdstm_curclk_ee)
1620 && !sceCdNop() )
1621 {
1622 sceCdSC(0, &g_cdvdstm_last_error_for_ee);
1623 }
1624 g_cdvdstm_retrycnt_ee_cdda = 1;
1625 }
1626 g_cdvdstm_lsn_ee += g_cdvdstm_sectorcount2;
1627 }
1628 }
1629 return 0;
1630}
1631
1632// clang-format off
1633__asm__ (
1634 "\t" ".set push" "\n"
1635 "\t" ".set noat" "\n"
1636 "\t" ".set noreorder" "\n"
1637 "\t" ".global optimized_memcpy" "\n"
1638 "\t" "optimized_memcpy:" "\n"
1639 "\t" " srl $a3, $a2, 2" "\n"
1640 "\t" " beqz $a3, .Loptimized_memcpy_12" "\n"
1641 "\t" " or $a3, $a0, $a1" "\n"
1642 "\t" " andi $a3, $a3, 0x3" "\n"
1643 "\t" " bnez $a3, .Loptimized_memcpy_3" "\n"
1644 "\t" " nop" "\n"
1645 "\t" " srl $a3, $a2, 2" "\n"
1646 "\t" " addiu $at, $zero, 0xC" "\n"
1647 "\t" " div $zero, $a3, $at" "\n"
1648 "\t" " mflo $a3" "\n"
1649 "\t" " mfhi $v1" "\n"
1650 "\t" " beqz $v1, .Loptimized_memcpy_2" "\n"
1651 "\t" " nop" "\n"
1652 "\t" ".Loptimized_memcpy_1:" "\n"
1653 "\t" " lw $v0, 0x0($a1)" "\n"
1654 "\t" " addiu $v1, $v1, -0x1" "\n"
1655 "\t" " sw $v0, 0x0($a0)" "\n"
1656 "\t" " addiu $a1, $a1, 0x4" "\n"
1657 "\t" " bnez $v1, .Loptimized_memcpy_1" "\n"
1658 "\t" " addiu $a0, $a0, 0x4" "\n"
1659 "\t" " beqz $a3, .Loptimized_memcpy_12" "\n"
1660 "\t" " nop" "\n"
1661 "\t" ".Loptimized_memcpy_2:" "\n"
1662 "\t" " lw $v0, 0x0($a1)" "\n"
1663 "\t" " lw $v1, 0x4($a1)" "\n"
1664 "\t" " lw $t0, 0x8($a1)" "\n"
1665 "\t" " lw $t1, 0xC($a1)" "\n"
1666 "\t" " lw $t2, 0x10($a1)" "\n"
1667 "\t" " lw $t3, 0x14($a1)" "\n"
1668 "\t" " lw $t4, 0x18($a1)" "\n"
1669 "\t" " lw $t5, 0x1C($a1)" "\n"
1670 "\t" " lw $t6, 0x20($a1)" "\n"
1671 "\t" " lw $t7, 0x24($a1)" "\n"
1672 "\t" " lw $t8, 0x28($a1)" "\n"
1673 "\t" " lw $t9, 0x2C($a1)" "\n"
1674 "\t" " addiu $a3, $a3, -0x1" "\n"
1675 "\t" " sw $v0, 0x0($a0)" "\n"
1676 "\t" " sw $v1, 0x4($a0)" "\n"
1677 "\t" " sw $t0, 0x8($a0)" "\n"
1678 "\t" " sw $t1, 0xC($a0)" "\n"
1679 "\t" " sw $t2, 0x10($a0)" "\n"
1680 "\t" " sw $t3, 0x14($a0)" "\n"
1681 "\t" " sw $t4, 0x18($a0)" "\n"
1682 "\t" " sw $t5, 0x1C($a0)" "\n"
1683 "\t" " sw $t6, 0x20($a0)" "\n"
1684 "\t" " sw $t7, 0x24($a0)" "\n"
1685 "\t" " sw $t8, 0x28($a0)" "\n"
1686 "\t" " sw $t9, 0x2C($a0)" "\n"
1687 "\t" " addiu $a1, $a1, 0x30" "\n"
1688 "\t" " bnez $a3, .Loptimized_memcpy_2" "\n"
1689 "\t" " addiu $a0, $a0, 0x30" "\n"
1690 "\t" " j .Loptimized_memcpy_12" "\n"
1691 "\t" " nop" "\n"
1692 "\t" ".Loptimized_memcpy_3:" "\n"
1693 "\t" " andi $a3, $a0, 0x3" "\n"
1694 "\t" " beqz $a3, .Loptimized_memcpy_6" "\n"
1695 "\t" " andi $a3, $a1, 0x3" "\n"
1696 "\t" " beqz $a3, .Loptimized_memcpy_6" "\n"
1697 "\t" " nop" "\n"
1698 "\t" " srl $a3, $a2, 2" "\n"
1699 "\t" " addiu $at, $zero, 0xC" "\n"
1700 "\t" " div $zero, $a3, $at" "\n"
1701 "\t" " mflo $a3" "\n"
1702 "\t" " mfhi $v1" "\n"
1703 "\t" " beqz $v1, .Loptimized_memcpy_5" "\n"
1704 "\t" " nop" "\n"
1705 "\t" ".Loptimized_memcpy_4:" "\n"
1706 "\t" " lwl $v0, 0x3($a1)" "\n"
1707 "\t" " lwr $v0, 0x0($a1)" "\n"
1708 "\t" " addiu $v1, $v1, -0x1" "\n"
1709 "\t" " swl $v0, 0x3($a0)" "\n"
1710 "\t" " swr $v0, 0x0($a0)" "\n"
1711 "\t" " addiu $a1, $a1, 0x4" "\n"
1712 "\t" " bnez $v1, .Loptimized_memcpy_4" "\n"
1713 "\t" " addiu $a0, $a0, 0x4" "\n"
1714 "\t" " beqz $a3, .Loptimized_memcpy_12" "\n"
1715 "\t" " nop" "\n"
1716 "\t" ".Loptimized_memcpy_5:" "\n"
1717 "\t" " lwl $v0, 0x3($a1)" "\n"
1718 "\t" " lwr $v0, 0x0($a1)" "\n"
1719 "\t" " lwl $v1, 0x7($a1)" "\n"
1720 "\t" " lwr $v1, 0x4($a1)" "\n"
1721 "\t" " lwl $t0, 0xB($a1)" "\n"
1722 "\t" " lwr $t0, 0x8($a1)" "\n"
1723 "\t" " lwl $t1, 0xF($a1)" "\n"
1724 "\t" " lwr $t1, 0xC($a1)" "\n"
1725 "\t" " lwl $t2, 0x13($a1)" "\n"
1726 "\t" " lwr $t2, 0x10($a1)" "\n"
1727 "\t" " lwl $t3, 0x17($a1)" "\n"
1728 "\t" " lwr $t3, 0x14($a1)" "\n"
1729 "\t" " lwl $t4, 0x1B($a1)" "\n"
1730 "\t" " lwr $t4, 0x18($a1)" "\n"
1731 "\t" " lwl $t5, 0x1F($a1)" "\n"
1732 "\t" " lwr $t5, 0x1C($a1)" "\n"
1733 "\t" " lwl $t6, 0x23($a1)" "\n"
1734 "\t" " lwr $t6, 0x20($a1)" "\n"
1735 "\t" " lwl $t7, 0x27($a1)" "\n"
1736 "\t" " lwr $t7, 0x24($a1)" "\n"
1737 "\t" " lwl $t8, 0x2B($a1)" "\n"
1738 "\t" " lwr $t8, 0x28($a1)" "\n"
1739 "\t" " lwl $t9, 0x2F($a1)" "\n"
1740 "\t" " lwr $t9, 0x2C($a1)" "\n"
1741 "\t" " addiu $a3, $a3, -0x1" "\n"
1742 "\t" " swl $v0, 0x3($a0)" "\n"
1743 "\t" " swr $v0, 0x0($a0)" "\n"
1744 "\t" " swl $v1, 0x7($a0)" "\n"
1745 "\t" " swr $v1, 0x4($a0)" "\n"
1746 "\t" " swl $t0, 0xB($a0)" "\n"
1747 "\t" " swr $t0, 0x8($a0)" "\n"
1748 "\t" " swl $t1, 0xF($a0)" "\n"
1749 "\t" " swr $t1, 0xC($a0)" "\n"
1750 "\t" " swl $t2, 0x13($a0)" "\n"
1751 "\t" " swr $t2, 0x10($a0)" "\n"
1752 "\t" " swl $t3, 0x17($a0)" "\n"
1753 "\t" " swr $t3, 0x14($a0)" "\n"
1754 "\t" " swl $t4, 0x1B($a0)" "\n"
1755 "\t" " swr $t4, 0x18($a0)" "\n"
1756 "\t" " swl $t5, 0x1F($a0)" "\n"
1757 "\t" " swr $t5, 0x1C($a0)" "\n"
1758 "\t" " swl $t6, 0x23($a0)" "\n"
1759 "\t" " swr $t6, 0x20($a0)" "\n"
1760 "\t" " swl $t7, 0x27($a0)" "\n"
1761 "\t" " swr $t7, 0x24($a0)" "\n"
1762 "\t" " swl $t8, 0x2B($a0)" "\n"
1763 "\t" " swr $t8, 0x28($a0)" "\n"
1764 "\t" " swl $t9, 0x2F($a0)" "\n"
1765 "\t" " swr $t9, 0x2C($a0)" "\n"
1766 "\t" " addiu $a1, $a1, 0x30" "\n"
1767 "\t" " bnez $a3, .Loptimized_memcpy_5" "\n"
1768 "\t" " addiu $a0, $a0, 0x30" "\n"
1769 "\t" " j .Loptimized_memcpy_12" "\n"
1770 "\t" " nop" "\n"
1771 "\t" ".Loptimized_memcpy_6:" "\n"
1772 "\t" " andi $a3, $a0, 0x3" "\n"
1773 "\t" " beqz $a3, .Loptimized_memcpy_9" "\n"
1774 "\t" " nop" "\n"
1775 "\t" " srl $a3, $a2, 2" "\n"
1776 "\t" " addiu $at, $zero, 0xC" "\n"
1777 "\t" " div $zero, $a3, $at" "\n"
1778 "\t" " mflo $a3" "\n"
1779 "\t" " mfhi $v1" "\n"
1780 "\t" " beqz $v1, .Loptimized_memcpy_8" "\n"
1781 "\t" " nop" "\n"
1782 "\t" ".Loptimized_memcpy_7:" "\n"
1783 "\t" " lw $v0, 0x0($a1)" "\n"
1784 "\t" " addiu $v1, $v1, -0x1" "\n"
1785 "\t" " swl $v0, 0x3($a0)" "\n"
1786 "\t" " swr $v0, 0x0($a0)" "\n"
1787 "\t" " addiu $a1, $a1, 0x4" "\n"
1788 "\t" " bnez $v1, .Loptimized_memcpy_7" "\n"
1789 "\t" " addiu $a0, $a0, 0x4" "\n"
1790 "\t" " beqz $a3, .Loptimized_memcpy_12" "\n"
1791 "\t" " nop" "\n"
1792 "\t" ".Loptimized_memcpy_8:" "\n"
1793 "\t" " lw $v0, 0x0($a1)" "\n"
1794 "\t" " lw $v1, 0x4($a1)" "\n"
1795 "\t" " lw $t0, 0x8($a1)" "\n"
1796 "\t" " lw $t1, 0xC($a1)" "\n"
1797 "\t" " lw $t2, 0x10($a1)" "\n"
1798 "\t" " lw $t3, 0x14($a1)" "\n"
1799 "\t" " lw $t4, 0x18($a1)" "\n"
1800 "\t" " lw $t5, 0x1C($a1)" "\n"
1801 "\t" " lw $t6, 0x20($a1)" "\n"
1802 "\t" " lw $t7, 0x24($a1)" "\n"
1803 "\t" " lw $t8, 0x28($a1)" "\n"
1804 "\t" " lw $t9, 0x2C($a1)" "\n"
1805 "\t" " addiu $a3, $a3, -0x1" "\n"
1806 "\t" " swl $v0, 0x3($a0)" "\n"
1807 "\t" " swr $v0, 0x0($a0)" "\n"
1808 "\t" " swl $v1, 0x7($a0)" "\n"
1809 "\t" " swr $v1, 0x4($a0)" "\n"
1810 "\t" " swl $t0, 0xB($a0)" "\n"
1811 "\t" " swr $t0, 0x8($a0)" "\n"
1812 "\t" " swl $t1, 0xF($a0)" "\n"
1813 "\t" " swr $t1, 0xC($a0)" "\n"
1814 "\t" " swl $t2, 0x13($a0)" "\n"
1815 "\t" " swr $t2, 0x10($a0)" "\n"
1816 "\t" " swl $t3, 0x17($a0)" "\n"
1817 "\t" " swr $t3, 0x14($a0)" "\n"
1818 "\t" " swl $t4, 0x1B($a0)" "\n"
1819 "\t" " swr $t4, 0x18($a0)" "\n"
1820 "\t" " swl $t5, 0x1F($a0)" "\n"
1821 "\t" " swr $t5, 0x1C($a0)" "\n"
1822 "\t" " swl $t6, 0x23($a0)" "\n"
1823 "\t" " swr $t6, 0x20($a0)" "\n"
1824 "\t" " swl $t7, 0x27($a0)" "\n"
1825 "\t" " swr $t7, 0x24($a0)" "\n"
1826 "\t" " swl $t8, 0x2B($a0)" "\n"
1827 "\t" " swr $t8, 0x28($a0)" "\n"
1828 "\t" " swl $t9, 0x2F($a0)" "\n"
1829 "\t" " swr $t9, 0x2C($a0)" "\n"
1830 "\t" " addiu $a1, $a1, 0x30" "\n"
1831 "\t" " bnez $a3, .Loptimized_memcpy_8" "\n"
1832 "\t" " addiu $a0, $a0, 0x30" "\n"
1833 "\t" " j .Loptimized_memcpy_12" "\n"
1834 "\t" " nop" "\n"
1835 "\t" ".Loptimized_memcpy_9:" "\n"
1836 "\t" " srl $a3, $a2, 2" "\n"
1837 "\t" " addiu $at, $zero, 0xC" "\n"
1838 "\t" " div $zero, $a3, $at" "\n"
1839 "\t" " mflo $a3" "\n"
1840 "\t" " mfhi $v1" "\n"
1841 "\t" " beqz $v1, .Loptimized_memcpy_11" "\n"
1842 "\t" " nop" "\n"
1843 "\t" ".Loptimized_memcpy_10:" "\n"
1844 "\t" " lwl $v0, 0x3($a1)" "\n"
1845 "\t" " lwr $v0, 0x0($a1)" "\n"
1846 "\t" " addiu $v1, $v1, -0x1" "\n"
1847 "\t" " sw $v0, 0x0($a0)" "\n"
1848 "\t" " addiu $a1, $a1, 0x4" "\n"
1849 "\t" " bnez $v1, .Loptimized_memcpy_10" "\n"
1850 "\t" " addiu $a0, $a0, 0x4" "\n"
1851 "\t" " beqz $a3, .Loptimized_memcpy_12" "\n"
1852 "\t" " nop" "\n"
1853 "\t" ".Loptimized_memcpy_11:" "\n"
1854 "\t" " lwl $v0, 0x3($a1)" "\n"
1855 "\t" " lwr $v0, 0x0($a1)" "\n"
1856 "\t" " lwl $v1, 0x7($a1)" "\n"
1857 "\t" " lwr $v1, 0x4($a1)" "\n"
1858 "\t" " lwl $t0, 0xB($a1)" "\n"
1859 "\t" " lwr $t0, 0x8($a1)" "\n"
1860 "\t" " lwl $t1, 0xF($a1)" "\n"
1861 "\t" " lwr $t1, 0xC($a1)" "\n"
1862 "\t" " lwl $t2, 0x13($a1)" "\n"
1863 "\t" " lwr $t2, 0x10($a1)" "\n"
1864 "\t" " lwl $t3, 0x17($a1)" "\n"
1865 "\t" " lwr $t3, 0x14($a1)" "\n"
1866 "\t" " lwl $t4, 0x1B($a1)" "\n"
1867 "\t" " lwr $t4, 0x18($a1)" "\n"
1868 "\t" " lwl $t5, 0x1F($a1)" "\n"
1869 "\t" " lwr $t5, 0x1C($a1)" "\n"
1870 "\t" " lwl $t6, 0x23($a1)" "\n"
1871 "\t" " lwr $t6, 0x20($a1)" "\n"
1872 "\t" " lwl $t7, 0x27($a1)" "\n"
1873 "\t" " lwr $t7, 0x24($a1)" "\n"
1874 "\t" " lwl $t8, 0x2B($a1)" "\n"
1875 "\t" " lwr $t8, 0x28($a1)" "\n"
1876 "\t" " lwl $t9, 0x2F($a1)" "\n"
1877 "\t" " lwr $t9, 0x2C($a1)" "\n"
1878 "\t" " addiu $a3, $a3, -0x1" "\n"
1879 "\t" " sw $v0, 0x0($a0)" "\n"
1880 "\t" " sw $v1, 0x4($a0)" "\n"
1881 "\t" " sw $t0, 0x8($a0)" "\n"
1882 "\t" " sw $t1, 0xC($a0)" "\n"
1883 "\t" " sw $t2, 0x10($a0)" "\n"
1884 "\t" " sw $t3, 0x14($a0)" "\n"
1885 "\t" " sw $t4, 0x18($a0)" "\n"
1886 "\t" " sw $t5, 0x1C($a0)" "\n"
1887 "\t" " sw $t6, 0x20($a0)" "\n"
1888 "\t" " sw $t7, 0x24($a0)" "\n"
1889 "\t" " sw $t8, 0x28($a0)" "\n"
1890 "\t" " sw $t9, 0x2C($a0)" "\n"
1891 "\t" " addiu $a1, $a1, 0x30" "\n"
1892 "\t" " bnez $a3, .Loptimized_memcpy_11" "\n"
1893 "\t" " addiu $a0, $a0, 0x30" "\n"
1894 "\t" ".Loptimized_memcpy_12:" "\n"
1895 "\t" " andi $v1, $a2, 0x3" "\n"
1896 "\t" " beqz $v1, .Loptimized_memcpy_14" "\n"
1897 "\t" " nop" "\n"
1898 "\t" ".Loptimized_memcpy_13:" "\n"
1899 "\t" " lb $v0, 0x0($a1)" "\n"
1900 "\t" " addiu $v1, $v1, -0x1" "\n"
1901 "\t" " sb $v0, 0x0($a0)" "\n"
1902 "\t" " addiu $a1, $a1, 0x1" "\n"
1903 "\t" " bnez $v1, .Loptimized_memcpy_13" "\n"
1904 "\t" " addiu $a0, $a0, 0x1" "\n"
1905 "\t" ".Loptimized_memcpy_14:" "\n"
1906 "\t" " addu $v0, $a2, $zero" "\n"
1907 "\t" " jr $ra" "\n"
1908 "\t" " nop" "\n"
1909 "\t" ".set pop" "\n"
1910);
1911// clang-format on
#define EIO
Definition errno.h:29
int CpuResumeIntr(int state)
Definition intrman.c:227
int QueryIntrContext(void)
int CpuSuspendIntr(int *state)
Definition intrman.c:205
#define IOP_DT_FSEXT
Definition iomanX.h:66
int sceCdBreak(void)
Definition cdi.c:25
int sceCdStStop(void)
Definition cdi.c:214
int sceCdGetDiskType(void)
Definition cdi.c:35
int sceCdSync(int mode)
Definition cdi.c:109
@ SCECdSpinMax
@ SCECdPSCDDA
@ SCECdPSCD
@ SCECdPS2DVD
@ SCECdCDDA
@ SCECdPS2CDDA
@ SCECdPS2CD
@ SCECdErREAD
@ SCECdErABRT
@ SCECdErREADCF
int sceCdRE(unsigned int lsn, unsigned int sectors, void *buf, sceCdRMode *mode)
Definition cdvdman.c:5363
u16 newflags
Definition loadcore.h:36