The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/sys/fdcio.h

Version: -  FREEBSD  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-2  -  FREEBSD-11-1  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-4  -  FREEBSD-10-3  -  FREEBSD-10-2  -  FREEBSD-10-1  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-3  -  FREEBSD-9-2  -  FREEBSD-9-1  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-4  -  FREEBSD-8-3  -  FREEBSD-8-2  -  FREEBSD-8-1  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-4  -  FREEBSD-7-3  -  FREEBSD-7-2  -  FREEBSD-7-1  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-4  -  FREEBSD-6-3  -  FREEBSD-6-2  -  FREEBSD-6-1  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-5  -  FREEBSD-5-4  -  FREEBSD-5-3  -  FREEBSD-5-2  -  FREEBSD-5-1  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  linux-2.6  -  linux-2.4.22  -  MK83  -  MK84  -  PLAN9  -  DFBSD  -  NETBSD  -  NETBSD5  -  NETBSD4  -  NETBSD3  -  NETBSD20  -  OPENBSD  -  xnu-517  -  xnu-792  -  xnu-792.6.70  -  xnu-1228  -  xnu-1456.1.26  -  xnu-1699.24.8  -  xnu-2050.18.24  -  OPENSOLARIS  -  minix-3-1-1 
SearchContext: -  none  -  3  -  10 

    1 /*-
    2  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
    3  *
    4  * Copyright (C) 1992-1994,2001 by Joerg Wunsch, Dresden
    5  * All rights reserved.
    6  *
    7  * Redistribution and use in source and binary forms, with or without
    8  * modification, are permitted provided that the following conditions
    9  * are met:
   10  * 1. Redistributions of source code must retain the above copyright
   11  *    notice, this list of conditions and the following disclaimer.
   12  * 2. Redistributions in binary form must reproduce the above copyright
   13  *    notice, this list of conditions and the following disclaimer in the
   14  *    documentation and/or other materials provided with the distribution.
   15  *
   16  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY
   17  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   18  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
   19  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE
   20  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
   21  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
   22  * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
   23  * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
   24  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
   25  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
   26  * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
   27  * DAMAGE.
   28  *
   29  * $FreeBSD: releng/12.0/sys/sys/fdcio.h 326256 2017-11-27 15:01:59Z pfg $
   30  */
   31 
   32 #ifndef _MACHINE_IOCTL_FD_H_
   33 #define _MACHINE_IOCTL_FD_H_
   34 
   35 #ifndef _KERNEL
   36 #include <sys/types.h>
   37 #endif
   38 #include <sys/ioccom.h>
   39 
   40 #define FD_FORMAT_VERSION 110   /* used to validate before formatting */
   41 #define FD_MAX_NSEC 36          /* highest known number of spt - allow for */
   42                                 /* 2.88 MB drives */
   43 
   44 struct fd_formb {
   45         int format_version;     /* == FD_FORMAT_VERSION */
   46         int cyl, head;
   47         int transfer_rate;      /* FDC_???KBPS */
   48 
   49         struct fd_form_data {
   50                 /*
   51                  * DO NOT CHANGE THE LAYOUT OF THIS STRUCTS
   52                  * it is hardware-dependent since it exactly
   53                  * matches the byte sequence to write to FDC
   54                  * during its `format track' operation
   55                  */
   56                 u_char secshift; /* 0 -> 128, ...; usually 2 -> 512 */
   57                 u_char nsecs;   /* must be <= FD_MAX_NSEC */
   58                 u_char gaplen;  /* GAP 3 length; usually 84 */
   59                 u_char fillbyte; /* usually 0xf6 */
   60                 struct fd_idfield_data {
   61                         /*
   62                          * data to write into id fields;
   63                          * for obscure formats, they mustn't match
   64                          * the real values (but mostly do)
   65                          */
   66                         u_char cylno;   /* 0 thru 79 (or 39) */
   67                         u_char headno;  /* 0, or 1 */
   68                         u_char secno;   /* starting at 1! */
   69                         u_char secsize; /* usually 2 */
   70                 } idfields[FD_MAX_NSEC]; /* 0 <= idx < nsecs used */
   71         } format_info;
   72 };
   73 
   74 /* make life easier */
   75 # define fd_formb_secshift   format_info.secshift
   76 # define fd_formb_nsecs      format_info.nsecs
   77 # define fd_formb_gaplen     format_info.gaplen
   78 # define fd_formb_fillbyte   format_info.fillbyte
   79 /* these data must be filled in for(i = 0; i < fd_formb_nsecs; i++) */
   80 # define fd_formb_cylno(i)   format_info.idfields[i].cylno
   81 # define fd_formb_headno(i)  format_info.idfields[i].headno
   82 # define fd_formb_secno(i)   format_info.idfields[i].secno
   83 # define fd_formb_secsize(i) format_info.idfields[i].secsize
   84 
   85 struct fd_type {
   86         int     sectrac;                /* sectors per track         */
   87         int     secsize;                /* size code for sectors     */
   88         int     datalen;                /* data len when secsize = 0 */
   89         int     gap;                    /* gap len between sectors   */
   90         int     tracks;                 /* total number of cylinders */
   91         int     size;                   /* size of disk in sectors   */
   92         int     trans;                  /* transfer speed code       */
   93         int     heads;                  /* number of heads           */
   94         int     f_gap;                  /* format gap len            */
   95         int     f_inter;                /* format interleave factor  */
   96         int     offset_side2;           /* offset of sectors on side2 */
   97         int     flags;                  /* misc. features */
   98 #define FL_MFM          0x0001          /* MFM recording */
   99 #define FL_2STEP        0x0002          /* 2 steps between cylinders */
  100 #define FL_PERPND       0x0004          /* perpendicular recording */
  101 #define FL_AUTO         0x0008          /* autodetect format */
  102 };
  103 
  104 struct fdc_status {
  105         u_int   status[7];
  106 };
  107 
  108 /*
  109  * cyl and head are being passed into ioctl(FD_READID)
  110  * all four fields are being returned
  111  */
  112 struct fdc_readid {
  113         u_char  cyl;            /* C - 0...79 */
  114         u_char  head;           /* H - 0...1 */
  115         u_char  sec;            /* R - 1...n */
  116         u_char  secshift;       /* N - log2(secsize / 128) */
  117 };
  118 
  119 /*
  120  * Diskette drive type, basically the same as stored in RTC on ISA
  121  * machines (see /sys/isa/rtc.h), but right-shifted by four bits.
  122  */
  123 enum fd_drivetype {
  124         FDT_NONE, FDT_360K, FDT_12M, FDT_720K, FDT_144M, FDT_288M_1,
  125         FDT_288M
  126 };
  127 
  128 
  129 #define FD_FORM   _IOW('F', 61, struct fd_formb) /* format a track */
  130 #define FD_GTYPE  _IOR('F', 62, struct fd_type)  /* get drive type */
  131 #define FD_STYPE  _IOW('F', 63, struct fd_type)  /* set drive type */
  132 
  133 #define FD_GOPTS  _IOR('F', 64, int) /* drive options, see below */
  134 #define FD_SOPTS  _IOW('F', 65, int)
  135 
  136 #define FD_CLRERR _IO('F', 67)  /* clear error counter */
  137 
  138 #define FD_READID _IOWR('F', 68, struct fdc_readid) /* read ID field */
  139 
  140 /*
  141  * Obtain NE765 status registers.  Only successful if there is
  142  * a valid status stored in fdc->status[].
  143  */
  144 #define FD_GSTAT  _IOR('F', 69, struct fdc_status)
  145 
  146 #define FD_GDTYPE _IOR('F', 70, enum fd_drivetype) /* obtain drive type */
  147 
  148 /* Options for FD_GOPTS/FD_SOPTS, cleared on device close */
  149 #define FDOPT_NORETRY 0x0001    /* no retries on failure */
  150 #define FDOPT_NOERRLOG 0x002    /* no "hard error" kernel log messages */
  151 #define FDOPT_NOERROR 0x0004    /* do not indicate errors, caller will use
  152                                    FD_GSTAT in order to obtain status */
  153 
  154 /*
  155  * Transfer rate definitions.  Used in the structures above.  They
  156  * represent the hardware encoding of bits 0 and 1 of the FDC control
  157  * register when writing to the register.
  158  * Transfer rates for FM encoding are half the values listed here
  159  * (but we currently don't support FM encoding).
  160  */
  161 #define FDC_500KBPS     0x00    /* 500KBPS MFM drive transfer rate */
  162 #define FDC_300KBPS     0x01    /* 300KBPS MFM drive transfer rate */
  163 #define FDC_250KBPS     0x02    /* 250KBPS MFM drive transfer rate */
  164 #define FDC_1MBPS       0x03    /* 1MPBS MFM drive transfer rate */
  165 
  166 /*
  167  * Parameters for common formats
  168  *
  169  * See struct fd_type for layout.
  170  * XXX: Field 'size' must be calculated.
  171  * XXX: Fields 'f_inter' and 'offset_side2' are unused by kernel.
  172  *
  173  * XXX: These should really go in a /etc/floppycap colon separated file
  174  * XXX: but the kernel needs some of them for proper defaults and it would
  175  * XXX: should have been done 20 years ago to make sense.
  176  */
  177 #define FDF_3_2880 36,2,0xFF,0x1B,80,0,FDC_1MBPS,002,0x4C,1,1,FL_MFM|FL_PERPND
  178 #define FDF_3_1722 21,2,0xFF,0x04,82,0,FDC_500KBPS,2,0x0C,2,0,FL_MFM
  179 #define FDF_3_1476 18,2,0xFF,0x1B,82,0,FDC_500KBPS,2,0x6C,1,0,FL_MFM
  180 #define FDF_3_1440 18,2,0xFF,0x1B,80,0,FDC_500KBPS,2,0x6C,1,0,FL_MFM
  181 #define FDF_3_1200 15,2,0xFF,0x1B,80,0,FDC_500KBPS,2,0x54,1,0,FL_MFM
  182 #define FDF_3_820  10,2,0xFF,0x10,82,0,FDC_250KBPS,2,0x2e,1,0,FL_MFM
  183 #define FDF_3_800  10,2,0xFF,0x10,80,0,FDC_250KBPS,2,0x2e,1,0,FL_MFM
  184 #define FDF_3_720   9,2,0xFF,0x20,80,0,FDC_250KBPS,2,0x50,1,0,FL_MFM
  185 #define FDF_5_1480 18,2,0xFF,0x02,82,0,FDC_500KBPS,2,0x02,2,0,FL_MFM 
  186 #define FDF_5_1440 18,2,0xFF,0x02,80,0,FDC_500KBPS,2,0x02,2,0,FL_MFM
  187 #define FDF_5_1230  8,3,0xFF,0x35,77,0,FDC_500KBPS,2,0x74,1,0,FL_MFM
  188 #define FDF_5_1200 15,2,0xFF,0x1B,80,0,FDC_500KBPS,2,0x54,1,0,FL_MFM
  189 #define FDF_5_820  10,2,0xFF,0x10,82,0,FDC_300KBPS,2,0x2e,1,0,FL_MFM
  190 #define FDF_5_800  10,2,0xFF,0x10,80,0,FDC_300KBPS,2,0x2e,1,0,FL_MFM
  191 #define FDF_5_720   9,2,0xFF,0x20,80,0,FDC_300KBPS,2,0x50,1,0,FL_MFM
  192 #define FDF_5_640   8,2,0xFF,0x2A,80,0,FDC_300KBPS,2,0x50,1,0,FL_MFM
  193 #define FDF_5_400  10,2,0xFF,0x10,80,0,FDC_300KBPS,1,0x2e,1,0,FL_MFM /* RX50 */
  194 #define FDF_5_360   9,2,0xFF,0x23,40,0,FDC_300KBPS,2,0x50,1,0,FL_MFM
  195 /* XXX:                      0x2a ? */
  196 
  197 #endif /* !_MACHINE_IOCTL_FD_H_ */

Cache object: 76c6ef2b86b80631a048595883e1c219


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.