Print this page
10570 Need workaround to EFI boot on AMI BIOS
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/uts/common/sys/efi_partition.h
+++ new/usr/src/uts/common/sys/efi_partition.h
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
↓ open down ↓ |
14 lines elided |
↑ open up ↑ |
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21 /*
22 22 * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
23 23 * Copyright 2012 Nexenta Systems, Inc. All rights reserved.
24 24 * Copyright 2014 Toomas Soome <tsoome@me.com>
25 + * Copyright (c) 2019, Joyent, Inc.
25 26 */
26 27
27 28 #ifndef _SYS_EFI_PARTITION_H
28 29 #define _SYS_EFI_PARTITION_H
29 30
30 31 #include <sys/uuid.h>
32 +#include <sys/stddef.h>
31 33
32 34 #ifdef __cplusplus
33 35 extern "C" {
34 36 #endif
35 37
36 38 /*
37 39 * GUID Partition Table Header
38 40 */
39 41
40 42 #define EFI_LABEL_SIZE 512
41 43 #define LEN_EFI_PAD (EFI_LABEL_SIZE - \
42 44 ((5 * sizeof (diskaddr_t)) + \
43 45 (7 * sizeof (uint_t)) + \
44 46 (8 * sizeof (char)) + \
45 47 (1 * (sizeof (struct uuid)))))
46 48
47 49 #define EFI_SIGNATURE 0x5452415020494645ULL
48 50
51 +/*
52 + * Although the EFI spec is clear that sizeof (efi_gpt_t) is a valid value
53 + * (512), at least one EFI system (AMI v4.6.4.1) incorrectly expects this to be
54 + * exactly the size of the structure defined in the spec, that is, 92.
55 + *
56 + * As the reserved section is never used, the modified value works fine
57 + * everywhere else.
58 + */
59 +#define EFI_HEADER_SIZE (offsetof(efi_gpt_t, efi_gpt_Reserved2))
60 +
49 61 /* EFI Guid Partition Table Header -- little endian on-disk format */
50 62 typedef struct efi_gpt {
51 63 uint64_t efi_gpt_Signature;
52 64 uint_t efi_gpt_Revision;
53 65 uint_t efi_gpt_HeaderSize;
54 66 uint_t efi_gpt_HeaderCRC32;
55 67 uint_t efi_gpt_Reserved1;
56 68 diskaddr_t efi_gpt_MyLBA;
57 69 diskaddr_t efi_gpt_AlternateLBA;
58 70 diskaddr_t efi_gpt_FirstUsableLBA;
59 71 diskaddr_t efi_gpt_LastUsableLBA;
60 72 struct uuid efi_gpt_DiskGUID;
61 73 diskaddr_t efi_gpt_PartitionEntryLBA;
62 74 uint_t efi_gpt_NumberOfPartitionEntries;
63 75 uint_t efi_gpt_SizeOfPartitionEntry;
64 76 uint_t efi_gpt_PartitionEntryArrayCRC32;
65 77 char efi_gpt_Reserved2[LEN_EFI_PAD];
66 78 } efi_gpt_t;
67 79
68 80 /* EFI Guid Partition Entry Attributes -- little endian format */
69 81 typedef struct efi_gpe_Attrs {
70 82 uint32_t PartitionAttrs :16,
71 83 Reserved2 :16;
72 84 uint32_t Reserved1 :31,
73 85 RequiredPartition :1;
74 86 } efi_gpe_Attrs_t;
75 87
76 88 /*
77 89 * 6a96237f-1dd2-11b2-99a6-080020736631 V_UNASSIGNED (not used as such)
78 90 * 6a82cb45-1dd2-11b2-99a6-080020736631 V_BOOT
79 91 * 6a85cf4d-1dd2-11b2-99a6-080020736631 V_ROOT
80 92 * 6a87c46f-1dd2-11b2-99a6-080020736631 V_SWAP
81 93 * 6a898cc3-1dd2-11b2-99a6-080020736631 V_USR
82 94 * 6a8b642b-1dd2-11b2-99a6-080020736631 V_BACKUP
83 95 * 6a8d2ac7-1dd2-11b2-99a6-080020736631 V_STAND (not used)
84 96 * 6a8ef2e9-1dd2-11b2-99a6-080020736631 V_VAR
85 97 * 6a90ba39-1dd2-11b2-99a6-080020736631 V_HOME
86 98 * 6a9283a5-1dd2-11b2-99a6-080020736631 V_ALTSCTR
87 99 * 6a945a3b-1dd2-11b2-99a6-080020736631 V_CACHE
88 100 */
89 101
90 102 #define EFI_UNUSED { 0x00000000, 0x0000, 0x0000, 0x00, 0x00, \
91 103 { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } }
92 104 #define EFI_RESV1 { 0x6a96237f, 0x1dd2, 0x11b2, 0x99, 0xa6, \
93 105 { 0x08, 0x00, 0x20, 0x73, 0x66, 0x31 } }
94 106 #define EFI_BOOT { 0x6a82cb45, 0x1dd2, 0x11b2, 0x99, 0xa6, \
95 107 { 0x08, 0x00, 0x20, 0x73, 0x66, 0x31 } }
96 108 #define EFI_ROOT { 0x6a85cf4d, 0x1dd2, 0x11b2, 0x99, 0xa6, \
97 109 { 0x08, 0x00, 0x20, 0x73, 0x66, 0x31 } }
98 110 #define EFI_SWAP { 0x6a87c46f, 0x1dd2, 0x11b2, 0x99, 0xa6, \
99 111 { 0x08, 0x00, 0x20, 0x73, 0x66, 0x31 } }
100 112 #define EFI_USR { 0x6a898cc3, 0x1dd2, 0x11b2, 0x99, 0xa6, \
101 113 { 0x08, 0x00, 0x20, 0x73, 0x66, 0x31 } }
102 114 #define EFI_BACKUP { 0x6a8b642b, 0x1dd2, 0x11b2, 0x99, 0xa6, \
103 115 { 0x08, 0x00, 0x20, 0x73, 0x66, 0x31 } }
104 116 #define EFI_RESV2 { 0x6a8d2ac7, 0x1dd2, 0x11b2, 0x99, 0xa6, \
105 117 { 0x08, 0x00, 0x20, 0x73, 0x66, 0x31 } }
106 118 #define EFI_VAR { 0x6a8ef2e9, 0x1dd2, 0x11b2, 0x99, 0xa6, \
107 119 { 0x08, 0x00, 0x20, 0x73, 0x66, 0x31 } }
108 120 #define EFI_HOME { 0x6a90ba39, 0x1dd2, 0x11b2, 0x99, 0xa6, \
109 121 { 0x08, 0x00, 0x20, 0x73, 0x66, 0x31 } }
110 122 #define EFI_ALTSCTR { 0x6a9283a5, 0x1dd2, 0x11b2, 0x99, 0xa6, \
111 123 { 0x08, 0x00, 0x20, 0x73, 0x66, 0x31 } }
112 124 #define EFI_RESERVED { 0x6a945a3b, 0x1dd2, 0x11b2, 0x99, 0xa6, \
113 125 { 0x08, 0x00, 0x20, 0x73, 0x66, 0x31 } }
114 126 #define EFI_SYSTEM { 0xC12A7328, 0xF81F, 0x11d2, 0xBA, 0x4B, \
115 127 { 0x00, 0xA0, 0xC9, 0x3E, 0xC9, 0x3B } }
116 128 #define EFI_LEGACY_MBR { 0x024DEE41, 0x33E7, 0x11d3, 0x9D, 0x69, \
117 129 { 0x00, 0x08, 0xC7, 0x81, 0xF3, 0x9F } }
118 130 #define EFI_SYMC_PUB { 0x6a9630d1, 0x1dd2, 0x11b2, 0x99, 0xa6, \
119 131 { 0x08, 0x00, 0x20, 0x73, 0x66, 0x31 } }
120 132 #define EFI_SYMC_CDS { 0x6a980767, 0x1dd2, 0x11b2, 0x99, 0xa6, \
121 133 { 0x08, 0x00, 0x20, 0x73, 0x66, 0x31 } }
122 134 #define EFI_MSFT_RESV { 0xE3C9E316, 0x0B5C, 0x4DB8, 0x81, 0x7D, \
123 135 { 0xF9, 0x2D, 0xF0, 0x02, 0x15, 0xAE } }
124 136 #define EFI_DELL_BASIC { 0xebd0a0a2, 0xb9e5, 0x4433, 0x87, 0xc0, \
125 137 { 0x68, 0xb6, 0xb7, 0x26, 0x99, 0xc7 } }
126 138 #define EFI_DELL_RAID { 0xa19d880f, 0x05fc, 0x4d3b, 0xa0, 0x06, \
127 139 { 0x74, 0x3f, 0x0f, 0x84, 0x91, 0x1e } }
128 140 #define EFI_DELL_SWAP { 0x0657fd6d, 0xa4ab, 0x43c4, 0x84, 0xe5, \
129 141 { 0x09, 0x33, 0xc8, 0x4b, 0x4f, 0x4f } }
130 142 #define EFI_DELL_LVM { 0xe6d6d379, 0xf507, 0x44c2, 0xa2, 0x3c, \
131 143 { 0x23, 0x8f, 0x2a, 0x3d, 0xf9, 0x28 } }
132 144 #define EFI_DELL_RESV { 0x8da63339, 0x0007, 0x60c0, 0xc4, 0x36, \
133 145 { 0x08, 0x3a, 0xc8, 0x23, 0x09, 0x08 } }
134 146 #define EFI_AAPL_BOOT { 0x426F6F74, 0x0000, 0x11aa, 0xaa, 0x11, \
135 147 { 0x00, 0x30, 0x65, 0x43, 0xec, 0xac } }
136 148 #define EFI_AAPL_HFS { 0x48465300, 0x0000, 0x11aa, 0xaa, 0x11, \
137 149 { 0x00, 0x30, 0x65, 0x43, 0xec, 0xac } }
138 150 #define EFI_AAPL_UFS { 0x55465300, 0x0000, 0x11aa, 0xaa, 0x11, \
139 151 { 0x00, 0x30, 0x65, 0x43, 0xec, 0xac } }
140 152 #define EFI_AAPL_ZFS { 0x6a898cc3, 0x1dd2, 0x11b2, 0x99, 0xa6, \
141 153 { 0x08, 0x00, 0x20, 0x73, 0x66, 0x31 } }
142 154 #define EFI_AAPL_APFS { 0x7c3457ef, 0x0000, 0x11aa, 0xaa, 0x11, \
143 155 { 0x00, 0x30, 0x65, 0x43, 0xec, 0xac } }
144 156 #define EFI_FREEBSD_BOOT { 0x83bd6b9d, 0x7f41, 0x11dc, 0xbe, 0x0b, \
145 157 { 0x00, 0x15, 0x60, 0xb8, 0x4f, 0x0f } }
146 158 #define EFI_FREEBSD_NANDFS { 0x74ba7dd9, 0xa689, 0x11e1, 0xbd, 0x04, \
147 159 { 0x00, 0xe0, 0x81, 0x28, 0x6a, 0xcf } }
148 160 #define EFI_FREEBSD_SWAP { 0x516e7cb5, 0x6ecf, 0x11d6, 0x8f, 0xf8, \
149 161 { 0x00, 0x02, 0x2d, 0x09, 0x71, 0x2b } }
150 162 #define EFI_FREEBSD_UFS { 0x516e7cb6, 0x6ecf, 0x11d6, 0x8f, 0xf8, \
151 163 { 0x00, 0x02, 0x2d, 0x09, 0x71, 0x2b } }
152 164 #define EFI_FREEBSD_VINUM { 0x516e7cb8, 0x6ecf, 0x11d6, 0x8f, 0xf8, \
153 165 { 0x00, 0x02, 0x2d, 0x09, 0x71, 0x2b } }
154 166 #define EFI_FREEBSD_ZFS { 0x516e7cba, 0x6ecf, 0x11d6, 0x8f, 0xf8, \
155 167 { 0x00, 0x02, 0x2d, 0x09, 0x71, 0x2b } }
156 168 #define EFI_BIOS_BOOT { 0x21686148, 0x6449, 0x6e6f, 0x74, 0x4e, \
157 169 { 0x65, 0x65, 0x64, 0x45, 0x46, 0x49 } }
158 170
159 171 /* minimum # of bytes for partition table entires, per EFI spec */
160 172 #define EFI_MIN_ARRAY_SIZE (16 * 1024)
161 173
162 174 #define EFI_PART_NAME_LEN 36
163 175
164 176 /* size of the "reserved" partition, in blocks */
165 177 #define EFI_MIN_RESV_SIZE (16 * 1024)
166 178
167 179 /* EFI Guid Partition Entry */
168 180 typedef struct efi_gpe {
169 181 struct uuid efi_gpe_PartitionTypeGUID;
170 182 struct uuid efi_gpe_UniquePartitionGUID;
171 183 diskaddr_t efi_gpe_StartingLBA;
172 184 diskaddr_t efi_gpe_EndingLBA;
173 185 efi_gpe_Attrs_t efi_gpe_Attributes;
174 186 ushort_t efi_gpe_PartitionName[EFI_PART_NAME_LEN];
175 187 } efi_gpe_t;
176 188
177 189 /*
178 190 * passed to the useful (we hope) routines (efi_alloc_and_read and
179 191 * efi_write) that take this VTOC-like struct. These routines handle
180 192 * converting this struct into the EFI struct, generate UUIDs and
181 193 * checksums, and perform any necessary byte-swapping to the on-disk
182 194 * format.
183 195 */
184 196 /* Solaris library abstraction for EFI partitons */
185 197 typedef struct dk_part {
186 198 diskaddr_t p_start; /* starting LBA */
187 199 diskaddr_t p_size; /* size in blocks */
188 200 struct uuid p_guid; /* partion type GUID */
189 201 ushort_t p_tag; /* converted to part'n type GUID */
190 202 ushort_t p_flag; /* attributes */
191 203 char p_name[EFI_PART_NAME_LEN]; /* partition name */
192 204 struct uuid p_uguid; /* unique partition GUID */
193 205 uint_t p_resv[8]; /* future use - set to zero */
194 206 } dk_part_t;
195 207
196 208 /* Solaris library abstraction for an EFI GPT */
197 209 #define EFI_VERSION102 0x00010002
198 210 #define EFI_VERSION100 0x00010000
199 211 #define EFI_VERSION_CURRENT EFI_VERSION100
200 212 typedef struct dk_gpt {
201 213 uint_t efi_version; /* set to EFI_VERSION_CURRENT */
202 214 uint_t efi_nparts; /* number of partitions below */
203 215 uint_t efi_part_size; /* size of each partition entry */
204 216 /* efi_part_size is unused */
205 217 uint_t efi_lbasize; /* size of block in bytes */
206 218 diskaddr_t efi_last_lba; /* last block on the disk */
207 219 diskaddr_t efi_first_u_lba; /* first block after labels */
208 220 diskaddr_t efi_last_u_lba; /* last block before backup labels */
209 221 struct uuid efi_disk_uguid; /* unique disk GUID */
210 222 uint_t efi_flags;
211 223 uint_t efi_reserved1; /* future use - set to zero */
212 224 diskaddr_t efi_altern_lba; /* lba of alternate GPT header */
213 225 uint_t efi_reserved[12]; /* future use - set to zero */
214 226 struct dk_part efi_parts[1]; /* array of partitions */
↓ open down ↓ |
156 lines elided |
↑ open up ↑ |
215 227 } dk_gpt_t;
216 228
217 229 /* possible values for "efi_flags" */
218 230 #define EFI_GPT_PRIMARY_CORRUPT 0x1 /* primary label corrupt */
219 231
220 232 /* the private ioctl between libefi and the driver */
221 233 typedef struct dk_efi {
222 234 diskaddr_t dki_lba; /* starting block */
223 235 len_t dki_length; /* length in bytes */
224 236 union {
225 - efi_gpt_t *_dki_data;
237 + efi_gpt_t *_dki_data;
226 238 uint64_t _dki_data_64;
227 239 } dki_un;
228 240 #define dki_data dki_un._dki_data
229 241 #define dki_data_64 dki_un._dki_data_64
230 242 } dk_efi_t;
231 243
232 244 struct partition64 {
233 245 struct uuid p_type;
234 246 uint_t p_partno;
235 247 uint_t p_resv1;
236 248 diskaddr_t p_start;
237 249 diskaddr_t p_size;
238 250 };
239 251
240 252 /*
241 253 * Number of EFI partitions
242 254 */
243 255 #define EFI_NUMPAR 9
244 256
245 257 #ifndef _KERNEL
246 258 extern int efi_alloc_and_init(int, uint32_t, struct dk_gpt **);
247 259 extern int efi_alloc_and_read(int, struct dk_gpt **);
248 260 extern int efi_write(int, struct dk_gpt *);
249 261 extern void efi_free(struct dk_gpt *);
250 262 extern int efi_type(int);
251 263 extern void efi_err_check(struct dk_gpt *);
252 264 extern int efi_auto_sense(int fd, struct dk_gpt **);
253 265 extern int efi_use_whole_disk(int fd);
254 266 #endif
255 267
256 268 #ifdef __cplusplus
257 269 }
258 270 #endif
259 271
260 272 #endif /* _SYS_EFI_PARTITION_H */
↓ open down ↓ |
25 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX