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