1 /*	$NetBSD: disklabel_rdb.h,v 1.2 2010/06/19 08:45:25 kiyohara 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 /*
36  * describes ados Rigid Disk Blocks
37  * which are used to partition a drive
38  */
39 #define RDBNULL ((u_long)0xffffffff)
40 
41 /*
42  * you will find rdblock somewhere in [0, RDBMAXBLOCKS)
43  */
44 #define RDB_MAXBLOCKS	16
45 
46 struct rdblock {
47 	u_long id;		/* 'RDSK' */
48 	u_long nsumlong;	/* number of longs in check sum */
49 	u_long chksum;		/* simple additive with wrap checksum */
50 	u_long hostid;		/* scsi target of host */
51 	u_long nbytes;		/* size of disk blocks */
52 	u_long flags;
53 	u_long badbhead;	/* linked list of badblocks */
54 	u_long partbhead;	/* linked list of partblocks */
55 	u_long fsbhead;		/*   "     "   of fsblocks */
56 	u_long driveinit;
57 	u_long resv1[6];	/* RDBNULL */
58 	u_long ncylinders;	/* number of cylinders on drive */
59 	u_long nsectors;	/* number of sectors per track */
60 	u_long nheads;		/* number of tracks per cylinder */
61 	u_long interleave;
62 	u_long park;		/* only used with st506 i.e. not */
63 	u_long resv2[3];
64 	u_long wprecomp;	/* start cyl for write precomp */
65 	u_long reducedwrite;	/* start cyl for reduced write current */
66 	u_long steprate;	/* driver step rate in ?s */
67 	u_long resv3[5];
68 	u_long rdblowb;		/* lowblock of range for rdb's */
69 	u_long rdbhighb;	/* high block of range for rdb's */
70 	u_long lowcyl;		/* low cylinder of partition area */
71 	u_long highcyl;		/* upper cylinder of partition area */
72 	u_long secpercyl;	/* number of sectors per cylinder */
73 	u_long parkseconds;	/* zero if no park needed */
74 	u_long resv4[2];
75 	char   diskvendor[8];	/* inquiry stuff */
76 	char   diskproduct[16];	/* inquiry stuff */
77 	char   diskrevision[4];	/* inquiry stuff */
78 	char   contvendor[8];	/* inquiry stuff */
79 	char   contproduct[16];	/* inquiry stuff */
80 	char   contrevision[4];	/* inquiry stuff */
81 #if never_use_secsize
82 	u_long resv5[0];
83 #endif
84 };
85 
86 
87 #define RDBF_LAST	0x1	/* last drive available */
88 #define RDBF_LASTLUN	0x2	/* last LUN available */
89 #define RDBF_LASTUNIT	0x4	/* last target available */
90 #define RDBF_NORESELECT	0x8	/* do not use reselect */
91 #define RDBF_DISKID	0x10	/* disk id is valid ?? */
92 #define RDBF_CTRLID	0x20	/* ctrl id is valid ?? */
93 #define RDBF_SYNC	0x40	/* drive supports SCSI synchronous mode */
94 
95 struct ados_environ {
96 	u_long tabsize;		/* 0: environ table size */
97 	u_long sizeblock;	/* 1: n long words in a block */
98 	u_long secorg;		/* 2: not used must be zero */
99 	u_long numheads;	/* 3: number of surfaces */
100 	u_long secperblk;	/* 4: must be 1 */
101 	u_long secpertrk;	/* 5: blocks per track */
102 	u_long resvblocks;	/* 6: reserved blocks at start */
103 	u_long prefac;		/* 7: must be 0 */
104 	u_long interleave;	/* 8: normally 1 */
105 	u_long lowcyl;		/* 9: low cylinder of partition */
106 	u_long highcyl;		/* 10: upper cylinder of partition */
107 	u_long numbufs;		/* 11: ados: number of buffers */
108 	u_long membuftype;	/* 12: ados: type of bufmem */
109 	u_long maxtrans;	/* 13: maxtrans the ctrlr supports */
110 	u_long mask;		/* 14: mask for valid address */
111 	u_long bootpri;		/* 15: boot priority for autoboot */
112 	u_long dostype;		/* 16: filesystem type */
113 	u_long baud;		/* 17: serial handler baud rate */
114 	u_long control;		/* 18: control word for fs */
115 	u_long bootblocks;	/* 19: blocks containing boot code */
116 	u_long fsize;		/* 20: file system block size */
117 	u_long frag;		/* 21: allowable frags per block */
118 	u_long cpg;		/* 22: cylinders per group */
119 };
120 
121 struct partblock {
122 	u_long id;		/* 'PART' */
123 	u_long nsumlong;	/* number of longs in check sum */
124 	u_long chksum;		/* simple additive with wrap checksum */
125 	u_long hostid;		/* scsi target of host */
126 	u_long next;		/* next in chain */
127 	u_long flags;		/* see below */
128 	u_long resv1[3];
129 	u_char partname[32];	/* (BCPL) part name (may not be unique) */
130 	u_long resv2[15];
131 	struct ados_environ e;
132 #if never_use_secsize
133 	u_long extra[9];	/* 8 for extra added to environ */
134 #endif
135 };
136 
137 #define PBF_BOOTABLE	0x1	/* partition is bootable */
138 #define PBF_NOMOUNT	0x2	/* partition should be mounted */
139 
140 struct badblock {
141 	u_long id;		/* 'BADB' */
142 	u_long nsumlong;	/* number of longs in check sum */
143 	u_long chksum;		/* simple additive with wrap checksum */
144 	u_long hostid;		/* scsi target of host */
145 	u_long next;		/* next in chain */
146 	u_long resv;
147 	struct badblockent {
148 		u_long badblock;
149 		u_long goodblock;
150 	} badtab[0];		/* 61 for secsize == 512 */
151 };
152 
153 struct fsblock {
154 	u_long id;		/* 'FSHD' */
155 	u_long nsumlong;	/* number of longs in check sum */
156 	u_long chksum;		/* simple additive with wrap checksum */
157 	u_long hostid;		/* scsi target of host */
158 	u_long next;		/* next in chain */
159 	u_long flags;
160 	u_long resv1[2];
161 	u_long dostype;		/* this is a file system for this type */
162 	u_long version;		/* version of this fs */
163 	u_long patchflags;	/* describes which functions to replace */
164 	u_long type;		/* zero */
165 	u_long task;		/* zero */
166 	u_long lock;		/* zero */
167 	u_long handler;		/* zero */
168 	u_long stacksize;	/* to use when loading handler */
169 	u_long priority;	/* to run the fs at. */
170 	u_long startup;		/* zero */
171 	u_long lsegblocks;	/* linked list of lsegblocks of fs code */
172 	u_long globalvec;	/* bcpl vector not used mostly */
173 #if never_use_secsize
174 	u_long resv2[44];
175 #endif
176 };
177 
178 struct lsegblock {
179 	u_long id;		/* 'LSEG' */
180 	u_long nsumlong;	/* number of longs in check sum */
181 	u_long chksum;		/* simple additive with wrap checksum */
182 	u_long hostid;		/* scsi target of host */
183 	u_long next;		/* next in chain */
184 	u_long loaddata[0];	/* load segment data, 123 for secsize == 512 */
185 };
186 
187 #define RDBLOCK_ID	0x5244534b	/* 'RDSK' */
188 #define PARTBLOCK_ID	0x50415254	/* 'PART' */
189 #define BADBLOCK_ID	0x42414442	/* 'BADB' */
190 #define FSBLOCK_ID	0x46534844	/* 'FSHD' */
191 #define LSEGBLOCK_ID	0x4c534547	/* 'LSEG' */
192 
193 /*
194  * Dos types for identifying file systems
195  * bsd file systems will be 'N','B',x,y where y is the fstype found in
196  * disklabel.h (for DOST_DOS it will be the version number)
197  */
198 #define DOST_XXXBSD	0x42534400	/* Old type back compat*/
199 #define DOST_NBR	0x4e425200	/* 'NBRx' NetBSD root partition */
200 #define DOST_NBS	0x4e425300	/* 'NBS0' NetBSD swap partition */
201 #define DOST_NBU	0x4e425500	/* 'NBUx' NetBSD user partition */
202 #define DOST_DOS	0x444f5300	/* 'DOSx' AmigaDos partition */
203 #define DOST_AMIX	0x554e4900	/* 'UNIx' AmigaDos partition */
204 #define DOST_MUFS	0x6d754600	/* 'muFx' AmigaDos partition (muFS) */
205 #define DOST_EXT2	0x4c4e5800	/* 'LNX0' Linux fs partition (ext2fs) */
206 #define DOST_LNXSWP	0x53575000	/* 'SWP0' Linux swap partition */
207 #define DOST_RAID	0x52414900	/* 'RAID' Raidframe partition */
208 #define DOST_MSD	0x4d534400	/* 'MSDx' MSDOS partition */
209 #define DOST_SFS	0x53465300	/* 'SFSx' Smart fs partition */
210 
211 struct adostype {
212 	u_char archtype;	/* see ADT_xxx below */
213 	u_char fstype;		/* byte 3 from amiga dostype */
214 };
215 
216 /* archtypes */
217 #define ADT_UNKNOWN	0
218 #define ADT_AMIGADOS	1
219 #define ADT_NETBSDROOT	2
220 #define ADT_NETBSDSWAP	3
221 #define ADT_NETBSDUSER	4
222 #define ADT_AMIX	5
223 #define ADT_EXT2	6
224 #define ADT_RAID	7
225 #define ADT_MSD		8
226 #define ADT_SFS		9
227 
228 #define ISFSARCH_NETBSD(adt) \
229 	((adt).archtype >= ADT_NETBSDROOT && (adt).archtype <= ADT_NETBSDUSER)
230 
231 #endif /* _SYS_DISKLABEL_RDB_H_ */
232