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.

254 lines
7.5 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 HDD IOCTL, DEVCTL and IOCTL2 command definitions
  13. */
  14. #ifndef __HDD_IOCTL_H__
  15. #define __HDD_IOCTL_H__
  16. #include <tamtypes.h>
  17. ///////////////////////////////////////////////////////////////////////////////
  18. // DEV9.IRX
  19. #define DEV9_TYPE_PCMCIA 0
  20. #define DEV9_TYPE_EXPBAY 1
  21. #define DDIOC_MODEL 0x4401
  22. #define DDIOC_OFF 0x4402
  23. #define DDIOC_SETPIO3 0x4403
  24. #define DDIOC_LED2CTL 0x4404
  25. ///////////////////////////////////////////////////////////////////////////////
  26. // HDD.IRX
  27. // Partition format/types (as returned via the mode field for getstat/dread)
  28. #define APA_TYPE_FREE 0x0000
  29. /** Master Boot Record */
  30. #define APA_TYPE_MBR 0x0001
  31. #define APA_TYPE_EXT2SWAP 0x0082
  32. #define APA_TYPE_EXT2 0x0083
  33. #define APA_TYPE_REISER 0x0088
  34. #define APA_TYPE_PFS 0x0100
  35. #define APA_TYPE_CFS 0x0101
  36. #define APA_IDMAX 32
  37. /** Maximum # of sub-partitions */
  38. #define APA_MAXSUB 64
  39. #define APA_PASSMAX 8
  40. /** Sub-partition status for partitions (attr field) */
  41. #define APA_FLAG_SUB 0x0001
  42. //
  43. // IOCTL2 commands
  44. //
  45. #define HIOCADDSUB 0x6801
  46. #define HIOCDELSUB 0x6802
  47. #define HIOCNSUB 0x6803
  48. #define HIOCFLUSH 0x6804
  49. // Arbitrarily-named commands
  50. /** Used by PFS.IRX to read/write data */
  51. #define HIOCTRANSFER 0x6832
  52. /** For main(0)/subs(1+) */
  53. #define HIOCGETSIZE 0x6833
  54. /** Set (sector of a partition) that has an error */
  55. #define HIOCSETPARTERROR 0x6834
  56. /** Get (sector of a partition) that has an error */
  57. #define HIOCGETPARTERROR 0x6835
  58. // I/O direction
  59. #define APA_IO_MODE_READ 0x00
  60. #define APA_IO_MODE_WRITE 0x01
  61. // structs for IOCTL2 commands
  62. typedef struct
  63. {
  64. /** main(0)/subs(1+) to read/write */
  65. u32 sub;
  66. u32 sector;
  67. /** in sectors */
  68. u32 size;
  69. /** ATAD_MODE_READ/ATAD_MODE_WRITE..... */
  70. u32 mode;
  71. void *buffer;
  72. } hddIoctl2Transfer_t;
  73. //
  74. // DEVCTL commands
  75. //
  76. // 'H' set
  77. /** Maximum partition size (in sectors) */
  78. #define HDIOC_MAXSECTOR 0x4801
  79. /** Capacity of the disk (in sectors) */
  80. #define HDIOC_TOTALSECTOR 0x4802
  81. #define HDIOC_IDLE 0x4803
  82. #define HDIOC_FLUSH 0x4804
  83. #define HDIOC_SWAPTMP 0x4805
  84. #define HDIOC_DEV9OFF 0x4806
  85. #define HDIOC_STATUS 0x4807
  86. #define HDIOC_FORMATVER 0x4808
  87. #define HDIOC_SMARTSTAT 0x4809
  88. /** Returns the approximate amount of free space */
  89. #define HDIOC_FREESECTOR 0x480A
  90. #define HDIOC_IDLEIMM 0x480B
  91. // 'h' command set
  92. // Arbitrarily-named commands
  93. #define HDIOC_GETTIME 0x6832
  94. /** arg = hddSetOsdMBR_t */
  95. #define HDIOC_SETOSDMBR 0x6833
  96. #define HDIOC_GETSECTORERROR 0x6834
  97. /** bufp = namebuffer[0x20] */
  98. #define HDIOC_GETERRORPARTNAME 0x6835
  99. /** arg = hddAtaTransfer_t */
  100. #define HDIOC_READSECTOR 0x6836
  101. /** arg = hddAtaTransfer_t */
  102. #define HDIOC_WRITESECTOR 0x6837
  103. /** bufp = buffer for atadSceIdentifyDrive */
  104. #define HDIOC_SCEIDENTIFY 0x6838
  105. // Only available using dvr_hdd0:
  106. #define HDIOC_INSTSEC 0x6839
  107. /** arg = u32 */
  108. #define HDIOC_SETMAXLBA28 0x683A
  109. #define HDIOC_GETMAXLBA48 0x683B
  110. #define HDIOC_ISLBA48 0x683C
  111. #define HDIOC_PRESETMAXLBA28 0x683D
  112. #define HDIOC_POSTSETMAXLBA28 0x683E
  113. #define HDIOC_ENABLEWRITECACHE 0x683F
  114. #define HDIOC_DISABLEWRITECACHE 0x6840
  115. // structs for DEVCTL commands
  116. typedef struct
  117. {
  118. u32 lba;
  119. u32 size;
  120. u8 data[];
  121. } hddAtaTransfer_t;
  122. typedef struct
  123. {
  124. u32 start;
  125. u32 size;
  126. } hddSetOsdMBR_t;
  127. // For backward-compatibility
  128. // ioctl2 commands for ps2hdd.irx
  129. #define HDDIO_ADD_SUB HIOCADDSUB
  130. #define HDDIO_DELETE_END_SUB HIOCDELSUB
  131. #define HDDIO_NUMBER_OF_SUBS HIOCNSUB
  132. #define HDDIO_FLUSH_CACHE HIOCFLUSH
  133. #define HDDIO_GETSIZE HIOCGETSIZE
  134. #define APA_IOCTL2_ADD_SUB HIOCADDSUB
  135. #define APA_IOCTL2_DELETE_LAST_SUB HIOCDELSUB
  136. #define APA_IOCTL2_NUMBER_OF_SUBS HIOCNSUB
  137. #define APA_IOCTL2_FLUSH_CACHE HIOCFLUSH
  138. #define APA_IOCTL2_TRANSFER_DATA HIOCTRANSFER
  139. #define APA_IOCTL2_GETSIZE HIOCGETSIZE
  140. #define APA_IOCTL2_SET_PART_ERROR HIOCSETPARTERROR
  141. #define APA_IOCTL2_GET_PART_ERROR HIOCGETPARTERROR
  142. // devctl commands for ps2hdd.irx
  143. #define HDDCTL_MAX_SECTORS HDIOC_MAXSECTOR
  144. #define HDDCTL_TOTAL_SECTORS HDIOC_TOTALSECTOR
  145. #define HDDCTL_IDLE HDIOC_IDLE
  146. #define HDDCTL_FLUSH_CACHE HDIOC_FLUSH
  147. #define HDDCTL_SWAP_TMP HDIOC_SWAPTMP
  148. #define HDDCTL_DEV9_SHUTDOWN HDIOC_DEV9OFF
  149. #define HDDCTL_STATUS HDIOC_STATUS
  150. #define HDDCTL_FORMAT HDIOC_FORMATVER
  151. #define HDDCTL_SMART_STAT HDIOC_SMARTSTAT
  152. #define HDDCTL_FREE_SECTORS HDIOC_FREESECTOR
  153. #define APA_DEVCTL_MAX_SECTORS HDIOC_MAXSECTOR
  154. #define APA_DEVCTL_TOTAL_SECTORS HDIOC_TOTALSECTOR
  155. #define APA_DEVCTL_IDLE HDIOC_IDLE
  156. #define APA_DEVCTL_FLUSH_CACHE HDIOC_FLUSH
  157. #define APA_DEVCTL_SWAP_TMP HDIOC_SWAPTMP
  158. #define APA_DEVCTL_DEV9_SHUTDOWN HDIOC_DEV9OFF
  159. #define APA_DEVCTL_STATUS HDIOC_STATUS
  160. #define APA_DEVCTL_FORMAT HDIOC_FORMATVER
  161. #define APA_DEVCTL_SMART_STAT HDIOC_SMARTSTAT
  162. #define APA_DEVCTL_FREE_SECTORS HDIOC_FREESECTOR
  163. #define APA_DEVCTL_GETTIME HDIOC_GETTIME
  164. #define APA_DEVCTL_SET_OSDMBR HDIOC_SETOSDMBR
  165. #define APA_DEVCTL_GET_SECTOR_ERROR HDIOC_GETSECTORERROR
  166. #define APA_DEVCTL_GET_ERROR_PART_NAME HDIOC_GETERRORPARTNAME
  167. #define APA_DEVCTL_ATA_READ HDIOC_READSECTOR
  168. #define APA_DEVCTL_ATA_WRITE HDIOC_WRITESECTOR
  169. #define APA_DEVCTL_SCE_IDENTIFY_DRIVE HDIOC_SCEIDENTIFY
  170. ///////////////////////////////////////////////////////////////////////////////
  171. // PFS.IRX
  172. // IOCTL2 commands
  173. // Command set 'p'
  174. #define PIOCALLOC 0x7001
  175. #define PIOCFREE 0x7002
  176. #define PIOCATTRADD 0x7003
  177. #define PIOCATTRDEL 0x7004
  178. #define PIOCATTRLOOKUP 0x7005
  179. #define PIOCATTRREAD 0x7006
  180. #define PIOCINVINODE 0x7032 // Only available in OSD version. Arbitrarily named.
  181. // DEVCTL commands
  182. // Command set 'P'
  183. #define PDIOC_ZONESZ 0x5001
  184. #define PDIOC_ZONEFREE 0x5002
  185. #define PDIOC_CLOSEALL 0x5003
  186. #define PDIOC_GETFSCKSTAT 0x5004
  187. #define PDIOC_CLRFSCKSTAT 0x5005
  188. // Arbitrarily-named commands
  189. #define PDIOC_SHOWBITMAP 0xFF
  190. // I/O direction
  191. #define PFS_IO_MODE_READ 0x00
  192. #define PFS_IO_MODE_WRITE 0x01
  193. // For backward-compatibility
  194. // ioctl2 commands for ps2fs.irx
  195. #define PFSIO_ALLOC PIOCALLOC
  196. #define PFSIO_FREE PIOCFREE
  197. #define PFSIO_ATTR_ADD PIOCATTRADD
  198. #define PFSIO_ATTR_DEL PIOCATTRDEL
  199. #define PFSIO_ATTR_LOOKUP PIOCATTRLOOKUP
  200. #define PFSIO_ATTR_READ PIOCATTRREAD
  201. #define PFS_IOCTL2_ALLOC PIOCALLOC
  202. #define PFS_IOCTL2_FREE PIOCFREE
  203. #define PFS_IOCTL2_ATTR_ADD PIOCATTRADD
  204. #define PFS_IOCTL2_ATTR_DEL PIOCATTRDEL
  205. #define PFS_IOCTL2_ATTR_LOOKUP PIOCATTRLOOKUP
  206. #define PFS_IOCTL2_ATTR_READ PIOCATTRREAD
  207. // devctl commands for ps2fs.irx
  208. #define PFSCTL_GET_ZONE_SIZE PDIOC_ZONESZ
  209. #define PFSCTL_GET_ZONE_FREE PDIOC_ZONEFREE
  210. #define PFSCTL_CLOSE_ALL PDIOC_CLOSEALL
  211. #define PFSCTL_GET_STAT PDIOC_GETFSCKSTAT
  212. #define PFSCTL_CLEAR_STAT PDIOC_CLRFSCKSTAT
  213. #define PFS_DEVCTL_GET_ZONE_SIZE PDIOC_ZONESZ
  214. #define PFS_DEVCTL_GET_ZONE_FREE PDIOC_ZONEFREE
  215. #define PFS_DEVCTL_CLOSE_ALL PDIOC_CLOSEALL
  216. #define PFS_DEVCTL_GET_STAT PDIOC_GETFSCKSTAT
  217. #define PFS_DEVCTL_CLEAR_STAT PDIOC_CLRFSCKSTAT
  218. #define PFS_DEVCTL_SHOW_BITMAP PDIOC_SHOWBITMAP
  219. #endif /* __HDD_IOCTL_H__ */