xref: /illumos-gate/usr/src/uts/sun/sys/fdvar.h (revision 7c478bd9)
1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate  * CDDL HEADER START
3*7c478bd9Sstevel@tonic-gate  *
4*7c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*7c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*7c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*7c478bd9Sstevel@tonic-gate  * with the License.
8*7c478bd9Sstevel@tonic-gate  *
9*7c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*7c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*7c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*7c478bd9Sstevel@tonic-gate  * and limitations under the License.
13*7c478bd9Sstevel@tonic-gate  *
14*7c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*7c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*7c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*7c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*7c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*7c478bd9Sstevel@tonic-gate  *
20*7c478bd9Sstevel@tonic-gate  * CDDL HEADER END
21*7c478bd9Sstevel@tonic-gate  */
22*7c478bd9Sstevel@tonic-gate /*
23*7c478bd9Sstevel@tonic-gate  * Copyright (c) 1989-1994,1997-1998,2000 by Sun Microsystems, Inc.
24*7c478bd9Sstevel@tonic-gate  * All rights reserved.
25*7c478bd9Sstevel@tonic-gate  */
26*7c478bd9Sstevel@tonic-gate 
27*7c478bd9Sstevel@tonic-gate #ifndef	_SYS_FDVAR_H
28*7c478bd9Sstevel@tonic-gate #define	_SYS_FDVAR_H
29*7c478bd9Sstevel@tonic-gate 
30*7c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
31*7c478bd9Sstevel@tonic-gate 
32*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
33*7c478bd9Sstevel@tonic-gate extern "C" {
34*7c478bd9Sstevel@tonic-gate #endif
35*7c478bd9Sstevel@tonic-gate 
36*7c478bd9Sstevel@tonic-gate #ifndef	OTYPCNT
37*7c478bd9Sstevel@tonic-gate #define	OTYPCNT	5
38*7c478bd9Sstevel@tonic-gate #endif
39*7c478bd9Sstevel@tonic-gate #ifndef	NDKMAP
40*7c478bd9Sstevel@tonic-gate #define	NDKMAP	8
41*7c478bd9Sstevel@tonic-gate #endif
42*7c478bd9Sstevel@tonic-gate 
43*7c478bd9Sstevel@tonic-gate /*
44*7c478bd9Sstevel@tonic-gate  * Compile with our without high level interrupt in trap window
45*7c478bd9Sstevel@tonic-gate  */
46*7c478bd9Sstevel@tonic-gate 
47*7c478bd9Sstevel@tonic-gate /* #define	NO_TRAPWIN_INTR	*/
48*7c478bd9Sstevel@tonic-gate 
49*7c478bd9Sstevel@tonic-gate /*
50*7c478bd9Sstevel@tonic-gate  * Macros for partition/unit from floppy device number,
51*7c478bd9Sstevel@tonic-gate  * plus other manifest defines....
52*7c478bd9Sstevel@tonic-gate  */
53*7c478bd9Sstevel@tonic-gate 
54*7c478bd9Sstevel@tonic-gate #define	FDUNITSHIFT	(3)
55*7c478bd9Sstevel@tonic-gate #define	FDINSTSHIFT	(2 + FDUNITSHIFT)
56*7c478bd9Sstevel@tonic-gate #define	FDPARTITION(x)	(getminor(x) & 0x7)
57*7c478bd9Sstevel@tonic-gate #define	FDUNIT(x)	((getminor(x) >> FDUNITSHIFT) & 0x3)
58*7c478bd9Sstevel@tonic-gate 
59*7c478bd9Sstevel@tonic-gate #define	FDCTLR(x)	(getminor(x) >> FDINSTSHIFT)	/* instance */
60*7c478bd9Sstevel@tonic-gate 
61*7c478bd9Sstevel@tonic-gate /*
62*7c478bd9Sstevel@tonic-gate  * Structure definitions for the floppy driver.
63*7c478bd9Sstevel@tonic-gate  */
64*7c478bd9Sstevel@tonic-gate 
65*7c478bd9Sstevel@tonic-gate /*
66*7c478bd9Sstevel@tonic-gate  * floppy disk command and status block.
67*7c478bd9Sstevel@tonic-gate  *
68*7c478bd9Sstevel@tonic-gate  * Needed to execute a command. Since the floppy chip is
69*7c478bd9Sstevel@tonic-gate  * single threaded with respect to having only one drive
70*7c478bd9Sstevel@tonic-gate  * active at a time, this block of information is only
71*7c478bd9Sstevel@tonic-gate  * valid for the length of a commnand and gets rewritten
72*7c478bd9Sstevel@tonic-gate  * for each command.
73*7c478bd9Sstevel@tonic-gate  */
74*7c478bd9Sstevel@tonic-gate 
75*7c478bd9Sstevel@tonic-gate #ifndef	_ASM
76*7c478bd9Sstevel@tonic-gate struct fdcsb {
77*7c478bd9Sstevel@tonic-gate 	caddr_t	csb_addr;	/* Data buffer address */
78*7c478bd9Sstevel@tonic-gate 	uint_t	csb_len;	/* Data buffer Length */
79*7c478bd9Sstevel@tonic-gate 	caddr_t	csb_raddr;	/* modified data buffer address */
80*7c478bd9Sstevel@tonic-gate 	uint_t	csb_rlen;	/* modified data buffer len (resid) */
81*7c478bd9Sstevel@tonic-gate 	uchar_t	csb_opmode;	/* Current operating mode */
82*7c478bd9Sstevel@tonic-gate 	uchar_t	csb_unit;	/* floppy slave unit number */
83*7c478bd9Sstevel@tonic-gate 	uchar_t	csb_ncmds;	/* how many command bytes to send */
84*7c478bd9Sstevel@tonic-gate 	uchar_t	csb_nrslts;	/* number of result bytes gotten */
85*7c478bd9Sstevel@tonic-gate 	uchar_t	csb_opflags;	/* opflags, see below */
86*7c478bd9Sstevel@tonic-gate 	uchar_t	csb_maxretry;	/* maximum retries this opertion */
87*7c478bd9Sstevel@tonic-gate 	uchar_t	csb_retrys;	/* how may retrys done so far */
88*7c478bd9Sstevel@tonic-gate 	uchar_t	csb_status;	/* status returned from hwintr */
89*7c478bd9Sstevel@tonic-gate 	uchar_t	csb_cmdstat;	/* if 0 then success, else failure */
90*7c478bd9Sstevel@tonic-gate 	uchar_t	csb_cmds[10];	/* commands to send to chip */
91*7c478bd9Sstevel@tonic-gate 	uchar_t	csb_rslt[10];	/* results from chip */
92*7c478bd9Sstevel@tonic-gate 	uchar_t  csb_dcsr_rslt;  /* set to 1 if there's an error in the DCSR */
93*7c478bd9Sstevel@tonic-gate 	uchar_t	csb_dma_rslt;	/* set to 1 if there's an error with the DMA */
94*7c478bd9Sstevel@tonic-gate 	ddi_dma_cookie_t csb_dmacookie; /* DMA cookie */
95*7c478bd9Sstevel@tonic-gate 
96*7c478bd9Sstevel@tonic-gate 	uint_t	csb_ccount;	/* no. of DMA cookies for current window */
97*7c478bd9Sstevel@tonic-gate 	uint_t	csb_nwin;	/* no. of DMA windows */
98*7c478bd9Sstevel@tonic-gate 	uint_t	csb_windex;	/* DMA window currently in use */
99*7c478bd9Sstevel@tonic-gate 	uint_t	csb_read;	/* indicates read or write */
100*7c478bd9Sstevel@tonic-gate };
101*7c478bd9Sstevel@tonic-gate #endif	/* !_ASM */
102*7c478bd9Sstevel@tonic-gate 
103*7c478bd9Sstevel@tonic-gate /*
104*7c478bd9Sstevel@tonic-gate  * defines for csb_opflags
105*7c478bd9Sstevel@tonic-gate  */
106*7c478bd9Sstevel@tonic-gate #define	CSB_OFIMMEDIATE	0x01		/* grab results immediately */
107*7c478bd9Sstevel@tonic-gate #define	CSB_OFSEEKOPS	0x02		/* seek/recal type cmd */
108*7c478bd9Sstevel@tonic-gate #define	CSB_OFXFEROPS	0x04		/* read/write type cmd */
109*7c478bd9Sstevel@tonic-gate #define	CSB_OFRAWIOCTL	0x10		/* raw ioctl - no recovery */
110*7c478bd9Sstevel@tonic-gate #define	CSB_OFNORESULTS	0x20		/* no results at all */
111*7c478bd9Sstevel@tonic-gate #define	CSB_OFTIMEIT	0x40		/* timeout (timer) */
112*7c478bd9Sstevel@tonic-gate 
113*7c478bd9Sstevel@tonic-gate #define	CSB_CMDTO 0x01
114*7c478bd9Sstevel@tonic-gate 
115*7c478bd9Sstevel@tonic-gate /*
116*7c478bd9Sstevel@tonic-gate  * csb_read flags
117*7c478bd9Sstevel@tonic-gate  */
118*7c478bd9Sstevel@tonic-gate #define	CSB_NULL	0x0
119*7c478bd9Sstevel@tonic-gate #define	CSB_READ	0x1
120*7c478bd9Sstevel@tonic-gate #define	CSB_WRITE	0x2
121*7c478bd9Sstevel@tonic-gate 
122*7c478bd9Sstevel@tonic-gate #ifndef	_ASM
123*7c478bd9Sstevel@tonic-gate #ifndef	_GENASSYM
124*7c478bd9Sstevel@tonic-gate 
125*7c478bd9Sstevel@tonic-gate /*
126*7c478bd9Sstevel@tonic-gate  * Define a structure to hold the packed default labels,
127*7c478bd9Sstevel@tonic-gate  * based on the real dk_label structure - but shorter
128*7c478bd9Sstevel@tonic-gate  * than 512 bytes. Now only used to define default info
129*7c478bd9Sstevel@tonic-gate  */
130*7c478bd9Sstevel@tonic-gate struct packed_label {
131*7c478bd9Sstevel@tonic-gate 	char		dkl_vname[128];	/* for ascii compatibility */
132*7c478bd9Sstevel@tonic-gate 	unsigned short	dkl_rpm;	/* rotations per minute */
133*7c478bd9Sstevel@tonic-gate 	unsigned short	dkl_pcyl;	/* # physical cylinders */
134*7c478bd9Sstevel@tonic-gate 	unsigned short	dkl_apc;	/* alternates per cylinder */
135*7c478bd9Sstevel@tonic-gate 	unsigned short	dkl_intrlv;	/* interleave factor */
136*7c478bd9Sstevel@tonic-gate 	unsigned short	dkl_ncyl;	/* # of data cylinders */
137*7c478bd9Sstevel@tonic-gate 	unsigned short	dkl_acyl;	/* # of alternate cylinders */
138*7c478bd9Sstevel@tonic-gate 	unsigned short	dkl_nhead;	/* # of heads in this partition */
139*7c478bd9Sstevel@tonic-gate 	unsigned short	dkl_nsect;	/* # of 512 byte sectors per track */
140*7c478bd9Sstevel@tonic-gate 	struct dk_map32	dkl_map[NDKMAP]; /* partition map, see dkio.h */
141*7c478bd9Sstevel@tonic-gate 	struct dk_vtoc  dkl_vtoc;	/* vtoc stuff from AT&T SVr4 */
142*7c478bd9Sstevel@tonic-gate };
143*7c478bd9Sstevel@tonic-gate 
144*7c478bd9Sstevel@tonic-gate /*
145*7c478bd9Sstevel@tonic-gate  * Per drive data
146*7c478bd9Sstevel@tonic-gate  */
147*7c478bd9Sstevel@tonic-gate struct fdunit {
148*7c478bd9Sstevel@tonic-gate 
149*7c478bd9Sstevel@tonic-gate 	/*
150*7c478bd9Sstevel@tonic-gate 	 * Packed label for this unit
151*7c478bd9Sstevel@tonic-gate 	 */
152*7c478bd9Sstevel@tonic-gate 	struct	dk_label un_label;
153*7c478bd9Sstevel@tonic-gate 
154*7c478bd9Sstevel@tonic-gate 	/*
155*7c478bd9Sstevel@tonic-gate 	 * Pointer to iostat statistics
156*7c478bd9Sstevel@tonic-gate 	 */
157*7c478bd9Sstevel@tonic-gate 	struct kstat *un_iostat;	/* iostat numbers */
158*7c478bd9Sstevel@tonic-gate 
159*7c478bd9Sstevel@tonic-gate 	/*
160*7c478bd9Sstevel@tonic-gate 	 * Layered open counters
161*7c478bd9Sstevel@tonic-gate 	 */
162*7c478bd9Sstevel@tonic-gate 	uint_t	un_lyropen[NDKMAP];
163*7c478bd9Sstevel@tonic-gate 
164*7c478bd9Sstevel@tonic-gate 	/*
165*7c478bd9Sstevel@tonic-gate 	 * Regular open type flags. If
166*7c478bd9Sstevel@tonic-gate 	 * NDKMAP gets > 8, change the
167*7c478bd9Sstevel@tonic-gate 	 * uchar_t type.
168*7c478bd9Sstevel@tonic-gate 	 *
169*7c478bd9Sstevel@tonic-gate 	 * Open types BLK, MNT, CHR, SWP
170*7c478bd9Sstevel@tonic-gate 	 * assumed to be values 0-3.
171*7c478bd9Sstevel@tonic-gate 	 */
172*7c478bd9Sstevel@tonic-gate 	uchar_t	un_regopen[OTYPCNT - 1];
173*7c478bd9Sstevel@tonic-gate 
174*7c478bd9Sstevel@tonic-gate 	/*
175*7c478bd9Sstevel@tonic-gate 	 * Exclusive open flags (per partition).
176*7c478bd9Sstevel@tonic-gate 	 *
177*7c478bd9Sstevel@tonic-gate 	 * The rules are that in order to open
178*7c478bd9Sstevel@tonic-gate 	 * a partition exclusively, the partition
179*7c478bd9Sstevel@tonic-gate 	 * must be completely closed already. Once
180*7c478bd9Sstevel@tonic-gate 	 * any partition of the device is opened
181*7c478bd9Sstevel@tonic-gate 	 * exclusively, no other open on that
182*7c478bd9Sstevel@tonic-gate 	 * partition may succeed until the partition
183*7c478bd9Sstevel@tonic-gate 	 * is closed.
184*7c478bd9Sstevel@tonic-gate 	 *
185*7c478bd9Sstevel@tonic-gate 	 * If NDKMAP gets > 8, this must change.
186*7c478bd9Sstevel@tonic-gate 	 */
187*7c478bd9Sstevel@tonic-gate 	uchar_t	un_exclmask;		/* set to indicate exclusive open */
188*7c478bd9Sstevel@tonic-gate 
189*7c478bd9Sstevel@tonic-gate 	struct	fd_char *un_chars;	/* ptr to diskette characteristics */
190*7c478bd9Sstevel@tonic-gate 	char	un_curfdtype;		/* current driver characteristics */
191*7c478bd9Sstevel@tonic-gate 					/* type. If -1, then it was set */
192*7c478bd9Sstevel@tonic-gate 					/* via an ioctl. Note that a close */
193*7c478bd9Sstevel@tonic-gate 					/* and then and open loses the */
194*7c478bd9Sstevel@tonic-gate 					/* ioctl set characteristics. */
195*7c478bd9Sstevel@tonic-gate 
196*7c478bd9Sstevel@tonic-gate 	struct fd_drive *un_drive;	/* ptr to drive characteristics */
197*7c478bd9Sstevel@tonic-gate 	int	un_unit_no;		/* drive id number */
198*7c478bd9Sstevel@tonic-gate 	uchar_t	un_flags;		/* state information */
199*7c478bd9Sstevel@tonic-gate 	clock_t	un_media_timeout;	/* media detection timeout */
200*7c478bd9Sstevel@tonic-gate 	timeout_id_t un_media_timeout_id; /* media detection timeout id */
201*7c478bd9Sstevel@tonic-gate 	enum dkio_state	un_media_state;	/* up-to-date media state */
202*7c478bd9Sstevel@tonic-gate 	int	un_ejected;
203*7c478bd9Sstevel@tonic-gate 	short	un_state;		/* Current power level of drive */
204*7c478bd9Sstevel@tonic-gate };
205*7c478bd9Sstevel@tonic-gate 
206*7c478bd9Sstevel@tonic-gate /* unit flags (state info) */
207*7c478bd9Sstevel@tonic-gate #define	FDUNIT_DRVCHECKED	0x01	/* this is drive present */
208*7c478bd9Sstevel@tonic-gate #define	FDUNIT_DRVPRESENT	0x02	/* this is drive present */
209*7c478bd9Sstevel@tonic-gate /* (the presence of a diskette is another matter) */
210*7c478bd9Sstevel@tonic-gate #define	FDUNIT_CHAROK		0x04	/* characteristics are known */
211*7c478bd9Sstevel@tonic-gate #define	FDUNIT_UNLABELED	0x10	/* no label using default */
212*7c478bd9Sstevel@tonic-gate #define	FDUNIT_CHANGED		0x20	/* diskette was changed after open */
213*7c478bd9Sstevel@tonic-gate #define	FDUNIT_MEDIUM		0x40	/* fd drive is in medium density */
214*7c478bd9Sstevel@tonic-gate #define	FDUNIT_SET_SPEED	0x80	/* Flag to force updating the */
215*7c478bd9Sstevel@tonic-gate 					/* registers with current speed */
216*7c478bd9Sstevel@tonic-gate 
217*7c478bd9Sstevel@tonic-gate #endif	/* !_GENASSYM */
218*7c478bd9Sstevel@tonic-gate 
219*7c478bd9Sstevel@tonic-gate /* unit flags for power (un_power) */
220*7c478bd9Sstevel@tonic-gate #define	FD_STATE_NORMAL		0x0 /* Normal running state */
221*7c478bd9Sstevel@tonic-gate #define	FD_STATE_SUSPENDED	0x1 /* Device suspended for cpr */
222*7c478bd9Sstevel@tonic-gate #define	FD_STATE_STOPPED	0x2 /* Device is stopped, can be turned off */
223*7c478bd9Sstevel@tonic-gate 
224*7c478bd9Sstevel@tonic-gate /*
225*7c478bd9Sstevel@tonic-gate  * --------|   fd_detach:DDI_SUSPEND ncmds may be != 0 |-----------|
226*7c478bd9Sstevel@tonic-gate  * |running|------------------------------------------>|           |
227*7c478bd9Sstevel@tonic-gate  * |NORMAL |  fd_attach:DDI_RESUME                     |           |
228*7c478bd9Sstevel@tonic-gate  * |       |<------------------------------------------| SUSPENDED |
229*7c478bd9Sstevel@tonic-gate  * |       |                                           |           |
230*7c478bd9Sstevel@tonic-gate  * |       |                                           -------------
231*7c478bd9Sstevel@tonic-gate  * |       |                                                ^
232*7c478bd9Sstevel@tonic-gate  * |       |                                                |DDI_SUSPEND
233*7c478bd9Sstevel@tonic-gate  * |       |                                                |
234*7c478bd9Sstevel@tonic-gate  * |       | fd_power: PM_LEVEL_OFF, ncmds == 0         -------------
235*7c478bd9Sstevel@tonic-gate  * |       |------------------------------------------->|STOPPED     |
236*7c478bd9Sstevel@tonic-gate  * |       | fd_power: PM_LEVEL_ON                      |            |
237*7c478bd9Sstevel@tonic-gate  * |       |<-------------------------------------------|            |
238*7c478bd9Sstevel@tonic-gate  * --------                                              ------------|
239*7c478bd9Sstevel@tonic-gate  *
240*7c478bd9Sstevel@tonic-gate  * running => FD_STATE_NORMAL
241*7c478bd9Sstevel@tonic-gate  *
242*7c478bd9Sstevel@tonic-gate  */
243*7c478bd9Sstevel@tonic-gate 
244*7c478bd9Sstevel@tonic-gate /* flags for power levels for auto power management */
245*7c478bd9Sstevel@tonic-gate #define	PM_LEVEL_ON	0x1   /* Changes the state to FD_STATE_STOPPED */
246*7c478bd9Sstevel@tonic-gate #define	PM_LEVEL_OFF	0x0   /* Changes the state to FD_STATE_NORMAL */
247*7c478bd9Sstevel@tonic-gate 
248*7c478bd9Sstevel@tonic-gate /* a place to keep some statistics on what's going on */
249*7c478bd9Sstevel@tonic-gate struct fdstat {
250*7c478bd9Sstevel@tonic-gate 	/* first operations */
251*7c478bd9Sstevel@tonic-gate 	int rd;		/* count reads */
252*7c478bd9Sstevel@tonic-gate 	int wr;		/* count writes */
253*7c478bd9Sstevel@tonic-gate 	int recal;	/* count recalibrates */
254*7c478bd9Sstevel@tonic-gate 	int form;	/* count format_tracks */
255*7c478bd9Sstevel@tonic-gate 	int other;	/* count other ops */
256*7c478bd9Sstevel@tonic-gate 
257*7c478bd9Sstevel@tonic-gate 	/* then errors */
258*7c478bd9Sstevel@tonic-gate 	int reset;	/* count resets */
259*7c478bd9Sstevel@tonic-gate 	int to;		/* count timeouts */
260*7c478bd9Sstevel@tonic-gate 	int run;	/* count overrun/underrun */
261*7c478bd9Sstevel@tonic-gate 	int de;		/* count data errors */
262*7c478bd9Sstevel@tonic-gate 	int bfmt;	/* count bad format errors */
263*7c478bd9Sstevel@tonic-gate };
264*7c478bd9Sstevel@tonic-gate 
265*7c478bd9Sstevel@tonic-gate /*
266*7c478bd9Sstevel@tonic-gate  * Per controller data
267*7c478bd9Sstevel@tonic-gate  */
268*7c478bd9Sstevel@tonic-gate 
269*7c478bd9Sstevel@tonic-gate struct fdctlr {
270*7c478bd9Sstevel@tonic-gate 	struct	fdctlr	*c_next;	/* next in a linked list */
271*7c478bd9Sstevel@tonic-gate 	union  fdcreg   *c_reg;		/* controller registers */
272*7c478bd9Sstevel@tonic-gate 	volatile uchar_t *c_control; 	/* addr of c_reg->fdc_control */
273*7c478bd9Sstevel@tonic-gate 	uchar_t		*c_fifo;	/* addr of c_reg->fdc_fifo */
274*7c478bd9Sstevel@tonic-gate 	uchar_t		*c_dor;		/* addr of c_reg->fdc_dor (077) */
275*7c478bd9Sstevel@tonic-gate 	uchar_t		*c_dir;		/* addr of c_reg->fdc_dir (077) */
276*7c478bd9Sstevel@tonic-gate 	caddr_t		*c_dma_regs;	/* DMA engine registers */
277*7c478bd9Sstevel@tonic-gate 	uint_t		c_fdtype;	/* type of ctlr */
278*7c478bd9Sstevel@tonic-gate 	uint_t		*c_hiintct;	/* for convenience.. */
279*7c478bd9Sstevel@tonic-gate 	uint_t		c_softic;	/* for use by hi level interrupt */
280*7c478bd9Sstevel@tonic-gate 	uchar_t		c_fasttrap;	/* 1 if fast traps enabled, else 0 */
281*7c478bd9Sstevel@tonic-gate 	struct	fdcsb	c_csb;		/* current csb */
282*7c478bd9Sstevel@tonic-gate 	kmutex_t	c_hilock;	/* high level mutex */
283*7c478bd9Sstevel@tonic-gate 	kmutex_t	c_lolock;	/* low level mutex */
284*7c478bd9Sstevel@tonic-gate 	kcondvar_t	c_iocv;		/* condition var for I/O done */
285*7c478bd9Sstevel@tonic-gate 	kcondvar_t	c_csbcv;	/* condition var for owning csb */
286*7c478bd9Sstevel@tonic-gate 	kcondvar_t	c_motoncv;	/* condition var for motor on */
287*7c478bd9Sstevel@tonic-gate 	kcondvar_t	c_statecv;	/* condition var for media state */
288*7c478bd9Sstevel@tonic-gate 	kcondvar_t	c_suspend_cv;  /* Cond Var on power management */
289*7c478bd9Sstevel@tonic-gate 	ksema_t		c_ocsem;	/* sem for serializing opens/closes */
290*7c478bd9Sstevel@tonic-gate 	ddi_iblock_cookie_t c_block;	/* returned from ddi_add_fastintr */
291*7c478bd9Sstevel@tonic-gate 	ddi_softintr_t	c_softid;	/* returned from ddi_add_softintr */
292*7c478bd9Sstevel@tonic-gate 	dev_info_t	*c_dip;		/* controller's dev_info node */
293*7c478bd9Sstevel@tonic-gate 	timeout_id_t	c_timeid;	/* watchdog timer id */
294*7c478bd9Sstevel@tonic-gate 	timeout_id_t	c_mtimeid;	/* motor off timer id */
295*7c478bd9Sstevel@tonic-gate 	struct	fdunit	*c_un;		/* unit on controller */
296*7c478bd9Sstevel@tonic-gate 	struct	buf	*c_actf;	/* head of wait list */
297*7c478bd9Sstevel@tonic-gate 	struct	buf	*c_actl;	/* tail of wait list */
298*7c478bd9Sstevel@tonic-gate 	struct	buf	*c_current;	/* currently active buf */
299*7c478bd9Sstevel@tonic-gate 	struct kstat	*c_intrstat;	/* interrupt stats pointer */
300*7c478bd9Sstevel@tonic-gate 	struct	fdstat	fdstats;	/* statistics */
301*7c478bd9Sstevel@tonic-gate 	uchar_t		c_flags;	/* state information */
302*7c478bd9Sstevel@tonic-gate 	caddr_t		c_auxiova;	/* auxio virtual address */
303*7c478bd9Sstevel@tonic-gate 	uchar_t		c_auxiodata;	/* auxio data to enable TC */
304*7c478bd9Sstevel@tonic-gate 	uchar_t		c_auxiodata2;	/* auxio data to disable TC */
305*7c478bd9Sstevel@tonic-gate 	ddi_acc_handle_t c_handlep_cont;
306*7c478bd9Sstevel@tonic-gate 					/* data access handle for controller */
307*7c478bd9Sstevel@tonic-gate 	ddi_acc_handle_t c_handlep_dma; /* data access handle for DMA engine */
308*7c478bd9Sstevel@tonic-gate 	ddi_acc_handle_t c_handlep_aux;  /* data access handle for aux regs */
309*7c478bd9Sstevel@tonic-gate 	ddi_dma_handle_t c_dmahandle; 	/* DMA handle */
310*7c478bd9Sstevel@tonic-gate 	uint_t		 *c_auxio_reg; 	/* auxio registers */
311*7c478bd9Sstevel@tonic-gate 	ddi_dma_attr_t 	c_fd_dma_lim;	/* DMA limit structure */
312*7c478bd9Sstevel@tonic-gate 	caddr_t		dma_buf;	/* Temporary DMAble buffer */
313*7c478bd9Sstevel@tonic-gate 	ddi_acc_handle_t c_dma_buf_handle; /* DMA handle for dma_buf */
314*7c478bd9Sstevel@tonic-gate 	uint_t		sb_dma_channel; /* 8237 dma channel no. */
315*7c478bd9Sstevel@tonic-gate 	uchar_t		sb_dma_lock;	/* Status of DMA lock by isadma */
316*7c478bd9Sstevel@tonic-gate };
317*7c478bd9Sstevel@tonic-gate #endif	/* !_ASM */
318*7c478bd9Sstevel@tonic-gate 
319*7c478bd9Sstevel@tonic-gate /* types of controllers supported by this driver */
320*7c478bd9Sstevel@tonic-gate #define	FDCTYPE_82072	0x0001
321*7c478bd9Sstevel@tonic-gate #define	FDCTYPE_82077   0x0002
322*7c478bd9Sstevel@tonic-gate #define	FDCTYPE_CTRLMASK 0x000f
323*7c478bd9Sstevel@tonic-gate 
324*7c478bd9Sstevel@tonic-gate /* types of io chips which indicates the type of auxio register */
325*7c478bd9Sstevel@tonic-gate #define	FDCTYPE_MACHIO		0x0010
326*7c478bd9Sstevel@tonic-gate #define	FDCTYPE_SLAVIO		0x0020
327*7c478bd9Sstevel@tonic-gate #define	FDCTYPE_CHEERIO		0x0040
328*7c478bd9Sstevel@tonic-gate #define	FDCTYPE_SB		0x0080
329*7c478bd9Sstevel@tonic-gate #define	FDCTYPE_AUXIOMASK 	0x00f0
330*7c478bd9Sstevel@tonic-gate 
331*7c478bd9Sstevel@tonic-gate /* Method used for transferring data */
332*7c478bd9Sstevel@tonic-gate #define	FDCTYPE_DMA		0x1000	/* supports DMA for the floppy */
333*7c478bd9Sstevel@tonic-gate #define	FDCTYPE_DMA8237		FDCTYPE_DMA	/* 8237 DMA controller */
334*7c478bd9Sstevel@tonic-gate #define	FDCTYPE_TRNSFER_MASTK	0xf000
335*7c478bd9Sstevel@tonic-gate 
336*7c478bd9Sstevel@tonic-gate /*
337*7c478bd9Sstevel@tonic-gate  * Early revs of the 82077 have a bug by which they
338*7c478bd9Sstevel@tonic-gate  * will not respond to the TC (Terminal count) signal.
339*7c478bd9Sstevel@tonic-gate  * Because this behavior is exhibited on the clone machines
340*7c478bd9Sstevel@tonic-gate  * for which the 077 code has been targeted, special workaround
341*7c478bd9Sstevel@tonic-gate  * logic has had to implemented for read/write commands.
342*7c478bd9Sstevel@tonic-gate  */
343*7c478bd9Sstevel@tonic-gate #define	FDCTYPE_TCBUG	0x0100
344*7c478bd9Sstevel@tonic-gate #define	FDCTYPE_BUGMASK	0x0f00
345*7c478bd9Sstevel@tonic-gate 
346*7c478bd9Sstevel@tonic-gate /*
347*7c478bd9Sstevel@tonic-gate  * Controller flags
348*7c478bd9Sstevel@tonic-gate  */
349*7c478bd9Sstevel@tonic-gate #define	FDCFLG_BUSY	0x01	/* operation in progress */
350*7c478bd9Sstevel@tonic-gate #define	FDCFLG_WANT	0x02	/* csb structure wanted */
351*7c478bd9Sstevel@tonic-gate #define	FDCFLG_WAITING	0x04	/* waiting on I/O completion */
352*7c478bd9Sstevel@tonic-gate #define	FDCFLG_TIMEDOUT	0x08	/* the current operation just timed out */
353*7c478bd9Sstevel@tonic-gate 
354*7c478bd9Sstevel@tonic-gate 
355*7c478bd9Sstevel@tonic-gate #ifndef	_ASM
356*7c478bd9Sstevel@tonic-gate /*
357*7c478bd9Sstevel@tonic-gate  * Miscellaneous
358*7c478bd9Sstevel@tonic-gate  */
359*7c478bd9Sstevel@tonic-gate #define	FDREAD	1			/* for fdrw() flag */
360*7c478bd9Sstevel@tonic-gate #define	FDWRITE	2			/* for fdrw() flag */
361*7c478bd9Sstevel@tonic-gate #define	FD_CRETRY 1000000		/* retry while sending comand */
362*7c478bd9Sstevel@tonic-gate #define	FD_RRETRY 1000000		/* retry while getting results */
363*7c478bd9Sstevel@tonic-gate #define	FDXC_SLEEP	0x1		/* tell fdexec to sleep 'till done */
364*7c478bd9Sstevel@tonic-gate #define	FDXC_CHECKCHG	0x2		/* tell fdexec to check disk chnged */
365*7c478bd9Sstevel@tonic-gate #define	FD_SB_DMA_ALIGN	0x10000		/* DMA alignment for South Bridge */
366*7c478bd9Sstevel@tonic-gate 
367*7c478bd9Sstevel@tonic-gate 
368*7c478bd9Sstevel@tonic-gate /*
369*7c478bd9Sstevel@tonic-gate  * flags/masks for error printing.
370*7c478bd9Sstevel@tonic-gate  * the levels are for severity
371*7c478bd9Sstevel@tonic-gate  */
372*7c478bd9Sstevel@tonic-gate #define	FDEP_L0		0	/* chatty as can be - for debug! */
373*7c478bd9Sstevel@tonic-gate #define	FDEP_L1		1	/* best for debug */
374*7c478bd9Sstevel@tonic-gate #define	FDEP_L2		2	/* minor errors - retries, etc. */
375*7c478bd9Sstevel@tonic-gate #define	FDEP_L3		3	/* major errors */
376*7c478bd9Sstevel@tonic-gate #define	FDEP_L4		4	/* catastophic errors, don't mask! */
377*7c478bd9Sstevel@tonic-gate #define	FDEP_LMAX	4	/* catastophic errors, don't mask! */
378*7c478bd9Sstevel@tonic-gate #define	FDERRPRINT(l, m, args)	\
379*7c478bd9Sstevel@tonic-gate 	{ if (((l) >= fderrlevel) && ((m) & fderrmask)) cmn_err args; }
380*7c478bd9Sstevel@tonic-gate 
381*7c478bd9Sstevel@tonic-gate /*
382*7c478bd9Sstevel@tonic-gate  * for each function, we can mask off its printing by clearing its bit in
383*7c478bd9Sstevel@tonic-gate  * the fderrmask.  Some functions (attach, ident) share a mask bit
384*7c478bd9Sstevel@tonic-gate  */
385*7c478bd9Sstevel@tonic-gate #define	FDEM_IDEN 0x00000001	/* fdidentify */
386*7c478bd9Sstevel@tonic-gate #define	FDEM_ATTA 0x00000001	/* fdattach */
387*7c478bd9Sstevel@tonic-gate #define	FDEM_SIZE 0x00000002	/* fdsize */
388*7c478bd9Sstevel@tonic-gate #define	FDEM_OPEN 0x00000004	/* fdopen */
389*7c478bd9Sstevel@tonic-gate #define	FDEM_GETL 0x00000008	/* fdgetlabel */
390*7c478bd9Sstevel@tonic-gate #define	FDEM_CLOS 0x00000010	/* fdclose */
391*7c478bd9Sstevel@tonic-gate #define	FDEM_STRA 0x00000020	/* fdstrategy */
392*7c478bd9Sstevel@tonic-gate #define	FDEM_STRT 0x00000040	/* fdstart */
393*7c478bd9Sstevel@tonic-gate #define	FDEM_RDWR 0x00000080	/* fdrdwr */
394*7c478bd9Sstevel@tonic-gate #define	FDEM_CMD  0x00000100	/* fdcmd */
395*7c478bd9Sstevel@tonic-gate #define	FDEM_EXEC 0x00000200	/* fdexec */
396*7c478bd9Sstevel@tonic-gate #define	FDEM_RECO 0x00000400	/* fdrecover */
397*7c478bd9Sstevel@tonic-gate #define	FDEM_INTR 0x00000800	/* fdintr */
398*7c478bd9Sstevel@tonic-gate #define	FDEM_WATC 0x00001000	/* fdwatch */
399*7c478bd9Sstevel@tonic-gate #define	FDEM_IOCT 0x00002000	/* fdioctl */
400*7c478bd9Sstevel@tonic-gate #define	FDEM_RAWI 0x00004000	/* fdrawioctl */
401*7c478bd9Sstevel@tonic-gate #define	FDEM_DUMP 0x00008000	/* fddump */
402*7c478bd9Sstevel@tonic-gate #define	FDEM_GETC 0x00010000	/* fdgetcsb */
403*7c478bd9Sstevel@tonic-gate #define	FDEM_RETC 0x00020000	/* fdretcsb */
404*7c478bd9Sstevel@tonic-gate #define	FDEM_RESE 0x00040000	/* fdreset */
405*7c478bd9Sstevel@tonic-gate #define	FDEM_RECA 0x00080000	/* fdrecalseek */
406*7c478bd9Sstevel@tonic-gate #define	FDEM_FORM 0x00100000	/* fdformat */
407*7c478bd9Sstevel@tonic-gate #define	FDEM_RW   0x00200000	/* fdrw */
408*7c478bd9Sstevel@tonic-gate #define	FDEM_CHEK 0x00400000	/* fdcheckdisk */
409*7c478bd9Sstevel@tonic-gate #define	FDEM_DSEL 0x00800000	/* fdselect */
410*7c478bd9Sstevel@tonic-gate #define	FDEM_EJEC 0x01000000	/* fdeject */
411*7c478bd9Sstevel@tonic-gate #define	FDEM_SCHG 0x02000000	/* fdsense_chng */
412*7c478bd9Sstevel@tonic-gate #define	FDEM_PACK 0x04000000	/* fdpacklabel */
413*7c478bd9Sstevel@tonic-gate #define	FDEM_MODS 0x08000000	/* _init, _info, _fini */
414*7c478bd9Sstevel@tonic-gate #define	FDEM_MOFF 0x10000000	/* fdmotoff */
415*7c478bd9Sstevel@tonic-gate #define	FDEM_SDMA 0x20000000    /* fdstart_dma */
416*7c478bd9Sstevel@tonic-gate #define	FDEM_PWR  0x40000000	/* fd power management */
417*7c478bd9Sstevel@tonic-gate #define	FDEM_ALL  0xFFFFFFFF	/* all */
418*7c478bd9Sstevel@tonic-gate 
419*7c478bd9Sstevel@tonic-gate #endif	/* !_ASM */
420*7c478bd9Sstevel@tonic-gate 
421*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
422*7c478bd9Sstevel@tonic-gate }
423*7c478bd9Sstevel@tonic-gate #endif
424*7c478bd9Sstevel@tonic-gate 
425*7c478bd9Sstevel@tonic-gate #endif	/* !_SYS_FDVAR_H */
426