Home | History | Annotate | Line # | Download | only in obio
iwm_fdvar.h revision 1.2.2.1
      1  1.2.2.1  scottr /*	$NetBSD: iwm_fdvar.h,v 1.2.2.1 1999/05/16 22:38:13 scottr Exp $	*/
      2      1.1  scottr 
      3      1.1  scottr /*
      4      1.1  scottr  * Copyright (c) 1997, 1998 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_FDVAR_H
     29      1.1  scottr #define _MAC68K_FDVAR_H
     30      1.1  scottr 
     31      1.1  scottr /**
     32      1.1  scottr  **	Constants
     33      1.1  scottr  **/
     34      1.1  scottr 
     35  1.2.2.1  scottr enum {
     36  1.2.2.1  scottr 	IWM_MAX_DRIVE = 2,		/* Attachable drives */
     37  1.2.2.1  scottr 	IWM_GCR_DISK_ZONES = 5,		/* Zones on GCR disk */
     38  1.2.2.1  scottr 	IWM_MAX_GCR_SECTORS = 12,	/* Max. sectors per GCR track */
     39  1.2.2.1  scottr 	IWM_MAX_FLOPPY_SECT = 50,	/* Larger than the highest sector */
     40  1.2.2.1  scottr 					/* number likely to occur */
     41  1.2.2.1  scottr };
     42      1.1  scottr 
     43      1.1  scottr 
     44      1.1  scottr /* Physical track format codes */
     45      1.1  scottr enum {
     46  1.2.2.1  scottr 	IWM_GCR,		/* Apple's Group Code Recording format */
     47  1.2.2.1  scottr 	IWM_MFM_DD,		/* Standard MFM on DD disk (250 KBit/s)	*/
     48  1.2.2.1  scottr 	IWM_MFM_HD		/* Standard MFM on HD disk (500 KBit/s)	*/
     49      1.1  scottr };
     50      1.1  scottr 
     51      1.1  scottr /* Drive softc flags */
     52      1.1  scottr enum {
     53      1.1  scottr 	IWM_FD_IS_OPEN	= 0x00000001,
     54      1.1  scottr 	IWM_FD_MOTOR_ON = 0x00000002
     55      1.1  scottr };
     56      1.1  scottr 
     57      1.1  scottr /* seek() behaviour */
     58      1.1  scottr enum {
     59      1.1  scottr 	IWM_SEEK_VANILLA,
     60      1.1  scottr 	IWM_SEEK_RECAL,
     61      1.1  scottr 	IWM_SEEK_VERIFY
     62      1.1  scottr };
     63      1.1  scottr 
     64  1.2.2.1  scottr /* I/O direction */
     65  1.2.2.1  scottr enum {
     66  1.2.2.1  scottr 	IWM_WRITE = 0,
     67  1.2.2.1  scottr 	IWM_READ
     68  1.2.2.1  scottr };
     69  1.2.2.1  scottr 
     70      1.1  scottr 
     71      1.1  scottr /**
     72      1.1  scottr  **	Data Types
     73      1.1  scottr  **/
     74      1.1  scottr 
     75      1.1  scottr /*
     76      1.1  scottr  * Floppy disk format information
     77      1.1  scottr  *
     78      1.1  scottr  * XXX How to describe ZBR here? UN*X disk drive handling -- clinging
     79      1.1  scottr  *     tenaciously to the trailing edge of technology...
     80      1.1  scottr  */
     81      1.1  scottr struct fdInfo {
     82  1.2.2.1  scottr 	short	heads;			/* # of heads the drive has */
     83  1.2.2.1  scottr 	short	tracks;			/* # of tracks per side (cyl's)	*/
     84  1.2.2.1  scottr 	short	sectorSize;		/* Bytes per sector */
     85  1.2.2.1  scottr 	short	secPerTrack;		/* fake	*/
     86  1.2.2.1  scottr 	short	secPerCyl;		/* fake	*/
     87  1.2.2.1  scottr 	short	secPerDisk;		/* # of sectors per __disk__ */
     88  1.2.2.1  scottr 	short	stepRate;		/* in ms (is a software delay) */
     89  1.2.2.1  scottr 	short	interleave;		/* Sector interleave */
     90  1.2.2.1  scottr 	short	physFormat;		/* GCR, MFM DD, MFM HD */
     91      1.1  scottr 	char	*description;
     92      1.1  scottr };
     93      1.1  scottr typedef struct fdInfo fdInfo_t;
     94      1.1  scottr 
     95      1.1  scottr /*
     96      1.1  scottr  * Current physical location on Sony GCR disk
     97      1.1  scottr  */
     98      1.1  scottr struct diskPosition {
     99      1.1  scottr 	short	track;
    100      1.1  scottr 	short	oldTrack;
    101      1.1  scottr 	short	side;
    102      1.1  scottr 	short	sector;
    103  1.2.2.1  scottr 	short	maxSect;		/* Highest sector # for this track */
    104      1.1  scottr };
    105      1.1  scottr typedef struct diskPosition diskPosition_t;
    106      1.1  scottr 
    107      1.1  scottr /*
    108      1.1  scottr  * Zone recording scheme (per disk surface/head)
    109      1.1  scottr  */
    110      1.1  scottr struct diskZone {
    111  1.2.2.1  scottr 	short	tracks;			/* # of tracks per zone	*/
    112      1.1  scottr 	short	sectPerTrack;
    113      1.1  scottr 	short	firstBlock;
    114      1.1  scottr 	short	lastBlock;
    115      1.1  scottr };
    116      1.1  scottr typedef struct diskZone diskZone_t;
    117      1.1  scottr 
    118      1.1  scottr /*
    119      1.1  scottr  * Arguments passed between iwmAttach() and the fd probe routines.
    120      1.1  scottr  */
    121      1.1  scottr struct iwmAttachArgs {
    122  1.2.2.1  scottr 	fdInfo_t *driveType;		/* Default drive parameters */
    123  1.2.2.1  scottr 	short	unit;			/* Current drive # */
    124      1.1  scottr };
    125      1.1  scottr typedef struct iwmAttachArgs iwmAttachArgs_t;
    126      1.1  scottr 
    127      1.1  scottr /*
    128      1.1  scottr  * Software state per disk: the IWM can have max. 2 drives. Newer
    129      1.1  scottr  * machines don't even have a port for an external drive.
    130      1.1  scottr  *
    131      1.1  scottr  */
    132      1.1  scottr struct fd_softc {
    133  1.2.2.1  scottr 	struct device devInfo;		/* generic device info */
    134  1.2.2.1  scottr 	struct disk diskInfo;		/* generic disk info */
    135  1.2.2.1  scottr 	struct buf bufQueue;		/* queue of buf's */
    136      1.1  scottr 
    137      1.1  scottr /* private stuff here */
    138  1.2.2.1  scottr /* errors & retries in current I/O job */
    139  1.2.2.1  scottr 	int	iwmErr;			/* Last IO error */
    140  1.2.2.1  scottr 	int	ioRetries;
    141  1.2.2.1  scottr 	int	seekRetries;
    142  1.2.2.1  scottr 	int	sectRetries;
    143  1.2.2.1  scottr 	int	verifyRetries;
    144  1.2.2.1  scottr 
    145  1.2.2.1  scottr /* hardware info */
    146  1.2.2.1  scottr 	int	drvFlags;		/* Copy of drive flags */
    147  1.2.2.1  scottr 	short   stepDirection;		/* Current step direction */
    148  1.2.2.1  scottr 	diskPosition_t pos;		/* Physical position on disk */
    149  1.2.2.1  scottr 
    150  1.2.2.1  scottr 
    151  1.2.2.1  scottr /* drive info */
    152  1.2.2.1  scottr 	short	unit;			/* Drive # as seen by IWM */
    153  1.2.2.1  scottr 	short	partition;		/* "Partition" info {a,b,c,...} */
    154  1.2.2.1  scottr 	fdInfo_t *defaultType;		/* default floppy format */
    155  1.2.2.1  scottr 	fdInfo_t *currentType;		/* current floppy format */
    156  1.2.2.1  scottr 	int     state;			/* XXX */
    157  1.2.2.1  scottr 
    158  1.2.2.1  scottr /* data transfer info */
    159  1.2.2.1  scottr 	int	ioDirection;		/* Read/write */
    160  1.2.2.1  scottr 	daddr_t	startBlk;		/* Starting block # */
    161  1.2.2.1  scottr 	int	bytesLeft;		/* Bytes left to transfer */
    162  1.2.2.1  scottr 	int	bytesDone;		/* Bytes transferred */
    163  1.2.2.1  scottr 	caddr_t current_buffer; 	/* target of current data transfer */
    164  1.2.2.1  scottr 	unsigned char *cbuf;		/* ptr to cylinder cache */
    165  1.2.2.1  scottr 	int	cachedSide;		/* Which head is cached? */
    166  1.2.2.1  scottr 	cylCacheSlot_t r_slots[IWM_MAX_GCR_SECTORS];
    167  1.2.2.1  scottr 	cylCacheSlot_t w_slots[IWM_MAX_GCR_SECTORS];
    168  1.2.2.1  scottr 	int	writeLabel;		/* Write access to disklabel? */
    169  1.2.2.1  scottr 	sectorHdr_t sHdr;		/* current sector header */
    170      1.1  scottr };
    171      1.1  scottr typedef struct fd_softc fd_softc_t;
    172      1.1  scottr 
    173      1.1  scottr /*
    174      1.1  scottr  * Software state of IWM controller
    175      1.1  scottr  *
    176      1.1  scottr  * SWIM/MFM mode may have some state to keep here.
    177      1.1  scottr  */
    178      1.1  scottr struct iwm_softc {
    179  1.2.2.1  scottr 	struct device devInfo;		/* generic device info */
    180  1.2.2.1  scottr 	int	drives;			/* # of attached fd's */
    181  1.2.2.1  scottr 	fd_softc_t *fd[IWM_MAX_DRIVE];	/* ptrs to children */
    182  1.2.2.1  scottr 
    183  1.2.2.1  scottr 	int	state;			/* make that an enum? */
    184  1.2.2.1  scottr 	u_char	modeReg;		/* Copy of IWM mode register */
    185  1.2.2.1  scottr 	short	maxRetries;		/* I/O retries */
    186      1.1  scottr 	int	errors;
    187  1.2.2.1  scottr 	int	underruns;		/* data not delivered in time */
    188      1.1  scottr };
    189      1.1  scottr typedef struct iwm_softc iwm_softc_t;
    190      1.1  scottr 
    191      1.1  scottr 
    192      1.1  scottr /**
    193      1.1  scottr  **     Exported functions
    194      1.1  scottr  **/
    195      1.1  scottr 
    196      1.1  scottr /*
    197      1.1  scottr  * IWM Loadable Kernel Module : Exported functions
    198      1.1  scottr  */
    199      1.1  scottr #ifdef _LKM
    200      1.1  scottr int	fdModInit __P((void));
    201      1.1  scottr void	fdModFree __P((void));
    202      1.1  scottr #endif
    203      1.1  scottr 
    204      1.1  scottr /*
    205      1.1  scottr  * This is the exported driver interface
    206      1.1  scottr  * (bdevsw[] & cdevsw[] function prototypes)
    207      1.1  scottr  *
    208      1.1  scottr  * (see <sys/conf.h>
    209      1.1  scottr  */
    210      1.1  scottr dev_type_open(fdopen);
    211      1.1  scottr dev_type_close(fdclose);
    212      1.1  scottr dev_type_strategy(fdstrategy);
    213      1.1  scottr dev_type_read(fdread);
    214      1.1  scottr dev_type_write(fdwrite);
    215      1.1  scottr dev_type_ioctl(fdioctl);
    216      1.1  scottr dev_type_size(fdsize);
    217      1.1  scottr dev_type_dump(fddump);
    218      1.2  scottr 
    219      1.2  scottr 
    220  1.2.2.1  scottr int 	iwmInit __P((void));
    221  1.2.2.1  scottr int 	iwmCheckDrive __P((int32_t drive));
    222  1.2.2.1  scottr int	iwmSelectDrive __P((int32_t drive));
    223  1.2.2.1  scottr int	iwmSelectSide __P((int32_t side));
    224      1.2  scottr int	iwmTrack00 __P((void));
    225  1.2.2.1  scottr int	iwmSeek __P((int32_t steps));
    226      1.2  scottr 
    227  1.2.2.1  scottr int     iwmReadSector __P((sectorHdr_t *hdr, cylCacheSlot_t *r_slots,
    228  1.2.2.1  scottr 			   caddr_t buf));
    229  1.2.2.1  scottr int	iwmWriteSector __P((sectorHdr_t *hdr, cylCacheSlot_t *w_slots));
    230      1.2  scottr 
    231  1.2.2.1  scottr int	iwmDiskEject __P((int32_t drive));		/* drive = [0..1] */
    232  1.2.2.1  scottr int	iwmMotor __P((int32_t drive, int32_t onOff));	/* on(1)/off(0)	*/
    233      1.2  scottr 
    234      1.2  scottr /*
    235      1.2  scottr  * Debugging only
    236      1.2  scottr  */
    237  1.2.2.1  scottr int	iwmQueryDrvFlag __P((int32_t drive, int32_t reg)); /* reg = [0..15] */
    238      1.2  scottr 
    239      1.2  scottr /* Make sure we run at splhigh when calling! */
    240      1.2  scottr int	iwmReadSectHdr __P((sectorHdr_t *hdr));
    241      1.2  scottr 
    242  1.2.2.1  scottr #if 0 /* XXX not yet */
    243  1.2.2.1  scottr int	iwmReadRawSector __P((int32_t ID, caddr_t buf));
    244  1.2.2.1  scottr int	iwmWriteRawSector __P((int32_t ID, caddr_t buf));
    245  1.2.2.1  scottr int	iwmReadRawTrack __P((int32_t mode, caddr_t buf));
    246  1.2.2.1  scottr #endif
    247      1.1  scottr 
    248      1.1  scottr #endif /* _MAC68K_FDVAR_H */
    249