]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/Disk/PartitionDxe/Gpt.c
MdeModulePkg/PartitionDxe: Add impl of Partition Information Protocol
[mirror_edk2.git] / MdeModulePkg / Universal / Disk / PartitionDxe / Gpt.c
index 35860515c13b9da3284b2a5f0d5c57cad2032016..2cd3e15e8acbcf49b07615dc4b184df0b64d7495 100644 (file)
@@ -13,7 +13,7 @@
   PartitionValidGptTable(), PartitionCheckGptEntry() routine will accept disk\r
   partition content and validate the GPT table and GPT entry.\r
 \r
-Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -205,19 +205,20 @@ PartitionInstallGptChildHandles (
   IN  EFI_DEVICE_PATH_PROTOCOL     *DevicePath\r
   )\r
 {\r
-  EFI_STATUS                  Status;\r
-  UINT32                      BlockSize;\r
-  EFI_LBA                     LastBlock;\r
-  MASTER_BOOT_RECORD          *ProtectiveMbr;\r
-  EFI_PARTITION_TABLE_HEADER  *PrimaryHeader;\r
-  EFI_PARTITION_TABLE_HEADER  *BackupHeader;\r
-  EFI_PARTITION_ENTRY         *PartEntry;\r
-  EFI_PARTITION_ENTRY         *Entry;\r
-  EFI_PARTITION_ENTRY_STATUS  *PEntryStatus;\r
-  UINTN                       Index;\r
-  EFI_STATUS                  GptValidStatus;\r
-  HARDDRIVE_DEVICE_PATH       HdDev;\r
-  UINT32                      MediaId;\r
+  EFI_STATUS                   Status;\r
+  UINT32                       BlockSize;\r
+  EFI_LBA                      LastBlock;\r
+  MASTER_BOOT_RECORD           *ProtectiveMbr;\r
+  EFI_PARTITION_TABLE_HEADER   *PrimaryHeader;\r
+  EFI_PARTITION_TABLE_HEADER   *BackupHeader;\r
+  EFI_PARTITION_ENTRY          *PartEntry;\r
+  EFI_PARTITION_ENTRY          *Entry;\r
+  EFI_PARTITION_ENTRY_STATUS   *PEntryStatus;\r
+  UINTN                        Index;\r
+  EFI_STATUS                   GptValidStatus;\r
+  HARDDRIVE_DEVICE_PATH        HdDev;\r
+  UINT32                       MediaId;\r
+  EFI_PARTITION_INFO_PROTOCOL  PartitionInfo;\r
 \r
   ProtectiveMbr = NULL;\r
   PrimaryHeader = NULL;\r
@@ -380,17 +381,25 @@ PartitionInstallGptChildHandles (
     }\r
 \r
     ZeroMem (&HdDev, sizeof (HdDev));\r
-    HdDev.Header.Type     = MEDIA_DEVICE_PATH;\r
-    HdDev.Header.SubType  = MEDIA_HARDDRIVE_DP;\r
+    HdDev.Header.Type      = MEDIA_DEVICE_PATH;\r
+    HdDev.Header.SubType   = MEDIA_HARDDRIVE_DP;\r
     SetDevicePathNodeLength (&HdDev.Header, sizeof (HdDev));\r
 \r
-    HdDev.PartitionNumber = (UINT32) Index + 1;\r
-    HdDev.MBRType         = MBR_TYPE_EFI_PARTITION_TABLE_HEADER;\r
-    HdDev.SignatureType   = SIGNATURE_TYPE_GUID;\r
-    HdDev.PartitionStart  = Entry->StartingLBA;\r
-    HdDev.PartitionSize   = Entry->EndingLBA - Entry->StartingLBA + 1;\r
+    HdDev.PartitionNumber  = (UINT32) Index + 1;\r
+    HdDev.MBRType          = MBR_TYPE_EFI_PARTITION_TABLE_HEADER;\r
+    HdDev.SignatureType    = SIGNATURE_TYPE_GUID;\r
+    HdDev.PartitionStart   = Entry->StartingLBA;\r
+    HdDev.PartitionSize    = Entry->EndingLBA - Entry->StartingLBA + 1;\r
     CopyMem (HdDev.Signature, &Entry->UniquePartitionGUID, sizeof (EFI_GUID));\r
 \r
+    ZeroMem (&PartitionInfo, sizeof (EFI_PARTITION_INFO_PROTOCOL));\r
+    PartitionInfo.Revision = EFI_PARTITION_INFO_PROTOCOL_REVISION;\r
+    PartitionInfo.Type     = PARTITION_TYPE_GPT;\r
+    if (CompareGuid (&Entry->PartitionTypeGUID, &gEfiPartTypeSystemPartGuid)) {\r
+      PartitionInfo.System = 1;\r
+    }\r
+    CopyMem (&PartitionInfo.Info.Gpt, Entry, sizeof (EFI_PARTITION_ENTRY));\r
+\r
     DEBUG ((EFI_D_INFO, " Index : %d\n", (UINT32) Index));\r
     DEBUG ((EFI_D_INFO, " Start LBA : %lx\n", (UINT64) HdDev.PartitionStart));\r
     DEBUG ((EFI_D_INFO, " End LBA : %lx\n", (UINT64) Entry->EndingLBA));\r
@@ -407,10 +416,10 @@ PartitionInstallGptChildHandles (
                BlockIo2,\r
                DevicePath,\r
                (EFI_DEVICE_PATH_PROTOCOL *) &HdDev,\r
+               &PartitionInfo,\r
                Entry->StartingLBA,\r
                Entry->EndingLBA,\r
-               BlockSize,\r
-               CompareGuid(&Entry->PartitionTypeGUID, &gEfiPartTypeSystemPartGuid)\r
+               BlockSize\r
                );\r
   }\r
 \r