]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/blame - zfs/include/sys/efi_partition.h
UBUNTU: SAUCE: (no-up) Update zfs to 0.6.5.8-0ubuntu9
[mirror_ubuntu-zesty-kernel.git] / zfs / include / sys / efi_partition.h
CommitLineData
7bdf406d
TG
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 http://www.opensolaris.org/os/licensing.
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 */
24
25#ifndef _SYS_EFI_PARTITION_H
26#define _SYS_EFI_PARTITION_H
27
28#include <sys/uuid.h>
29
30#ifdef __cplusplus
31extern "C" {
32#endif
33
34/*
35 * GUID Partition Table Header
36 */
37
38#define EFI_MIN_LABEL_SIZE 92
39#define EFI_LABEL_SIZE 512
40#define LEN_EFI_PAD (EFI_LABEL_SIZE - \
41 ((5 * sizeof (diskaddr_t)) + \
42 (7 * sizeof (uint_t)) + \
43 (8 * sizeof (char)) + \
44 (1 * (sizeof (struct uuid)))))
45
46#define EFI_SIGNATURE 0x5452415020494645ULL
47
48/* EFI Guid Partition Table Header -- little endian on-disk format */
49typedef struct efi_gpt {
50 uint64_t efi_gpt_Signature;
51 uint_t efi_gpt_Revision;
52 uint_t efi_gpt_HeaderSize;
53 uint_t efi_gpt_HeaderCRC32;
54 uint_t efi_gpt_Reserved1;
55 diskaddr_t efi_gpt_MyLBA;
56 diskaddr_t efi_gpt_AlternateLBA;
57 diskaddr_t efi_gpt_FirstUsableLBA;
58 diskaddr_t efi_gpt_LastUsableLBA;
59 struct uuid efi_gpt_DiskGUID;
60 diskaddr_t efi_gpt_PartitionEntryLBA;
61 uint_t efi_gpt_NumberOfPartitionEntries;
62 uint_t efi_gpt_SizeOfPartitionEntry;
63 uint_t efi_gpt_PartitionEntryArrayCRC32;
64 char efi_gpt_Reserved2[LEN_EFI_PAD];
65} efi_gpt_t;
66
67/* EFI Guid Partition Entry Attributes -- little endian format */
68typedef struct efi_gpe_Attrs {
69 uint32_t PartitionAttrs :16,
70 Reserved2 :16;
71 uint32_t Reserved1 :31,
72 RequiredPartition :1;
73} efi_gpe_Attrs_t;
74
75/*
76 * 6a96237f-1dd2-11b2-99a6-080020736631 V_UNASSIGNED (not used as such)
77 * 6a82cb45-1dd2-11b2-99a6-080020736631 V_BOOT
78 * 6a85cf4d-1dd2-11b2-99a6-080020736631 V_ROOT
79 * 6a87c46f-1dd2-11b2-99a6-080020736631 V_SWAP
80 * 6a898cc3-1dd2-11b2-99a6-080020736631 V_USR
81 * 6a8b642b-1dd2-11b2-99a6-080020736631 V_BACKUP
82 * 6a8d2ac7-1dd2-11b2-99a6-080020736631 V_STAND (not used)
83 * 6a8ef2e9-1dd2-11b2-99a6-080020736631 V_VAR
84 * 6a90ba39-1dd2-11b2-99a6-080020736631 V_HOME
85 * 6a9283a5-1dd2-11b2-99a6-080020736631 V_ALTSCTR
86 * 6a945a3b-1dd2-11b2-99a6-080020736631 V_CACHE
87 */
88
0bd31011
TG
89#define EFI_UNUSED { 0x00000000, 0x0000, 0x0000, 0x00, 0x00, \
90 { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } }
91#define EFI_RESV1 { 0x6a96237f, 0x1dd2, 0x11b2, 0x99, 0xa6, \
92 { 0x08, 0x00, 0x20, 0x73, 0x66, 0x31 } }
93#define EFI_BOOT { 0x6a82cb45, 0x1dd2, 0x11b2, 0x99, 0xa6, \
94 { 0x08, 0x00, 0x20, 0x73, 0x66, 0x31 } }
95#define EFI_ROOT { 0x6a85cf4d, 0x1dd2, 0x11b2, 0x99, 0xa6, \
96 { 0x08, 0x00, 0x20, 0x73, 0x66, 0x31 } }
97#define EFI_SWAP { 0x6a87c46f, 0x1dd2, 0x11b2, 0x99, 0xa6, \
98 { 0x08, 0x00, 0x20, 0x73, 0x66, 0x31 } }
99#define EFI_USR { 0x6a898cc3, 0x1dd2, 0x11b2, 0x99, 0xa6, \
100 { 0x08, 0x00, 0x20, 0x73, 0x66, 0x31 } }
101#define EFI_BACKUP { 0x6a8b642b, 0x1dd2, 0x11b2, 0x99, 0xa6, \
102 { 0x08, 0x00, 0x20, 0x73, 0x66, 0x31 } }
103#define EFI_RESV2 { 0x6a8d2ac7, 0x1dd2, 0x11b2, 0x99, 0xa6, \
104 { 0x08, 0x00, 0x20, 0x73, 0x66, 0x31 } }
105#define EFI_VAR { 0x6a8ef2e9, 0x1dd2, 0x11b2, 0x99, 0xa6, \
106 { 0x08, 0x00, 0x20, 0x73, 0x66, 0x31 } }
107#define EFI_HOME { 0x6a90ba39, 0x1dd2, 0x11b2, 0x99, 0xa6, \
108 { 0x08, 0x00, 0x20, 0x73, 0x66, 0x31 } }
109#define EFI_ALTSCTR { 0x6a9283a5, 0x1dd2, 0x11b2, 0x99, 0xa6, \
110 { 0x08, 0x00, 0x20, 0x73, 0x66, 0x31 } }
111#define EFI_RESERVED { 0x6a945a3b, 0x1dd2, 0x11b2, 0x99, 0xa6, \
112 { 0x08, 0x00, 0x20, 0x73, 0x66, 0x31 } }
113#define EFI_SYSTEM { 0xC12A7328, 0xF81F, 0x11d2, 0xBA, 0x4B, \
114 { 0x00, 0xA0, 0xC9, 0x3E, 0xC9, 0x3B } }
115#define EFI_LEGACY_MBR { 0x024DEE41, 0x33E7, 0x11d3, 0x9D, 0x69, \
116 { 0x00, 0x08, 0xC7, 0x81, 0xF3, 0x9F } }
117#define EFI_SYMC_PUB { 0x6a9630d1, 0x1dd2, 0x11b2, 0x99, 0xa6, \
118 { 0x08, 0x00, 0x20, 0x73, 0x66, 0x31 } }
119#define EFI_SYMC_CDS { 0x6a980767, 0x1dd2, 0x11b2, 0x99, 0xa6, \
120 { 0x08, 0x00, 0x20, 0x73, 0x66, 0x31 } }
121#define EFI_MSFT_RESV { 0xE3C9E316, 0x0B5C, 0x4DB8, 0x81, 0x7D, \
122 { 0xF9, 0x2D, 0xF0, 0x02, 0x15, 0xAE } }
123#define EFI_DELL_BASIC { 0xebd0a0a2, 0xb9e5, 0x4433, 0x87, 0xc0, \
124 { 0x68, 0xb6, 0xb7, 0x26, 0x99, 0xc7 } }
125#define EFI_DELL_RAID { 0xa19d880f, 0x05fc, 0x4d3b, 0xa0, 0x06, \
126 { 0x74, 0x3f, 0x0f, 0x84, 0x91, 0x1e } }
127#define EFI_DELL_SWAP { 0x0657fd6d, 0xa4ab, 0x43c4, 0x84, 0xe5, \
128 { 0x09, 0x33, 0xc8, 0x4b, 0x4f, 0x4f } }
129#define EFI_DELL_LVM { 0xe6d6d379, 0xf507, 0x44c2, 0xa2, 0x3c, \
130 { 0x23, 0x8f, 0x2a, 0x3d, 0xf9, 0x28 } }
131#define EFI_DELL_RESV { 0x8da63339, 0x0007, 0x60c0, 0xc4, 0x36, \
132 { 0x08, 0x3a, 0xc8, 0x23, 0x09, 0x08 } }
133#define EFI_AAPL_HFS { 0x48465300, 0x0000, 0x11aa, 0xaa, 0x11, \
134 { 0x00, 0x30, 0x65, 0x43, 0xec, 0xac } }
135#define EFI_AAPL_UFS { 0x55465300, 0x0000, 0x11aa, 0xaa, 0x11, \
136 { 0x00, 0x30, 0x65, 0x43, 0xec, 0xac } }
7bdf406d
TG
137
138/* minimum # of bytes for partition table entires, per EFI spec */
139#define EFI_MIN_ARRAY_SIZE (16 * 1024)
140
141#define EFI_PART_NAME_LEN 36
142
143/* size of the "reserved" partition, in blocks */
144#define EFI_MIN_RESV_SIZE (16 * 1024)
145
146/* EFI Guid Partition Entry */
147typedef struct efi_gpe {
148 struct uuid efi_gpe_PartitionTypeGUID;
149 struct uuid efi_gpe_UniquePartitionGUID;
150 diskaddr_t efi_gpe_StartingLBA;
151 diskaddr_t efi_gpe_EndingLBA;
152 efi_gpe_Attrs_t efi_gpe_Attributes;
153 ushort_t efi_gpe_PartitionName[EFI_PART_NAME_LEN];
154} efi_gpe_t;
155
156/*
157 * passed to the useful (we hope) routines (efi_alloc_and_read and
158 * efi_write) that take this VTOC-like struct. These routines handle
159 * converting this struct into the EFI struct, generate UUIDs and
160 * checksums, and perform any necessary byte-swapping to the on-disk
161 * format.
162 */
163/* Solaris library abstraction for EFI partitons */
164typedef struct dk_part {
165 diskaddr_t p_start; /* starting LBA */
166 diskaddr_t p_size; /* size in blocks */
167 struct uuid p_guid; /* partion type GUID */
168 ushort_t p_tag; /* converted to part'n type GUID */
169 ushort_t p_flag; /* attributes */
170 char p_name[EFI_PART_NAME_LEN]; /* partition name */
171 struct uuid p_uguid; /* unique partition GUID */
172 uint_t p_resv[8]; /* future use - set to zero */
173} dk_part_t;
174
175/* Solaris library abstraction for an EFI GPT */
176#define EFI_VERSION102 0x00010002
177#define EFI_VERSION100 0x00010000
178#define EFI_VERSION_CURRENT EFI_VERSION100
179typedef struct dk_gpt {
180 uint_t efi_version; /* set to EFI_VERSION_CURRENT */
181 uint_t efi_nparts; /* number of partitions below */
182 uint_t efi_part_size; /* size of each partition entry */
183 /* efi_part_size is unused */
184 uint_t efi_lbasize; /* size of block in bytes */
185 diskaddr_t efi_last_lba; /* last block on the disk */
186 diskaddr_t efi_first_u_lba; /* first block after labels */
187 diskaddr_t efi_last_u_lba; /* last block before backup labels */
188 struct uuid efi_disk_uguid; /* unique disk GUID */
189 uint_t efi_flags;
190 uint_t efi_reserved1; /* future use - set to zero */
191 diskaddr_t efi_altern_lba; /* lba of alternate GPT header */
192 uint_t efi_reserved[12]; /* future use - set to zero */
193 struct dk_part efi_parts[1]; /* array of partitions */
194} dk_gpt_t;
195
196/* possible values for "efi_flags" */
197#define EFI_GPT_PRIMARY_CORRUPT 0x1 /* primary label corrupt */
198
199/* the private ioctl between libefi and the driver */
200typedef struct dk_efi {
201 diskaddr_t dki_lba; /* starting block */
202 len_t dki_length; /* length in bytes */
203 union {
204 efi_gpt_t *_dki_data;
205 uint64_t _dki_data_64;
206 } dki_un;
207#define dki_data dki_un._dki_data
208#define dki_data_64 dki_un._dki_data_64
209} dk_efi_t;
210
211struct partition64 {
212 struct uuid p_type;
213 uint_t p_partno;
214 uint_t p_resv1;
215 diskaddr_t p_start;
216 diskaddr_t p_size;
217};
218
219/*
220 * Number of EFI partitions
221 */
222#if defined(__linux__)
223#define EFI_NUMPAR 128 /* Expected by parted-1.8.1 */
224#else
225#define EFI_NUMPAR 9
226#endif
227
228#ifndef _KERNEL
229extern int efi_alloc_and_init(int, uint32_t, struct dk_gpt **);
230extern int efi_alloc_and_read(int, struct dk_gpt **);
231extern int efi_write(int, struct dk_gpt *);
232extern int efi_rescan(int);
233extern void efi_free(struct dk_gpt *);
234extern int efi_type(int);
235extern void efi_err_check(struct dk_gpt *);
236extern int efi_auto_sense(int fd, struct dk_gpt **);
237extern int efi_use_whole_disk(int fd);
238#endif
239
240#ifdef __cplusplus
241}
242#endif
243
244#endif /* _SYS_EFI_PARTITION_H */