disklabel.h revision 1.10
1/* $OpenBSD: disklabel.h,v 1.10 2006/10/18 20:09:38 deraadt Exp $ */ 2 3/* 4 * Copyright (c) 1994 Christopher G. Demetriou 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 Christopher G. Demetriou. 18 * 4. The name of the author may not be used to endorse or promote products 19 * derived from this software without specific prior written permission 20 * 21 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 22 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 23 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 24 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 25 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 26 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 30 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 */ 32 33#ifndef _MACHINE_DISKLABEL_H_ 34#define _MACHINE_DISKLABEL_H_ 35 36#define LABELSECTOR 1 /* sector containing label */ 37#define LABELOFFSET 0 /* offset of label in sector */ 38#define MAXPARTITIONS 16 /* number of partitions */ 39#define RAW_PART 2 /* raw partition: ie. rsd0c */ 40 41/* MBR partition table */ 42#define DOSBBSECTOR 0 /* MBR sector number */ 43#define DOSPARTOFF 446 /* Offset of MBR partition table */ 44#define NDOSPART 4 /* # of partitions in MBR */ 45#define DOSMAGICOFF 510 /* Offset of magic number */ 46#define DOSMAGIC 0xaa55 /* Actual magic number */ 47#define MBRMAGIC DOSMAGIC 48#define DOSMBR_SIGNATURE MBRMAGIC 49#define DOSMBR_SIGNATURE_OFF DOSMAGICOFF 50#define DOSACTIVE 0x80 51 52struct dos_partition { 53 u_int8_t dp_flag; /* default boot flag */ 54 u_int8_t dp_shd; /* start head, IsN't Always Meaningful */ 55 u_int8_t dp_ssect; /* start sector, INAM */ 56 u_int8_t dp_scyl; /* start cylinder, INAM */ 57 u_int8_t dp_typ; /* partition type */ 58 u_int8_t dp_ehd; /* end head, INAM */ 59 u_int8_t dp_esect; /* end sector, INAM */ 60 u_int8_t dp_ecyl; /* end cylinder, INAM */ 61 u_int32_t dp_start; /* absolute start sector number */ 62 u_int32_t dp_size; /* partition size in sectors */ 63}; 64 65/* Known DOS partition types. */ 66#define DOSPTYP_UNUSED 0x00 /* Unused partition */ 67#define DOSPTYP_FAT12 0x01 /* 12-bit FAT */ 68#define DOSPTYP_FAT16S 0x04 /* 16-bit FAT, less than 32M */ 69#define DOSPTYP_EXTEND 0x05 /* Extended; contains sub-partitions */ 70#define DOSPTYP_FAT16B 0x06 /* 16-bit FAT, more than 32M */ 71#define DOSPTYP_FAT32 0x0b /* 32-bit FAT */ 72#define DOSPTYP_FAT32L 0x0c /* 32-bit FAT, LBA-mapped */ 73#define DOSPTYP_FAT16L 0x0e /* 16-bit FAT, LBA-mapped */ 74#define DOSPTYP_EXTENDL 0x0f /* Extended, LBA-mapped; contains sub-partitions */ 75#define DOSPTYP_ONTRACK 0x54 76#define DOSPTYP_LINUX 0x83 /* That other thing */ 77#define DOSPTYP_FREEBSD 0xa5 /* FreeBSD partition type */ 78#define DOSPTYP_OPENBSD 0xa6 /* OpenBSD partition type */ 79#define DOSPTYP_NETBSD 0xa9 /* NetBSD partition type */ 80 81/* Isolate the relevant bits to get sector and cylinder. */ 82#define DPSECT(s) ((s) & 0x3f) 83#define DPCYL(c, s) ((c) + (((s) & 0xc0) << 2)) 84 85/* HFS/DPME */ 86 87/* partition map structure from Inside Macintosh: Devices, SCSI Manager 88 * pp. 13-14. The partition map always begins on physical block 1. 89 * 90 * With the exception of block 0, all blocks on the disk must belong to 91 * exactly one partition. The partition map itself belongs to a partition 92 * of type `APPLE_PARTITION_MAP', and is not limited in size by anything 93 * other than available disk space. The partition map is not necessarily 94 * the first partition listed. 95 */ 96struct part_map_entry { 97#define PART_ENTRY_MAGIC 0x504d 98 u_int16_t pmSig; /* partition signature */ 99 u_int16_t pmSigPad; /* (reserved) */ 100 u_int32_t pmMapBlkCnt; /* number of blocks in partition map */ 101 u_int32_t pmPyPartStart; /* first physical block of partition */ 102 u_int32_t pmPartBlkCnt; /* number of blocks in partition */ 103 char pmPartName[32]; /* partition name */ 104 char pmPartType[32]; /* partition type */ 105 u_int32_t pmLgDataStart; /* first logical block of data area */ 106 u_int32_t pmDataCnt; /* number of blocks in data area */ 107 u_int32_t pmPartStatus; /* partition status information */ 108 u_int32_t pmLgBootStart; /* first logical block of boot code */ 109 u_int32_t pmBootSize; /* size of boot code, in bytes */ 110 u_int32_t pmBootLoad; /* boot code load address */ 111 u_int32_t pmBootLoad2; /* (reserved) */ 112 u_int32_t pmBootEntry; /* boot code entry point */ 113 u_int32_t pmBootEntry2; /* (reserved) */ 114 u_int32_t pmBootCksum; /* boot code checksum */ 115 char pmProcessor[16]; /* processor type (e.g. "68020") */ 116 u_int8_t pmBootArgs[128]; /* A/UX boot arguments */ 117 /* we do not index the disk image as an array, 118 * leave out the on disk padding 119 */ 120#if 0 121 u_int8_t pad[248]; /* pad to end of block */ 122#endif 123}; 124 125#define PART_TYPE_DRIVER "APPLE_DRIVER" 126#define PART_TYPE_DRIVER43 "APPLE_DRIVER43" 127#define PART_TYPE_DRIVERATA "APPLE_DRIVER_ATA" 128#define PART_TYPE_DRIVERIOKIT "APPLE_DRIVER_IOKIT" 129#define PART_TYPE_FWDRIVER "APPLE_FWDRIVER" 130#define PART_TYPE_FWB_COMPONENT "FWB DRIVER COMPONENTS" 131#define PART_TYPE_FREE "APPLE_FREE" 132#define PART_TYPE_MAC "APPLE_HFS" 133#define PART_TYPE_OPENBSD "OPENBSD" 134 135 136struct cpu_disklabel { 137 struct dos_partition dosparts[NDOSPART]; 138 /* only store first entry and openbsd partition */ 139 struct part_map_entry macparts[2]; 140}; 141 142#endif /* _MACHINE_DISKLABEL_H_ */ 143