xref: /onnv-gate/usr/src/uts/common/sys/fdc.h (revision 0:68f95e015346)
1*0Sstevel@tonic-gate /*
2*0Sstevel@tonic-gate  * CDDL HEADER START
3*0Sstevel@tonic-gate  *
4*0Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*0Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*0Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*0Sstevel@tonic-gate  * with the License.
8*0Sstevel@tonic-gate  *
9*0Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*0Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*0Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*0Sstevel@tonic-gate  * and limitations under the License.
13*0Sstevel@tonic-gate  *
14*0Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*0Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*0Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*0Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*0Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*0Sstevel@tonic-gate  *
20*0Sstevel@tonic-gate  * CDDL HEADER END
21*0Sstevel@tonic-gate  */
22*0Sstevel@tonic-gate /*
23*0Sstevel@tonic-gate  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
24*0Sstevel@tonic-gate  * Use is subject to license terms.
25*0Sstevel@tonic-gate  */
26*0Sstevel@tonic-gate 
27*0Sstevel@tonic-gate #ifndef	_SYS_FDC_H
28*0Sstevel@tonic-gate #define	_SYS_FDC_H
29*0Sstevel@tonic-gate 
30*0Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
31*0Sstevel@tonic-gate 
32*0Sstevel@tonic-gate #ifdef	__cplusplus
33*0Sstevel@tonic-gate extern "C" {
34*0Sstevel@tonic-gate #endif
35*0Sstevel@tonic-gate 
36*0Sstevel@tonic-gate #ifndef	OTYPCNT
37*0Sstevel@tonic-gate #define	OTYPCNT	5
38*0Sstevel@tonic-gate #endif
39*0Sstevel@tonic-gate 
40*0Sstevel@tonic-gate typedef struct xlate_tbl {
41*0Sstevel@tonic-gate 	int	value;
42*0Sstevel@tonic-gate 	uchar_t	code;
43*0Sstevel@tonic-gate } xlate_tbl_t;
44*0Sstevel@tonic-gate 
45*0Sstevel@tonic-gate /*
46*0Sstevel@tonic-gate  * the floppy disk minor device number is interpreted as follows:
47*0Sstevel@tonic-gate  *
48*0Sstevel@tonic-gate  *	 7 6 5 4 3 2 1 0
49*0Sstevel@tonic-gate  * 	+---------+-----+
50*0Sstevel@tonic-gate  * 	|  drive  | part|
51*0Sstevel@tonic-gate  * 	+---------+-----+
52*0Sstevel@tonic-gate  * where:
53*0Sstevel@tonic-gate  *		drive = instance
54*0Sstevel@tonic-gate  *		part = partition
55*0Sstevel@tonic-gate  */
56*0Sstevel@tonic-gate /*
57*0Sstevel@tonic-gate  * Macros for partition/drive from floppy device number,
58*0Sstevel@tonic-gate  * plus other manifest defines....
59*0Sstevel@tonic-gate  */
60*0Sstevel@tonic-gate 
61*0Sstevel@tonic-gate #define	PARTITION(x)	(getminor(x) & 7)
62*0Sstevel@tonic-gate #define	DRIVE(x)	(getminor(x) >> 3)
63*0Sstevel@tonic-gate #define	FDUNIT(x)	((x) & 3)	/* unit on controller */
64*0Sstevel@tonic-gate #define	FDCTLR(x)	((x) >> 2)	/* controller instance */
65*0Sstevel@tonic-gate #define	NFDUN	4
66*0Sstevel@tonic-gate 
67*0Sstevel@tonic-gate 
68*0Sstevel@tonic-gate /*
69*0Sstevel@tonic-gate  * Floppy drive / diskette type numbers.
70*0Sstevel@tonic-gate  */
71*0Sstevel@tonic-gate #define	FMT_5H	  0
72*0Sstevel@tonic-gate #define	FMT_5Q	  1
73*0Sstevel@tonic-gate #define	FMT_5D9	  2
74*0Sstevel@tonic-gate #define	FMT_5D8	  3
75*0Sstevel@tonic-gate #define	FMT_5D4	  4
76*0Sstevel@tonic-gate #define	FMT_5D16  5
77*0Sstevel@tonic-gate #define	FMT_3E	  6
78*0Sstevel@tonic-gate #define	FMT_3H	  7
79*0Sstevel@tonic-gate #define	FMT_3I	  8
80*0Sstevel@tonic-gate #define	FMT_3M	  9
81*0Sstevel@tonic-gate #define	FMT_3D	  10
82*0Sstevel@tonic-gate #define	FMT_AUTO  11
83*0Sstevel@tonic-gate #define	FMT_MAX	  11
84*0Sstevel@tonic-gate #define	FMT_UNKWN 11
85*0Sstevel@tonic-gate 
86*0Sstevel@tonic-gate 
87*0Sstevel@tonic-gate /*
88*0Sstevel@tonic-gate  * Mini- and Micro- Diskettes Attributes Structure
89*0Sstevel@tonic-gate  */
90*0Sstevel@tonic-gate struct fdattr {
91*0Sstevel@tonic-gate 	ushort_t fda_rotatespd;		/* rotational speed */
92*0Sstevel@tonic-gate 	ushort_t fda_intrlv;		/* interleave factor */
93*0Sstevel@tonic-gate 
94*0Sstevel@tonic-gate 	uchar_t fda_gapl;		/* gap 3 length */
95*0Sstevel@tonic-gate 	uchar_t fda_gapf;		/* gap 3 length for format */
96*0Sstevel@tonic-gate };
97*0Sstevel@tonic-gate 
98*0Sstevel@tonic-gate /*
99*0Sstevel@tonic-gate  * Miscellaneous
100*0Sstevel@tonic-gate  */
101*0Sstevel@tonic-gate #define	FDWRITE	0			/* for fdrw() flag */
102*0Sstevel@tonic-gate #define	FDREAD	1			/* for fdrw() flag */
103*0Sstevel@tonic-gate #define	FDRDONE	86			/*  . read with no retries */
104*0Sstevel@tonic-gate 
105*0Sstevel@tonic-gate /*
106*0Sstevel@tonic-gate  * Per floppy-drive / diskette state structure
107*0Sstevel@tonic-gate  */
108*0Sstevel@tonic-gate 
109*0Sstevel@tonic-gate struct fdisk {
110*0Sstevel@tonic-gate 	struct fcu_obj	*d_obj;
111*0Sstevel@tonic-gate 	int		d_media;	/* drive media capacities */
112*0Sstevel@tonic-gate 	struct kstat 	*d_iostat;	/* pointer to iostat statistics */
113*0Sstevel@tonic-gate 	int		d_bpsshf;	/* shift count for bytes to sector */
114*0Sstevel@tonic-gate 
115*0Sstevel@tonic-gate 	ksema_t		d_ocsem;	/* sem for serializing opens/closes */
116*0Sstevel@tonic-gate 
117*0Sstevel@tonic-gate 	struct buf	*d_actf;	/* head of wait list */
118*0Sstevel@tonic-gate 	struct buf	*d_actl;	/* tail of wait list */
119*0Sstevel@tonic-gate 	struct buf	*d_current;	/* currently active buf */
120*0Sstevel@tonic-gate 	struct partition d_part[NDKMAP];	/* partitions descriptions */
121*0Sstevel@tonic-gate 
122*0Sstevel@tonic-gate 	/*
123*0Sstevel@tonic-gate 	 * Regular open type flags.
124*0Sstevel@tonic-gate 	 * Open types BLK, MNT, CHR, SWP assumed to be values 0-3.
125*0Sstevel@tonic-gate 	 */
126*0Sstevel@tonic-gate 	ulong_t	d_regopen[OTYPCNT - 1];
127*0Sstevel@tonic-gate 	ulong_t	d_lyropen[NDKMAP];	/* Layered open counters */
128*0Sstevel@tonic-gate 
129*0Sstevel@tonic-gate 	/*
130*0Sstevel@tonic-gate 	 * Exclusive open flags (per partition).
131*0Sstevel@tonic-gate 	 *
132*0Sstevel@tonic-gate 	 * The rules are that in order to open a partition exclusively,
133*0Sstevel@tonic-gate 	 * the partition must be completely closed already. Once any
134*0Sstevel@tonic-gate 	 * partition of the device is opened exclusively, no other open
135*0Sstevel@tonic-gate 	 * on that partition may succeed until the partition is closed.
136*0Sstevel@tonic-gate 	 */
137*0Sstevel@tonic-gate 	ulong_t		d_exclmask;	/* set to indicate exclusive open */
138*0Sstevel@tonic-gate 
139*0Sstevel@tonic-gate 	/*
140*0Sstevel@tonic-gate 	 * Current drive characteristics type.
141*0Sstevel@tonic-gate 	 * If -1, then it was set via an ioctl.  Note that a close
142*0Sstevel@tonic-gate 	 * and then an open loses the ioctl set characteristics.
143*0Sstevel@tonic-gate 	 */
144*0Sstevel@tonic-gate 	signed char	d_curfdtype;
145*0Sstevel@tonic-gate 	uchar_t		d_deffdtype;
146*0Sstevel@tonic-gate 
147*0Sstevel@tonic-gate 	uchar_t		d_bsec;		/* encoded bytes_per_sector */
148*0Sstevel@tonic-gate 	uchar_t		d_drate;	/* encoded data_rate */
149*0Sstevel@tonic-gate 	uchar_t		d_motor;	/* motor-on bit */
150*0Sstevel@tonic-gate 
151*0Sstevel@tonic-gate 	uchar_t		d_hutsrt;	/* encoded head unload & step_rate */
152*0Sstevel@tonic-gate 	uchar_t		d_hlt;		/* encoded head load time */
153*0Sstevel@tonic-gate 	uchar_t		d_dtl;		/* dtl code */
154*0Sstevel@tonic-gate 
155*0Sstevel@tonic-gate 	int	d_media_timeout;	/* media detection timeout */
156*0Sstevel@tonic-gate 	timeout_id_t	d_media_timeout_id; /* media detection timeout id */
157*0Sstevel@tonic-gate 	enum dkio_state d_media_state;	/* up-to-date media state */
158*0Sstevel@tonic-gate 	int		d_ejected;
159*0Sstevel@tonic-gate 	kcondvar_t	d_statecv;	/* condition var for media state */
160*0Sstevel@tonic-gate 
161*0Sstevel@tonic-gate 	ulong_t		d_vtoc_bootinfo[3];	/* from label */
162*0Sstevel@tonic-gate 	ulong_t		d_vtoc_version;
163*0Sstevel@tonic-gate 	time_t		d_vtoc_timestamp[NDKMAP];
164*0Sstevel@tonic-gate 	char		d_vtoc_volume[LEN_DKL_VVOL];
165*0Sstevel@tonic-gate 	char		d_vtoc_asciilabel[LEN_DKL_ASCII];
166*0Sstevel@tonic-gate };
167*0Sstevel@tonic-gate 
168*0Sstevel@tonic-gate 
169*0Sstevel@tonic-gate /* a place to keep some statistics on what's going on */
170*0Sstevel@tonic-gate struct fdstat {
171*0Sstevel@tonic-gate 	/* first operations */
172*0Sstevel@tonic-gate 	int rd;		/* count reads */
173*0Sstevel@tonic-gate 	int wr;		/* count writes */
174*0Sstevel@tonic-gate 	int recal;	/* count recalibrates */
175*0Sstevel@tonic-gate 	int form;	/* count format_tracks */
176*0Sstevel@tonic-gate 	int other;	/* count other ops */
177*0Sstevel@tonic-gate 
178*0Sstevel@tonic-gate 	/* then errors */
179*0Sstevel@tonic-gate 	int reset;	/* count resets */
180*0Sstevel@tonic-gate 	int to;		/* count timeouts */
181*0Sstevel@tonic-gate 	int run;	/* count overrun/underrun */
182*0Sstevel@tonic-gate 	int de;		/* count data errors */
183*0Sstevel@tonic-gate 	int bfmt;	/* count bad format errors */
184*0Sstevel@tonic-gate };
185*0Sstevel@tonic-gate 
186*0Sstevel@tonic-gate /*
187*0Sstevel@tonic-gate  * floppy disk command and status block.
188*0Sstevel@tonic-gate  *
189*0Sstevel@tonic-gate  * Needed to execute a command. Since the floppy chip is
190*0Sstevel@tonic-gate  * single threaded with respect to having only one drive
191*0Sstevel@tonic-gate  * active at a time, this block of information is only
192*0Sstevel@tonic-gate  * valid for the length of a command and gets rewritten
193*0Sstevel@tonic-gate  * for each command.
194*0Sstevel@tonic-gate  */
195*0Sstevel@tonic-gate 
196*0Sstevel@tonic-gate enum fxstate {
197*0Sstevel@tonic-gate 	FXS_START,
198*0Sstevel@tonic-gate 	FXS_MTRON,
199*0Sstevel@tonic-gate 	FXS_RCAL,
200*0Sstevel@tonic-gate 	FXS_DKCHGX,
201*0Sstevel@tonic-gate 	FXS_RESTART,
202*0Sstevel@tonic-gate 	FXS_RESEEK,
203*0Sstevel@tonic-gate 	FXS_SEEK,
204*0Sstevel@tonic-gate 	FXS_HDST,
205*0Sstevel@tonic-gate 	FXS_RDID,
206*0Sstevel@tonic-gate 	FXS_DOIT,
207*0Sstevel@tonic-gate 	FXS_DOWT,
208*0Sstevel@tonic-gate 	FXS_KILL,
209*0Sstevel@tonic-gate 	FXS_RESET,
210*0Sstevel@tonic-gate 	FXS_END
211*0Sstevel@tonic-gate };
212*0Sstevel@tonic-gate 
213*0Sstevel@tonic-gate enum fmtrstate {
214*0Sstevel@tonic-gate 	FMS_OFF,
215*0Sstevel@tonic-gate 	FMS_START,
216*0Sstevel@tonic-gate 	FMS_KILLST,
217*0Sstevel@tonic-gate 	FMS_ON,
218*0Sstevel@tonic-gate 	FMS_DELAY,
219*0Sstevel@tonic-gate 	FMS_IDLE
220*0Sstevel@tonic-gate };
221*0Sstevel@tonic-gate 
222*0Sstevel@tonic-gate enum fmtrinput {
223*0Sstevel@tonic-gate 	FMI_TIMER,
224*0Sstevel@tonic-gate 	FMI_STARTCMD,
225*0Sstevel@tonic-gate 	FMI_RSTARTCMD,
226*0Sstevel@tonic-gate 	FMI_DELAYCMD,
227*0Sstevel@tonic-gate 	FMI_IDLECMD
228*0Sstevel@tonic-gate };
229*0Sstevel@tonic-gate 
230*0Sstevel@tonic-gate struct fdcsb {
231*0Sstevel@tonic-gate 	struct buf *csb_bufp;	/* associated buf */
232*0Sstevel@tonic-gate 	ddi_dma_handle_t csb_dmahandle;
233*0Sstevel@tonic-gate 	int csb_handle_bound;		/* DMA handle has been bound */
234*0Sstevel@tonic-gate 	uint_t csb_dmacookiecnt;	/* number of DMA cookies */
235*0Sstevel@tonic-gate 	uint_t csb_dmacurrcookie;	/* current cookie number */
236*0Sstevel@tonic-gate 	uint_t csb_dmawincnt;		/* number of DMA windows */
237*0Sstevel@tonic-gate 	uint_t csb_dmacurrwin;		/* current DMA window */
238*0Sstevel@tonic-gate 	ddi_dma_cookie_t csb_dmacookie;
239*0Sstevel@tonic-gate 	enum fxstate csb_xstate;	/* Current execution state */
240*0Sstevel@tonic-gate 	enum fxstate csb_oldxs;	/* old execution state */
241*0Sstevel@tonic-gate 	uchar_t	csb_npcyl;	/* new physical cylinder number */
242*0Sstevel@tonic-gate 	uchar_t	csb_drive;	/* floppy unit number */
243*0Sstevel@tonic-gate 	uchar_t	csb_ncmds;	/* how many command bytes to send */
244*0Sstevel@tonic-gate 	uchar_t	csb_nrslts;	/* number of result bytes gotten */
245*0Sstevel@tonic-gate 	uchar_t	csb_opflags;	/* opflags, see below */
246*0Sstevel@tonic-gate 	uchar_t	csb_timer;	/* op timer, in 0.1 sec */
247*0Sstevel@tonic-gate 	uchar_t	csb_maxretry;	/* maximum retries this operation */
248*0Sstevel@tonic-gate 	uchar_t	csb_retrys;	/* how may retrys done so far */
249*0Sstevel@tonic-gate 	uchar_t	csb_ourtrys;	/* how may over/underrun retrys done so far */
250*0Sstevel@tonic-gate 	uchar_t	csb_status;	/* status returned from hwintr */
251*0Sstevel@tonic-gate 	uchar_t	csb_cmdstat;	/* if 0 then success, else failure */
252*0Sstevel@tonic-gate 	uchar_t	csb_cmd[10];	/* command to send to chip */
253*0Sstevel@tonic-gate 	uchar_t	csb_rslt[10];	/* results from chip */
254*0Sstevel@tonic-gate };
255*0Sstevel@tonic-gate 
256*0Sstevel@tonic-gate /*
257*0Sstevel@tonic-gate  * defines for csb_opflags
258*0Sstevel@tonic-gate  */
259*0Sstevel@tonic-gate #define	CSB_OFINRPT	0x01		/* generates an interrupt */
260*0Sstevel@tonic-gate #define	CSB_OFDMARD	0x02		/* uses DMA for reading */
261*0Sstevel@tonic-gate #define	CSB_OFDMAWT	0x04		/* uses DMA for writing */
262*0Sstevel@tonic-gate #define	CSB_OFRESLT	0x08		/* generates results */
263*0Sstevel@tonic-gate #define	CSB_OFRAWIOCTL	0x10		/* raw i/o control */
264*0Sstevel@tonic-gate 
265*0Sstevel@tonic-gate #define	CSB_CMDTO   0x01
266*0Sstevel@tonic-gate #define	CSB_CMDDMA  0x03
267*0Sstevel@tonic-gate #define	CSB_CMDNGNR 0x07
268*0Sstevel@tonic-gate 
269*0Sstevel@tonic-gate 
270*0Sstevel@tonic-gate /*
271*0Sstevel@tonic-gate  * 82077AA Controller modes
272*0Sstevel@tonic-gate  */
273*0Sstevel@tonic-gate enum fdcmode077 {
274*0Sstevel@tonic-gate 	FDCMODE_AT,
275*0Sstevel@tonic-gate 	FDCMODE_PS2,	/* not supported */
276*0Sstevel@tonic-gate 	FDCMODE_30
277*0Sstevel@tonic-gate };
278*0Sstevel@tonic-gate 
279*0Sstevel@tonic-gate /*
280*0Sstevel@tonic-gate  * Per controller data
281*0Sstevel@tonic-gate  */
282*0Sstevel@tonic-gate 
283*0Sstevel@tonic-gate struct fdcntlr {
284*0Sstevel@tonic-gate 	kmutex_t	c_lock;		/* controller mutex */
285*0Sstevel@tonic-gate 	kmutex_t	c_dorlock;	/* digital_output_register mutex */
286*0Sstevel@tonic-gate 	kcondvar_t	c_iocv;		/* condition var for I/O done */
287*0Sstevel@tonic-gate 	ksema_t		c_selsem;	/* sem for select unit */
288*0Sstevel@tonic-gate 
289*0Sstevel@tonic-gate 	dev_info_t	*c_dip;
290*0Sstevel@tonic-gate 	int		c_number;	/* logical controller number */
291*0Sstevel@tonic-gate 	int		c_regbase;	/* base i/o address */
292*0Sstevel@tonic-gate 	int		c_dmachan;	/* DMA channel number */
293*0Sstevel@tonic-gate 	int		c_intprio;	/* interrupt priority */
294*0Sstevel@tonic-gate 	int		c_intvec;	/* interrupt vector num */
295*0Sstevel@tonic-gate 	int		c_chip;
296*0Sstevel@tonic-gate 	enum fdcmode077	c_mode;		/* 82077 controller mode */
297*0Sstevel@tonic-gate 
298*0Sstevel@tonic-gate 	ulong_t		c_flags;	/* state information */
299*0Sstevel@tonic-gate 	struct kstat	*c_intrstat;	/* interrupt stats pointer */
300*0Sstevel@tonic-gate 	struct	fdstat	fdstats;	/* statistics */
301*0Sstevel@tonic-gate 
302*0Sstevel@tonic-gate 	ddi_iblock_cookie_t c_iblock;	/* returned from ddi_add_intr */
303*0Sstevel@tonic-gate 	ddi_idevice_cookie_t c_idevice;	/* returned from ddi_add_intr */
304*0Sstevel@tonic-gate 
305*0Sstevel@tonic-gate 	int		c_curunit;	/* current/last selected unit */
306*0Sstevel@tonic-gate 	timeout_id_t	c_timeid;	/* watchdog timer id */
307*0Sstevel@tonic-gate 
308*0Sstevel@tonic-gate 	struct	fcu_obj	*c_unit[NFDUN];	/* slave on controller */
309*0Sstevel@tonic-gate 	timeout_id_t	c_motort[NFDUN]; /* motor timer id */
310*0Sstevel@tonic-gate 	enum fmtrstate	c_mtrstate[NFDUN];
311*0Sstevel@tonic-gate 	int		c_curpcyl[NFDUN]; /* current physical cylinder */
312*0Sstevel@tonic-gate 	signed char	c_sekdir[NFDUN]; /* direction of last seek */
313*0Sstevel@tonic-gate 
314*0Sstevel@tonic-gate 	struct	fdcsb	c_csb;		/* current csb */
315*0Sstevel@tonic-gate 
316*0Sstevel@tonic-gate 	/*
317*0Sstevel@tonic-gate 	 * floppy controller register values
318*0Sstevel@tonic-gate 	 */
319*0Sstevel@tonic-gate 	uchar_t		c_digout;
320*0Sstevel@tonic-gate 	uchar_t		c_drate;	/* only 82072 and 82077AA controllers */
321*0Sstevel@tonic-gate 	uchar_t		c_config;	/* DSR on PC/AT with 8272A */
322*0Sstevel@tonic-gate 	uchar_t		c_mstat;
323*0Sstevel@tonic-gate 	uchar_t		c_data;
324*0Sstevel@tonic-gate 	uchar_t		c_digin;
325*0Sstevel@tonic-gate 
326*0Sstevel@tonic-gate 	uchar_t		c_bsec;		/* encoded bytes_per_sector */
327*0Sstevel@tonic-gate 	uchar_t		c_hutsrt;	/* encoded head unload & step_rate */
328*0Sstevel@tonic-gate 	uchar_t		c_hlt;		/* encoded head load time */
329*0Sstevel@tonic-gate };
330*0Sstevel@tonic-gate 
331*0Sstevel@tonic-gate /*
332*0Sstevel@tonic-gate  * Controller flags
333*0Sstevel@tonic-gate  */
334*0Sstevel@tonic-gate #define	FCFLG_BUSY	0x01	/* operation in progress */
335*0Sstevel@tonic-gate #define	FCFLG_WANT	0x02	/* csb structure wanted */
336*0Sstevel@tonic-gate #define	FCFLG_WAITMR	0x10	/* waiting for motor to start I/O */
337*0Sstevel@tonic-gate #define	FCFLG_WAITING	0x20	/* waiting on I/O completion */
338*0Sstevel@tonic-gate #define	FCFLG_TIMEOUT	0x80	/* the current operation just timed out */
339*0Sstevel@tonic-gate #define	FCFLG_DSOUT	0x100	/* DENSEL ouput is in use for speed ctl */
340*0Sstevel@tonic-gate #define	FCFLG_3DMODE	0x800	/* ctlr is 3D Mode capable */
341*0Sstevel@tonic-gate 
342*0Sstevel@tonic-gate 
343*0Sstevel@tonic-gate /*
344*0Sstevel@tonic-gate  * FDC operations
345*0Sstevel@tonic-gate  */
346*0Sstevel@tonic-gate 
347*0Sstevel@tonic-gate struct fcobjops {
348*0Sstevel@tonic-gate 	int	(*fco_start)();		/* controller start */
349*0Sstevel@tonic-gate 	int	(*fco_abort)();		/* controller abort */
350*0Sstevel@tonic-gate 	int	(*fco_getcap)();	/* capability retrieval */
351*0Sstevel@tonic-gate 	int	(*fco_setcap)();	/* capability establishment */
352*0Sstevel@tonic-gate 	int	(*fco_dkinfo)();	/* get disk controller info */
353*0Sstevel@tonic-gate 
354*0Sstevel@tonic-gate 	int	(*fco_select)();	/* select / deselect unit */
355*0Sstevel@tonic-gate 	int	(*fco_getchng)();	/* get media change */
356*0Sstevel@tonic-gate 	int	(*fco_resetchng)();	/* reset media change */
357*0Sstevel@tonic-gate 	int	(*fco_rcseek)();	/* recal / seek */
358*0Sstevel@tonic-gate 	int	(*fco_rwbuf)();		/* read /write request */
359*0Sstevel@tonic-gate 	int	(*fco_rw)();		/* read /write sector */
360*0Sstevel@tonic-gate 	int	(*fco_format)();	/* format track */
361*0Sstevel@tonic-gate 	int	(*fco_rwioctl)();	/* raw ioctl */
362*0Sstevel@tonic-gate };
363*0Sstevel@tonic-gate 
364*0Sstevel@tonic-gate /*
365*0Sstevel@tonic-gate  * FDC unit object
366*0Sstevel@tonic-gate  */
367*0Sstevel@tonic-gate 
368*0Sstevel@tonic-gate struct fcu_obj {
369*0Sstevel@tonic-gate 	ulong_t		fj_flags;	/* state information */
370*0Sstevel@tonic-gate 	kmutex_t 	fj_lock;	/* unit mutex */
371*0Sstevel@tonic-gate 	caddr_t		fj_data;
372*0Sstevel@tonic-gate 	struct fd_drive *fj_drive;	/* pointer to drive characteristics */
373*0Sstevel@tonic-gate 	struct fd_char	*fj_chars;	/* ptr to diskette characteristics */
374*0Sstevel@tonic-gate 	struct fdattr	*fj_attr;	/* additional diskette attributes */
375*0Sstevel@tonic-gate 	dev_info_t	*fj_dip;
376*0Sstevel@tonic-gate 	ushort_t	fj_rotspd;	/* rotational speed */
377*0Sstevel@tonic-gate 	ulong_t		fj_unit;
378*0Sstevel@tonic-gate 	struct fcobjops *fj_ops;
379*0Sstevel@tonic-gate 	struct fdcntlr	*fj_fdc;
380*0Sstevel@tonic-gate 	ddi_iblock_cookie_t *fj_iblock;
381*0Sstevel@tonic-gate };
382*0Sstevel@tonic-gate 
383*0Sstevel@tonic-gate /* unit flags (state info) */
384*0Sstevel@tonic-gate #define	FUNIT_DRVATCH		0x001	/* this is drive present */
385*0Sstevel@tonic-gate #define	FUNIT_WPROT		0x004	/* diskette is read only */
386*0Sstevel@tonic-gate #define	FUNIT_CHAROK		0x010	/* characteristics are known */
387*0Sstevel@tonic-gate #define	FUNIT_LABELOK		0x020	/* label was read from disk */
388*0Sstevel@tonic-gate #define	FUNIT_UNLABELED		0x040	/* no label using default */
389*0Sstevel@tonic-gate #define	FUNIT_CHANGED		0x100	/* diskette was changed after open */
390*0Sstevel@tonic-gate #define	FUNIT_CHGDET		0x200	/* diskette removal was detected */
391*0Sstevel@tonic-gate #define	FUNIT_3DMODE		0x4000	/* unit is in fast speed mode */
392*0Sstevel@tonic-gate #define	FUNIT_BUSY		0x8000	/* unit is busy */
393*0Sstevel@tonic-gate 
394*0Sstevel@tonic-gate #ifdef _VPIX
395*0Sstevel@tonic-gate #define	DRV_NONE	0x00
396*0Sstevel@tonic-gate #define	DRV_DBL		0x01
397*0Sstevel@tonic-gate #define	DRV_QUAD	0x02
398*0Sstevel@tonic-gate #define	DRV_720		0x04	/* LOW_35 gets changed to this for or'ing */
399*0Sstevel@tonic-gate #define	DRV_144		0x08	/* HI35 gets changed to this for or'ing */
400*0Sstevel@tonic-gate 
401*0Sstevel@tonic-gate /* ioctl numbers used by VPIX */
402*0Sstevel@tonic-gate #define	FIOC		('F'<<8)
403*0Sstevel@tonic-gate #define	F_DTYP		(FIOC|60)	/* returns fd_drvtype */
404*0Sstevel@tonic-gate #define	F_FCR		(FIOC|61)	/* output to Floppy Control Register */
405*0Sstevel@tonic-gate #define	F_DOR		(FIOC|62)	/* output to Digital Output Register */
406*0Sstevel@tonic-gate #define	F_RAW		(FIOC|63)	/* general raw controller interface */
407*0Sstevel@tonic-gate #endif
408*0Sstevel@tonic-gate 
409*0Sstevel@tonic-gate #ifdef	__cplusplus
410*0Sstevel@tonic-gate }
411*0Sstevel@tonic-gate #endif
412*0Sstevel@tonic-gate 
413*0Sstevel@tonic-gate #endif	/* !_SYS_FDC_H */
414