iwm_fdvar.h revision 1.12 1 1.12 christos /* $NetBSD: iwm_fdvar.h,v 1.12 2007/03/04 06:00:09 christos 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.3 scottr enum {
36 1.3 scottr IWM_MAX_DRIVE = 2, /* Attachable drives */
37 1.3 scottr IWM_GCR_DISK_ZONES = 5, /* Zones on GCR disk */
38 1.3 scottr IWM_MAX_GCR_SECTORS = 12, /* Max. sectors per GCR track */
39 1.3 scottr IWM_MAX_FLOPPY_SECT = 50, /* Larger than the highest sector */
40 1.3 scottr /* number likely to occur */
41 1.3 scottr };
42 1.1 scottr
43 1.1 scottr
44 1.1 scottr /* Physical track format codes */
45 1.1 scottr enum {
46 1.3 scottr IWM_GCR, /* Apple's Group Code Recording format */
47 1.3 scottr IWM_MFM_DD, /* Standard MFM on DD disk (250 KBit/s) */
48 1.3 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.3 scottr /* I/O direction */
65 1.3 scottr enum {
66 1.3 scottr IWM_WRITE = 0,
67 1.3 scottr IWM_READ
68 1.3 scottr };
69 1.3 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.3 scottr short heads; /* # of heads the drive has */
83 1.3 scottr short tracks; /* # of tracks per side (cyl's) */
84 1.3 scottr short sectorSize; /* Bytes per sector */
85 1.3 scottr short secPerTrack; /* fake */
86 1.3 scottr short secPerCyl; /* fake */
87 1.3 scottr short secPerDisk; /* # of sectors per __disk__ */
88 1.3 scottr short stepRate; /* in ms (is a software delay) */
89 1.3 scottr short interleave; /* Sector interleave */
90 1.3 scottr short physFormat; /* GCR, MFM DD, MFM HD */
91 1.9 jmc const 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.3 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.3 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.3 scottr fdInfo_t *driveType; /* Default drive parameters */
123 1.3 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.3 scottr struct device devInfo; /* generic device info */
134 1.3 scottr struct disk diskInfo; /* generic disk info */
135 1.10 yamt struct bufq_state *bufQueue; /* queue of buf's */
136 1.4 thorpej int sc_active; /* number of active requests */
137 1.5 thorpej struct callout motor_ch; /* motor callout */
138 1.1 scottr
139 1.1 scottr /* private stuff here */
140 1.3 scottr /* errors & retries in current I/O job */
141 1.3 scottr int iwmErr; /* Last IO error */
142 1.3 scottr int ioRetries;
143 1.3 scottr int seekRetries;
144 1.3 scottr int sectRetries;
145 1.3 scottr int verifyRetries;
146 1.3 scottr
147 1.3 scottr /* hardware info */
148 1.3 scottr int drvFlags; /* Copy of drive flags */
149 1.3 scottr short stepDirection; /* Current step direction */
150 1.3 scottr diskPosition_t pos; /* Physical position on disk */
151 1.3 scottr
152 1.3 scottr
153 1.3 scottr /* drive info */
154 1.3 scottr short unit; /* Drive # as seen by IWM */
155 1.3 scottr short partition; /* "Partition" info {a,b,c,...} */
156 1.3 scottr fdInfo_t *defaultType; /* default floppy format */
157 1.3 scottr fdInfo_t *currentType; /* current floppy format */
158 1.3 scottr int state; /* XXX */
159 1.3 scottr
160 1.3 scottr /* data transfer info */
161 1.3 scottr int ioDirection; /* Read/write */
162 1.3 scottr daddr_t startBlk; /* Starting block # */
163 1.3 scottr int bytesLeft; /* Bytes left to transfer */
164 1.3 scottr int bytesDone; /* Bytes transferred */
165 1.12 christos void *current_buffer; /* target of current data transfer */
166 1.3 scottr unsigned char *cbuf; /* ptr to cylinder cache */
167 1.3 scottr int cachedSide; /* Which head is cached? */
168 1.3 scottr cylCacheSlot_t r_slots[IWM_MAX_GCR_SECTORS];
169 1.3 scottr cylCacheSlot_t w_slots[IWM_MAX_GCR_SECTORS];
170 1.3 scottr int writeLabel; /* Write access to disklabel? */
171 1.3 scottr sectorHdr_t sHdr; /* current sector header */
172 1.1 scottr };
173 1.1 scottr typedef struct fd_softc fd_softc_t;
174 1.1 scottr
175 1.1 scottr /*
176 1.1 scottr * Software state of IWM controller
177 1.1 scottr *
178 1.1 scottr * SWIM/MFM mode may have some state to keep here.
179 1.1 scottr */
180 1.1 scottr struct iwm_softc {
181 1.3 scottr struct device devInfo; /* generic device info */
182 1.3 scottr int drives; /* # of attached fd's */
183 1.3 scottr fd_softc_t *fd[IWM_MAX_DRIVE]; /* ptrs to children */
184 1.3 scottr
185 1.3 scottr int state; /* make that an enum? */
186 1.3 scottr u_char modeReg; /* Copy of IWM mode register */
187 1.3 scottr short maxRetries; /* I/O retries */
188 1.1 scottr int errors;
189 1.3 scottr int underruns; /* data not delivered in time */
190 1.1 scottr };
191 1.1 scottr typedef struct iwm_softc iwm_softc_t;
192 1.1 scottr
193 1.1 scottr
194 1.1 scottr /**
195 1.1 scottr ** Exported functions
196 1.1 scottr **/
197 1.1 scottr
198 1.1 scottr /*
199 1.1 scottr * IWM Loadable Kernel Module : Exported functions
200 1.1 scottr */
201 1.1 scottr #ifdef _LKM
202 1.8 chs int fdModInit(void);
203 1.8 chs void fdModFree(void);
204 1.1 scottr #endif
205 1.2 scottr
206 1.8 chs int iwmInit(void);
207 1.8 chs int iwmCheckDrive(int32_t);
208 1.8 chs int iwmSelectDrive(int32_t);
209 1.8 chs int iwmSelectSide(int32_t);
210 1.8 chs int iwmTrack00(void);
211 1.8 chs int iwmSeek(int32_t);
212 1.2 scottr
213 1.12 christos int iwmReadSector(sectorHdr_t *, cylCacheSlot_t *, void *);
214 1.8 chs int iwmWriteSector(sectorHdr_t *, cylCacheSlot_t *);
215 1.8 chs
216 1.8 chs int iwmDiskEject(int32_t); /* drive = [0..1] */
217 1.8 chs int iwmMotor(int32_t, int32_t); /* on(1)/off(0) */
218 1.2 scottr
219 1.2 scottr /*
220 1.2 scottr * Debugging only
221 1.2 scottr */
222 1.8 chs int iwmQueryDrvFlag(int32_t, int32_t); /* reg = [0..15] */
223 1.2 scottr
224 1.2 scottr /* Make sure we run at splhigh when calling! */
225 1.8 chs int iwmReadSectHdr(sectorHdr_t *);
226 1.2 scottr
227 1.3 scottr #if 0 /* XXX not yet */
228 1.12 christos int iwmReadRawSector(int32_t, void *);
229 1.12 christos int iwmWriteRawSector(int32_t, void *);
230 1.12 christos int iwmReadRawTrack(int32_t, void *);
231 1.3 scottr #endif
232 1.1 scottr
233 1.1 scottr #endif /* _MAC68K_FDVAR_H */
234