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