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