]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[efi] Add partition information protocol header and GUID definition
authorMichael Brown <mcb30@ipxe.org>
Sun, 29 Mar 2026 14:17:55 +0000 (15:17 +0100)
committerMichael Brown <mcb30@ipxe.org>
Sun, 29 Mar 2026 14:23:27 +0000 (15:23 +0100)
Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/include/ipxe/efi/IndustryStandard/Mbr.h [new file with mode: 0644]
src/include/ipxe/efi/Protocol/PartitionInfo.h [new file with mode: 0644]
src/include/ipxe/efi/efi.h
src/interface/efi/efi_guid.c

diff --git a/src/include/ipxe/efi/IndustryStandard/Mbr.h b/src/include/ipxe/efi/IndustryStandard/Mbr.h
new file mode 100644 (file)
index 0000000..b72d64e
--- /dev/null
@@ -0,0 +1,54 @@
+/** @file
+  Legacy Master Boot Record Format Definition.
+
+Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#pragma once
+
+FILE_LICENCE ( BSD2_PATENT );
+FILE_SECBOOT ( PERMITTED );
+
+#define MBR_SIGNATURE  0xaa55
+
+#define EXTENDED_DOS_PARTITION      0x05
+#define EXTENDED_WINDOWS_PARTITION  0x0F
+
+#define MAX_MBR_PARTITIONS  4
+
+#define PMBR_GPT_PARTITION  0xEE
+#define EFI_PARTITION       0xEF
+
+#define MBR_SIZE  512
+
+#pragma pack(1)
+///
+/// MBR Partition Entry
+///
+typedef struct {
+  UINT8    BootIndicator;
+  UINT8    StartHead;
+  UINT8    StartSector;
+  UINT8    StartTrack;
+  UINT8    OSIndicator;
+  UINT8    EndHead;
+  UINT8    EndSector;
+  UINT8    EndTrack;
+  UINT8    StartingLBA[4];
+  UINT8    SizeInLBA[4];
+} MBR_PARTITION_RECORD;
+
+///
+/// MBR Partition Table
+///
+typedef struct {
+  UINT8                   BootStrapCode[440];
+  UINT8                   UniqueMbrSignature[4];
+  UINT8                   Unknown[2];
+  MBR_PARTITION_RECORD    Partition[MAX_MBR_PARTITIONS];
+  UINT16                  Signature;
+} MASTER_BOOT_RECORD;
+
+#pragma pack()
diff --git a/src/include/ipxe/efi/Protocol/PartitionInfo.h b/src/include/ipxe/efi/Protocol/PartitionInfo.h
new file mode 100644 (file)
index 0000000..7a653d5
--- /dev/null
@@ -0,0 +1,67 @@
+/** @file
+  This file defines the EFI Partition Information Protocol.
+
+  Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+
+  @par Revision Reference:
+  This Protocol is introduced in UEFI Specification 2.7
+
+**/
+
+#pragma once
+
+FILE_LICENCE ( BSD2_PATENT );
+FILE_SECBOOT ( PERMITTED );
+
+#include <ipxe/efi/IndustryStandard/Mbr.h>
+#include <ipxe/efi/Uefi/UefiGpt.h>
+
+//
+// EFI Partition Information Protocol GUID value
+//
+#define EFI_PARTITION_INFO_PROTOCOL_GUID \
+  { 0x8cf2f62c, 0xbc9b, 0x4821, { 0x80, 0x8d, 0xec, 0x9e, 0xc4, 0x21, 0xa1, 0xa0 }};
+
+#define EFI_PARTITION_INFO_PROTOCOL_REVISION  0x0001000
+#define PARTITION_TYPE_OTHER                  0x00
+#define PARTITION_TYPE_MBR                    0x01
+#define PARTITION_TYPE_GPT                    0x02
+
+#pragma pack(1)
+
+///
+/// Partition Information Protocol structure.
+///
+typedef struct {
+  //
+  // Set to EFI_PARTITION_INFO_PROTOCOL_REVISION.
+  //
+  UINT32    Revision;
+  //
+  // Partition info type (PARTITION_TYPE_MBR, PARTITION_TYPE_GPT, or PARTITION_TYPE_OTHER).
+  //
+  UINT32    Type;
+  //
+  // If 1, partition describes an EFI System Partition.
+  //
+  UINT8     System;
+  UINT8     Reserved[7];
+  union {
+    ///
+    /// MBR data
+    ///
+    MBR_PARTITION_RECORD    Mbr;
+    ///
+    /// GPT data
+    ///
+    EFI_PARTITION_ENTRY     Gpt;
+  } Info;
+} EFI_PARTITION_INFO_PROTOCOL;
+
+#pragma pack()
+
+///
+/// Partition Information Protocol GUID variable.
+///
+extern EFI_GUID  gEfiPartitionInfoProtocolGuid;
index a73ef0959ed7bb3bd333f00fa3ac2a667005475e..1ecbfcc46a626ee07d131ffadf380175fa71ea48 100644 (file)
@@ -228,6 +228,7 @@ extern EFI_GUID efi_mtftp6_protocol_guid;
 extern EFI_GUID efi_mtftp6_service_binding_protocol_guid;
 extern EFI_GUID efi_nii_protocol_guid;
 extern EFI_GUID efi_nii31_protocol_guid;
+extern EFI_GUID efi_partition_info_protocol_guid;
 extern EFI_GUID efi_pci_io_protocol_guid;
 extern EFI_GUID efi_pci_root_bridge_io_protocol_guid;
 extern EFI_GUID efi_pxe_base_code_protocol_guid;
index c989aebfef5868a95017cc1e5dd5a83f7203ea29..b73c6be4a303c93640d6c72741020491e479028f 100644 (file)
@@ -63,6 +63,7 @@ FILE_SECBOOT ( PERMITTED );
 #include <ipxe/efi/Protocol/Mtftp4.h>
 #include <ipxe/efi/Protocol/Mtftp6.h>
 #include <ipxe/efi/Protocol/NetworkInterfaceIdentifier.h>
+#include <ipxe/efi/Protocol/PartitionInfo.h>
 #include <ipxe/efi/Protocol/PciIo.h>
 #include <ipxe/efi/Protocol/PciRootBridgeIo.h>
 #include <ipxe/efi/Protocol/PxeBaseCode.h>
@@ -308,6 +309,10 @@ EFI_GUID efi_nii_protocol_guid
 EFI_GUID efi_nii31_protocol_guid
        = EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL_GUID_31;
 
+/** Partition information protocol GUID */
+EFI_GUID efi_partition_info_protocol_guid
+       = EFI_PARTITION_INFO_PROTOCOL_GUID;
+
 /** PCI I/O protocol GUID */
 EFI_GUID efi_pci_io_protocol_guid
        = EFI_PCI_IO_PROTOCOL_GUID;
@@ -639,6 +644,8 @@ static struct efi_well_known_guid efi_well_known_guids[] = {
          "Nii" },
        { &efi_nii31_protocol_guid,
          "Nii31" },
+       { &efi_partition_info_protocol_guid,
+         "PartitionInfo" },
        { &efi_pci_io_protocol_guid,
          "PciIo" },
        { &efi_pci_root_bridge_io_protocol_guid,