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