home *** CD-ROM | disk | FTP | other *** search
/ Jason Aller Floppy Collection / 202.img / SCO386N2.TD0 / usr / include / sys / dio.h < prev    next >
Encoding:
C/C++ Source or Header  |  1988-05-18  |  5.4 KB  |  179 lines

  1. /*
  2.  *    @(#) dio.h 2.1 88/05/18 
  3.  *
  4.  *    Copyright (C) The Santa Cruz Operation, 1984, 1985, 1986, 1987.
  5.  *    Copyright (C) Microsoft Corporation, 1984, 1985, 1986, 1987.
  6.  *    This Module contains Proprietary Information of
  7.  *    The Santa Cruz Operation, Microsoft Corporation
  8.  *    and AT&T, and should be treated as Confidential.
  9.  */
  10.  
  11. /*
  12.  * header file for sco standard bad track scheme
  13.  */
  14.  
  15. /*
  16.  * minor device number macros
  17.  */
  18. #define dmask(x)           ((1 << (x)) - 1)
  19. #define    dphys(ptr,x)       (((unsigned)(x) >> ( 8 - (ptr)->physbits)) & \
  20.                   dmask((ptr)->physbits))
  21. #define    dlog(ptr,x)       (((unsigned)(x) >> (ptr)->partbits) & \
  22.                                   dmask((ptr)->logbits))
  23. #define    dpart(ptr,x)        ((unsigned)(x) & \
  24.                                   dmask((ptr)->partbits)) 
  25. #define    dmkdev(ptr,d,l,p)  (((unsigned)(d) << (8 - (ptr)->physbits)) | \
  26.                             ((unsigned)(l) << (ptr)->partbits) | \
  27.                             ((unsigned)(p)))
  28.  
  29. /*
  30.  * ioctl interface
  31.  */
  32. #define    DIO        ('D'<<8)
  33. #define    DIOGETP        (DIO|1)        /* get disk parameters */
  34. #define    DIOSETP        (DIO|2)        /* set disk parameters */
  35. #define    DIORPART    (DIO|3)        /* read partition table */
  36. #define    DIOWPART    (DIO|4)        /* write partition table */
  37. #define    DIORBTRK    (DIO|5)        /* read bad track table - fails in 2.2*/
  38. #define    DIOWBTRK    (DIO|6)        /* write bad track table -fails in 2.2*/
  39. #define DIOBITP         (DIO|7)         /* get bit parameters */
  40. #define DIORVDT         (DIO|8)         /* read virt. drive table */
  41. #define DIOWVDT         (DIO|9)         /* write virt. drive table */
  42. #define    DIOSDISK    (DIO|10)    /* Size disk characeristics    */
  43. #define    DIORDISK    (DIO|11)    /* Read disk characteristics    */
  44. #define    DIOWDISK    (DIO|12)    /* Write disk characteristics    */
  45. #define    DIOSBTRK    (DIO|13)    /* Set badtracks/virt. drive */
  46. #define    DIORBTRK22    (DIO|14)    /* read bad track table - for 2.2  */
  47. #define    DIOWBTRK22    (DIO|15)    /* write bad track table - for 2.2 */
  48. #define    DIODKTYPE    (DIO|16)    /* which disk type are we?    */
  49. #define    DIOFORCE22    (DIO|17)    /* force driver into 2.2 mode    */
  50.  
  51. /* 
  52.  Definitions for space used by system routines in the hard disk area.  Note that
  53.  they are in sector(512 byte) quantities.  The size of the badtrack table is not
  54.  defined here because it can vary - it grew from 2 to 8 with Release 2.2.
  55.  */
  56.     
  57. #define    BOOTZERO    2    /* Really only 1, but 1 more is reserved */
  58. #define    DIVVYTBL    2    /* Size of divvy table             */
  59. #define    BOOTONE        40    /* Maximum size of boot1 code         */
  60. #define    BTABMAX        8    /* Maximum size of badtrack table     */
  61.                 /* Number of sectors at start of virtual */
  62.                 /* drive that must be good (error free)  */
  63. #define    GDSECS        (BOOTZERO+DIVVYTBL+BOOTONE+BTABMAX)
  64.  
  65. /*
  66.  * table sizes
  67.  */
  68.  
  69. #define MAXPARTS   16                       /* max partitions possible*/
  70. #define MAXALTS    1023                     /* max alternate tracks possible */
  71. #define MAXVDRIVES 16                       /* max virtual drives possible */
  72.  
  73. #define NPARTS(ptr) (1 << ((ptr)->partbits))/* this dev's # of partitions   */
  74. #define NVIRTS(ptr) (1 << ((ptr)->logbits ))/* this dev's # of virt. drives */
  75. #define NPHYS(ptr)  (1 << ((ptr)->physbits))/* this dev's # of phys drives  */
  76.  
  77. /*
  78.  * magic numbers
  79.  */
  80. #define    PAMAGIC    0x1234    /* magic number for partition table */
  81. #define    BAMAGIC    0x4321    /* magic number for bad track table */
  82. #define    VAMAGIC    0x1342    /* magic number for virtual drive table */
  83.  
  84. #ifdef M_I386
  85. #pragma pack(2)
  86. #endif
  87.  
  88. /*
  89.  * table format for DIOGETP, DIOSETP
  90.  */
  91. struct dparam {
  92.     unsigned short d_cylin;        /* cylinders per drive */
  93.     unsigned short d_heads;        /* heads per drive */
  94.     unsigned short d_sectors;    /* sectors per cylinder */
  95.     unsigned short d_bytes;        /* bytes per sector */
  96.     unsigned short d_reserved;      /* sectors reserved for system use */
  97.                     /* at beginning of disk */
  98. };
  99.  
  100.  
  101. /*
  102.  * table format for DIORPART, DIOWPART
  103.  * partitions of zero size are considered non-existant
  104.  */
  105. struct partable {
  106.     unsigned short p_magic;        /* magic number validity indicator */
  107.     struct parts {
  108.         long p_off;        /* offset of partition */
  109.         long p_siz;        /* size of partition */
  110.     } p[MAXPARTS];
  111. };
  112.  
  113. #ifdef M_I386
  114. #pragma pack()
  115. #endif
  116.  
  117. /*
  118.  * table format for DIORBTRK, DIOWBTRK
  119.  * alternate list stored in sorted order by b_trk terminated
  120.  * by a -1 in b_trk
  121.  */
  122.  struct badtab {
  123.     unsigned short b_magic;
  124.     unsigned short b_maxbad; 
  125.     struct badtrks {
  126.         unsigned short b_trk;
  127.         unsigned short b_alt;
  128.     } b[MAXALTS];
  129. };
  130.  
  131. #ifdef M_I386
  132. #pragma pack(2)
  133. #endif
  134.  
  135. /* table format for DIOBITP
  136.  * Get makeup of minor device number, which is how many bits of the
  137.  * number are the partition number, how many are the virtual drive,
  138.  * and how many are the physical drive
  139.  */
  140. struct dbitparams {
  141.     short partbits;
  142.     short logbits;
  143.     short physbits;
  144. };
  145.  
  146. #ifdef M_I386
  147. #pragma pack()
  148. #endif
  149.  
  150. /* table format for DIORVDT, DIOWVDT
  151.  * Get/set the contents of the virtual drive table
  152.  * which lists what operating system can be found
  153.  * in each virtual drive, and the sizes of each.
  154.  */
  155.  
  156. #define NOTACTIVE 0x00
  157. #define ACTIVE    0x80
  158.  
  159. #define NO_OS        0
  160. #define DOS          1
  161. #define DOSL         4        /* different number for "large" DOS */
  162. #define XENIX        2
  163. #define CCPM         0xDB
  164. #define AVIRT         5        /* active virtual drive (bootable) */
  165. #define DOSVIRT         6        /* DOS virtual drive */
  166.  
  167. struct vdtab {
  168.     unsigned short v_magic;
  169.     unsigned short v_nvds;
  170.     struct vdisk {
  171.         unsigned short v_active;
  172.         unsigned short v_os;
  173.         long v_off;
  174.         long v_size;
  175.         long v_reserved;       /* sectors reserved for system use */
  176.     } v_vdisk[MAXVDRIVES];
  177. };
  178.  
  179.