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