disklabel.h revision 1.7 1 1.7 matt /* $NetBSD: disklabel.h,v 1.7 2001/02/27 06:16:06 matt 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.1 tsubai #define LABELSECTOR 0 /* sector containing label */
100 1.1 tsubai #define LABELOFFSET 64 /* offset of label in sector */
101 1.1 tsubai #define MAXPARTITIONS 16 /* number of partitions */
102 1.1 tsubai #define RAW_PART 2 /* raw partition: XX?c */
103 1.1 tsubai
104 1.1 tsubai struct cpu_disklabel {
105 1.1 tsubai int cd_start; /* Offset to NetBSD partition in blocks */
106 1.1 tsubai };
107 1.4 wrstuden
108 1.4 wrstuden /*
109 1.4 wrstuden * Driver Descriptor Map, from Inside Macintosh: Devices, SCSI Manager
110 1.4 wrstuden * pp 12-13. The driver descriptor map always resides on physical block 0.
111 1.4 wrstuden */
112 1.4 wrstuden struct drvr_descriptor {
113 1.4 wrstuden u_int32_t descBlock; /* first block of driver */
114 1.4 wrstuden u_int16_t descSize; /* driver size in blocks */
115 1.4 wrstuden u_int16_t descType; /* system type */
116 1.4 wrstuden };
117 1.4 wrstuden
118 1.4 wrstuden /* system types; Apple reserves 0-15 */
119 1.4 wrstuden #define DRVR_TYPE_MACINTOSH 1
120 1.4 wrstuden
121 1.4 wrstuden struct drvr_map {
122 1.4 wrstuden #define DRIVER_MAP_MAGIC 0x4552
123 1.4 wrstuden u_int16_t sbSig; /* map signature */
124 1.4 wrstuden u_int16_t sbBlockSize; /* block size of device */
125 1.4 wrstuden u_int32_t sbBlkCount; /* number of blocks on device */
126 1.4 wrstuden u_int16_t sbDevType; /* (used internally by ROM) */
127 1.4 wrstuden u_int16_t sbDevID; /* (used internally by ROM) */
128 1.4 wrstuden u_int32_t sbData; /* (used internally by ROM) */
129 1.4 wrstuden u_int16_t sbDrvrCount; /* number of driver descriptors */
130 1.4 wrstuden #define DRVR_MAX_DESCRIPTORS 61
131 1.4 wrstuden struct drvr_descriptor sb_dd[DRVR_MAX_DESCRIPTORS];
132 1.4 wrstuden u_int16_t pad[3];
133 1.4 wrstuden } __attribute__ ((packed));
134 1.4 wrstuden
135 1.4 wrstuden #define ddBlock(N) sb_dd[(N)].descBlock
136 1.4 wrstuden #define ddSize(N) sb_dd[(N)].descSize
137 1.4 wrstuden #define ddType(N) sb_dd[(N)].descType
138 1.4 wrstuden
139 1.4 wrstuden /*
140 1.4 wrstuden * Partition map structure from Inside Macintosh: Devices, SCSI Manager
141 1.4 wrstuden * pp. 13-14. The partition map always begins on physical block 1.
142 1.4 wrstuden *
143 1.4 wrstuden * With the exception of block 0, all blocks on the disk must belong to
144 1.4 wrstuden * exactly one partition. The partition map itself belongs to a partition
145 1.4 wrstuden * of type `APPLE_PARTITION_MAP', and is not limited in size by anything
146 1.4 wrstuden * other than available disk space. The partition map is not necessarily
147 1.4 wrstuden * the first partition listed.
148 1.4 wrstuden */
149 1.4 wrstuden struct part_map_entry {
150 1.4 wrstuden #define PART_ENTRY_MAGIC 0x504d
151 1.4 wrstuden u_int16_t pmSig; /* partition signature */
152 1.4 wrstuden u_int16_t pmSigPad; /* (reserved) */
153 1.4 wrstuden u_int32_t pmMapBlkCnt; /* number of blocks in partition map */
154 1.4 wrstuden u_int32_t pmPyPartStart; /* first physical block of partition */
155 1.4 wrstuden u_int32_t pmPartBlkCnt; /* number of blocks in partition */
156 1.4 wrstuden char pmPartName[32]; /* partition name */
157 1.4 wrstuden char pmPartType[32]; /* partition type */
158 1.4 wrstuden u_int32_t pmLgDataStart; /* first logical block of data area */
159 1.4 wrstuden u_int32_t pmDataCnt; /* number of blocks in data area */
160 1.4 wrstuden u_int32_t pmPartStatus; /* partition status information */
161 1.4 wrstuden u_int32_t pmLgBootStart; /* first logical block of boot code */
162 1.4 wrstuden u_int32_t pmBootSize; /* size of boot code, in bytes */
163 1.4 wrstuden u_int32_t pmBootLoad; /* boot code load address */
164 1.4 wrstuden u_int32_t pmBootLoad2; /* (reserved) */
165 1.4 wrstuden u_int32_t pmBootEntry; /* boot code entry point */
166 1.4 wrstuden u_int32_t pmBootEntry2; /* (reserved) */
167 1.4 wrstuden u_int32_t pmBootCksum; /* boot code checksum */
168 1.4 wrstuden char pmProcessor[16]; /* processor type (e.g. "68020") */
169 1.4 wrstuden u_int8_t pmBootArgs[128]; /* A/UX boot arguments */
170 1.4 wrstuden u_int8_t pad[248]; /* pad to end of block */
171 1.4 wrstuden };
172 1.4 wrstuden
173 1.4 wrstuden #define PART_TYPE_DRIVER "APPLE_DRIVER"
174 1.4 wrstuden #define PART_TYPE_DRIVER43 "APPLE_DRIVER43"
175 1.4 wrstuden #define PART_TYPE_DRIVERATA "APPLE_DRIVER_ATA"
176 1.6 wrstuden #define PART_TYPE_DRIVERIOKIT "APPLE_DRIVER_IOKIT"
177 1.7 matt #define PART_TYPE_FWDRIVER "APPLE_FWDRIVER"
178 1.4 wrstuden #define PART_TYPE_FWB_COMPONENT "FWB DRIVER COMPONENTS"
179 1.5 wrstuden #define PART_TYPE_FREE "APPLE_FREE"
180 1.4 wrstuden #define PART_TYPE_MAC "APPLE_HFS"
181 1.4 wrstuden #define PART_TYPE_NETBSD "NETBSD"
182 1.5 wrstuden #define PART_TYPE_NBSD_PPCBOOT "NETBSD/MACPPC"
183 1.4 wrstuden #define PART_TYPE_PARTMAP "APPLE_PARTITION_MAP"
184 1.5 wrstuden #define PART_TYPE_PATCHES "APPLE_PATCHES"
185 1.4 wrstuden #define PART_TYPE_SCRATCH "APPLE_SCRATCH"
186 1.4 wrstuden #define PART_TYPE_UNIX "APPLE_UNIX_SVR2"
187 1.4 wrstuden
188 1.4 wrstuden /*
189 1.4 wrstuden * "pmBootArgs" for APPLE_UNIX_SVR2 partition.
190 1.4 wrstuden * NetBSD/mac68k only uses Magic, Cluster, Type, and Flags.
191 1.4 wrstuden */
192 1.4 wrstuden struct blockzeroblock {
193 1.4 wrstuden u_int32_t bzbMagic;
194 1.4 wrstuden u_int8_t bzbCluster;
195 1.4 wrstuden u_int8_t bzbType;
196 1.4 wrstuden u_int16_t bzbBadBlockInode;
197 1.4 wrstuden u_int16_t bzbFlags;
198 1.4 wrstuden u_int16_t bzbReserved;
199 1.4 wrstuden u_int32_t bzbCreationTime;
200 1.4 wrstuden u_int32_t bzbMountTime;
201 1.4 wrstuden u_int32_t bzbUMountTime;
202 1.4 wrstuden };
203 1.4 wrstuden
204 1.5 wrstuden /* Apple occasionally changes these */
205 1.4 wrstuden #define BZB_MAGIC 0xABADBABE
206 1.4 wrstuden #define BZB_TYPEFS 1
207 1.4 wrstuden #define BZB_TYPESWAP 3
208 1.4 wrstuden #define BZB_ROOTFS 0x8000
209 1.4 wrstuden #define BZB_USRFS 0x4000
210 1.5 wrstuden #define BZB_USRFS_NEW 0x0004
211 1.1 tsubai
212 1.1 tsubai #ifdef _KERNEL
213 1.1 tsubai struct disklabel;
214 1.1 tsubai int bounds_check_with_label __P((struct buf *bp, struct disklabel *lp, int wlabel));
215 1.1 tsubai #endif /* _KERNEL */
216 1.1 tsubai
217 1.1 tsubai #endif /* _MACHINE_DISKLABEL_H_ */
218