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