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