home *** CD-ROM | disk | FTP | other *** search
/ NeXTSTEP 3.0 / NeXTSTEP3.0.iso / NextDeveloper / Headers / bsd / dev / disk.h < prev    next >
Text File  |  1992-07-29  |  5KB  |  166 lines

  1. /*    @(#)disk.h    1.0    08/29/87    (c) 1987 NeXT    */
  2.  
  3. /* 
  4.  * HISTORY
  5.  * 22-May-91  Gregg Kellogg (gk) at NeXT
  6.  *    Split out public interface.
  7.  *
  8.  * 20-Jul-90  Doug Mitchell
  9.  *    Added DKIOCSFORMAT, DKIOCGFORMAT
  10.  *
  11.  * 16-Apr-90  Doug Mitchell at NeXT
  12.  *    Added DKIOCPANELPRT.
  13.  *
  14.  * 25-Mar-90  John Seamons (jks) at NeXT
  15.  *    Removed obsolete DKIOCNOTIFY and DKIOCINSERT.
  16.  *
  17.  * 23-Mar-90  Doug Mitchell
  18.  *    Added DKIOCEJECT.
  19.  * 
  20.  * 14-Feb-90  Doug Mitchell at NeXT
  21.  *    Added DKIOCMNOTIFY.
  22.  *
  23.  * 16-Mar-88  John Seamons (jks) at NeXT
  24.  *    Cleaned up to support standard disk label definitions.
  25.  *
  26.  * 24-Feb-88  Mike DeMoney (mike) at NeXT
  27.  *    Added defines for dl_bootfile and dl_boot0_blkno.
  28.  *    Reduced NBAD to allow for these entries in disktab.
  29.  *
  30.  * 29-Aug-87  John Seamons (jks) at NeXT
  31.  *    Created.
  32.  *
  33.  */
  34.  
  35. #ifndef    _M68K_DEV_DISK_PRIV_
  36. #define    _M68K_DEV_DISK_PRIV_
  37.  
  38. #import    <mach/machine/vm_types.h>
  39. #import    <mach/machine/boolean.h>
  40. #import <sys/types.h>
  41. #import <sys/ioctl.h>
  42. #import <sys/disktab.h>
  43. #import <sys/time.h>
  44.  
  45. struct disk_req {
  46.     int    dr_bcount;        /* byte coun()r data transfers */
  47.     caddr_t    dr_addr;        /* memory addr for data transfers */
  48.     struct    timeval dr_exec_time;    /* execution time of operation */
  49.  
  50.     /* interpretation of cmdblk and errblk is driver specific */
  51. #define    DR_CMDSIZE    32
  52. #define    DR_ERRSIZE    32
  53.     char    dr_cmdblk[DR_CMDSIZE];
  54.     char    dr_errblk[DR_ERRSIZE];
  55. };
  56.  
  57. struct sdc_wire {
  58.     vm_offset_t    start, end;
  59.     boolean_t    new_pageable;
  60. };
  61.  
  62. struct disk_label {
  63. #define    DL_V1        0x4e655854    /* version #1: "NeXT" */
  64. #define    DL_V2        0x646c5632    /* version #2: "dlV2" */
  65. #define    DL_V3        0x646c5633    /* version #3: "dlV3" */
  66. #define    DL_VERSION    DL_V3        /* default version */
  67.     int    dl_version;        /* label version number */
  68.     int    dl_label_blkno;        /* block # where this label is */
  69.     int    dl_size;        /* size of media area (sectors) */
  70. #define    MAXLBLLEN    24
  71.     char    dl_label[MAXLBLLEN];    /* media label */
  72.     u_int    dl_flags;        /* flags */
  73. #define    DL_UNINIT    0x80000000    /* label is uninitialized */
  74.     u_int    dl_tag;            /* volume tag */
  75.     struct    disktab dl_dt;        /* common info in disktab */
  76. #define    dl_name        dl_dt.d_name
  77. #define    dl_type        dl_dt.d_type
  78. #define dl_part        dl_dt.d_partitions
  79. #define    dl_front    dl_dt.d_front
  80. #define    dl_back        dl_dt.d_back
  81. #define    dl_ngroups    dl_dt.d_ngroups
  82. #define    dl_ag_size    dl_dt.d_ag_size
  83. #define    dl_ag_alts    dl_dt.d_ag_alts
  84. #define    dl_ag_off    dl_dt.d_ag_off
  85. #define    dl_secsize    dl_dt.d_secsize
  86. #define    dl_ncyl        dl_dt.d_ncylinders
  87. #define    dl_nsect    dl_dt.d_nsectors
  88. #define    dl_ntrack    dl_dt.d_ntracks
  89. #define    dl_rpm        dl_dt.d_rpm
  90. #define    dl_bootfile    dl_dt.d_bootfile
  91. #define    dl_boot0_blkno    dl_dt.d_boot0_blkno
  92. #define    dl_hostname    dl_dt.d_hostname
  93. #define    dl_rootpartition dl_dt.d_rootpartition
  94. #define    dl_rwpartition    dl_dt.d_rwpartition
  95.  
  96.     /*
  97.      *  if dl_version >= DL_V3 then the bad block table is relocated
  98.      *  to a structure separate from the disk label.
  99.      */
  100.     union {
  101.         u_short    DL_v3_checksum;
  102. #define    NBAD    1670            /* sized to make label ~= 8KB */
  103.         int    DL_bad[NBAD];    /* block number that is bad */
  104.     } dl_un;
  105. #define    dl_v3_checksum    dl_un.DL_v3_checksum
  106. #define    dl_bad        dl_un.DL_bad
  107.     u_short    dl_checksum;        /* ones complement checksum */
  108.     
  109.     /* add things here so dl_checksum stays in a fixed place */
  110. };
  111.  
  112. #define    BAD_BLK_OFF    4        /* offset of bad blk tbl from label */
  113. struct bad_block {            /* bad block table, sized to be 12KB */
  114. #define    NBAD_BLK    (12 * 1024 / sizeof (int))
  115.     int    bad_blk[NBAD_BLK];
  116. };
  117.  
  118. /* sector bitmap stat(02 bits per sector) */
  119. #define    SB_UNTESTED    0    /* must be zero */
  120. #define    SB_BAD        1
  121. #define    SB_WRITTEN    2
  122. #define    SB_ERASED    3
  123.  
  124. struct drive_info {            /* info about drive hardware */
  125.     char    di_name[MAXDNMLEN];    /* drive type name */
  126. #define    NLABELS    4
  127.     int    di_label_blkno[NLABELS];/* label loc'ns in DEVICE SECTORS */
  128.     int    di_devblklen;        /* device sector size */
  129.     int    di_maxbcount;        /* max bytes per transfer request */
  130. };
  131.  
  132. struct    disk_stats {
  133.     int    s_ecccnt;    /* avg ECC corrections per sector */
  134.     int    s_maxecc;    /* max ECC corrections observed */
  135.  
  136.     /* interpretation of s_stats is driver specific */
  137. #define    DS_STATSIZE    32
  138.     char    s_stats[DS_STATSIZE];
  139. };
  140.  
  141. #define    DKIOCGLABEL    _IO('d', 0)            // read label
  142. #define    DKIOCSLABEL    _IO('d', 1)            // write label
  143. #define    DKIOCGBITMAP    _IO('d', 2)            // read bitmap
  144. #define    DKIOCSBITMAP    _IO('d', 3)            // write bitmap
  145. #define    DKIOCREQ    _IOWR('d', 4, struct disk_req)    // cmd request
  146. #define    DKIOCINFO    _IOR('d', 5, struct drive_info)    // get drive info
  147. #define    DKIOCZSTATS    _IO('d',7)            // zero statistics
  148. #define    DKIOCGSTATS    _IO('d', 8)            // get statistics
  149. #define    DKIOCRESET    _IO('d', 9)            // reset disk
  150. #define    DKIOCGFLAGS    _IOR('d', 11, int)        // get driver flags
  151. #define    DKIOCSFLAGS    _IOW('d', 12, int)        // set driver flags
  152. #define    DKIOCSDCWIRE    _IOW('d', 14, struct sdc_wire)    // sdc wire memory
  153. #define    DKIOCSDCLOCK    _IO('d', 15)            // sdc lock
  154. #define    DKIOCSDCUNLOCK    _IO('d', 16)            // sdc unlock
  155. #define    DKIOCGFREEVOL    _IOR('d', 17, int)        // get free volume #
  156. #define    DKIOCGBBT    _IO('d', 18)            // read bad blk tbl
  157. #define    DKIOCSBBT    _IO('d', 19)            // write bad blk tbl
  158. #define    DKIOCMNOTIFY    _IOW('d', 20, int)        // message on insert
  159. #define    DKIOCEJECT    _IO('d', 21)            // eject disk
  160. #define    DKIOCPANELPRT    _IOW('d', 22, int)        // register Panel
  161.                             // Request port
  162. #define DKIOCSFORMAT    _IOW('d', 23, int)        // set 'Formatted' flag 
  163. #define DKIOCGFORMAT    _IOR('d', 23, int)        // get 'Formatted' flag 
  164.  
  165. #endif    _M68K_DEV_DISK_PRIV_
  166.