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 October 22, 2017
  18 .Dt FDIO 7I
  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
  26 The Solaris floppy driver supports a set of
  27 .Xr ioctl 2
  28 requests for getting and setting the floppy drive characteristics.
  29 Basic to these
  30 .Xr ioctl 2
  31 requests are the definitions in
  32 .In sys/fdio.h .
  33 .Sh IOCTLS
  34 The following
  35 .Xr ioctl 2
  36 requests are available on the Solaris floppy driver.
  37 .Bl -tag -width FDDEFGEOCHAR
  38 .It Dv FDDEFGEOCHAR
  39 x86 based systems:  This
  40 .Xr ioctl 2
  41 forces the floppy driver to restore
  42 the diskette and drive characteristics and geometry, and partition information
  43 to default values based on the device configuration.
  44 .It Dv FDGETCHANGE
  45 The argument is a pointer to an
  46 .Vt int .
  47 This
  48 .Xr ioctl 2
  49 returns the status of the diskette-changed signal from the floppy interface.
  50 The following defines are provided for cohesion.
  51 .El
  52 .Pp
  53 Note: 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
  74 The argument is a pointer to an
  75 .Vt fd_char
  76 structure (described below).
  77 This
  78 .Xr ioctl 2
  79 gets the characteristics of the floppy diskette from the floppy controller.
  80 .It Dv FDIOSCHAR
  81 The argument is a pointer to an
  82 .Vt fd_char
  83 structure (described below).
  84 This
  85 .Xr ioctl 2
  86 sets the characteristics of the floppy diskette for the floppy controller.
  87 Typical values in the
  88 .Vt fd_char
  89 structure 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  */
 105 struct 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
 117 The argument to this
 118 .Xr ioctl 2
 119 is a pointer to an
 120 .Vt fd_drive
 121 structure (described below).
 122 This
 123 .Xr ioctl 2
 124 gets the characteristics of the floppy drive from the floppy controller.
 125 .It Dv FDSETDRIVECHAR
 126 x86 based systems:  The argument to this
 127 .Xr ioctl 2
 128 is a pointer to an
 129 .Vt fd_drive
 130 structure (described below).
 131 This
 132 .Xr ioctl 2
 133 sets the characteristics of the floppy drive for the floppy controller.
 134 Only
 135 .Fa fdd_steprate ,
 136 .Fa fdd_headsettle ,
 137 .Fa fdd_motoron ,
 138 and
 139 .Fa fdd_motoroff
 140 are actually used by the floppy disk driver.
 141 .El
 142 .Bd -literal -offset 2n
 143 /*
 144  * Floppy Drive characteristics
 145  */
 146 struct 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 recucing 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
 165 Not available.
 166 .It Dv FDSETSEARCH
 167 Not available.
 168 .It Dv FDEJECT
 169 SPARC:  This
 170 .Xr ioctl 2
 171 requests the floppy drive to eject the diskette.
 172 .It Dv FDIOCMD
 173 The argument is a pointer to an
 174 .Vt fd_cmd
 175 structure (described below).
 176 This
 177 .Xr ioctl 2
 178 allows access to the floppy diskette using the floppy device driver.
 179 Only the
 180 .Dv FDCMD_WRITE ,
 181 .Dv FDCMD_READ ,
 182 and
 183 .Dv FDCMD_FORMAT_TRACK
 184 commands are currently available.
 185 .El
 186 .Bd -literal -offset 2n
 187 struct 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
 197 Please note that the
 198 .Fa fdc_buflen
 199 field is currently unused.
 200 The
 201 .Fa fdc_secnt
 202 field is used to calculate the transfer size, and the buffer is
 203 assumed 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
 217 The argument is a pointer to an
 218 .Vt fd_raw
 219 structure (described below).
 220 This
 221 .Xr ioctl 2
 222 allows direct control of the floppy drive using the floppy controller.
 223 Refer to the appropriate floppy-controller data sheet for full
 224 details on required command bytes and returned result bytes.
 225 The 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
 245 Please note that when using
 246 .Dv FDRAW_SEEK
 247 or
 248 .Dv FDRAW_REZERO ,
 249 the driver automatically issues a
 250 .Dv FDRAW_SENSE_INT
 251 command to clear the interrupt from the
 252 .Dv FDRAW_SEEK
 253 or the
 254 .Dv FDRAW_REZERO .
 255 The result bytes returned by these commands are the results from the
 256 .Dv DRAW_SENSE_INT
 257 command.
 258 Please see the floppy-controller data sheet for
 259 more details on
 260 .Dv FDRAW_SENSE_INT .
 261 .Bd -literal -offset 2n
 262 /*
 263  * Used by FDRAW
 264  */
 265 struct    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 7D ,
 276 .Xr dkio 7I ,
 277 .Xr hdio 7I