home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 4 Drivers / 04-Drivers.zip / vraid22.zip / dsklayout.h next >
C/C++ Source or Header  |  2000-03-16  |  5KB  |  192 lines

  1. /*
  2.  * $Source: r:/source/driver/raid/RCS/dsklayout.h,v $
  3.  * $Revision: 1.9 $
  4.  * $Date: 2000/03/17 02:07:23 $
  5.  * $Locker:  $
  6.  *
  7.  *    Describes layout of administrative disk sectors.
  8.  *
  9.  * $Log: dsklayout.h,v $
  10.  * Revision 1.9  2000/03/17 02:07:23  vitus
  11.  * - added EXTENDED_PARTTYPE
  12.  *
  13.  * Revision 1.8  1999/06/21 02:34:17  vitus
  14.  * - corrected my english (spelling)
  15.  *
  16.  * Revision 1.7  1999/05/12 01:38:06  vitus
  17.  * - SEC_VRDEV2: new layout
  18.  * - moved RDFLAGS_* from driver specific header
  19.  *
  20.  * Revision 1.6  1999/01/22 02:54:08  vitus
  21.  * - added VRAIDEVICE2 sectors (preliminary)
  22.  *
  23.  * Revision 1.5  1998/12/22 00:03:10  vitus
  24.  * - added missing "#pragma pack()".  Silly bug.
  25.  *
  26.  * Revision 1.4  1998/06/26 22:11:22  vitus
  27.  * - removed flags from SEC_PHYSDEV
  28.  *
  29.  * Revision 1.3  1998/05/29 01:39:53  vitus
  30.  * - changed definition of STRIPE,CHAIN
  31.  * - SINGLE is now valid type of VRAIDDEVICE sector
  32.  *
  33.  * Revision 1.2  1998/04/08 01:05:01  vitus
  34.  * - changed unnamed to named structures (IBM Compiler)
  35.  * - added size to child definition
  36.  * - removed bitfield usage (probs with different compilers)
  37.  *
  38.  * Revision 1.1  1998/03/10 02:25:09  vitus
  39.  * Initial revision
  40.  * ---------------------------------------------
  41.  * This code is Copyright Vitus Jensen 1997-2000
  42.  */
  43.  
  44. #ifndef _DSKSLAYOUT_H
  45. #define _DSKSLAYOUT_H
  46. #pragma pack(1)
  47.  
  48. #define SECTOR_SIZE        512
  49.  
  50.  
  51. /*
  52.  * Absolute sector 0 contains a standard partition table.
  53.  * A single partition is defined starting at absolute sector 1
  54.  * and including the rest of physical disk space.
  55.  */
  56. #define VRAID_PARTTYPE        0x7C
  57. #if !defined(EXTENDED_PARTTYPE)
  58. # define EXTENDED_PARTTYPE    0x05
  59. #endif
  60.  
  61.  
  62. /*
  63.  * Relative sectors 1 to n in partition are used for administrative data.
  64.  * May become variable in non-alpha versions...
  65.  */
  66. #define VRAID_ADMINSECTORS    32
  67.  
  68.  
  69. /*
  70.  * Layout of master boot record sector,
  71.  * imported from OS2DASD header file.
  72.  */
  73. typedef struct _PARTITIONENTRY {
  74.     UCHAR    BootIndicator;
  75.     UCHAR    BegHead;
  76.     UCHAR    BegSector;            /* plus 2 bits BegCylinder */
  77.     UCHAR    BegCylinder;
  78.     UCHAR    SysIndicator;
  79.     UCHAR    EndHead;
  80.     UCHAR    EndSector;            /* plus 2 bits EndCylinder */
  81.     UCHAR    EndCylinder;
  82.     ULONG    RelativeSectors;
  83.     ULONG    NumSectors;
  84. } PARTITIONENTRY, FAR * PPARTITIONENTRY;
  85.  
  86.  
  87. typedef struct _MBR {
  88.     UCHAR    Pad[0x1BE];
  89.     PARTITIONENTRY PartitionTable[4];
  90.     USHORT    Signature;
  91. } MBR, FAR * PMBR;
  92.  
  93.  
  94.  
  95.  
  96. /*
  97.  * All devices are marked with an unique ID.
  98.  * This could be build from two byte host ID (sum of BIOS image) and
  99.  * a time stamp (UNIX time = seconds since 1.1.1970) at creation of device.
  100.  */
  101. typedef UCHAR        DEVID[6];
  102. typedef DEVID FAR *    PDEVID;
  103.  
  104.  
  105. /*
  106.  * First configuration sector defines this physical device.  Currently
  107.  * only an ID is defined.
  108.  * Sector type: "PHYSDEVICE      "
  109.  */
  110. typedef struct _SEC_PHYSDEV {
  111.     UCHAR    sectype[16];            /* R: type of sector */
  112.     ULONG    timestamp;            /* R: when written */
  113.     union {
  114.     char        dummy[490];
  115.     struct {
  116.         DEVID    id;
  117.         USHORT    adminspace;        /* will be VRAID_ADMINSECTORS */
  118.         ULONG    size;            /* user size [sectors]} */
  119.     } s;
  120.     } u;
  121.     USHORT        crc;            /* CRC16 */
  122. } SEC_PHYSDEV, FAR * PSEC_PHYSDEV;
  123.  
  124.  
  125.  
  126.  
  127. /*
  128.  * Second and all further configuration sectors define
  129.  * the VRDEVICES build upon this disk.
  130.  * Sector type: "VRAIDDEVICE     ":
  131.  */
  132. typedef struct _SEC_VRDEV {
  133.     UCHAR    sectype[16];            /* R: type of sector */
  134.     ULONG    timestamp;            /* R: when written */
  135.     union {
  136.     char        dummy[490];
  137.     struct {
  138.         DEVID    id;
  139.         UCHAR    type;            /* RDTYPE_* */
  140.         UCHAR    flags;            /* RDFLAG_* */
  141.         USHORT    children;        /* entries in following table */
  142.         struct {
  143.         DEVID    id;
  144.         ULONG    size;            /* [sectors] */
  145.         } child[1];
  146.     } s;
  147.     } u;
  148.     USHORT        crc;            /* CRC16 */
  149. } SEC_VRDEV, FAR * PSEC_VRDEV;
  150.  
  151.  
  152. /* Sector type: "VRAIDDEVICE2    " */
  153. typedef struct _SEC_VRDEV2 {
  154.     UCHAR    sectype[16];            /* R: type of sector */
  155.     ULONG    timestamp;            /* R: when written */
  156.     union {
  157.     char        dummy[490];
  158.     struct {
  159.         DEVID    id;
  160.         UCHAR    type;            /* RDTYPE_* */
  161.         UCHAR    flags;            /* RDFLAG_* */
  162.         USHORT    children;        /* entries in following table */
  163.         struct {
  164.         DEVID    id;
  165.         UCHAR    flags;            /* bit 0: valid */
  166.         UCHAR    reserved;        /* to be defined */
  167.         ULONG    valid;            /* valid sector if(flags & 0x01)=0 */
  168.         ULONG    size;            /* [sectors] */
  169.         } child[1];
  170.     } s;
  171.     } u;
  172.     USHORT        crc;            /* CRC16 */
  173. } SEC_VRDEV2, FAR * PSEC_VRDEV2;
  174.  
  175. #define RDTYPE_SINGLE    1
  176. #define RDTYPE_CHAIN    2
  177. #define RDTYPE_STRIPE    3
  178. #define RDTYPE_MIRROR    4
  179. #define RDTYPE_RAID4    5
  180. #define RDTYPE_RAID5    6
  181.  
  182. #define RDFLAG_BUILDING        0x01        /* build or rebuild */
  183. #define RDFLAG_ERROR        0x02        /* array in ERROR state,
  184.                            no more I/Os possible */
  185. #define RDFLAG_FAIL        0x04        /* redundancy lost */
  186.  
  187. #define RDFLAG_HOSTDRIVE    0x80        /* a hostdrive, stop scanning */
  188.  
  189.  
  190. #pragma pack()
  191. #endif /* _DSKSLAYOUT_H */
  192.