Home | History | Annotate | Line # | Download | only in sys
disklabel_rdb.h revision 1.4
      1 /*	$NetBSD: disklabel_rdb.h,v 1.4 2017/02/26 11:51:38 rin Exp $	*/
      2 
      3 /*
      4  * Copyright (c) 1994 Christian E. Hopps
      5  * All rights reserved.
      6  *
      7  * Redistribution and use in source and binary forms, with or without
      8  * modification, are permitted provided that the following conditions
      9  * are met:
     10  * 1. Redistributions of source code must retain the above copyright
     11  *    notice, this list of conditions and the following disclaimer.
     12  * 2. Redistributions in binary form must reproduce the above copyright
     13  *    notice, this list of conditions and the following disclaimer in the
     14  *    documentation and/or other materials provided with the distribution.
     15  * 3. All advertising materials mentioning features or use of this software
     16  *    must display the following acknowledgement:
     17  *      This product includes software developed by Christian E. Hopps.
     18  * 4. The name of the author may not be used to endorse or promote products
     19  *    derived from this software without specific prior written permission
     20  *
     21  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     22  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     23  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     24  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     25  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     26  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     30  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     31  */
     32 #ifndef _SYS_DISKLABEL_RDB_H_
     33 #define _SYS_DISKLABEL_RDB_H_
     34 
     35 #include <sys/types.h>
     36 
     37 /*
     38  * describes ados Rigid Disk Blocks
     39  * which are used to partition a drive
     40  */
     41 #define RDBNULL ((uint32_t)0xffffffff)
     42 
     43 /*
     44  * you will find rdblock somewhere in [0, RDBMAXBLOCKS)
     45  */
     46 #define RDB_MAXBLOCKS	16
     47 
     48 struct rdblock {
     49 	uint32_t id;		/* 'RDSK' */
     50 	uint32_t nsumlong;	/* number of long words in check sum */
     51 	uint32_t chksum;	/* simple additive with wrap checksum */
     52 	uint32_t hostid;	/* scsi target of host */
     53 	uint32_t nbytes;	/* size of disk blocks */
     54 	uint32_t flags;
     55 	uint32_t badbhead;	/* linked list of badblocks */
     56 	uint32_t partbhead;	/* linked list of partblocks */
     57 	uint32_t fsbhead;	/*   "     "   of fsblocks */
     58 	uint32_t driveinit;
     59 	uint32_t resv1[6];	/* RDBNULL */
     60 	uint32_t ncylinders;	/* number of cylinders on drive */
     61 	uint32_t nsectors;	/* number of sectors per track */
     62 	uint32_t nheads;	/* number of tracks per cylinder */
     63 	uint32_t interleave;
     64 	uint32_t park;		/* only used with st506 i.e. not */
     65 	uint32_t resv2[3];
     66 	uint32_t wprecomp;	/* start cyl for write precomp */
     67 	uint32_t reducedwrite;	/* start cyl for reduced write current */
     68 	uint32_t steprate;	/* driver step rate in ?s */
     69 	uint32_t resv3[5];
     70 	uint32_t rdblowb;	/* lowblock of range for rdb's */
     71 	uint32_t rdbhighb;	/* high block of range for rdb's */
     72 	uint32_t lowcyl;	/* low cylinder of partition area */
     73 	uint32_t highcyl;	/* upper cylinder of partition area */
     74 	uint32_t secpercyl;	/* number of sectors per cylinder */
     75 	uint32_t parkseconds;	/* zero if no park needed */
     76 	uint32_t resv4[2];
     77 	char   diskvendor[8];	/* inquiry stuff */
     78 	char   diskproduct[16];	/* inquiry stuff */
     79 	char   diskrevision[4];	/* inquiry stuff */
     80 	char   contvendor[8];	/* inquiry stuff */
     81 	char   contproduct[16];	/* inquiry stuff */
     82 	char   contrevision[4];	/* inquiry stuff */
     83 #if never_use_secsize
     84 	uint32_t resv5[0];
     85 #endif
     86 };
     87 
     88 
     89 #define RDBF_LAST	0x1	/* last drive available */
     90 #define RDBF_LASTLUN	0x2	/* last LUN available */
     91 #define RDBF_LASTUNIT	0x4	/* last target available */
     92 #define RDBF_NORESELECT	0x8	/* do not use reselect */
     93 #define RDBF_DISKID	0x10	/* disk id is valid ?? */
     94 #define RDBF_CTRLID	0x20	/* ctrl id is valid ?? */
     95 #define RDBF_SYNC	0x40	/* drive supports SCSI synchronous mode */
     96 
     97 struct ados_environ {
     98 	uint32_t tabsize;	/* 0: environ table size */
     99 	uint32_t sizeblock;	/* 1: n long words in a block */
    100 	uint32_t secorg;	/* 2: not used must be zero */
    101 	uint32_t numheads;	/* 3: number of surfaces */
    102 	uint32_t secperblk;	/* 4: must be 1 */
    103 	uint32_t secpertrk;	/* 5: blocks per track */
    104 	uint32_t resvblocks;	/* 6: reserved blocks at start */
    105 	uint32_t prefac;	/* 7: must be 0 */
    106 	uint32_t interleave;	/* 8: normally 1 */
    107 	uint32_t lowcyl;	/* 9: low cylinder of partition */
    108 	uint32_t highcyl;	/* 10: upper cylinder of partition */
    109 	uint32_t numbufs;	/* 11: ados: number of buffers */
    110 	uint32_t membuftype;	/* 12: ados: type of bufmem */
    111 	uint32_t maxtrans;	/* 13: maxtrans the ctrlr supports */
    112 	uint32_t mask;		/* 14: mask for valid address */
    113 	uint32_t bootpri;	/* 15: boot priority for autoboot */
    114 	uint32_t dostype;	/* 16: filesystem type */
    115 	uint32_t baud;		/* 17: serial handler baud rate */
    116 	uint32_t control;	/* 18: control word for fs */
    117 	uint32_t bootblocks;	/* 19: blocks containing boot code */
    118 	uint32_t fsize;		/* 20: file system block size */
    119 	uint32_t frag;		/* 21: allowable frags per block */
    120 	uint32_t cpg;		/* 22: cylinders per group */
    121 };
    122 
    123 struct partblock {
    124 	uint32_t id;		/* 'PART' */
    125 	uint32_t nsumlong;	/* number of long words in check sum */
    126 	uint32_t chksum;	/* simple additive with wrap checksum */
    127 	uint32_t hostid;	/* scsi target of host */
    128 	uint32_t next;		/* next in chain */
    129 	uint32_t flags;		/* see below */
    130 	uint32_t resv1[3];
    131 	unsigned char partname[32]; /* (BCPL) part name (may not be unique) */
    132 	uint32_t resv2[15];
    133 	struct ados_environ e;
    134 #if never_use_secsize
    135 	uint32_t extra[9];	/* 8 for extra added to environ */
    136 #endif
    137 };
    138 
    139 #define PBF_BOOTABLE	0x1	/* partition is bootable */
    140 #define PBF_NOMOUNT	0x2	/* partition should be mounted */
    141 
    142 struct badblock {
    143 	uint32_t id;		/* 'BADB' */
    144 	uint32_t nsumlong;	/* number of long words in check sum */
    145 	uint32_t chksum;	/* simple additive with wrap checksum */
    146 	uint32_t hostid;	/* scsi target of host */
    147 	uint32_t next;		/* next in chain */
    148 	uint32_t resv;
    149 	struct badblockent {
    150 		uint32_t badblock;
    151 		uint32_t goodblock;
    152 	} badtab[0];		/* 61 for secsize == 512 */
    153 };
    154 
    155 struct fsblock {
    156 	uint32_t id;		/* 'FSHD' */
    157 	uint32_t nsumlong;	/* number of long words in check sum */
    158 	uint32_t chksum;	/* simple additive with wrap checksum */
    159 	uint32_t hostid;	/* scsi target of host */
    160 	uint32_t next;		/* next in chain */
    161 	uint32_t flags;
    162 	uint32_t resv1[2];
    163 	uint32_t dostype;	/* this is a file system for this type */
    164 	uint32_t version;	/* version of this fs */
    165 	uint32_t patchflags;	/* describes which functions to replace */
    166 	uint32_t type;		/* zero */
    167 	uint32_t task;		/* zero */
    168 	uint32_t lock;		/* zero */
    169 	uint32_t handler;	/* zero */
    170 	uint32_t stacksize;	/* to use when loading handler */
    171 	uint32_t priority;	/* to run the fs at. */
    172 	uint32_t startup;	/* zero */
    173 	uint32_t lsegblocks;	/* linked list of lsegblocks of fs code */
    174 	uint32_t globalvec;	/* bcpl vector not used mostly */
    175 #if never_use_secsize
    176 	uint32_t resv2[44];
    177 #endif
    178 };
    179 
    180 struct lsegblock {
    181 	uint32_t id;		/* 'LSEG' */
    182 	uint32_t nsumlong;	/* number of long words in check sum */
    183 	uint32_t chksum;	/* simple additive with wrap checksum */
    184 	uint32_t hostid;	/* scsi target of host */
    185 	uint32_t next;		/* next in chain */
    186 	uint32_t loaddata[0];	/* load segment data, 123 for secsize == 512 */
    187 };
    188 
    189 #define RDBLOCK_ID	0x5244534b	/* 'RDSK' */
    190 #define PARTBLOCK_ID	0x50415254	/* 'PART' */
    191 #define BADBLOCK_ID	0x42414442	/* 'BADB' */
    192 #define FSBLOCK_ID	0x46534844	/* 'FSHD' */
    193 #define LSEGBLOCK_ID	0x4c534547	/* 'LSEG' */
    194 
    195 /*
    196  * Dos types for identifying file systems
    197  * bsd file systems will be 'N','B',x,y where y is the fstype found in
    198  * disklabel.h (for DOST_DOS it will be the version number)
    199  */
    200 #define DOST_XXXBSD	0x42534400	/* Old type back compat*/
    201 #define DOST_NBR	0x4e425200	/* 'NBRx' NetBSD root partition */
    202 #define DOST_NBS	0x4e425300	/* 'NBS0' NetBSD swap partition */
    203 #define DOST_NBU	0x4e425500	/* 'NBUx' NetBSD user partition */
    204 #define DOST_DOS	0x444f5300	/* 'DOSx' AmigaDos partition */
    205 #define DOST_AMIX	0x554e4900	/* 'UNIx' AmigaDos partition */
    206 #define DOST_MUFS	0x6d754600	/* 'muFx' AmigaDos partition (muFS) */
    207 #define DOST_EXT2	0x4c4e5800	/* 'LNX0' Linux fs partition (ext2fs) */
    208 #define DOST_LNXSWP	0x53575000	/* 'SWP0' Linux swap partition */
    209 #define DOST_RAID	0x52414900	/* 'RAID' Raidframe partition */
    210 #define DOST_MSD	0x4d534400	/* 'MSDx' MSDOS partition */
    211 #define DOST_SFS	0x53465300	/* 'SFSx' Smart fs partition */
    212 
    213 struct adostype {
    214 	unsigned char archtype;	/* see ADT_xxx below */
    215 	unsigned char fstype;	/* byte 3 from amiga dostype */
    216 };
    217 
    218 /* archtypes */
    219 #define ADT_UNKNOWN	0
    220 #define ADT_AMIGADOS	1
    221 #define ADT_NETBSDROOT	2
    222 #define ADT_NETBSDSWAP	3
    223 #define ADT_NETBSDUSER	4
    224 #define ADT_AMIX	5
    225 #define ADT_EXT2	6
    226 #define ADT_RAID	7
    227 #define ADT_MSD		8
    228 #define ADT_SFS		9
    229 
    230 #define ISFSARCH_NETBSD(adt) \
    231 	((adt).archtype >= ADT_NETBSDROOT && (adt).archtype <= ADT_NETBSDUSER)
    232 
    233 #endif /* _SYS_DISKLABEL_RDB_H_ */
    234