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