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