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