1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 * or https://opensource.org/licenses/CDDL-1.0. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21 /* 22 * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. 23 * Copyright 2012 Nexenta Systems, Inc. All rights reserved. 24 */ 25 26 #ifndef _SYS_EFI_PARTITION_H 27 #define _SYS_EFI_PARTITION_H extern __attribute__((visibility("default"))) 28 29 #include <sys/uuid.h> 30 31 #ifdef __cplusplus 32 extern "C" { 33 #endif 34 35 /* 36 * GUID Partition Table Header 37 */ 38 39 #define EFI_MIN_LABEL_SIZE 92 40 #define EFI_LABEL_SIZE 512 41 #define LEN_EFI_PAD (EFI_LABEL_SIZE - \ 42 ((5 * sizeof (diskaddr_t)) + \ 43 (7 * sizeof (uint_t)) + \ 44 (8 * sizeof (char)) + \ 45 (1 * (sizeof (struct uuid))))) 46 47 #define EFI_SIGNATURE 0x5452415020494645ULL 48 49 /* EFI Guid Partition Table Header -- little endian on-disk format */ 50 typedef struct efi_gpt { 51 uint64_t efi_gpt_Signature; 52 uint_t efi_gpt_Revision; 53 uint_t efi_gpt_HeaderSize; 54 uint_t efi_gpt_HeaderCRC32; 55 uint_t efi_gpt_Reserved1; 56 diskaddr_t efi_gpt_MyLBA; 57 diskaddr_t efi_gpt_AlternateLBA; 58 diskaddr_t efi_gpt_FirstUsableLBA; 59 diskaddr_t efi_gpt_LastUsableLBA; 60 struct uuid efi_gpt_DiskGUID; 61 diskaddr_t efi_gpt_PartitionEntryLBA; 62 uint_t efi_gpt_NumberOfPartitionEntries; 63 uint_t efi_gpt_SizeOfPartitionEntry; 64 uint_t efi_gpt_PartitionEntryArrayCRC32; 65 char efi_gpt_Reserved2[LEN_EFI_PAD]; 66 } efi_gpt_t; 67 68 /* EFI Guid Partition Entry Attributes -- little endian format */ 69 typedef struct efi_gpe_Attrs { 70 uint32_t PartitionAttrs :16, 71 Reserved2 :16; 72 uint32_t Reserved1 :31, 73 RequiredPartition :1; 74 } efi_gpe_Attrs_t; 75 76 /* MBR partition identification tags */ 77 #define V_UNASSIGNED 0x00 /* unassigned partition */ 78 #define V_USR 0x04 /* Usr filesystem */ 79 #define V_RESERVED 0x0b /* SMI reserved data */ 80 81 /* 82 * 6a96237f-1dd2-11b2-99a6-080020736631 V_UNASSIGNED (not used as such) 83 * 6a898cc3-1dd2-11b2-99a6-080020736631 V_USR 84 * 6a945a3b-1dd2-11b2-99a6-080020736631 V_RESERVED 85 */ 86 87 #define EFI_UNUSED { 0x00000000, 0x0000, 0x0000, 0x00, 0x00, \ 88 { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } } 89 #define EFI_RESV1 { 0x6a96237f, 0x1dd2, 0x11b2, 0x99, 0xa6, \ 90 { 0x08, 0x00, 0x20, 0x73, 0x66, 0x31 } } 91 #define EFI_BOOT { 0x6a82cb45, 0x1dd2, 0x11b2, 0x99, 0xa6, \ 92 { 0x08, 0x00, 0x20, 0x73, 0x66, 0x31 } } 93 #define EFI_ROOT { 0x6a85cf4d, 0x1dd2, 0x11b2, 0x99, 0xa6, \ 94 { 0x08, 0x00, 0x20, 0x73, 0x66, 0x31 } } 95 #define EFI_SWAP { 0x6a87c46f, 0x1dd2, 0x11b2, 0x99, 0xa6, \ 96 { 0x08, 0x00, 0x20, 0x73, 0x66, 0x31 } } 97 #define EFI_USR { 0x6a898cc3, 0x1dd2, 0x11b2, 0x99, 0xa6, \ 98 { 0x08, 0x00, 0x20, 0x73, 0x66, 0x31 } } 99 #define EFI_BACKUP { 0x6a8b642b, 0x1dd2, 0x11b2, 0x99, 0xa6, \ 100 { 0x08, 0x00, 0x20, 0x73, 0x66, 0x31 } } 101 #define EFI_RESV2 { 0x6a8d2ac7, 0x1dd2, 0x11b2, 0x99, 0xa6, \ 102 { 0x08, 0x00, 0x20, 0x73, 0x66, 0x31 } } 103 #define EFI_VAR { 0x6a8ef2e9, 0x1dd2, 0x11b2, 0x99, 0xa6, \ 104 { 0x08, 0x00, 0x20, 0x73, 0x66, 0x31 } } 105 #define EFI_HOME { 0x6a90ba39, 0x1dd2, 0x11b2, 0x99, 0xa6, \ 106 { 0x08, 0x00, 0x20, 0x73, 0x66, 0x31 } } 107 #define EFI_ALTSCTR { 0x6a9283a5, 0x1dd2, 0x11b2, 0x99, 0xa6, \ 108 { 0x08, 0x00, 0x20, 0x73, 0x66, 0x31 } } 109 #define EFI_RESERVED { 0x6a945a3b, 0x1dd2, 0x11b2, 0x99, 0xa6, \ 110 { 0x08, 0x00, 0x20, 0x73, 0x66, 0x31 } } 111 #define EFI_SYSTEM { 0xC12A7328, 0xF81F, 0x11d2, 0xBA, 0x4B, \ 112 { 0x00, 0xA0, 0xC9, 0x3E, 0xC9, 0x3B } } 113 #define EFI_LEGACY_MBR { 0x024DEE41, 0x33E7, 0x11d3, 0x9D, 0x69, \ 114 { 0x00, 0x08, 0xC7, 0x81, 0xF3, 0x9F } } 115 #define EFI_SYMC_PUB { 0x6a9630d1, 0x1dd2, 0x11b2, 0x99, 0xa6, \ 116 { 0x08, 0x00, 0x20, 0x73, 0x66, 0x31 } } 117 #define EFI_SYMC_CDS { 0x6a980767, 0x1dd2, 0x11b2, 0x99, 0xa6, \ 118 { 0x08, 0x00, 0x20, 0x73, 0x66, 0x31 } } 119 #define EFI_MSFT_RESV { 0xE3C9E316, 0x0B5C, 0x4DB8, 0x81, 0x7D, \ 120 { 0xF9, 0x2D, 0xF0, 0x02, 0x15, 0xAE } } 121 #define EFI_DELL_BASIC { 0xebd0a0a2, 0xb9e5, 0x4433, 0x87, 0xc0, \ 122 { 0x68, 0xb6, 0xb7, 0x26, 0x99, 0xc7 } } 123 #define EFI_DELL_RAID { 0xa19d880f, 0x05fc, 0x4d3b, 0xa0, 0x06, \ 124 { 0x74, 0x3f, 0x0f, 0x84, 0x91, 0x1e } } 125 #define EFI_DELL_SWAP { 0x0657fd6d, 0xa4ab, 0x43c4, 0x84, 0xe5, \ 126 { 0x09, 0x33, 0xc8, 0x4b, 0x4f, 0x4f } } 127 #define EFI_DELL_LVM { 0xe6d6d379, 0xf507, 0x44c2, 0xa2, 0x3c, \ 128 { 0x23, 0x8f, 0x2a, 0x3d, 0xf9, 0x28 } } 129 #define EFI_DELL_RESV { 0x8da63339, 0x0007, 0x60c0, 0xc4, 0x36, \ 130 { 0x08, 0x3a, 0xc8, 0x23, 0x09, 0x08 } } 131 #define EFI_AAPL_HFS { 0x48465300, 0x0000, 0x11aa, 0xaa, 0x11, \ 132 { 0x00, 0x30, 0x65, 0x43, 0xec, 0xac } } 133 #define EFI_AAPL_UFS { 0x55465300, 0x0000, 0x11aa, 0xaa, 0x11, \ 134 { 0x00, 0x30, 0x65, 0x43, 0xec, 0xac } } 135 #define EFI_FREEBSD_BOOT { 0x83bd6b9d, 0x7f41, 0x11dc, 0xbe, 0x0b, \ 136 { 0x00, 0x15, 0x60, 0xb8, 0x4f, 0x0f } } 137 #define EFI_FREEBSD_SWAP { 0x516e7cb5, 0x6ecf, 0x11d6, 0x8f, 0xf8, \ 138 { 0x00, 0x02, 0x2d, 0x09, 0x71, 0x2b } } 139 #define EFI_FREEBSD_UFS { 0x516e7cb6, 0x6ecf, 0x11d6, 0x8f, 0xf8, \ 140 { 0x00, 0x02, 0x2d, 0x09, 0x71, 0x2b } } 141 #define EFI_FREEBSD_VINUM { 0x516e7cb8, 0x6ecf, 0x11d6, 0x8f, 0xf8, \ 142 { 0x00, 0x02, 0x2d, 0x09, 0x71, 0x2b } } 143 #define EFI_FREEBSD_ZFS { 0x516e7cba, 0x6ecf, 0x11d6, 0x8f, 0xf8, \ 144 { 0x00, 0x02, 0x2d, 0x09, 0x71, 0x2b } } 145 146 /* From Wikipedia */ 147 148 #define EFI_BIOS_BOOT { 0x21686148, 0x6449, 0x6e6f, 0x74, 0x4e, \ 149 { 0x65, 0x65, 0x64, 0x45, 0x46, 0x49 } } 150 #define EFI_INTC_RS { 0xd3bfe2de, 0x3daf, 0x11df, 0xba, 0x40, \ 151 { 0xe3, 0xa5, 0x56, 0xd8, 0x95, 0x93 } } 152 #define EFI_SNE_BOOT { 0xf4019732, 0x066e, 0x4e12, 0x82, 0x73, \ 153 { 0x34, 0x6c, 0x56, 0x41, 0x49, 0x4f } } 154 #define EFI_LENOVO_BOOT { 0xbfbfafe7, 0xa34f, 0x448a, 0x9a, 0x5b, \ 155 { 0x62, 0x13, 0xeb, 0x73, 0x6c, 0x22 } } 156 #define EFI_MSFT_LDMM { 0x5808c8aa, 0x7e8f, 0x42e0, 0x85, 0xd2, \ 157 { 0xe1, 0xe9, 0x04, 0x34, 0xcf, 0xb3 } } 158 #define EFI_MSFT_LDMD { 0xaf9b60a0, 0x1431, 0x4f62, 0xbc, 0x68, \ 159 { 0x33, 0x11, 0x71, 0x4a, 0x69, 0xad } } 160 #define EFI_MSFT_RE { 0xde94bba4, 0x06d1, 0x4d40, 0xa1, 0x6a, \ 161 { 0xbf, 0xd5, 0x01, 0x79, 0xd6, 0xac } } 162 #define EFI_IBM_GPFS { 0x37affc90, 0xef7d, 0x4e96, 0x91, 0xc3, \ 163 { 0x2d, 0x7a, 0xe0, 0x55, 0xb1, 0x74 } } 164 #define EFI_MSFT_STORAGESPACES { 0xe75caf8f, 0xf680, 0x4cee, 0xaf, 0xa3, \ 165 { 0xb0, 0x01, 0xe5, 0x6e, 0xfc, 0x2d } } 166 #define EFI_HPQ_DATA { 0x75894c1e, 0x3aeb, 0x11d3, 0xb7, 0xc1, \ 167 { 0x7b, 0x03, 0xa0, 0x00, 0x00, 0x00 } } 168 #define EFI_HPQ_SVC { 0xe2a1e728, 0x32e3, 0x11d6, 0xa6, 0x82, \ 169 { 0x7b, 0x03, 0xa0, 0x00, 0x00, 0x00 } } 170 #define EFI_RHT_DATA { 0x0fc63daf, 0x8483, 0x4772, 0x8e, 0x79, \ 171 { 0x3d, 0x69, 0xd8, 0x47, 0x7d, 0xe4 } } 172 #define EFI_RHT_HOME { 0x933ac7e1, 0x2eb4, 0x4f13, 0xb8, 0x44, \ 173 { 0x0e, 0x14, 0xe2, 0xae, 0xf9, 0x15 } } 174 #define EFI_RHT_SRV { 0x3b8f8425, 0x20e0, 0x4f3b, 0x90, 0x7f, \ 175 { 0x1a, 0x25, 0xa7, 0x6f, 0x98, 0xe8 } } 176 #define EFI_RHT_DMCRYPT { 0x7ffec5c9, 0x2d00, 0x49b7, 0x89, 0x41, \ 177 { 0x3e, 0xa1, 0x0a, 0x55, 0x86, 0xb7 } } 178 #define EFI_RHT_LUKS { 0xca7d7ccb, 0x63ed, 0x4c53, 0x86, 0x1c, \ 179 { 0x17, 0x42, 0x53, 0x60, 0x59, 0xcc } } 180 #define EFI_FREEBSD_DISKLABEL { 0x516e7cb4, 0x6ecf, 0x11d6, 0x8f, 0xf8, \ 181 { 0x00, 0x02, 0x2d, 0x09, 0x71, 0x2b } } 182 #define EFI_AAPL_RAID { 0x52414944, 0x0000, 0x11aa, 0xaa, 0x11, \ 183 { 0x00, 0x30, 0x65, 0x43, 0xec, 0xac } } 184 #define EFI_AAPL_RAIDOFFLINE { 0x52414944, 0x5f4f, 0x11aa, 0xaa, 0x11, \ 185 { 0x00, 0x30, 0x65, 0x43, 0xec, 0xac } } 186 #define EFI_AAPL_BOOT { 0x426f6f74, 0x0000, 0x11aa, 0xaa, 0x11, \ 187 { 0x00, 0x30, 0x65, 0x43, 0xec, 0xac } } 188 #define EFI_AAPL_LABEL { 0x4c616265, 0x6c00, 0x11aa, 0xaa, 0x11, \ 189 { 0x00, 0x30, 0x65, 0x43, 0xec, 0xac } } 190 #define EFI_AAPL_TVRECOVERY { 0x5265636f, 0x7665, 0x11aa, 0xaa, 0x11, \ 191 { 0x00, 0x30, 0x65, 0x43, 0xec, 0xac } } 192 #define EFI_AAPL_CORESTORAGE { 0x53746f72, 0x6167, 0x11aa, 0xaa, 0x11, \ 193 { 0x00, 0x30, 0x65, 0x43, 0xec, 0xac } } 194 #define EFI_NETBSD_SWAP { 0x49f48d32, 0xb10e, 0x11dc, 0xb9, 0x9b, \ 195 { 0x00, 0x19, 0xd1, 0x87, 0x96, 0x48 } } 196 #define EFI_NETBSD_FFS { 0x49f48d5a, 0xb10e, 0x11dc, 0xb9, 0x9b, \ 197 { 0x00, 0x19, 0xd1, 0x87, 0x96, 0x48 } } 198 #define EFI_NETBSD_LFS { 0x49f48d82, 0xb10e, 0x11dc, 0xb9, 0x9b, \ 199 { 0x00, 0x19, 0xd1, 0x87, 0x96, 0x48 } } 200 #define EFI_NETBSD_RAID { 0x49f48daa, 0xb10e, 0x11dc, 0xb9, 0x9b, \ 201 { 0x00, 0x19, 0xd1, 0x87, 0x96, 0x48 } } 202 #define EFI_NETBSD_CAT { 0x2db519c4, 0xb10f, 0x11dc, 0xb9, 0x9b, \ 203 { 0x00, 0x19, 0xd1, 0x87, 0x96, 0x48 } } 204 #define EFI_NETBSD_CRYPT { 0x2db519ec, 0xb10f, 0x11dc, 0xb9, 0x9b, \ 205 { 0x00, 0x19, 0xd1, 0x87, 0x96, 0x48 } } 206 #define EFI_GOOG_KERN { 0xfe3a2a5d, 0x4f32, 0x41a7, 0xb7, 0x25, \ 207 { 0xac, 0xcc, 0x32, 0x85, 0xa3, 0x09 } } 208 #define EFI_GOOG_ROOT { 0x3cb8e202, 0x3b7e, 0x47dd, 0x8a, 0x3c, \ 209 { 0x7f, 0xf2, 0xa1, 0x3c, 0xfc, 0xec } } 210 #define EFI_GOOG_RESV { 0x2e0a753d, 0x9e48, 0x43b0, 0x83, 0x37, \ 211 { 0xb1, 0x51, 0x92, 0xcb, 0x1b, 0x5e } } 212 #define EFI_HAIKU_BFS { 0x42465331, 0x3ba3, 0x10f1, 0x80, 0x2a, \ 213 { 0x48, 0x61, 0x69, 0x6b, 0x75, 0x21 } } 214 #define EFI_MIDNIGHTBSD_BOOT { 0x85d5e45e, 0x237c, 0x11e1, 0xb4, 0xb3, \ 215 { 0xe8, 0x9a, 0x8f, 0x7f, 0xc3, 0xa7 } } 216 #define EFI_MIDNIGHTBSD_DATA { 0x85d5e45a, 0x237c, 0x11e1, 0xb4, 0xb3, \ 217 { 0xe8, 0x9a, 0x8f, 0x7f, 0xc3, 0xa7 } } 218 #define EFI_MIDNIGHTBSD_SWAP { 0x85d5e45b, 0x237c, 0x11e1, 0xb4, 0xb3, \ 219 { 0xe8, 0x9a, 0x8f, 0x7f, 0xc3, 0xa7 } } 220 #define EFI_MIDNIGHTBSD_UFS { 0x0394ef8b, 0x237e, 0x11e1, 0xb4, 0xb3, \ 221 { 0xe8, 0x9a, 0x8f, 0x7f, 0xc3, 0xa7 } } 222 #define EFI_MIDNIGHTBSD_VINUM { 0x85d5e45c, 0x237c, 0x11e1, 0xb4, 0xb3, \ 223 { 0xe8, 0x9a, 0x8f, 0x7f, 0xc3, 0xa7 } } 224 #define EFI_MIDNIGHTBSD_ZFS { 0x85d5e45d, 0x237c, 0x11e1, 0xb4, 0xb3, \ 225 { 0xe8, 0x9a, 0x8f, 0x7f, 0xc3, 0xa7 } } 226 #define EFI_CEPH_JOURNAL { 0x45b0969e, 0x9b03, 0x4f30, 0xb4, 0xc6, \ 227 { 0xb4, 0xb8, 0x0c, 0xef, 0xf1, 0x06 } } 228 #define EFI_CEPH_DMCRYPTJOURNAL { 0x45b0969e, 0x9b03, 0x4f30, 0xb4, 0xc6, \ 229 { 0x5e, 0xc0, 0x0c, 0xef, 0xf1, 0x06 } } 230 #define EFI_CEPH_OSD { 0x4fbd7e29, 0x9d25, 0x41b8, 0xaf, 0xd0, \ 231 { 0x06, 0x2c, 0x0c, 0xef, 0xf0, 0x5d } } 232 #define EFI_CEPH_DMCRYPTOSD { 0x4fbd7e29, 0x9d25, 0x41b8, 0xaf, 0xd0, \ 233 { 0x5e, 0xc0, 0x0c, 0xef, 0xf0, 0x5d } } 234 #define EFI_CEPH_CREATE { 0x89c57f98, 0x2fe5, 0x4dc0, 0x89, 0xc1, \ 235 { 0xf3, 0xad, 0x0c, 0xef, 0xf2, 0xbe } } 236 #define EFI_CEPH_DMCRYPTCREATE { 0x89c57f98, 0x2fe5, 0x4dc0, 0x89, 0xc1, \ 237 { 0x5e, 0xc0, 0x0c, 0xef, 0xf2, 0xbe } } 238 #define EFI_OPENBSD_DISKLABEL { 0x824cc7a0, 0x36a8, 0x11e3, 0x89, 0x0a, \ 239 { 0x95, 0x25, 0x19, 0xad, 0x3f, 0x61 } } 240 #define EFI_BBRY_QNX { 0xcef5a9ad, 0x73bc, 0x4601, 0x89, 0xf3, \ 241 { 0xcd, 0xee, 0xee, 0xe3, 0x21, 0xa1 } } 242 #define EFI_BELL_PLAN9 { 0xc91818f9, 0x8025, 0x47af, 0x89, 0xd2, \ 243 { 0xf0, 0x30, 0xd7, 0x00, 0x0c, 0x2c } } 244 #define EFI_VMW_KCORE { 0x9d275380, 0x40ad, 0x11db, 0xbf, 0x97, \ 245 { 0x00, 0x0c, 0x29, 0x11, 0xd1, 0xb8 } } 246 #define EFI_VMW_VMFS { 0xaa31e02a, 0x400f, 0x11db, 0x95, 0x90, \ 247 { 0x00, 0x0c, 0x29, 0x11, 0xd1, 0xb8 } } 248 #define EFI_VMW_RESV { 0x9198effc, 0x31c0, 0x11db, 0x8f, 0x78, \ 249 { 0x00, 0x0c, 0x29, 0x11, 0xd1, 0xb8 } } 250 251 /* From GPT fdisk */ 252 253 #define EFI_RHT_ROOTX86 { 0x44479540, 0xf297, 0x41b2, 0x9a, 0xf7, \ 254 { 0xd1, 0x31, 0xd5, 0xf0, 0x45, 0x8a } } 255 #define EFI_RHT_ROOTAMD64 { 0x4f68bce3, 0xe8cd, 0x4db1, 0x96, 0xe7, \ 256 { 0xfb, 0xca, 0xf9, 0x84, 0xb7, 0x09 } } 257 #define EFI_RHT_ROOTARM { 0x69dad710, 0x2ce4, 0x4e3c, 0xb1, 0x6c, \ 258 { 0x21, 0xa1, 0xd4, 0x9a, 0xbe, 0xd3 } } 259 #define EFI_RHT_ROOTARM64 { 0xb921b045, 0x1df0, 0x41c3, 0xaf, 0x44, \ 260 { 0x4c, 0x6f, 0x28, 0x0d, 0x3f, 0xae } } 261 #define EFI_ACRONIS_SECUREZONE { 0x0311fc50, 0x01ca, 0x4725, 0xad, 0x77, \ 262 { 0x9a, 0xdb, 0xb2, 0x0a, 0xce, 0x98 } } 263 #define EFI_ONIE_BOOT { 0x7412f7d5, 0xa156, 0x4b13, 0x81, 0xdc, \ 264 { 0x86, 0x71, 0x74, 0x92, 0x93, 0x25 } } 265 #define EFI_ONIE_CONFIG { 0xd4e6e2cd, 0x4469, 0x46f3, 0xb5, 0xcb, \ 266 { 0x1b, 0xff, 0x57, 0xaf, 0xc1, 0x49 } } 267 #define EFI_IBM_PPRPBOOT { 0x9e1a2d38, 0xc612, 0x4316, 0xaa, 0x26, \ 268 { 0x8b, 0x49, 0x52, 0x1e, 0x5a, 0x8b } } 269 #define EFI_FREEDESKTOP_BOOT { 0xbc13c2ff, 0x59e6, 0x4262, 0xa3, 0x52, \ 270 { 0xb2, 0x75, 0xfd, 0x6f, 0x71, 0x72 } } 271 272 /* minimum # of bytes for partition table entries, per EFI spec */ 273 #define EFI_MIN_ARRAY_SIZE (16 * 1024) 274 275 #define EFI_PART_NAME_LEN 36 276 277 /* size of the "reserved" partition, in blocks */ 278 #define EFI_MIN_RESV_SIZE (16 * 1024) 279 280 /* EFI Guid Partition Entry */ 281 typedef struct efi_gpe { 282 struct uuid efi_gpe_PartitionTypeGUID; 283 struct uuid efi_gpe_UniquePartitionGUID; 284 diskaddr_t efi_gpe_StartingLBA; 285 diskaddr_t efi_gpe_EndingLBA; 286 efi_gpe_Attrs_t efi_gpe_Attributes; 287 ushort_t efi_gpe_PartitionName[EFI_PART_NAME_LEN]; 288 } efi_gpe_t; 289 290 /* 291 * passed to the useful (we hope) routines (efi_alloc_and_read and 292 * efi_write) that take this VTOC-like struct. These routines handle 293 * converting this struct into the EFI struct, generate UUIDs and 294 * checksums, and perform any necessary byte-swapping to the on-disk 295 * format. 296 */ 297 /* Solaris library abstraction for EFI partitions */ 298 typedef struct dk_part { 299 diskaddr_t p_start; /* starting LBA */ 300 diskaddr_t p_size; /* size in blocks */ 301 struct uuid p_guid; /* partition type GUID */ 302 ushort_t p_tag; /* converted to part'n type GUID */ 303 ushort_t p_flag; /* attributes */ 304 char p_name[EFI_PART_NAME_LEN]; /* partition name */ 305 struct uuid p_uguid; /* unique partition GUID */ 306 uint_t p_resv[8]; /* future use - set to zero */ 307 } dk_part_t; 308 309 /* Solaris library abstraction for an EFI GPT */ 310 #define EFI_VERSION102 0x00010002 311 #define EFI_VERSION100 0x00010000 312 #define EFI_VERSION_CURRENT EFI_VERSION100 313 typedef struct dk_gpt { 314 uint_t efi_version; /* set to EFI_VERSION_CURRENT */ 315 uint_t efi_nparts; /* number of partitions below */ 316 uint_t efi_part_size; /* size of each partition entry */ 317 /* efi_part_size is unused */ 318 uint_t efi_lbasize; /* size of block in bytes */ 319 diskaddr_t efi_last_lba; /* last block on the disk */ 320 diskaddr_t efi_first_u_lba; /* first block after labels */ 321 diskaddr_t efi_last_u_lba; /* last block before backup labels */ 322 struct uuid efi_disk_uguid; /* unique disk GUID */ 323 uint_t efi_flags; 324 uint_t efi_reserved1; /* future use - set to zero */ 325 diskaddr_t efi_altern_lba; /* lba of alternate GPT header */ 326 uint_t efi_reserved[12]; /* future use - set to zero */ 327 struct dk_part efi_parts[1]; /* array of partitions */ 328 } dk_gpt_t; 329 330 /* possible values for "efi_flags" */ 331 #define EFI_GPT_PRIMARY_CORRUPT 0x1 /* primary label corrupt */ 332 333 /* the private ioctl between libefi and the driver */ 334 typedef struct dk_efi { 335 diskaddr_t dki_lba; /* starting block */ 336 len_t dki_length; /* length in bytes */ 337 union { 338 efi_gpt_t *_dki_data; 339 uint64_t _dki_data_64; 340 } dki_un; 341 #define dki_data dki_un._dki_data 342 #define dki_data_64 dki_un._dki_data_64 343 } dk_efi_t; 344 345 struct partition64 { 346 struct uuid p_type; 347 uint_t p_partno; 348 uint_t p_resv1; 349 diskaddr_t p_start; 350 diskaddr_t p_size; 351 }; 352 353 /* 354 * Number of EFI partitions 355 */ 356 #if defined(__linux__) 357 #define EFI_NUMPAR 128 /* Expected by parted-1.8.1 */ 358 #else 359 #define EFI_NUMPAR 9 360 #endif 361 362 #ifndef _KERNEL 363 #define VT_ERROR (-2) /* errno supplies specific error */ 364 #define VT_EIO (-3) /* I/O error accessing vtoc */ 365 #define VT_EINVAL (-4) /* illegal value in vtoc or request */ 366 #define VT_ENOSPC (-6) /* requested space not found */ 367 368 _SYS_EFI_PARTITION_H int efi_debug; 369 _SYS_EFI_PARTITION_H int efi_alloc_and_init(int, uint32_t, struct dk_gpt **); 370 _SYS_EFI_PARTITION_H int efi_alloc_and_read(int, struct dk_gpt **); 371 _SYS_EFI_PARTITION_H int efi_write(int, struct dk_gpt *); 372 _SYS_EFI_PARTITION_H int efi_rescan(int); 373 _SYS_EFI_PARTITION_H void efi_free(struct dk_gpt *); 374 _SYS_EFI_PARTITION_H void efi_err_check(struct dk_gpt *); 375 _SYS_EFI_PARTITION_H int efi_use_whole_disk(int fd); 376 #endif 377 378 #ifdef __cplusplus 379 } 380 #endif 381 382 #endif /* _SYS_EFI_PARTITION_H */ 383