disklabel.h revision 1.16 1 1.16 christos /* $NetBSD: disklabel.h,v 1.16 2019/04/03 22:10:49 christos Exp $ */
2 1.1 tsubai
3 1.1 tsubai /*-
4 1.1 tsubai * Copyright (C) 1995, 1996 Wolfgang Solfrank.
5 1.1 tsubai * Copyright (C) 1995, 1996 TooLs GmbH.
6 1.1 tsubai * All rights reserved.
7 1.1 tsubai *
8 1.1 tsubai * Redistribution and use in source and binary forms, with or without
9 1.1 tsubai * modification, are permitted provided that the following conditions
10 1.1 tsubai * are met:
11 1.1 tsubai * 1. Redistributions of source code must retain the above copyright
12 1.1 tsubai * notice, this list of conditions and the following disclaimer.
13 1.1 tsubai * 2. Redistributions in binary form must reproduce the above copyright
14 1.1 tsubai * notice, this list of conditions and the following disclaimer in the
15 1.1 tsubai * documentation and/or other materials provided with the distribution.
16 1.1 tsubai * 3. All advertising materials mentioning features or use of this software
17 1.1 tsubai * must display the following acknowledgement:
18 1.1 tsubai * This product includes software developed by TooLs GmbH.
19 1.1 tsubai * 4. The name of TooLs GmbH may not be used to endorse or promote products
20 1.1 tsubai * derived from this software without specific prior written permission.
21 1.1 tsubai *
22 1.1 tsubai * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR
23 1.1 tsubai * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24 1.1 tsubai * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25 1.1 tsubai * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 1.1 tsubai * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
27 1.1 tsubai * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
28 1.1 tsubai * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
29 1.1 tsubai * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
30 1.1 tsubai * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
31 1.1 tsubai * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 1.1 tsubai */
33 1.4 wrstuden /*
34 1.4 wrstuden * Copyright (c) 1994 Christopher G. Demetriou
35 1.4 wrstuden * All rights reserved.
36 1.4 wrstuden *
37 1.4 wrstuden * Redistribution and use in source and binary forms, with or without
38 1.4 wrstuden * modification, are permitted provided that the following conditions
39 1.4 wrstuden * are met:
40 1.4 wrstuden * 1. Redistributions of source code must retain the above copyright
41 1.4 wrstuden * notice, this list of conditions and the following disclaimer.
42 1.4 wrstuden * 2. Redistributions in binary form must reproduce the above copyright
43 1.4 wrstuden * notice, this list of conditions and the following disclaimer in the
44 1.4 wrstuden * documentation and/or other materials provided with the distribution.
45 1.4 wrstuden * 3. All advertising materials mentioning features or use of this software
46 1.4 wrstuden * must display the following acknowledgement:
47 1.4 wrstuden * This product includes software developed by Christopher G. Demetriou.
48 1.4 wrstuden * 4. The name of the author may not be used to endorse or promote products
49 1.4 wrstuden * derived from this software without specific prior written permission
50 1.4 wrstuden *
51 1.4 wrstuden * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
52 1.4 wrstuden * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
53 1.4 wrstuden * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
54 1.4 wrstuden * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
55 1.4 wrstuden * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
56 1.4 wrstuden * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
57 1.4 wrstuden * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
58 1.4 wrstuden * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
59 1.4 wrstuden * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
60 1.4 wrstuden * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
61 1.4 wrstuden */
62 1.4 wrstuden /*-
63 1.4 wrstuden * Copyright (C) 1993 Allen K. Briggs, Chris P. Caputo,
64 1.4 wrstuden * Michael L. Finch, Bradley A. Grantham, and
65 1.4 wrstuden * Lawrence A. Kesteloot
66 1.4 wrstuden * All rights reserved.
67 1.4 wrstuden *
68 1.4 wrstuden * Redistribution and use in source and binary forms, with or without
69 1.4 wrstuden * modification, are permitted provided that the following conditions
70 1.4 wrstuden * are met:
71 1.4 wrstuden * 1. Redistributions of source code must retain the above copyright
72 1.4 wrstuden * notice, this list of conditions and the following disclaimer.
73 1.4 wrstuden * 2. Redistributions in binary form must reproduce the above copyright
74 1.4 wrstuden * notice, this list of conditions and the following disclaimer in the
75 1.4 wrstuden * documentation and/or other materials provided with the distribution.
76 1.4 wrstuden * 3. All advertising materials mentioning features or use of this software
77 1.4 wrstuden * must display the following acknowledgement:
78 1.4 wrstuden * This product includes software developed by the Alice Group.
79 1.4 wrstuden * 4. The names of the Alice Group or any of its members may not be used
80 1.4 wrstuden * to endorse or promote products derived from this software without
81 1.4 wrstuden * specific prior written permission.
82 1.4 wrstuden *
83 1.4 wrstuden * THIS SOFTWARE IS PROVIDED BY THE ALICE GROUP ``AS IS'' AND ANY EXPRESS OR
84 1.4 wrstuden * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
85 1.4 wrstuden * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
86 1.4 wrstuden * IN NO EVENT SHALL THE ALICE GROUP BE LIABLE FOR ANY DIRECT, INDIRECT,
87 1.4 wrstuden * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
88 1.4 wrstuden * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
89 1.4 wrstuden * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
90 1.4 wrstuden * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
91 1.4 wrstuden * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
92 1.4 wrstuden * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
93 1.4 wrstuden *
94 1.4 wrstuden */
95 1.1 tsubai
96 1.1 tsubai #ifndef _MACHINE_DISKLABEL_H_
97 1.1 tsubai #define _MACHINE_DISKLABEL_H_
98 1.1 tsubai
99 1.15 bouyer #define LABELUSESMBR 1 /* use MBR partitionning */
100 1.1 tsubai #define LABELSECTOR 0 /* sector containing label */
101 1.1 tsubai #define LABELOFFSET 64 /* offset of label in sector */
102 1.9 itojun #define MBR_LABELSECTOR 1 /* sector containing label - in MBR */
103 1.9 itojun #define MBR_LABELOFFSET 0 /* offset of label in sector - in MBR */
104 1.1 tsubai #define MAXPARTITIONS 16 /* number of partitions */
105 1.1 tsubai #define RAW_PART 2 /* raw partition: XX?c */
106 1.1 tsubai
107 1.1 tsubai struct cpu_disklabel {
108 1.9 itojun daddr_t cd_start; /* Offset to NetBSD partition in blocks */
109 1.9 itojun daddr_t cd_labelsector; /* label sector offset from cd_start */
110 1.9 itojun int cd_labeloffset; /* label byte offset within label sector */
111 1.1 tsubai };
112 1.4 wrstuden
113 1.4 wrstuden /*
114 1.4 wrstuden * Driver Descriptor Map, from Inside Macintosh: Devices, SCSI Manager
115 1.4 wrstuden * pp 12-13. The driver descriptor map always resides on physical block 0.
116 1.4 wrstuden */
117 1.4 wrstuden struct drvr_descriptor {
118 1.4 wrstuden u_int32_t descBlock; /* first block of driver */
119 1.4 wrstuden u_int16_t descSize; /* driver size in blocks */
120 1.4 wrstuden u_int16_t descType; /* system type */
121 1.4 wrstuden };
122 1.4 wrstuden
123 1.4 wrstuden /* system types; Apple reserves 0-15 */
124 1.4 wrstuden #define DRVR_TYPE_MACINTOSH 1
125 1.4 wrstuden
126 1.4 wrstuden struct drvr_map {
127 1.4 wrstuden #define DRIVER_MAP_MAGIC 0x4552
128 1.4 wrstuden u_int16_t sbSig; /* map signature */
129 1.4 wrstuden u_int16_t sbBlockSize; /* block size of device */
130 1.4 wrstuden u_int32_t sbBlkCount; /* number of blocks on device */
131 1.4 wrstuden u_int16_t sbDevType; /* (used internally by ROM) */
132 1.4 wrstuden u_int16_t sbDevID; /* (used internally by ROM) */
133 1.4 wrstuden u_int32_t sbData; /* (used internally by ROM) */
134 1.4 wrstuden u_int16_t sbDrvrCount; /* number of driver descriptors */
135 1.4 wrstuden #define DRVR_MAX_DESCRIPTORS 61
136 1.4 wrstuden struct drvr_descriptor sb_dd[DRVR_MAX_DESCRIPTORS];
137 1.4 wrstuden u_int16_t pad[3];
138 1.4 wrstuden } __attribute__ ((packed));
139 1.4 wrstuden
140 1.4 wrstuden #define ddBlock(N) sb_dd[(N)].descBlock
141 1.4 wrstuden #define ddSize(N) sb_dd[(N)].descSize
142 1.4 wrstuden #define ddType(N) sb_dd[(N)].descType
143 1.4 wrstuden
144 1.4 wrstuden /*
145 1.4 wrstuden * Partition map structure from Inside Macintosh: Devices, SCSI Manager
146 1.4 wrstuden * pp. 13-14. The partition map always begins on physical block 1.
147 1.4 wrstuden *
148 1.4 wrstuden * With the exception of block 0, all blocks on the disk must belong to
149 1.4 wrstuden * exactly one partition. The partition map itself belongs to a partition
150 1.4 wrstuden * of type `APPLE_PARTITION_MAP', and is not limited in size by anything
151 1.4 wrstuden * other than available disk space. The partition map is not necessarily
152 1.4 wrstuden * the first partition listed.
153 1.4 wrstuden */
154 1.4 wrstuden struct part_map_entry {
155 1.4 wrstuden #define PART_ENTRY_MAGIC 0x504d
156 1.4 wrstuden u_int16_t pmSig; /* partition signature */
157 1.4 wrstuden u_int16_t pmSigPad; /* (reserved) */
158 1.4 wrstuden u_int32_t pmMapBlkCnt; /* number of blocks in partition map */
159 1.4 wrstuden u_int32_t pmPyPartStart; /* first physical block of partition */
160 1.4 wrstuden u_int32_t pmPartBlkCnt; /* number of blocks in partition */
161 1.4 wrstuden char pmPartName[32]; /* partition name */
162 1.4 wrstuden char pmPartType[32]; /* partition type */
163 1.4 wrstuden u_int32_t pmLgDataStart; /* first logical block of data area */
164 1.4 wrstuden u_int32_t pmDataCnt; /* number of blocks in data area */
165 1.4 wrstuden u_int32_t pmPartStatus; /* partition status information */
166 1.4 wrstuden u_int32_t pmLgBootStart; /* first logical block of boot code */
167 1.4 wrstuden u_int32_t pmBootSize; /* size of boot code, in bytes */
168 1.4 wrstuden u_int32_t pmBootLoad; /* boot code load address */
169 1.4 wrstuden u_int32_t pmBootLoad2; /* (reserved) */
170 1.4 wrstuden u_int32_t pmBootEntry; /* boot code entry point */
171 1.4 wrstuden u_int32_t pmBootEntry2; /* (reserved) */
172 1.4 wrstuden u_int32_t pmBootCksum; /* boot code checksum */
173 1.4 wrstuden char pmProcessor[16]; /* processor type (e.g. "68020") */
174 1.4 wrstuden u_int8_t pmBootArgs[128]; /* A/UX boot arguments */
175 1.4 wrstuden u_int8_t pad[248]; /* pad to end of block */
176 1.4 wrstuden };
177 1.4 wrstuden
178 1.4 wrstuden #define PART_TYPE_DRIVER "APPLE_DRIVER"
179 1.4 wrstuden #define PART_TYPE_DRIVER43 "APPLE_DRIVER43"
180 1.4 wrstuden #define PART_TYPE_DRIVERATA "APPLE_DRIVER_ATA"
181 1.6 wrstuden #define PART_TYPE_DRIVERIOKIT "APPLE_DRIVER_IOKIT"
182 1.7 matt #define PART_TYPE_FWDRIVER "APPLE_FWDRIVER"
183 1.4 wrstuden #define PART_TYPE_FWB_COMPONENT "FWB DRIVER COMPONENTS"
184 1.5 wrstuden #define PART_TYPE_FREE "APPLE_FREE"
185 1.4 wrstuden #define PART_TYPE_MAC "APPLE_HFS"
186 1.10 dbj #define PART_TYPE_APPLEUFS "APPLE_UFS"
187 1.4 wrstuden #define PART_TYPE_NETBSD "NETBSD"
188 1.5 wrstuden #define PART_TYPE_NBSD_PPCBOOT "NETBSD/MACPPC"
189 1.8 wrstuden #define PART_TYPE_NBSD_68KBOOT "NETBSD/MAC68K"
190 1.8 wrstuden #define PART_TYPE_PATCHES "APPLE_PATCHES"
191 1.4 wrstuden #define PART_TYPE_PARTMAP "APPLE_PARTITION_MAP"
192 1.4 wrstuden #define PART_TYPE_SCRATCH "APPLE_SCRATCH"
193 1.10 dbj #define PART_TYPE_BOOT "APPLE_BOOT"
194 1.10 dbj #define PART_TYPE_LOADER "APPLE_LOADER"
195 1.4 wrstuden #define PART_TYPE_UNIX "APPLE_UNIX_SVR2"
196 1.10 dbj #define PART_TYPE_LINUX "LINUX"
197 1.10 dbj #define PART_TYPE_LINUX_SWAP "LINUX_SWAP"
198 1.4 wrstuden
199 1.4 wrstuden /*
200 1.4 wrstuden * "pmBootArgs" for APPLE_UNIX_SVR2 partition.
201 1.4 wrstuden * NetBSD/mac68k only uses Magic, Cluster, Type, and Flags.
202 1.4 wrstuden */
203 1.4 wrstuden struct blockzeroblock {
204 1.4 wrstuden u_int32_t bzbMagic;
205 1.4 wrstuden u_int8_t bzbCluster;
206 1.4 wrstuden u_int8_t bzbType;
207 1.4 wrstuden u_int16_t bzbBadBlockInode;
208 1.4 wrstuden u_int16_t bzbFlags;
209 1.4 wrstuden u_int16_t bzbReserved;
210 1.4 wrstuden u_int32_t bzbCreationTime;
211 1.4 wrstuden u_int32_t bzbMountTime;
212 1.4 wrstuden u_int32_t bzbUMountTime;
213 1.4 wrstuden };
214 1.8 wrstuden #define bzbFSType bzbType
215 1.8 wrstuden #define bzbFrag bzbCluster
216 1.8 wrstuden #define bzbCPG bzbBadBlockInode /* Also sgs for LFS */
217 1.8 wrstuden #define bzbFSize bzbCreationTime
218 1.4 wrstuden
219 1.5 wrstuden /* Apple occasionally changes these */
220 1.4 wrstuden #define BZB_MAGIC 0xABADBABE
221 1.4 wrstuden #define BZB_TYPEFS 1
222 1.4 wrstuden #define BZB_TYPESWAP 3
223 1.4 wrstuden #define BZB_ROOTFS 0x8000
224 1.4 wrstuden #define BZB_USRFS 0x4000
225 1.5 wrstuden #define BZB_USRFS_NEW 0x0004
226 1.1 tsubai
227 1.16 christos #define __HAVE_SETDISKLABEL
228 1.16 christos
229 1.1 tsubai #endif /* _MACHINE_DISKLABEL_H_ */
230