17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5f2be5148Sszhou  * Common Development and Distribution License (the "License").
6f2be5148Sszhou  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
217c478bd9Sstevel@tonic-gate /*
2280c797c0SSharath M Srinivasan  * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
23e21ea675SYuri Pankov  * Copyright 2012 Nexenta Systems, Inc.  All rights reserved.
24e088753cSToomas Soome  * Copyright 2014 Toomas Soome <tsoome@me.com>
25fd797736SJohn Levon  * Copyright (c) 2019, Joyent, Inc.
267c478bd9Sstevel@tonic-gate  */
277c478bd9Sstevel@tonic-gate 
287c478bd9Sstevel@tonic-gate #ifndef	_SYS_EFI_PARTITION_H
297c478bd9Sstevel@tonic-gate #define	_SYS_EFI_PARTITION_H
307c478bd9Sstevel@tonic-gate 
317c478bd9Sstevel@tonic-gate #include <sys/uuid.h>
32fd797736SJohn Levon #include <sys/stddef.h>
337c478bd9Sstevel@tonic-gate 
347c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
357c478bd9Sstevel@tonic-gate extern "C" {
367c478bd9Sstevel@tonic-gate #endif
377c478bd9Sstevel@tonic-gate 
387c478bd9Sstevel@tonic-gate /*
397c478bd9Sstevel@tonic-gate  * GUID Partition Table Header
407c478bd9Sstevel@tonic-gate  */
417c478bd9Sstevel@tonic-gate 
427c478bd9Sstevel@tonic-gate #define	EFI_LABEL_SIZE	512
437c478bd9Sstevel@tonic-gate #define	LEN_EFI_PAD	(EFI_LABEL_SIZE - \
447c478bd9Sstevel@tonic-gate 			    ((5 * sizeof (diskaddr_t)) + \
457c478bd9Sstevel@tonic-gate 			    (7 * sizeof (uint_t)) + \
467c478bd9Sstevel@tonic-gate 			    (8 * sizeof (char)) + \
477c478bd9Sstevel@tonic-gate 			    (1 * (sizeof (struct uuid)))))
487c478bd9Sstevel@tonic-gate 
497c478bd9Sstevel@tonic-gate #define	EFI_SIGNATURE	0x5452415020494645ULL
507c478bd9Sstevel@tonic-gate 
51fd797736SJohn Levon /*
52fd797736SJohn Levon  * Although the EFI spec is clear that sizeof (efi_gpt_t) is a valid value
53fd797736SJohn Levon  * (512), at least one EFI system (AMI v4.6.4.1) incorrectly expects this to be
54fd797736SJohn Levon  * exactly the size of the structure defined in the spec, that is, 92.
55fd797736SJohn Levon  *
56fd797736SJohn Levon  * As the reserved section is never used, the modified value works fine
57fd797736SJohn Levon  * everywhere else.
58fd797736SJohn Levon  */
59fd797736SJohn Levon #define	EFI_HEADER_SIZE (offsetof(efi_gpt_t, efi_gpt_Reserved2))
60fd797736SJohn Levon 
617c478bd9Sstevel@tonic-gate /* EFI Guid Partition Table Header -- little endian on-disk format */
627c478bd9Sstevel@tonic-gate typedef struct efi_gpt {
637c478bd9Sstevel@tonic-gate 	uint64_t	efi_gpt_Signature;
647c478bd9Sstevel@tonic-gate 	uint_t		efi_gpt_Revision;
657c478bd9Sstevel@tonic-gate 	uint_t		efi_gpt_HeaderSize;
667c478bd9Sstevel@tonic-gate 	uint_t		efi_gpt_HeaderCRC32;
677c478bd9Sstevel@tonic-gate 	uint_t		efi_gpt_Reserved1;
687c478bd9Sstevel@tonic-gate 	diskaddr_t	efi_gpt_MyLBA;
697c478bd9Sstevel@tonic-gate 	diskaddr_t	efi_gpt_AlternateLBA;
707c478bd9Sstevel@tonic-gate 	diskaddr_t	efi_gpt_FirstUsableLBA;
717c478bd9Sstevel@tonic-gate 	diskaddr_t	efi_gpt_LastUsableLBA;
727c478bd9Sstevel@tonic-gate 	struct uuid	efi_gpt_DiskGUID;
737c478bd9Sstevel@tonic-gate 	diskaddr_t	efi_gpt_PartitionEntryLBA;
747c478bd9Sstevel@tonic-gate 	uint_t		efi_gpt_NumberOfPartitionEntries;
757c478bd9Sstevel@tonic-gate 	uint_t		efi_gpt_SizeOfPartitionEntry;
767c478bd9Sstevel@tonic-gate 	uint_t		efi_gpt_PartitionEntryArrayCRC32;
777c478bd9Sstevel@tonic-gate 	char		efi_gpt_Reserved2[LEN_EFI_PAD];
787c478bd9Sstevel@tonic-gate } efi_gpt_t;
797c478bd9Sstevel@tonic-gate 
807c478bd9Sstevel@tonic-gate /* EFI Guid Partition Entry Attributes -- little endian format */
817c478bd9Sstevel@tonic-gate typedef struct efi_gpe_Attrs {
827c478bd9Sstevel@tonic-gate 	uint32_t	PartitionAttrs		:16,
837c478bd9Sstevel@tonic-gate 			Reserved2		:16;
847c478bd9Sstevel@tonic-gate 	uint32_t	Reserved1		:31,
857c478bd9Sstevel@tonic-gate 			RequiredPartition	:1;
867c478bd9Sstevel@tonic-gate } efi_gpe_Attrs_t;
877c478bd9Sstevel@tonic-gate 
887c478bd9Sstevel@tonic-gate /*
897c478bd9Sstevel@tonic-gate  * 6a96237f-1dd2-11b2-99a6-080020736631	V_UNASSIGNED (not used as such)
907c478bd9Sstevel@tonic-gate  * 6a82cb45-1dd2-11b2-99a6-080020736631	V_BOOT
917c478bd9Sstevel@tonic-gate  * 6a85cf4d-1dd2-11b2-99a6-080020736631	V_ROOT
927c478bd9Sstevel@tonic-gate  * 6a87c46f-1dd2-11b2-99a6-080020736631	V_SWAP
937c478bd9Sstevel@tonic-gate  * 6a898cc3-1dd2-11b2-99a6-080020736631	V_USR
947c478bd9Sstevel@tonic-gate  * 6a8b642b-1dd2-11b2-99a6-080020736631	V_BACKUP
957c478bd9Sstevel@tonic-gate  * 6a8d2ac7-1dd2-11b2-99a6-080020736631	V_STAND (not used)
967c478bd9Sstevel@tonic-gate  * 6a8ef2e9-1dd2-11b2-99a6-080020736631	V_VAR
977c478bd9Sstevel@tonic-gate  * 6a90ba39-1dd2-11b2-99a6-080020736631	V_HOME
987c478bd9Sstevel@tonic-gate  * 6a9283a5-1dd2-11b2-99a6-080020736631	V_ALTSCTR
997c478bd9Sstevel@tonic-gate  * 6a945a3b-1dd2-11b2-99a6-080020736631	V_CACHE
1007c478bd9Sstevel@tonic-gate  */
1017c478bd9Sstevel@tonic-gate 
102e21ea675SYuri Pankov #define	EFI_UNUSED		{ 0x00000000, 0x0000, 0x0000, 0x00, 0x00, \
103e21ea675SYuri Pankov 				    { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } }
104e21ea675SYuri Pankov #define	EFI_RESV1		{ 0x6a96237f, 0x1dd2, 0x11b2, 0x99, 0xa6, \
105e21ea675SYuri Pankov 				    { 0x08, 0x00, 0x20, 0x73, 0x66, 0x31 } }
106e21ea675SYuri Pankov #define	EFI_BOOT		{ 0x6a82cb45, 0x1dd2, 0x11b2, 0x99, 0xa6, \
107e21ea675SYuri Pankov 				    { 0x08, 0x00, 0x20, 0x73, 0x66, 0x31 } }
108e21ea675SYuri Pankov #define	EFI_ROOT		{ 0x6a85cf4d, 0x1dd2, 0x11b2, 0x99, 0xa6, \
109e21ea675SYuri Pankov 				    { 0x08, 0x00, 0x20, 0x73, 0x66, 0x31 } }
110e21ea675SYuri Pankov #define	EFI_SWAP		{ 0x6a87c46f, 0x1dd2, 0x11b2, 0x99, 0xa6, \
111e21ea675SYuri Pankov 				    { 0x08, 0x00, 0x20, 0x73, 0x66, 0x31 } }
112e21ea675SYuri Pankov #define	EFI_USR			{ 0x6a898cc3, 0x1dd2, 0x11b2, 0x99, 0xa6, \
113e21ea675SYuri Pankov 				    { 0x08, 0x00, 0x20, 0x73, 0x66, 0x31 } }
114e21ea675SYuri Pankov #define	EFI_BACKUP		{ 0x6a8b642b, 0x1dd2, 0x11b2, 0x99, 0xa6, \
115e21ea675SYuri Pankov 				    { 0x08, 0x00, 0x20, 0x73, 0x66, 0x31 } }
116e21ea675SYuri Pankov #define	EFI_RESV2		{ 0x6a8d2ac7, 0x1dd2, 0x11b2, 0x99, 0xa6, \
117e21ea675SYuri Pankov 				    { 0x08, 0x00, 0x20, 0x73, 0x66, 0x31 } }
118e21ea675SYuri Pankov #define	EFI_VAR			{ 0x6a8ef2e9, 0x1dd2, 0x11b2, 0x99, 0xa6, \
119e21ea675SYuri Pankov 				    { 0x08, 0x00, 0x20, 0x73, 0x66, 0x31 } }
120e21ea675SYuri Pankov #define	EFI_HOME		{ 0x6a90ba39, 0x1dd2, 0x11b2, 0x99, 0xa6, \
121e21ea675SYuri Pankov 				    { 0x08, 0x00, 0x20, 0x73, 0x66, 0x31 } }
122e21ea675SYuri Pankov #define	EFI_ALTSCTR		{ 0x6a9283a5, 0x1dd2, 0x11b2, 0x99, 0xa6, \
123e21ea675SYuri Pankov 				    { 0x08, 0x00, 0x20, 0x73, 0x66, 0x31 } }
124e21ea675SYuri Pankov #define	EFI_RESERVED		{ 0x6a945a3b, 0x1dd2, 0x11b2, 0x99, 0xa6, \
125e21ea675SYuri Pankov 				    { 0x08, 0x00, 0x20, 0x73, 0x66, 0x31 } }
126e21ea675SYuri Pankov #define	EFI_SYSTEM		{ 0xC12A7328, 0xF81F, 0x11d2, 0xBA, 0x4B, \
127e21ea675SYuri Pankov 				    { 0x00, 0xA0, 0xC9, 0x3E, 0xC9, 0x3B } }
128e21ea675SYuri Pankov #define	EFI_LEGACY_MBR		{ 0x024DEE41, 0x33E7, 0x11d3, 0x9D, 0x69, \
129e21ea675SYuri Pankov 				    { 0x00, 0x08, 0xC7, 0x81, 0xF3, 0x9F } }
130e21ea675SYuri Pankov #define	EFI_SYMC_PUB		{ 0x6a9630d1, 0x1dd2, 0x11b2, 0x99, 0xa6, \
131e21ea675SYuri Pankov 				    { 0x08, 0x00, 0x20, 0x73, 0x66, 0x31 } }
132e21ea675SYuri Pankov #define	EFI_SYMC_CDS		{ 0x6a980767, 0x1dd2, 0x11b2, 0x99, 0xa6, \
133e21ea675SYuri Pankov 				    { 0x08, 0x00, 0x20, 0x73, 0x66, 0x31 } }
134e21ea675SYuri Pankov #define	EFI_MSFT_RESV		{ 0xE3C9E316, 0x0B5C, 0x4DB8, 0x81, 0x7D, \
135e21ea675SYuri Pankov 				    { 0xF9, 0x2D, 0xF0, 0x02, 0x15, 0xAE } }
136e21ea675SYuri Pankov #define	EFI_DELL_BASIC		{ 0xebd0a0a2, 0xb9e5, 0x4433, 0x87, 0xc0, \
137e21ea675SYuri Pankov 				    { 0x68, 0xb6, 0xb7, 0x26, 0x99, 0xc7 } }
138e21ea675SYuri Pankov #define	EFI_DELL_RAID		{ 0xa19d880f, 0x05fc, 0x4d3b, 0xa0, 0x06, \
139e21ea675SYuri Pankov 				    { 0x74, 0x3f, 0x0f, 0x84, 0x91, 0x1e } }
140e21ea675SYuri Pankov #define	EFI_DELL_SWAP		{ 0x0657fd6d, 0xa4ab, 0x43c4, 0x84, 0xe5, \
141e21ea675SYuri Pankov 				    { 0x09, 0x33, 0xc8, 0x4b, 0x4f, 0x4f } }
142e21ea675SYuri Pankov #define	EFI_DELL_LVM		{ 0xe6d6d379, 0xf507, 0x44c2, 0xa2, 0x3c, \
143e21ea675SYuri Pankov 				    { 0x23, 0x8f, 0x2a, 0x3d, 0xf9, 0x28 } }
144e21ea675SYuri Pankov #define	EFI_DELL_RESV		{ 0x8da63339, 0x0007, 0x60c0, 0xc4, 0x36, \
145e21ea675SYuri Pankov 				    { 0x08, 0x3a, 0xc8, 0x23, 0x09, 0x08 } }
146d06952d0SToomas Soome #define	EFI_AAPL_BOOT		{ 0x426F6F74, 0x0000, 0x11aa, 0xaa, 0x11, \
147d06952d0SToomas Soome 				{ 0x00, 0x30, 0x65, 0x43, 0xec, 0xac } }
148e21ea675SYuri Pankov #define	EFI_AAPL_HFS		{ 0x48465300, 0x0000, 0x11aa, 0xaa, 0x11, \
149e21ea675SYuri Pankov 				    { 0x00, 0x30, 0x65, 0x43, 0xec, 0xac } }
150e21ea675SYuri Pankov #define	EFI_AAPL_UFS		{ 0x55465300, 0x0000, 0x11aa, 0xaa, 0x11, \
151e21ea675SYuri Pankov 				    { 0x00, 0x30, 0x65, 0x43, 0xec, 0xac } }
152d06952d0SToomas Soome #define	EFI_AAPL_ZFS		{ 0x6a898cc3, 0x1dd2, 0x11b2, 0x99, 0xa6, \
153d06952d0SToomas Soome 				    { 0x08, 0x00, 0x20, 0x73, 0x66, 0x31 } }
154d06952d0SToomas Soome #define	EFI_AAPL_APFS		{ 0x7c3457ef, 0x0000, 0x11aa, 0xaa, 0x11, \
155d06952d0SToomas Soome 				    { 0x00, 0x30, 0x65, 0x43, 0xec, 0xac } }
156e21ea675SYuri Pankov #define	EFI_FREEBSD_BOOT	{ 0x83bd6b9d, 0x7f41, 0x11dc, 0xbe, 0x0b, \
157e21ea675SYuri Pankov 				    { 0x00, 0x15, 0x60, 0xb8, 0x4f, 0x0f } }
158d06952d0SToomas Soome #define	EFI_FREEBSD_NANDFS	{ 0x74ba7dd9, 0xa689, 0x11e1, 0xbd, 0x04, \
159d06952d0SToomas Soome 				    { 0x00, 0xe0, 0x81, 0x28, 0x6a, 0xcf } }
160e21ea675SYuri Pankov #define	EFI_FREEBSD_SWAP	{ 0x516e7cb5, 0x6ecf, 0x11d6, 0x8f, 0xf8, \
161e21ea675SYuri Pankov 				    { 0x00, 0x02, 0x2d, 0x09, 0x71, 0x2b } }
162e21ea675SYuri Pankov #define	EFI_FREEBSD_UFS		{ 0x516e7cb6, 0x6ecf, 0x11d6, 0x8f, 0xf8, \
163e21ea675SYuri Pankov 				    { 0x00, 0x02, 0x2d, 0x09, 0x71, 0x2b } }
164e21ea675SYuri Pankov #define	EFI_FREEBSD_VINUM	{ 0x516e7cb8, 0x6ecf, 0x11d6, 0x8f, 0xf8, \
165e21ea675SYuri Pankov 				    { 0x00, 0x02, 0x2d, 0x09, 0x71, 0x2b } }
166e21ea675SYuri Pankov #define	EFI_FREEBSD_ZFS		{ 0x516e7cba, 0x6ecf, 0x11d6, 0x8f, 0xf8, \
167e21ea675SYuri Pankov 				    { 0x00, 0x02, 0x2d, 0x09, 0x71, 0x2b } }
168e088753cSToomas Soome #define	EFI_BIOS_BOOT		{ 0x21686148, 0x6449, 0x6e6f, 0x74, 0x4e, \
169e088753cSToomas Soome 				    { 0x65, 0x65, 0x64, 0x45, 0x46, 0x49 } }
1707c478bd9Sstevel@tonic-gate 
1718488aeb5Staylor /* minimum # of bytes for partition table entires, per EFI spec */
1727c478bd9Sstevel@tonic-gate #define	EFI_MIN_ARRAY_SIZE	(16 * 1024)
1737c478bd9Sstevel@tonic-gate 
1747c478bd9Sstevel@tonic-gate #define	EFI_PART_NAME_LEN	36
1757c478bd9Sstevel@tonic-gate 
1768488aeb5Staylor /* size of the "reserved" partition, in blocks */
1778488aeb5Staylor #define	EFI_MIN_RESV_SIZE	(16 * 1024)
1788488aeb5Staylor 
1797c478bd9Sstevel@tonic-gate /* EFI Guid Partition Entry */
1807c478bd9Sstevel@tonic-gate typedef struct efi_gpe {
1817c478bd9Sstevel@tonic-gate 	struct uuid	efi_gpe_PartitionTypeGUID;
1827c478bd9Sstevel@tonic-gate 	struct uuid	efi_gpe_UniquePartitionGUID;
1837c478bd9Sstevel@tonic-gate 	diskaddr_t	efi_gpe_StartingLBA;
1847c478bd9Sstevel@tonic-gate 	diskaddr_t	efi_gpe_EndingLBA;
1857c478bd9Sstevel@tonic-gate 	efi_gpe_Attrs_t	efi_gpe_Attributes;
1867c478bd9Sstevel@tonic-gate 	ushort_t	efi_gpe_PartitionName[EFI_PART_NAME_LEN];
1877c478bd9Sstevel@tonic-gate } efi_gpe_t;
1887c478bd9Sstevel@tonic-gate 
1897c478bd9Sstevel@tonic-gate /*
1907c478bd9Sstevel@tonic-gate  * passed to the useful (we hope) routines (efi_alloc_and_read and
1917c478bd9Sstevel@tonic-gate  * efi_write) that take this VTOC-like struct.  These routines handle
1927c478bd9Sstevel@tonic-gate  * converting this struct into the EFI struct, generate UUIDs and
1937c478bd9Sstevel@tonic-gate  * checksums, and perform any necessary byte-swapping to the on-disk
1947c478bd9Sstevel@tonic-gate  * format.
1957c478bd9Sstevel@tonic-gate  */
1967c478bd9Sstevel@tonic-gate /* Solaris library abstraction for EFI partitons */
1977c478bd9Sstevel@tonic-gate typedef struct dk_part	{
1987c478bd9Sstevel@tonic-gate 	diskaddr_t	p_start;	/* starting LBA */
1997c478bd9Sstevel@tonic-gate 	diskaddr_t	p_size;		/* size in blocks */
2007c478bd9Sstevel@tonic-gate 	struct uuid	p_guid;		/* partion type GUID */
2017c478bd9Sstevel@tonic-gate 	ushort_t	p_tag;		/* converted to part'n type GUID */
2027c478bd9Sstevel@tonic-gate 	ushort_t	p_flag;		/* attributes */
2037c478bd9Sstevel@tonic-gate 	char		p_name[EFI_PART_NAME_LEN]; /* partition name */
2047c478bd9Sstevel@tonic-gate 	struct uuid	p_uguid;	/* unique partition GUID */
2057c478bd9Sstevel@tonic-gate 	uint_t		p_resv[8];	/* future use - set to zero */
2067c478bd9Sstevel@tonic-gate } dk_part_t;
2077c478bd9Sstevel@tonic-gate 
2087c478bd9Sstevel@tonic-gate /* Solaris library abstraction for an EFI GPT */
2097c478bd9Sstevel@tonic-gate #define	EFI_VERSION102		0x00010002
2107c478bd9Sstevel@tonic-gate #define	EFI_VERSION100		0x00010000
2117c478bd9Sstevel@tonic-gate #define	EFI_VERSION_CURRENT	EFI_VERSION100
2127c478bd9Sstevel@tonic-gate typedef struct dk_gpt {
2137c478bd9Sstevel@tonic-gate 	uint_t		efi_version;	/* set to EFI_VERSION_CURRENT */
2147c478bd9Sstevel@tonic-gate 	uint_t		efi_nparts;	/* number of partitions below */
2157c478bd9Sstevel@tonic-gate 	uint_t		efi_part_size;	/* size of each partition entry */
2167c478bd9Sstevel@tonic-gate 					/* efi_part_size is unused */
2177c478bd9Sstevel@tonic-gate 	uint_t		efi_lbasize;	/* size of block in bytes */
2187c478bd9Sstevel@tonic-gate 	diskaddr_t	efi_last_lba;	/* last block on the disk */
2197c478bd9Sstevel@tonic-gate 	diskaddr_t	efi_first_u_lba; /* first block after labels */
2207c478bd9Sstevel@tonic-gate 	diskaddr_t	efi_last_u_lba;	/* last block before backup labels */
2217c478bd9Sstevel@tonic-gate 	struct uuid	efi_disk_uguid;	/* unique disk GUID */
2227c478bd9Sstevel@tonic-gate 	uint_t		efi_flags;
223af007057Syl 	uint_t		efi_reserved1;	/* future use - set to zero */
224af007057Syl 	diskaddr_t	efi_altern_lba;	/* lba of alternate GPT header */
225af007057Syl 	uint_t		efi_reserved[12]; /* future use - set to zero */
2267c478bd9Sstevel@tonic-gate 	struct dk_part	efi_parts[1];	/* array of partitions */
2277c478bd9Sstevel@tonic-gate } dk_gpt_t;
2287c478bd9Sstevel@tonic-gate 
2297c478bd9Sstevel@tonic-gate /* possible values for "efi_flags" */
2307c478bd9Sstevel@tonic-gate #define	EFI_GPT_PRIMARY_CORRUPT	0x1	/* primary label corrupt */
2317c478bd9Sstevel@tonic-gate 
2327c478bd9Sstevel@tonic-gate /* the private ioctl between libefi and the driver */
2337c478bd9Sstevel@tonic-gate typedef struct dk_efi {
2347c478bd9Sstevel@tonic-gate 	diskaddr_t	 dki_lba;	/* starting block */
2357c478bd9Sstevel@tonic-gate 	len_t		 dki_length;	/* length in bytes */
2367c478bd9Sstevel@tonic-gate 	union {
237fd797736SJohn Levon 		efi_gpt_t	*_dki_data;
2387c478bd9Sstevel@tonic-gate 		uint64_t	_dki_data_64;
2397c478bd9Sstevel@tonic-gate 	} dki_un;
2407c478bd9Sstevel@tonic-gate #define	dki_data	dki_un._dki_data
2417c478bd9Sstevel@tonic-gate #define	dki_data_64	dki_un._dki_data_64
2427c478bd9Sstevel@tonic-gate } dk_efi_t;
2437c478bd9Sstevel@tonic-gate 
2447c478bd9Sstevel@tonic-gate struct partition64 {
2457c478bd9Sstevel@tonic-gate 	struct uuid	p_type;
2467c478bd9Sstevel@tonic-gate 	uint_t		p_partno;
2477c478bd9Sstevel@tonic-gate 	uint_t		p_resv1;
2487c478bd9Sstevel@tonic-gate 	diskaddr_t	p_start;
2497c478bd9Sstevel@tonic-gate 	diskaddr_t	p_size;
2507c478bd9Sstevel@tonic-gate };
2517c478bd9Sstevel@tonic-gate 
2527c478bd9Sstevel@tonic-gate /*
2537c478bd9Sstevel@tonic-gate  * Number of EFI partitions
2547c478bd9Sstevel@tonic-gate  */
2557c478bd9Sstevel@tonic-gate #define	EFI_NUMPAR	9
2567c478bd9Sstevel@tonic-gate 
2577c478bd9Sstevel@tonic-gate #ifndef _KERNEL
258*62ce8e2eSToomas Soome extern	uint_t	efi_reserved_sectors(struct dk_gpt *);
2597c478bd9Sstevel@tonic-gate extern	int	efi_alloc_and_init(int, uint32_t, struct dk_gpt **);
2607c478bd9Sstevel@tonic-gate extern	int	efi_alloc_and_read(int, struct dk_gpt **);
2617c478bd9Sstevel@tonic-gate extern	int	efi_write(int, struct dk_gpt *);
2627c478bd9Sstevel@tonic-gate extern	void	efi_free(struct dk_gpt *);
2637c478bd9Sstevel@tonic-gate extern	int	efi_type(int);
2647c478bd9Sstevel@tonic-gate extern	void	efi_err_check(struct dk_gpt *);
2657c478bd9Sstevel@tonic-gate extern	int	efi_auto_sense(int fd, struct dk_gpt **);
266af007057Syl extern	int	efi_use_whole_disk(int fd);
2677c478bd9Sstevel@tonic-gate #endif
2687c478bd9Sstevel@tonic-gate 
2697c478bd9Sstevel@tonic-gate #ifdef __cplusplus
2707c478bd9Sstevel@tonic-gate }
2717c478bd9Sstevel@tonic-gate #endif
2727c478bd9Sstevel@tonic-gate 
2737c478bd9Sstevel@tonic-gate #endif /* _SYS_EFI_PARTITION_H */
274