xref: /illumos-gate/usr/src/man/man4i/fdio.4i (revision 0250c53ad267726f2438e3c6556199a0bbf588a2)
1.\"  Copyright (c) 2001, Sun Microsystems, Inc.  All Rights Reserved
2.\"  Copyright (c) 2017, Joyent, Inc.
3.\" The contents of this file are subject to the terms of the
4.\" Common Development and Distribution License (the "License").
5.\" You may not use this file except in compliance with the License.
6.\"
7.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
8.\" or http://www.opensolaris.org/os/licensing.
9.\" See the License for the specific language governing permissions
10.\" and limitations under the License.
11.\"
12.\" When distributing Covered Code, include this CDDL HEADER in each
13.\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
14.\" If applicable, add the following below this CDDL HEADER, with the
15.\" fields enclosed by brackets "[]" replaced with your own identifying
16.\" information: Portions Copyright [yyyy] [name of copyright owner]
17.Dd March 13, 2022
18.Dt FDIO 4I
19.Os
20.Sh NAME
21.Nm fdio
22.Nd floppy disk control operations
23.Sh SYNOPSIS
24.In sys/fdio.h
25.Sh DESCRIPTION
26The Solaris floppy driver supports a set of
27.Xr ioctl 2
28requests for getting and setting the floppy drive characteristics.
29Basic to these
30.Xr ioctl 2
31requests are the definitions in
32.In sys/fdio.h .
33.Sh IOCTLS
34The following
35.Xr ioctl 2
36requests are available on the Solaris floppy driver.
37.Bl -tag -width FDDEFGEOCHAR
38.It Dv FDDEFGEOCHAR
39x86 based systems:  This
40.Xr ioctl 2
41forces the floppy driver to restore
42the diskette and drive characteristics and geometry, and partition information
43to default values based on the device configuration.
44.It Dv FDGETCHANGE
45The argument is a pointer to an
46.Vt int .
47This
48.Xr ioctl 2
49returns the status of the diskette-changed signal from the floppy interface.
50The following defines are provided for cohesion.
51.El
52.Pp
53Note: For x86 based systems, use
54.Dv FDGC_DETECTED
55(which is available only on x86 based systems) instead of
56.Dv FDGC_HISTORY .
57.Bd -literal -offset 2n
58/*
59 * Used by FDGETCHANGE, returned state of the sense disk change bit.
60 */
61#define FDGC_HISTORY  0x01	 /*
62				  * disk has changed since insertion or
63                                  * last FDGETCHANGE call
64				  */
65#define FDGC_CURRENT  0x02	 /*
66				  * if set, indicates drive has floppy,
67                                  * otherwise, drive is empty
68				  */
69#define FDGC_CURWPROT 0x10	 /* current state of write protect */
70#define FDGC_DETECTED 0x20	 /* previous state of DISK CHANGE */
71.Ed
72.Bl -tag -width FDIOGCHAR
73.It Dv FDIOGCHAR
74The argument is a pointer to an
75.Vt fd_char
76structure (described below).
77This
78.Xr ioctl 2
79gets the characteristics of the floppy diskette from the floppy controller.
80.It Dv FDIOSCHAR
81The argument is a pointer to an
82.Vt fd_char
83structure (described below).
84This
85.Xr ioctl 2
86sets the characteristics of the floppy diskette for the floppy controller.
87Typical values in the
88.Vt fd_char
89structure for a high density diskette:
90.Bl -column fdc_stransfer_rate value "{ This field doesn't apply. }"
91.It Field Ta Value Ta
92.It fdc_medium Ta 0 Ta
93.It fdc_transfer_rate Ta 500 Ta
94.It fdc_ncyl Ta 80 Ta
95.It fdc_nhead Ta 2 Ta
96.It fdc_sec_size Ta 512 Ta
97.It fdc_secptrack Ta 18 Ta
98.It fdc_steps Ta -1 Ta { This field doesn't apply. }
99.El
100.El
101.Bd -literal -offset 2n
102/*
103 * Floppy characteristics
104 */
105struct fd_char {
106 uchar_t fdc_medium;    /* equals 1 if floppy is medium density format */
107 int fdc_transfer_rate; /* transfer rate */
108 int fdc_ncyl;          /* number of cylinders */
109 int fdc_nhead;         /* number of heads */
110 int fdc_sec_size;      /* sector size */
111 int fdc_secptrack;     /* sectors per track */
112 int fdc_steps;         /* no. of steps per data track */
113};
114.Ed
115.Bl -tag -width FDGETDRIVECHAR
116.It Dv FDGETDRIVECHAR
117The argument to this
118.Xr ioctl 2
119is a pointer to an
120.Vt fd_drive
121structure (described below).
122This
123.Xr ioctl 2
124gets the characteristics of the floppy drive from the floppy controller.
125.It Dv FDSETDRIVECHAR
126x86 based systems:  The argument to this
127.Xr ioctl 2
128is a pointer to an
129.Vt fd_drive
130structure (described below).
131This
132.Xr ioctl 2
133sets the characteristics of the floppy drive for the floppy controller.
134Only
135.Fa fdd_steprate ,
136.Fa fdd_headsettle ,
137.Fa fdd_motoron ,
138and
139.Fa fdd_motoroff
140are actually used by the floppy disk driver.
141.El
142.Bd -literal -offset 2n
143/*
144 * Floppy Drive characteristics
145 */
146struct fd_drive {
147    int	fdd_ejectable;    /* does the drive support eject? */
148    int	fdd_maxsearch;    /* size of per-unit search table */
149    int	fdd_writeprecomp; /* cyl to start write precompensation */
150    int	fdd_writereduce;  /* cyl to start reducing write current */
151    int	fdd_stepwidth;    /* width of step pulse in 1 us units */
152    int	fdd_steprate;     /* step rate in 100 us units */
153    int	fdd_headsettle;   /* delay, in 100 us units */
154    int	fdd_headload;     /* delay, in 100 us units */
155    int	fdd_headunload;   /* delay, in 100 us units */
156    int	fdd_motoron;      /* delay, in 100 ms units */
157    int	fdd_motoroff;     /* delay, in 100 ms units */
158    int	fdd_precomplevel; /* bit shift, in nano-secs */
159    int	fdd_pins;         /* defines meaning of pin 1, 2, 4 and 34 */
160    int	fdd_flags;        /* TRUE READY, Starting Sector #, & Motor On */
161};
162.Ed
163.Bl -tag -width FDGETSEARCH
164.It Dv FDGETSEARCH
165Not available.
166.It Dv FDSETSEARCH
167Not available.
168.It Dv FDEJECT
169SPARC:  This
170.Xr ioctl 2
171requests the floppy drive to eject the diskette.
172.It Dv FDIOCMD
173The argument is a pointer to an
174.Vt fd_cmd
175structure (described below).
176This
177.Xr ioctl 2
178allows access to the floppy diskette using the floppy device driver.
179Only the
180.Dv FDCMD_WRITE ,
181.Dv FDCMD_READ ,
182and
183.Dv FDCMD_FORMAT_TRACK
184commands are currently available.
185.El
186.Bd -literal -offset 2n
187struct fd_cmd {
188	ushort_t fdc_cmd;      /* command to be executed */
189	int      fdc_flags;    /* execution flags (x86 only) */
190	daddr_t  fdc_blkno;    /* disk address for command */
191	int      fdc_secnt;    /* sector count for command */
192	caddr_t  fdc_bufaddr;  /* user's buffer address */
193	uint_t   fdc_buflen;   /* size of user's buffer */
194};
195.Ed
196.Pp
197Please note that the
198.Fa fdc_buflen
199field is currently unused.
200The
201.Fa fdc_secnt
202field is used to calculate the transfer size, and the buffer is
203assumed to be large enough to accommodate the transfer.
204.Bd -literal -offset 2n
205/*
206 * Floppy commands
207 */
208#define	FDCMD_WRITE	1
209#define	FDCMD_READ	2
210#define	FDCMD_SEEK	3
211#define	FDCMD_REZERO	4
212#define	FDCMD_FORMAT_UNIT	5
213#define	FDCMD_FORMAT_TRACK	6
214.Ed
215.Bl -tag -width FDRAW
216.It Dv FDRAW
217The argument is a pointer to an
218.Vt fd_raw
219structure (described below).
220This
221.Xr ioctl 2
222allows direct control of the floppy drive using the floppy controller.
223Refer to the appropriate floppy-controller data sheet for full
224details on required command bytes and returned result bytes.
225The following commands are supported.
226.El
227.Bd -literal -offset 2n
228/*
229 * Floppy raw commands
230 */
231#define FDRAW_SPECIFY	0x03
232#define FDRAW_READID	0x0a	(x86 only)
233#define FDRAW_SENSE_DRV	0x04
234#define FDRAW_REZERO	0x07
235#define FDRAW_SEEK	0x0f
236#define FDRAW_SENSE_INT	0x08	(x86 only)
237#define FDRAW_FORMAT	0x0d
238#define FDRAW_READTRACK	0x02
239#define FDRAW_WRCMD	0x05
240#define FDRAW_RDCMD	0x06
241#define FDRAW_WRITEDEL	0x09
242#define FDRAW_READDEL   0x0c
243.Ed
244.Pp
245Please note that when using
246.Dv FDRAW_SEEK
247or
248.Dv FDRAW_REZERO ,
249the driver automatically issues a
250.Dv FDRAW_SENSE_INT
251command to clear the interrupt from the
252.Dv FDRAW_SEEK
253or the
254.Dv FDRAW_REZERO .
255The result bytes returned by these commands are the results from the
256.Dv DRAW_SENSE_INT
257command.
258Please see the floppy-controller data sheet for
259more details on
260.Dv FDRAW_SENSE_INT .
261.Bd -literal -offset 2n
262/*
263 * Used by FDRAW
264 */
265struct    fd_raw {
266   char     fdr_cmd[10];   /* user-supplied command bytes */
267   short    fdr_cnum;      /* number of command bytes */
268   char     fdr_result[10];  /* controller-supplied result bytes */
269   ushort_t fdr_nbytes;    /* number to transfer if read/write command */
270   char     *fdr_addr;     /* where to transfer if read/write command */
271};
272.Ed
273.Sh SEE ALSO
274.Xr ioctl 2 ,
275.Xr fd 4D ,
276.Xr dkio 4I ,
277.Xr hdio 4I
278