xref: /minix/sys/sys/bootblock.h (revision 0a6a1f1d)
1 /*	$NetBSD: bootblock.h,v 1.57 2014/09/14 17:39:06 nonaka Exp $	*/
2 
3 /*-
4  * Copyright (c) 2002-2004 The NetBSD Foundation, Inc.
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  *
16  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
17  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
18  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
20  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26  * POSSIBILITY OF SUCH DAMAGE.
27  */
28 /*-
29  * Copyright (C) 1993	Allen K. Briggs, Chris P. Caputo,
30  *			Michael L. Finch, Bradley A. Grantham, and
31  *			Lawrence A. Kesteloot
32  * All rights reserved.
33  *
34  * Redistribution and use in source and binary forms, with or without
35  * modification, are permitted provided that the following conditions
36  * are met:
37  * 1. Redistributions of source code must retain the above copyright
38  *    notice, this list of conditions and the following disclaimer.
39  * 2. Redistributions in binary form must reproduce the above copyright
40  *    notice, this list of conditions and the following disclaimer in the
41  *    documentation and/or other materials provided with the distribution.
42  * 3. All advertising materials mentioning features or use of this software
43  *    must display the following acknowledgement:
44  *	This product includes software developed by the Alice Group.
45  * 4. The names of the Alice Group or any of its members may not be used
46  *    to endorse or promote products derived from this software without
47  *    specific prior written permission.
48  *
49  * THIS SOFTWARE IS PROVIDED BY THE ALICE GROUP ``AS IS'' AND ANY EXPRESS OR
50  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
51  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
52  * IN NO EVENT SHALL THE ALICE GROUP BE LIABLE FOR ANY DIRECT, INDIRECT,
53  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
54  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
55  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
56  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
57  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
58  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
59  *
60  */
61 /*
62  * Copyright (c) 1994, 1999 Christopher G. Demetriou
63  * All rights reserved.
64  *
65  * Redistribution and use in source and binary forms, with or without
66  * modification, are permitted provided that the following conditions
67  * are met:
68  * 1. Redistributions of source code must retain the above copyright
69  *    notice, this list of conditions and the following disclaimer.
70  * 2. Redistributions in binary form must reproduce the above copyright
71  *    notice, this list of conditions and the following disclaimer in the
72  *    documentation and/or other materials provided with the distribution.
73  * 3. All advertising materials mentioning features or use of this software
74  *    must display the following acknowledgement:
75  *      This product includes software developed by Christopher G. Demetriou
76  *      for the NetBSD Project.
77  * 4. The name of the author may not be used to endorse or promote products
78  *    derived from this software without specific prior written permission
79  *
80  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
81  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
82  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
83  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
84  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
85  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
86  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
87  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
88  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
89  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
90  */
91 /*
92  * Copyright (c) 1994 Rolf Grossmann
93  * All rights reserved.
94  *
95  * Redistribution and use in source and binary forms, with or without
96  * modification, are permitted provided that the following conditions
97  * are met:
98  * 1. Redistributions of source code must retain the above copyright
99  *    notice, this list of conditions and the following disclaimer.
100  * 2. Redistributions in binary form must reproduce the above copyright
101  *    notice, this list of conditions and the following disclaimer in the
102  *    documentation and/or other materials provided with the distribution.
103  * 3. All advertising materials mentioning features or use of this software
104  *    must display the following acknowledgement:
105  *      This product includes software developed by Rolf Grossmann.
106  * 4. The name of the author may not be used to endorse or promote products
107  *    derived from this software without specific prior written permission
108  *
109  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
110  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
111  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
112  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
113  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
114  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
115  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
116  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
117  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
118  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
119  */
120 
121 #ifndef _SYS_BOOTBLOCK_H
122 #define	_SYS_BOOTBLOCK_H
123 
124 #if !defined(__ASSEMBLER__)
125 #include <sys/cdefs.h>
126 #if defined(_KERNEL) || defined(_STANDALONE)
127 #include <sys/stdint.h>
128 #else
129 #include <stdint.h>
130 #endif
131 #endif	/* !defined(__ASSEMBLER__) */
132 
133 /* ------------------------------------------
134  * MBR (Master Boot Record) --
135  *	definitions for systems that use MBRs
136  */
137 
138 /*
139  * Layout of boot records:
140  *
141  *	Byte range	Use	Description
142  *	----------	---	-----------
143  *
144  *	0 - 2		FMP	JMP xxx, NOP
145  *	3 - 10		FP	OEM Name
146  *
147  *	11 - 61		FMP	FAT12/16 BPB
148  *				Whilst not strictly necessary for MBR,
149  *				GRUB reserves this area
150  *
151  *	11 - 89		P	FAT32 BPB
152  *				(are we ever going to boot off this?)
153  *
154  *
155  *	62 - 217	FMP	Boot code
156  *
157  *	90 - 217	P	FAT32 boot code
158  *
159  *	218 - 223	M	Win95b/98/me "drive time"
160  *		http://www.geocities.com/thestarman3/asm/mbr/95BMEMBR.htm#MYST
161  *				only changed if all 6 bytes are 0
162  *
163  *	224 - 436	FMP	boot code (continued)
164  *
165  *	437 - 439	M	WinNT/2K/XP MBR "boot language"
166  *		http://www.geocities.com/thestarman3/asm/mbr/Win2kmbr.htm
167  *				not needed by us
168  *
169  *	400 - 439	MP	NetBSD: mbr_bootsel
170  *
171  *	424 - 439	M	NetBSD: bootptn_guid (in GPT PMBR only)
172  *
173  *	440 - 443	M	WinNT/2K/XP Drive Serial Number (NT DSN)
174  *		http://www.geocities.com/thestarman3/asm/mbr/Win2kmbr.htm
175  *
176  *	444 - 445	FMP	bootcode or unused
177  *				NetBSD: mbr_bootsel_magic
178  *
179  *	446 - 509	M	partition table
180  *
181  *	510 - 511	FMP	magic number (0xAA55)
182  *
183  *	Use:
184  *	----
185  *	F	Floppy boot sector
186  *	M	Master Boot Record
187  *	P	Partition Boot record
188  *
189  */
190 
191 /*
192  * MBR (Master Boot Record)
193  */
194 #define	MBR_BBSECTOR		0	/* MBR relative sector # */
195 #define	MBR_BPB_OFFSET		11	/* offsetof(mbr_sector, mbr_bpb) */
196 #define	MBR_BOOTCODE_OFFSET	90	/* offsetof(mbr_sector, mbr_bootcode) */
197 #define	MBR_BS_OFFSET		400	/* offsetof(mbr_sector, mbr_bootsel) */
198 #define	MBR_BS_OLD_OFFSET	404	/* where mbr_bootsel used to be */
199 #define	MBR_GPT_GUID_OFFSET	424	/* location of partition GUID to boot */
200 #define	MBR_GPT_GUID_DEFAULT		/* default uninitialized GUID */ \
201 	{0xeee69d04,0x02f4,0x11e0,0x8f,0x5d,{0x00,0xe0,0x81,0x52,0x9a,0x6b}}
202 #define	MBR_DSN_OFFSET		440	/* offsetof(mbr_sector, mbr_dsn) */
203 #define	MBR_BS_MAGIC_OFFSET	444	/* offsetof(mbr_sector, mbr_bootsel_magic) */
204 #define	MBR_PART_OFFSET		446	/* offsetof(mbr_sector, mbr_part[0]) */
205 #define	MBR_MAGIC_OFFSET	510	/* offsetof(mbr_sector, mbr_magic) */
206 #define	MBR_MAGIC		0xaa55	/* MBR magic number */
207 #define	MBR_BS_MAGIC		0xb5e1	/* mbr_bootsel magic number */
208 #define	MBR_PART_COUNT		4	/* Number of partitions in MBR */
209 #define	MBR_BS_PARTNAMESIZE	8	/* Size of name mbr_bootsel nametab */
210 					/* (excluding trailing NUL) */
211 
212 		/* values for mbr_partition.mbrp_flag */
213 #define	MBR_PFLAG_ACTIVE	0x80	/* The active partition */
214 
215 		/* values for mbr_partition.mbrp_type */
216 #define	MBR_PTYPE_UNUSED	0x00	/* Unused */
217 #define	MBR_PTYPE_FAT12		0x01	/* 12-bit FAT */
218 #define	MBR_PTYPE_XENIX_ROOT	0x02	/* XENIX / */
219 #define	MBR_PTYPE_XENIX_USR	0x03	/* XENIX /usr */
220 #define	MBR_PTYPE_FAT16S	0x04	/* 16-bit FAT, less than 32M */
221 #define	MBR_PTYPE_EXT		0x05	/* extended partition */
222 #define	MBR_PTYPE_FAT16B	0x06	/* 16-bit FAT, more than 32M */
223 #define	MBR_PTYPE_NTFS		0x07	/* OS/2 HPFS, NTFS, QNX2, Adv. UNIX */
224 #define	MBR_PTYPE_DELL		0x08	/* AIX or os, or etc. */
225 #define MBR_PTYPE_AIX_BOOT	0x09	/* AIX boot partition or Coherent */
226 #define MBR_PTYPE_OS2_BOOT	0x0a	/* O/2 boot manager or Coherent swap */
227 #define	MBR_PTYPE_FAT32		0x0b	/* 32-bit FAT */
228 #define	MBR_PTYPE_FAT32L	0x0c	/* 32-bit FAT, LBA-mapped */
229 #define	MBR_PTYPE_7XXX		0x0d	/* 7XXX, LBA-mapped */
230 #define	MBR_PTYPE_FAT16L	0x0e	/* 16-bit FAT, LBA-mapped */
231 #define	MBR_PTYPE_EXT_LBA	0x0f	/* extended partition, LBA-mapped */
232 #define	MBR_PTYPE_OPUS		0x10	/* OPUS */
233 #define MBR_PTYPE_OS2_DOS12	0x11 	/* OS/2 DOS 12-bit FAT */
234 #define MBR_PTYPE_COMPAQ_DIAG	0x12 	/* Compaq diagnostics */
235 #define MBR_PTYPE_OS2_DOS16S	0x14 	/* OS/2 DOS 16-bit FAT <32M */
236 #define MBR_PTYPE_OS2_DOS16B	0x16 	/* OS/2 DOS 16-bit FAT >=32M */
237 #define MBR_PTYPE_OS2_IFS	0x17 	/* OS/2 hidden IFS */
238 #define MBR_PTYPE_AST_SWAP	0x18 	/* AST Windows swapfile */
239 #define MBR_PTYPE_WILLOWTECH	0x19 	/* Willowtech Photon coS */
240 #define MBR_PTYPE_HID_FAT32	0x1b 	/* hidden win95 fat 32 */
241 #define MBR_PTYPE_HID_FAT32_LBA	0x1c 	/* hidden win95 fat 32 lba */
242 #define MBR_PTYPE_HID_FAT16_LBA	0x1d	/* hidden win95 fat 16 lba */
243 #define MBR_PTYPE_WILLOWSOFT	0x20 	/* Willowsoft OFS1 */
244 #define MBR_PTYPE_RESERVED_x21	0x21 	/* reserved */
245 #define MBR_PTYPE_RESERVED_x23	0x23 	/* reserved */
246 #define MBR_PTYPE_RESERVED_x24	0x24	/* NEC DOS */
247 #define MBR_PTYPE_RESERVED_x26	0x26 	/* reserved */
248 #define MBR_PTYPE_RESERVED_x31	0x31 	/* reserved */
249 #define MBR_PTYPE_NOS		0x32	/* Alien Internet Services NOS */
250 #define MBR_PTYPE_RESERVED_x33	0x33 	/* reserved */
251 #define MBR_PTYPE_RESERVED_x34	0x34 	/* reserved */
252 #define MBR_PTYPE_OS2_JFS	0x35 	/* JFS on OS2 */
253 #define MBR_PTYPE_RESERVED_x36	0x36 	/* reserved */
254 #define MBR_PTYPE_THEOS		0x38 	/* Theos */
255 #define MBR_PTYPE_PLAN9		0x39 	/* Plan 9, or Theos spanned */
256 #define MBR_PTYPE_THEOS_4GB	0x3a 	/* Theos ver 4 4gb partition */
257 #define MBR_PTYPE_THEOS_EXT	0x3b 	/* Theos ve 4 extended partition */
258 #define MBR_PTYPE_PMRECOVERY	0x3c 	/* PartitionMagic recovery */
259 #define MBR_PTYPE_HID_NETWARE	0x3d 	/* Hidden Netware */
260 #define MBR_PTYPE_VENIX		0x40 	/* VENIX 286 or LynxOS */
261 #define	MBR_PTYPE_PREP		0x41	/* PReP */
262 #define	MBR_PTYPE_DRDOS_LSWAP	0x42	/* linux swap sharing DRDOS disk */
263 #define	MBR_PTYPE_DRDOS_LINUX	0x43	/* linux sharing DRDOS disk */
264 #define	MBR_PTYPE_GOBACK	0x44	/* GoBack change utility */
265 #define	MBR_PTYPE_BOOT_US	0x45	/* Boot US Boot manager */
266 #define	MBR_PTYPE_EUMEL_x46	0x46	/* EUMEL/Elan or Ergos 3 */
267 #define	MBR_PTYPE_EUMEL_x47	0x47	/* EUMEL/Elan or Ergos 3 */
268 #define	MBR_PTYPE_EUMEL_x48	0x48	/* EUMEL/Elan or Ergos 3 */
269 #define	MBR_PTYPE_ALFS_THIN	0x4a	/* ALFX/THIN filesystem for DOS */
270 #define	MBR_PTYPE_OBERON	0x4c	/* Oberon partition */
271 #define MBR_PTYPE_QNX4X		0x4d 	/* QNX4.x */
272 #define MBR_PTYPE_QNX4X_2	0x4e 	/* QNX4.x 2nd part */
273 #define MBR_PTYPE_QNX4X_3	0x4f 	/* QNX4.x 3rd part */
274 #define MBR_PTYPE_DM		0x50 	/* DM (disk manager) */
275 #define MBR_PTYPE_DM6_AUX1	0x51 	/* DM6 Aux1 (or Novell) */
276 #define MBR_PTYPE_CPM		0x52 	/* CP/M or Microport SysV/AT */
277 #define MBR_PTYPE_DM6_AUX3	0x53 	/* DM6 Aux3 */
278 #define	MBR_PTYPE_DM6_DDO	0x54	/* DM6 DDO */
279 #define MBR_PTYPE_EZDRIVE	0x55	/* EZ-Drive (disk manager) */
280 #define MBR_PTYPE_GOLDEN_BOW	0x56	/* Golden Bow (disk manager) */
281 #define MBR_PTYPE_DRIVE_PRO	0x57	/* Drive PRO */
282 #define MBR_PTYPE_PRIAM_EDISK	0x5c	/* Priam Edisk (disk manager) */
283 #define MBR_PTYPE_SPEEDSTOR	0x61	/* SpeedStor */
284 #define MBR_PTYPE_HURD		0x63	/* GNU HURD or Mach or Sys V/386 */
285 #define MBR_PTYPE_NOVELL_2XX	0x64	/* Novell Netware 2.xx or Speedstore */
286 #define MBR_PTYPE_NOVELL_3XX	0x65	/* Novell Netware 3.xx */
287 #define MBR_PTYPE_NOVELL_386	0x66	/* Novell 386 Netware */
288 #define MBR_PTYPE_NOVELL_x67	0x67	/* Novell */
289 #define MBR_PTYPE_NOVELL_x68	0x68	/* Novell */
290 #define MBR_PTYPE_NOVELL_x69	0x69	/* Novell */
291 #define MBR_PTYPE_DISKSECURE	0x70	/* DiskSecure Multi-Boot */
292 #define MBR_PTYPE_RESERVED_x71	0x71	/* reserved */
293 #define MBR_PTYPE_RESERVED_x73	0x73	/* reserved */
294 #define MBR_PTYPE_RESERVED_x74	0x74	/* reserved */
295 #define MBR_PTYPE_PCIX		0x75	/* PC/IX */
296 #define MBR_PTYPE_RESERVED_x76	0x76	/* reserved */
297 #define MBR_PTYPE_M2FS_M2CS	0x77	/* M2FS/M2CS partition */
298 #define MBR_PTYPE_XOSL_FS	0x78	/* XOSL boot loader filesystem */
299 #define MBR_PTYPE_MINIX_14A	0x80	/* MINIX until 1.4a */
300 #define MBR_PTYPE_MINIX_14B	0x81	/* MINIX since 1.4b */
301 #define	MBR_PTYPE_LNXSWAP	0x82	/* Linux swap or Solaris */
302 #define	MBR_PTYPE_LNXEXT2	0x83	/* Linux native */
303 #define MBR_PTYPE_OS2_C		0x84	/* OS/2 hidden C: drive */
304 #define	MBR_PTYPE_EXT_LNX	0x85	/* Linux extended partition */
305 #define	MBR_PTYPE_NTFATVOL 	0x86	/* NT FAT volume set */
306 #define	MBR_PTYPE_NTFSVOL	0x87	/* NTFS volume set or HPFS mirrored */
307 #define	MBR_PTYPE_LNX_KERNEL	0x8a	/* Linux Kernel AiR-BOOT partition */
308 #define	MBR_PTYPE_FT_FAT32	0x8b	/* Legacy Fault tolerant FAT32 */
309 #define	MBR_PTYPE_FT_FAT32_EXT	0x8c	/* Legacy Fault tolerant FAT32 ext */
310 #define	MBR_PTYPE_HID_FR_FD_12	0x8d	/* Hidden free FDISK FAT12 */
311 #define	MBR_PTYPE_LNX_LVM	0x8e	/* Linux Logical Volume Manager */
312 #define	MBR_PTYPE_HID_FR_FD_16	0x90	/* Hidden free FDISK FAT16 */
313 #define	MBR_PTYPE_HID_FR_FD_EXT	0x91	/* Hidden free FDISK DOS EXT */
314 #define	MBR_PTYPE_HID_FR_FD_16B	0x92	/* Hidden free FDISK FAT16 Big */
315 #define MBR_PTYPE_AMOEBA_FS 	0x93	/* Amoeba filesystem */
316 #define MBR_PTYPE_AMOEBA_BAD 	0x94	/* Amoeba bad block table */
317 #define MBR_PTYPE_MIT_EXOPC 	0x95	/* MIT EXOPC native partitions */
318 #define	MBR_PTYPE_HID_FR_FD_32	0x97	/* Hidden free FDISK FAT32 */
319 #define	MBR_PTYPE_DATALIGHT	0x98	/* Datalight ROM-DOS Super-Boot */
320 #define MBR_PTYPE_MYLEX 	0x99	/* Mylex EISA SCSI */
321 #define	MBR_PTYPE_HID_FR_FD_16L	0x9a	/* Hidden free FDISK FAT16 LBA */
322 #define	MBR_PTYPE_HID_FR_FD_EXL	0x9b	/* Hidden free FDISK EXT LBA */
323 #define MBR_PTYPE_BSDI	 	0x9f	/* BSDI? */
324 #define MBR_PTYPE_IBM_HIB	0xa0	/* IBM Thinkpad hibernation */
325 #define MBR_PTYPE_HP_VOL_xA1	0xa1	/* HP Volume expansion (SpeedStor) */
326 #define MBR_PTYPE_HP_VOL_xA3	0xa3	/* HP Volume expansion (SpeedStor) */
327 #define MBR_PTYPE_HP_VOL_xA4	0xa4	/* HP Volume expansion (SpeedStor) */
328 #define	MBR_PTYPE_386BSD	0xa5	/* 386BSD partition type */
329 #define	MBR_PTYPE_OPENBSD	0xa6	/* OpenBSD partition type */
330 #define	MBR_PTYPE_NEXTSTEP_486 	0xa7	/* NeXTSTEP 486 */
331 #define	MBR_PTYPE_APPLE_UFS 	0xa8	/* Apple UFS */
332 #define	MBR_PTYPE_NETBSD	0xa9	/* NetBSD partition type */
333 #define MBR_PTYPE_OLIVETTI	0xaa	/* Olivetty Fat12 1.44MB Service part */
334 #define MBR_PTYPE_APPLE_BOOT	0xab	/* Apple Boot */
335 #define MBR_PTYPE_SHAG_OS	0xae	/* SHAG OS filesystem */
336 #define MBR_PTYPE_APPLE_HFS	0xaf	/* Apple HFS */
337 #define MBR_PTYPE_BOOTSTAR_DUM	0xb0	/* BootStar Dummy */
338 #define MBR_PTYPE_RESERVED_xB1	0xb1	/* reserved */
339 #define MBR_PTYPE_RESERVED_xB3	0xb3	/* reserved */
340 #define MBR_PTYPE_RESERVED_xB4	0xb4	/* reserved */
341 #define MBR_PTYPE_RESERVED_xB6	0xb6	/* reserved */
342 #define MBR_PTYPE_BSDI_386	0xb7	/* BSDI BSD/386 filesystem */
343 #define MBR_PTYPE_BSDI_SWAP	0xb8	/* BSDI BSD/386 swap */
344 #define	MBR_PTYPE_BOOT_WIZARD	0xbb	/* Boot Wizard Hidden */
345 #define	MBR_PTYPE_SOLARIS_8	0xbe	/* Solaris 8 partition type */
346 #define	MBR_PTYPE_SOLARIS	0xbf	/* Solaris partition type */
347 #define MBR_PTYPE_CTOS		0xc0 	/* CTOS */
348 #define MBR_PTYPE_DRDOS_FAT12	0xc1 	/* DRDOS/sec (FAT-12) */
349 #define MBR_PTYPE_HID_LNX	0xc2 	/* Hidden Linux */
350 #define MBR_PTYPE_HID_LNX_SWAP	0xc3 	/* Hidden Linux swap */
351 #define MBR_PTYPE_DRDOS_FAT16S	0xc4 	/* DRDOS/sec (FAT-16, < 32M) */
352 #define MBR_PTYPE_DRDOS_EXT	0xc5 	/* DRDOS/sec (EXT) */
353 #define MBR_PTYPE_DRDOS_FAT16B	0xc6 	/* DRDOS/sec (FAT-16, >= 32M) */
354 #define MBR_PTYPE_SYRINX	0xc7 	/* Syrinx (Cyrnix?) or HPFS disabled */
355 #define MBR_PTYPE_DRDOS_8_xC8	0xc8 	/* Reserved for DR-DOS 8.0+ */
356 #define MBR_PTYPE_DRDOS_8_xC9	0xc9 	/* Reserved for DR-DOS 8.0+ */
357 #define MBR_PTYPE_DRDOS_8_xCA	0xca 	/* Reserved for DR-DOS 8.0+ */
358 #define MBR_PTYPE_DRDOS_74_CHS	0xcb 	/* DR-DOS 7.04+ Secured FAT32 CHS */
359 #define MBR_PTYPE_DRDOS_74_LBA	0xcc 	/* DR-DOS 7.04+ Secured FAT32 LBA */
360 #define MBR_PTYPE_CTOS_MEMDUMP	0xcd	/* CTOS Memdump */
361 #define MBR_PTYPE_DRDOS_74_16X	0xce 	/* DR-DOS 7.04+ FAT16X LBA */
362 #define MBR_PTYPE_DRDOS_74_EXT	0xcf 	/* DR-DOS 7.04+ EXT LBA */
363 #define MBR_PTYPE_REAL32	0xd0 	/* REAL/32 secure big partition */
364 #define MBR_PTYPE_MDOS_FAT12	0xd1 	/* Old Multiuser DOS FAT12 */
365 #define MBR_PTYPE_MDOS_FAT16S	0xd4 	/* Old Multiuser DOS FAT16 Small */
366 #define MBR_PTYPE_MDOS_EXT	0xd5 	/* Old Multiuser DOS Extended */
367 #define MBR_PTYPE_MDOS_FAT16B	0xd6 	/* Old Multiuser DOS FAT16 Big */
368 #define MBR_PTYPE_CPM_86	0xd8 	/* CP/M 86 */
369 #define MBR_PTYPE_CONCURRENT	0xdb 	/* CP/M or Concurrent CP/M */
370 #define MBR_PTYPE_HID_CTOS_MEM	0xdd 	/* Hidden CTOS Memdump */
371 #define MBR_PTYPE_DELL_UTIL	0xde 	/* Dell PowerEdge Server utilities */
372 #define MBR_PTYPE_DGUX_VIRTUAL	0xdf 	/* DG/UX virtual disk manager */
373 #define MBR_PTYPE_STMICROELEC	0xe0 	/* STMicroelectronics ST AVFS */
374 #define MBR_PTYPE_DOS_ACCESS	0xe1 	/* DOS access or SpeedStor 12-bit */
375 #define MBR_PTYPE_STORDIM	0xe3 	/* DOS R/O or Storage Dimensions */
376 #define MBR_PTYPE_SPEEDSTOR_16S	0xe4 	/* SpeedStor 16-bit FAT < 1024 cyl. */
377 #define MBR_PTYPE_RESERVED_xE5	0xe5	/* reserved */
378 #define MBR_PTYPE_RESERVED_xE6	0xe6	/* reserved */
379 #define MBR_PTYPE_BEOS		0xeb 	/* BeOS */
380 #define	MBR_PTYPE_PMBR		0xee	/* GPT Protective MBR */
381 #define	MBR_PTYPE_EFI		0xef	/* EFI system partition */
382 #define MBR_PTYPE_LNX_PA_RISC	0xf0 	/* Linux PA-RISC boot loader */
383 #define MBR_PTYPE_SPEEDSTOR_X	0xf1 	/* SpeedStor or Storage Dimensions */
384 #define MBR_PTYPE_DOS33_SEC	0xf2 	/* DOS 3.3+ Secondary */
385 #define MBR_PTYPE_RESERVED_xF3	0xf3	/* reserved */
386 #define MBR_PTYPE_SPEEDSTOR_L	0xf4	/* SpeedStor large partition */
387 #define MBR_PTYPE_PROLOGUE	0xf5	/* Prologue multi-volumen partition */
388 #define MBR_PTYPE_RESERVED_xF6	0xf6 	/* reserved */
389 #define MBR_PTYPE_PCACHE	0xf9 	/* pCache: ext2/ext3 persistent cache */
390 #define MBR_PTYPE_BOCHS		0xfa 	/* Bochs x86 emulator */
391 #define MBR_PTYPE_VMWARE	0xfb 	/* VMware File System */
392 #define MBR_PTYPE_VMWARE_SWAP	0xfc 	/* VMware Swap */
393 #define MBR_PTYPE_LNX_RAID	0xfd 	/* Linux RAID partition persistent sb */
394 #define MBR_PTYPE_LANSTEP	0xfe	/* LANstep or IBM PS/2 IML */
395 #define MBR_PTYPE_XENIX_BAD	0xff 	/* Xenix Bad Block Table */
396 
397 #ifdef MBRPTYPENAMES
398 static const struct mbr_ptype {
399 	int id;
400 	const char *name;
401 } mbr_ptypes[] = {
402 	{ MBR_PTYPE_UNUSED, "<UNUSED>" },
403 	{ MBR_PTYPE_FAT12, "Primary DOS with 12 bit FAT" },
404 	{ MBR_PTYPE_XENIX_ROOT, "XENIX / filesystem" },
405 	{ MBR_PTYPE_XENIX_USR, "XENIX /usr filesystem" },
406 	{ MBR_PTYPE_FAT16S, "Primary DOS with 16 bit FAT <32M" },
407 	{ MBR_PTYPE_EXT, "Extended partition" },
408 	{ MBR_PTYPE_FAT16B, "Primary 'big' DOS, 16-bit FAT (> 32MB)" },
409 	{ MBR_PTYPE_NTFS, "NTFS, OS/2 HPFS, QNX2 or Advanced UNIX" },
410 	{ MBR_PTYPE_DELL, "AIX filesystem or OS/2 (thru v1.3) or DELL "
411 			  "multiple drives or Commodore DOS or SplitDrive" },
412 	{ MBR_PTYPE_AIX_BOOT, "AIX boot partition or Coherent" },
413 	{ MBR_PTYPE_OS2_BOOT, "OS/2 Boot Manager or Coherent swap or OPUS" },
414 	{ MBR_PTYPE_FAT32, "Primary DOS with 32 bit FAT" },
415 	{ MBR_PTYPE_FAT32L, "Primary DOS with 32 bit FAT - LBA" },
416 	{ MBR_PTYPE_7XXX, "Type 7??? - LBA" },
417 	{ MBR_PTYPE_FAT16L, "DOS (16-bit FAT) - LBA" },
418 	{ MBR_PTYPE_EXT_LBA, "Ext. partition - LBA" },
419 	{ MBR_PTYPE_OPUS, "OPUS" },
420 	{ MBR_PTYPE_OS2_DOS12, "OS/2 BM: hidden DOS 12-bit FAT" },
421 	{ MBR_PTYPE_COMPAQ_DIAG, "Compaq diagnostics" },
422 	{ MBR_PTYPE_OS2_DOS16S, "OS/2 BM: hidden DOS 16-bit FAT <32M "
423 				"or Novell DOS 7.0 bug" },
424 	{ MBR_PTYPE_OS2_DOS16B, "OS/2 BM: hidden DOS 16-bit FAT >=32M" },
425 	{ MBR_PTYPE_OS2_IFS, "OS/2 BM: hidden IFS" },
426 	{ MBR_PTYPE_AST_SWAP, "AST Windows swapfile" },
427 	{ MBR_PTYPE_WILLOWTECH, "Willowtech Photon coS" },
428 	{ MBR_PTYPE_HID_FAT32, "hidden Windows/95 FAT32" },
429 	{ MBR_PTYPE_HID_FAT32_LBA, "hidden Windows/95 FAT32 LBA" },
430 	{ MBR_PTYPE_HID_FAT16_LBA, "hidden Windows/95 FAT16 LBA" },
431 	{ MBR_PTYPE_WILLOWSOFT, "Willowsoft OFS1" },
432 	{ MBR_PTYPE_RESERVED_x21, "reserved" },
433 	{ MBR_PTYPE_RESERVED_x23, "reserved" },
434 	{ MBR_PTYPE_RESERVED_x24, "NEC DOS"},
435 	{ MBR_PTYPE_RESERVED_x26, "reserved" },
436 	{ MBR_PTYPE_RESERVED_x31, "reserved" },
437 	{ MBR_PTYPE_NOS, "Alien Internet Services NOS" },
438 	{ MBR_PTYPE_RESERVED_x33, "reserved" },
439 	{ MBR_PTYPE_RESERVED_x34, "reserved" },
440 	{ MBR_PTYPE_OS2_JFS, "JFS on OS2" },
441 	{ MBR_PTYPE_RESERVED_x36, "reserved" },
442 	{ MBR_PTYPE_THEOS, "Theos" },
443 	{ MBR_PTYPE_PLAN9, "Plan 9" },
444 	{ MBR_PTYPE_PLAN9, "Plan 9, or Theos spanned" },
445 	{ MBR_PTYPE_THEOS_4GB,	"Theos ver 4 4gb partition" },
446 	{ MBR_PTYPE_THEOS_EXT,	"Theos ve 4 extended partition" },
447 	{ MBR_PTYPE_PMRECOVERY, "PartitionMagic recovery" },
448 	{ MBR_PTYPE_HID_NETWARE, "Hidden Netware" },
449 	{ MBR_PTYPE_VENIX, "VENIX 286 or LynxOS" },
450 	{ MBR_PTYPE_PREP, "Linux/MINIX (sharing disk with DRDOS) "
451 			  "or Personal RISC boot" },
452 	{ MBR_PTYPE_DRDOS_LSWAP, "SFS or Linux swap "
453 				 "(sharing disk with DRDOS)" },
454 	{ MBR_PTYPE_DRDOS_LINUX, "Linux native (sharing disk with DRDOS)" },
455 	{ MBR_PTYPE_GOBACK, "GoBack change utility" },
456 	{ MBR_PTYPE_BOOT_US, "Boot US Boot manager" },
457 	{ MBR_PTYPE_EUMEL_x46, "EUMEL/Elan or Ergos 3" },
458 	{ MBR_PTYPE_EUMEL_x47, "EUMEL/Elan or Ergos 3" },
459 	{ MBR_PTYPE_EUMEL_x48, "EUMEL/Elan or Ergos 3" },
460 	{ MBR_PTYPE_ALFS_THIN, "ALFX/THIN filesystem for DOS" },
461 	{ MBR_PTYPE_OBERON, "Oberon partition" },
462 	{ MBR_PTYPE_QNX4X, "QNX4.x" },
463 	{ MBR_PTYPE_QNX4X_2, "QNX4.x 2nd part" },
464 	{ MBR_PTYPE_QNX4X_3, "QNX4.x 3rd part" },
465 	{ MBR_PTYPE_DM, "DM (disk manager)" },
466 	{ MBR_PTYPE_DM6_AUX1, "DM6 Aux1 (or Novell)" },
467 	{ MBR_PTYPE_CPM, "CP/M or Microport SysV/AT" },
468 	{ MBR_PTYPE_DM6_AUX3, "DM6 Aux3" },
469 	{ MBR_PTYPE_DM6_DDO, "DM6 DDO" },
470 	{ MBR_PTYPE_EZDRIVE, "EZ-Drive (disk manager)" },
471 	{ MBR_PTYPE_GOLDEN_BOW, "Golden Bow (disk manager)" },
472 	{ MBR_PTYPE_DRIVE_PRO, "Drive PRO" },
473 	{ MBR_PTYPE_PRIAM_EDISK, "Priam Edisk (disk manager)" },
474 	{ MBR_PTYPE_SPEEDSTOR, "SpeedStor" },
475 	{ MBR_PTYPE_HURD, "GNU HURD or Mach or Sys V/386 "
476 			  "(such as ISC UNIX) or MtXinu" },
477 	{ MBR_PTYPE_NOVELL_2XX, "Novell Netware 2.xx or Speedstore" },
478 	{ MBR_PTYPE_NOVELL_3XX, "Novell Netware 3.xx" },
479 	{ MBR_PTYPE_NOVELL_386, "Novell 386 Netware" },
480 	{ MBR_PTYPE_NOVELL_x67, "Novell" },
481 	{ MBR_PTYPE_NOVELL_x68, "Novell" },
482 	{ MBR_PTYPE_NOVELL_x69, "Novell" },
483 	{ MBR_PTYPE_DISKSECURE, "DiskSecure Multi-Boot" },
484 	{ MBR_PTYPE_RESERVED_x71, "reserved" },
485 	{ MBR_PTYPE_RESERVED_x73, "reserved" },
486 	{ MBR_PTYPE_RESERVED_x74, "reserved" },
487 	{ MBR_PTYPE_PCIX, "PC/IX" },
488 	{ MBR_PTYPE_RESERVED_x76, "reserved" },
489 	{ MBR_PTYPE_M2FS_M2CS,	"M2FS/M2CS partition" },
490 	{ MBR_PTYPE_XOSL_FS, "XOSL boot loader filesystem" },
491 	{ MBR_PTYPE_MINIX_14A, "MINIX until 1.4a" },
492 	{ MBR_PTYPE_MINIX_14B, "MINIX since 1.4b, early Linux, Mitac dmgr" },
493 	{ MBR_PTYPE_LNXSWAP, "Linux swap or Prime or Solaris" },
494 	{ MBR_PTYPE_LNXEXT2, "Linux native" },
495 	{ MBR_PTYPE_OS2_C, "OS/2 hidden C: drive" },
496 	{ MBR_PTYPE_EXT_LNX, "Linux extended" },
497 	{ MBR_PTYPE_NTFATVOL, "NT FAT volume set" },
498 	{ MBR_PTYPE_NTFSVOL, "NTFS volume set or HPFS mirrored" },
499 	{ MBR_PTYPE_LNX_KERNEL,	"Linux Kernel AiR-BOOT partition" },
500 	{ MBR_PTYPE_FT_FAT32, "Legacy Fault tolerant FAT32" },
501 	{ MBR_PTYPE_FT_FAT32_EXT, "Legacy Fault tolerant FAT32 ext" },
502 	{ MBR_PTYPE_HID_FR_FD_12, "Hidden free FDISK FAT12" },
503 	{ MBR_PTYPE_LNX_LVM, "Linux Logical Volume Manager" },
504 	{ MBR_PTYPE_HID_FR_FD_16, "Hidden free FDISK FAT16" },
505 	{ MBR_PTYPE_HID_FR_FD_EXT, "Hidden free FDISK DOS EXT" },
506 	{ MBR_PTYPE_HID_FR_FD_16L, "Hidden free FDISK FAT16 Large" },
507 	{ MBR_PTYPE_AMOEBA_FS, "Amoeba filesystem" },
508 	{ MBR_PTYPE_AMOEBA_BAD, "Amoeba bad block table" },
509 	{ MBR_PTYPE_MIT_EXOPC, "MIT EXOPC native partitions" },
510 	{ MBR_PTYPE_HID_FR_FD_32, "Hidden free FDISK FAT32" },
511 	{ MBR_PTYPE_DATALIGHT, "Datalight ROM-DOS Super-Boot" },
512 	{ MBR_PTYPE_MYLEX, "Mylex EISA SCSI" },
513 	{ MBR_PTYPE_HID_FR_FD_16L, "Hidden free FDISK FAT16 LBA" },
514 	{ MBR_PTYPE_HID_FR_FD_EXL, "Hidden free FDISK EXT LBA" },
515 	{ MBR_PTYPE_BSDI, "BSDI?" },
516 	{ MBR_PTYPE_IBM_HIB, "IBM Thinkpad hibernation" },
517 	{ MBR_PTYPE_HP_VOL_xA1, "HP Volume expansion (SpeedStor)" },
518 	{ MBR_PTYPE_HP_VOL_xA3, "HP Volume expansion (SpeedStor)" },
519 	{ MBR_PTYPE_HP_VOL_xA4, "HP Volume expansion (SpeedStor)" },
520 	{ MBR_PTYPE_386BSD, "FreeBSD or 386BSD or old NetBSD" },
521 	{ MBR_PTYPE_OPENBSD, "OpenBSD" },
522 	{ MBR_PTYPE_NEXTSTEP_486, "NeXTSTEP 486" },
523 	{ MBR_PTYPE_APPLE_UFS, "Apple UFS" },
524 	{ MBR_PTYPE_NETBSD, "NetBSD" },
525 	{ MBR_PTYPE_OLIVETTI, "Olivetty Fat12 1.44MB Service part" },
526 	{ MBR_PTYPE_SHAG_OS, "SHAG OS filesystem" },
527 	{ MBR_PTYPE_BOOTSTAR_DUM, "BootStar Dummy" },
528 	{ MBR_PTYPE_BOOT_WIZARD, "Boot Wizard Hidden" },
529 	{ MBR_PTYPE_APPLE_BOOT, "Apple Boot" },
530 	{ MBR_PTYPE_APPLE_HFS, "Apple HFS" },
531 	{ MBR_PTYPE_RESERVED_xB6, "reserved" },
532 	{ MBR_PTYPE_RESERVED_xB6, "reserved" },
533 	{ MBR_PTYPE_RESERVED_xB6, "reserved" },
534 	{ MBR_PTYPE_RESERVED_xB6, "reserved" },
535 	{ MBR_PTYPE_BSDI_386, "BSDI BSD/386 filesystem" },
536 	{ MBR_PTYPE_BSDI_SWAP, "BSDI BSD/386 swap" },
537 	{ MBR_PTYPE_SOLARIS_8, "Solaris 8 boot partition" },
538 	{ MBR_PTYPE_SOLARIS, "Solaris boot partition" },
539 	{ MBR_PTYPE_CTOS, "CTOS" },
540 	{ MBR_PTYPE_DRDOS_FAT12, "DRDOS/sec (FAT-12)" },
541 	{ MBR_PTYPE_HID_LNX, "Hidden Linux" },
542 	{ MBR_PTYPE_HID_LNX_SWAP, "Hidden Linux Swap" },
543 	{ MBR_PTYPE_DRDOS_FAT16S, "DRDOS/sec (FAT-16, < 32M)" },
544 	{ MBR_PTYPE_DRDOS_EXT, "DRDOS/sec (EXT)" },
545 	{ MBR_PTYPE_DRDOS_FAT16B, "DRDOS/sec (FAT-16, >= 32M)" },
546 	{ MBR_PTYPE_SYRINX, "Syrinx (Cyrnix?) or HPFS disabled" },
547 	{ MBR_PTYPE_DRDOS_8_xC8, "Reserved for DR-DOS 8.0+" },
548 	{ MBR_PTYPE_DRDOS_8_xC9, "Reserved for DR-DOS 8.0+" },
549 	{ MBR_PTYPE_DRDOS_8_xCA, "Reserved for DR-DOS 8.0+" },
550 	{ MBR_PTYPE_DRDOS_74_CHS, "DR-DOS 7.04+ Secured FAT32 CHS" },
551 	{ MBR_PTYPE_DRDOS_74_LBA, "DR-DOS 7.04+ Secured FAT32 LBA" },
552 	{ MBR_PTYPE_CTOS_MEMDUMP, "CTOS Memdump" },
553 	{ MBR_PTYPE_DRDOS_74_16X, "DR-DOS 7.04+ FAT16X LBA" },
554 	{ MBR_PTYPE_DRDOS_74_EXT, "DR-DOS 7.04+ EXT LBA" },
555 	{ MBR_PTYPE_REAL32, "REAL/32 secure big partition" },
556 	{ MBR_PTYPE_MDOS_FAT12, "Old Multiuser DOS FAT12" },
557 	{ MBR_PTYPE_MDOS_FAT16S, "Old Multiuser DOS FAT16 Small" },
558 	{ MBR_PTYPE_MDOS_EXT, "Old Multiuser DOS Extended" },
559 	{ MBR_PTYPE_MDOS_FAT16B, "Old Multiuser DOS FAT16 Big" },
560 	{ MBR_PTYPE_CPM_86, "CP/M 86" },
561 	{ MBR_PTYPE_CONCURRENT, "CP/M or Concurrent CP/M or Concurrent DOS "
562 				"or CTOS" },
563 	{ MBR_PTYPE_HID_CTOS_MEM, "Hidden CTOS Memdump" },
564 	{ MBR_PTYPE_DELL_UTIL, "Dell PowerEdge Server utilities" },
565 	{ MBR_PTYPE_DGUX_VIRTUAL, "DG/UX virtual disk manager" },
566 	{ MBR_PTYPE_STMICROELEC, "STMicroelectronics ST AVFS" },
567 	{ MBR_PTYPE_DOS_ACCESS, "DOS access or SpeedStor 12-bit FAT "
568 				"extended partition" },
569 	{ MBR_PTYPE_STORDIM, "DOS R/O or SpeedStor or Storage Dimensions" },
570 	{ MBR_PTYPE_SPEEDSTOR_16S, "SpeedStor 16-bit FAT extended partition "
571 				   "< 1024 cyl." },
572 	{ MBR_PTYPE_RESERVED_xE5, "reserved" },
573 	{ MBR_PTYPE_RESERVED_xE6, "reserved" },
574 	{ MBR_PTYPE_BEOS, "BeOS" },
575 	{ MBR_PTYPE_PMBR, "GPT Protective MBR" },
576 	{ MBR_PTYPE_EFI, "EFI system partition" },
577 	{ MBR_PTYPE_LNX_PA_RISC, "Linux PA-RISC boot loader" },
578 	{ MBR_PTYPE_SPEEDSTOR_X, "SpeedStor or Storage Dimensions" },
579 	{ MBR_PTYPE_DOS33_SEC, "DOS 3.3+ Secondary" },
580 	{ MBR_PTYPE_RESERVED_xF3, "reserved" },
581 	{ MBR_PTYPE_SPEEDSTOR_L, "SpeedStor large partition or "
582 				 "Storage Dimensions" },
583 	{ MBR_PTYPE_PROLOGUE, "Prologue multi-volumen partition" },
584 	{ MBR_PTYPE_RESERVED_xF6, "reserved" },
585 	{ MBR_PTYPE_PCACHE, "pCache: ext2/ext3 persistent cache" },
586 	{ MBR_PTYPE_BOCHS, "Bochs x86 emulator" },
587 	{ MBR_PTYPE_VMWARE, "VMware File System" },
588 	{ MBR_PTYPE_VMWARE_SWAP, "VMware Swap" },
589 	{ MBR_PTYPE_LNX_RAID, "Linux RAID partition persistent sb" },
590 	{ MBR_PTYPE_LANSTEP, "SpeedStor >1024 cyl. or LANstep "
591 			     "or IBM PS/2 IML" },
592 	{ MBR_PTYPE_XENIX_BAD, "Xenix Bad Block Table" },
593 };
594 #endif
595 
596 #define	MBR_PSECT(s)		((s) & 0x3f)
597 #define	MBR_PCYL(c, s)		((c) + (((s) & 0xc0) << 2))
598 
599 #define	MBR_IS_EXTENDED(x)	((x) == MBR_PTYPE_EXT || \
600 				 (x) == MBR_PTYPE_EXT_LBA || \
601 				 (x) == MBR_PTYPE_EXT_LNX)
602 
603 		/* values for mbr_bootsel.mbrbs_flags */
604 #define	MBR_BS_ACTIVE	0x01	/* Bootselector active (or code present) */
605 #define	MBR_BS_EXTINT13	0x02	/* Set by fdisk if LBA needed (deprecated) */
606 #define	MBR_BS_READ_LBA	0x04	/* Force LBA reads (deprecated) */
607 #define	MBR_BS_EXTLBA	0x08	/* Extended ptn capable (LBA reads) */
608 #define	MBR_BS_ASCII	0x10	/* Bootselect code needs ascii key code */
609 /* This is always set, the bootsel is located using the magic number...  */
610 #define	MBR_BS_NEWMBR	0x80	/* New bootsel at offset 440 */
611 
612 #if !defined(__ASSEMBLER__)					/* { */
613 
614 /*
615  * (x86) BIOS Parameter Block for FAT12
616  */
617 struct mbr_bpbFAT12 {
618 	uint16_t	bpbBytesPerSec;	/* bytes per sector */
619 	uint8_t		bpbSecPerClust;	/* sectors per cluster */
620 	uint16_t	bpbResSectors;	/* number of reserved sectors */
621 	uint8_t		bpbFATs;	/* number of FATs */
622 	uint16_t	bpbRootDirEnts;	/* number of root directory entries */
623 	uint16_t	bpbSectors;	/* total number of sectors */
624 	uint8_t		bpbMedia;	/* media descriptor */
625 	uint16_t	bpbFATsecs;	/* number of sectors per FAT */
626 	uint16_t	bpbSecPerTrack;	/* sectors per track */
627 	uint16_t	bpbHeads;	/* number of heads */
628 	uint16_t	bpbHiddenSecs;	/* # of hidden sectors */
629 } __packed;
630 
631 /*
632  * (x86) BIOS Parameter Block for FAT16
633  */
634 struct mbr_bpbFAT16 {
635 	uint16_t	bpbBytesPerSec;	/* bytes per sector */
636 	uint8_t		bpbSecPerClust;	/* sectors per cluster */
637 	uint16_t	bpbResSectors;	/* number of reserved sectors */
638 	uint8_t		bpbFATs;	/* number of FATs */
639 	uint16_t	bpbRootDirEnts;	/* number of root directory entries */
640 	uint16_t	bpbSectors;	/* total number of sectors */
641 	uint8_t		bpbMedia;	/* media descriptor */
642 	uint16_t	bpbFATsecs;	/* number of sectors per FAT */
643 	uint16_t	bpbSecPerTrack;	/* sectors per track */
644 	uint16_t	bpbHeads;	/* number of heads */
645 	uint32_t	bpbHiddenSecs;	/* # of hidden sectors */
646 	uint32_t	bpbHugeSectors;	/* # of sectors if bpbSectors == 0 */
647 	uint8_t		bsDrvNum;	/* Int 0x13 drive number (e.g. 0x80) */
648 	uint8_t		bsReserved1;	/* Reserved; set to 0 */
649 	uint8_t		bsBootSig;	/* 0x29 if next 3 fields are present */
650 	uint8_t		bsVolID[4];	/* Volume serial number */
651 	uint8_t		bsVolLab[11];	/* Volume label */
652 	uint8_t		bsFileSysType[8];
653 					/* "FAT12   ", "FAT16   ", "FAT     " */
654 } __packed;
655 
656 /*
657  * (x86) BIOS Parameter Block for FAT32
658  */
659 struct mbr_bpbFAT32 {
660 	uint16_t	bpbBytesPerSec;	/* bytes per sector */
661 	uint8_t		bpbSecPerClust;	/* sectors per cluster */
662 	uint16_t	bpbResSectors;	/* number of reserved sectors */
663 	uint8_t		bpbFATs;	/* number of FATs */
664 	uint16_t	bpbRootDirEnts;	/* number of root directory entries */
665 	uint16_t	bpbSectors;	/* total number of sectors */
666 	uint8_t		bpbMedia;	/* media descriptor */
667 	uint16_t	bpbFATsecs;	/* number of sectors per FAT */
668 	uint16_t	bpbSecPerTrack;	/* sectors per track */
669 	uint16_t	bpbHeads;	/* number of heads */
670 	uint32_t	bpbHiddenSecs;	/* # of hidden sectors */
671 	uint32_t	bpbHugeSectors;	/* # of sectors if bpbSectors == 0 */
672 	uint32_t	bpbBigFATsecs;	/* like bpbFATsecs for FAT32 */
673 	uint16_t	bpbExtFlags;	/* extended flags: */
674 #define	MBR_FAT32_FATNUM	0x0F	/*   mask for numbering active FAT */
675 #define	MBR_FAT32_FATMIRROR	0x80	/*   FAT is mirrored (as previously) */
676 	uint16_t	bpbFSVers;	/* filesystem version */
677 #define	MBR_FAT32_FSVERS	0	/*   currently only 0 is understood */
678 	uint32_t	bpbRootClust;	/* start cluster for root directory */
679 	uint16_t	bpbFSInfo;	/* filesystem info structure sector */
680 	uint16_t	bpbBackup;	/* backup boot sector */
681 	uint8_t		bsReserved[12];	/* Reserved for future expansion */
682 	uint8_t		bsDrvNum;	/* Int 0x13 drive number (e.g. 0x80) */
683 	uint8_t		bsReserved1;	/* Reserved; set to 0 */
684 	uint8_t		bsBootSig;	/* 0x29 if next 3 fields are present */
685 	uint8_t		bsVolID[4];	/* Volume serial number */
686 	uint8_t		bsVolLab[11];	/* Volume label */
687 	uint8_t		bsFileSysType[8]; /* "FAT32   " */
688 } __packed;
689 
690 /*
691  * (x86) MBR boot selector
692  */
693 struct mbr_bootsel {
694 	uint8_t		mbrbs_defkey;
695 	uint8_t		mbrbs_flags;
696 	uint16_t	mbrbs_timeo;
697 	char		mbrbs_nametab[MBR_PART_COUNT][MBR_BS_PARTNAMESIZE + 1];
698 } __packed;
699 
700 /*
701  * MBR partition
702  */
703 struct mbr_partition {
704 	uint8_t		mbrp_flag;	/* MBR partition flags */
705 	uint8_t		mbrp_shd;	/* Starting head */
706 	uint8_t		mbrp_ssect;	/* Starting sector */
707 	uint8_t		mbrp_scyl;	/* Starting cylinder */
708 	uint8_t		mbrp_type;	/* Partition type (see below) */
709 	uint8_t		mbrp_ehd;	/* End head */
710 	uint8_t		mbrp_esect;	/* End sector */
711 	uint8_t		mbrp_ecyl;	/* End cylinder */
712 	uint32_t	mbrp_start;	/* Absolute starting sector number */
713 	uint32_t	mbrp_size;	/* Partition size in sectors */
714 } __packed;
715 
716 int xlat_mbr_fstype(int);	/* in sys/lib/libkern/xlat_mbr_fstype.c */
717 
718 /*
719  * MBR boot sector.
720  * This is used by both the MBR (Master Boot Record) in sector 0 of the disk
721  * and the PBR (Partition Boot Record) in sector 0 of an MBR partition.
722  */
723 struct mbr_sector {
724 					/* Jump instruction to boot code.  */
725 					/* Usually 0xE9nnnn or 0xEBnn90 */
726 	uint8_t			mbr_jmpboot[3];
727 					/* OEM name and version */
728 	uint8_t			mbr_oemname[8];
729 	union {				/* BIOS Parameter Block */
730 		struct mbr_bpbFAT12	bpb12;
731 		struct mbr_bpbFAT16	bpb16;
732 		struct mbr_bpbFAT32	bpb32;
733 	} mbr_bpb;
734 					/* Boot code */
735 	uint8_t			mbr_bootcode[310];
736 					/* Config for /usr/mdec/mbr_bootsel */
737 	struct mbr_bootsel	mbr_bootsel;
738 					/* NT Drive Serial Number */
739 	uint32_t		mbr_dsn;
740 					/* mbr_bootsel magic */
741 	uint16_t		mbr_bootsel_magic;
742 					/* MBR partition table */
743 	struct mbr_partition	mbr_parts[MBR_PART_COUNT];
744 					/* MBR magic (0xaa55) */
745 	uint16_t		mbr_magic;
746 } __packed;
747 
748 #endif	/* !defined(__ASSEMBLER__) */				/* } */
749 
750 
751 /* ------------------------------------------
752  * shared --
753  *	definitions shared by many platforms
754  */
755 
756 #if !defined(__ASSEMBLER__)					/* { */
757 
758 	/* Maximum # of blocks in bbi_block_table, each bbi_block_size long */
759 #define	SHARED_BBINFO_MAXBLOCKS	118	/* so sizeof(shared_bbinfo) == 512 */
760 
761 struct shared_bbinfo {
762 	uint8_t bbi_magic[32];
763 	int32_t bbi_block_size;
764 	int32_t bbi_block_count;
765 	int32_t bbi_block_table[SHARED_BBINFO_MAXBLOCKS];
766 };
767 
768 /* ------------------------------------------
769  * alpha --
770  *	Alpha (disk, but also tape) Boot Block.
771  *
772  *	See Section (III) 3.6.1 of the Alpha Architecture Reference Manual.
773  */
774 
775 struct alpha_boot_block {
776 	uint64_t bb_data[63];		/* data (disklabel, also as below) */
777 	uint64_t bb_cksum;		/* checksum of the boot block,
778 					 * taken as uint64_t's
779 					 */
780 };
781 #define	bb_secsize	bb_data[60]	/* secondary size (blocks) */
782 #define	bb_secstart	bb_data[61]	/* secondary start (blocks) */
783 #define	bb_flags	bb_data[62]	/* unknown flags (set to zero) */
784 
785 #define	ALPHA_BOOT_BLOCK_OFFSET		0	/* offset of boot block. */
786 #define	ALPHA_BOOT_BLOCK_BLOCKSIZE	512	/* block size for sector
787 						 * size/start, and for boot
788 						 * block itself.
789 						 */
790 
791 #define	ALPHA_BOOT_BLOCK_CKSUM(bb,cksum)				\
792 	do {								\
793 		const struct alpha_boot_block *_bb = (bb);		\
794 		uint64_t _cksum;					\
795 		size_t _i;						\
796 									\
797 		_cksum = 0;						\
798 		for (_i = 0;						\
799 		    _i < (sizeof _bb->bb_data / sizeof _bb->bb_data[0]); \
800 		    _i++)						\
801 			_cksum += le64toh(_bb->bb_data[_i]);		\
802 		*(cksum) = htole64(_cksum);				\
803 	} while (/*CONSTCOND*/ 0)
804 
805 /* ------------------------------------------
806  * apple --
807  *	Apple computers boot block related information
808  */
809 
810 /*
811  *	Driver Descriptor Map, from Inside Macintosh: Devices, SCSI Manager
812  *	pp 12-13.  The driver descriptor map always resides on physical block 0.
813  */
814 struct apple_drvr_descriptor {
815 	uint32_t	descBlock;	/* first block of driver */
816 	uint16_t	descSize;	/* driver size in blocks */
817 	uint16_t	descType;	/* system type */
818 } __packed;
819 
820 /*
821  *	system types; Apple reserves 0-15
822  */
823 #define	APPLE_DRVR_TYPE_MACINTOSH	1
824 
825 #define	APPLE_DRVR_MAP_MAGIC		0x4552
826 #define	APPLE_DRVR_MAP_MAX_DESCRIPTORS	61
827 
828 struct apple_drvr_map {
829 	uint16_t	sbSig;		/* map signature */
830 	uint16_t	sbBlockSize;	/* block size of device */
831 	uint32_t	sbBlkCount;	/* number of blocks on device */
832 	uint16_t	sbDevType;	/* (used internally by ROM) */
833 	uint16_t	sbDevID;	/* (used internally by ROM) */
834 	uint32_t	sbData;		/* (used internally by ROM) */
835 	uint16_t	sbDrvrCount;	/* number of driver descriptors */
836 	struct apple_drvr_descriptor sb_dd[APPLE_DRVR_MAP_MAX_DESCRIPTORS];
837 	uint16_t	pad[3];
838 } __packed;
839 
840 /*
841  *	Partition map structure from Inside Macintosh: Devices, SCSI Manager
842  *	pp. 13-14.  The partition map always begins on physical block 1.
843  *
844  *	With the exception of block 0, all blocks on the disk must belong to
845  *	exactly one partition.  The partition map itself belongs to a partition
846  *	of type `APPLE_PARTITION_MAP', and is not limited in size by anything
847  *	other than available disk space.  The partition map is not necessarily
848  *	the first partition listed.
849  */
850 #define	APPLE_PART_MAP_ENTRY_MAGIC	0x504d
851 
852 struct apple_part_map_entry {
853 	uint16_t	pmSig;		/* partition signature */
854 	uint16_t	pmSigPad;	/* (reserved) */
855 	uint32_t	pmMapBlkCnt;	/* number of blocks in partition map */
856 	uint32_t	pmPyPartStart;	/* first physical block of partition */
857 	uint32_t	pmPartBlkCnt;	/* number of blocks in partition */
858 	uint8_t		pmPartName[32];	/* partition name */
859 	uint8_t		pmPartType[32];	/* partition type */
860 	uint32_t	pmLgDataStart;	/* first logical block of data area */
861 	uint32_t	pmDataCnt;	/* number of blocks in data area */
862 	uint32_t	pmPartStatus;	/* partition status information */
863 /*
864  * Partition Status Information from Apple Tech Note 1189
865  */
866 #define	APPLE_PS_VALID		0x00000001	/* Entry is valid */
867 #define	APPLE_PS_ALLOCATED	0x00000002	/* Entry is allocated */
868 #define	APPLE_PS_IN_USE		0x00000004	/* Entry in use */
869 #define	APPLE_PS_BOOT_INFO	0x00000008	/* Entry contains boot info */
870 #define	APPLE_PS_READABLE	0x00000010	/* Entry is readable */
871 #define	APPLE_PS_WRITABLE	0x00000020	/* Entry is writable */
872 #define	APPLE_PS_BOOT_CODE_PIC	0x00000040	/* Boot code has position
873 						 * independent code */
874 #define	APPLE_PS_CC_DRVR	0x00000100	/* Partition contains chain-
875 						 * compatible driver */
876 #define	APPLE_PS_RL_DRVR	0x00000200	/* Partition contains real
877 						 * driver */
878 #define	APPLE_PS_CH_DRVR	0x00000400	/* Partition contains chain
879 						 * driver */
880 #define	APPLE_PS_AUTO_MOUNT	0x40000000	/* Mount automatically at
881 						 * startup */
882 #define	APPLE_PS_STARTUP	0x80000000	/* Is the startup partition */
883 	uint32_t	pmLgBootStart;	/* first logical block of boot code */
884 	uint32_t	pmBootSize;	/* size of boot code, in bytes */
885 	uint32_t	pmBootLoad;	/* boot code load address */
886 	uint32_t	pmBootLoad2;	/* (reserved) */
887 	uint32_t	pmBootEntry;	/* boot code entry point */
888 	uint32_t	pmBootEntry2;	/* (reserved) */
889 	uint32_t	pmBootCksum;	/* boot code checksum */
890 	int8_t		pmProcessor[16]; /* processor type (e.g. "68020") */
891 	uint8_t		pmBootArgs[128]; /* A/UX boot arguments */
892 	uint8_t		pad[248];	/* pad to end of block */
893 };
894 
895 #define	APPLE_PART_TYPE_DRIVER		"APPLE_DRIVER"
896 #define	APPLE_PART_TYPE_DRIVER43	"APPLE_DRIVER43"
897 #define	APPLE_PART_TYPE_DRIVERATA	"APPLE_DRIVER_ATA"
898 #define	APPLE_PART_TYPE_DRIVERIOKIT	"APPLE_DRIVER_IOKIT"
899 #define	APPLE_PART_TYPE_FWDRIVER	"APPLE_FWDRIVER"
900 #define	APPLE_PART_TYPE_FWB_COMPONENT	"FWB DRIVER COMPONENTS"
901 #define	APPLE_PART_TYPE_FREE		"APPLE_FREE"
902 #define	APPLE_PART_TYPE_MAC		"APPLE_HFS"
903 #define	APPLE_PART_TYPE_NETBSD		"NETBSD"
904 #define	APPLE_PART_TYPE_NBSD_PPCBOOT	"NETBSD/MACPPC"
905 #define	APPLE_PART_TYPE_NBSD_68KBOOT	"NETBSD/MAC68K"
906 #define	APPLE_PART_TYPE_PATCHES		"APPLE_PATCHES"
907 #define	APPLE_PART_TYPE_PARTMAP		"APPLE_PARTITION_MAP"
908 #define	APPLE_PART_TYPE_PATCHES		"APPLE_PATCHES"
909 #define	APPLE_PART_TYPE_SCRATCH		"APPLE_SCRATCH"
910 #define	APPLE_PART_TYPE_UNIX		"APPLE_UNIX_SVR2"
911 
912 /*
913  * "pmBootArgs" for APPLE_UNIX_SVR2 partition.
914  * NetBSD/mac68k only uses Magic, Cluster, Type, and Flags.
915  */
916 struct apple_blockzeroblock {
917 	uint32_t       bzbMagic;
918 	uint8_t        bzbCluster;
919 	uint8_t        bzbType;
920 	uint16_t       bzbBadBlockInode;
921 	uint16_t       bzbFlags;
922 	uint16_t       bzbReserved;
923 	uint32_t       bzbCreationTime;
924 	uint32_t       bzbMountTime;
925 	uint32_t       bzbUMountTime;
926 };
927 
928 #define	APPLE_BZB_MAGIC		0xABADBABE
929 #define	APPLE_BZB_TYPEFS	1
930 #define	APPLE_BZB_TYPESWAP	3
931 #define	APPLE_BZB_ROOTFS	0x8000
932 #define	APPLE_BZB_USRFS		0x4000
933 
934 /* ------------------------------------------
935  * ews4800mips
936  *
937  */
938 
939 #define	EWS4800MIPS_BBINFO_MAGIC		"NetBSD/ews4800mips     20040611"
940 #define	EWS4800MIPS_BOOT_BLOCK_OFFSET		0
941 #define	EWS4800MIPS_BOOT_BLOCK_BLOCKSIZE	512
942 #define	EWS4800MIPS_BOOT_BLOCK_MAX_SIZE		(512 * 8)
943 
944 /* ------------------------------------------
945  * hp300
946  *
947  */
948 
949 /* volume header for "LIF" format volumes */
950 
951 struct	hp300_lifvol {
952 	int16_t	vol_id;
953 	char	vol_label[6];
954 	int32_t	vol_addr;
955 	int16_t	vol_oct;
956 	int16_t	vol_dummy;
957 	int32_t	vol_dirsize;
958 	int16_t	vol_version;
959 	int16_t	vol_zero;
960 	int32_t	vol_huh1;
961 	int32_t	vol_huh2;
962 	int32_t	vol_length;
963 };
964 
965 /* LIF directory entry format */
966 
967 struct	hp300_lifdir {
968 	char	dir_name[10];
969 	int16_t	dir_type;
970 	int32_t	dir_addr;
971 	int32_t	dir_length;
972 	char	dir_toc[6];
973 	int16_t	dir_flag;
974 	int32_t	dir_exec;
975 };
976 
977 /* load header for boot rom */
978 struct hp300_load {
979 	int32_t address;
980 	int32_t count;
981 };
982 
983 #define	HP300_VOL_ID		-32768
984 #define	HP300_VOL_OCT		4096
985 #define	HP300_DIR_TYPE		-5822
986 #define	HP300_DIR_FLAG		0x8001	/* dont ask me! */
987 #define	HP300_SECTSIZE		256
988 
989 
990 /* ------------------------------------------
991  * hppa
992  *
993  */
994 
995 /*
996  * volume header for "LIF" format volumes
997  */
998 struct	hppa_lifvol {
999 	uint16_t	vol_id;
1000 	uint8_t		vol_label[6];
1001 	uint32_t	vol_addr;
1002 	uint16_t	vol_oct;
1003 	uint16_t	vol_dummy;
1004 
1005 	uint32_t	vol_dirsize;
1006 	uint16_t	vol_version;
1007 	uint16_t	vol_zero;
1008 	uint32_t	vol_number;
1009 	uint32_t	vol_lastvol;
1010 
1011 	uint32_t	vol_length;
1012 	uint8_t		vol_toc[6];
1013 	uint8_t		vol_dummy1[198];
1014 
1015 	uint32_t	ipl_addr;
1016 	uint32_t	ipl_size;
1017 	uint32_t	ipl_entry;
1018 
1019 	uint32_t	vol_dummy2;
1020 };
1021 
1022 struct	hppa_lifdir {
1023 	uint8_t		dir_name[10];
1024 	uint16_t	dir_type;
1025 	uint32_t	dir_addr;
1026 	uint32_t	dir_length;
1027 	uint8_t		dir_toc[6];
1028 	uint16_t	dir_flag;
1029 	uint32_t	dir_implement;
1030 };
1031 
1032 struct hppa_lifload {
1033 	int address;
1034 	int count;
1035 };
1036 
1037 #define	HPPA_LIF_VOL_ID	0x8000
1038 #define	HPPA_LIF_VOL_OCT	0x1000
1039 #define	HPPA_LIF_DIR_SWAP	0x5243
1040 #define	HPPA_LIF_DIR_FS	0xcd38
1041 #define	HPPA_LIF_DIR_IOMAP	0xcd60
1042 #define	HPPA_LIF_DIR_HPUX	0xcd80
1043 #define	HPPA_LIF_DIR_ISL	0xce00
1044 #define	HPPA_LIF_DIR_PAD	0xcffe
1045 #define	HPPA_LIF_DIR_AUTO	0xcfff
1046 #define	HPPA_LIF_DIR_EST	0xd001
1047 #define	HPPA_LIF_DIR_TYPE	0xe942
1048 
1049 #define	HPPA_LIF_DIR_FLAG	0x8001	/* dont ask me! */
1050 #define	HPPA_LIF_SECTSIZE	256
1051 
1052 #define	HPPA_LIF_NUMDIR	8
1053 
1054 #define	HPPA_LIF_VOLSTART	0
1055 #define	HPPA_LIF_VOLSIZE	sizeof(struct hppa_lifvol)
1056 #define	HPPA_LIF_DIRSTART	2048
1057 #define	HPPA_LIF_DIRSIZE	(HPPA_LIF_NUMDIR * sizeof(struct hppa_lifdir))
1058 #define	HPPA_LIF_FILESTART	4096
1059 
1060 #define	hppa_btolifs(b)	(((b) + (HPPA_LIF_SECTSIZE - 1)) / HPPA_LIF_SECTSIZE)
1061 #define	hppa_lifstob(s)	((s) * HPPA_LIF_SECTSIZE)
1062 #define	hppa_lifstodb(s)	((s) * HPPA_LIF_SECTSIZE / DEV_BSIZE)
1063 
1064 
1065 /* ------------------------------------------
1066  * x86
1067  *
1068  */
1069 
1070 /*
1071  * Parameters for NetBSD /boot written to start of pbr code by installboot
1072  */
1073 
1074 struct x86_boot_params {
1075 	uint32_t	bp_length;	/* length of patchable data */
1076 	uint32_t	bp_flags;
1077 	uint32_t	bp_timeout;	/* boot timeout in seconds */
1078 	uint32_t	bp_consdev;
1079 	uint32_t	bp_conspeed;
1080 	uint8_t		bp_password[16];	/* md5 hash of password */
1081 	char		bp_keymap[64];	/* keyboard translation map */
1082 	uint32_t	bp_consaddr;	/* ioaddr for console */
1083 };
1084 
1085 #endif	/* !defined(__ASSEMBLER__) */				/* } */
1086 
1087 #define	X86_BOOT_MAGIC(n)	('x' << 24 | 0x86b << 12 | 'm' << 4 | (n))
1088 #define	X86_BOOT_MAGIC_1	X86_BOOT_MAGIC(1)	/* pbr.S */
1089 #define	X86_BOOT_MAGIC_2	X86_BOOT_MAGIC(2)	/* bootxx.S */
1090 #define	X86_BOOT_MAGIC_PXE	X86_BOOT_MAGIC(3)	/* start_pxe.S */
1091 #define	X86_BOOT_MAGIC_FAT	X86_BOOT_MAGIC(4)	/* fatboot.S */
1092 #define	X86_MBR_GPT_MAGIC	0xedb88320		/* gpt.S */
1093 
1094 		/* values for bp_flags */
1095 #define	X86_BP_FLAGS_RESET_VIDEO	1
1096 #define	X86_BP_FLAGS_PASSWORD		2
1097 #define	X86_BP_FLAGS_NOMODULES		4
1098 #define	X86_BP_FLAGS_NOBOOTCONF		8
1099 #define	X86_BP_FLAGS_LBA64VALID		0x10
1100 
1101 		/* values for bp_consdev */
1102 #define	X86_BP_CONSDEV_PC	0
1103 #define	X86_BP_CONSDEV_COM0	1
1104 #define	X86_BP_CONSDEV_COM1	2
1105 #define	X86_BP_CONSDEV_COM2	3
1106 #define	X86_BP_CONSDEV_COM3	4
1107 #define	X86_BP_CONSDEV_COM0KBD	5
1108 #define	X86_BP_CONSDEV_COM1KBD	6
1109 #define	X86_BP_CONSDEV_COM2KBD	7
1110 #define	X86_BP_CONSDEV_COM3KBD	8
1111 
1112 /* ------------------------------------------
1113  * landisk
1114  */
1115 
1116 #if !defined(__ASSEMBLER__)					/* { */
1117 
1118 /*
1119  * Parameters for NetBSD /boot written to start of pbr code by installboot
1120  */
1121 struct landisk_boot_params {
1122 	uint32_t	bp_length;	/* length of patchable data */
1123 	uint32_t	bp_flags;
1124 	uint32_t	bp_timeout;	/* boot timeout in seconds */
1125 	uint32_t	bp_consdev;
1126 	uint32_t	bp_conspeed;
1127 };
1128 
1129 #endif	/* !defined(__ASSEMBLER__) */				/* } */
1130 
1131 #define	LANDISK_BOOT_MAGIC_1	0x20031125
1132 #define	LANDISK_BOOT_MAGIC_2	0x20041110
1133 
1134 #if !defined(__ASSEMBLER__)					/* { */
1135 
1136 /* ------------------------------------------
1137  * macppc
1138  */
1139 
1140 #define	MACPPC_BOOT_BLOCK_OFFSET	2048
1141 #define	MACPPC_BOOT_BLOCK_BLOCKSIZE	512
1142 #define	MACPPC_BOOT_BLOCK_MAX_SIZE	2048	/* XXX: could be up to 6144 */
1143 	/* Magic string -- 32 bytes long (including the NUL) */
1144 #define	MACPPC_BBINFO_MAGIC		"NetBSD/macppc bootxx   20020515"
1145 
1146 /* ------------------------------------------
1147  * news68k, newsmips
1148  */
1149 
1150 #define	NEWS_BOOT_BLOCK_LABELOFFSET	64 /* XXX from <machine/disklabel.h> */
1151 #define	NEWS_BOOT_BLOCK_OFFSET		0
1152 #define	NEWS_BOOT_BLOCK_BLOCKSIZE	512
1153 #define	NEWS_BOOT_BLOCK_MAX_SIZE	(512 * 16)
1154 
1155 	/* Magic string -- 32 bytes long (including the NUL) */
1156 #define	NEWS68K_BBINFO_MAGIC		"NetBSD/news68k bootxx  20020518"
1157 #define	NEWSMIPS_BBINFO_MAGIC		"NetBSD/newsmips bootxx 20020518"
1158 
1159 /* ------------------------------------------
1160  * next68k
1161  */
1162 
1163 #define	NEXT68K_LABEL_MAXPARTITIONS	8	/* number of partitions in next68k_disklabel */
1164 #define	NEXT68K_LABEL_CPULBLLEN		24
1165 #define	NEXT68K_LABEL_MAXDNMLEN		24
1166 #define	NEXT68K_LABEL_MAXTYPLEN		24
1167 #define	NEXT68K_LABEL_MAXBFLEN		24
1168 #define	NEXT68K_LABEL_MAXHNLEN		32
1169 #define	NEXT68K_LABEL_MAXMPTLEN		16
1170 #define	NEXT68K_LABEL_MAXFSTLEN		8
1171 #define	NEXT68K_LABEL_NBAD		1670	/* sized to make label ~= 8KB */
1172 
1173 struct next68k_partition {
1174 	int32_t	cp_offset;		/* starting sector */
1175 	int32_t	cp_size;		/* number of sectors in partition */
1176 	int16_t	cp_bsize;		/* block size in bytes */
1177 	int16_t	cp_fsize;		/* filesystem basic fragment size */
1178 	char	cp_opt;			/* optimization type: 's'pace/'t'ime */
1179 	char	cp_pad1;
1180 	int16_t	cp_cpg;			/* filesystem cylinders per group */
1181 	int16_t	cp_density;		/* bytes per inode density */
1182 	int8_t	cp_minfree;		/* minfree (%) */
1183 	int8_t	cp_newfs;		/* run newfs during init */
1184 	char	cp_mountpt[NEXT68K_LABEL_MAXMPTLEN];
1185 					/* default/standard mount point */
1186 	int8_t	cp_automnt;		/* auto-mount when inserted */
1187 	char	cp_type[NEXT68K_LABEL_MAXFSTLEN]; /* file system type name */
1188 	char	cp_pad2;
1189 } __packed;
1190 
1191 /* The disklabel the way it is on the disk */
1192 struct next68k_disklabel {
1193 	int32_t	cd_version;		/* label version */
1194 	int32_t	cd_label_blkno;		/* block # of this label */
1195 	int32_t	cd_size;		/* size of media area (sectors) */
1196 	char	cd_label[NEXT68K_LABEL_CPULBLLEN]; /* disk name (label) */
1197 	uint32_t cd_flags;		/* flags */
1198 	uint32_t cd_tag;		/* volume tag */
1199 	char	cd_name[NEXT68K_LABEL_MAXDNMLEN]; /* drive (hardware) name */
1200 	char	cd_type[NEXT68K_LABEL_MAXTYPLEN]; /* drive type */
1201 	int32_t	cd_secsize;		/* # of bytes per sector */
1202 	int32_t	cd_ntracks;		/* # of tracks per cylinder */
1203 	int32_t	cd_nsectors;		/* # of data sectors per track */
1204 	int32_t	cd_ncylinders;		/* # of data cylinders per unit */
1205 	int32_t	cd_rpm;			/* rotational speed */
1206 	int16_t	cd_front;		/* # of sectors in "front porch" */
1207 	int16_t	cd_back;		/* # of sectors in "back porch" */
1208 	int16_t	cd_ngroups;		/* # of alt groups */
1209 	int16_t	cd_ag_size;		/* alt group size (sectors) */
1210 	int16_t	cd_ag_alts;		/* alternate sectors / alt group */
1211 	int16_t	cd_ag_off;		/* sector offset to first alternate */
1212 	int32_t	cd_boot_blkno[2];	/* boot program locations */
1213 	char	cd_kernel[NEXT68K_LABEL_MAXBFLEN]; /* default kernel name */
1214 	char	cd_hostname[NEXT68K_LABEL_MAXHNLEN];
1215 				/* host name (usu. where disk was labeled) */
1216 	char	cd_rootpartition;	/* root partition letter e.g. 'a' */
1217 	char	cd_rwpartition;		/* r/w partition letter e.g. 'b' */
1218 	struct next68k_partition cd_partitions[NEXT68K_LABEL_MAXPARTITIONS];
1219 
1220 	union {
1221 		uint16_t CD_v3_checksum; /* label version 3 checksum */
1222 		int32_t	CD_bad[NEXT68K_LABEL_NBAD];
1223 					/* block number that is bad */
1224 	} cd_un;
1225 	uint16_t cd_checksum;		/* label version 1 or 2 checksum */
1226 } __packed;
1227 
1228 #define	NEXT68K_LABEL_cd_checksum	cd_checksum
1229 #define	NEXT68K_LABEL_cd_v3_checksum	cd_un.CD_v3_checksum
1230 #define	NEXT68K_LABEL_cd_bad		cd_un.CD_bad
1231 
1232 #define	NEXT68K_LABEL_SECTOR		0	/* sector containing label */
1233 #define	NEXT68K_LABEL_OFFSET		0	/* offset of label in sector */
1234 #define	NEXT68K_LABEL_SIZE		8192	/* size of label */
1235 #define	NEXT68K_LABEL_CD_V1		0x4e655854 /* version #1: "NeXT" */
1236 #define	NEXT68K_LABEL_CD_V2		0x646c5632 /* version #2: "dlV2" */
1237 #define	NEXT68K_LABEL_CD_V3		0x646c5633 /* version #3: "dlV3" */
1238 #define	NEXT68K_LABEL_DEFAULTFRONTPORCH	(160 * 2)
1239 #define	NEXT68K_LABEL_DEFAULTBOOT0_1	(32 * 2)
1240 #define	NEXT68K_LABEL_DEFAULTBOOT0_2	(96 * 2)
1241 
1242 /* ------------------------------------------
1243  * pmax --
1244  *	PMAX (DECstation / MIPS) boot block information
1245  */
1246 
1247 /*
1248  * If mode is 0, there is just one sequence of blocks and one Dec_BootMap
1249  * is used.  If mode is 1, there are multiple sequences of blocks
1250  * and multiple Dec_BootMaps are used, the last with numBlocks = 0.
1251  */
1252 struct pmax_boot_map {
1253 	int32_t	num_blocks;		/* Number of blocks to read. */
1254 	int32_t	start_block;		/* Starting block on disk. */
1255 };
1256 
1257 /*
1258  * This is the structure of a disk or tape boot block.  The boot_map
1259  * can either be a single boot count and start block (contiguous mode)
1260  * or a list of up to 61 (to fill a 512 byte sector) block count and
1261  * start block pairs.  Under NetBSD, contiguous mode is always used.
1262  */
1263 struct pmax_boot_block {
1264 	uint8_t		pad[8];
1265 	int32_t		magic;			/* PMAX_BOOT_MAGIC */
1266 	int32_t		mode;			/* Mode for boot info. */
1267 	uint32_t	load_addr;		/* Address to start loading. */
1268 	uint32_t	exec_addr;		/* Address to start execing. */
1269 	struct		pmax_boot_map map[61];	/* boot program section(s). */
1270 } __packed;
1271 
1272 #define	PMAX_BOOT_MAGIC			0x0002757a
1273 #define	PMAX_BOOTMODE_CONTIGUOUS	0
1274 #define	PMAX_BOOTMODE_SCATTERED		1
1275 
1276 #define	PMAX_BOOT_BLOCK_OFFSET		0
1277 #define	PMAX_BOOT_BLOCK_BLOCKSIZE	512
1278 
1279 
1280 /* ------------------------------------------
1281  * sgimips
1282  */
1283 
1284 /*
1285  * Some IRIX man pages refer to the size being a multiple of whole cylinders.
1286  * Later ones only refer to the size being "typically" 2MB.  IRIX fx(1)
1287  * uses a default drive geometry if one can't be determined, suggesting
1288  * that "whole cylinder" multiples are not required.
1289  */
1290 
1291 #define SGI_BOOT_BLOCK_SIZE_VOLHDR	3135
1292 #define SGI_BOOT_BLOCK_MAGIC		0xbe5a941
1293 #define SGI_BOOT_BLOCK_MAXPARTITIONS	16
1294 #define SGI_BOOT_BLOCK_MAXVOLDIRS	15
1295 #define SGI_BOOT_BLOCK_BLOCKSIZE	512
1296 
1297 /*
1298  * SGI partition conventions:
1299  *
1300  * Partition 0 - root
1301  * Partition 1 - swap
1302  * Partition 6 - usr
1303  * Partition 7 - volume body
1304  * Partition 8 - volume header
1305  * Partition 10 - whole disk
1306  */
1307 
1308 struct sgi_boot_devparms {
1309 	uint8_t		dp_skew;
1310 	uint8_t		dp_gap1;
1311 	uint8_t		dp_gap2;
1312 	uint8_t		dp_spares_cyl;
1313 	uint16_t	dp_cyls;
1314 	uint16_t	dp_shd0;
1315 	uint16_t	dp_trks0;
1316 	uint8_t		dp_ctq_depth;
1317 	uint8_t		dp_cylshi;
1318 	uint16_t	dp_unused;
1319 	uint16_t	dp_secs;
1320 	uint16_t	dp_secbytes;
1321 	uint16_t	dp_interleave;
1322 	uint32_t	dp_flags;
1323 	uint32_t	dp_datarate;
1324 	uint32_t	dp_nretries;
1325 	uint32_t	dp_mspw;
1326 	uint16_t	dp_xgap1;
1327 	uint16_t	dp_xsync;
1328 	uint16_t	dp_xrdly;
1329 	uint16_t	dp_xgap2;
1330 	uint16_t	dp_xrgate;
1331 	uint16_t	dp_xwcont;
1332 } __packed;
1333 
1334 struct sgi_boot_block {
1335 	uint32_t	magic;
1336 	int16_t		root;
1337 	int16_t		swap;
1338 	char		bootfile[16];
1339 	struct sgi_boot_devparms dp;
1340 	struct {
1341 		char		name[8];
1342 		int32_t		block;
1343 		int32_t		bytes;
1344 	}		voldir[SGI_BOOT_BLOCK_MAXVOLDIRS];
1345 	struct {
1346 		int32_t		blocks;
1347 		int32_t		first;
1348 		int32_t		type;
1349 	}		partitions[SGI_BOOT_BLOCK_MAXPARTITIONS];
1350 	int32_t		checksum;
1351 	int32_t		_pad;
1352 } __packed;
1353 
1354 #define SGI_PTYPE_VOLHDR	0
1355 #define SGI_PTYPE_TRKREPL	1
1356 #define SGI_PTYPE_SECREPL	2
1357 #define SGI_PTYPE_RAW		3
1358 #define SGI_PTYPE_BSD		4
1359 #define SGI_PTYPE_SYSV		5
1360 #define SGI_PTYPE_VOLUME	6
1361 #define SGI_PTYPE_EFS		7
1362 #define SGI_PTYPE_LVOL		8
1363 #define SGI_PTYPE_RLVOL		9
1364 #define SGI_PTYPE_XFS		10
1365 #define SGI_PTYPE_XFSLOG	11
1366 #define SGI_PTYPE_XLV		12
1367 #define SGI_PTYPE_XVM		13
1368 
1369 /* ------------------------------------------
1370  * sparc
1371  */
1372 
1373 #define	SPARC_BOOT_BLOCK_OFFSET		512
1374 #define	SPARC_BOOT_BLOCK_BLOCKSIZE	512
1375 #define	SPARC_BOOT_BLOCK_MAX_SIZE	(512 * 15)
1376 	/* Magic string -- 32 bytes long (including the NUL) */
1377 #define	SPARC_BBINFO_MAGIC		"NetBSD/sparc bootxx    20020515"
1378 
1379 
1380 /* ------------------------------------------
1381  * sparc64
1382  */
1383 
1384 #define	SPARC64_BOOT_BLOCK_OFFSET	512
1385 #define	SPARC64_BOOT_BLOCK_BLOCKSIZE	512
1386 #define	SPARC64_BOOT_BLOCK_MAX_SIZE	(512 * 15)
1387 
1388 
1389 /* ------------------------------------------
1390  * sun68k (sun2, sun3)
1391  */
1392 
1393 #define	SUN68K_BOOT_BLOCK_OFFSET	512
1394 #define	SUN68K_BOOT_BLOCK_BLOCKSIZE	512
1395 #define	SUN68K_BOOT_BLOCK_MAX_SIZE	(512 * 15)
1396 	/* Magic string -- 32 bytes long (including the NUL) */
1397 #define	SUN68K_BBINFO_MAGIC		"NetBSD/sun68k bootxx   20020515"
1398 
1399 
1400 /* ------------------------------------------
1401  * vax --
1402  *	VAX boot block information
1403  */
1404 
1405 struct vax_boot_block {
1406 /* Note that these don't overlap any of the pmax boot block */
1407 	uint8_t		pad0[2];
1408 	uint8_t		bb_id_offset;	/* offset in words to id (magic1)*/
1409 	uint8_t		bb_mbone;	/* must be one */
1410 	uint16_t	bb_lbn_hi;	/* lbn (hi word) of bootstrap */
1411 	uint16_t	bb_lbn_low;	/* lbn (low word) of bootstrap */
1412 	uint8_t		pad1[406];
1413 	/* disklabel offset is 64 from base, or 56 from start of pad1 */
1414 
1415 	/* The rest of these fields are identification area and describe
1416 	 * the secondary block for uVAX VMB.
1417 	 */
1418 	uint8_t		bb_magic1;	/* magic number */
1419 	uint8_t		bb_mbz1;	/* must be zero */
1420 	uint8_t		bb_pad1;	/* any value */
1421 	uint8_t		bb_sum1;	/* ~(magic1 + mbz1 + pad1) */
1422 
1423 	uint8_t		bb_mbz2;	/* must be zero */
1424 	uint8_t		bb_volinfo;	/* volinfo */
1425 	uint8_t		bb_pad2a;	/* any value */
1426 	uint8_t		bb_pad2b;	/* any value */
1427 
1428 	uint32_t	bb_size;	/* size in blocks of bootstrap */
1429 	uint32_t	bb_load;	/* load offset to bootstrap */
1430 	uint32_t	bb_entry;	/* byte offset in bootstrap */
1431 	uint32_t	bb_sum3;	/* sum of previous 3 fields */
1432 
1433 	/* The rest is unused.
1434 	 */
1435 	uint8_t		pad2[74];
1436 } __packed;
1437 
1438 #define	VAX_BOOT_MAGIC1			0x18	/* size of BB info? */
1439 #define	VAX_BOOT_VOLINFO_NONE		0x00	/* no special info */
1440 #define	VAX_BOOT_VOLINFO_SS		0x01	/* single sided */
1441 #define	VAX_BOOT_VOLINFO_DS		0x81	/* double sided */
1442 
1443 #define	VAX_BOOT_SIZE			15	/* 15 blocks */
1444 #define	VAX_BOOT_LOAD			0	/* no load offset */
1445 #define	VAX_BOOT_ENTRY			0x200	/* one block in */
1446 
1447 #define	VAX_BOOT_BLOCK_OFFSET		0
1448 #define	VAX_BOOT_BLOCK_BLOCKSIZE	512
1449 
1450 
1451 /* ------------------------------------------
1452  * x68k
1453  */
1454 
1455 #define	X68K_BOOT_BLOCK_OFFSET		0
1456 #define	X68K_BOOT_BLOCK_BLOCKSIZE	512
1457 #define	X68K_BOOT_BLOCK_MAX_SIZE	(512 * 16)
1458 	/* Magic string -- 32 bytes long (including the NUL) */
1459 #define	X68K_BBINFO_MAGIC		"NetBSD/x68k bootxx     20020601"
1460 
1461 #endif	/* !defined(__ASSEMBLER__) */				/* } */
1462 
1463 #endif	/* !_SYS_BOOTBLOCK_H */
1464