xref: /illumos-gate/usr/src/uts/common/sys/fdio.h (revision 2d6eb4a5)
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 2004 Sun Microsystems, Inc.  All rights reserved.
24*7c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
25*7c478bd9Sstevel@tonic-gate  */
26*7c478bd9Sstevel@tonic-gate 
27*7c478bd9Sstevel@tonic-gate #ifndef _SYS_FDIO_H
28*7c478bd9Sstevel@tonic-gate #define	_SYS_FDIO_H
29*7c478bd9Sstevel@tonic-gate 
30*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
31*7c478bd9Sstevel@tonic-gate extern "C" {
32*7c478bd9Sstevel@tonic-gate #endif
33*7c478bd9Sstevel@tonic-gate 
34*7c478bd9Sstevel@tonic-gate /*
35*7c478bd9Sstevel@tonic-gate  * Floppy Disk Characteristic Structure
36*7c478bd9Sstevel@tonic-gate  */
37*7c478bd9Sstevel@tonic-gate struct fd_char {
38*7c478bd9Sstevel@tonic-gate 	uchar_t fdc_medium;		/* medium type. */
39*7c478bd9Sstevel@tonic-gate 	int fdc_transfer_rate;		/* transfer rate */
40*7c478bd9Sstevel@tonic-gate 	int fdc_ncyl;			/* number of cylinders */
41*7c478bd9Sstevel@tonic-gate 	int fdc_nhead;			/* number of heads */
42*7c478bd9Sstevel@tonic-gate 	int fdc_sec_size;		/* sector size */
43*7c478bd9Sstevel@tonic-gate 	int fdc_secptrack;		/* sectors per track */
44*7c478bd9Sstevel@tonic-gate 	int fdc_steps;			/* number of steps per  */
45*7c478bd9Sstevel@tonic-gate };
46*7c478bd9Sstevel@tonic-gate 
47*7c478bd9Sstevel@tonic-gate /*
48*7c478bd9Sstevel@tonic-gate  * Floppy State Structure
49*7c478bd9Sstevel@tonic-gate  */
50*7c478bd9Sstevel@tonic-gate struct fd_state {
51*7c478bd9Sstevel@tonic-gate 	int	fds_bsec;		/* bytes per sector */
52*7c478bd9Sstevel@tonic-gate 	int 	fds_strack;		/* sectors per track */
53*7c478bd9Sstevel@tonic-gate 	int	fds_step;		/* step rate */
54*7c478bd9Sstevel@tonic-gate 	int	fds_rate;		/* data rate */
55*7c478bd9Sstevel@tonic-gate 	int	fds_error;		/* error returned by controller */
56*7c478bd9Sstevel@tonic-gate };
57*7c478bd9Sstevel@tonic-gate 
58*7c478bd9Sstevel@tonic-gate /*
59*7c478bd9Sstevel@tonic-gate  * Used by FDGETCHANGE, return state of the sense disk change bit.
60*7c478bd9Sstevel@tonic-gate  */
61*7c478bd9Sstevel@tonic-gate #define	FDGC_HISTORY	0x01	/* disk has changed since last i/o */
62*7c478bd9Sstevel@tonic-gate #define	FDGC_CURRENT	0x02	/* current state of disk change */
63*7c478bd9Sstevel@tonic-gate #define	FDGC_CURWPROT	0x10	/* current state of write protect */
64*7c478bd9Sstevel@tonic-gate #define	FDGC_DETECTED	0x20	/* previous state of DISK CHANGE */
65*7c478bd9Sstevel@tonic-gate 
66*7c478bd9Sstevel@tonic-gate /*
67*7c478bd9Sstevel@tonic-gate  * Used by FD{G, S}ETDRIVECHAR
68*7c478bd9Sstevel@tonic-gate  */
69*7c478bd9Sstevel@tonic-gate struct fd_drive {
70*7c478bd9Sstevel@tonic-gate 	int fdd_ejectable;	/* does the drive support eject? */
71*7c478bd9Sstevel@tonic-gate 	int fdd_maxsearch;	/* size of per-unit search table */
72*7c478bd9Sstevel@tonic-gate 
73*7c478bd9Sstevel@tonic-gate 	int fdd_writeprecomp;	/* cyl to start write prcompensation */
74*7c478bd9Sstevel@tonic-gate 	int fdd_writereduce;	/* cyl to start recucing write current */
75*7c478bd9Sstevel@tonic-gate 	int fdd_stepwidth;	/* width of step pulse in 1 us units */
76*7c478bd9Sstevel@tonic-gate 	int fdd_steprate;	/* step rate in 100 us units */
77*7c478bd9Sstevel@tonic-gate 	int fdd_headsettle;	/* delay, in 100 us units */
78*7c478bd9Sstevel@tonic-gate 	int fdd_headload;	/* delay, in 100 us units */
79*7c478bd9Sstevel@tonic-gate 	int fdd_headunload;	/* delay, in 100 us units */
80*7c478bd9Sstevel@tonic-gate 	int fdd_motoron;	/* delay, in 100 ms units */
81*7c478bd9Sstevel@tonic-gate 	int fdd_motoroff;	/* delay, in 100 ms units */
82*7c478bd9Sstevel@tonic-gate 	int fdd_precomplevel;	/* bit shift, in nano-secs */
83*7c478bd9Sstevel@tonic-gate 	int fdd_pins;		/* defines meaning of pin 1, 2, 4, and 34 */
84*7c478bd9Sstevel@tonic-gate 	int fdd_flags;		/* TRUE READY, Starting Sector #, & Motor On */
85*7c478bd9Sstevel@tonic-gate };
86*7c478bd9Sstevel@tonic-gate 
87*7c478bd9Sstevel@tonic-gate /*
88*7c478bd9Sstevel@tonic-gate  * fdd_flags:
89*7c478bd9Sstevel@tonic-gate  */
90*7c478bd9Sstevel@tonic-gate #define	FDD_READY	0x1
91*7c478bd9Sstevel@tonic-gate #define	FDD_MOTON	0x2
92*7c478bd9Sstevel@tonic-gate #define	FDD_POLLABLE	0x4
93*7c478bd9Sstevel@tonic-gate 
94*7c478bd9Sstevel@tonic-gate /*
95*7c478bd9Sstevel@tonic-gate  * Used by FD{G, S}ETSEARCH
96*7c478bd9Sstevel@tonic-gate  */
97*7c478bd9Sstevel@tonic-gate struct fd_search {
98*7c478bd9Sstevel@tonic-gate 	int	fds_numentries; /* number of elements in the table */
99*7c478bd9Sstevel@tonic-gate 	struct	fd_char *fds_search;
100*7c478bd9Sstevel@tonic-gate };
101*7c478bd9Sstevel@tonic-gate 
102*7c478bd9Sstevel@tonic-gate /*
103*7c478bd9Sstevel@tonic-gate  * Used by FDIOCMD
104*7c478bd9Sstevel@tonic-gate  */
105*7c478bd9Sstevel@tonic-gate struct fd_cmd {
106*7c478bd9Sstevel@tonic-gate 	ushort_t	fdc_cmd;	/* command to be executed */
107*7c478bd9Sstevel@tonic-gate 	int		fdc_flags;	/* execution flags */
108*7c478bd9Sstevel@tonic-gate 	daddr_t		fdc_blkno;	/* disk address for command */
109*7c478bd9Sstevel@tonic-gate 	int		fdc_secnt;	/* sector count for command */
110*7c478bd9Sstevel@tonic-gate 	caddr_t		fdc_bufaddr;	/* user's buffer address */
111*7c478bd9Sstevel@tonic-gate 	uint_t		fdc_buflen;	/* size of user's buffer */
112*7c478bd9Sstevel@tonic-gate };
113*7c478bd9Sstevel@tonic-gate 
114*7c478bd9Sstevel@tonic-gate #if defined(_SYSCALL32)
115*7c478bd9Sstevel@tonic-gate struct fd_cmd32 {
116*7c478bd9Sstevel@tonic-gate 	ushort_t	fdc_cmd;	/* command to be executed */
117*7c478bd9Sstevel@tonic-gate 	int		fdc_flags;	/* execution flags */
118*7c478bd9Sstevel@tonic-gate 	daddr32_t	fdc_blkno;	/* disk address for command */
119*7c478bd9Sstevel@tonic-gate 	int		fdc_secnt;	/* sector count for command */
120*7c478bd9Sstevel@tonic-gate 	caddr32_t	fdc_bufaddr;	/* user's buffer address */
121*7c478bd9Sstevel@tonic-gate 	uint_t		fdc_buflen;	/* size of user's buffer */
122*7c478bd9Sstevel@tonic-gate };
123*7c478bd9Sstevel@tonic-gate #endif /* _SYSCALL32 */
124*7c478bd9Sstevel@tonic-gate 
125*7c478bd9Sstevel@tonic-gate /*
126*7c478bd9Sstevel@tonic-gate  * Floppy commands
127*7c478bd9Sstevel@tonic-gate  */
128*7c478bd9Sstevel@tonic-gate #define	FDCMD_WRITE		1
129*7c478bd9Sstevel@tonic-gate #define	FDCMD_READ		2
130*7c478bd9Sstevel@tonic-gate #define	FDCMD_SEEK		3
131*7c478bd9Sstevel@tonic-gate #define	FDCMD_REZERO		4
132*7c478bd9Sstevel@tonic-gate #define	FDCMD_FORMAT_UNIT 	5
133*7c478bd9Sstevel@tonic-gate #define	FDCMD_FORMAT_TRACK	6
134*7c478bd9Sstevel@tonic-gate 
135*7c478bd9Sstevel@tonic-gate /*
136*7c478bd9Sstevel@tonic-gate  * Execution flags.
137*7c478bd9Sstevel@tonic-gate  */
138*7c478bd9Sstevel@tonic-gate #define	FD_SILENT	0x01		/* no error messages */
139*7c478bd9Sstevel@tonic-gate #define	FD_DIAGNOSE	0x02		/* fail if any error occurs */
140*7c478bd9Sstevel@tonic-gate #define	FD_ISOLATE	0x04		/* isolate from normal commands */
141*7c478bd9Sstevel@tonic-gate #define	FD_READ		0x08		/* read from device */
142*7c478bd9Sstevel@tonic-gate #define	FD_WRITE	0x10		/* write to  device */
143*7c478bd9Sstevel@tonic-gate 
144*7c478bd9Sstevel@tonic-gate /*
145*7c478bd9Sstevel@tonic-gate  * Used by FDRAW
146*7c478bd9Sstevel@tonic-gate  */
147*7c478bd9Sstevel@tonic-gate struct fd_raw {
148*7c478bd9Sstevel@tonic-gate 	char	fdr_cmd[10];	/* user-supplied command bytes */
149*7c478bd9Sstevel@tonic-gate 	short   fdr_cnum;	/* number of command bytes */
150*7c478bd9Sstevel@tonic-gate 	char    fdr_result[10];	/* controller-supplied result bytes */
151*7c478bd9Sstevel@tonic-gate 	ushort_t fdr_nbytes;	/* number to transfer if read/write command */
152*7c478bd9Sstevel@tonic-gate 	caddr_t	fdr_addr;	/* where to transfer if read/write command */
153*7c478bd9Sstevel@tonic-gate };
154*7c478bd9Sstevel@tonic-gate 
155*7c478bd9Sstevel@tonic-gate #ifdef _SYSCALL32
156*7c478bd9Sstevel@tonic-gate 
157*7c478bd9Sstevel@tonic-gate struct fd_raw32 {
158*7c478bd9Sstevel@tonic-gate 	char	fdr_cmd[10];	/* user-supplied command bytes */
159*7c478bd9Sstevel@tonic-gate 	short   fdr_cnum;	/* number of command bytes */
160*7c478bd9Sstevel@tonic-gate 	char    fdr_result[10];	/* controller-supplied result bytes */
161*7c478bd9Sstevel@tonic-gate 	ushort_t fdr_nbytes;	/* number to transfer if read/write command */
162*7c478bd9Sstevel@tonic-gate 	caddr32_t fdr_addr;	/* where to transfer if read/write command */
163*7c478bd9Sstevel@tonic-gate };
164*7c478bd9Sstevel@tonic-gate 
165*7c478bd9Sstevel@tonic-gate #endif	/* _SYSCALL32 */
166*7c478bd9Sstevel@tonic-gate 
167*7c478bd9Sstevel@tonic-gate 
168*7c478bd9Sstevel@tonic-gate /*
169*7c478bd9Sstevel@tonic-gate  * Floppy raw commands
170*7c478bd9Sstevel@tonic-gate  */
171*7c478bd9Sstevel@tonic-gate #define	FDRAW_SPECIFY	0x03
172*7c478bd9Sstevel@tonic-gate #define	FDRAW_READID	0x0a
173*7c478bd9Sstevel@tonic-gate #define	FDRAW_SENSE_DRV	0x04
174*7c478bd9Sstevel@tonic-gate #define	FDRAW_REZERO	0x07
175*7c478bd9Sstevel@tonic-gate #define	FDRAW_SEEK	0x0f
176*7c478bd9Sstevel@tonic-gate #define	FDRAW_SENSE_INT	0x08
177*7c478bd9Sstevel@tonic-gate #define	FDRAW_FORMAT	0x0d
178*7c478bd9Sstevel@tonic-gate #define	FDRAW_READTRACK	0x02
179*7c478bd9Sstevel@tonic-gate #define	FDRAW_WRCMD	0x05
180*7c478bd9Sstevel@tonic-gate #define	FDRAW_RDCMD	0x06
181*7c478bd9Sstevel@tonic-gate #define	FDRAW_WRITEDEL	0x09
182*7c478bd9Sstevel@tonic-gate #define	FDRAW_READDEL	0x0c
183*7c478bd9Sstevel@tonic-gate 
184*7c478bd9Sstevel@tonic-gate 
185*7c478bd9Sstevel@tonic-gate /*
186*7c478bd9Sstevel@tonic-gate  * Disk io control commands
187*7c478bd9Sstevel@tonic-gate  */
188*7c478bd9Sstevel@tonic-gate #define	FDIOC		(0x04 << 8)
189*7c478bd9Sstevel@tonic-gate #define	FDIOGCHAR	(FDIOC|51)		/* GetCharacteristics */
190*7c478bd9Sstevel@tonic-gate #define	FDIOSCHAR	(FDIOC|52)		/* SetCharacteristics */
191*7c478bd9Sstevel@tonic-gate #define	FDEJECT		(FDIOC|53)		/* Eject floppy disk */
192*7c478bd9Sstevel@tonic-gate #define	FDGETCHANGE	(FDIOC|54)		/* Get diskchng stat */
193*7c478bd9Sstevel@tonic-gate #define	FDGETDRIVECHAR	(FDIOC|55)		/* Get drivechar */
194*7c478bd9Sstevel@tonic-gate #define	FDSETDRIVECHAR	(FDIOC|56)		/* Set drivechar */
195*7c478bd9Sstevel@tonic-gate #define	FDGETSEARCH	(FDIOC|57)		/* Get search tbl */
196*7c478bd9Sstevel@tonic-gate #define	FDSETSEARCH	(FDIOC|58)		/* Set search tbl */
197*7c478bd9Sstevel@tonic-gate #define	FDIOCMD		(FDIOC|59)		/* Floppy command */
198*7c478bd9Sstevel@tonic-gate #define	FDRAW		(FDIOC|70)		/* ECDstyle genericcmd */
199*7c478bd9Sstevel@tonic-gate #define	FDDEFGEOCHAR	(FDIOC|86)		/* restore default geometry */
200*7c478bd9Sstevel@tonic-gate 						/* & characteristics */
201*7c478bd9Sstevel@tonic-gate 
202*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
203*7c478bd9Sstevel@tonic-gate }
204*7c478bd9Sstevel@tonic-gate #endif
205*7c478bd9Sstevel@tonic-gate 
206*7c478bd9Sstevel@tonic-gate #endif	/* _SYS_FDIO_H */
207