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