home *** CD-ROM | disk | FTP | other *** search
/ NeXTSTEP 3.2 (Developer) / NS_dev_3.2.iso / NextDeveloper / Headers / bsd / dev / fd_extern.h < prev    next >
Text File  |  1993-10-19  |  18KB  |  692 lines

  1. /*    @(#)fd_extern.h     2.0    01/25/90    (c) 1990 NeXT    
  2.  *
  3.  * fd_vars.h -- Externally used data structures and constants for Floppy 
  4.  *        Disk driver
  5.  *
  6.  * KERNEL VERSION
  7.  *
  8.  * HISTORY
  9.  * 20-Mar-91    Doug Mitchell
  10.  *    Made #importing  pmap.h and vm_map.h dependent on #ifdef KERNEL.
  11.  * 25-Jan-90    Doug Mitchell at NeXT
  12.  *    Created.
  13.  *
  14.  */
  15.  
  16. #ifndef    _FDEXTERN_
  17. #define _FDEXTERN_
  18.  
  19. #import <sys/types.h>
  20. #import <sys/ioctl.h>
  21. #ifdef    KERNEL
  22. #import <machdep/machine/pmap.h>
  23. #import <vm/vm_map.h>
  24. #endif    KERNEL
  25. #import <mach/boolean.h>
  26. #import <mach/vm_param.h>
  27. #define FD_CMDSIZE    0x10        /* max size of command passed to 
  28.                      * controller */
  29. #define FD_STATSIZE    0x10        /* max size of status array returned
  30.                      * from controller */
  31.                      
  32. typedef    int fd_return_t;        /* see FDR_xxx, below */
  33.  
  34. struct fd_drive_stat {
  35.     u_char        media_id:2,    /* media type currently inserted. See
  36.                      * FD_MID_xxx, below. */
  37.              motor_on:1,    /* state of motor at I/O complete 
  38.                      * 1 = on; 0 = off */
  39.             write_prot:1,    /* write protect 1 = Write Protected */
  40.             drive_present:1,
  41.             rsvd1:3;    /* reserved */
  42. };
  43.  
  44. /*
  45.  * I/O request struct. Used in DKIOCREQ ioctl to specify one command sequence
  46.  * to be executed.
  47.  */
  48. struct fd_ioreq {
  49.     /* 
  50.      * inputs to driver:
  51.      */
  52.     u_char        density;    /* see FD_DENS_xxx, below */
  53.     int        timeout;    /* I/O timeout in milliseconds. Used
  54.                      * in FDCMD_CMD_XFR commands only. */
  55.     int        command;    /* see FDCMD_xxx, below */
  56.     u_char        cmd_blk[FD_CMDSIZE];
  57.                     /* actual command bytes */
  58.     u_int        num_cmd_bytes;    /* expected # of bytes in cmd_blk[] to
  59.                      * transfer */
  60.     caddr_t        addrs;        /* source/dest of data */
  61.     u_int        byte_count;    /* max # of data bytes to move */
  62.     u_char        stat_blk[FD_STATSIZE];
  63.                     /* status returned from controller */
  64.     u_int        num_stat_bytes;    /* number of status bytes to transfer
  65.                      * to stat_blk[] */
  66.     int         flags;        /* see FD_IOF_xxx, below */
  67.     
  68.     /*
  69.      * outputs from driver:
  70.      */
  71.     fd_return_t    status;        /* FDR_SUCCESS, etc. */
  72.     u_int        cmd_bytes_xfr;    /* # of command bytes actually moved */
  73.     u_int        bytes_xfr;    /* # of data bytes actually moved */
  74.     u_int        stat_bytes_xfr;    /* # if status bytes moved to 
  75.                      * stat_blk[] */
  76.     struct fd_drive_stat drive_stat; /* media ID, etc. */
  77.  
  78.     /*
  79.      * used internally by driver
  80.      */
  81. #ifdef    KERNEL
  82.     pmap_t        pmap;        /* DMA is mapped by this */
  83.     vm_map_t    map;        /* map of requestor's task */
  84. #else    KERNEL
  85.     void        *pmap;
  86.     void        *map;
  87. #endif    KERNEL
  88.     u_char        unit;        /* drive # (relative to controller) */
  89. };
  90.  
  91. typedef struct fd_ioreq fdIoReq_t;    
  92. typedef struct fd_ioreq *fd_ioreq_t;
  93.  
  94. /*
  95.  * fd_ioreq.command values 
  96.  */
  97. #define FDCMD_BAD        0x00    /* not used */
  98. #define FDCMD_CMD_XFR        0x01    /* transfer command in fd_ioreq.cmd_blk
  99.                      */
  100. #define FDCMD_EJECT        0x02    /* eject disk */
  101. #define FDCMD_MOTOR_ON        0x03    /* motor on */
  102. #define FDCMD_MOTOR_OFF        0x04    /* motor off */
  103. #define FDCMD_GET_STATUS    0x05    /* Get status (media ID, motor state,
  104.                      * write protect) */
  105.  
  106. /*
  107.  * fd_ioreq.density values. Some routines rely on these being in
  108.  * cardinal order...
  109.  */
  110. #define FD_DENS_NONE    0        /* unformatted */
  111. #define FD_DENS_1    1        /* 1 MByte/disk unformatted */
  112. #define FD_DENS_2    2        /* 2 MByte/disk unformatted */
  113. #define FD_DENS_4    3        /* 4 MByte/disk unformatted */
  114.  
  115. #if     i386
  116. #define FD_DENS_DEFAULT    FD_DENS_2
  117. #else
  118. #define FD_DENS_DEFAULT FD_DENS_4
  119. #endif
  120.  
  121. /*
  122.  * fd_ioreq.flags values
  123.  */
  124. #define FD_IOF_DMA_DIR        0x00000002
  125. #define FD_IOF_DMA_RD        0x00000002    /* DMA direction = device to
  126.                          * host */
  127. #define FD_IOF_DMA_WR        0x00000000    /* DMA direction = host to
  128.                          * device */
  129.                          
  130. /*
  131.  * fdr_return_t values
  132.  */
  133. #define FDR_SUCCESS        0    /* OK */
  134. #define FDR_TIMEOUT        1    /* fd_ioreq.timeout exceeded */
  135. #define FDR_MEMALLOC        2    /* couldn't allocate memory */
  136. #define FDR_MEMFAIL        3    /* memory transfer error */
  137. #define FDR_REJECT        4    /* bad field in fd_ioreq */
  138. #define FDR_BADDRV        5    /* drive not present */
  139. #define FDR_DATACRC        6    /* media error - data CRC */
  140. #define FDR_HDRCRC        7    /* media error - header CRC */
  141. #define FDR_MEDIA        8    /* misc. media error */
  142. #define FDR_SEEK         9    /* seek error */
  143. #define FDR_BADPHASE        10    /* controller changed phase 
  144.                      * unexpectedly */
  145. #define FDR_DRIVE_FAIL        11    /* Basic Drive Failure */
  146. #define FDR_NOHDR        12    /* Header Not Found */
  147. #define FDR_WRTPROT        13    /* Disk Write Protected */
  148. #define FDR_NO_ADDRS_MK        14    /* Missing Address Mark */
  149. #define FDR_CNTRL_MK        15    /* Missing Control Mark */
  150. #define FDR_NO_DATA_MK        16    /* Missing Data Mark */
  151. #define FDR_CNTRL_REJECT    17    /* controller rejected command */
  152. #define FDR_CNTRLR        18    /* Controller Handshake Error */
  153. #define FDR_DMAOURUN        19    /* DMA Over/underrun */
  154. #define FDR_VOLUNAVAIL        20    /* Requested Volume not available */
  155. #define FDR_ALIGN        21    /* DMA alignment error */
  156. #define FDR_DMA            22    /* DMA error */
  157. #define FDR_SPURIOUS        23    /* spurious interrupt */
  158.  
  159. /*
  160.  * fd_drive_stat.media_id values
  161.  */
  162. #define FD_MID_NONE        0    /* no disk inserted */
  163. #define FD_MID_1MB        3    /* 1 MByte unformatted */
  164. #define FD_MID_2MB        2    /* 2 MByte unformatted */
  165. #define FD_MID_4MB        1    /* 4 MBytes unformatted */
  166.  
  167. #if i386
  168. #define FD_MID_DEFAULT    FD_MID_2MB
  169. #ifdef KERNEL                   /* Maximum Number of bytes of data
  170.                           that can be transfered via DMA 
  171.                            using FDIOCREQ ioctl command
  172.                        */
  173.  
  174. #define FD_MAX_DMA_SIZE        PAGE_SIZE 
  175. #else
  176. #define FD_MAX_DMA_SIZE        vm_page_size 
  177. #endif KERNEL                   
  178. #endif i386
  179.  
  180. /*
  181.  * ioctl's specific to floppy disk
  182.  */
  183. #define    FDIOCREQ    _IOWR('f', 0, struct fd_ioreq)    /* cmd request */
  184. #define FDIOCGFORM    _IOR ('f', 1, struct fd_format_info)
  185.                             /* get format */
  186. #define FDIOCSDENS    _IOW ('f', 2, int)        /* set density */
  187. #define FDIOCSSIZE    _IOW ('f', 3, int)        /* set sector size */
  188. #define FDIOCSGAPL    _IOW ('f', 4, int)        /* set Gap 3 length */
  189. #define FDIOCRRW    _IOWR('f', 5, struct fd_rawio)    /* raw read/write */
  190. #define FDIOCSIRETRY    _IOW ('f', 6, int)        /* set inner retry loop
  191.                              * count */
  192. #define FDIOCGIRETRY    _IOR ('f', 7, int)        /* get inner retry loop
  193.                              * count */
  194. #define FDIOCSORETRY    _IOW ('f', 8, int)        /* set outer retry loop
  195.                              * count */
  196. #define FDIOCGORETRY    _IOR ('f', 9, int)        /* get outer retry loop
  197.                              * count */
  198. /*
  199.  *     software registers passed to controller during command sequences 
  200.  */
  201.  
  202. struct fd_rw_cmd {
  203.     /*
  204.      * 9 command bytes passed at start of read/write data
  205.      */
  206.      
  207. #if     __LITTLE_ENDIAN__
  208.  
  209.     u_char  opcode:5,
  210.         sk:1,            /* skip sectors with deleted AM */
  211.         mfm:1,            /* MFM encoding */
  212.         mt:1;             /* multi track */
  213.     u_char    drive_sel:2,        /* drive select */
  214.         hds:1,            /* head select */
  215.          rsvd1:5;        /* reserved */
  216.     u_char    cylinder;
  217.     u_char    head;
  218.     u_char    sector;
  219.     u_char    sector_size;        /* 'n' in the Intel spec. */
  220.     u_char    eot;            /* sector # at end of track */
  221.     u_char    gap_length;        /* gap length */
  222.     u_char    dtl;            /* special sector size */
  223.  
  224. #elif    __BIG_ENDIAN__
  225.  
  226.     u_char     mt:1,            /* multitrack */
  227.         mfm:1,            /* MFM encoding */
  228.         sk:1,            /* skip sectors with deleted AM */
  229.         opcode:5;
  230.     u_char    rsvd1:5,        /* reserved */
  231.         hds:1,            /* head select */
  232.         drive_sel:2;        /* drive select */
  233.     u_char    cylinder;
  234.     u_char    head;
  235.     u_char    sector;
  236.     u_char    sector_size;        /* 'n' in the Intel spec. */
  237.     u_char    eot;            /* sector # at end of track */
  238.     u_char    gap_length;        /* gap length */
  239.     u_char    dtl;            /* special sector size */
  240.     
  241. #else
  242. #error    Floppy command / data structures are compiler sensitive
  243. #endif
  244. };
  245.  
  246. #define SIZEOF_RW_CMD    9        /* compiler yields 9 as sizeof this
  247.                      * struct */
  248.                      
  249. struct fd_rw_stat {
  250.     /* 
  251.      * 7 status bytes passed at completion of read/write data 
  252.      */
  253.  
  254.     u_char    stat0;
  255.     u_char    stat1;
  256.     u_char     stat2;
  257.     u_char    cylinder;
  258.     u_char    head;
  259.     u_char    sector;
  260.     u_char    sector_size;        /* 'n' in the Intel spec. */
  261. };
  262.  
  263. #define SIZEOF_RW_STAT    7
  264.  
  265. struct fd_int_stat {
  266.     /* 
  267.      * result of Sense Interrupt Status command
  268.      */
  269.     u_char     stat0;    
  270.     u_char    pcn;            /* present cylinder & */
  271. };
  272.  
  273. struct fd_seek_cmd {
  274.     /* 
  275.      * Seek command. Uses Sense Interrupt Status to get results.
  276.      */
  277.      
  278. #if     __LITTLE_ENDIAN__
  279.  
  280.     u_char    opcode:6,        /* will be FCCMD_SEEK */
  281.         dir:1,            /* 1 == towards spindle for 
  282.                         relative seek*/
  283.         relative:1;        /* 1 = relative */
  284.     u_char    drive_sel:2,        /* drive select */
  285.         hds:1,            /* head select */
  286.         rsvd1:5;        /* reserved */
  287.     u_char    cyl;            /* cylinder # or offset */
  288.     
  289. #elif    __BIG_ENDIAN__
  290.  
  291.     u_char    relative:1,        /* 1 = relative */
  292.         dir:1,            /* 1 == towards spindle */
  293.         opcode:6;        /* will be FCCMD_SEEK */
  294.     u_char    rsvd1:5,        /* reserved */
  295.         hds:1,            /* head select */
  296.         drive_sel:2;        /* drive select */
  297.     u_char    cyl;            /* cylinder # or offset */
  298.     
  299. #else
  300. #error    Floppy command / data structures are compiler sensitive
  301. #endif
  302. };
  303.  
  304. #define SEEK_DIR_IN        1        /* seek towards spindle */
  305. #define SEEK_DIR_OUT        0        /* seek away from spindle */
  306.  
  307. #define SIZEOF_SEEK_CMD        3
  308.  
  309. struct fd_recal_cmd {
  310.     /* 
  311.      * Recalibrate command. Uses Sense Interrupt Status to get results.
  312.      */
  313.     u_char    opcode;            /* will be FCCMD_RECAL */
  314.     
  315. #if     __LITTLE_ENDIAN__
  316.  
  317.     u_char    drive_sel:2,        /* drive select */
  318.         rsvd1:6;        /* reserved */
  319.     
  320. #elif    __BIG_ENDIAN__
  321.  
  322.     u_char    rsvd1:6,        /* reserved */
  323.         drive_sel:2;        /* drive select */
  324.     
  325. #else
  326. #error    Floppy command / data structures are compiler sensitive
  327. #endif
  328. };
  329.     
  330. struct fd_configure_cmd {
  331.     /*
  332.      * configure command. No result bytes are returned.
  333.      */
  334.     u_char     opcode;            /* will be FCCMD_CONFIGURE */
  335.     u_char    rsvd1;            /* must be 0 */
  336.     u_char     conf_2;            /* EIS, EFIFO, etc. */
  337.     u_char    pretrk;            /* write precomp track # */
  338. };
  339.  
  340. /*
  341.  * configure command fields 
  342.  */
  343. #define CF2_EIS            0x40    /* enable implied seek */
  344. #define CF2_EFIFO        0x20    /* enable FIFO. True Low. */
  345. #define CF2_DPOLL        0x10    /* disable polling */
  346. #define CF2_FIFO_DEFAULT    0x08    /* OUR default FIFO threshold */
  347. #define CF_PRETRACK        0x00    /* OUR default precom track */
  348. #define I82077_FIFO_SIZE    0x10    /* size of FIFO */
  349.  
  350. struct fd_specify_cmd {
  351.     /*
  352.      * Specify command. No result bytes are returned.
  353.      */
  354.     u_char     opcode;            /* will be FCCMD_SPECIFY */
  355.     
  356. #if     __LITTLE_ENDIAN__
  357.  
  358.     u_char     hut:4,            /* head unload time */
  359.         srt:4;            /* step rate */
  360.     u_char    nd:1,            /* Non-DMA mode */
  361.         hlt:7;            /* head load time */
  362.     
  363. #elif    __BIG_ENDIAN__
  364.  
  365.     u_char    srt:4,            /* step rate */
  366.          hut:4;            /* head unload time */
  367.     u_char    hlt:7,            /* head load time */
  368.         nd:1;            /* Non-DMA mode */
  369.     
  370. #else
  371. #error    Floppy command / data structures are compiler sensitive
  372. #endif
  373. };
  374.  
  375. #define SIZEOF_SPECIFY_CMD    3
  376.  
  377. struct fd_readid_cmd {
  378.     /* 
  379.      * Read ID command. Returns status in an fd_rw_stat.
  380.      */
  381.      
  382. #if     __LITTLE_ENDIAN__
  383.  
  384.     u_char    opcode:6,        /* Will be FCCMD_READID */
  385.         mfm:1,
  386.          rsvd1:1;
  387.     u_char    drive_sel:2,        /* drive select */
  388.         hds:1,            /* head select */
  389.         rsvd2:5;        /* reserved */
  390.     
  391. #elif    __BIG_ENDIAN__
  392.  
  393.     u_char     rsvd1:1,
  394.         mfm:1,
  395.         opcode:6;        /* Will be FCCMD_READID */
  396.     u_char    rsvd2:5,        /* reserved */
  397.         hds:1,            /* head select */
  398.         drive_sel:2;        /* drive select */
  399.     
  400. #else
  401. #error    Floppy command / data structures are compiler sensitive
  402. #endif
  403. };
  404.  
  405. struct fd_perpendicular_cmd {
  406.     u_char    opcode;            /* will be FCCMD_PERPENDICULAR */
  407.     
  408. #if     __LITTLE_ENDIAN__
  409.  
  410.     u_char    gap:1,
  411.         wgate:1,
  412.         rsvd1:6;        /* must be 0 */
  413.     
  414. #elif    __BIG_ENDIAN__
  415.  
  416.     u_char    rsvd1:6,        /* must be 0 */
  417.         wgate:1,
  418.         gap:1;
  419.     
  420. #else
  421. #error    Floppy command / data structures are compiler sensitive
  422. #endif
  423. };
  424.  
  425. struct fd_format_cmd {
  426.     /*
  427.      * Format track command. Returns status in an fd_rw_stat
  428.      * (with undefined address fields).
  429.      */
  430.      
  431. #if     __LITTLE_ENDIAN__
  432.  
  433.     u_char    opcode:6,        /* will be FCCMD_FORMAT */
  434.         mfm:1,
  435.         rsvd1:1;
  436.     u_char    drive_sel:2,        /* drive select */
  437.         hds:1,            /* head select */
  438.         rsvd2:5;        /* reserved */
  439.     
  440. #elif    __BIG_ENDIAN__
  441.  
  442.     u_char    rsvd1:1,
  443.         mfm:1,
  444.         opcode:6;        /* will be FCCMD_FORMAT */
  445.     u_char    rsvd2:5,        /* reserved */
  446.         hds:1,            /* head select */
  447.         drive_sel:2;        /* drive select */
  448.     
  449. #else
  450. #error    Floppy command / data structures are compiler sensitive
  451. #endif
  452.     u_char    n;            /* sector size (2**n * 128 = sect_size)
  453.                      */
  454.     u_char    sects_per_trk;
  455.     u_char    gap_length;
  456.     u_char    filler_data;        /* data field written with this byte */
  457. };
  458.  
  459. struct fd_sense_drive_status_cmd {
  460.     /*
  461.      * returns one result byte which is basically status register 3
  462.      */
  463.  
  464.     u_char    opcode;     /* will be FCCMD_DRIVE_STATUS */
  465.     
  466. #if     __LITTLE_ENDIAN__
  467.  
  468.     u_char    drive_sel:2,    /* drive select */
  469.         hds:1,        /* head select */
  470.          resvd2:5;     /* always zero */
  471.     
  472. #elif    __BIG_ENDIAN__
  473.  
  474.     u_char    resvd2:5,     /* always zero */
  475.         hds:1,        /* head select */
  476.          drive_sel:2;    /* drive select */
  477.     
  478. #else
  479. #error    Floppy command / data structures are compiler sensitive
  480. #endif
  481. };
  482.  
  483. /*
  484.  *    software register values
  485.  */
  486.  
  487. /*
  488.  * cmd (command byte). Not all of these opcodes are used with the fd_rw_cmd 
  489.  * struct...
  490.  */
  491. #define FCCMD_OPCODE_MASK    0x1F
  492. #define    FCCMD_MULTITRACK    0x80
  493. #define FCCMD_MFM        0x40        /* MFM flag */
  494. #define FCCMD_SK        0x20        /* skip flag */
  495. #define FCCMD_READ        0x06
  496. #define FCCMD_READ_DELETE    0x0C
  497. #define FCCMD_WRITE        0x05
  498. #define FCCMD_WRITE_DELETE    0x09
  499. #define FCCMD_READ_TRACK    0x02
  500. #define FCCMD_VERIFY        0x16
  501. #define FCCMD_VERSION        0x10
  502. #define FCCMD_FORMAT        0x0D
  503. #define FCCMD_RECAL        0x07
  504. #define FCCMD_INTSTAT        0x08        /* sense interrupt status */
  505. #define FCCMD_SPECIFY        0x03
  506. #define FCCMD_DRIVE_STATUS    0x04
  507. #define FCCMD_SEEK        0x0F
  508. #define FCCMD_CONFIGURE        0x13
  509. #define FCCMD_DUMPREG        0x0E
  510. #define FCCMD_READID        0x0A        /* Read ID */
  511. #define FCCMD_PERPENDICULAR    0x12        /* perpendicular recording mode
  512.                          */
  513. /* 
  514.  * rws_stat0 (status register 0)
  515.  */
  516. #define SR0_INTCODE        0xC0    /* interrupt code - see INTCODE_xxx */
  517. #define INTCODE_COMPLETE    0x00    /* normal I/O complete */
  518. #define INTCODE_ABNORMAL    0x40    /* abnormal termination */
  519. #define INTCODE_INVALID        0x80    /* Invalid command */
  520. #define INTCODE_POLL_TERM    0xC0    /* abnormal termination caused by 
  521.                      * polling */
  522. #define SR0_SEEKEND        0x20    /* Seek End */
  523. #define SR0_EQ_CHECK        0x10    /* Equipment check (recal failed,
  524.                      *    seek beyond track 0, etc.) */
  525. #define SR0_HEAD        0x04    /* current head address */
  526. #define SR0_DRVSEL        0x03
  527. #define SR0_DRVSEL1        0x02    /* Drive Select 1 */
  528. #define SR0_DRVSEL0        0x01    /* Drive Select 0 */
  529.  
  530. /*
  531.  * rws_stat1 (status register 1)
  532.  */
  533. #define SR1_EOCYL        0x80    /* end of cylinder */
  534. #define SR1_CRCERR        0x20    /* data or ID CRC error */
  535. #define SR1_OURUN        0x10    /* DMA over/underrun */
  536. #define SR1_NOHDR        0x04    /* Header Not Found */
  537. #define SR1_NOT_WRT        0x02    /* Not writable */
  538. #define SR1_MISS_AM        0x01    /* Missing Address mark */
  539.  
  540. /*
  541.  * rws_stat2 (status register 2)
  542.  */
  543. #define SR2_CNTRL_MK        0x40    /* control mark */
  544. #define SR2_DATACRC        0x20    /* Data CRC error */
  545. #define SR2_WRONG_CYL        0x10    /* wrong cylinder */
  546. #define SR2_BAD_CYL        0x02    /* Bad cylinder */
  547. #define SR2_MISS_AM        0x01    /* missing data mark */
  548.  
  549. /*
  550.  * rws_stat3 (status register 3)
  551.  */
  552. #define SR3_WP            0x40    /* write protected */
  553. #define SR3_TRACK0        0x10    /* Track 0 */
  554. #define SR3_HEAD        0x04    /* Head # */
  555. #define SR3_DRVSEL1        0x02    /* same as status register 0?? */
  556. #define SR3_DEVSEL0        0x01    
  557.  
  558. /*
  559.  * disk info - maps media_id to tracks_per_cyl and num_cylinders.
  560.  */
  561. struct fd_disk_info {
  562.     u_int     media_id;            /* FD_MID_1MB, etc. */
  563.     u_char    tracks_per_cyl;            /* # of heads */
  564.     u_int    num_cylinders;    
  565.     u_int    max_density;            /* maximum legal density.
  566.                          * (FD_DENS_1, etc.) */
  567. };
  568.  
  569. /*
  570.  * sector size info - maps sector size to 82077 sector size code and
  571.  * gap3 length.  Note that the controller must be programmed for different
  572.  * gap3 size when formatting as opposed to reading or writing.  Since gap3
  573.  * sizes may be dependent on the actual disk hardware, the fmt gap is
  574.  * maintained here to avoid requiring the formatter to determine
  575.  * the disk device type.
  576.  */
  577. struct fd_sectsize_info {
  578.     u_int         sect_size;        /* in bytes */
  579.     u_char        n;            /* 82077 sectsize code */
  580.     u_int        sects_per_trk;        /* physical sectors per trk */
  581.     u_char        rw_gap_length;        /* Gap 3 for rw cmds */ 
  582.     u_char        fmt_gap_length;        /* Gap 3 for fmt cmds */ 
  583. };
  584.  
  585. typedef struct fd_sectsize_info fd_sectsize_info_t;
  586.  
  587. /*
  588.  * density info - maps density to capacity. Note that a disk may be formatted
  589.  * with a lower density than its max possible density.
  590.  */
  591. struct fd_density_info {
  592.     u_int         density;        /* FD_DENS_1, etc. */
  593.     u_int         capacity;        /* in bytes */
  594.     boolean_t    mfm;            /* TRUE = MFM encoding */
  595. };
  596.  
  597. typedef struct fd_density_info fd_density_info_t;
  598.  
  599. /*
  600.  * disk format info. Used with ioctl(FDIOCGFORM).
  601.  */
  602. struct fd_format_info {
  603.     /*
  604.      * the disk_info struct is always valid as long as a disk is
  605.      * inserted.
  606.      */
  607.     struct fd_disk_info    disk_info;
  608.     
  609.     int            flags;        /* See FFI_xxx, below */
  610.  
  611.     /*
  612.      * the remainder is only valid if (flags & FFI_FORMATTED) is true.
  613.      */
  614.     struct fd_density_info    density_info;
  615.     struct fd_sectsize_info    sectsize_info;
  616.     u_int            total_sects;    /* total # of sectors on 
  617.                          * disk */
  618. };
  619.  
  620. /*
  621.  * fd_format_info.flags fields
  622.  */
  623. #define FFI_FORMATTED        0x00000001    /* known disk format */
  624. #define FFI_LABELVALID        0x00000002    /* Valid NeXT file system label
  625.                          * present */
  626. #define FFI_WRITEPROTECT    0x00000004    /* disk is write protected */
  627.                          
  628. struct format_data {
  629.     /* 
  630.      * one of these per sector. A Format command involves DMA'ing one of 
  631.      * these for each sector on a track. The format command is executed
  632.      * with a FDIOCREQ ioctl.
  633.      */
  634.     u_char cylinder;
  635.     u_char head;
  636.     u_char sector;
  637.     u_char n;            /* as in sector_size = 2**n * 128 */
  638. };
  639.  
  640. /*
  641.  * result of FCCMD_DUMPREG command
  642.  */
  643. struct fd_82077_regs {
  644.     u_char    pcn[4];        /* cylinder # for drives 0..3 */
  645.     u_char    srt:4,
  646.         hut:4;
  647.     u_char    hlt:7,
  648.         nd:1;
  649.     u_char    sc_eot;
  650.     u_char    rsvd1;
  651.     u_char    rsvd2:1,
  652.         eis:1,
  653.         efifo:1,
  654.         poll:1,
  655.         fifothr:4;
  656.     u_char    pretrk;
  657. };
  658.  
  659. /*
  660.  * Used for FDIOCRRW - raw disk I/O 
  661.  * -- no bad block mapping
  662.  * -- no label required
  663.  * -- no front porch 
  664.  * -- block size = physical sector size
  665.  */
  666. struct fd_rawio {
  667.     /*
  668.      * Passed to driver
  669.      */
  670.     u_int         sector;
  671.     u_int        sector_count;
  672.     caddr_t        dma_addrs;
  673.     boolean_t    read;        /* TRUE = read; FALSE = write */
  674.     /*
  675.      * Returned from driver
  676.      */
  677.     fd_return_t    status;        /* FDR_xxx (see above) */
  678.     u_int         sects_xfr;    /* sectors actually moved */
  679. };
  680.  
  681. /*
  682.  * misc. hardware constants
  683.  */
  684. #define NUM_FD_HEADS     2        /* number of tracks/cylinder */
  685. #define NUM_FD_CYL    80        /* cylinders/disk (is this actually a 
  686.                      * constant for all densities?) */
  687. #define FD_PARK_TRACK    79        /* track to which to seek before
  688.                      * eject */
  689. #define NUM_UNITS    4        /* max # of drives per controller */ 
  690.  
  691. #endif    _FDEXTERN_
  692.