iwm_fdvar.h revision 1.1 1 /* $Id: iwm_fdvar.h,v 1.1 1999/02/18 07:38:26 scottr Exp $ */
2
3 /*
4 * Copyright (c) 1997, 1998 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_FDVAR_H
29 #define _MAC68K_FDVAR_H
30
31 /**
32 ** Constants
33 **/
34
35 /* Number of attachable drives */
36 #define IWM_MAX_DRIVE 2
37
38 /* Number of zones on GCR disk */
39 #define IWM_GCR_DISK_ZONES 5
40
41 /* Larger than the highest sector number likely */
42 #define IWM_MAX_FLOPPY_SECT 50
43
44 /* Physical track format codes */
45 enum {
46 IWM_GCR, /* Apple's Group Code Recording format */
47 IWM_MFM_DD, /* Standard MFM on DD disk (250 KBit/s) */
48 IWM_MFM_HD /* Standard MFM on HD disk (500 KBit/s) */
49 };
50
51 /* Drive softc flags */
52 enum {
53 IWM_FD_IS_OPEN = 0x00000001,
54 IWM_FD_MOTOR_ON = 0x00000002
55 };
56
57 /* seek() behaviour */
58 enum {
59 IWM_SEEK_VANILLA,
60 IWM_SEEK_RECAL,
61 IWM_SEEK_VERIFY
62 };
63
64
65 /**
66 ** Data Types
67 **/
68
69 /*
70 * Floppy disk format information
71 *
72 * XXX How to describe ZBR here? UN*X disk drive handling -- clinging
73 * tenaciously to the trailing edge of technology...
74 */
75 struct fdInfo {
76 short heads; /* # of heads the drive has */
77 short tracks; /* # of tracks per side (cyl's) */
78 short sectorSize; /* Bytes per sector */
79 short secPerTrack; /* fake */
80 short secPerCyl; /* fake */
81 short secPerDisk; /* # of sectors per __disk__ */
82 short stepRate; /* in ms (is a software delay) */
83 short interleave; /* Sector interleave */
84 short physFormat; /* GCR, MFM DD, MFM HD */
85 char *description;
86 };
87 typedef struct fdInfo fdInfo_t;
88
89 /*
90 * Current physical location on Sony GCR disk
91 */
92 struct diskPosition {
93 short track;
94 short oldTrack;
95 short side;
96 short sector;
97 short maxSect; /* Highest sector # for this track */
98 };
99 typedef struct diskPosition diskPosition_t;
100
101 /*
102 * Zone recording scheme (per disk surface/head)
103 */
104 struct diskZone {
105 short tracks; /* # of tracks per zone */
106 short sectPerTrack;
107 short firstBlock;
108 short lastBlock;
109 };
110 typedef struct diskZone diskZone_t;
111
112 /*
113 * Arguments passed between iwmAttach() and the fd probe routines.
114 */
115 struct iwmAttachArgs {
116 fdInfo_t *driveType; /* Default drive parameters */
117 short unit; /* Current drive # */
118 };
119 typedef struct iwmAttachArgs iwmAttachArgs_t;
120
121 /*
122 * Software state per disk: the IWM can have max. 2 drives. Newer
123 * machines don't even have a port for an external drive.
124 *
125 */
126 struct fd_softc {
127 struct device devInfo; /* generic device info */
128 struct disk diskInfo; /* generic disk info */
129 struct buf bufQueue; /* queue of buf's */
130
131 /* private stuff here */
132 daddr_t startBlk; /* Starting block # */
133 int bytesLeft; /* Bytes left to transfer */
134 int bytesDone; /* Bytes transferred */
135
136 int drvFlags; /* Copy of drive flags */
137 short unit; /* Drive # as seen by IWM */
138 short partition; /* "Partition" info {a,b,c,...} */
139 fdInfo_t *defaultType; /* default floppy format */
140 fdInfo_t *currentType; /* current floppy format */
141 int state; /* XXX */
142 void *trackBuf; /* Pointer to track buffer */
143 short stepDirection; /* Current step direction */
144 diskPosition_t pos; /* Physical position on disk */
145 int writeLabel; /* Write access to disklabel? */
146 };
147 typedef struct fd_softc fd_softc_t;
148
149 /*
150 * Software state of IWM controller
151 *
152 * SWIM/MFM mode may have some state to keep here.
153 */
154 struct iwm_softc {
155 struct device devInfo; /* generic device info */
156 int drives; /* # of attached fd's */
157 fd_softc_t *fd[IWM_MAX_DRIVE]; /* ptrs to children */
158
159 int state; /* make that an enum? */
160 u_char modeReg; /* Copy of IWM mode register */
161 short maxRetries; /* I/O retries */
162 int errors;
163 int underruns; /* data not delivered in time */
164 };
165 typedef struct iwm_softc iwm_softc_t;
166
167
168 /**
169 ** Exported functions
170 **/
171
172 /*
173 * IWM Loadable Kernel Module : Exported functions
174 */
175 #ifdef _LKM
176 int fdModInit __P((void));
177 void fdModFree __P((void));
178 #endif
179
180 /*
181 * This is the exported driver interface
182 * (bdevsw[] & cdevsw[] function prototypes)
183 *
184 * (see <sys/conf.h>
185 */
186 dev_type_open(fdopen);
187 dev_type_close(fdclose);
188 dev_type_strategy(fdstrategy);
189 dev_type_read(fdread);
190 dev_type_write(fdwrite);
191 dev_type_ioctl(fdioctl);
192 dev_type_size(fdsize);
193 dev_type_dump(fddump);
194
195 #endif /* _MAC68K_FDVAR_H */
196