swim_iop.h
上传用户:jlfgdled
上传日期:2013-04-10
资源大小:33168k
文件大小:7k
源码类别:

Linux/Unix编程

开发平台:

Unix_Linux

  1. /*
  2.  * SWIM access through the IOP
  3.  * Written by Joshua M. Thompson
  4.  */
  5. /* IOP number and channel number for the SWIM */
  6. #define SWIM_IOP IOP_NUM_ISM
  7. #define SWIM_CHAN 1
  8. /* Command code: */
  9. #define CMD_INIT 0x01 /* Initialize                  */
  10. #define CMD_SHUTDOWN 0x02 /* Shutdown                    */
  11. #define CMD_START_POLL 0x03 /* Start insert/eject polling  */
  12. #define CMD_STOP_POLL 0x04 /* Stop insert/eject polling   */
  13. #define CMD_SETHFSTAG 0x05 /* Set HFS tag buffer address  */
  14. #define CMD_STATUS 0x06 /* Status                      */
  15. #define CMD_EJECT 0x07 /* Eject                       */
  16. #define CMD_FORMAT 0x08 /* Format                      */
  17. #define CMD_FORMAT_VERIFY 0x09 /* Format and Verify           */
  18. #define CMD_WRITE 0x0A /* Write                       */
  19. #define CMD_READ 0x0B /* Read                        */
  20. #define CMD_READ_VERIFY 0x0C /* Read and Verify             */
  21. #define CMD_CACHE_CTRL 0x0D /* Cache control               */
  22. #define CMD_TAGBUFF_CTRL 0x0E /* Tag buffer control          */
  23. #define CMD_GET_ICON 0x0F /* Get Icon                    */
  24. /* Drive types: */
  25. /* note: apple sez DRV_FDHD is 4, but I get back a type */
  26. /*       of 5 when I do a drive status check on my FDHD */
  27. #define DRV_NONE 0 /* No drive             */
  28. #define DRV_UNKNOWN 1 /* Unspecified drive    */
  29. #define DRV_400K 2 /* 400K                 */
  30. #define DRV_800K 3 /* 400K/800K            */
  31. #define DRV_FDHD 5 /* 400K/800K/720K/1440K */
  32. #define DRV_HD20 7 /* Apple HD20           */
  33. /* Format types: */
  34. #define FMT_HD20 0x0001 /*  Apple HD20 */
  35. #define FMT_400K 0x0002 /*  400K (GCR) */
  36. #define FMT_800K 0x0004 /*  800K (GCR) */
  37. #define FMT_720K 0x0008 /*  720K (MFM) */
  38. #define FMT_1440K 0x0010 /* 1.44M (MFM) */
  39. #define FMD_KIND_400K 1
  40. #define FMD_KIND_800K 2
  41. #define FMD_KIND_720K 3
  42. #define FMD_KIND_1440K 1
  43. /* Icon Flags: */
  44. #define ICON_MEDIA 0x01 /* Have IOP supply media icon */
  45. #define ICON_DRIVE 0x01 /* Have IOP supply drive icon */
  46. /* Error codes: */
  47. #define gcrOnMFMErr -400 /* GCR (400/800K) on HD media */
  48. #define verErr -84 /* verify failed */
  49. #define fmt2Err -83 /* cant get enough sync during format */
  50. #define fmt1Err -82 /* can't find sector 0 after track format */
  51. #define sectNFErr -81 /* can't find sector */
  52. #define seekErr -80 /* drive error during seek */
  53. #define spdAdjErr -79 /* can't set drive speed */
  54. #define twoSideErr -78 /* drive is single-sided */
  55. #define initIWMErr -77 /* error during initialization */
  56. #define tk0badErr -76 /* track zero is bad */
  57. #define cantStepErr -75 /* drive error during step */
  58. #define wrUnderrun -74 /* write underrun occurred */
  59. #define badDBtSlp -73 /* bad data bitslip marks */
  60. #define badDCksum -72 /* bad data checksum */
  61. #define noDtaMkErr -71 /* can't find data mark */
  62. #define badBtSlpErr -70 /* bad address bitslip marks */
  63. #define badCksmErr -69 /* bad address-mark checksum */
  64. #define dataVerErr -68 /* read-verify failed */
  65. #define noAdrMkErr -67 /* can't find an address mark */
  66. #define noNybErr -66 /* no nybbles? disk is probably degaussed */
  67. #define offLinErr -65 /* no disk in drive */
  68. #define noDriveErr -64 /* drive isn't connected */
  69. #define nsDrvErr -56 /* no such drive */
  70. #define paramErr -50 /* bad positioning information */
  71. #define wPrErr -44 /* write protected */
  72. #define openErr -23 /* already initialized */
  73. #ifndef __ASSEMBLY__
  74. struct swim_drvstatus {
  75. __u16 curr_track; /* Current track number                   */
  76. __u8 write_prot; /* 0x80 if disk is write protected        */
  77. __u8 disk_in_drive; /* 0x01 or 0x02 if a disk is in the drive */
  78. __u8 installed; /* 0x01 if drive installed, 0xFF if not   */
  79. __u8 num_sides; /* 0x80 if two-sided format supported     */
  80. __u8 two_sided; /* 0xff if two-sided format diskette      */
  81. __u8 new_interface; /* 0x00 if old 400K drive, 0xFF if newer  */
  82. __u16 errors; /* Disk error count                       */
  83. struct { /* 32 bits */
  84. __u16 reserved;
  85. __u16 :4;
  86. __u16 external:1; /* Drive is external        */
  87. __u16 scsi:1; /* Drive is a SCSI drive    */
  88. __u16 fixed:1; /* Drive has fixed media    */
  89. __u16 secondary:1; /* Drive is secondary drive */
  90. __u8 type; /* Drive type               */
  91. } info;
  92. __u8 mfm_drive; /* 0xFF if this is an FDHD drive    */
  93. __u8 mfm_disk; /* 0xFF if 720K/1440K (MFM) disk    */
  94. __u8 mfm_format; /* 0x00 if 720K, 0xFF if 1440K      */
  95. __u8 ctlr_type; /* 0x00 if IWM, 0xFF if SWIM        */
  96. __u16 curr_format; /* Current format type              */
  97. __u16 allowed_fmt; /* Allowed format types             */
  98. __u32 num_blocks; /* Number of blocks on disk         */
  99. __u8 icon_flags; /* Icon flags                       */
  100. __u8 unusued;
  101. };
  102. /* Commands issued from the host to the IOP: */
  103. struct swimcmd_init {
  104. __u8 code; /* CMD_INIT */
  105. __u8 unusued;
  106. __u16 error;
  107. __u8 drives[28]; /* drive type list */
  108. };
  109. struct swimcmd_startpoll {
  110. __u8 code; /* CMD_START_POLL */
  111. __u8 unusued;
  112. __u16 error;
  113. };
  114. struct swimcmd_sethfstag {
  115. __u8 code; /* CMD_SETHFSTAG */
  116. __u8 unusued;
  117. __u16 error;
  118. caddr_t tagbuf; /* HFS tag buffer address */
  119. };
  120. struct swimcmd_status {
  121. __u8 code; /* CMD_STATUS */
  122. __u8 drive_num;
  123. __u16 error;
  124. struct swim_drvstatus status;
  125. };
  126. struct swimcmd_eject {
  127. __u8 code; /* CMD_EJECT */
  128. __u8 drive_num;
  129. __u16 error;
  130. struct swim_drvstatus status;
  131. };
  132. struct swimcmd_format {
  133. __u8 code; /* CMD_FORMAT */
  134. __u8 drive_num;
  135. __u16 error;
  136. union {
  137. struct {
  138. __u16 fmt;    /* format kind                  */
  139. __u8  hdrbyte;    /* fmt byte for hdr (0=default) */
  140. __u8  interleave;  /* interleave (0 = default)     */
  141. caddr_t databuf;   /* sector data buff (0=default  */
  142. caddr_t tagbuf;    /* tag data buffer (0=default)  */
  143. } f;
  144. struct swim_drvstatus status;
  145. } p;
  146. };
  147. struct swimcmd_fmtverify {
  148. __u8 code; /* CMD_FORMAT_VERIFY */
  149. __u8 drive_num;
  150. __u16 error;
  151. };
  152. struct swimcmd_rw {
  153. __u8 code; /* CMD_READ, CMD_WRITE or CMD_READ_VERIFY */
  154. __u8 drive_num;
  155. __u16 error;
  156. caddr_t buffer; /* R/W buffer address */
  157. __u32 first_block; /* Starting block     */
  158. __u32 num_blocks; /* Number of blocks   */
  159. __u8 tag[12]; /* tag data           */
  160. };
  161. struct swimcmd_cachectl {
  162. __u8 code; /* CMD_CACHE_CTRL */
  163. __u8 unused;
  164. __u16 error;
  165. __u8 enable; /* Nonzero to enable cache                */
  166. __u8 install; /* +1 = install, -1 = remove, 0 = neither */
  167. };
  168. struct swimcmd_tagbufctl {
  169. __u8 code; /* CMD_TAGBUFF_CTRL */
  170. __u8 unused;
  171. __u16 error;
  172. caddr_t buf; /* buffer address or 0 to disable */
  173. };
  174. struct swimcmd_geticon {
  175. __u8 code; /* CMD_GET_ICON */
  176. __u8 drive_num;
  177. __u16 error;
  178. caddr_t buffer; /* Nuffer address */
  179. __u16 kind; /* 0 = media icon, 1 = drive icon */
  180. __u16 unused;
  181. __u16 max_bytes; /* maximum  byte count */
  182. };
  183. /* Messages from the SWIM IOP to the host CPU: */
  184. struct swimmsg_status {
  185. __u8 code; /* 1 = insert, 2 = eject, 3 = status changed */
  186. __u8 drive_num;
  187. __u16 error;
  188. struct swim_drvstatus status;
  189. };
  190. #endif /* __ASSEMBLY__ */