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