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