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