xref: /titanic_51/usr/src/uts/common/sys/fdc.h (revision ca925f54ccacc64abb1dc147c736397a9ccaab0e)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*ca925f54SGarrett D'Amore  * Common Development and Distribution License (the "License").
6*ca925f54SGarrett D'Amore  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
217c478bd9Sstevel@tonic-gate /*
22*ca925f54SGarrett D'Amore  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
237c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
247c478bd9Sstevel@tonic-gate  */
257c478bd9Sstevel@tonic-gate 
267c478bd9Sstevel@tonic-gate #ifndef	_SYS_FDC_H
277c478bd9Sstevel@tonic-gate #define	_SYS_FDC_H
287c478bd9Sstevel@tonic-gate 
297c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
307c478bd9Sstevel@tonic-gate extern "C" {
317c478bd9Sstevel@tonic-gate #endif
327c478bd9Sstevel@tonic-gate 
337c478bd9Sstevel@tonic-gate #ifndef	OTYPCNT
347c478bd9Sstevel@tonic-gate #define	OTYPCNT	5
357c478bd9Sstevel@tonic-gate #endif
367c478bd9Sstevel@tonic-gate 
377c478bd9Sstevel@tonic-gate typedef struct xlate_tbl {
387c478bd9Sstevel@tonic-gate 	int	value;
397c478bd9Sstevel@tonic-gate 	uchar_t	code;
407c478bd9Sstevel@tonic-gate } xlate_tbl_t;
417c478bd9Sstevel@tonic-gate 
427c478bd9Sstevel@tonic-gate /*
437c478bd9Sstevel@tonic-gate  * the floppy disk minor device number is interpreted as follows:
447c478bd9Sstevel@tonic-gate  *
457c478bd9Sstevel@tonic-gate  *	 7 6 5 4 3 2 1 0
467c478bd9Sstevel@tonic-gate  * 	+---------+-----+
477c478bd9Sstevel@tonic-gate  * 	|  drive  | part|
487c478bd9Sstevel@tonic-gate  * 	+---------+-----+
497c478bd9Sstevel@tonic-gate  * where:
507c478bd9Sstevel@tonic-gate  *		drive = instance
517c478bd9Sstevel@tonic-gate  *		part = partition
527c478bd9Sstevel@tonic-gate  */
537c478bd9Sstevel@tonic-gate /*
547c478bd9Sstevel@tonic-gate  * Macros for partition/drive from floppy device number,
557c478bd9Sstevel@tonic-gate  * plus other manifest defines....
567c478bd9Sstevel@tonic-gate  */
577c478bd9Sstevel@tonic-gate 
587c478bd9Sstevel@tonic-gate #define	PARTITION(x)	(getminor(x) & 7)
597c478bd9Sstevel@tonic-gate #define	DRIVE(x)	(getminor(x) >> 3)
607c478bd9Sstevel@tonic-gate #define	FDUNIT(x)	((x) & 3)	/* unit on controller */
617c478bd9Sstevel@tonic-gate #define	FDCTLR(x)	((x) >> 2)	/* controller instance */
627c478bd9Sstevel@tonic-gate #define	NFDUN	4
637c478bd9Sstevel@tonic-gate 
647c478bd9Sstevel@tonic-gate 
657c478bd9Sstevel@tonic-gate /*
667c478bd9Sstevel@tonic-gate  * Floppy drive / diskette type numbers.
677c478bd9Sstevel@tonic-gate  */
687c478bd9Sstevel@tonic-gate #define	FMT_5H	  0
697c478bd9Sstevel@tonic-gate #define	FMT_5Q	  1
707c478bd9Sstevel@tonic-gate #define	FMT_5D9	  2
717c478bd9Sstevel@tonic-gate #define	FMT_5D8	  3
727c478bd9Sstevel@tonic-gate #define	FMT_5D4	  4
737c478bd9Sstevel@tonic-gate #define	FMT_5D16  5
747c478bd9Sstevel@tonic-gate #define	FMT_3E	  6
757c478bd9Sstevel@tonic-gate #define	FMT_3H	  7
767c478bd9Sstevel@tonic-gate #define	FMT_3I	  8
777c478bd9Sstevel@tonic-gate #define	FMT_3M	  9
787c478bd9Sstevel@tonic-gate #define	FMT_3D	  10
797c478bd9Sstevel@tonic-gate #define	FMT_AUTO  11
807c478bd9Sstevel@tonic-gate #define	FMT_MAX	  11
817c478bd9Sstevel@tonic-gate #define	FMT_UNKWN 11
827c478bd9Sstevel@tonic-gate 
837c478bd9Sstevel@tonic-gate 
847c478bd9Sstevel@tonic-gate /*
857c478bd9Sstevel@tonic-gate  * Mini- and Micro- Diskettes Attributes Structure
867c478bd9Sstevel@tonic-gate  */
877c478bd9Sstevel@tonic-gate struct fdattr {
887c478bd9Sstevel@tonic-gate 	ushort_t fda_rotatespd;		/* rotational speed */
897c478bd9Sstevel@tonic-gate 	ushort_t fda_intrlv;		/* interleave factor */
907c478bd9Sstevel@tonic-gate 
917c478bd9Sstevel@tonic-gate 	uchar_t fda_gapl;		/* gap 3 length */
927c478bd9Sstevel@tonic-gate 	uchar_t fda_gapf;		/* gap 3 length for format */
937c478bd9Sstevel@tonic-gate };
947c478bd9Sstevel@tonic-gate 
957c478bd9Sstevel@tonic-gate /*
967c478bd9Sstevel@tonic-gate  * Miscellaneous
977c478bd9Sstevel@tonic-gate  */
987c478bd9Sstevel@tonic-gate #define	FDWRITE	0			/* for fdrw() flag */
997c478bd9Sstevel@tonic-gate #define	FDREAD	1			/* for fdrw() flag */
1007c478bd9Sstevel@tonic-gate #define	FDRDONE	86			/*  . read with no retries */
1017c478bd9Sstevel@tonic-gate 
1027c478bd9Sstevel@tonic-gate /*
1037c478bd9Sstevel@tonic-gate  * Per floppy-drive / diskette state structure
1047c478bd9Sstevel@tonic-gate  */
1057c478bd9Sstevel@tonic-gate 
1067c478bd9Sstevel@tonic-gate struct fdisk {
1077c478bd9Sstevel@tonic-gate 	struct fcu_obj	*d_obj;
1087c478bd9Sstevel@tonic-gate 	int		d_media;	/* drive media capacities */
1097c478bd9Sstevel@tonic-gate 	struct kstat 	*d_iostat;	/* pointer to iostat statistics */
1107c478bd9Sstevel@tonic-gate 	int		d_bpsshf;	/* shift count for bytes to sector */
1117c478bd9Sstevel@tonic-gate 
1127c478bd9Sstevel@tonic-gate 	ksema_t		d_ocsem;	/* sem for serializing opens/closes */
1137c478bd9Sstevel@tonic-gate 
1147c478bd9Sstevel@tonic-gate 	struct buf	*d_actf;	/* head of wait list */
1157c478bd9Sstevel@tonic-gate 	struct buf	*d_actl;	/* tail of wait list */
1167c478bd9Sstevel@tonic-gate 	struct buf	*d_current;	/* currently active buf */
1177c478bd9Sstevel@tonic-gate 	struct partition d_part[NDKMAP];	/* partitions descriptions */
1187c478bd9Sstevel@tonic-gate 
1197c478bd9Sstevel@tonic-gate 	/*
1207c478bd9Sstevel@tonic-gate 	 * Regular open type flags.
1217c478bd9Sstevel@tonic-gate 	 * Open types BLK, MNT, CHR, SWP assumed to be values 0-3.
1227c478bd9Sstevel@tonic-gate 	 */
1237c478bd9Sstevel@tonic-gate 	ulong_t	d_regopen[OTYPCNT - 1];
1247c478bd9Sstevel@tonic-gate 	ulong_t	d_lyropen[NDKMAP];	/* Layered open counters */
1257c478bd9Sstevel@tonic-gate 
1267c478bd9Sstevel@tonic-gate 	/*
1277c478bd9Sstevel@tonic-gate 	 * Exclusive open flags (per partition).
1287c478bd9Sstevel@tonic-gate 	 *
1297c478bd9Sstevel@tonic-gate 	 * The rules are that in order to open a partition exclusively,
1307c478bd9Sstevel@tonic-gate 	 * the partition must be completely closed already. Once any
1317c478bd9Sstevel@tonic-gate 	 * partition of the device is opened exclusively, no other open
1327c478bd9Sstevel@tonic-gate 	 * on that partition may succeed until the partition is closed.
1337c478bd9Sstevel@tonic-gate 	 */
1347c478bd9Sstevel@tonic-gate 	ulong_t		d_exclmask;	/* set to indicate exclusive open */
1357c478bd9Sstevel@tonic-gate 
1367c478bd9Sstevel@tonic-gate 	/*
1377c478bd9Sstevel@tonic-gate 	 * Current drive characteristics type.
1387c478bd9Sstevel@tonic-gate 	 * If -1, then it was set via an ioctl.  Note that a close
1397c478bd9Sstevel@tonic-gate 	 * and then an open loses the ioctl set characteristics.
1407c478bd9Sstevel@tonic-gate 	 */
1417c478bd9Sstevel@tonic-gate 	signed char	d_curfdtype;
1427c478bd9Sstevel@tonic-gate 	uchar_t		d_deffdtype;
1437c478bd9Sstevel@tonic-gate 
1447c478bd9Sstevel@tonic-gate 	uchar_t		d_bsec;		/* encoded bytes_per_sector */
1457c478bd9Sstevel@tonic-gate 	uchar_t		d_drate;	/* encoded data_rate */
1467c478bd9Sstevel@tonic-gate 	uchar_t		d_motor;	/* motor-on bit */
1477c478bd9Sstevel@tonic-gate 
1487c478bd9Sstevel@tonic-gate 	uchar_t		d_hutsrt;	/* encoded head unload & step_rate */
1497c478bd9Sstevel@tonic-gate 	uchar_t		d_hlt;		/* encoded head load time */
1507c478bd9Sstevel@tonic-gate 	uchar_t		d_dtl;		/* dtl code */
1517c478bd9Sstevel@tonic-gate 
1527c478bd9Sstevel@tonic-gate 	int	d_media_timeout;	/* media detection timeout */
1537c478bd9Sstevel@tonic-gate 	timeout_id_t	d_media_timeout_id; /* media detection timeout id */
1547c478bd9Sstevel@tonic-gate 	enum dkio_state d_media_state;	/* up-to-date media state */
1557c478bd9Sstevel@tonic-gate 	int		d_ejected;
1567c478bd9Sstevel@tonic-gate 	kcondvar_t	d_statecv;	/* condition var for media state */
1577c478bd9Sstevel@tonic-gate 
1587c478bd9Sstevel@tonic-gate 	ulong_t		d_vtoc_bootinfo[3];	/* from label */
1597c478bd9Sstevel@tonic-gate 	ulong_t		d_vtoc_version;
1607c478bd9Sstevel@tonic-gate 	time_t		d_vtoc_timestamp[NDKMAP];
1617c478bd9Sstevel@tonic-gate 	char		d_vtoc_volume[LEN_DKL_VVOL];
1627c478bd9Sstevel@tonic-gate 	char		d_vtoc_asciilabel[LEN_DKL_ASCII];
1637c478bd9Sstevel@tonic-gate };
1647c478bd9Sstevel@tonic-gate 
1657c478bd9Sstevel@tonic-gate 
1667c478bd9Sstevel@tonic-gate /* a place to keep some statistics on what's going on */
1677c478bd9Sstevel@tonic-gate struct fdstat {
1687c478bd9Sstevel@tonic-gate 	/* first operations */
1697c478bd9Sstevel@tonic-gate 	int rd;		/* count reads */
1707c478bd9Sstevel@tonic-gate 	int wr;		/* count writes */
1717c478bd9Sstevel@tonic-gate 	int recal;	/* count recalibrates */
1727c478bd9Sstevel@tonic-gate 	int form;	/* count format_tracks */
1737c478bd9Sstevel@tonic-gate 	int other;	/* count other ops */
1747c478bd9Sstevel@tonic-gate 
1757c478bd9Sstevel@tonic-gate 	/* then errors */
1767c478bd9Sstevel@tonic-gate 	int reset;	/* count resets */
1777c478bd9Sstevel@tonic-gate 	int to;		/* count timeouts */
1787c478bd9Sstevel@tonic-gate 	int run;	/* count overrun/underrun */
1797c478bd9Sstevel@tonic-gate 	int de;		/* count data errors */
1807c478bd9Sstevel@tonic-gate 	int bfmt;	/* count bad format errors */
1817c478bd9Sstevel@tonic-gate };
1827c478bd9Sstevel@tonic-gate 
1837c478bd9Sstevel@tonic-gate /*
1847c478bd9Sstevel@tonic-gate  * floppy disk command and status block.
1857c478bd9Sstevel@tonic-gate  *
1867c478bd9Sstevel@tonic-gate  * Needed to execute a command. Since the floppy chip is
1877c478bd9Sstevel@tonic-gate  * single threaded with respect to having only one drive
1887c478bd9Sstevel@tonic-gate  * active at a time, this block of information is only
1897c478bd9Sstevel@tonic-gate  * valid for the length of a command and gets rewritten
1907c478bd9Sstevel@tonic-gate  * for each command.
1917c478bd9Sstevel@tonic-gate  */
1927c478bd9Sstevel@tonic-gate 
1937c478bd9Sstevel@tonic-gate enum fxstate {
1947c478bd9Sstevel@tonic-gate 	FXS_START,
1957c478bd9Sstevel@tonic-gate 	FXS_MTRON,
1967c478bd9Sstevel@tonic-gate 	FXS_RCAL,
1977c478bd9Sstevel@tonic-gate 	FXS_DKCHGX,
1987c478bd9Sstevel@tonic-gate 	FXS_RESTART,
1997c478bd9Sstevel@tonic-gate 	FXS_RESEEK,
2007c478bd9Sstevel@tonic-gate 	FXS_SEEK,
2017c478bd9Sstevel@tonic-gate 	FXS_HDST,
2027c478bd9Sstevel@tonic-gate 	FXS_RDID,
2037c478bd9Sstevel@tonic-gate 	FXS_DOIT,
2047c478bd9Sstevel@tonic-gate 	FXS_DOWT,
2057c478bd9Sstevel@tonic-gate 	FXS_KILL,
2067c478bd9Sstevel@tonic-gate 	FXS_RESET,
2077c478bd9Sstevel@tonic-gate 	FXS_END
2087c478bd9Sstevel@tonic-gate };
2097c478bd9Sstevel@tonic-gate 
2107c478bd9Sstevel@tonic-gate enum fmtrstate {
2117c478bd9Sstevel@tonic-gate 	FMS_OFF,
2127c478bd9Sstevel@tonic-gate 	FMS_START,
2137c478bd9Sstevel@tonic-gate 	FMS_KILLST,
2147c478bd9Sstevel@tonic-gate 	FMS_ON,
2157c478bd9Sstevel@tonic-gate 	FMS_DELAY,
2167c478bd9Sstevel@tonic-gate 	FMS_IDLE
2177c478bd9Sstevel@tonic-gate };
2187c478bd9Sstevel@tonic-gate 
2197c478bd9Sstevel@tonic-gate enum fmtrinput {
2207c478bd9Sstevel@tonic-gate 	FMI_TIMER,
2217c478bd9Sstevel@tonic-gate 	FMI_STARTCMD,
2227c478bd9Sstevel@tonic-gate 	FMI_RSTARTCMD,
2237c478bd9Sstevel@tonic-gate 	FMI_DELAYCMD,
2247c478bd9Sstevel@tonic-gate 	FMI_IDLECMD
2257c478bd9Sstevel@tonic-gate };
2267c478bd9Sstevel@tonic-gate 
2277c478bd9Sstevel@tonic-gate struct fdcsb {
2287c478bd9Sstevel@tonic-gate 	struct buf *csb_bufp;	/* associated buf */
2297c478bd9Sstevel@tonic-gate 	ddi_dma_handle_t csb_dmahandle;
2307c478bd9Sstevel@tonic-gate 	int csb_handle_bound;		/* DMA handle has been bound */
2317c478bd9Sstevel@tonic-gate 	uint_t csb_dmacookiecnt;	/* number of DMA cookies */
2327c478bd9Sstevel@tonic-gate 	uint_t csb_dmacurrcookie;	/* current cookie number */
2337c478bd9Sstevel@tonic-gate 	uint_t csb_dmawincnt;		/* number of DMA windows */
2347c478bd9Sstevel@tonic-gate 	uint_t csb_dmacurrwin;		/* current DMA window */
2357c478bd9Sstevel@tonic-gate 	ddi_dma_cookie_t csb_dmacookie;
2367c478bd9Sstevel@tonic-gate 	enum fxstate csb_xstate;	/* Current execution state */
2377c478bd9Sstevel@tonic-gate 	enum fxstate csb_oldxs;	/* old execution state */
2387c478bd9Sstevel@tonic-gate 	uchar_t	csb_npcyl;	/* new physical cylinder number */
2397c478bd9Sstevel@tonic-gate 	uchar_t	csb_drive;	/* floppy unit number */
2407c478bd9Sstevel@tonic-gate 	uchar_t	csb_ncmds;	/* how many command bytes to send */
2417c478bd9Sstevel@tonic-gate 	uchar_t	csb_nrslts;	/* number of result bytes gotten */
2427c478bd9Sstevel@tonic-gate 	uchar_t	csb_opflags;	/* opflags, see below */
2437c478bd9Sstevel@tonic-gate 	uchar_t	csb_timer;	/* op timer, in 0.1 sec */
2447c478bd9Sstevel@tonic-gate 	uchar_t	csb_maxretry;	/* maximum retries this operation */
2457c478bd9Sstevel@tonic-gate 	uchar_t	csb_retrys;	/* how may retrys done so far */
2467c478bd9Sstevel@tonic-gate 	uchar_t	csb_ourtrys;	/* how may over/underrun retrys done so far */
2477c478bd9Sstevel@tonic-gate 	uchar_t	csb_status;	/* status returned from hwintr */
2487c478bd9Sstevel@tonic-gate 	uchar_t	csb_cmdstat;	/* if 0 then success, else failure */
2497c478bd9Sstevel@tonic-gate 	uchar_t	csb_cmd[10];	/* command to send to chip */
2507c478bd9Sstevel@tonic-gate 	uchar_t	csb_rslt[10];	/* results from chip */
2517c478bd9Sstevel@tonic-gate };
2527c478bd9Sstevel@tonic-gate 
2537c478bd9Sstevel@tonic-gate /*
2547c478bd9Sstevel@tonic-gate  * defines for csb_opflags
2557c478bd9Sstevel@tonic-gate  */
2567c478bd9Sstevel@tonic-gate #define	CSB_OFINRPT	0x01		/* generates an interrupt */
2577c478bd9Sstevel@tonic-gate #define	CSB_OFDMARD	0x02		/* uses DMA for reading */
2587c478bd9Sstevel@tonic-gate #define	CSB_OFDMAWT	0x04		/* uses DMA for writing */
2597c478bd9Sstevel@tonic-gate #define	CSB_OFRESLT	0x08		/* generates results */
2607c478bd9Sstevel@tonic-gate #define	CSB_OFRAWIOCTL	0x10		/* raw i/o control */
2617c478bd9Sstevel@tonic-gate 
2627c478bd9Sstevel@tonic-gate #define	CSB_CMDTO   0x01
2637c478bd9Sstevel@tonic-gate #define	CSB_CMDDMA  0x03
2647c478bd9Sstevel@tonic-gate #define	CSB_CMDNGNR 0x07
2657c478bd9Sstevel@tonic-gate 
2667c478bd9Sstevel@tonic-gate 
2677c478bd9Sstevel@tonic-gate /*
2687c478bd9Sstevel@tonic-gate  * 82077AA Controller modes
2697c478bd9Sstevel@tonic-gate  */
2707c478bd9Sstevel@tonic-gate enum fdcmode077 {
2717c478bd9Sstevel@tonic-gate 	FDCMODE_AT,
2727c478bd9Sstevel@tonic-gate 	FDCMODE_PS2,	/* not supported */
2737c478bd9Sstevel@tonic-gate 	FDCMODE_30
2747c478bd9Sstevel@tonic-gate };
2757c478bd9Sstevel@tonic-gate 
2767c478bd9Sstevel@tonic-gate /*
2777c478bd9Sstevel@tonic-gate  * Per controller data
2787c478bd9Sstevel@tonic-gate  */
2797c478bd9Sstevel@tonic-gate 
2807c478bd9Sstevel@tonic-gate struct fdcntlr {
2817c478bd9Sstevel@tonic-gate 	kmutex_t	c_lock;		/* controller mutex */
2827c478bd9Sstevel@tonic-gate 	kmutex_t	c_dorlock;	/* digital_output_register mutex */
2837c478bd9Sstevel@tonic-gate 	kcondvar_t	c_iocv;		/* condition var for I/O done */
2847c478bd9Sstevel@tonic-gate 	ksema_t		c_selsem;	/* sem for select unit */
285*ca925f54SGarrett D'Amore 	boolean_t	c_suspended;	/* if DDI_SUSPENDed */
2867c478bd9Sstevel@tonic-gate 
2877c478bd9Sstevel@tonic-gate 	dev_info_t	*c_dip;
2887c478bd9Sstevel@tonic-gate 	int		c_number;	/* logical controller number */
2897c478bd9Sstevel@tonic-gate 	int		c_regbase;	/* base i/o address */
2907c478bd9Sstevel@tonic-gate 	int		c_dmachan;	/* DMA channel number */
2917c478bd9Sstevel@tonic-gate 	int		c_intprio;	/* interrupt priority */
2927c478bd9Sstevel@tonic-gate 	int		c_intvec;	/* interrupt vector num */
2937c478bd9Sstevel@tonic-gate 	int		c_chip;
2947c478bd9Sstevel@tonic-gate 	enum fdcmode077	c_mode;		/* 82077 controller mode */
2957c478bd9Sstevel@tonic-gate 
2967c478bd9Sstevel@tonic-gate 	ulong_t		c_flags;	/* state information */
2977c478bd9Sstevel@tonic-gate 	struct kstat	*c_intrstat;	/* interrupt stats pointer */
2987c478bd9Sstevel@tonic-gate 	struct	fdstat	fdstats;	/* statistics */
2997c478bd9Sstevel@tonic-gate 
3007c478bd9Sstevel@tonic-gate 	ddi_iblock_cookie_t c_iblock;	/* returned from ddi_add_intr */
3017c478bd9Sstevel@tonic-gate 	ddi_idevice_cookie_t c_idevice;	/* returned from ddi_add_intr */
3027c478bd9Sstevel@tonic-gate 
3037c478bd9Sstevel@tonic-gate 	int		c_curunit;	/* current/last selected unit */
3047c478bd9Sstevel@tonic-gate 	timeout_id_t	c_timeid;	/* watchdog timer id */
3057c478bd9Sstevel@tonic-gate 
3067c478bd9Sstevel@tonic-gate 	struct	fcu_obj	*c_unit[NFDUN];	/* slave on controller */
3077c478bd9Sstevel@tonic-gate 	timeout_id_t	c_motort[NFDUN]; /* motor timer id */
3087c478bd9Sstevel@tonic-gate 	enum fmtrstate	c_mtrstate[NFDUN];
3097c478bd9Sstevel@tonic-gate 	int		c_curpcyl[NFDUN]; /* current physical cylinder */
3107c478bd9Sstevel@tonic-gate 	signed char	c_sekdir[NFDUN]; /* direction of last seek */
3117c478bd9Sstevel@tonic-gate 
3127c478bd9Sstevel@tonic-gate 	struct	fdcsb	c_csb;		/* current csb */
3137c478bd9Sstevel@tonic-gate 
3147c478bd9Sstevel@tonic-gate 	/*
3157c478bd9Sstevel@tonic-gate 	 * floppy controller register values
3167c478bd9Sstevel@tonic-gate 	 */
3177c478bd9Sstevel@tonic-gate 	uchar_t		c_digout;
3187c478bd9Sstevel@tonic-gate 	uchar_t		c_drate;	/* only 82072 and 82077AA controllers */
3197c478bd9Sstevel@tonic-gate 	uchar_t		c_config;	/* DSR on PC/AT with 8272A */
3207c478bd9Sstevel@tonic-gate 	uchar_t		c_mstat;
3217c478bd9Sstevel@tonic-gate 	uchar_t		c_data;
3227c478bd9Sstevel@tonic-gate 	uchar_t		c_digin;
3237c478bd9Sstevel@tonic-gate 
3247c478bd9Sstevel@tonic-gate 	uchar_t		c_bsec;		/* encoded bytes_per_sector */
3257c478bd9Sstevel@tonic-gate 	uchar_t		c_hutsrt;	/* encoded head unload & step_rate */
3267c478bd9Sstevel@tonic-gate 	uchar_t		c_hlt;		/* encoded head load time */
3277c478bd9Sstevel@tonic-gate };
3287c478bd9Sstevel@tonic-gate 
3297c478bd9Sstevel@tonic-gate /*
3307c478bd9Sstevel@tonic-gate  * Controller flags
3317c478bd9Sstevel@tonic-gate  */
3327c478bd9Sstevel@tonic-gate #define	FCFLG_BUSY	0x01	/* operation in progress */
3337c478bd9Sstevel@tonic-gate #define	FCFLG_WANT	0x02	/* csb structure wanted */
3347c478bd9Sstevel@tonic-gate #define	FCFLG_WAITMR	0x10	/* waiting for motor to start I/O */
3357c478bd9Sstevel@tonic-gate #define	FCFLG_WAITING	0x20	/* waiting on I/O completion */
3367c478bd9Sstevel@tonic-gate #define	FCFLG_TIMEOUT	0x80	/* the current operation just timed out */
3377c478bd9Sstevel@tonic-gate #define	FCFLG_DSOUT	0x100	/* DENSEL ouput is in use for speed ctl */
3387c478bd9Sstevel@tonic-gate #define	FCFLG_3DMODE	0x800	/* ctlr is 3D Mode capable */
3397c478bd9Sstevel@tonic-gate 
3407c478bd9Sstevel@tonic-gate 
3417c478bd9Sstevel@tonic-gate /*
3427c478bd9Sstevel@tonic-gate  * FDC operations
3437c478bd9Sstevel@tonic-gate  */
3447c478bd9Sstevel@tonic-gate 
3457c478bd9Sstevel@tonic-gate struct fcobjops {
3467c478bd9Sstevel@tonic-gate 	int	(*fco_abort)();		/* controller abort */
3477c478bd9Sstevel@tonic-gate 	int	(*fco_dkinfo)();	/* get disk controller info */
3487c478bd9Sstevel@tonic-gate 
3497c478bd9Sstevel@tonic-gate 	int	(*fco_select)();	/* select / deselect unit */
3507c478bd9Sstevel@tonic-gate 	int	(*fco_getchng)();	/* get media change */
3517c478bd9Sstevel@tonic-gate 	int	(*fco_resetchng)();	/* reset media change */
3527c478bd9Sstevel@tonic-gate 	int	(*fco_rcseek)();	/* recal / seek */
3537c478bd9Sstevel@tonic-gate 	int	(*fco_rwbuf)();		/* read /write request */
3547c478bd9Sstevel@tonic-gate 	int	(*fco_rw)();		/* read /write sector */
3557c478bd9Sstevel@tonic-gate 	int	(*fco_format)();	/* format track */
3567c478bd9Sstevel@tonic-gate 	int	(*fco_rwioctl)();	/* raw ioctl */
3577c478bd9Sstevel@tonic-gate };
3587c478bd9Sstevel@tonic-gate 
3597c478bd9Sstevel@tonic-gate /*
3607c478bd9Sstevel@tonic-gate  * FDC unit object
3617c478bd9Sstevel@tonic-gate  */
3627c478bd9Sstevel@tonic-gate 
3637c478bd9Sstevel@tonic-gate struct fcu_obj {
3647c478bd9Sstevel@tonic-gate 	ulong_t		fj_flags;	/* state information */
3657c478bd9Sstevel@tonic-gate 	kmutex_t 	fj_lock;	/* unit mutex */
3667c478bd9Sstevel@tonic-gate 	caddr_t		fj_data;
3677c478bd9Sstevel@tonic-gate 	struct fd_drive *fj_drive;	/* pointer to drive characteristics */
3687c478bd9Sstevel@tonic-gate 	struct fd_char	*fj_chars;	/* ptr to diskette characteristics */
3697c478bd9Sstevel@tonic-gate 	struct fdattr	*fj_attr;	/* additional diskette attributes */
3707c478bd9Sstevel@tonic-gate 	dev_info_t	*fj_dip;
3717c478bd9Sstevel@tonic-gate 	ushort_t	fj_rotspd;	/* rotational speed */
3727c478bd9Sstevel@tonic-gate 	ulong_t		fj_unit;
3737c478bd9Sstevel@tonic-gate 	struct fcobjops *fj_ops;
3747c478bd9Sstevel@tonic-gate 	struct fdcntlr	*fj_fdc;
3757c478bd9Sstevel@tonic-gate 	ddi_iblock_cookie_t *fj_iblock;
3767c478bd9Sstevel@tonic-gate };
3777c478bd9Sstevel@tonic-gate 
3787c478bd9Sstevel@tonic-gate /* unit flags (state info) */
3797c478bd9Sstevel@tonic-gate #define	FUNIT_DRVATCH		0x001	/* this is drive present */
3807c478bd9Sstevel@tonic-gate #define	FUNIT_WPROT		0x004	/* diskette is read only */
3817c478bd9Sstevel@tonic-gate #define	FUNIT_CHAROK		0x010	/* characteristics are known */
3827c478bd9Sstevel@tonic-gate #define	FUNIT_LABELOK		0x020	/* label was read from disk */
3837c478bd9Sstevel@tonic-gate #define	FUNIT_UNLABELED		0x040	/* no label using default */
3847c478bd9Sstevel@tonic-gate #define	FUNIT_CHANGED		0x100	/* diskette was changed after open */
3857c478bd9Sstevel@tonic-gate #define	FUNIT_CHGDET		0x200	/* diskette removal was detected */
3867c478bd9Sstevel@tonic-gate #define	FUNIT_3DMODE		0x4000	/* unit is in fast speed mode */
3877c478bd9Sstevel@tonic-gate #define	FUNIT_BUSY		0x8000	/* unit is busy */
3887c478bd9Sstevel@tonic-gate 
3897c478bd9Sstevel@tonic-gate #ifdef _VPIX
3907c478bd9Sstevel@tonic-gate #define	DRV_NONE	0x00
3917c478bd9Sstevel@tonic-gate #define	DRV_DBL		0x01
3927c478bd9Sstevel@tonic-gate #define	DRV_QUAD	0x02
3937c478bd9Sstevel@tonic-gate #define	DRV_720		0x04	/* LOW_35 gets changed to this for or'ing */
3947c478bd9Sstevel@tonic-gate #define	DRV_144		0x08	/* HI35 gets changed to this for or'ing */
3957c478bd9Sstevel@tonic-gate 
3967c478bd9Sstevel@tonic-gate /* ioctl numbers used by VPIX */
3977c478bd9Sstevel@tonic-gate #define	FIOC		('F'<<8)
3987c478bd9Sstevel@tonic-gate #define	F_DTYP		(FIOC|60)	/* returns fd_drvtype */
3997c478bd9Sstevel@tonic-gate #define	F_FCR		(FIOC|61)	/* output to Floppy Control Register */
4007c478bd9Sstevel@tonic-gate #define	F_DOR		(FIOC|62)	/* output to Digital Output Register */
4017c478bd9Sstevel@tonic-gate #define	F_RAW		(FIOC|63)	/* general raw controller interface */
4027c478bd9Sstevel@tonic-gate #endif
4037c478bd9Sstevel@tonic-gate 
4047c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
4057c478bd9Sstevel@tonic-gate }
4067c478bd9Sstevel@tonic-gate #endif
4077c478bd9Sstevel@tonic-gate 
4087c478bd9Sstevel@tonic-gate #endif	/* !_SYS_FDC_H */
409