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#include "iomanX.h"
13
14#include <cdvd-ioctl.h>
15#include <errno.h>
16#include <kerr.h>
17
18IRX_ID("cdvd_st_driver", 2, 2);
19// Based on the module from SCE SDK 3.1.0.
20
21extern struct irx_export_table _exp_cdvdstm;
22
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);
28static int cdrom_stm_init(iop_device_t *device);
29static int cdrom_stm_deinit(iop_device_t *device);
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);
37
38static void iop_stream_intr_cb_thunk(int userdata)
39{
40 iop_stream_intr_cb((void *)userdata);
41}
42
43static void ee_stream_intr_cb_normal_thunk(int userdata)
44{
45 ee_stream_intr_cb_normal((void *)userdata);
46}
47
48static void ee_stream_intr_cb_cdda_thunk(int userdata)
49{
50 ee_stream_intr_cb_cdda((void *)userdata);
51}
52
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;
63
64IOMANX_RETURN_VALUE_IMPL(EIO);
65
66static iop_device_ops_t g_cdrom_stm_dev_ops = {
67 &cdrom_stm_init, // init,
68 &cdrom_stm_deinit, // deinit,
69 IOMANX_RETURN_VALUE(EIO), // format,
70 IOMANX_RETURN_VALUE(EIO), // open,
71 IOMANX_RETURN_VALUE(EIO), // close,
72 IOMANX_RETURN_VALUE(EIO), // read,
73 IOMANX_RETURN_VALUE(EIO), // write,
74 IOMANX_RETURN_VALUE(EIO), // lseek,
75 IOMANX_RETURN_VALUE(EIO), // ioctl,
76 IOMANX_RETURN_VALUE(EIO), // remove,
77 IOMANX_RETURN_VALUE(EIO), // mkdir,
78 IOMANX_RETURN_VALUE(EIO), // rmdir,
79 IOMANX_RETURN_VALUE(EIO), // dopen,
80 IOMANX_RETURN_VALUE(EIO), // dclose,
81 IOMANX_RETURN_VALUE(EIO), // dread,
82 IOMANX_RETURN_VALUE(EIO), // getstat,
83 IOMANX_RETURN_VALUE(EIO), // chstat,
84 IOMANX_RETURN_VALUE(EIO), // rename,
85 IOMANX_RETURN_VALUE(EIO), // chdir,
86 IOMANX_RETURN_VALUE(EIO), // sync,
87 IOMANX_RETURN_VALUE(EIO), // mount,
88 IOMANX_RETURN_VALUE(EIO), // umount,
89 IOMANX_RETURN_VALUE_S64(EIO), // lseek64,
90 &cdrom_stm_devctl,
91 IOMANX_RETURN_VALUE(EIO), // symlink
92 IOMANX_RETURN_VALUE(EIO), // readlink
93 IOMANX_RETURN_VALUE(EIO), // ioctl2
94};
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;
106static sceCdRMode g_rmode_for_stream0;
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;
115static sceCdRMode g_cdvdstm_mode_iop;
116static int g_cdvdstm_stmstart_iop;
117static iop_sys_clock_t g_cdvdstm_curclk_iop;
118static SifDmaTransfer_t g_cdvdstm_dmat;
119static int g_cdvdstm_readlbn_ee_normal;
120static SifDmaTransfer_t g_cdvdstm_dmat2;
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;
127static sceCdRMode g_cdvdstm_mode_ee;
128static int g_cdvdstm_stmstart_ee;
129static iop_sys_clock_t g_cdvdstm_curclk_ee;
130
131static int vCancelAlarm(unsigned int (*alarm_cb)(void *arg), void *arg)
132{
133 return (QueryIntrContext() ? iCancelAlarm : CancelAlarm)(alarm_cb, arg);
134}
135
136static int vSetEventFlag(void)
137{
138 return (QueryIntrContext() ? iSetEventFlag : SetEventFlag)(g_cdvdman_intr_efid, 8);
139}
140
141static int vClearEventFlag(void)
142{
143 return (QueryIntrContext() ? iClearEventFlag : ClearEventFlag)(g_cdvdman_intr_efid, ~8);
144}
145
146int cdvdstm_dummyentry(void)
147{
148 VERBOSE_PRINTF(1, "Dummy Entry Called\n");
149 return 0;
150}
151
152int cdvdstm_termcall(void)
153{
154 cdrom_stm_devctl_t instruct;
155 int outres;
156
157 memset(&instruct, 0, sizeof(instruct));
158 instruct.m_cmdid = 3;
159 instruct.m_rmode.datapattern = SCECdSecS2048;
160 instruct.m_rmode.spindlctrl = SCECdSpinMax;
161 instruct.m_rmode.trycount = 0;
162 ee_stream_handler_normal(&instruct, 0x14, &outres);
163 sceCdStStop();
164 return 0;
165}
166
167static unsigned int stm_iop_read_timeout_alarm_cb(void *userdata)
168{
169 const iop_sys_clock_t *sys_clock;
170
171 sys_clock = (const iop_sys_clock_t *)userdata;
172 KPRINTF("Stm Iop Read Time Out %d(msec)\n", sys_clock->lo / 0x9000);
173 return !sceCdBreak();
174}
175
176static int sceCdStream0_inner(unsigned int rdsize, char *addrarg, int modearg, int *error_ptr)
177{
178 int cur_size;
179 unsigned int streamres;
180 int last_error;
181 u32 efbits;
182 int err;
183
184 VERBOSE_KPRINTF(1, "sceCdStream0 call read size= %d mode= %d addr= %08x\n", rdsize, modearg, addrarg);
185 cur_size = 0;
186 if ( !sceCdSC(0xFFFFFFFF, &last_error) )
187 return 0;
188 *error_ptr = 0;
189 if ( !modearg )
190 return iop_stream_handler(0, rdsize, addrarg, 2, &g_rmode_for_stream0, error_ptr);
191 vSetEventFlag();
192 err = 0;
193 streamres = 0;
194 while ( (!err || streamres) )
195 {
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 )
199 vClearEventFlag();
200 cur_size += streamres;
201 if ( err )
202 *error_ptr = err;
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 )
205 break;
206 }
207 return cur_size;
208}
209
210static int sceCdStream0(int rdsize_sectors, char *addrarg, int modearg, int *error_ptr)
211{
212 return sceCdStream0_inner(rdsize_sectors << 11, addrarg, modearg, error_ptr) / 0x800;
213}
214
215static unsigned int iop_stream_handler(
216 unsigned int posszarg1, unsigned int posszarg2, void *buffer, int cmdid, const sceCdRMode *rmode, int *error_ptr)
217{
218 int retryflag;
219 int bankcur_tmp;
220 unsigned int i;
221 unsigned int written_chunk_size_tmp;
222 int bankcur_next_tmp1;
223 int chunk_size;
224 int bankcur_next_tmp2;
225 int state;
226
227 retryflag = 0;
228 VERBOSE_KPRINTF(1, "CD Stream Call mode= %d\n", cmdid);
229 *error_ptr = 0;
230 if ( g_cdvdstm_stmstart_iop == 2 && cmdid != 9 && cmdid != 3 )
231 {
232 return 0;
233 }
234 switch ( cmdid )
235 {
236 case 8:
237 sceCdSC(1, &g_cdvdstm_last_error_for_iop);
238 if ( sceCdNop() )
239 return 1;
240 sceCdSC(0, &g_cdvdstm_last_error_for_iop);
241 return 0;
242 case 7:
243 CpuSuspendIntr(&state);
244 vCancelAlarm(iop_stream_intr_cb, &g_cdvdstm_curclk_iop);
245 sceCdSC(0, &g_cdvdstm_last_error_for_iop);
246 CpuResumeIntr(state);
247 sceCdSync(0);
248 vCancelAlarm(stm_iop_read_timeout_alarm_cb, &g_cdvdstm_curclk_iop);
249 return 1;
250 case 6:
251 bankcur_tmp = g_cdvdstm_bankcur_iop;
252 if ( !g_cdvdstm_usedmap_iop[bankcur_tmp] )
253 {
254 bankcur_tmp += 1;
255 if ( (unsigned int)bankcur_tmp >= (unsigned int)g_cdvdstm_bankmax )
256 bankcur_tmp = 0;
257 if ( !g_cdvdstm_usedmap_iop[bankcur_tmp] )
258 bankcur_tmp = g_cdvdstm_bankcur_iop;
259 }
260 for ( i = 0; (i < (unsigned int)g_cdvdstm_bankmax) && g_cdvdstm_usedmap_iop[bankcur_tmp]
261 && (g_cdvdstm_bankgp_iop != bankcur_tmp);
262 i += 1 )
263 {
264 bankcur_tmp += 1;
265 if ( (unsigned int)bankcur_tmp >= (unsigned int)g_cdvdstm_bankmax )
266 bankcur_tmp = 0;
267 }
268 return i * ((unsigned int)g_cdvdstm_numbytes >> 11);
269 case 5:
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;
276 KPRINTF(
277 "Stream Buffer 1Bank %dbyte %dbanks addr:%08x %dbyte used.\n",
278 g_cdvdstm_numbytes,
279 posszarg2,
280 buffer,
281 g_cdvdstm_numbytes * posszarg2);
282 return 1;
283 case 3:
284 CpuSuspendIntr(&state);
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);
288 CpuResumeIntr(state);
289 sceCdBreak();
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;
295 sceCdSync(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);
299 return 1;
300 case 9:
301 if ( sceCdSC(0xFFFFFFFF, &g_cdvdstm_last_error_for_iop) )
302 {
303 CpuSuspendIntr(&state);
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;
308 CpuResumeIntr(state);
309 return 1;
310 }
311 return 0;
312 case 1:
313 g_cdvdstm_mode_iop.datapattern = rmode->datapattern;
314 g_cdvdstm_mode_iop.trycount = rmode->trycount;
315 g_cdvdstm_mode_iop.spindlctrl = rmode->spindlctrl;
316 g_cdvdstm_retryerr_iop = 0;
317 break;
318 case 4:
319 CpuSuspendIntr(&state);
320 vCancelAlarm(iop_stream_intr_cb, &g_cdvdstm_curclk_iop);
321 sceCdSC(0, &g_cdvdstm_last_error_for_iop);
322 retryflag = 1;
323 CpuResumeIntr(state);
324 posszarg2 = 0;
325 cmdid = 1;
326 g_cdvdstm_lsn_iop = posszarg1;
327 g_cdvdstm_bankoffs_iop = 0;
328 g_cdvdstm_bankcur_iop = 0;
329 g_cdvdstm_bankgp_iop = 0;
330 sceCdSync(0);
331 vCancelAlarm(stm_iop_read_timeout_alarm_cb, &g_cdvdstm_curclk_iop);
332 break;
333 }
334 if ( cmdid == 1 )
335 {
336 CpuSuspendIntr(&state);
337 retryflag = 1;
338 vCancelAlarm(iop_stream_intr_cb, &g_cdvdstm_curclk_iop);
339 sceCdSC(0, &g_cdvdstm_last_error_for_iop);
340 CpuResumeIntr(state);
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;
348 sceCdSync(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);
352 if ( !sceCdNop() )
353 {
354 sceCdSC(0, &g_cdvdstm_last_error_for_iop);
355 return 0;
356 }
357 }
358 CpuSuspendIntr(&state);
359 written_chunk_size_tmp = -1;
360 for ( i = 0; i < posszarg2; i += chunk_size )
361 {
362 if ( !g_cdvdstm_usedmap_iop[g_cdvdstm_bankcur_iop] )
363 {
364 VERBOSE_KPRINTF(
365 1,
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] )
380 {
381 g_cdvdstm_bankcur_iop = bankcur_next_tmp1;
382 }
383 break;
384 }
385 if ( (unsigned int)g_cdvdstm_bankoffs_iop >= (unsigned int)g_cdvdstm_numbytes )
386 {
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 )
394 {
395 g_cdvdstm_bankcur_iop = bankcur_next_tmp2;
396 written_chunk_size_tmp = i;
397 VERBOSE_KPRINTF(
398 1,
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);
407 break;
408 }
409 }
410 optimized_memcpy(
411 &((char *)buffer)[i],
412 &((char *)g_cdvdstm_buffer)[g_cdvdstm_bankcur_iop * g_cdvdstm_numbytes + g_cdvdstm_bankoffs_iop],
413 0x800);
414 chunk_size = ((unsigned int)0x800 > posszarg2 - i) ? (posszarg2 - i) : 0x800;
415 g_cdvdstm_bankoffs_iop += chunk_size;
416 }
417 if ( written_chunk_size_tmp == 0xFFFFFFFF )
418 written_chunk_size_tmp = posszarg2;
419 CpuResumeIntr(state);
420 if ( !retryflag )
421 {
422 if ( sceCdSC(0xFFFFFFFF, &g_cdvdstm_last_error_for_iop) != 1 && !written_chunk_size_tmp && !g_cdvdstm_retryerr_iop )
423 {
424 g_cdvdstm_retryerr_iop = 273;
425 }
426 *error_ptr = g_cdvdstm_retryerr_iop;
427 g_cdvdstm_retryerr_iop = 0;
428 return written_chunk_size_tmp;
429 }
430 return 1;
431}
432
433static unsigned int iop_stream_intr_cb(void *userdata)
434{
435 int last_error;
436 int scres_unused;
437
438 (void)userdata;
439
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);
444 if ( !last_error )
445 {
446#ifdef CDVD_VARIANT_XOSD
447 switch ( sceCdSC(0xFFFFFFDA, &scres_unused) )
448#else
449 switch ( sceCdGetDiskType() )
450#endif
451 {
452 case SCECdPSCD:
453 case SCECdPSCDDA:
454 case SCECdPS2CD:
455 case SCECdPS2CDDA:
456 case SCECdPS2DVD:
457 break;
458 default:
459 last_error = SCECdErREADCF;
460 break;
461 }
462 }
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 )
467 {
468 VERBOSE_KPRINTF(
469 1, "Stm Rtry stmstart:%d err:%02x retry:%d\n", g_cdvdstm_stmstart_iop, last_error, g_cdvdstm_retrycnt_iop);
470 }
471 g_cdvdstm_curclk_iop.lo = (g_cdvdstm_stmstart_iop || last_error || g_cdvdstm_retrycnt_iop) ?
472 0x20f58000 :
473 (0x9000 * sceCdSC(0xFFFFFFEF, &scres_unused));
474 if ( last_error )
475 {
476 VERBOSE_KPRINTF(1, "IOP Stream read Error code= 0x%02x retry= %d\n", last_error, g_cdvdstm_retrycnt_iop);
477 if ( last_error == SCECdErREAD || last_error == SCECdErABRT )
478 {
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;
483 }
484 else
485 {
486 g_cdvdstm_retryerr_iop = last_error;
487 g_cdvdstm_retrycnt_iop = 1;
488 }
489 }
490 if ( g_cdvdstm_retrycnt_iop )
491 {
492 unsigned int tgttmp;
493
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);
499 if ( sceCdRE(
500 tgttmp,
501 g_cdvdstm_sectorcount,
502 (char *)g_cdvdstm_buffer + g_cdvdstm_bankgp_iop * g_cdvdstm_numbytes,
503 &g_cdvdstm_mode_iop) )
504 {
505 iSetAlarm(&g_cdvdstm_curclk_iop, stm_iop_read_timeout_alarm_cb, &g_cdvdstm_curclk_iop);
506 }
507 else
508 {
509 g_cdvdstm_curclk_iop.lo = 0x708000;
510 if (
511 iSetAlarm(&g_cdvdstm_curclk_iop, iop_stream_intr_cb, &g_cdvdstm_curclk_iop)
512 && !sceCdNop() )
513 {
514 sceCdSC(0, &last_error);
515 }
516 g_cdvdstm_retrycnt_iop += 1;
517 }
518 return 0;
519 }
520 else
521 {
522 int gptmp;
523
524 if ( !g_cdvdstm_stmstart_iop )
525 {
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;
531 }
532 if (
533 !g_cdvdstm_stmstart_iop
534 && (g_cdvdstm_usedmap_iop[g_cdvdstm_bankgp_iop] || g_cdvdstm_bankcur_iop == g_cdvdstm_bankgp_iop) )
535 {
536 g_cdvdstm_bankgp_iop = gptmp;
537 g_cdvdstm_usedmap_iop[gptmp] = 0;
538 VERBOSE_KPRINTF(
539 1,
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,
548 g_cdvdstm_mode_iop.spindlctrl);
549 g_cdvdstm_curclk_iop.lo = 0x48000;
550 if (
551 iSetAlarm(&g_cdvdstm_curclk_iop, iop_stream_intr_cb, &g_cdvdstm_curclk_iop)
552 && !sceCdNop() )
553 {
554 sceCdSC(0, &last_error);
555 }
556 }
557 else
558 {
559 if ( g_cdvdstm_stmstart_iop == 2 )
560 {
561 unsigned int i;
562
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;
568 }
569 g_cdvdstm_stmstart_iop = 0;
570 g_cdvdstm_tgt = g_cdvdstm_lsn_iop;
571 if ( sceCdRE(
572 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) )
576 {
577 iSetAlarm(
578 &g_cdvdstm_curclk_iop, stm_iop_read_timeout_alarm_cb, &g_cdvdstm_curclk_iop);
579 }
580 else
581 {
582 g_cdvdstm_curclk_iop.lo = 0x708000;
583 if (
584 iSetAlarm(&g_cdvdstm_curclk_iop, iop_stream_intr_cb, &g_cdvdstm_curclk_iop)
585 && !sceCdNop() )
586 {
587 sceCdSC(0, &last_error);
588 }
589 g_cdvdstm_retrycnt_iop = 1;
590 }
591 g_cdvdstm_lsn_iop += g_cdvdstm_sectorcount;
592 }
593 }
594 return 0;
595}
596
597static int cdrom_stm_init(iop_device_t *device)
598{
599 (void)device;
600 iop_sema_t semaparam;
601
602 semaparam.attr = SA_THPRI;
603 semaparam.initial = 1;
604 semaparam.max = 1;
605 semaparam.option = 0;
606 g_cdvdstm_semid = CreateSema(&semaparam);
607 return 0;
608}
609
610static int cdrom_stm_deinit(iop_device_t *device)
611{
612 (void)device;
613 SignalSema(g_cdvdstm_semid);
614 DeleteSema(g_cdvdstm_semid);
615 return 0;
616}
617
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)
620{
621 int retres;
622 cdrom_stm_devctl_t *instruct;
623 int *outres_ptr;
624
625 (void)f;
626 (void)name;
627 (void)outbuf_len;
628
629 instruct = inbuf;
630 outres_ptr = outbuf;
631 WaitSema(g_cdvdstm_semid);
632 retres = 0;
633 if ( g_cdvdstm_in_deldrv )
634 {
635 SignalSema(g_cdvdstm_semid);
636 return -EIO;
637 }
638 switch ( cmd )
639 {
640 case 0x4393:
641 if ( instruct->m_cmdid == 5 || instruct->m_cmdid == 3 || instruct->m_cmdid - 7 < 2 )
642 {
643 vSetEventFlag();
644 }
645 *outres_ptr = iop_stream_handler(
646 instruct->m_posszarg1,
647 instruct->m_posszarg2,
648 instruct->m_buffer,
649 instruct->m_cmdid,
650 &instruct->m_rmode,
651 (int *)&instruct->m_error);
652 break;
653 case 0x4394:
654 *outres_ptr =
655 sceCdStream0(instruct->m_posszarg2, (char *)instruct->m_buffer, instruct->m_cmdid, (int *)&instruct->m_error);
656 break;
657 case 0x4396:
658 ee_stream_handler_normal(instruct, inbuf_len, outres_ptr);
659 break;
660 case 0x4398:
661 ee_stream_handler_cdda(instruct, inbuf_len, outres_ptr);
662 break;
663 default:
664 // The following printf was removed for ioprp300x
665 PRINTF("Un-support devctl %08x\n", cmd);
666 retres = -EIO;
667 break;
668 }
669 SignalSema(g_cdvdstm_semid);
670 return retres;
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(&g_cdrom_stm_dev);
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 vsceSifDmaStat(int dmat)
722{
723#ifdef CDVD_VARIANT_XOSD
724 int st;
725 int state;
726
727 if ( QueryIntrContext() )
728 return sceSifDmaStat(dmat);
729 CpuSuspendIntr(&state);
730 st = sceSifDmaStat(dmat);
731 CpuResumeIntr(state);
732 return st;
733#else
734 return sceSifDmaStat(dmat);
735#endif
736}
737
738static unsigned int stm_ee_read_timeout_alarm_cb(void *userdata)
739{
740 int read_timeout;
741 const iop_sys_clock_t *sys_clock;
742
743 sys_clock = (const iop_sys_clock_t *)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);
747 return !sceCdBreak();
748}
749
750static void ee_stream_handler_normal(cdrom_stm_devctl_t *instruct, int inbuf_len, int *outres_ptr)
751{
752 int retryflag;
753 u32 cmdid;
754 u32 posszarg2_bytes;
755 int bankcur_tmp;
756 unsigned int chunks_sectors;
757 int bankcur_next_tmp1;
758 int posszarg2_bytes_clamped;
759 int dmat1;
760 int bankcur_next_tmp2;
761 int posszarg2_bytes_overrun;
762 int outres_tmp2;
763 int state;
764 unsigned int i;
765
766 (void)inbuf_len;
767
768 retryflag = 0;
769 cmdid = instruct->m_cmdid;
770 if ( g_cdvdstm_stmstart_ee == 2 && (cmdid != 9 && cmdid != 3) )
771 {
772 *outres_ptr = 0;
773 return;
774 }
775 switch ( cmdid )
776 {
777 case 8:
778 sceCdSC(2, &g_cdvdstm_last_error_for_ee);
779 if ( !sceCdNop() )
780 {
781 sceCdSC(0, &g_cdvdstm_last_error_for_ee);
782 *outres_ptr = 0;
783 return;
784 }
785 *outres_ptr = 1;
786 return;
787 case 7:
788 CpuSuspendIntr(&state);
789 CancelAlarm(ee_stream_intr_cb_normal, &g_cdvdstm_curclk_ee);
790 sceCdSC(0, &g_cdvdstm_last_error_for_ee);
791 CpuResumeIntr(state);
792 sceCdSync(0);
793 *outres_ptr = 1;
794 CancelAlarm(stm_ee_read_timeout_alarm_cb, &g_cdvdstm_curclk_ee);
795 return;
796 case 6:
797 bankcur_tmp = g_cdvdstm_bankcur_ee;
798 if ( !g_cdvdstm_usedmap_ee[bankcur_tmp] )
799 {
800 bankcur_tmp += 1;
801 if ( (unsigned int)bankcur_tmp >= (unsigned int)g_cdvdstm_bankcnt2 )
802 bankcur_tmp = 0;
803 if ( !g_cdvdstm_usedmap_ee[bankcur_tmp] )
804 bankcur_tmp = g_cdvdstm_bankcur_ee;
805 }
806 for ( i = 0; (i < (unsigned int)g_cdvdstm_bankcnt2) && g_cdvdstm_usedmap_ee[bankcur_tmp]
807 && (g_cdvdstm_bankgp_ee != bankcur_tmp);
808 i += 1 )
809 {
810 bankcur_tmp += 1;
811 if ( (unsigned int)bankcur_tmp >= (unsigned int)g_cdvdstm_bankcnt2 )
812 bankcur_tmp = 0;
813 }
814 *outres_ptr = i * ((unsigned int)g_cdvdstm_chunksz2 >> 11);
815 return;
816 case 5:
817 sceCdstm1Cb(ee_stream_intr_cb_normal_thunk);
818 if ( !instruct->m_posszarg2 )
819 __builtin_trap();
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;
826 PRINTF(
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)));
831 *outres_ptr = 1;
832 return;
833 case 3:
834 CpuSuspendIntr(&state);
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);
838 CpuResumeIntr(state);
839 sceCdBreak();
840 for ( i = 0; i < (unsigned int)g_cdvdstm_bankcnt2; i += 1 )
841 {
842 g_cdvdstm_usedmap_ee[i] = 0;
843 }
844 g_cdvdstm_bankoffs_ee = 0;
845 g_cdvdstm_bankcur_ee = 0;
846 g_cdvdstm_bankgp_ee = 0;
847 *outres_ptr = 1;
848 sceCdSync(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);
852 return;
853 case 1:
854 g_cdvdstm_mode_ee.datapattern = instruct->m_rmode.datapattern;
855 g_cdvdstm_mode_ee.trycount = instruct->m_rmode.trycount;
856 g_cdvdstm_mode_ee.spindlctrl = instruct->m_rmode.spindlctrl;
857 g_cdvdstm_retryerr_ee = 0;
858 break;
859 }
860 posszarg2_bytes = instruct->m_posszarg2 << 11;
861 if ( cmdid == 9 )
862 {
863 if ( sceCdSC(0xFFFFFFFF, &g_cdvdstm_last_error_for_ee) )
864 {
865 CpuSuspendIntr(&state);
866 g_cdvdstm_lsn_ee = instruct->m_posszarg1;
867 for ( i = 0; i < (unsigned int)g_cdvdstm_bankcnt2; i += 1 )
868 {
869 g_cdvdstm_usedmap_ee[i] = 0;
870 }
871 g_cdvdstm_stmstart_ee = 2;
872 CpuResumeIntr(state);
873 *outres_ptr = 1;
874 return;
875 }
876 *outres_ptr = 0;
877 return;
878 }
879 if ( cmdid == 4 )
880 {
881 retryflag = 1;
882 CpuSuspendIntr(&state);
883 CancelAlarm(ee_stream_intr_cb_normal, &g_cdvdstm_curclk_ee);
884 sceCdSC(0, &g_cdvdstm_last_error_for_ee);
885 posszarg2_bytes = 0;
886 cmdid = 1;
887 CpuResumeIntr(state);
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;
892 sceCdSync(0);
893 CancelAlarm(stm_ee_read_timeout_alarm_cb, &g_cdvdstm_curclk_ee);
894 }
895 if ( cmdid == 1 )
896 {
897 CpuSuspendIntr(&state);
898 CancelAlarm(ee_stream_intr_cb_normal, &g_cdvdstm_curclk_ee);
899 sceCdSC(0, &g_cdvdstm_last_error_for_ee);
900 CpuResumeIntr(state);
901 retryflag = 1;
902 for ( i = 0; i < (unsigned int)g_cdvdstm_bankcnt2; i += 1 )
903 {
904 g_cdvdstm_usedmap_ee[i] = 0;
905 }
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;
910 sceCdSync(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);
914 if ( !sceCdNop() )
915 {
916 sceCdSC(0, &g_cdvdstm_last_error_for_ee);
917 *outres_ptr = 0;
918 return;
919 }
920 }
921 posszarg2_bytes_overrun = -1;
922 for ( i = 0; i < posszarg2_bytes; i += posszarg2_bytes_clamped )
923 {
924 unsigned int posszarg2_bytes_remain;
925
926 posszarg2_bytes_remain = posszarg2_bytes - i;
927 if ( !g_cdvdstm_usedmap_ee[g_cdvdstm_bankcur_ee] )
928 {
929 VERBOSE_KPRINTF(
930 1,
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],
937 g_cdvdstm_bankgp_ee,
938 g_cdvdstm_bankcur_ee);
939 CpuSuspendIntr(&state);
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;
947 CpuResumeIntr(state);
948 break;
949 }
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 )
958 {
959 while ( 1 )
960 {
961 CpuSuspendIntr(&state);
962 dmat1 = sceSifSetDma(&g_cdvdstm_dmat, 1);
963 CpuResumeIntr(state);
964 if ( dmat1 )
965 break;
966 DelayThread(500);
967 }
968 g_cdvdstm_bankoffs_ee += posszarg2_bytes_clamped;
969 while ( vsceSifDmaStat(dmat1) >= 0 )
970 ;
971 }
972 if ( (unsigned int)g_cdvdstm_bankoffs_ee >= (unsigned int)g_cdvdstm_chunksz2 )
973 {
974 CpuSuspendIntr(&state);
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 )
982 {
983 CpuResumeIntr(state);
984 }
985 else
986 {
987 g_cdvdstm_bankcur_ee = bankcur_next_tmp2;
988 CpuResumeIntr(state);
989 VERBOSE_KPRINTF(
990 1,
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],
997 g_cdvdstm_bankgp_ee,
998 g_cdvdstm_bankcur_ee);
999 posszarg2_bytes_overrun = posszarg2_bytes - (posszarg2_bytes_remain - posszarg2_bytes_clamped);
1000 break;
1001 }
1002 }
1003 }
1004 if ( posszarg2_bytes_overrun == -1 )
1005 posszarg2_bytes_overrun = posszarg2_bytes;
1006 outres_tmp2 = (retryflag) ? 1 : (posszarg2_bytes_overrun / 0x800);
1007 if ( !retryflag )
1008 {
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 )
1012 {
1013 outres_tmp2 = (u16)outres_tmp2 | (g_cdvdstm_retryerr_ee << 16);
1014 g_cdvdstm_retryerr_ee = 0;
1015 }
1016 }
1017 *outres_ptr = outres_tmp2;
1018 return;
1019}
1020
1021static unsigned int ee_stream_intr_cb_normal(void *userdata)
1022{
1023 int scres_unused;
1024
1025 (void)userdata;
1026
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 )
1032 {
1033#ifdef CDVD_VARIANT_XOSD
1034 switch ( sceCdSC(0xFFFFFFDA, &scres_unused) )
1035#else
1036 switch ( sceCdGetDiskType() )
1037#endif
1038 {
1039 case SCECdPSCD:
1040 case SCECdPSCDDA:
1041 case SCECdPS2CD:
1042 case SCECdPS2CDDA:
1043 case SCECdPS2DVD:
1044 break;
1045 default:
1046 g_cdvdstm_last_error_for_ee = SCECdErREADCF;
1047 break;
1048 }
1049 }
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) ?
1054 0x20f58000 :
1055 (0x9000 * sceCdSC(0xFFFFFFEF, &scres_unused));
1056 if ( g_cdvdstm_last_error_for_ee )
1057 {
1058 VERBOSE_KPRINTF(
1059 1,
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);
1064 if ( g_cdvdstm_last_error_for_ee == SCECdErREAD || g_cdvdstm_last_error_for_ee == SCECdErABRT )
1065 {
1066 if ( g_cdvdstm_retrycnt_ee_normal )
1067 {
1068 VERBOSE_KPRINTF(1, "On Retry retry %d err %08x\n", g_cdvdstm_retrycnt_ee_normal, g_cdvdstm_last_error_for_ee);
1069 }
1070 g_cdvdstm_retrycnt_ee_normal = 3;
1071 }
1072 else
1073 {
1074 g_cdvdstm_retrycnt_ee_normal = 1;
1075 }
1076 g_cdvdstm_retryerr_ee = g_cdvdstm_last_error_for_ee;
1077 }
1078 if ( g_cdvdstm_retrycnt_ee_normal )
1079 {
1080 g_cdvdstm_retrycnt_ee_normal -= 1;
1081 if ( sceCdRE(
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) )
1088 {
1089 iSetAlarm(&g_cdvdstm_curclk_ee, stm_ee_read_timeout_alarm_cb, &g_cdvdstm_curclk_ee);
1090 }
1091 else
1092 {
1093 VERBOSE_KPRINTF(1, "Stm Read Call fail\n");
1094 g_cdvdstm_curclk_ee.lo = 0x708000;
1095 if (
1096 iSetAlarm(&g_cdvdstm_curclk_ee, ee_stream_intr_cb_normal, &g_cdvdstm_curclk_ee)
1097 && !sceCdNop() )
1098 {
1099 sceCdSC(0, &g_cdvdstm_last_error_for_ee);
1100 }
1101 g_cdvdstm_retrycnt_ee_normal += 1;
1102 }
1103 }
1104 else
1105 {
1106 int gptmp;
1107
1108 if ( !g_cdvdstm_stmstart_ee )
1109 {
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;
1115 }
1116 if (
1117 !g_cdvdstm_stmstart_ee
1118 && (g_cdvdstm_usedmap_ee[g_cdvdstm_bankgp_ee] || g_cdvdstm_bankcur_ee == g_cdvdstm_bankgp_ee) )
1119 {
1120 g_cdvdstm_bankgp_ee = gptmp;
1121 g_cdvdstm_usedmap_ee[gptmp] = 0;
1122 VERBOSE_KPRINTF(
1123 1,
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,
1132 g_cdvdstm_mode_ee.spindlctrl);
1133 g_cdvdstm_curclk_ee.lo = 0x48000;
1134 if (
1135 iSetAlarm(&g_cdvdstm_curclk_ee, ee_stream_intr_cb_normal, &g_cdvdstm_curclk_ee)
1136 && !sceCdNop() )
1137 {
1138 sceCdSC(0, &g_cdvdstm_last_error_for_ee);
1139 }
1140 }
1141 else
1142 {
1143 if ( g_cdvdstm_stmstart_ee == 2 )
1144 {
1145 unsigned int i;
1146
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;
1152 }
1153 g_cdvdstm_stmstart_ee = 0;
1154 g_cdvdstm_readlbn_ee_normal = g_cdvdstm_lsn_ee;
1155 if ( sceCdRE(
1156 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) )
1160 {
1161 iSetAlarm(&g_cdvdstm_curclk_ee, stm_ee_read_timeout_alarm_cb, &g_cdvdstm_curclk_ee);
1162 }
1163 else
1164 {
1165 VERBOSE_KPRINTF(1, "Stm Read Call1 fail\n");
1166 g_cdvdstm_curclk_ee.lo = 0x708000;
1167 if (
1168 iSetAlarm(&g_cdvdstm_curclk_ee, ee_stream_intr_cb_normal, &g_cdvdstm_curclk_ee)
1169 && !sceCdNop() )
1170 {
1171 sceCdSC(0, &g_cdvdstm_last_error_for_ee);
1172 }
1173 g_cdvdstm_retrycnt_ee_normal = 1;
1174 }
1175 g_cdvdstm_lsn_ee += g_cdvdstm_sectorcount2;
1176 }
1177 }
1178 return 0;
1179}
1180
1181static void ee_stream_handler_cdda(cdrom_stm_devctl_t *instruct, int inbuf_len, int *outres_ptr)
1182{
1183 u32 cmdid;
1184 u32 posszarg2_bytes;
1185 int retryflag;
1186 int bankcur_tmp;
1187 u32 chunks_sectors;
1188 int bankcur_next_tmp1;
1189 int posszarg2_bytes_clamped;
1190 int dmat2;
1191 int bankcur_next_tmp2;
1192 int posszarg2_overrun_chunks2;
1193 unsigned int posszarg2_bytes_overrun;
1194 int state;
1195 unsigned int i;
1196
1197 (void)inbuf_len;
1198
1199 cmdid = instruct->m_cmdid;
1200 posszarg2_bytes = instruct->m_posszarg2 * g_cdvdstm_usedchunksize2;
1201 retryflag = 0;
1202 if ( g_cdvdstm_stmstart_ee == 2 && (cmdid != 9 && cmdid != 3) )
1203 {
1204 *outres_ptr = 0;
1205 return;
1206 }
1207 switch ( cmdid )
1208 {
1209 case 8:
1210 sceCdSC(2, &g_cdvdstm_last_error_for_ee);
1211 if ( sceCdNop() )
1212 {
1213 *outres_ptr = 1;
1214 return;
1215 }
1216 sceCdSC(0, &g_cdvdstm_last_error_for_ee);
1217 *outres_ptr = 0;
1218 return;
1219 case 7:
1220 CpuSuspendIntr(&state);
1221 CancelAlarm(ee_stream_intr_cb_cdda, &g_cdvdstm_curclk_ee);
1222 sceCdSC(0, &g_cdvdstm_last_error_for_ee);
1223 CpuResumeIntr(state);
1224 sceCdSync(0);
1225 *outres_ptr = 1;
1226 CancelAlarm(stm_ee_read_timeout_alarm_cb, &g_cdvdstm_curclk_ee);
1227 return;
1228 case 6:
1229 bankcur_tmp = g_cdvdstm_bankcur_ee;
1230 if ( !g_cdvdstm_usedmap_ee[bankcur_tmp] )
1231 {
1232 bankcur_tmp += 1;
1233 if ( (unsigned int)bankcur_tmp >= (unsigned int)g_cdvdstm_bankcnt2 )
1234 bankcur_tmp = 0;
1235 if ( !g_cdvdstm_usedmap_ee[bankcur_tmp] )
1236 bankcur_tmp = g_cdvdstm_bankcur_ee;
1237 }
1238 for ( i = 0; (i < (unsigned int)g_cdvdstm_bankcnt2) && g_cdvdstm_usedmap_ee[bankcur_tmp]
1239 && (g_cdvdstm_bankgp_ee != bankcur_tmp);
1240 i += 1 )
1241 {
1242 bankcur_tmp += 1;
1243 if ( (unsigned int)(bankcur_tmp) >= (unsigned int)g_cdvdstm_bankcnt2 )
1244 bankcur_tmp = 0;
1245 }
1246 if ( !g_cdvdstm_usedchunksize2 )
1247 __builtin_trap();
1248 *outres_ptr = i * (g_cdvdstm_chunksz2 / (unsigned int)g_cdvdstm_usedchunksize2);
1249 return;
1250 case 5:
1251 sceCdstm1Cb(ee_stream_intr_cb_cdda_thunk);
1252 switch ( instruct->m_rmode.datapattern )
1253 {
1254 case SCECdSecS2368:
1255 g_cdvdstm_usedchunksize2 = 2368;
1256 break;
1257 case SCECdSecS2448:
1258 g_cdvdstm_usedchunksize2 = 2448;
1259 break;
1260 case SCECdSecS2352:
1261 default:
1262 g_cdvdstm_usedchunksize2 = 0x930;
1263 break;
1264 }
1265 if ( !instruct->m_posszarg2 )
1266 __builtin_trap();
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;
1273 PRINTF(
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));
1278 *outres_ptr = 1;
1279 return;
1280 case 3:
1281 CpuSuspendIntr(&state);
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);
1285 CpuResumeIntr(state);
1286 sceCdBreak();
1287 for ( i = 0; i < (unsigned int)g_cdvdstm_bankcnt2; i += 1 )
1288 {
1289 g_cdvdstm_usedmap_ee[i] = 0;
1290 }
1291 g_cdvdstm_bankoffs_ee = 0;
1292 g_cdvdstm_bankcur_ee = 0;
1293 g_cdvdstm_bankgp_ee = 0;
1294 *outres_ptr = 1;
1295 sceCdSync(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);
1299 return;
1300 case 1:
1301 g_cdvdstm_mode_ee.datapattern = instruct->m_rmode.datapattern;
1302 g_cdvdstm_mode_ee.trycount = instruct->m_rmode.trycount;
1303 g_cdvdstm_mode_ee.spindlctrl = instruct->m_rmode.spindlctrl;
1304 g_cdvdstm_retryerr_ee = 0;
1305 break;
1306 }
1307 if ( cmdid == 9 )
1308 {
1309 if ( sceCdSC(0xFFFFFFFF, &g_cdvdstm_last_error_for_ee) )
1310 {
1311 CpuSuspendIntr(&state);
1312 g_cdvdstm_lsn_ee = instruct->m_posszarg1;
1313 for ( i = 0; i < (unsigned int)g_cdvdstm_bankcnt2; i += 1 )
1314 {
1315 g_cdvdstm_usedmap_ee[i] = 0;
1316 }
1317 g_cdvdstm_stmstart_ee = 2;
1318 CpuResumeIntr(state);
1319 *outres_ptr = 1;
1320 return;
1321 }
1322 *outres_ptr = 0;
1323 return;
1324 }
1325 if ( cmdid == 4 )
1326 {
1327 retryflag = 1;
1328 CpuSuspendIntr(&state);
1329 CancelAlarm(ee_stream_intr_cb_cdda, &g_cdvdstm_curclk_ee);
1330 sceCdSC(0, &g_cdvdstm_last_error_for_ee);
1331 posszarg2_bytes = 0;
1332 cmdid = 1;
1333 CpuResumeIntr(state);
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;
1338 sceCdSync(0);
1339 CancelAlarm(stm_ee_read_timeout_alarm_cb, &g_cdvdstm_curclk_ee);
1340 }
1341 if ( cmdid == 1 )
1342 {
1343 signed int posszarg2_chunks;
1344
1345 CpuSuspendIntr(&state);
1346 CancelAlarm(ee_stream_intr_cb_cdda, &g_cdvdstm_curclk_ee);
1347 sceCdSC(0, &g_cdvdstm_last_error_for_ee);
1348 CpuResumeIntr(state);
1349 retryflag = 1;
1350 for ( i = 0; i < (unsigned int)g_cdvdstm_bankcnt2; i += 1 )
1351 {
1352 g_cdvdstm_usedmap_ee[i] = 0;
1353 }
1354 g_cdvdstm_lsn_ee = instruct->m_posszarg1;
1355 g_cdvdstm_bankoffs_ee = 0;
1356 g_cdvdstm_bankcur_ee = 0;
1357 sceCdSync(0);
1358 CancelAlarm(stm_ee_read_timeout_alarm_cb, &g_cdvdstm_curclk_ee);
1359 if ( !g_cdvdstm_chunksz2 )
1360 __builtin_trap();
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 )
1363 {
1364 int outres_tmp2;
1365
1366 outres_tmp2 = sceCdReadCDDA(g_cdvdstm_lsn_ee, g_cdvdstm_sectorcount2, g_cdvdstm_buffer2, &g_cdvdstm_mode_ee);
1367 sceCdSync(3);
1368 sceCdSC(0xFFFFFFFF, &g_cdvdstm_last_error_for_ee);
1369 if ( g_cdvdstm_last_error_for_ee || !outres_tmp2 )
1370 {
1371 sceCdSC(0, &g_cdvdstm_last_error_for_ee);
1372 *outres_ptr = 0;
1373 return;
1374 }
1375 g_cdvdstm_lsn_ee += g_cdvdstm_sectorcount2;
1376 g_cdvdstm_usedmap_ee[g_cdvdstm_bankgp_ee] = 1;
1377 }
1378 g_cdvdstm_stmstart_ee = 1;
1379 sceCdSC(2, &g_cdvdstm_last_error_for_ee);
1380 if ( !sceCdNop() )
1381 {
1382 sceCdSC(0, &g_cdvdstm_last_error_for_ee);
1383 *outres_ptr = 0;
1384 return;
1385 }
1386 }
1387 posszarg2_bytes_overrun = -1;
1388 for ( i = 0; i < posszarg2_bytes; i += posszarg2_bytes_clamped )
1389 {
1390 unsigned int posszarg2_bytes_remain;
1391
1392 posszarg2_bytes_remain = posszarg2_bytes - i;
1393 if ( !g_cdvdstm_usedmap_ee[g_cdvdstm_bankcur_ee] )
1394 {
1395 VERBOSE_KPRINTF(
1396 1,
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);
1405 CpuSuspendIntr(&state);
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;
1413 CpuResumeIntr(state);
1414 break;
1415 }
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 )
1424 {
1425 while ( 1 )
1426 {
1427 CpuSuspendIntr(&state);
1428 dmat2 = sceSifSetDma(&g_cdvdstm_dmat2, 1);
1429 CpuResumeIntr(state);
1430 if ( dmat2 )
1431 break;
1432 DelayThread(500);
1433 }
1434 g_cdvdstm_bankoffs_ee += posszarg2_bytes_clamped;
1435 while ( vsceSifDmaStat(dmat2) >= 0 )
1436 ;
1437 }
1438 if ( (unsigned int)g_cdvdstm_bankoffs_ee >= (unsigned int)g_cdvdstm_chunksz2 )
1439 {
1440 CpuSuspendIntr(&state);
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 )
1448 {
1449 CpuResumeIntr(state);
1450 }
1451 else
1452 {
1453 g_cdvdstm_bankcur_ee = bankcur_next_tmp2;
1454 CpuResumeIntr(state);
1455 VERBOSE_KPRINTF(
1456 1,
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);
1466 break;
1467 }
1468 }
1469 }
1470 if ( posszarg2_bytes_overrun == 0xFFFFFFFF )
1471 posszarg2_bytes_overrun = posszarg2_bytes;
1472 if ( !g_cdvdstm_usedchunksize2 )
1473 __builtin_trap();
1474 posszarg2_overrun_chunks2 = posszarg2_bytes_overrun / g_cdvdstm_usedchunksize2;
1475 if ( retryflag )
1476 {
1477 *outres_ptr = 1;
1478 return;
1479 }
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 )
1483 {
1484 posszarg2_overrun_chunks2 = (u16)posszarg2_overrun_chunks2 | (g_cdvdstm_retryerr_ee << 16);
1485 g_cdvdstm_retryerr_ee = 0;
1486 }
1487 *outres_ptr = posszarg2_overrun_chunks2;
1488}
1489
1490static unsigned int ee_stream_intr_cb_cdda(void *userdata)
1491{
1492 int scres_unused;
1493
1494 (void)userdata;
1495
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 )
1501 {
1502#ifdef CDVD_VARIANT_XOSD
1503 switch ( sceCdSC(0xFFFFFFDA, &scres_unused) )
1504#else
1505 switch ( sceCdGetDiskType() )
1506#endif
1507 {
1508 case SCECdPSCDDA:
1509 case SCECdPS2CDDA:
1510 case 0x21:
1511 case SCECdCDDA:
1512 break;
1513 default:
1514 g_cdvdstm_last_error_for_ee = SCECdErREADCF;
1515 break;
1516 }
1517 }
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) ?
1522 0x20f58000 :
1523 (0x9000 * sceCdSC(0xFFFFFFEF, &scres_unused));
1524 if ( g_cdvdstm_last_error_for_ee )
1525 {
1526 VERBOSE_KPRINTF(
1527 1,
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);
1532 if ( g_cdvdstm_last_error_for_ee == SCECdErREAD || g_cdvdstm_last_error_for_ee == SCECdErABRT )
1533 {
1534 if ( g_cdvdstm_retrycnt_ee_cdda )
1535 {
1536 VERBOSE_KPRINTF(1, "On Retry retry %d err %08x\n", g_cdvdstm_retrycnt_ee_cdda, g_cdvdstm_last_error_for_ee);
1537 }
1538 g_cdvdstm_retrycnt_ee_cdda = 4;
1539 }
1540 else
1541 {
1542 g_cdvdstm_retrycnt_ee_cdda = 1;
1543 }
1544 g_cdvdstm_retryerr_ee = g_cdvdstm_last_error_for_ee;
1545 }
1546 else
1547 {
1548 g_cdvdstm_retrycnt_ee_cdda = 0;
1549 }
1550 if ( g_cdvdstm_retrycnt_ee_cdda )
1551 {
1552 g_cdvdstm_retrycnt_ee_cdda -= 1;
1553 if (
1554 !g_cdvdstm_retrycnt_ee_cdda
1555 && (g_cdvdstm_last_error_for_ee == SCECdErREAD || g_cdvdstm_last_error_for_ee == SCECdErABRT) )
1556 {
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;
1560 }
1561 if ( sceCdReadCDDA(
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) )
1566 {
1567 iSetAlarm(&g_cdvdstm_curclk_ee, stm_ee_read_timeout_alarm_cb, &g_cdvdstm_curclk_ee);
1568 }
1569 else
1570 {
1571 VERBOSE_KPRINTF(1, "Stm Read Call fail\n");
1572 g_cdvdstm_curclk_ee.lo = 0x708000;
1573 if (
1574 iSetAlarm(&g_cdvdstm_curclk_ee, ee_stream_intr_cb_cdda, &g_cdvdstm_curclk_ee)
1575 && !sceCdNop() )
1576 {
1577 sceCdSC(0, &g_cdvdstm_last_error_for_ee);
1578 }
1579 g_cdvdstm_retrycnt_ee_cdda += 1;
1580 }
1581 }
1582 else
1583 {
1584 int gptmp;
1585
1586 if ( !g_cdvdstm_stmstart_ee )
1587 {
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;
1593 }
1594 if (
1595 !g_cdvdstm_stmstart_ee
1596 && (g_cdvdstm_usedmap_ee[g_cdvdstm_bankgp_ee] || g_cdvdstm_bankcur_ee == g_cdvdstm_bankgp_ee) )
1597 {
1598 g_cdvdstm_bankgp_ee = gptmp;
1599 g_cdvdstm_usedmap_ee[gptmp] = 0;
1600 VERBOSE_KPRINTF(
1601 1,
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,
1610 g_cdvdstm_mode_ee.spindlctrl);
1611 g_cdvdstm_curclk_ee.lo = 0x48000;
1612 if (
1613 iSetAlarm(&g_cdvdstm_curclk_ee, ee_stream_intr_cb_cdda, &g_cdvdstm_curclk_ee)
1614 && !sceCdNop() )
1615 {
1616 sceCdSC(0, &g_cdvdstm_last_error_for_ee);
1617 }
1618 }
1619 else
1620 {
1621 if ( g_cdvdstm_stmstart_ee == 2 )
1622 {
1623 unsigned int i;
1624
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;
1630 }
1631 g_cdvdstm_stmstart_ee = 0;
1632 g_cdvdstm_readlbn_ee_cdda = g_cdvdstm_lsn_ee;
1633 if ( sceCdReadCDDA(
1634 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) )
1638 {
1639 iSetAlarm(&g_cdvdstm_curclk_ee, stm_ee_read_timeout_alarm_cb, &g_cdvdstm_curclk_ee);
1640 }
1641 else
1642 {
1643 VERBOSE_KPRINTF(1, "Stm Read Call1 fail\n");
1644 g_cdvdstm_curclk_ee.lo = 0x708000;
1645 if (
1646 iSetAlarm(&g_cdvdstm_curclk_ee, ee_stream_intr_cb_cdda, &g_cdvdstm_curclk_ee)
1647 && !sceCdNop() )
1648 {
1649 sceCdSC(0, &g_cdvdstm_last_error_for_ee);
1650 }
1651 g_cdvdstm_retrycnt_ee_cdda = 1;
1652 }
1653 g_cdvdstm_lsn_ee += g_cdvdstm_sectorcount2;
1654 }
1655 }
1656 return 0;
1657}
1658
1659// clang-format off
1660__asm__ (
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"
1671 "\t" " nop" "\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"
1678 "\t" " nop" "\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"
1687 "\t" " nop" "\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"
1718 "\t" " nop" "\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"
1724 "\t" " nop" "\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"
1731 "\t" " nop" "\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"
1742 "\t" " nop" "\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"
1797 "\t" " nop" "\n"
1798 "\t" ".Loptimized_memcpy_6:" "\n"
1799 "\t" " andi $a3, $a0, 0x3" "\n"
1800 "\t" " beqz $a3, .Loptimized_memcpy_9" "\n"
1801 "\t" " nop" "\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"
1808 "\t" " nop" "\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"
1818 "\t" " nop" "\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"
1861 "\t" " nop" "\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"
1869 "\t" " nop" "\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"
1879 "\t" " nop" "\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"
1924 "\t" " nop" "\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"
1934 "\t" " jr $ra" "\n"
1935 "\t" " nop" "\n"
1936 "\t" ".set pop" "\n"
1937);
1938// 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:6865
u16 newflags
Definition loadcore.h:36