xref: /freebsd/sys/contrib/edk2/Include/Uefi/UefiGpt.h (revision 0d1ba6657e90b1f9b76e1c393b1555d6cf6cf260)
1*0d1ba665SWarner Losh /** @file
2*0d1ba665SWarner Losh   EFI Guid Partition Table Format Definition.
3*0d1ba665SWarner Losh 
4*0d1ba665SWarner Losh Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
5*0d1ba665SWarner Losh This program and the accompanying materials are licensed and made available under
6*0d1ba665SWarner Losh the terms and conditions of the BSD License that accompanies this distribution.
7*0d1ba665SWarner Losh The full text of the license may be found at
8*0d1ba665SWarner Losh http://opensource.org/licenses/bsd-license.php.
9*0d1ba665SWarner Losh 
10*0d1ba665SWarner Losh THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11*0d1ba665SWarner Losh WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12*0d1ba665SWarner Losh 
13*0d1ba665SWarner Losh **/
14*0d1ba665SWarner Losh 
15*0d1ba665SWarner Losh #ifndef __UEFI_GPT_H__
16*0d1ba665SWarner Losh #define __UEFI_GPT_H__
17*0d1ba665SWarner Losh 
18*0d1ba665SWarner Losh ///
19*0d1ba665SWarner Losh /// The primary GUID Partition Table Header must be
20*0d1ba665SWarner Losh /// located in LBA 1 (i.e., the second logical block).
21*0d1ba665SWarner Losh ///
22*0d1ba665SWarner Losh #define PRIMARY_PART_HEADER_LBA 1
23*0d1ba665SWarner Losh ///
24*0d1ba665SWarner Losh /// EFI Partition Table Signature: "EFI PART".
25*0d1ba665SWarner Losh ///
26*0d1ba665SWarner Losh #define EFI_PTAB_HEADER_ID      SIGNATURE_64 ('E','F','I',' ','P','A','R','T')
27*0d1ba665SWarner Losh 
28*0d1ba665SWarner Losh #pragma pack(1)
29*0d1ba665SWarner Losh 
30*0d1ba665SWarner Losh ///
31*0d1ba665SWarner Losh /// GPT Partition Table Header.
32*0d1ba665SWarner Losh ///
33*0d1ba665SWarner Losh typedef struct {
34*0d1ba665SWarner Losh   ///
35*0d1ba665SWarner Losh   /// The table header for the GPT partition Table.
36*0d1ba665SWarner Losh   /// This header contains EFI_PTAB_HEADER_ID.
37*0d1ba665SWarner Losh   ///
38*0d1ba665SWarner Losh   EFI_TABLE_HEADER  Header;
39*0d1ba665SWarner Losh   ///
40*0d1ba665SWarner Losh   /// The LBA that contains this data structure.
41*0d1ba665SWarner Losh   ///
42*0d1ba665SWarner Losh   EFI_LBA           MyLBA;
43*0d1ba665SWarner Losh   ///
44*0d1ba665SWarner Losh   /// LBA address of the alternate GUID Partition Table Header.
45*0d1ba665SWarner Losh   ///
46*0d1ba665SWarner Losh   EFI_LBA           AlternateLBA;
47*0d1ba665SWarner Losh   ///
48*0d1ba665SWarner Losh   /// The first usable logical block that may be used
49*0d1ba665SWarner Losh   /// by a partition described by a GUID Partition Entry.
50*0d1ba665SWarner Losh   ///
51*0d1ba665SWarner Losh   EFI_LBA           FirstUsableLBA;
52*0d1ba665SWarner Losh   ///
53*0d1ba665SWarner Losh   /// The last usable logical block that may be used
54*0d1ba665SWarner Losh   /// by a partition described by a GUID Partition Entry.
55*0d1ba665SWarner Losh   ///
56*0d1ba665SWarner Losh   EFI_LBA           LastUsableLBA;
57*0d1ba665SWarner Losh   ///
58*0d1ba665SWarner Losh   /// GUID that can be used to uniquely identify the disk.
59*0d1ba665SWarner Losh   ///
60*0d1ba665SWarner Losh   EFI_GUID          DiskGUID;
61*0d1ba665SWarner Losh   ///
62*0d1ba665SWarner Losh   /// The starting LBA of the GUID Partition Entry array.
63*0d1ba665SWarner Losh   ///
64*0d1ba665SWarner Losh   EFI_LBA           PartitionEntryLBA;
65*0d1ba665SWarner Losh   ///
66*0d1ba665SWarner Losh   /// The number of Partition Entries in the GUID Partition Entry array.
67*0d1ba665SWarner Losh   ///
68*0d1ba665SWarner Losh   UINT32            NumberOfPartitionEntries;
69*0d1ba665SWarner Losh   ///
70*0d1ba665SWarner Losh   /// The size, in bytes, of each the GUID Partition
71*0d1ba665SWarner Losh   /// Entry structures in the GUID Partition Entry
72*0d1ba665SWarner Losh   /// array. This field shall be set to a value of 128 x 2^n where n is
73*0d1ba665SWarner Losh   /// an integer greater than or equal to zero (e.g., 128, 256, 512, etc.).
74*0d1ba665SWarner Losh   ///
75*0d1ba665SWarner Losh   UINT32            SizeOfPartitionEntry;
76*0d1ba665SWarner Losh   ///
77*0d1ba665SWarner Losh   /// The CRC32 of the GUID Partition Entry array.
78*0d1ba665SWarner Losh   /// Starts at PartitionEntryLBA and is
79*0d1ba665SWarner Losh   /// computed over a byte length of
80*0d1ba665SWarner Losh   /// NumberOfPartitionEntries * SizeOfPartitionEntry.
81*0d1ba665SWarner Losh   ///
82*0d1ba665SWarner Losh   UINT32            PartitionEntryArrayCRC32;
83*0d1ba665SWarner Losh } EFI_PARTITION_TABLE_HEADER;
84*0d1ba665SWarner Losh 
85*0d1ba665SWarner Losh ///
86*0d1ba665SWarner Losh /// GPT Partition Entry.
87*0d1ba665SWarner Losh ///
88*0d1ba665SWarner Losh typedef struct {
89*0d1ba665SWarner Losh   ///
90*0d1ba665SWarner Losh   /// Unique ID that defines the purpose and type of this Partition. A value of
91*0d1ba665SWarner Losh   /// zero defines that this partition entry is not being used.
92*0d1ba665SWarner Losh   ///
93*0d1ba665SWarner Losh   EFI_GUID  PartitionTypeGUID;
94*0d1ba665SWarner Losh   ///
95*0d1ba665SWarner Losh   /// GUID that is unique for every partition entry. Every partition ever
96*0d1ba665SWarner Losh   /// created will have a unique GUID.
97*0d1ba665SWarner Losh   /// This GUID must be assigned when the GUID Partition Entry is created.
98*0d1ba665SWarner Losh   ///
99*0d1ba665SWarner Losh   EFI_GUID  UniquePartitionGUID;
100*0d1ba665SWarner Losh   ///
101*0d1ba665SWarner Losh   /// Starting LBA of the partition defined by this entry
102*0d1ba665SWarner Losh   ///
103*0d1ba665SWarner Losh   EFI_LBA   StartingLBA;
104*0d1ba665SWarner Losh   ///
105*0d1ba665SWarner Losh   /// Ending LBA of the partition defined by this entry.
106*0d1ba665SWarner Losh   ///
107*0d1ba665SWarner Losh   EFI_LBA   EndingLBA;
108*0d1ba665SWarner Losh   ///
109*0d1ba665SWarner Losh   /// Attribute bits, all bits reserved by UEFI
110*0d1ba665SWarner Losh   /// Bit 0:      If this bit is set, the partition is required for the platform to function. The owner/creator of the
111*0d1ba665SWarner Losh   ///             partition indicates that deletion or modification of the contents can result in loss of platform
112*0d1ba665SWarner Losh   ///             features or failure for the platform to boot or operate. The system cannot function normally if
113*0d1ba665SWarner Losh   ///             this partition is removed, and it should be considered part of the hardware of the system.
114*0d1ba665SWarner Losh   ///             Actions such as running diagnostics, system recovery, or even OS install or boot, could
115*0d1ba665SWarner Losh   ///             potentially stop working if this partition is removed. Unless OS software or firmware
116*0d1ba665SWarner Losh   ///             recognizes this partition, it should never be removed or modified as the UEFI firmware or
117*0d1ba665SWarner Losh   ///             platform hardware may become non-functional.
118*0d1ba665SWarner Losh   /// Bit 1:      If this bit is set, then firmware must not produce an EFI_BLOCK_IO_PROTOCOL device for
119*0d1ba665SWarner Losh   ///             this partition. By not producing an EFI_BLOCK_IO_PROTOCOL partition, file system
120*0d1ba665SWarner Losh   ///             mappings will not be created for this partition in UEFI.
121*0d1ba665SWarner Losh   /// Bit 2:      This bit is set aside to let systems with traditional PC-AT BIOS firmware implementations
122*0d1ba665SWarner Losh   ///             inform certain limited, special-purpose software running on these systems that a GPT
123*0d1ba665SWarner Losh   ///             partition may be bootable. The UEFI boot manager must ignore this bit when selecting
124*0d1ba665SWarner Losh   ///             a UEFI-compliant application, e.g., an OS loader.
125*0d1ba665SWarner Losh   /// Bits 3-47:  Undefined and must be zero. Reserved for expansion by future versions of the UEFI
126*0d1ba665SWarner Losh   ///             specification.
127*0d1ba665SWarner Losh   /// Bits 48-63: Reserved for GUID specific use. The use of these bits will vary depending on the
128*0d1ba665SWarner Losh   ///             PartitionTypeGUID. Only the owner of the PartitionTypeGUID is allowed
129*0d1ba665SWarner Losh   ///             to modify these bits. They must be preserved if Bits 0-47 are modified..
130*0d1ba665SWarner Losh   ///
131*0d1ba665SWarner Losh   UINT64    Attributes;
132*0d1ba665SWarner Losh   ///
133*0d1ba665SWarner Losh   /// Null-terminated name of the partition.
134*0d1ba665SWarner Losh   ///
135*0d1ba665SWarner Losh   CHAR16    PartitionName[36];
136*0d1ba665SWarner Losh } EFI_PARTITION_ENTRY;
137*0d1ba665SWarner Losh 
138*0d1ba665SWarner Losh #pragma pack()
139*0d1ba665SWarner Losh #endif
140*0d1ba665SWarner Losh 
141*0d1ba665SWarner Losh 
142