1 /*- 2 * Copyright (c) 2002 Marcel Moolenaar 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 9 * 1. Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * 2. Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * 15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * 26 * $FreeBSD: stable/9/sys/sys/gpt.h 260981 2014-01-21 09:20:45Z marck $ 27 */ 28 29 #ifndef _SYS_GPT_H_ 30 #define _SYS_GPT_H_ 31 32 #include <sys/uuid.h> 33 34 struct gpt_hdr { 35 char hdr_sig[8]; 36 #define GPT_HDR_SIG "EFI PART" 37 uint32_t hdr_revision; 38 #define GPT_HDR_REVISION 0x00010000 39 uint32_t hdr_size; 40 uint32_t hdr_crc_self; 41 uint32_t __reserved; 42 uint64_t hdr_lba_self; 43 uint64_t hdr_lba_alt; 44 uint64_t hdr_lba_start; 45 uint64_t hdr_lba_end; 46 struct uuid hdr_uuid; 47 uint64_t hdr_lba_table; 48 uint32_t hdr_entries; 49 uint32_t hdr_entsz; 50 uint32_t hdr_crc_table; 51 /* 52 * The header as defined in the EFI spec is not a multiple of 8 bytes 53 * and given that the alignment requirement is on an 8 byte boundary, 54 * padding will happen. We make the padding explicit so that we can 55 * correct the value returned by sizeof() when we put the size of the 56 * header in field hdr_size, or otherwise use offsetof(). 57 */ 58 uint32_t padding; 59 }; 60 61 struct gpt_ent { 62 struct uuid ent_type; 63 struct uuid ent_uuid; 64 uint64_t ent_lba_start; 65 uint64_t ent_lba_end; 66 uint64_t ent_attr; 67 #define GPT_ENT_ATTR_PLATFORM (1ULL << 0) 68 #define GPT_ENT_ATTR_BOOTME (1ULL << 59) 69 #define GPT_ENT_ATTR_BOOTONCE (1ULL << 58) 70 #define GPT_ENT_ATTR_BOOTFAILED (1ULL << 57) 71 uint16_t ent_name[36]; /* UTF-16. */ 72 }; 73 74 #define GPT_ENT_TYPE_UNUSED \ 75 {0x00000000,0x0000,0x0000,0x00,0x00,{0x00,0x00,0x00,0x00,0x00,0x00}} 76 #define GPT_ENT_TYPE_EFI \ 77 {0xc12a7328,0xf81f,0x11d2,0xba,0x4b,{0x00,0xa0,0xc9,0x3e,0xc9,0x3b}} 78 #define GPT_ENT_TYPE_MBR \ 79 {0x024dee41,0x33e7,0x11d3,0x9d,0x69,{0x00,0x08,0xc7,0x81,0xf3,0x9f}} 80 #define GPT_ENT_TYPE_FREEBSD \ 81 {0x516e7cb4,0x6ecf,0x11d6,0x8f,0xf8,{0x00,0x02,0x2d,0x09,0x71,0x2b}} 82 #define GPT_ENT_TYPE_FREEBSD_BOOT \ 83 {0x83bd6b9d,0x7f41,0x11dc,0xbe,0x0b,{0x00,0x15,0x60,0xb8,0x4f,0x0f}} 84 #define GPT_ENT_TYPE_FREEBSD_NANDFS \ 85 {0x74ba7dd9,0xa689,0x11e1,0xbd,0x04,{0x00,0xe0,0x81,0x28,0x6a,0xcf}} 86 #define GPT_ENT_TYPE_FREEBSD_SWAP \ 87 {0x516e7cb5,0x6ecf,0x11d6,0x8f,0xf8,{0x00,0x02,0x2d,0x09,0x71,0x2b}} 88 #define GPT_ENT_TYPE_FREEBSD_UFS \ 89 {0x516e7cb6,0x6ecf,0x11d6,0x8f,0xf8,{0x00,0x02,0x2d,0x09,0x71,0x2b}} 90 #define GPT_ENT_TYPE_FREEBSD_VINUM \ 91 {0x516e7cb8,0x6ecf,0x11d6,0x8f,0xf8,{0x00,0x02,0x2d,0x09,0x71,0x2b}} 92 #define GPT_ENT_TYPE_FREEBSD_ZFS \ 93 {0x516e7cba,0x6ecf,0x11d6,0x8f,0xf8,{0x00,0x02,0x2d,0x09,0x71,0x2b}} 94 95 /* 96 * The following are unused but documented here to avoid reuse. 97 * 98 * GPT_ENT_TYPE_FREEBSD_UFS2 \ 99 * {0x516e7cb7,0x6ecf,0x11d6,0x8f,0xf8,{0x00,0x02,0x2d,0x09,0x71,0x2b}} 100 */ 101 102 /* 103 * Foreign partition types that we're likely to encounter. Note that Linux 104 * apparently choose to share data partitions with MS. I don't what the 105 * advantage might be. I can see how sharing swap partitions is advantageous 106 * though. 107 */ 108 #define GPT_ENT_TYPE_MS_RESERVED \ 109 {0xe3c9e316,0x0b5c,0x4db8,0x81,0x7d,{0xf9,0x2d,0xf0,0x02,0x15,0xae}} 110 #define GPT_ENT_TYPE_MS_BASIC_DATA \ 111 {0xebd0a0a2,0xb9e5,0x4433,0x87,0xc0,{0x68,0xb6,0xb7,0x26,0x99,0xc7}} 112 #define GPT_ENT_TYPE_MS_LDM_METADATA \ 113 {0x5808c8aa,0x7e8f,0x42e0,0x85,0xd2,{0xe1,0xe9,0x04,0x34,0xcf,0xb3}} 114 #define GPT_ENT_TYPE_MS_LDM_DATA \ 115 {0xaf9b60a0,0x1431,0x4f62,0xbc,0x68,{0x33,0x11,0x71,0x4a,0x69,0xad}} 116 117 #define GPT_ENT_TYPE_LINUX_DATA GPT_ENT_TYPE_MS_BASIC_DATA 118 #define GPT_ENT_TYPE_LINUX_RAID \ 119 {0xa19d880f,0x05fc,0x4d3b,0xa0,0x06,{0x74,0x3f,0x0f,0x84,0x91,0x1e}} 120 #define GPT_ENT_TYPE_LINUX_SWAP \ 121 {0x0657fd6d,0xa4ab,0x43c4,0x84,0xe5,{0x09,0x33,0xc8,0x4b,0x4f,0x4f}} 122 #define GPT_ENT_TYPE_LINUX_LVM \ 123 {0xe6d6d379,0xf507,0x44c2,0xa2,0x3c,{0x23,0x8f,0x2a,0x3d,0xf9,0x28}} 124 125 #define GPT_ENT_TYPE_VMFS \ 126 {0xaa31e02a,0x400f,0x11db,0x95,0x90,{0x00,0x0c,0x29,0x11,0xd1,0xb8}} 127 #define GPT_ENT_TYPE_VMKDIAG \ 128 {0x9d275380,0x40ad,0x11db,0xbf,0x97,{0x00,0x0c,0x29,0x11,0xd1,0xb8}} 129 #define GPT_ENT_TYPE_VMRESERVED \ 130 {0x9198effc,0x31c0,0x11db,0x8f,0x78,{0x00,0x0c,0x29,0x11,0xd1,0xb8}} 131 #define GPT_ENT_TYPE_VMVSANHDR \ 132 {0x381cfccc,0x7288,0x11e0,0x92,0xee,{0x00,0x0c,0x29,0x11,0xd0,0xb2}} 133 134 #define GPT_ENT_TYPE_APPLE_BOOT \ 135 {0x426F6F74,0x0000,0x11aa,0xaa,0x11,{0x00,0x30,0x65,0x43,0xec,0xac}} 136 #define GPT_ENT_TYPE_APPLE_HFS \ 137 {0x48465300,0x0000,0x11aa,0xaa,0x11,{0x00,0x30,0x65,0x43,0xec,0xac}} 138 #define GPT_ENT_TYPE_APPLE_UFS \ 139 {0x55465300,0x0000,0x11aa,0xaa,0x11,{0x00,0x30,0x65,0x43,0xec,0xac}} 140 #define GPT_ENT_TYPE_APPLE_ZFS \ 141 {0x6a898cc3,0x1dd2,0x11b2,0x99,0xa6,{0x08,0x00,0x20,0x73,0x66,0x31}} 142 #define GPT_ENT_TYPE_APPLE_RAID \ 143 {0x52414944,0x0000,0x11aa,0xaa,0x22,{0x00,0x30,0x65,0x43,0xec,0xac}} 144 #define GPT_ENT_TYPE_APPLE_RAID_OFFLINE \ 145 {0x52414944,0x5f4f,0x11aa,0xaa,0x22,{0x00,0x30,0x65,0x43,0xec,0xac}} 146 #define GPT_ENT_TYPE_APPLE_LABEL \ 147 {0x4C616265,0x6c00,0x11aa,0xaa,0x11,{0x00,0x30,0x65,0x43,0xec,0xac}} 148 #define GPT_ENT_TYPE_APPLE_TV_RECOVERY \ 149 {0x5265636f,0x7665,0x11AA,0xaa,0x11,{0x00,0x30,0x65,0x43,0xec,0xac}} 150 151 #define GPT_ENT_TYPE_NETBSD_FFS \ 152 {0x49f48d5a,0xb10e,0x11dc,0xb9,0x9b,{0x00,0x19,0xd1,0x87,0x96,0x48}} 153 #define GPT_ENT_TYPE_NETBSD_LFS \ 154 {0x49f48d82,0xb10e,0x11dc,0xb9,0x9b,{0x00,0x19,0xd1,0x87,0x96,0x48}} 155 #define GPT_ENT_TYPE_NETBSD_SWAP \ 156 {0x49f48d32,0xb10e,0x11dc,0xB9,0x9B,{0x00,0x19,0xd1,0x87,0x96,0x48}} 157 #define GPT_ENT_TYPE_NETBSD_RAID \ 158 {0x49f48daa,0xb10e,0x11dc,0xb9,0x9b,{0x00,0x19,0xd1,0x87,0x96,0x48}} 159 #define GPT_ENT_TYPE_NETBSD_CCD \ 160 {0x2db519c4,0xb10f,0x11dc,0xb9,0x9b,{0x00,0x19,0xd1,0x87,0x96,0x48}} 161 #define GPT_ENT_TYPE_NETBSD_CGD \ 162 {0x2db519ec,0xb10f,0x11dc,0xb9,0x9b,{0x00,0x19,0xd1,0x87,0x96,0x48}} 163 164 /* 165 * Boot partition used by GRUB 2. 166 */ 167 #define GPT_ENT_TYPE_BIOS_BOOT \ 168 {0x21686148,0x6449,0x6e6f,0x74,0x4e,{0x65,0x65,0x64,0x45,0x46,0x49}} 169 170 #endif /* _SYS_GPT_H_ */ 171