xref: /freebsd/sys/contrib/edk2/Include/Uefi/UefiGpt.h (revision 580fcf642ea2d5a1e60f24947d1c2e97007e44e9)
10d1ba665SWarner Losh /** @file
20d1ba665SWarner Losh   EFI Guid Partition Table Format Definition.
30d1ba665SWarner Losh 
4*3245fa21SMitchell Horne Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>
5*3245fa21SMitchell Horne SPDX-License-Identifier: BSD-2-Clause-Patent
60d1ba665SWarner Losh 
70d1ba665SWarner Losh **/
80d1ba665SWarner Losh 
90d1ba665SWarner Losh #ifndef __UEFI_GPT_H__
100d1ba665SWarner Losh #define __UEFI_GPT_H__
110d1ba665SWarner Losh 
120d1ba665SWarner Losh ///
130d1ba665SWarner Losh /// The primary GUID Partition Table Header must be
140d1ba665SWarner Losh /// located in LBA 1 (i.e., the second logical block).
150d1ba665SWarner Losh ///
160d1ba665SWarner Losh #define PRIMARY_PART_HEADER_LBA  1
170d1ba665SWarner Losh ///
180d1ba665SWarner Losh /// EFI Partition Table Signature: "EFI PART".
190d1ba665SWarner Losh ///
200d1ba665SWarner Losh #define EFI_PTAB_HEADER_ID  SIGNATURE_64 ('E','F','I',' ','P','A','R','T')
21*3245fa21SMitchell Horne ///
22*3245fa21SMitchell Horne /// Minimum bytes reserve for EFI entry array buffer.
23*3245fa21SMitchell Horne ///
24*3245fa21SMitchell Horne #define EFI_GPT_PART_ENTRY_MIN_SIZE  16384
250d1ba665SWarner Losh 
260d1ba665SWarner Losh #pragma pack(1)
270d1ba665SWarner Losh 
280d1ba665SWarner Losh ///
290d1ba665SWarner Losh /// GPT Partition Table Header.
300d1ba665SWarner Losh ///
310d1ba665SWarner Losh typedef struct {
320d1ba665SWarner Losh   ///
330d1ba665SWarner Losh   /// The table header for the GPT partition Table.
340d1ba665SWarner Losh   /// This header contains EFI_PTAB_HEADER_ID.
350d1ba665SWarner Losh   ///
360d1ba665SWarner Losh   EFI_TABLE_HEADER    Header;
370d1ba665SWarner Losh   ///
380d1ba665SWarner Losh   /// The LBA that contains this data structure.
390d1ba665SWarner Losh   ///
400d1ba665SWarner Losh   EFI_LBA             MyLBA;
410d1ba665SWarner Losh   ///
420d1ba665SWarner Losh   /// LBA address of the alternate GUID Partition Table Header.
430d1ba665SWarner Losh   ///
440d1ba665SWarner Losh   EFI_LBA             AlternateLBA;
450d1ba665SWarner Losh   ///
460d1ba665SWarner Losh   /// The first usable logical block that may be used
470d1ba665SWarner Losh   /// by a partition described by a GUID Partition Entry.
480d1ba665SWarner Losh   ///
490d1ba665SWarner Losh   EFI_LBA             FirstUsableLBA;
500d1ba665SWarner Losh   ///
510d1ba665SWarner Losh   /// The last usable logical block that may be used
520d1ba665SWarner Losh   /// by a partition described by a GUID Partition Entry.
530d1ba665SWarner Losh   ///
540d1ba665SWarner Losh   EFI_LBA             LastUsableLBA;
550d1ba665SWarner Losh   ///
560d1ba665SWarner Losh   /// GUID that can be used to uniquely identify the disk.
570d1ba665SWarner Losh   ///
580d1ba665SWarner Losh   EFI_GUID            DiskGUID;
590d1ba665SWarner Losh   ///
600d1ba665SWarner Losh   /// The starting LBA of the GUID Partition Entry array.
610d1ba665SWarner Losh   ///
620d1ba665SWarner Losh   EFI_LBA             PartitionEntryLBA;
630d1ba665SWarner Losh   ///
640d1ba665SWarner Losh   /// The number of Partition Entries in the GUID Partition Entry array.
650d1ba665SWarner Losh   ///
660d1ba665SWarner Losh   UINT32              NumberOfPartitionEntries;
670d1ba665SWarner Losh   ///
680d1ba665SWarner Losh   /// The size, in bytes, of each the GUID Partition
690d1ba665SWarner Losh   /// Entry structures in the GUID Partition Entry
700d1ba665SWarner Losh   /// array. This field shall be set to a value of 128 x 2^n where n is
710d1ba665SWarner Losh   /// an integer greater than or equal to zero (e.g., 128, 256, 512, etc.).
720d1ba665SWarner Losh   ///
730d1ba665SWarner Losh   UINT32              SizeOfPartitionEntry;
740d1ba665SWarner Losh   ///
750d1ba665SWarner Losh   /// The CRC32 of the GUID Partition Entry array.
760d1ba665SWarner Losh   /// Starts at PartitionEntryLBA and is
770d1ba665SWarner Losh   /// computed over a byte length of
780d1ba665SWarner Losh   /// NumberOfPartitionEntries * SizeOfPartitionEntry.
790d1ba665SWarner Losh   ///
800d1ba665SWarner Losh   UINT32              PartitionEntryArrayCRC32;
810d1ba665SWarner Losh } EFI_PARTITION_TABLE_HEADER;
820d1ba665SWarner Losh 
830d1ba665SWarner Losh ///
840d1ba665SWarner Losh /// GPT Partition Entry.
850d1ba665SWarner Losh ///
860d1ba665SWarner Losh typedef struct {
870d1ba665SWarner Losh   ///
880d1ba665SWarner Losh   /// Unique ID that defines the purpose and type of this Partition. A value of
890d1ba665SWarner Losh   /// zero defines that this partition entry is not being used.
900d1ba665SWarner Losh   ///
910d1ba665SWarner Losh   EFI_GUID    PartitionTypeGUID;
920d1ba665SWarner Losh   ///
930d1ba665SWarner Losh   /// GUID that is unique for every partition entry. Every partition ever
940d1ba665SWarner Losh   /// created will have a unique GUID.
950d1ba665SWarner Losh   /// This GUID must be assigned when the GUID Partition Entry is created.
960d1ba665SWarner Losh   ///
970d1ba665SWarner Losh   EFI_GUID    UniquePartitionGUID;
980d1ba665SWarner Losh   ///
990d1ba665SWarner Losh   /// Starting LBA of the partition defined by this entry
1000d1ba665SWarner Losh   ///
1010d1ba665SWarner Losh   EFI_LBA     StartingLBA;
1020d1ba665SWarner Losh   ///
1030d1ba665SWarner Losh   /// Ending LBA of the partition defined by this entry.
1040d1ba665SWarner Losh   ///
1050d1ba665SWarner Losh   EFI_LBA     EndingLBA;
1060d1ba665SWarner Losh   ///
1070d1ba665SWarner Losh   /// Attribute bits, all bits reserved by UEFI
1080d1ba665SWarner Losh   /// Bit 0:      If this bit is set, the partition is required for the platform to function. The owner/creator of the
1090d1ba665SWarner Losh   ///             partition indicates that deletion or modification of the contents can result in loss of platform
1100d1ba665SWarner Losh   ///             features or failure for the platform to boot or operate. The system cannot function normally if
1110d1ba665SWarner Losh   ///             this partition is removed, and it should be considered part of the hardware of the system.
1120d1ba665SWarner Losh   ///             Actions such as running diagnostics, system recovery, or even OS install or boot, could
1130d1ba665SWarner Losh   ///             potentially stop working if this partition is removed. Unless OS software or firmware
1140d1ba665SWarner Losh   ///             recognizes this partition, it should never be removed or modified as the UEFI firmware or
1150d1ba665SWarner Losh   ///             platform hardware may become non-functional.
1160d1ba665SWarner Losh   /// Bit 1:      If this bit is set, then firmware must not produce an EFI_BLOCK_IO_PROTOCOL device for
1170d1ba665SWarner Losh   ///             this partition. By not producing an EFI_BLOCK_IO_PROTOCOL partition, file system
1180d1ba665SWarner Losh   ///             mappings will not be created for this partition in UEFI.
1190d1ba665SWarner Losh   /// Bit 2:      This bit is set aside to let systems with traditional PC-AT BIOS firmware implementations
1200d1ba665SWarner Losh   ///             inform certain limited, special-purpose software running on these systems that a GPT
1210d1ba665SWarner Losh   ///             partition may be bootable. The UEFI boot manager must ignore this bit when selecting
1220d1ba665SWarner Losh   ///             a UEFI-compliant application, e.g., an OS loader.
1230d1ba665SWarner Losh   /// Bits 3-47:  Undefined and must be zero. Reserved for expansion by future versions of the UEFI
1240d1ba665SWarner Losh   ///             specification.
1250d1ba665SWarner Losh   /// Bits 48-63: Reserved for GUID specific use. The use of these bits will vary depending on the
1260d1ba665SWarner Losh   ///             PartitionTypeGUID. Only the owner of the PartitionTypeGUID is allowed
1270d1ba665SWarner Losh   ///             to modify these bits. They must be preserved if Bits 0-47 are modified..
1280d1ba665SWarner Losh   ///
1290d1ba665SWarner Losh   UINT64    Attributes;
1300d1ba665SWarner Losh   ///
1310d1ba665SWarner Losh   /// Null-terminated name of the partition.
1320d1ba665SWarner Losh   ///
1330d1ba665SWarner Losh   CHAR16    PartitionName[36];
1340d1ba665SWarner Losh } EFI_PARTITION_ENTRY;
1350d1ba665SWarner Losh 
1360d1ba665SWarner Losh #pragma pack()
1370d1ba665SWarner Losh #endif
138