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