Sony PlayStation2 Study
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

982 lines
26 KiB

4 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /*
  2. # _____ ___ ____ ___ ____
  3. # ____| | ____| | | |____|
  4. # | ___| |____ ___| ____| | \ PS2DEV Open Source Project.
  5. #-----------------------------------------------------------------------
  6. # Copyright 2001-2004, 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. * @file
  12. * Common definitions for libcdvd on the EE and IOP
  13. */
  14. #ifndef __LIBCDVD_COMMON_H__
  15. #define __LIBCDVD_COMMON_H__
  16. #include <tamtypes.h>
  17. /* File open modes */
  18. /** Open file for streaming */
  19. #define SCE_CdSTREAM 0x40000000
  20. enum SCECdvdSectorType{
  21. /* Game CD and DVD sector types. */
  22. SCECdSecS2048=0,
  23. SCECdSecS2328,
  24. SCECdSecS2340,
  25. /* CDDA sector types. */
  26. SCECdSecS2352=0,
  27. SCECdSecS2368,
  28. SCECdSecS2448,
  29. };
  30. enum SCECdvdSpinValue{
  31. /** Spin at maximum speed */
  32. SCECdSpinMax=0,
  33. /** Spins at the recommended speed for streaming data */
  34. SCECdSpinStm=0,
  35. /** Spins at the DVD layer 0 speed */
  36. SCECdSpinDvdDL0=0,
  37. /** Optimized speed. Starts reading at max speed, slows down as read errors occur. */
  38. SCECdSpinNom=1,
  39. /** 1x. For CDDA reading. */
  40. SCECdSpinX1,
  41. //Note: These modes were taken from the PS2Linux libcdvd.h file, and they don't appear in any other Sony libcdvd.h file.
  42. /** 2x */
  43. SCECdSpinX2,
  44. /** 4x */
  45. SCECdSpinX4,
  46. /** 12x */
  47. SCECdSpinX12,
  48. /** Optimized speed, based on current speed. */
  49. SCECdSpinNm2=10,
  50. /** DVD x1.6 CLV */
  51. SCECdSpin1p6,
  52. /** Spin at maximum speed (Not sure what's the difference between this and SCECdSpinMax) */
  53. SCECdSpinMx=20,
  54. };
  55. enum SCECdvdMModeMediaType{
  56. SCECdMmodeCd=1,
  57. SCECdMmodeDvd
  58. };
  59. enum SCECdvdErrorCode{
  60. /** Can't get error code */
  61. SCECdErFAIL = -1,
  62. /** No Error */
  63. SCECdErNO = 0x00,
  64. /** Aborted */
  65. SCECdErABRT,
  66. /** Unsupported command */
  67. SCECdErCMD = 0x10,
  68. /** Tray is open */
  69. SCECdErOPENS,
  70. /** No disc inserted */
  71. SCECdErNODISC,
  72. /** Device not ready */
  73. SCECdErNORDY,
  74. /** Unsupported command for current disc */
  75. SCECdErCUD,
  76. /** Illegal position/LSN */
  77. SCECdErIPI = 0x20,
  78. /** Illegal length */
  79. SCECdErILI,
  80. /** Invalid parameter */
  81. SCECdErPRM,
  82. /** Read error */
  83. SCECdErREAD = 0x30,
  84. /** Tray was opened while reading */
  85. SCECdErTRMOPN,
  86. /** End Of Media */
  87. SCECdErEOM,
  88. SCECdErSFRMTNG = 0x38,
  89. /** Error setting command */
  90. SCECdErREADCF = 0xFD,
  91. /** Error setting command */
  92. SCECdErREADCFR
  93. };
  94. enum SCECdvdMediaType{
  95. SCECdGDTFUNCFAIL = -1,
  96. SCECdNODISC = 0x00,
  97. SCECdDETCT,
  98. SCECdDETCTCD,
  99. SCECdDETCTDVDS,
  100. SCECdDETCTDVDD,
  101. SCECdUNKNOWN,
  102. SCECdPSCD = 0x10,
  103. SCECdPSCDDA,
  104. SCECdPS2CD,
  105. SCECdPS2CDDA,
  106. SCECdPS2DVD,
  107. SCECdCDDA = 0xFD,
  108. SCECdDVDV,
  109. SCECdIllegalMedia
  110. };
  111. enum SCECdvdInterruptCode{
  112. /** No interrupt */
  113. CdlNoIntr = 0x00,
  114. /** Data Ready */
  115. CdlDataReady,
  116. /** Command Complete */
  117. SCECdComplete,
  118. /** Acknowledge (reserved) */
  119. CdlAcknowledge,
  120. /** End of Data Detected */
  121. CdlDataEnd,
  122. /** Error Detected */
  123. CdlDiskError,
  124. /** Drive Not Ready */
  125. SCECdNotReady
  126. };
  127. //Tray request modes
  128. enum SCECdvdTrayReqMode{
  129. SCECdTrayOpen=0,
  130. SCECdTrayClose,
  131. SCECdTrayCheck
  132. };
  133. //Drive states
  134. enum SCECdvdDriveState{
  135. SCECdStatStop = 0x00,
  136. SCECdStatShellOpen,
  137. SCECdStatSpin,
  138. SCECdStatRead = 0x06,
  139. SCECdStatPause = 0x0A,
  140. SCECdStatSeek = 0x12,
  141. SCECdStatEmg = 0x20,
  142. };
  143. typedef struct {
  144. u8 stat;
  145. u8 second;
  146. u8 minute;
  147. u8 hour;
  148. u8 pad;
  149. u8 day;
  150. u8 month;
  151. u8 year;
  152. } sceCdCLOCK;
  153. typedef struct {
  154. u32 lsn;
  155. u32 size;
  156. char name[16];
  157. u8 date[8];
  158. } sceCdlFILE;
  159. // location structure, used with sceCdIntToPos() and sceCdPosToInt()
  160. typedef struct {
  161. /** minute (BCD) */
  162. u8 minute;
  163. /** second (BCD) */
  164. u8 second;
  165. /** sector (BCD) */
  166. u8 sector;
  167. /** track (void), aka "frame" */
  168. u8 track;
  169. } sceCdlLOCCD;
  170. typedef struct {
  171. u8 trycount;
  172. u8 spindlctrl;
  173. u8 datapattern;
  174. u8 pad;
  175. } sceCdRMode;
  176. typedef struct {
  177. /** sector location to start reading from */
  178. u32 lbn;
  179. /** number of sectors to read */
  180. u32 sectors;
  181. /** buffer address to read to ( bit0: 0=EE, 1=IOP ) (EE addresses must be on 64-byte alignment) */
  182. u32 buffer;
  183. } sceCdRChain;
  184. // macros for converting between an integer and a BCD number
  185. #ifndef btoi
  186. #define btoi(b) ((b)/16*10 + (b)%16) // BCD to int
  187. #endif
  188. #ifndef itob
  189. #define itob(i) ((i)/10*16 + (i)%10) // int to BCD
  190. #endif
  191. /** max number of toc entries for sceCdGetToc() */
  192. #define CdlMAXTOC 100
  193. enum SCECdvdCallbackReason{
  194. SCECdFuncRead = 1,
  195. SCECdFuncReadCDDA,
  196. SCECdFuncGetToc,
  197. SCECdFuncSeek,
  198. SCECdFuncStandby,
  199. SCECdFuncStop,
  200. SCECdFuncPause,
  201. SCECdFuncBreak
  202. };
  203. /** sceCd callback function typedef for sceCdCallback() */
  204. typedef void (*sceCdCBFunc)(int reason);
  205. enum SCECdvdInitMode{
  206. /** Initializes library and waits until commands can be sent. */
  207. SCECdINIT = 0x00,
  208. /** Initialize only the library. */
  209. SCECdINoD,
  210. /** Deinitialize library. */
  211. SCECdEXIT = 0x05
  212. };
  213. // Low-level filesystem properties for sceCdSearchFile()
  214. /** Maximum number of files in a directory. */
  215. #define CdlMAXFILE 64
  216. /** Maximum number of total directories. */
  217. #define CdlMAXDIR 128
  218. /** Maximum levels of directories. */
  219. #define CdlMAXLEVEL 8
  220. // For streaming operations (Use with sceCdStRead())
  221. enum SCECdvdStreamMode{
  222. /** Stream without blocking. */
  223. STMNBLK = 0,
  224. /** Stream, but block. */
  225. STMBLK
  226. };
  227. // EE read modes (Used with sceCdSetEEReadMode()).
  228. #define SCECdNoCheckReady 0x00000001
  229. #define SCECdNoWriteBackDCache 0x00000002
  230. #ifdef __cplusplus
  231. extern "C" {
  232. #endif
  233. // **** N-Command Functions ****
  234. /** read data from disc
  235. * non-blocking, requires sceCdSync() call
  236. *
  237. * @param lbn sector location to start reading from
  238. * @param sectors number of sectors to read
  239. * @param buffer buffer to read to
  240. * @param mode mode to read as
  241. * @return 1 on success, 0 on failure.
  242. */
  243. int sceCdRead(u32 lbn, u32 sectors, void *buffer, sceCdRMode *mode);
  244. int sceCdReadDVDV(u32 lbn, u32 sectors, void *buffer, sceCdRMode *mode);
  245. int sceCdReadCDDA(u32 lbn, u32 sectors, void *buffer, sceCdRMode *mode);
  246. /** get toc from inserted disc
  247. *
  248. * @param toc buffer to hold toc (1024 bytes)
  249. * @return 1 on success, 0 on failure.
  250. */
  251. int sceCdGetToc(u8 *toc);
  252. /** Alternate TOC retrieving function with parameter
  253. *
  254. * @param toc buffer to hold toc (1024 bytes)
  255. * @param param Parameter
  256. * @return 1 on success, 0 on failure.
  257. */
  258. int sceCdGetToc2(u8 *toc, int param);
  259. /** seek to given sector on disc
  260. * non-blocking, requires sceCdSync() call
  261. *
  262. * @param lbn sector to seek to on disc
  263. * @return 1 on success, 0 on failure.
  264. */
  265. int sceCdSeek(u32 lbn);
  266. /** puts ps2 sceCd drive into standby mode
  267. * non-blocking, requires sceCdSync() call
  268. *
  269. * @return 1 on success, 0 on failure.
  270. */
  271. int sceCdStandby(void);
  272. /** stops ps2 sceCd drive from spinning
  273. * non-blocking, requires sceCdSync() call
  274. *
  275. * @return 1 on success, 0 on failure.
  276. */
  277. int sceCdStop(void);
  278. /** pauses ps2 sceCd drive
  279. * non-blocking, requires sceCdSync() call
  280. *
  281. * @return 1 on success, 0 on failure.
  282. */
  283. int sceCdPause(void);
  284. /** do a 'chain' of reads with one command
  285. * last chain value must be all 0xFFFFFFFF
  286. * (max of 64 reads can be set at once)
  287. * non-blocking, requires sceCdSync() call
  288. *
  289. * SUPPORTED IN XCDVDMAN/XCDVDFSV ONLY
  290. *
  291. * @param tag pointer to an array of read chain data
  292. * @param mode read mode
  293. * @return 1 on success, 0 on failure.
  294. */
  295. int sceCdReadChain(sceCdRChain *tag, sceCdRMode *mode);
  296. // **** S-Command functions ****
  297. /** Reads the PlayStation clock.
  298. * (time value is in BCD)
  299. *
  300. * NOTE: For the old CDVDMAN module, the month field will not have its most significant bit automatically filed off.
  301. *
  302. * @param clock time/date struct
  303. * @return 1 on success, 0 on failure.
  304. */
  305. int sceCdReadClock(sceCdCLOCK *clock);
  306. /** Sets the PlayStation 2 clock.
  307. * (time value is in BCD)
  308. *
  309. * @param clock time/date struct to set clocks time with
  310. * @return 1 on success, 0 on failure.
  311. */
  312. int sceCdWriteClock(const sceCdCLOCK *clock);
  313. /** gets the type of the currently inserted disc
  314. *
  315. * @return disk type (SCECdvdMediaTypes)
  316. */
  317. int sceCdGetDiskType(void);
  318. /** gets the last error that occurred
  319. *
  320. * @return error type (SCECdvdErrorCode)
  321. */
  322. int sceCdGetError(void);
  323. /** open/close/check disk tray
  324. *
  325. * @param param param (SCECdvdTrayReqMode)
  326. * @param traychk address for returning tray state change
  327. * @return 1 on success, 0 on failure.
  328. */
  329. int sceCdTrayReq(int param, u32 *traychk);
  330. /** gets the state of the drive
  331. *
  332. * @return status (SCECdvdDriveStates)
  333. */
  334. int sceCdStatus(void);
  335. /** 'breaks' the currently executing command
  336. *
  337. * @return 1 on success, 0 on failure.
  338. */
  339. int sceCdBreak(void);
  340. /** cancel power off
  341. *
  342. * SUPPORTED IN XCDVDMAN/XCDVDFSV ONLY
  343. *
  344. * @param result result
  345. * @return 1 on success, 0 on failure.
  346. */
  347. int sceCdCancelPOffRdy(u32* result);
  348. /** blue led control
  349. *
  350. * SUPPORTED IN XCDVDMAN/XCDVDFSV ONLY
  351. *
  352. * @param control control value
  353. * @param result result
  354. * @return 1 on success, 0 on failure.
  355. */
  356. int sceCdBlueLEDCtl(u8 control, u32 *result);
  357. /** power off
  358. *
  359. * SUPPORTED IN XCDVDMAN/XCDVDFSV ONLY
  360. *
  361. * @param result result
  362. * @return 1 on success, 0 on failure.
  363. */
  364. int sceCdPowerOff(u32 *result);
  365. /** set media mode
  366. *
  367. * SUPPORTED IN XCDVDMAN/XCDVDFSV ONLY
  368. *
  369. * @param media media mode (SCECdvdMModeMediaTypes)
  370. * @return 1 on success, 0 on failure.
  371. */
  372. int sceCdMmode(int media);
  373. /** change libcdvd thread priority
  374. *
  375. * SUPPORTED IN XCDVDMAN/XCDVDFSV ONLY
  376. *
  377. * @param priority priority
  378. * @return 1 on success, 0 on failure.
  379. */
  380. int sceCdChangeThreadPriority(int priority);
  381. // **** Streaming Functions ****
  382. /** start streaming data
  383. *
  384. * @param lbn sector location to start streaming from
  385. * @param mode mode to read in
  386. * @return 1 on success, 0 on failure.
  387. */
  388. int sceCdStStart(u32 lbn, sceCdRMode *mode);
  389. /** read stream data
  390. *
  391. * @param sectors number of sectors to read
  392. * @param buffer read buffer address
  393. * @param mode data stream mode (STMNBLK or STMBLK)
  394. * @param error error value holder
  395. * @return number of sectors read if successful, 0 otherwise
  396. */
  397. int sceCdStRead(u32 sectors, u32 *buffer, u32 mode, u32 *error);
  398. /** stop streaming
  399. *
  400. * @return 1 on success, 0 on failure.
  401. */
  402. int sceCdStStop(void);
  403. /** seek to a new stream position
  404. *
  405. * @param lbn sector location to start streaming from
  406. * @return 1 on success, 0 on failure.
  407. */
  408. int sceCdStSeek(u32 lbn);
  409. /** init streaming
  410. *
  411. * @param bufmax stream buffer size
  412. * @param bankmax number of ring buffers
  413. * @param buffer buffer address on iop
  414. * @return 1 on success, 0 on failure.
  415. */
  416. int sceCdStInit(u32 bufmax, u32 bankmax, void *buffer);
  417. /** get stream read status
  418. *
  419. * @return number of sectors read if successful, 0 otherwise
  420. */
  421. int sceCdStStat(void);
  422. /** pause streaming
  423. *
  424. * @return 1 on success, 0 on failure.
  425. */
  426. int sceCdStPause(void);
  427. /** continue streaming
  428. *
  429. * @return 1 on success, 0 on failure.
  430. */
  431. int sceCdStResume(void);
  432. // **** Other Functions ****
  433. /** initializes libcdvd
  434. *
  435. * @param mode mode (SCECdvdInitModes)
  436. * @return 1 on success, 0 on failure.
  437. */
  438. int sceCdInit(int mode);
  439. /** waits/checks for completion of n-commands
  440. *
  441. * @param mode 0 = wait for completion of command (blocking), 1 = check current status and return immediately
  442. * @return 0 = completed, 1 = not completed
  443. */
  444. int sceCdSync(int mode);
  445. /** search for a file on disc
  446. *
  447. * @param file file structure to get file info in
  448. * @param name name of file to search for (no wildcard characters) (should be in the form '\\SYSTEM.CNF;1')
  449. * @return 1 on success, 0 on failure. (or no file found)
  450. */
  451. int sceCdSearchFile(sceCdlFILE *file, const char *name);
  452. /** checks if drive is ready
  453. *
  454. * @param mode mode
  455. * @return SCECdComplete if ready, SCECdNotReady if busy
  456. */
  457. int sceCdDiskReady(int mode);
  458. /** convert from sector number to minute:second:frame */
  459. sceCdlLOCCD *sceCdIntToPos(u32 i, sceCdlLOCCD *p);
  460. /** convert from minute:second:frame to sector number */
  461. u32 sceCdPosToInt(sceCdlLOCCD *p);
  462. /** get the current read position (when reading using sceCdRead) */
  463. u32 sceCdGetReadPos(void);
  464. /** initialise EE callback thread
  465. *
  466. * @param priority callback thread priority
  467. * @param stackAddr callback thread stack address
  468. * @param stackSize callback thread stack size
  469. * @return 1 if initialised callback, 0 if only priority was changed
  470. */
  471. int sceCdInitEeCB(int priority, void *stackAddr, int stackSize);
  472. /** set sceCd callback function
  473. *
  474. * @param function pointer to new callback function
  475. * @return pointer to old function
  476. */
  477. sceCdCBFunc sceCdCallback(sceCdCBFunc function);
  478. /** Reads SUBQ data from the disc.
  479. //
  480. // @param buffer Pointer to the buffer for storing the SUBQ data in.
  481. // @param status Result code.
  482. // @return 1 on success, 0 on failure.
  483. */
  484. int sceCdReadSUBQ(void *buffer, u32 *status);
  485. // **** System functions ****
  486. /** Disables (Forbids) the DVD READ N-command, so that DVD video disc sectors cannot be read.
  487. * Support for the DVD READ N-command is re-enabled when a DVD player is loaded.
  488. *
  489. * @param result Result code.
  490. * @return 1 on success, 0 on failure.
  491. */
  492. int sceCdForbidDVDP(u32 *result);
  493. /** Controls automatic adjustment of the CD/DVD drive.
  494. * This also causes the auto-tilt motor (on units that have one) to be activated.
  495. *
  496. * @param mode Mode
  497. * @param result Result code.
  498. * @return 1 on success, 0 on failure.
  499. */
  500. int sceCdAutoAdjustCtrl(int mode, u32 *result);
  501. /** Controls on-the-fly (hardware) data decryption. Setting all options to 0 will disable decryption.
  502. * This is used for decrypting encrypted sectors like the PlayStation 2 logo.
  503. *
  504. * @param arg1 Unknown
  505. * @param arg2 Unknown
  506. * @param shift Shift amount
  507. * @return 1 on success, 0 on failure.
  508. */
  509. int sceCdDecSet(unsigned char arg1, unsigned char arg2, unsigned char shift);
  510. /** Reads the requested key from the CD/DVD.
  511. *
  512. * @param arg1 Unknown
  513. * @param arg2 Unknown
  514. * @param command Command
  515. * @param key Buffer to store the key in.
  516. * @return 1 on success, 0 on failure.
  517. */
  518. int sceCdReadKey(unsigned char arg1, unsigned char arg2, unsigned int command, unsigned char *key);
  519. /** Sets the "HD mode", whatever that means.
  520. *
  521. * @param mode mode
  522. * @return 1 on success, 0 on failure.
  523. */
  524. int sceCdSetHDMode(u32 mode);
  525. /** Opens a specified configuration block, within NVRAM. Each block is 15 bytes long.
  526. *
  527. * @param block Block number.
  528. * @param mode Mode (0 = read, 1 = write).
  529. * @param NumBlocks Number of blocks.
  530. * @param status Result code.
  531. * @return 1 on success, 0 on failure.
  532. */
  533. int sceCdOpenConfig(int block, int mode, int NumBlocks, u32 *status);
  534. /** Closes the configuration block.
  535. *
  536. * @param result Result code.
  537. * @return 1 on success, 0 on failure.
  538. */
  539. int sceCdCloseConfig(u32 *result);
  540. /** Reads the configuration block(s) that was/were previously opened. Each block is 15 bytes long.
  541. *
  542. * @param buffer Pointer to the buffer to store the configuration data in.
  543. * @param result Result code.
  544. * @return 1 on success, 0 on failure.
  545. */
  546. int sceCdReadConfig(void *buffer, u32 *result);
  547. /** Writes to the configuration block(s) that was/were previously opened. Each block is 15 bytes long.
  548. *
  549. * @param buffer Pointer to the buffer that contains the new configuration data.
  550. * @param result Result code.
  551. * @return 1 on success, 0 on failure.
  552. */
  553. int sceCdWriteConfig(const void *buffer, u32 *result);
  554. /** Reads a single word from the NVRAM storage.
  555. *
  556. * @param address Address in 2-byte words, of the word that will be read.
  557. * @param data Pointer to the buffer that will contain the data read.
  558. * @param result Result code.
  559. * @return 1 on success, 0 on failure.
  560. */
  561. int sceCdReadNVM(u32 address, u16 *data, u8 *result);
  562. /** Writes a single word to the NVRAM storage.
  563. * Does not fully work on consoles starting from the SCPH-50000 ("Dragon" MECHACON):
  564. * Some parts, like those containing the console IDs, cannot be overwritten.
  565. *
  566. * @param address Address in 2-byte words, of the word that will be written to.
  567. * @param data Pointer to the buffer that contains the new data.
  568. * @param result Result code.
  569. * @return 1 on success, 0 on failure.
  570. */
  571. int sceCdWriteNVM(u32 address, u16 data, u8 *result);
  572. /** Reads the i.Link ID of the console.
  573. * All consoles have an i.Link ID, including those that do not have a physical i.Link port.
  574. *
  575. * @param buffer Pointer to the buffer that will contain the data read.
  576. * @param result Result code.
  577. * @return 1 on success, 0 on failure.
  578. */
  579. int sceCdRI(u8 *buffer, u32 *result);
  580. /** Writes a new i.Link ID for the console.
  581. * Does not work on consoles starting from the SCPH-50000 ("Dragon" MECHACON):
  582. *
  583. * @param buffer Pointer to the buffer that contains the new i.Link ID.
  584. * @param result Result code.
  585. * @return 1 on success, 0 on failure.
  586. */
  587. int sceCdWI(const u8 *buffer, u32 *result);
  588. /** Reads the ID of the console. This is not the same as the i.Link ID.
  589. *
  590. * @param buffer Pointer to the buffer that will contain the data read.
  591. * @param result Result code.
  592. * @return 1 on success, 0 on failure.
  593. */
  594. int sceCdReadConsoleID(u8 *buffer, u32 *result);
  595. /** Writes a new ID for the console. This is not the same as the i.Link ID.
  596. * Does not work on consoles starting from the SCPH-50000 ("Dragon" MECHACON):
  597. *
  598. * @param buffer Pointer to the buffer that contains the new i.Link ID.
  599. * @param status Result code.
  600. * @return 1 on success, 0 on failure.
  601. */
  602. int sceCdWriteConsoleID(const u8 *buffer, u32 *status);
  603. /** Controls Audio Digital output.
  604. *
  605. * @param arg1 Unknown
  606. * @param status Result code.
  607. * @return 1 on success, 0 on failure.
  608. */
  609. int sceCdCtrlADout(int arg1, u32 *status);
  610. /** Reads MECHACON version data (RR MM mm TT): RR = Magicgate region, MM = major, mm = minor, TT = system type (00 = PS2, 01 = PSX)
  611. * Magicgate region codes are: 00 = Japan, 01 = USA, 02 = Europe, 03 = Oceania, 04 = Asia, 05 = Russia, 06 = China, and 07 = Mexico.
  612. *
  613. * NOTE: The old CDVDMAN module only returns MM mm TT instead. The region byte is made up of the lower 7 bits of the status/result code.
  614. *
  615. * @param buffer Pointer to the buffer to store the version data in.
  616. * @param status Result code.
  617. * @return 1 on success, 0 on failure.
  618. */
  619. int sceCdMV(u8 *buffer, u32 *status);
  620. /** Performs bootup certification.
  621. * SUPPORTED IN XCDVDMAN/XCDVDFSV ONLY
  622. *
  623. * @param romname ROM version - The ROM "name" of the console in this format:
  624. * romname[0] - ROM major version number (In decimal).
  625. * romname[1] - ROM minor version number (In decimal).
  626. * romname[2] - ROM region.
  627. * romname[3] - Console type (E.g. C, D or T).
  628. * @return 1 on success, 0 on failure.
  629. */
  630. int sceCdBootCertify(const u8 *romname);
  631. /** Reads the console's model "name": e.g. "SCPH-39000".
  632. * SUPPORTED IN XCDVDMAN/XCDVDFSV ONLY
  633. *
  634. * @param buffer Pointer to the buffer for storing the model name in.
  635. * @param status Result code.
  636. * @return 1 on success, 0 on failure.
  637. */
  638. int sceCdRM(char *buffer, u32 *status);
  639. /** Sets the console's model name.
  640. * Does not work on consoles starting from the SCPH-50000 ("Dragon" MECHACON).
  641. * SUPPORTED IN XCDVDMAN/XCDVDFSV ONLY
  642. *
  643. * @param buffer Pointer to a buffer containing the new model name.
  644. * @param status Result code.
  645. * @return 1 on success, 0 on failure.
  646. */
  647. int sceCdWM(const char *buffer, u32 *status);
  648. /** Disables (Forbids) the READ N-command, so that disc sectors cannot be read.
  649. * Support for the READ N-command is re-enabled when the disc is replaced.
  650. * SUPPORTED IN XCDVDMAN/XCDVDFSV ONLY
  651. *
  652. * @param result Result code.
  653. * @return 1 on success, 0 on failure.
  654. */
  655. int sceCdForbidRead(u32 *result);
  656. // **** Extra Functions ****
  657. /** Reads sectors to a buffer
  658. * SUPPORTED IN NEWER CDVDMAN MODULES INCLUDED WITHIN NEWER IOPRP ONLY
  659. *
  660. * @param lsn sector location to start from
  661. * @param sectors amount to sectors to read
  662. * @param buf pointer to a buffer
  663. * @param mode mode to read in
  664. * @return 1 on success, 0 on failure.
  665. */
  666. int sceCdReadFull(unsigned long int lsn, unsigned long int sectors, void *buf, sceCdRMode *mode);
  667. /** Seeks to a given position
  668. * SUPPORTED IN NEWER CDVDMAN MODULES INCLUDED WITHIN NEWER IOPRP ONLY
  669. *
  670. * @param lsn sector location to seek to
  671. * @return 1 on success, 0 on failure.
  672. */
  673. int sceCdStSeekF(unsigned long int lsn);
  674. /** Sets a handler for the power-off event which will be called before the console switches off.
  675. * SUPPORTED IN NEWER CDVDMAN MODULES INCLUDED WITHIN NEWER IOPRP ONLY
  676. *
  677. * @param func pointer of callback function to be called when power-off processing is activated
  678. * @param addr an argument which will be passed to the callback function
  679. * returns: a pointer to the previous handler function, or a null pointer if nothing has been set eariler
  680. */
  681. void *sceCdPOffCallback(void(*func)(void *),void *addr);
  682. /** Sets the timeout lengths for the certain CDVDMAN's operations.
  683. * SUPPORTED IN NEWER CDVDMAN MODULES INCLUDED WITHIN NEWER IOPRP ONLY
  684. *
  685. * @param param the timeout type to set
  686. * @param timeout a timeout value
  687. * @return 1 on success, 0 on failure.
  688. */
  689. int sceCdSetTimeout(int param, int timeout);
  690. /** Reads the Model ID.
  691. * SUPPORTED IN NEWER CDVDMAN MODULES INCLUDED WITHIN DNAS IOPRP ONLY
  692. *
  693. * @param id integer where the Model ID is stored.
  694. * @return 1 on success, 0 on failure.
  695. */
  696. int sceCdReadModelID(unsigned long int *id);
  697. /** Reads the information about DVD disk.
  698. * SUPPORTED IN NEWER CDVDMAN MODULES INCLUDED WITHIN NEWER IOPRP ONLY
  699. *
  700. * @param on_dual pointer to variable where type of DVD disc is returned
  701. * @param layer1_start pointer to variable where the address of the second layer of a dual-layer DVD disc is returned.
  702. * @return 1 on success, 0 on failure.
  703. */
  704. int sceCdReadDvdDualInfo(int *on_dual, unsigned long int *layer1_start);
  705. /** Retrieves basic information about a file on CD or the specified layer of DVD media.
  706. * SUPPORTED IN NEWER CDVDMAN MODULES INCLUDED WITHIN NEWER IOPRP ONLY
  707. *
  708. * @param fp file structure to get file info in
  709. * @param path name of file to search for (no wildcard characters) (should be in the form '\\SYSTEM.CNF;1')
  710. * @param layer layer to search (0 for the first layer, 1 for the second layer)
  711. * @return 1 on success, 0 on failure.
  712. */
  713. int sceCdLayerSearchFile(sceCdlFILE *fp, const char *path, int layer);
  714. /** Returns the CD/DVD drive status.
  715. * SUPPORTED IN NEWER CDVDMAN MODULES INCLUDED WITHIN NEWER IOPRP ONLY
  716. *
  717. * @return status
  718. */
  719. int sceCdStatus2(void);
  720. /** Reads sectors from CD or DVD disc.
  721. * SUPPORTED IN NEWER CDVDMAN MODULES INCLUDED WITHIN NEWER IOPRP ONLY
  722. *
  723. * @param lsn sector location to start from
  724. * @param sectors amount to sectors to read
  725. * @param buf pointer to a buffer
  726. * @param mode mode to read in
  727. * @return 1 on success, 0 on failure.
  728. */
  729. int sceCdRE(unsigned long int lsn,unsigned long int sectors,void *buf,sceCdRMode *mode);
  730. /** Reads a GUID.
  731. * SUPPORTED IN NEWER CDVDMAN MODULES INCLUDED WITHIN DNAS IOPRP ONLY
  732. *
  733. * @param guid u64 integer where the GUID is stored.
  734. * @return 1 on success, 0 on failure.
  735. */
  736. int sceCdReadGUID(u64 *guid);
  737. /** Controls remote-control bypass
  738. * SUPPORTED BY ONLY DESR/PSX DVR CDVDMAN MODULES
  739. *
  740. * @param mode 0 = Bypass, 1 = Normal
  741. * @param status Result code.
  742. * @return 1 on success, 0 on failure
  743. */
  744. int sceCdRcBypassCtl(int mode, u32 *status);
  745. /** Reads wake up time.
  746. * SUPPORTED IN XCDVDMAN INCLUDED WITHIN NEWER BOOT ROMS ONLY
  747. *
  748. * @return 1 on success, 0 on failure
  749. */
  750. int sceCdReadWakeUpTime(sceCdCLOCK *clock, u16 *arg2, u32 *arg3, int *arg4);
  751. /** Writes wake up time.
  752. * SUPPORTED IN XCDVDMAN INCLUDED WITHIN NEWER BOOT ROMS ONLY
  753. *
  754. * @return 1 on success, 0 on failure
  755. */
  756. int sceCdWriteWakeUpTime(const sceCdCLOCK *clock, u16 arg2, int arg3);
  757. /** Remote control 2_7.
  758. * SUPPORTED IN XCDVDMAN INCLUDED WITHIN NEWER BOOT ROMS ONLY
  759. *
  760. * @return 1 on success, 0 on failure
  761. */
  762. int sceRemote2_7(u16 a1, u32 *a2);
  763. /** Set LEDs mode.
  764. * SUPPORTED IN XCDVDMAN INCLUDED WITHIN NEWER BOOT ROMS ONLY
  765. *
  766. * @return 1 on success, 0 on failure
  767. */
  768. int sceCdSetLEDsMode(u32 arg1, u32 *result);
  769. /** Reads PS1 boot parameter.
  770. * SUPPORTED IN XCDVDMAN INCLUDED WITHIN NEWER BOOT ROMS ONLY
  771. *
  772. * @return 1 on success, 0 on failure
  773. */
  774. int sceCdReadPS1BootParam(u8 *out, u32 *result);
  775. /** Sets fan profile.
  776. * SUPPORTED IN XCDVDMAN INCLUDED WITHIN NEWER BOOT ROMS ONLY
  777. *
  778. * @return 1 on success, 0 on failure
  779. */
  780. int sceCdSetFanProfile(u8 arg1, u32 *result);
  781. /** Change sys.
  782. * SUPPORTED BY ONLY DESR/PSX DVR CDVDMAN MODULES
  783. *
  784. * @return 1 on success, 0 on failure
  785. */
  786. int sceCdChgSys(u32 arg1);
  787. /** Notice game start.
  788. * SUPPORTED BY ONLY DESR/PSX DVR CDVDMAN MODULES
  789. *
  790. * @return 1 on success, 0 on failure
  791. */
  792. int sceCdNoticeGameStart(u8 arg1, u32 *result);
  793. /** Extended LED control.
  794. * SUPPORTED BY ONLY DESR/PSX DVR CDVDMAN MODULES
  795. *
  796. * @return 1 on success, 0 on failure
  797. */
  798. int sceCdXLEDCtl(u8 arg1, u8 arg2, u32 *result1, u32 *result2);
  799. /** Buzzer control.
  800. * SUPPORTED BY ONLY DESR/PSX DVR CDVDMAN MODULES
  801. *
  802. * @return 1 on success, 0 on failure
  803. */
  804. int sceCdBuzzerCtl(u32 *result);
  805. /** XBS power control.
  806. * SUPPORTED BY ONLY DESR/PSX DVR CDVDMAN MODULES
  807. *
  808. * @return 1 on success, 0 on failure
  809. */
  810. int sceCdXBSPowerCtl(u8 arg1, u8 arg2, u32 *result1, u32 *result2);
  811. /** Set medium removal.
  812. * SUPPORTED BY ONLY DESR/PSX DVR CDVDMAN MODULES
  813. *
  814. * @return 1 on success, 0 on failure
  815. */
  816. int sceCdSetMediumRemoval(u8 arg1, u32 *result);
  817. /** Get medium removal.
  818. * SUPPORTED BY ONLY DESR/PSX DVR CDVDMAN MODULES
  819. *
  820. * @return 1 on success, 0 on failure
  821. */
  822. int sceCdGetMediumRemoval(u32 *result1, u32 *result2);
  823. /** XDVRP reset.
  824. * SUPPORTED BY ONLY DESR/PSX DVR CDVDMAN MODULES
  825. *
  826. * @return 1 on success, 0 on failure
  827. */
  828. int sceCdXDVRPReset(u8 arg1, u32 *result);
  829. /** Get wake up reason.
  830. * SUPPORTED BY ONLY DESR/PSX DVR CDVDMAN MODULES
  831. *
  832. * @return 1 on success, 0 on failure
  833. */
  834. int sceCdGetWakeUpReason(void);
  835. /** Reads region parameters.
  836. * SUPPORTED IN XCDVDMAN INCLUDED WITHIN NEWER BOOT ROMS ONLY
  837. *
  838. * @return 1 on success, 0 on failure
  839. */
  840. int sceCdReadRegionParams(u32 *arg1, u32 *result);
  841. /** Writes region parameters.
  842. * SUPPORTED IN XCDVDMAN INCLUDED WITHIN NEWER BOOT ROMS ONLY
  843. *
  844. * @return 1 on success, 0 on failure
  845. */
  846. int sceCdWriteRegionParams(u8 arg1, u32 *arg2, u8 *arg3, u32 *result);
  847. #ifdef __cplusplus
  848. }
  849. #endif
  850. #endif /* __LIBCDVD_COMMON_H__ */