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