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/i386ps2/fdreg.h

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /* 
    2  * Mach Operating System
    3  * Copyright (c) 1991 Carnegie Mellon University
    4  * Copyright (c) 1991 IBM Corporation 
    5  * All Rights Reserved.
    6  * 
    7  * Permission to use, copy, modify and distribute this software and its
    8  * documentation is hereby granted, provided that both the copyright
    9  * notice and this permission notice appear in all copies of the
   10  * software, derivative works or modified versions, and any portions
   11  * thereof, and that both notices appear in supporting documentation,
   12  * and that the name IBM not be used in advertising or publicity 
   13  * pertaining to distribution of the software without specific, written
   14  * prior permission.
   15  * 
   16  * CARNEGIE MELLON AND IBM ALLOW FREE USE OF THIS SOFTWARE IN ITS "AS IS"
   17  * CONDITION.  CARNEGIE MELLON AND IBM DISCLAIM ANY LIABILITY OF ANY KIND FOR
   18  * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
   19  * 
   20  * Carnegie Mellon requests users of this software to return to
   21  * 
   22  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
   23  *  School of Computer Science
   24  *  Carnegie Mellon University
   25  *  Pittsburgh PA 15213-3890
   26  * 
   27  * any improvements or extensions that they make and grant Carnegie Mellon
   28  * the rights to redistribute these changes.
   29  */
   30 
   31 /* @(#)63       1.1  mk/src/latest/kernel/i386/PS2/fdreg.h, MACH 4/4/91 10:22:07 */
   32 #ifndef _H_FD
   33 #define _H_FD
   34 /*
   35  * COMPONENT_NAME: (SYSXFD) Diskette Device Driver Header File
   36  *
   37  * FUNCTIONS:
   38  *
   39  * ORIGINS: 27
   40  */
   41 
   42 /*
   43  * HISTORY
   44  * $Log:        fdreg.h,v $
   45  * Revision 2.3  93/03/11  14:09:08  danner
   46  *      u_long -> u_int
   47  *      [93/03/09            danner]
   48  * 
   49  * Revision 2.2  93/02/04  07:59:42  danner
   50  *      Integrate PS2 code from IBM.
   51  *      [93/01/18            prithvi]
   52  * 
   53  */
   54 
   55 /* Diskette types
   56  */
   57 #define D_48    2               /* 48 tpi, (360K, 5.25" drive) */
   58 #define D_135H  8               /* 135 tpi, (1.44M, 3.5" drive) */
   59 
   60 /*
   61  * Diskette minor numbers use the following convention:
   62  *
   63  *       Diskette Diameter
   64  *              |
   65  *    Drive     |     
   66  *    Number    |        Diskette Type
   67  *    ______    |    _____________________
   68  *   |      |  | |  |                     |
   69  *    0    0    0    0    0    0    0    0
   70  *
   71  */
   72 
   73 /*
   74  * Defines for each of the diskette minor device types.            
   75  */
   76 
   77 /* NEEDS WORK -- these #'s should be merged with #'s in fd_defs.h */
   78 #define FDGENERIC       0       /* generic minor device number */
   79 #define FD1440_3        0x01    /* 3.5 inch, 1.44M diskette */
   80 #define FD720_3         0x02    /* 3.5 inch, 720K diskette */
   81 #define FD1200_5        0x21    /* 5.25 inch, 1.2M diskette */
   82 #define FD360_5         0x22    /* 5.25 inch, 360K diskette */
   83 
   84 /*
   85  * Diskette device driver ioctl operations.
   86  */
   87 
   88 #define FDIOC   ('F'<<8)
   89 #define FDIOCDSELDRV    (FDIOC|1)       /* de-select the drive */
   90 #define FDIOCFORMAT     (FDIOC|2)       /* format track */
   91 #define FDIOCGETPARMS   (FDIOC|3)       /* get diskette & drive
   92                                                 characteristics */
   93 #define FDIOCGINFO      (FDIOC|4)       /* get drive info */
   94 #define FDIOCNORETRY    (FDIOC|5)       /* disable retries on errors */
   95 #define FDIOCREADID     (FDIOC|6)       /* read first address field found */
   96 #define FDIOCRECAL      (FDIOC|7)       /* recalibrate the drive */
   97 #define FDIOCRESET      (FDIOC|8)       /* reset diskette controller */
   98 #define FDIOCRETRY      (FDIOC|9)       /* enable retries on errors */
   99 #define FDIOCSEEK       (FDIOC|10)      /* seek to designated cylinder */
  100 #define FDIOCSELDRV     (FDIOC|11)      /* select the drive */
  101 #define FDIOCSETPARMS   (FDIOC|12)      /* set diskette characteristics */
  102 #define FDIOCSETTLE     (FDIOC|13)      /* check the head settle time */
  103 #define FDIOCSINFO      (FDIOC|14)      /* set drive info */
  104 #define FDIOCSPEED      (FDIOC|15)      /* check the diskette rotation speed */
  105 #define FDIOCSTATUS     (FDIOC|16)      /* get the drive status */
  106 
  107 /*
  108  * The following is the structure used by the FDIOCGINFO and FDIOCSINFO
  109  * ioctl operations.
  110  */
  111 
  112 struct fdinfo {
  113         short   type;                   /* drive type (D_48, D_135H) */
  114         short   info_reserved;
  115         int     nsects;                 /* number of sectors/track */
  116         int     sides;                  /* number of sides */
  117         int     ncyls;                  /* number of cylinders */
  118 };
  119 
  120 /*
  121  * The following is the structure used by the FDIOCSTATUS ioctl
  122  * system call.                                               
  123  */
  124 
  125 struct fd_status {
  126         u_char  status1;        /* status byte 1 */
  127 #define FDNODRIVE       1       /* no drive selected */
  128 #define FDDRIVE0        2       /* drive 0 selected */
  129 #define FDDRIVE1        4       /* drive 1 selected */
  130 #define FD250KBPS       8       /* 250 kbps data transfer rate */
  131 #define FD300KBPS       16      /* 300 kbps data transfer rate */
  132 #define FD500KBPS       32      /* 500 kbps data transfer rare */
  133         u_char  status2;        /* status byte 2 */
  134 #define FD3INCHHIGH     2       /* 1.44 Megabyte drive */
  135 #define FD5INCHLOW      8       /* 360 Kilobyte drive */
  136 #define FDRETRY         16      /* retries are enabled */
  137 #define FDTIMEOUT       32      /* device driver timer expired */
  138         u_char  status3;        /* status byte 3 */
  139 #define FDDOUBLE        2       /* doubled-sided diskette */
  140 #define FD9PRTRCK       8       /* 9 sectors per track */
  141 #define FD15PRTRCK      16      /* 15 sectors per track */
  142 #define FD18PRTRCK      32      /* 18 sectors per track */
  143 #define FD40CYLS        64      /* 40 cylinders */
  144 #define FD80CYLS        28      /* 80 cylinders */
  145         u_char  command0;       /* command phase byte 0 */
  146         u_char  command1;       /* command phase byte 1 */
  147         u_char  mainstat;       /* controller main status register */
  148         u_char  dsktchng;       /* controller disk changed register */
  149         u_char  result0;        /* result phase status register 0 */
  150         u_char  result1;        /* result phase status register 1 */
  151         u_char  result2;        /* result phase status register 2 */
  152         u_char  result3;        /* result phase status register 3 */
  153         u_char  cylinder_num;   /* cylinder number */
  154         u_char  head_num;       /* head number */
  155         u_char  sector_num;     /* sector number */
  156         u_char  bytes_num;      /* number of bytes per sector */
  157         u_char  head_settle_time;       /* time in milliseconds */
  158         u_int   motor_speed;    /* time in milliseconds */
  159         u_int   Mbytes_read;    /* number of Mbytes read since last config */
  160         u_int   Mbytes_written; /* number of Mbytes written since last
  161                                         config */
  162         u_int   status_reserved0;
  163         u_int   status_reserved1;
  164 };
  165 
  166 /*
  167  * The following is the structure used by the FDIOCSETPARMS and the
  168  * FDIOCGETPARMS ioctl system calls.
  169  */
  170 
  171 struct fdparms {
  172         u_char  diskette_type;  /* ORed together flags describing type */
  173         u_char  sector_size;    /* encoded sector size */
  174         u_char  tracks_per_cylinder;    /* decimal value */
  175         u_char  data_rate;      /* encoded data rate */
  176         u_char  head_settle_time;       /* head settle time in milliseconds */
  177         u_char  head_load;      /* encoded head settle time */
  178         u_char  fill_byte;      /* hex data pattern */
  179         u_char  step_rate;      /* encoded step rate time */
  180         u_char  step_rate_time; /* step rate in milliseconds */
  181         u_char  gap;            /* r/w gap */
  182         u_char  format_gap;     /* format gap */
  183         u_char  data_length;    /* see data sheet for usage info */
  184         u_char  motor_off_time; /* time before motor is turned off (secs) */
  185         u_short sectors_per_track;      /* decimal value */
  186         u_short sectors_per_cylinder;   /* decimal value */
  187         u_short cylinders_per_disk;     /* decimal value */
  188         u_short bytes_per_sector;       /* decimal value */
  189         u_short number_of_blocks;       /* total number of sectors on the 
  190                                                 diskette */
  191         u_short motor_start;    /* motor start time in milliseconds */
  192         u_short motor_ticks;    /* motor start time in timer ticks */
  193 };
  194 
  195 /* BASED ON R2 1.49 src */
  196 
  197 /* New for OSF:
  198 */
  199 #define         splfd   spl5
  200 #define         SPLFD   5
  201 
  202 #define FDMAXDRIVES     2       /* maximum number of drives allowed */
  203 #ifndef NFD
  204 #define NFD             FDMAXDRIVES
  205 #endif
  206 #define next_unit(unit)         ( ((unit) + 1) % FDMAXDRIVES )
  207 /* NEEDS WORK -- next_unit() maybe could use fdadapter.fd_numd ?? */
  208 
  209 #define FDMAXRETRIES    6       /* maximum # of retries after overrun or CRC */
  210 
  211 #define FDDRIVEMASK     0xc0    /* mask to extract the drive number */
  212 #define FDTYPEMASK      0x3f    /* mask to delete the drive number */
  213 #define FDSIZEMASK      0xdf    /* mask to delete the diskette diameter flag */
  214 
  215 #define fd_drive(dev)   ( (minor((dev)) & FDDRIVEMASK) >> 6 )
  216 
  217 /* Differnt characteristics.  These are bitmasks for minor(devno) */
  218 #define FD_HIGH         0x01            /* high density */
  219 #define FD_LOW          0x02            /* low density */
  220 #define FD_3            0x00            /* 3 1/2" drive */
  221 #define FD_5            0x20            /* 5 1/4" drive */
  222 
  223 /* Different types of minors:  minor(devno) & FDTYPEMASK */
  224 #define FD_GENERIC      0
  225 #define FD_3H           (FD_3 | FD_HIGH)
  226 #define FD_3L           (FD_3 | FD_LOW)
  227 #define FD_5H           (FD_5 | FD_HIGH)
  228 #define FD_5L           (FD_5 | FD_LOW)
  229 
  230 #define FDSUCCESS          0    /* rc for successful subroutine completion */
  231 #define FDFAILURE         -1    /* rc for unsuccessful subroutine completion */
  232 
  233 /* Commands for fdexecute_command():
  234 **  POLLED commands have the 0x8000 bit set
  235 **  Other extended commands (non ABIOS) have the 0x100 bit set
  236 **
  237 ** Note: These commands need to use the same value as the ABIOS request
  238 ** number in order to facilitate easy retries (see fd_intr.c).
  239 */
  240 #define FDABIOS_INIT            ABIOS_LOGICAL_PARAMETER
  241 #define FDABIOS_RESET           ABIOS_RESET
  242 #define FDREAD_PARMS            ABIOS_READ_PARAMETER
  243 #define FDREAD_DATA             ABIOS_READ
  244 #define FDMOTOR_OFF             ABIOS_FD_TURN_OFF_MOTOR
  245 #define FDWRITE_DATA            ABIOS_WRITE
  246 #define FDRMEDIA_PARMS          ABIOS_FD_READ_MEDIA_TYPE
  247 #define FDFORMAT_TRACK          ABIOS_ADDITIONAL_XFER
  248 #define FDDISK_SAME             ABIOS_FD_CHANGE_SIGNAL_STATUS
  249 #define FD_SETDP                ABIOS_WRITE_PARAMETER
  250 #define FD_SETMT                ABIOS_FD_SET_MEDIA_TYPE
  251 
  252 #define FDABIOS_POLL            0x8000
  253 #define FDREAD_DATA_POLL        (FDREAD_DATA | FDABIOS_POLL)
  254 #define FDWRITE_DATA_POLL       (FDWRITE_DATA | FDABIOS_POLL)
  255 #define FDFORMAT_TRACK_POLL     (FDFORMAT_TRACK | FDABIOS_POLL)
  256 #define FD_SETDP_POLL           (FD_SETDP | FDABIOS_POLL)
  257 #define FD_SETMT_POLL           (FD_SETMT | FDABIOS_POLL)
  258 
  259 /* This should be in this order...val & ~0x100 is used as an index! */
  260 #define FDLOAD_144              0x100
  261 #define FDLOAD_720              0x101
  262 #define FDLOAD_360              0x102
  263 
  264 /*  The following are for FDDISK_TRUE.  Not that they cannot start at 0.
  265 ** See fdissue_command case for FDISK_SAME.
  266 */
  267 #define DISK_CHANGED            0x01
  268 #define DISK_SAME               0x02
  269 
  270 /* Structure for storing the physical address of data.
  271 */
  272 struct phys_add {
  273         u_char cylinder;
  274         u_char head;
  275         u_char sector;
  276         u_int transfer_length;  /* length (in bytes) of the current transfer */
  277 };
  278 
  279 /* fdp->drive_state values.
  280 */
  281 #define FDSTAT_OPEN     0x01    /* drive is open */
  282 #define FDSTAT_CLOS     0x00    /* drive is not open */
  283 #define FDSTAT_EXOP     0x02    /* drive is exclusively opened */
  284 
  285 struct floppy {
  286         dev_t device_number;    /* save off the 'devno' for later use */
  287         u_short abios_flags;    /* Holds ABIOS ctrl flags */
  288         u_char fd_change;       /* Support for ABIOS change signal */
  289         u_char open_check;      /* TRUE if doing open() media checks */
  290         u_char close_waiting;   /* TRUE or FALSE that the close */
  291         u_char drive_state;     /* current state of the drive */
  292         u_char drive_type;      /* type of diskette drive, uses same
  293                                  * defines as fdinfo structure. */
  294         u_char diskette_type;   /* type of diskette in the drive */
  295         u_char sectors_per_track;       /* number of sectors per track */
  296         u_char sectors_per_cylinder;    /* number of sectors per cylinder */
  297         u_char tracks_per_cylinder;     /* number of tracks per cylinder */
  298         u_char cylinders_per_disk;      /* number of cylinders on the disk */
  299         u_char data_rate;       /* data rate setting for diskette type */
  300         u_char gap;             /* inter-sector gap length */
  301         u_char format_gap;      /* format inter-sector gap length */
  302         u_char timeout_flag;    /* TRUE means that a timeout has occurred */
  303         u_char retry_flag;      /* 0 = disabled, anything else = enabled */
  304         u_char fill_byte;       /* fill byte for formmating */
  305         u_char cylinder_id;     /* cylinder number for format ioctls */
  306         u_char head_id;         /* head number for format ioctls */
  307         u_char head_settle_time;        /* head settle time (milliseconds) */
  308         u_char data_length;     /* data length controller parameter */
  309         u_char motor_off_time;  /* inactive time before motor turned
  310                                  * off (seconds) */
  311         u_short format_size;    /* size of format buffer */
  312         u_short bytes_per_sector;       /* raw sector size */
  313         u_short number_of_blocks;       /* total # of blocks on the disk */
  314         u_short motor_start;    /* motor start time (in milliseconds) */
  315         u_short start_block;    /* starting block # for read or write */
  316         u_int modified_bcount;  /* modified byte count for transfers */
  317         u_int retry_count;      /* retry count for the i/o operation */
  318         u_int sector_count;     /* total number of sectors to read/write */
  319         u_int sectors_done;     /* number of sectors already transfered */
  320         u_int buf_offset;       /* the offset in the data buffer for
  321                                  * this io */
  322         int close_sleep;        /* sleep event list anchor for close routine */
  323 
  324         /*  The next four members keep track of the number of bytes
  325         ** transfered since the drive was last configured.
  326         */
  327         u_int read_count_bytes;
  328         u_int read_count_megabytes;
  329         u_int write_count_bytes;
  330         u_int write_count_megabytes;
  331 
  332         char *format_buffer;    /* pointer to buffer with format info */
  333         struct buf *headptr;    /* pointer to first queued buffer header */
  334         struct buf *tailptr;    /* pointer to last queued buffer header */
  335 
  336         struct phys_add start;  /* current transfer address on diskette */
  337         u_char transfer_split;  /* transfer spans cylinders */
  338         u_char e_bytesps;       /* encoded bytes per secter */
  339 };
  340 
  341 /* defines for the fd_change field above.  It describles the various states
  342 ** the diskette change signal can be in.  After our 1st read it is an
  343 ** error to recieve this signal, but it is ok on our first read.
  344 */
  345 #define FDCHANGE_NEW    0
  346 #define FDCHANGE_INIT   1
  347 
  348 #define FDMOT_WD        0x10
  349 #define FDINT_WD        0x11
  350 #define TIMEOUT(fdw)    (timeout((fdw).func,(caddr_t)&(fdw),(fdw).time))
  351 #define UNTIMEOUT(fdw)  (untimeout((fdw).func,(caddr_t)&(fdw)))
  352 struct fdwatchdog {
  353         void (*func)();
  354         int time;
  355         struct floppy *fdp;
  356         u_char type;
  357 };
  358 
  359 /* Internal error code values for fdlog_error
  360 */
  361 #define FD_UNSUP_DRIVE          0
  362 #define FD_UNSUP_SECT           1
  363 #define FD_UNSUP_MINOR          2
  364 #define FD_ERR_LOSTINT          3
  365 #define FD_ERR_NOMEDIA          4
  366 #define FD_ERR_RETRY            5
  367 #define FD_ERR_CHMEDIA          6
  368 
  369 /* Structure describing controller (global) status.
  370 */
  371 #define FDFREE           0              /* need_controller */
  372 #define FDBUSY           1
  373 #define FDNOTWAITING     0              /* close_waiting */
  374 #define FDWAITING        1
  375 
  376 struct adapter_structure {
  377         u_char fdintr_status;           /* is the interrupt handler busy? */
  378         u_char need_controller;         /* is the controller needed? */
  379         u_char fd_intl;                 /* interrupt level as told by ABIOS */
  380         u_char fd_numd;                 /* number of units really there */
  381         struct intr *fdhandler;         /* ptr to interrupt handler struct */
  382         struct fdwatchdog int_wd;       /* interrupt watchdog timer struct */
  383         struct fdwatchdog mot_wd;       /* motor watchdog timer structure */
  384 
  385         /* This is the ABIOS interface stuff */
  386         struct Fd_request fd_req;               /* request block */
  387         int fd_flag;                            /* save info from ABIOS */
  388         int motor_off_delay;                    /* motor off delay */
  389         int need_sleep;                         /* for need_controller */
  390         caddr_t vaddr;                          /* for fddoor_check */
  391 };
  392 
  393 /*  This structure is used to store the default configuration for
  394 ** the various types of drives in order to make the set parms ioctl
  395 ** easy to implemnt.
  396 */
  397 struct fd_data {
  398         short sectors;
  399         short cylinders;
  400         short heads;
  401         short gap;
  402         short format_gap;
  403         short data_len;
  404 };
  405 #endif /* _H_FD */

Cache object: d622212f2d53a0773a73918c30afa8c1


[ 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.