1 1.8 christos /* $NetBSD: iwmreg.h,v 1.8 2007/03/04 06:00:09 christos Exp $ */ 2 1.1 scottr 3 1.1 scottr /* 4 1.3 scottr * Copyright (c) 1996-99 Hauke Fath. All rights reserved. 5 1.1 scottr * 6 1.1 scottr * Redistribution and use in source and binary forms, with or without 7 1.1 scottr * modification, are permitted provided that the following conditions 8 1.1 scottr * are met: 9 1.1 scottr * 1. Redistributions of source code must retain the above copyright 10 1.1 scottr * notice, this list of conditions and the following disclaimer. 11 1.1 scottr * 2. Redistributions in binary form must reproduce the above copyright 12 1.1 scottr * notice, this list of conditions and the following disclaimer in the 13 1.1 scottr * documentation and/or other materials provided with the distribution. 14 1.1 scottr * 3. The name of the author may not be used to endorse or promote products 15 1.1 scottr * derived from this software without specific prior written permission. 16 1.1 scottr * 17 1.1 scottr * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 18 1.1 scottr * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 19 1.1 scottr * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20 1.1 scottr * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 21 1.1 scottr * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 22 1.1 scottr * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 1.1 scottr * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 1.1 scottr * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 1.1 scottr * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 1.1 scottr * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 1.1 scottr */ 28 1.1 scottr #ifndef _MAC68K_IWMREG_H 29 1.1 scottr #define _MAC68K_IWMREG_H 30 1.1 scottr 31 1.1 scottr /* 32 1.1 scottr * iwmreg.h -- Interface declarations for iwm. 33 1.1 scottr */ 34 1.1 scottr 35 1.3 scottr #ifndef _LOCORE 36 1.3 scottr 37 1.1 scottr /* 38 1.1 scottr * Configuration 39 1.1 scottr */ 40 1.1 scottr 41 1.1 scottr /* Virtual Drive flags register */ 42 1.3 scottr enum { 43 1.1 scottr IWM_DS_DISK = 0x01, 44 1.1 scottr IWM_NO_DISK = 0x02, 45 1.1 scottr IWM_MOTOR_OFF = 0x04, 46 1.4 wiz IWM_WRITABLE = 0x08, 47 1.1 scottr IWM_DD_DISK = 0x10, 48 1.1 scottr IWM_NO_DRIVE = 0x80000000 49 1.1 scottr }; 50 1.1 scottr 51 1.1 scottr /* 52 1.1 scottr * Access 53 1.1 scottr */ 54 1.3 scottr enum { 55 1.3 scottr noErr = 0, /* All went well */ 56 1.1 scottr noDriveErr = -64, /* Drive not installed */ 57 1.1 scottr offLinErr = -65, /* R/W requested for an offline drive */ 58 1.1 scottr noNybErr = -66, /* Disk is probably blank */ 59 1.1 scottr noAdrMkErr = -67, /* Can't find an address mark */ 60 1.1 scottr dataVerErr = -68, /* Read verify compare failed */ 61 1.1 scottr badCkSmErr = -69, /* Bad address mark checksum */ 62 1.1 scottr badBtSlpErr = -70, /* Bad address mark (no lead-out) */ 63 1.1 scottr noDtaMkErr = -71, /* Could not find a data mark */ 64 1.1 scottr badDCkSum = -72, /* Bad data mark checksum */ 65 1.1 scottr badDBtSlp = -73, /* One of the data mark bit slip */ 66 1.1 scottr /* nibbles was incorrect. */ 67 1.1 scottr wrUnderRun = -74, /* Could not write fast enough to */ 68 1.1 scottr /* keep up with the IWM */ 69 1.1 scottr cantStepErr = -75, /* Step handshake failed during seek */ 70 1.1 scottr tk0BadErr = -76, /* Track 00 sensor does not change */ 71 1.1 scottr /* during head calibration */ 72 1.1 scottr initIWMErr = -77, /* Unable to initialize IWM */ 73 1.1 scottr twoSideErr = -78, /* Tried to access a double-sided disk */ 74 1.1 scottr /* on a single-sided drive (400K drive) */ 75 1.1 scottr spAdjErr = -79, /* Can't adjust drive speed (400K drive) */ 76 1.1 scottr seekErr = -80, /* Wrong track number read in a sector's */ 77 1.1 scottr /* address field */ 78 1.1 scottr sectNFErr = -81, /* Sector number never found on a track */ 79 1.1 scottr fmt1Err = -82, /* Can't find sector 0 after track format */ 80 1.1 scottr fmt2Err = -83, /* Can't get enough sync */ 81 1.1 scottr verErr = -84 /* Track failed to verify */ 82 1.1 scottr }; 83 1.1 scottr 84 1.3 scottr #define IWM_TAG_SIZE 20 /* That's what "SonyEqu.a" says */ 85 1.3 scottr 86 1.3 scottr 87 1.3 scottr /* Buffer for sector header data */ 88 1.1 scottr struct sectorHdr { 89 1.1 scottr u_int8_t side; 90 1.1 scottr u_int8_t track; 91 1.1 scottr u_int8_t sector; 92 1.3 scottr u_int8_t Tags[IWM_TAG_SIZE]; 93 1.1 scottr }; 94 1.1 scottr typedef struct sectorHdr sectorHdr_t; 95 1.3 scottr 96 1.3 scottr /* 97 1.3 scottr * Cylinder cache data structure 98 1.3 scottr * Cyl buffer is allocated in fdopen() and deallocated in fdclose(). 99 1.3 scottr * 100 1.3 scottr * The "valid" flag is overloaded as "dirty" flag when writing 101 1.3 scottr * to disk. 102 1.3 scottr */ 103 1.3 scottr struct cylCacheSlot { 104 1.3 scottr unsigned char *secbuf; /* ptr to one sector buffer */ 105 1.3 scottr int32_t valid; /* content valid for cur. cylinder? */ 106 1.3 scottr }; 107 1.3 scottr typedef struct cylCacheSlot cylCacheSlot_t; 108 1.3 scottr 109 1.3 scottr 110 1.3 scottr #else /* _LOCORE */ 111 1.3 scottr 112 1.3 scottr 113 1.3 scottr /* 114 1.3 scottr * Assembler equates for IWM, kept here to ensure consistency. 115 1.3 scottr * Modelled after <sys/disklabel.h> 116 1.3 scottr */ 117 1.3 scottr 118 1.3 scottr /* 119 1.3 scottr * Offsets into data structures 120 1.3 scottr */ 121 1.3 scottr /* sectorHdr_t */ 122 1.3 scottr .equ o_side, 0 123 1.3 scottr .equ o_track, 1 124 1.3 scottr .equ o_sector, 2 125 1.3 scottr .equ o_Tags, 3 126 1.3 scottr 127 1.3 scottr /* cylCacheSlot_t */ 128 1.3 scottr .equ o_secbuf, 0 129 1.3 scottr .equ o_valid, 4 130 1.3 scottr 131 1.3 scottr /* 132 1.3 scottr * Parameter (a6) offsets from <mac68k/obio/iwm_fdvar.h> 133 1.3 scottr * 134 1.8 christos * int iwmReadSector(sectorHdr_t *hdr, cylCacheSlot_t *r_slots, void *buf) 135 1.5 chs * int iwmWriteSector(sectorHdr_t *hdr, cylCacheSlot_t *w_slots) 136 1.3 scottr */ 137 1.3 scottr .equ o_hdr, 8 138 1.3 scottr .equ o_rslots, 12 139 1.3 scottr .equ o_wslots, 12 140 1.3 scottr .equ o_buf, 16 141 1.3 scottr 142 1.3 scottr /* 143 1.3 scottr * Offsets from IWM base address 144 1.3 scottr * Lines are set by any memory access to corresponding address (IM III-34/-44). 145 1.3 scottr * The SWIM has actual registers at these addresses, so writing to them 146 1.3 scottr * in IWM mode is a no-no. 147 1.3 scottr */ 148 1.3 scottr .equ ph0L, 0x0000 /* CA0 off (0) */ 149 1.3 scottr .equ ph0H, 0x0200 /* CA0 on (1) */ 150 1.3 scottr .equ ph1L, 0x0400 /* CA1 off (0) */ 151 1.3 scottr .equ ph1H, 0x0600 /* CA1 on (1) */ 152 1.3 scottr .equ ph2L, 0x0800 /* CA2 off (0) */ 153 1.3 scottr .equ ph2H, 0x0A00 /* CA2 on (1) */ 154 1.3 scottr .equ ph3L, 0x0C00 /* LSTRB off (low) */ 155 1.3 scottr .equ ph3H, 0x0E00 /* LSTRB on (high) */ 156 1.3 scottr .equ mtrOff, 0x1000 /* disk enable off */ 157 1.3 scottr .equ mtrOn, 0x1200 /* disk enable on */ 158 1.3 scottr .equ intDrive, 0x1400 /* select internal drive */ 159 1.3 scottr .equ extDrive, 0x1600 /* select external drive */ 160 1.3 scottr .equ q6L, 0x1800 /* Q6 off */ 161 1.3 scottr .equ q6H, 0x1A00 /* Q6 on */ 162 1.3 scottr .equ q7L, 0x1C00 /* Q7 off */ 163 1.3 scottr .equ q7H, 0x1E00 /* Q7 on */ 164 1.3 scottr 165 1.3 scottr 166 1.3 scottr /* 167 1.3 scottr * VIA Disk SEL line 168 1.3 scottr */ 169 1.3 scottr .equ vBufA, 0x1E00 /* Offset from vBase to register A */ 170 1.3 scottr /* (IM III-43) */ 171 1.3 scottr .equ vHeadSel, 5 /* Multi-purpose line (SEL) */ 172 1.3 scottr .equ vHeadSelMask, 0x0020 /* Corresponding bit mask */ 173 1.3 scottr 174 1.3 scottr 175 1.3 scottr /* 176 1.3 scottr * Disk registers 177 1.3 scottr * bit 0 - CA2, bit 1 - SEL, bit 2 - CA0, bit 3 - CA1 IM III name 178 1.3 scottr */ 179 1.3 scottr 180 1.3 scottr /* Status */ 181 1.3 scottr .equ stepDirection, 0x0000 /* Direction of next head step */ 182 1.3 scottr /* 0 = in, 1 = out (DIRTN) */ 183 1.3 scottr .equ rdDataFrom0, 0x0001 /* Set up drive to read data from */ 184 1.3 scottr /* head 0 (RDDATA0) */ 185 1.3 scottr .equ diskInserted, 0x0002 /* Disk inserted */ 186 1.3 scottr /* 0 = yes, 1 = no (CSTIN) */ 187 1.3 scottr .equ rdDataFrom1, 0x0003 /* Set up drive to read data from */ 188 1.3 scottr /* head 1 (RDDATA1) */ 189 1.3 scottr .equ stillStepping, 0x0004 /* Drive is still stepping */ 190 1.3 scottr /* 0 = yes, 1 = no (STEP) */ 191 1.3 scottr .equ writeProtected, 0x0006 /* Disk is locked */ 192 1.3 scottr /* 0 = yes, 1 = no (WRTPRT) */ 193 1.3 scottr .equ drvMotorState, 0x0008 /* Drive motor is on */ 194 1.3 scottr /* 0 = yes, 1 = no (MOTORON) */ 195 1.3 scottr .equ singleSided, 0x0009 /* Drive is single-sided */ 196 1.3 scottr /* 0 = yes, 1 = no (SIDES) */ 197 1.3 scottr .equ atTrack00, 0x000A /* Head is at track 00 */ 198 1.3 scottr /* 0 = yes, 1 = no (TK0) */ 199 1.3 scottr .equ headLoaded, 0x000B /* Head loaded, drive is ready */ 200 1.3 scottr /* 0 = yes, 1 = no () */ 201 1.3 scottr .equ drvInstalled, 0x000D /* Disk drive installed */ 202 1.3 scottr /* 0 = yes, 1 = no () */ 203 1.3 scottr .equ tachPulse, 0x000E /* Tachometer pulse (60 /rev.) */ 204 1.3 scottr /* 0 = yes, 1 = no (TACH) */ 205 1.3 scottr .equ diskIsHD, 0x000F /* HD disk detected */ 206 1.3 scottr /* 0 = yes, 1 = no (DRVIN) */ 207 1.3 scottr 208 1.3 scottr /* Commands */ 209 1.3 scottr .equ stepInCmd, 0x0000 /* Head step direction in (DIRTN) */ 210 1.3 scottr .equ stepOutCmd, 0x0001 /* Head step direction out (DIRTN+1) */ 211 1.3 scottr .equ doStepCmd, 0x0004 /* Step head (STEP) */ 212 1.3 scottr .equ motorOnCmd, 0x0008 /* Switch drive motor on (MOTORON) */ 213 1.3 scottr .equ motorOffCmd, 0x0009 /* Switch drive motor off (MOTOROFF) */ 214 1.3 scottr .equ ejectDiskCmd, 0x000D /* Eject disk from drive (EJECT) */ 215 1.3 scottr 216 1.3 scottr 217 1.3 scottr /* 218 1.3 scottr * Low level disk errors 219 1.3 scottr * For simplicity, they are given the MacOS names and numbers. 220 1.3 scottr */ 221 1.3 scottr .equ noErr, 0 /* All went well */ 222 1.3 scottr .equ noDriveErr, -64 /* Drive not installed */ 223 1.3 scottr .equ offLinErr, -65 /* R/W requested for an offline drive */ 224 1.3 scottr .equ noNybErr, -66 /* Disk is probably blank */ 225 1.3 scottr .equ noAdrMkErr, -67 /* Can't find an address mark */ 226 1.3 scottr .equ dataVerErr, -68 /* Read verify compare failed */ 227 1.3 scottr .equ badCkSmErr, -69 /* Bad address mark checksum */ 228 1.3 scottr .equ badBtSlpErr, -70 /* Bad address mark (no lead-out) */ 229 1.3 scottr .equ noDtaMkErr, -71 /* Could not find a data mark */ 230 1.3 scottr .equ badDCkSum, -72 /* Bad data mark checksum */ 231 1.3 scottr .equ badDBtSlp, -73 /* One of the data mark bit slip */ 232 1.3 scottr /* nibbles was incorrect. */ 233 1.3 scottr .equ wrUnderRun, -74 /* Could not write fast enough to */ 234 1.3 scottr /* keep up with the IWM */ 235 1.3 scottr .equ cantStepErr, -75 /* Step handshake failed during seek */ 236 1.3 scottr .equ tk0BadErr, -76 /* Track 00 sensor does not change */ 237 1.3 scottr /* during head calibration */ 238 1.3 scottr .equ initIWMErr, -77 /* Unable to initialize IWM */ 239 1.3 scottr .equ twoSideErr, -78 /* Tried to access a double-sided disk */ 240 1.3 scottr /* on a single-sided drive (400K drive) */ 241 1.3 scottr .equ spAdjErr, -79 /* Can't adjust drive speed (400K drive) */ 242 1.3 scottr .equ seekErr, -80 /* Wrong track number read in a */ 243 1.3 scottr /* sector's address field */ 244 1.3 scottr .equ sectNFErr, -81 /* Sector number never found on a track */ 245 1.3 scottr .equ fmt1Err, -82 /* Can't find sector 0 after */ 246 1.3 scottr /* track format */ 247 1.3 scottr .equ fmt2Err, -83 /* Can't get enough sync */ 248 1.3 scottr .equ verErr, -84 /* Track failed to verify */ 249 1.3 scottr 250 1.3 scottr /* 251 1.3 scottr * Misc constants 252 1.3 scottr */ 253 1.3 scottr .equ iwmMode, 0x17 /* SWIM switch */ 254 1.3 scottr .equ maxGCRSectors, 12 /* Max. sectors per track for GCR */ 255 1.3 scottr 256 1.3 scottr 257 1.3 scottr #endif /* _LOCORE */ 258 1.1 scottr 259 1.1 scottr #endif /* _MAC68K_IWMREG_H */ 260