Sync usage with man page.
[netbsd-mini2440.git] / sys / arch / mac68k / obio / iwm_fdvar.h
bloba98e3b118896e3d8927ba4f23b91672c44df4df1
1 /* $NetBSD: iwm_fdvar.h,v 1.13 2007/03/05 15:32:33 he Exp $ */
3 /*
4 * Copyright (c) 1997, 1998 Hauke Fath. All rights reserved.
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.
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 #ifndef _MAC68K_FDVAR_H
27 #define _MAC68K_FDVAR_H
29 /**
30 ** Constants
31 **/
33 enum {
34 IWM_MAX_DRIVE = 2, /* Attachable drives */
35 IWM_GCR_DISK_ZONES = 5, /* Zones on GCR disk */
36 IWM_MAX_GCR_SECTORS = 12, /* Max. sectors per GCR track */
37 IWM_MAX_FLOPPY_SECT = 50, /* Larger than the highest sector */
38 /* number likely to occur */
42 /* Physical track format codes */
43 enum {
44 IWM_GCR, /* Apple's Group Code Recording format */
45 IWM_MFM_DD, /* Standard MFM on DD disk (250 KBit/s) */
46 IWM_MFM_HD /* Standard MFM on HD disk (500 KBit/s) */
49 /* Drive softc flags */
50 enum {
51 IWM_FD_IS_OPEN = 0x00000001,
52 IWM_FD_MOTOR_ON = 0x00000002
55 /* seek() behaviour */
56 enum {
57 IWM_SEEK_VANILLA,
58 IWM_SEEK_RECAL,
59 IWM_SEEK_VERIFY
62 /* I/O direction */
63 enum {
64 IWM_WRITE = 0,
65 IWM_READ
69 /**
70 ** Data Types
71 **/
74 * Floppy disk format information
76 * XXX How to describe ZBR here? UN*X disk drive handling -- clinging
77 * tenaciously to the trailing edge of technology...
79 struct fdInfo {
80 short heads; /* # of heads the drive has */
81 short tracks; /* # of tracks per side (cyl's) */
82 short sectorSize; /* Bytes per sector */
83 short secPerTrack; /* fake */
84 short secPerCyl; /* fake */
85 short secPerDisk; /* # of sectors per __disk__ */
86 short stepRate; /* in ms (is a software delay) */
87 short interleave; /* Sector interleave */
88 short physFormat; /* GCR, MFM DD, MFM HD */
89 const char *description;
91 typedef struct fdInfo fdInfo_t;
94 * Current physical location on Sony GCR disk
96 struct diskPosition {
97 short track;
98 short oldTrack;
99 short side;
100 short sector;
101 short maxSect; /* Highest sector # for this track */
103 typedef struct diskPosition diskPosition_t;
106 * Zone recording scheme (per disk surface/head)
108 struct diskZone {
109 short tracks; /* # of tracks per zone */
110 short sectPerTrack;
111 short firstBlock;
112 short lastBlock;
114 typedef struct diskZone diskZone_t;
117 * Arguments passed between iwmAttach() and the fd probe routines.
119 struct iwmAttachArgs {
120 fdInfo_t *driveType; /* Default drive parameters */
121 short unit; /* Current drive # */
123 typedef struct iwmAttachArgs iwmAttachArgs_t;
126 * Software state per disk: the IWM can have max. 2 drives. Newer
127 * machines don't even have a port for an external drive.
130 struct fd_softc {
131 struct device devInfo; /* generic device info */
132 struct disk diskInfo; /* generic disk info */
133 struct bufq_state *bufQueue; /* queue of buf's */
134 int sc_active; /* number of active requests */
135 struct callout motor_ch; /* motor callout */
137 /* private stuff here */
138 /* errors & retries in current I/O job */
139 int iwmErr; /* Last IO error */
140 int ioRetries;
141 int seekRetries;
142 int sectRetries;
143 int verifyRetries;
145 /* hardware info */
146 int drvFlags; /* Copy of drive flags */
147 short stepDirection; /* Current step direction */
148 diskPosition_t pos; /* Physical position on disk */
151 /* drive info */
152 short unit; /* Drive # as seen by IWM */
153 short partition; /* "Partition" info {a,b,c,...} */
154 fdInfo_t *defaultType; /* default floppy format */
155 fdInfo_t *currentType; /* current floppy format */
156 int state; /* XXX */
158 /* data transfer info */
159 int ioDirection; /* Read/write */
160 daddr_t startBlk; /* Starting block # */
161 int bytesLeft; /* Bytes left to transfer */
162 int bytesDone; /* Bytes transferred */
163 char *current_buffer; /* target of current data transfer */
164 unsigned char *cbuf; /* ptr to cylinder cache */
165 int cachedSide; /* Which head is cached? */
166 cylCacheSlot_t r_slots[IWM_MAX_GCR_SECTORS];
167 cylCacheSlot_t w_slots[IWM_MAX_GCR_SECTORS];
168 int writeLabel; /* Write access to disklabel? */
169 sectorHdr_t sHdr; /* current sector header */
171 typedef struct fd_softc fd_softc_t;
174 * Software state of IWM controller
176 * SWIM/MFM mode may have some state to keep here.
178 struct iwm_softc {
179 struct device devInfo; /* generic device info */
180 int drives; /* # of attached fd's */
181 fd_softc_t *fd[IWM_MAX_DRIVE]; /* ptrs to children */
183 int state; /* make that an enum? */
184 u_char modeReg; /* Copy of IWM mode register */
185 short maxRetries; /* I/O retries */
186 int errors;
187 int underruns; /* data not delivered in time */
189 typedef struct iwm_softc iwm_softc_t;
193 ** Exported functions
197 * IWM Loadable Kernel Module : Exported functions
199 #ifdef _LKM
200 int fdModInit(void);
201 void fdModFree(void);
202 #endif
204 int iwmInit(void);
205 int iwmCheckDrive(int32_t);
206 int iwmSelectDrive(int32_t);
207 int iwmSelectSide(int32_t);
208 int iwmTrack00(void);
209 int iwmSeek(int32_t);
211 int iwmReadSector(sectorHdr_t *, cylCacheSlot_t *, void *);
212 int iwmWriteSector(sectorHdr_t *, cylCacheSlot_t *);
214 int iwmDiskEject(int32_t); /* drive = [0..1] */
215 int iwmMotor(int32_t, int32_t); /* on(1)/off(0) */
218 * Debugging only
220 int iwmQueryDrvFlag(int32_t, int32_t); /* reg = [0..15] */
222 /* Make sure we run at splhigh when calling! */
223 int iwmReadSectHdr(sectorHdr_t *);
225 #if 0 /* XXX not yet */
226 int iwmReadRawSector(int32_t, void *);
227 int iwmWriteRawSector(int32_t, void *);
228 int iwmReadRawTrack(int32_t, void *);
229 #endif
231 #endif /* _MAC68K_FDVAR_H */