10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 52866Sszhou * Common Development and Distribution License (the "License"). 62866Sszhou * You may not use this file except in compliance with the License. 70Sstevel@tonic-gate * 80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 100Sstevel@tonic-gate * See the License for the specific language governing permissions 110Sstevel@tonic-gate * and limitations under the License. 120Sstevel@tonic-gate * 130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 180Sstevel@tonic-gate * 190Sstevel@tonic-gate * CDDL HEADER END 200Sstevel@tonic-gate */ 210Sstevel@tonic-gate /* 22*13027SSharath.Srinivasan@Sun.COM * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. 230Sstevel@tonic-gate */ 240Sstevel@tonic-gate 250Sstevel@tonic-gate #ifndef _SYS_EFI_PARTITION_H 260Sstevel@tonic-gate #define _SYS_EFI_PARTITION_H 270Sstevel@tonic-gate 280Sstevel@tonic-gate #include <sys/uuid.h> 290Sstevel@tonic-gate 300Sstevel@tonic-gate #ifdef __cplusplus 310Sstevel@tonic-gate extern "C" { 320Sstevel@tonic-gate #endif 330Sstevel@tonic-gate 340Sstevel@tonic-gate /* 350Sstevel@tonic-gate * GUID Partition Table Header 360Sstevel@tonic-gate */ 370Sstevel@tonic-gate 380Sstevel@tonic-gate #define EFI_LABEL_SIZE 512 390Sstevel@tonic-gate #define LEN_EFI_PAD (EFI_LABEL_SIZE - \ 400Sstevel@tonic-gate ((5 * sizeof (diskaddr_t)) + \ 410Sstevel@tonic-gate (7 * sizeof (uint_t)) + \ 420Sstevel@tonic-gate (8 * sizeof (char)) + \ 430Sstevel@tonic-gate (1 * (sizeof (struct uuid))))) 440Sstevel@tonic-gate 450Sstevel@tonic-gate #define EFI_SIGNATURE 0x5452415020494645ULL 460Sstevel@tonic-gate 470Sstevel@tonic-gate /* EFI Guid Partition Table Header -- little endian on-disk format */ 480Sstevel@tonic-gate typedef struct efi_gpt { 490Sstevel@tonic-gate uint64_t efi_gpt_Signature; 500Sstevel@tonic-gate uint_t efi_gpt_Revision; 510Sstevel@tonic-gate uint_t efi_gpt_HeaderSize; 520Sstevel@tonic-gate uint_t efi_gpt_HeaderCRC32; 530Sstevel@tonic-gate uint_t efi_gpt_Reserved1; 540Sstevel@tonic-gate diskaddr_t efi_gpt_MyLBA; 550Sstevel@tonic-gate diskaddr_t efi_gpt_AlternateLBA; 560Sstevel@tonic-gate diskaddr_t efi_gpt_FirstUsableLBA; 570Sstevel@tonic-gate diskaddr_t efi_gpt_LastUsableLBA; 580Sstevel@tonic-gate struct uuid efi_gpt_DiskGUID; 590Sstevel@tonic-gate diskaddr_t efi_gpt_PartitionEntryLBA; 600Sstevel@tonic-gate uint_t efi_gpt_NumberOfPartitionEntries; 610Sstevel@tonic-gate uint_t efi_gpt_SizeOfPartitionEntry; 620Sstevel@tonic-gate uint_t efi_gpt_PartitionEntryArrayCRC32; 630Sstevel@tonic-gate char efi_gpt_Reserved2[LEN_EFI_PAD]; 640Sstevel@tonic-gate } efi_gpt_t; 650Sstevel@tonic-gate 660Sstevel@tonic-gate /* EFI Guid Partition Entry Attributes -- little endian format */ 670Sstevel@tonic-gate typedef struct efi_gpe_Attrs { 680Sstevel@tonic-gate uint32_t PartitionAttrs :16, 690Sstevel@tonic-gate Reserved2 :16; 700Sstevel@tonic-gate uint32_t Reserved1 :31, 710Sstevel@tonic-gate RequiredPartition :1; 720Sstevel@tonic-gate } efi_gpe_Attrs_t; 730Sstevel@tonic-gate 740Sstevel@tonic-gate /* 750Sstevel@tonic-gate * 6a96237f-1dd2-11b2-99a6-080020736631 V_UNASSIGNED (not used as such) 760Sstevel@tonic-gate * 6a82cb45-1dd2-11b2-99a6-080020736631 V_BOOT 770Sstevel@tonic-gate * 6a85cf4d-1dd2-11b2-99a6-080020736631 V_ROOT 780Sstevel@tonic-gate * 6a87c46f-1dd2-11b2-99a6-080020736631 V_SWAP 790Sstevel@tonic-gate * 6a898cc3-1dd2-11b2-99a6-080020736631 V_USR 800Sstevel@tonic-gate * 6a8b642b-1dd2-11b2-99a6-080020736631 V_BACKUP 810Sstevel@tonic-gate * 6a8d2ac7-1dd2-11b2-99a6-080020736631 V_STAND (not used) 820Sstevel@tonic-gate * 6a8ef2e9-1dd2-11b2-99a6-080020736631 V_VAR 830Sstevel@tonic-gate * 6a90ba39-1dd2-11b2-99a6-080020736631 V_HOME 840Sstevel@tonic-gate * 6a9283a5-1dd2-11b2-99a6-080020736631 V_ALTSCTR 850Sstevel@tonic-gate * 6a945a3b-1dd2-11b2-99a6-080020736631 V_CACHE 860Sstevel@tonic-gate */ 870Sstevel@tonic-gate 880Sstevel@tonic-gate #define EFI_UNUSED { 0x00000000, 0x0000, 0x0000, 0x00, 0x00, \ 890Sstevel@tonic-gate { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } } 900Sstevel@tonic-gate #define EFI_RESV1 { 0x6a96237f, 0x1dd2, 0x11b2, 0x99, 0xa6, \ 910Sstevel@tonic-gate { 0x08, 0x00, 0x20, 0x73, 0x66, 0x31 } } 920Sstevel@tonic-gate #define EFI_BOOT { 0x6a82cb45, 0x1dd2, 0x11b2, 0x99, 0xa6, \ 930Sstevel@tonic-gate { 0x08, 0x00, 0x20, 0x73, 0x66, 0x31 } } 940Sstevel@tonic-gate #define EFI_ROOT { 0x6a85cf4d, 0x1dd2, 0x11b2, 0x99, 0xa6, \ 950Sstevel@tonic-gate { 0x08, 0x00, 0x20, 0x73, 0x66, 0x31 } } 960Sstevel@tonic-gate #define EFI_SWAP { 0x6a87c46f, 0x1dd2, 0x11b2, 0x99, 0xa6, \ 970Sstevel@tonic-gate { 0x08, 0x00, 0x20, 0x73, 0x66, 0x31 } } 980Sstevel@tonic-gate #define EFI_USR { 0x6a898cc3, 0x1dd2, 0x11b2, 0x99, 0xa6, \ 990Sstevel@tonic-gate { 0x08, 0x00, 0x20, 0x73, 0x66, 0x31 } } 1000Sstevel@tonic-gate #define EFI_BACKUP { 0x6a8b642b, 0x1dd2, 0x11b2, 0x99, 0xa6, \ 1010Sstevel@tonic-gate { 0x08, 0x00, 0x20, 0x73, 0x66, 0x31 } } 1020Sstevel@tonic-gate #define EFI_RESV2 { 0x6a8d2ac7, 0x1dd2, 0x11b2, 0x99, 0xa6, \ 1030Sstevel@tonic-gate { 0x08, 0x00, 0x20, 0x73, 0x66, 0x31 } } 1040Sstevel@tonic-gate #define EFI_VAR { 0x6a8ef2e9, 0x1dd2, 0x11b2, 0x99, 0xa6, \ 1050Sstevel@tonic-gate { 0x08, 0x00, 0x20, 0x73, 0x66, 0x31 } } 1060Sstevel@tonic-gate #define EFI_HOME { 0x6a90ba39, 0x1dd2, 0x11b2, 0x99, 0xa6, \ 1070Sstevel@tonic-gate { 0x08, 0x00, 0x20, 0x73, 0x66, 0x31 } } 1080Sstevel@tonic-gate #define EFI_ALTSCTR { 0x6a9283a5, 0x1dd2, 0x11b2, 0x99, 0xa6, \ 1090Sstevel@tonic-gate { 0x08, 0x00, 0x20, 0x73, 0x66, 0x31 } } 1100Sstevel@tonic-gate #define EFI_RESERVED { 0x6a945a3b, 0x1dd2, 0x11b2, 0x99, 0xa6, \ 1110Sstevel@tonic-gate { 0x08, 0x00, 0x20, 0x73, 0x66, 0x31 } } 1120Sstevel@tonic-gate #define EFI_SYSTEM { 0xC12A7328, 0xF81F, 0x11d2, 0xBA, 0x4B, \ 1130Sstevel@tonic-gate { 0x00, 0xA0, 0xC9, 0x3E, 0xC9, 0x3B } } 1140Sstevel@tonic-gate #define EFI_LEGACY_MBR { 0x024DEE41, 0x33E7, 0x11d3, 0x9D, 0x69, \ 1150Sstevel@tonic-gate { 0x00, 0x08, 0xC7, 0x81, 0xF3, 0x9F } } 116*13027SSharath.Srinivasan@Sun.COM #define EFI_SYMC_PUB { 0x6a9630d1, 0x1dd2, 0x11b2, 0x99, 0xa6, \ 1170Sstevel@tonic-gate { 0x08, 0x00, 0x20, 0x73, 0x66, 0x31 } } 118*13027SSharath.Srinivasan@Sun.COM #define EFI_SYMC_CDS { 0x6a980767, 0x1dd2, 0x11b2, 0x99, 0xa6, \ 1190Sstevel@tonic-gate { 0x08, 0x00, 0x20, 0x73, 0x66, 0x31 } } 1200Sstevel@tonic-gate #define EFI_MSFT_RESV { 0xE3C9E316, 0x0B5C, 0x4DB8, 0x81, 0x7D, \ 1210Sstevel@tonic-gate { 0xF9, 0x2D, 0xF0, 0x02, 0x15, 0xAE } } 1220Sstevel@tonic-gate #define EFI_DELL_BASIC { 0xebd0a0a2, 0xb9e5, 0x4433, 0x87, 0xc0, \ 1230Sstevel@tonic-gate { 0x68, 0xb6, 0xb7, 0x26, 0x99, 0xc7 } } 1240Sstevel@tonic-gate #define EFI_DELL_RAID { 0xa19d880f, 0x05fc, 0x4d3b, 0xa0, 0x06, \ 1250Sstevel@tonic-gate { 0x74, 0x3f, 0x0f, 0x84, 0x91, 0x1e } } 1260Sstevel@tonic-gate #define EFI_DELL_SWAP { 0x0657fd6d, 0xa4ab, 0x43c4, 0x84, 0xe5, \ 1270Sstevel@tonic-gate { 0x09, 0x33, 0xc8, 0x4b, 0x4f, 0x4f } } 1280Sstevel@tonic-gate #define EFI_DELL_LVM { 0xe6d6d379, 0xf507, 0x44c2, 0xa2, 0x3c, \ 1290Sstevel@tonic-gate { 0x23, 0x8f, 0x2a, 0x3d, 0xf9, 0x28 } } 1300Sstevel@tonic-gate #define EFI_DELL_RESV { 0x8da63339, 0x0007, 0x60c0, 0xc4, 0x36, \ 1310Sstevel@tonic-gate { 0x08, 0x3a, 0xc8, 0x23, 0x09, 0x08 } } 1322866Sszhou #define EFI_AAPL_HFS { 0x48465300, 0x0000, 0x11aa, 0xaa, 0x11, \ 1332866Sszhou { 0x00, 0x30, 0x65, 0x43, 0xec, 0xac } } 1342866Sszhou #define EFI_AAPL_UFS { 0x55465300, 0x0000, 0x11aa, 0xaa, 0x11, \ 1352866Sszhou { 0x00, 0x30, 0x65, 0x43, 0xec, 0xac } } 1360Sstevel@tonic-gate 1374276Staylor /* minimum # of bytes for partition table entires, per EFI spec */ 1380Sstevel@tonic-gate #define EFI_MIN_ARRAY_SIZE (16 * 1024) 1390Sstevel@tonic-gate 1400Sstevel@tonic-gate #define EFI_PART_NAME_LEN 36 1410Sstevel@tonic-gate 1424276Staylor /* size of the "reserved" partition, in blocks */ 1434276Staylor #define EFI_MIN_RESV_SIZE (16 * 1024) 1444276Staylor 1450Sstevel@tonic-gate /* EFI Guid Partition Entry */ 1460Sstevel@tonic-gate typedef struct efi_gpe { 1470Sstevel@tonic-gate struct uuid efi_gpe_PartitionTypeGUID; 1480Sstevel@tonic-gate struct uuid efi_gpe_UniquePartitionGUID; 1490Sstevel@tonic-gate diskaddr_t efi_gpe_StartingLBA; 1500Sstevel@tonic-gate diskaddr_t efi_gpe_EndingLBA; 1510Sstevel@tonic-gate efi_gpe_Attrs_t efi_gpe_Attributes; 1520Sstevel@tonic-gate ushort_t efi_gpe_PartitionName[EFI_PART_NAME_LEN]; 1530Sstevel@tonic-gate } efi_gpe_t; 1540Sstevel@tonic-gate 1550Sstevel@tonic-gate /* 1560Sstevel@tonic-gate * passed to the useful (we hope) routines (efi_alloc_and_read and 1570Sstevel@tonic-gate * efi_write) that take this VTOC-like struct. These routines handle 1580Sstevel@tonic-gate * converting this struct into the EFI struct, generate UUIDs and 1590Sstevel@tonic-gate * checksums, and perform any necessary byte-swapping to the on-disk 1600Sstevel@tonic-gate * format. 1610Sstevel@tonic-gate */ 1620Sstevel@tonic-gate /* Solaris library abstraction for EFI partitons */ 1630Sstevel@tonic-gate typedef struct dk_part { 1640Sstevel@tonic-gate diskaddr_t p_start; /* starting LBA */ 1650Sstevel@tonic-gate diskaddr_t p_size; /* size in blocks */ 1660Sstevel@tonic-gate struct uuid p_guid; /* partion type GUID */ 1670Sstevel@tonic-gate ushort_t p_tag; /* converted to part'n type GUID */ 1680Sstevel@tonic-gate ushort_t p_flag; /* attributes */ 1690Sstevel@tonic-gate char p_name[EFI_PART_NAME_LEN]; /* partition name */ 1700Sstevel@tonic-gate struct uuid p_uguid; /* unique partition GUID */ 1710Sstevel@tonic-gate uint_t p_resv[8]; /* future use - set to zero */ 1720Sstevel@tonic-gate } dk_part_t; 1730Sstevel@tonic-gate 1740Sstevel@tonic-gate /* Solaris library abstraction for an EFI GPT */ 1750Sstevel@tonic-gate #define EFI_VERSION102 0x00010002 1760Sstevel@tonic-gate #define EFI_VERSION100 0x00010000 1770Sstevel@tonic-gate #define EFI_VERSION_CURRENT EFI_VERSION100 1780Sstevel@tonic-gate typedef struct dk_gpt { 1790Sstevel@tonic-gate uint_t efi_version; /* set to EFI_VERSION_CURRENT */ 1800Sstevel@tonic-gate uint_t efi_nparts; /* number of partitions below */ 1810Sstevel@tonic-gate uint_t efi_part_size; /* size of each partition entry */ 1820Sstevel@tonic-gate /* efi_part_size is unused */ 1830Sstevel@tonic-gate uint_t efi_lbasize; /* size of block in bytes */ 1840Sstevel@tonic-gate diskaddr_t efi_last_lba; /* last block on the disk */ 1850Sstevel@tonic-gate diskaddr_t efi_first_u_lba; /* first block after labels */ 1860Sstevel@tonic-gate diskaddr_t efi_last_u_lba; /* last block before backup labels */ 1870Sstevel@tonic-gate struct uuid efi_disk_uguid; /* unique disk GUID */ 1880Sstevel@tonic-gate uint_t efi_flags; 1896590Syl194034 uint_t efi_reserved1; /* future use - set to zero */ 1906590Syl194034 diskaddr_t efi_altern_lba; /* lba of alternate GPT header */ 1916590Syl194034 uint_t efi_reserved[12]; /* future use - set to zero */ 1920Sstevel@tonic-gate struct dk_part efi_parts[1]; /* array of partitions */ 1930Sstevel@tonic-gate } dk_gpt_t; 1940Sstevel@tonic-gate 1950Sstevel@tonic-gate /* possible values for "efi_flags" */ 1960Sstevel@tonic-gate #define EFI_GPT_PRIMARY_CORRUPT 0x1 /* primary label corrupt */ 1970Sstevel@tonic-gate 1980Sstevel@tonic-gate /* the private ioctl between libefi and the driver */ 1990Sstevel@tonic-gate typedef struct dk_efi { 2000Sstevel@tonic-gate diskaddr_t dki_lba; /* starting block */ 2010Sstevel@tonic-gate len_t dki_length; /* length in bytes */ 2020Sstevel@tonic-gate union { 2030Sstevel@tonic-gate efi_gpt_t *_dki_data; 2040Sstevel@tonic-gate uint64_t _dki_data_64; 2050Sstevel@tonic-gate } dki_un; 2060Sstevel@tonic-gate #define dki_data dki_un._dki_data 2070Sstevel@tonic-gate #define dki_data_64 dki_un._dki_data_64 2080Sstevel@tonic-gate } dk_efi_t; 2090Sstevel@tonic-gate 2100Sstevel@tonic-gate struct partition64 { 2110Sstevel@tonic-gate struct uuid p_type; 2120Sstevel@tonic-gate uint_t p_partno; 2130Sstevel@tonic-gate uint_t p_resv1; 2140Sstevel@tonic-gate diskaddr_t p_start; 2150Sstevel@tonic-gate diskaddr_t p_size; 2160Sstevel@tonic-gate }; 2170Sstevel@tonic-gate 2180Sstevel@tonic-gate /* 2190Sstevel@tonic-gate * Number of EFI partitions 2200Sstevel@tonic-gate */ 2210Sstevel@tonic-gate #define EFI_NUMPAR 9 2220Sstevel@tonic-gate 2230Sstevel@tonic-gate #ifndef _KERNEL 2240Sstevel@tonic-gate extern int efi_alloc_and_init(int, uint32_t, struct dk_gpt **); 2250Sstevel@tonic-gate extern int efi_alloc_and_read(int, struct dk_gpt **); 2260Sstevel@tonic-gate extern int efi_write(int, struct dk_gpt *); 2270Sstevel@tonic-gate extern void efi_free(struct dk_gpt *); 2280Sstevel@tonic-gate extern int efi_type(int); 2290Sstevel@tonic-gate extern void efi_err_check(struct dk_gpt *); 2300Sstevel@tonic-gate extern int efi_auto_sense(int fd, struct dk_gpt **); 2316590Syl194034 extern int efi_use_whole_disk(int fd); 2320Sstevel@tonic-gate #endif 2330Sstevel@tonic-gate 2340Sstevel@tonic-gate #ifdef __cplusplus 2350Sstevel@tonic-gate } 2360Sstevel@tonic-gate #endif 2370Sstevel@tonic-gate 2380Sstevel@tonic-gate #endif /* _SYS_EFI_PARTITION_H */ 239