* [PATCH 0/2] Add EFI Partition Information Protocol @ 2017-06-22 8:44 Hao Wu 2017-06-22 8:44 ` [PATCH 1/2] MdePkg: Add EFI Partition Information Protocol definitions Hao Wu 2017-06-22 8:44 ` [PATCH 2/2] MdeModulePkg/PartitionDxe: Add impl of Partition Information Protocol Hao Wu 0 siblings, 2 replies; 6+ messages in thread From: Hao Wu @ 2017-06-22 8:44 UTC (permalink / raw) To: edk2-devel; +Cc: Hao Wu, Ruiyu Ni Add the EFI Partition Information Protocol per the latest UEFI spec. Test for the series: A simple application called 'DumpPartInfo' is used to dump the contents of the Partition Information protocols when the following devices are attached: a. MBR Hard disk b. GPT Hard disk c. CDROM The source of the application and the series is available at: https://github.com/hwu25/edk2 branch:partition_info_test Cc: Ruiyu Ni <ruiyu.ni@intel.com> Hao Wu (2): MdePkg: Add EFI Partition Information Protocol definitions MdeModulePkg/PartitionDxe: Add impl of Partition Information Protocol MdeModulePkg/Universal/Disk/PartitionDxe/ElTorito.c | 43 ++++++----- MdeModulePkg/Universal/Disk/PartitionDxe/Gpt.c | 55 ++++++++------ MdeModulePkg/Universal/Disk/PartitionDxe/Mbr.c | 51 ++++++++----- MdeModulePkg/Universal/Disk/PartitionDxe/Partition.c | 23 ++++-- MdeModulePkg/Universal/Disk/PartitionDxe/Partition.h | 48 ++++++------ MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.inf | 3 +- MdePkg/Include/Protocol/PartitionInfo.h | 78 ++++++++++++++++++++ MdePkg/MdePkg.dec | 3 + 8 files changed, 216 insertions(+), 88 deletions(-) create mode 100644 MdePkg/Include/Protocol/PartitionInfo.h -- 2.12.0.windows.1 ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/2] MdePkg: Add EFI Partition Information Protocol definitions 2017-06-22 8:44 [PATCH 0/2] Add EFI Partition Information Protocol Hao Wu @ 2017-06-22 8:44 ` Hao Wu 2017-07-07 2:26 ` Ni, Ruiyu 2017-06-22 8:44 ` [PATCH 2/2] MdeModulePkg/PartitionDxe: Add impl of Partition Information Protocol Hao Wu 1 sibling, 1 reply; 6+ messages in thread From: Hao Wu @ 2017-06-22 8:44 UTC (permalink / raw) To: edk2-devel; +Cc: Hao Wu, Ruiyu Ni, Michael D Kinney, Liming Gao Cc: Ruiyu Ni <ruiyu.ni@intel.com> Cc: Michael D Kinney <michael.d.kinney@intel.com> Cc: Liming Gao <liming.gao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Hao Wu <hao.a.wu@intel.com> --- MdePkg/Include/Protocol/PartitionInfo.h | 78 ++++++++++++++++++++ MdePkg/MdePkg.dec | 3 + 2 files changed, 81 insertions(+) diff --git a/MdePkg/Include/Protocol/PartitionInfo.h b/MdePkg/Include/Protocol/PartitionInfo.h new file mode 100644 index 0000000000..60e46456c6 --- /dev/null +++ b/MdePkg/Include/Protocol/PartitionInfo.h @@ -0,0 +1,78 @@ +/** @file + This file defines the EFI Partition Information Protocol. + + Copyright (c) 2017, Intel Corporation. All rights reserved.<BR> + This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + @par Revision Reference: + This Protocol is introduced in UEFI Specification 2.7 + +**/ + +#ifndef __PARTITION_INFO_PROTOCOL_H__ +#define __PARTITION_INFO_PROTOCOL_H__ + +#include <IndustryStandard/Mbr.h> +#include <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 }}; + +// +// Forward reference for pure ANSI compatability +// +typedef struct _EFI_PARTITION_INFO_PROTOCOL EFI_PARTITION_INFO_PROTOCOL; + +#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. +/// +struct _EFI_PARTITION_INFO_PROTOCOL { + // + // 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; +}; + +#pragma pack() + +/// +/// Partition Information Protocol GUID variable. +/// +extern EFI_GUID gEfiPartitionInfoProtocolGuid; + +#endif diff --git a/MdePkg/MdePkg.dec b/MdePkg/MdePkg.dec index 7a7504b7a3..c48f248526 100644 --- a/MdePkg/MdePkg.dec +++ b/MdePkg/MdePkg.dec @@ -1671,6 +1671,9 @@ ## Include/Protocol/BluetoothLeConfig.h gEfiBluetoothLeConfigProtocolGuid = { 0x8f76da58, 0x1f99, 0x4275, { 0xa4, 0xec, 0x47, 0x56, 0x51, 0x5b, 0x1c, 0xe8 } } + ## Include/Protocol/PartitionInfo.h + gEfiPartitionInfoProtocolGuid = { 0x8cf2f62c, 0xbc9b, 0x4821, { 0x80, 0x8d, 0xec, 0x9e, 0xc4, 0x21, 0xa1, 0xa0 }} + # # Protocols defined in Shell2.0 # -- 2.12.0.windows.1 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] MdePkg: Add EFI Partition Information Protocol definitions 2017-06-22 8:44 ` [PATCH 1/2] MdePkg: Add EFI Partition Information Protocol definitions Hao Wu @ 2017-07-07 2:26 ` Ni, Ruiyu 2017-07-07 5:40 ` Wu, Hao A 0 siblings, 1 reply; 6+ messages in thread From: Ni, Ruiyu @ 2017-07-07 2:26 UTC (permalink / raw) To: Wu, Hao A Cc: Ni, Ruiyu, Kinney, Michael D, Gao, Liming, edk2-devel@lists.01.org Minor comment: Why uses forward reference for structure EFI_PARTITION_INFO_PROTOCOL? The forward reference is because some protocol interfaces need the pointer of protocol structure as This parameter. I think you can directly use typedef struct {...} EFI_PARTITION_INFO_PROTOCOL. Thanks/Ray > -----Original Message----- > From: Wu, Hao A > Sent: Thursday, June 22, 2017 4:45 PM > To: edk2-devel@lists.01.org > Cc: Wu, Hao A <hao.a.wu@intel.com>; Ni, Ruiyu <ruiyu.ni@intel.com>; > Kinney, Michael D <michael.d.kinney@intel.com>; Gao, Liming > <liming.gao@intel.com> > Subject: [PATCH 1/2] MdePkg: Add EFI Partition Information Protocol > definitions > > Cc: Ruiyu Ni <ruiyu.ni@intel.com> > Cc: Michael D Kinney <michael.d.kinney@intel.com> > Cc: Liming Gao <liming.gao@intel.com> > Contributed-under: TianoCore Contribution Agreement 1.0 > Signed-off-by: Hao Wu <hao.a.wu@intel.com> > --- > MdePkg/Include/Protocol/PartitionInfo.h | 78 ++++++++++++++++++++ > MdePkg/MdePkg.dec | 3 + > 2 files changed, 81 insertions(+) > > diff --git a/MdePkg/Include/Protocol/PartitionInfo.h > b/MdePkg/Include/Protocol/PartitionInfo.h > new file mode 100644 > index 0000000000..60e46456c6 > --- /dev/null > +++ b/MdePkg/Include/Protocol/PartitionInfo.h > @@ -0,0 +1,78 @@ > +/** @file > + This file defines the EFI Partition Information Protocol. > + > + Copyright (c) 2017, Intel Corporation. All rights reserved.<BR> This > + program and the accompanying materials are licensed and made > + available under the terms and conditions of the BSD License which > + accompanies this distribution. The full text of the license may be > + found at http://opensource.org/licenses/bsd-license.php > + > + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" > BASIS, > + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER > EXPRESS OR IMPLIED. > + > + @par Revision Reference: > + This Protocol is introduced in UEFI Specification 2.7 > + > +**/ > + > +#ifndef __PARTITION_INFO_PROTOCOL_H__ > +#define __PARTITION_INFO_PROTOCOL_H__ > + > +#include <IndustryStandard/Mbr.h> > +#include <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 }}; > + > +// > +// Forward reference for pure ANSI compatability // typedef struct > +_EFI_PARTITION_INFO_PROTOCOL EFI_PARTITION_INFO_PROTOCOL; > + > +#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. > +/// > +struct _EFI_PARTITION_INFO_PROTOCOL { > + // > + // 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; > +}; > + > +#pragma pack() > + > +/// > +/// Partition Information Protocol GUID variable. > +/// > +extern EFI_GUID gEfiPartitionInfoProtocolGuid; > + > +#endif > diff --git a/MdePkg/MdePkg.dec b/MdePkg/MdePkg.dec index > 7a7504b7a3..c48f248526 100644 > --- a/MdePkg/MdePkg.dec > +++ b/MdePkg/MdePkg.dec > @@ -1671,6 +1671,9 @@ > ## Include/Protocol/BluetoothLeConfig.h > gEfiBluetoothLeConfigProtocolGuid = { 0x8f76da58, 0x1f99, 0x4275, > { 0xa4, 0xec, 0x47, 0x56, 0x51, 0x5b, 0x1c, 0xe8 } } > > + ## Include/Protocol/PartitionInfo.h > + gEfiPartitionInfoProtocolGuid = { 0x8cf2f62c, 0xbc9b, 0x4821, { 0x80, > 0x8d, 0xec, 0x9e, 0xc4, 0x21, 0xa1, 0xa0 }} > + > # > # Protocols defined in Shell2.0 > # > -- > 2.12.0.windows.1 ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] MdePkg: Add EFI Partition Information Protocol definitions 2017-07-07 2:26 ` Ni, Ruiyu @ 2017-07-07 5:40 ` Wu, Hao A 0 siblings, 0 replies; 6+ messages in thread From: Wu, Hao A @ 2017-07-07 5:40 UTC (permalink / raw) To: Ni, Ruiyu; +Cc: Kinney, Michael D, Gao, Liming, edk2-devel@lists.01.org > -----Original Message----- > From: Ni, Ruiyu > Sent: Friday, July 07, 2017 10:27 AM > To: Wu, Hao A > Cc: Ni, Ruiyu; Kinney, Michael D; Gao, Liming; edk2-devel@lists.01.org > Subject: RE: [PATCH 1/2] MdePkg: Add EFI Partition Information Protocol > definitions > > Minor comment: > Why uses forward reference for structure EFI_PARTITION_INFO_PROTOCOL? > The forward reference is because some protocol interfaces need the pointer of > protocol structure as This parameter. > I think you can directly use typedef struct {...} EFI_PARTITION_INFO_PROTOCOL. > Got it. Sent a V2 patch according to the comment. Best Regards, Hao Wu > Thanks/Ray > > > -----Original Message----- > > From: Wu, Hao A > > Sent: Thursday, June 22, 2017 4:45 PM > > To: edk2-devel@lists.01.org > > Cc: Wu, Hao A <hao.a.wu@intel.com>; Ni, Ruiyu <ruiyu.ni@intel.com>; > > Kinney, Michael D <michael.d.kinney@intel.com>; Gao, Liming > > <liming.gao@intel.com> > > Subject: [PATCH 1/2] MdePkg: Add EFI Partition Information Protocol > > definitions > > > > Cc: Ruiyu Ni <ruiyu.ni@intel.com> > > Cc: Michael D Kinney <michael.d.kinney@intel.com> > > Cc: Liming Gao <liming.gao@intel.com> > > Contributed-under: TianoCore Contribution Agreement 1.0 > > Signed-off-by: Hao Wu <hao.a.wu@intel.com> > > --- > > MdePkg/Include/Protocol/PartitionInfo.h | 78 ++++++++++++++++++++ > > MdePkg/MdePkg.dec | 3 + > > 2 files changed, 81 insertions(+) > > > > diff --git a/MdePkg/Include/Protocol/PartitionInfo.h > > b/MdePkg/Include/Protocol/PartitionInfo.h > > new file mode 100644 > > index 0000000000..60e46456c6 > > --- /dev/null > > +++ b/MdePkg/Include/Protocol/PartitionInfo.h > > @@ -0,0 +1,78 @@ > > +/** @file > > + This file defines the EFI Partition Information Protocol. > > + > > + Copyright (c) 2017, Intel Corporation. All rights reserved.<BR> This > > + program and the accompanying materials are licensed and made > > + available under the terms and conditions of the BSD License which > > + accompanies this distribution. The full text of the license may be > > + found at http://opensource.org/licenses/bsd-license.php > > + > > + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" > > BASIS, > > + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER > > EXPRESS OR IMPLIED. > > + > > + @par Revision Reference: > > + This Protocol is introduced in UEFI Specification 2.7 > > + > > +**/ > > + > > +#ifndef __PARTITION_INFO_PROTOCOL_H__ > > +#define __PARTITION_INFO_PROTOCOL_H__ > > + > > +#include <IndustryStandard/Mbr.h> > > +#include <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 }}; > > + > > +// > > +// Forward reference for pure ANSI compatability // typedef struct > > +_EFI_PARTITION_INFO_PROTOCOL EFI_PARTITION_INFO_PROTOCOL; > > + > > +#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. > > +/// > > +struct _EFI_PARTITION_INFO_PROTOCOL { > > + // > > + // 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; > > +}; > > + > > +#pragma pack() > > + > > +/// > > +/// Partition Information Protocol GUID variable. > > +/// > > +extern EFI_GUID gEfiPartitionInfoProtocolGuid; > > + > > +#endif > > diff --git a/MdePkg/MdePkg.dec b/MdePkg/MdePkg.dec index > > 7a7504b7a3..c48f248526 100644 > > --- a/MdePkg/MdePkg.dec > > +++ b/MdePkg/MdePkg.dec > > @@ -1671,6 +1671,9 @@ > > ## Include/Protocol/BluetoothLeConfig.h > > gEfiBluetoothLeConfigProtocolGuid = { 0x8f76da58, 0x1f99, 0x4275, > > { 0xa4, 0xec, 0x47, 0x56, 0x51, 0x5b, 0x1c, 0xe8 } } > > > > + ## Include/Protocol/PartitionInfo.h > > + gEfiPartitionInfoProtocolGuid = { 0x8cf2f62c, 0xbc9b, 0x4821, { 0x80, > > 0x8d, 0xec, 0x9e, 0xc4, 0x21, 0xa1, 0xa0 }} > > + > > # > > # Protocols defined in Shell2.0 > > # > > -- > > 2.12.0.windows.1 ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 2/2] MdeModulePkg/PartitionDxe: Add impl of Partition Information Protocol 2017-06-22 8:44 [PATCH 0/2] Add EFI Partition Information Protocol Hao Wu 2017-06-22 8:44 ` [PATCH 1/2] MdePkg: Add EFI Partition Information Protocol definitions Hao Wu @ 2017-06-22 8:44 ` Hao Wu 2017-07-07 2:24 ` Ni, Ruiyu 1 sibling, 1 reply; 6+ messages in thread From: Hao Wu @ 2017-06-22 8:44 UTC (permalink / raw) To: edk2-devel; +Cc: Hao Wu, Ruiyu Ni, Bret Barkelew Cc: Ruiyu Ni <ruiyu.ni@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Bret Barkelew <brbarkel@microsoft.com> Signed-off-by: Hao Wu <hao.a.wu@intel.com> --- MdeModulePkg/Universal/Disk/PartitionDxe/ElTorito.c | 43 ++++++++------- MdeModulePkg/Universal/Disk/PartitionDxe/Gpt.c | 55 ++++++++++++-------- MdeModulePkg/Universal/Disk/PartitionDxe/Mbr.c | 51 ++++++++++++------ MdeModulePkg/Universal/Disk/PartitionDxe/Partition.c | 23 ++++++-- MdeModulePkg/Universal/Disk/PartitionDxe/Partition.h | 48 +++++++++-------- MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.inf | 3 +- 6 files changed, 135 insertions(+), 88 deletions(-) diff --git a/MdeModulePkg/Universal/Disk/PartitionDxe/ElTorito.c b/MdeModulePkg/Universal/Disk/PartitionDxe/ElTorito.c index 2af38429dd..2084ee5abe 100644 --- a/MdeModulePkg/Universal/Disk/PartitionDxe/ElTorito.c +++ b/MdeModulePkg/Universal/Disk/PartitionDxe/ElTorito.c @@ -1,7 +1,7 @@ /** @file Decode an El Torito formatted CD-ROM -Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR> +Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR> This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -44,22 +44,23 @@ PartitionInstallElToritoChildHandles ( IN EFI_DEVICE_PATH_PROTOCOL *DevicePath ) { - EFI_STATUS Status; - UINT64 VolDescriptorOffset; - UINT32 Lba2KB; - EFI_BLOCK_IO_MEDIA *Media; - CDROM_VOLUME_DESCRIPTOR *VolDescriptor; - ELTORITO_CATALOG *Catalog; - UINTN Check; - UINTN Index; - UINTN BootEntry; - UINTN MaxIndex; - UINT16 *CheckBuffer; - CDROM_DEVICE_PATH CdDev; - UINT32 SubBlockSize; - UINT32 SectorCount; - EFI_STATUS Found; - UINT32 VolSpaceSize; + EFI_STATUS Status; + UINT64 VolDescriptorOffset; + UINT32 Lba2KB; + EFI_BLOCK_IO_MEDIA *Media; + CDROM_VOLUME_DESCRIPTOR *VolDescriptor; + ELTORITO_CATALOG *Catalog; + UINTN Check; + UINTN Index; + UINTN BootEntry; + UINTN MaxIndex; + UINT16 *CheckBuffer; + CDROM_DEVICE_PATH CdDev; + UINT32 SubBlockSize; + UINT32 SectorCount; + EFI_STATUS Found; + UINT32 VolSpaceSize; + EFI_PARTITION_INFO_PROTOCOL PartitionInfo; Found = EFI_NOT_FOUND; Media = BlockIo->Media; @@ -248,6 +249,10 @@ PartitionInstallElToritoChildHandles ( ); } + ZeroMem (&PartitionInfo, sizeof (EFI_PARTITION_INFO_PROTOCOL)); + PartitionInfo.Revision = EFI_PARTITION_INFO_PROTOCOL_REVISION; + PartitionInfo.Type = PARTITION_TYPE_OTHER; + Status = PartitionInstallChildHandle ( This, Handle, @@ -257,10 +262,10 @@ PartitionInstallElToritoChildHandles ( BlockIo2, DevicePath, (EFI_DEVICE_PATH_PROTOCOL *) &CdDev, + &PartitionInfo, Catalog->Boot.Lba * (SIZE_2KB / Media->BlockSize), Catalog->Boot.Lba * (SIZE_2KB / Media->BlockSize) + CdDev.PartitionSize - 1, - SubBlockSize, - FALSE + SubBlockSize ); if (!EFI_ERROR (Status)) { Found = EFI_SUCCESS; diff --git a/MdeModulePkg/Universal/Disk/PartitionDxe/Gpt.c b/MdeModulePkg/Universal/Disk/PartitionDxe/Gpt.c index 35860515c1..2cd3e15e8a 100644 --- a/MdeModulePkg/Universal/Disk/PartitionDxe/Gpt.c +++ b/MdeModulePkg/Universal/Disk/PartitionDxe/Gpt.c @@ -13,7 +13,7 @@ PartitionValidGptTable(), PartitionCheckGptEntry() routine will accept disk partition content and validate the GPT table and GPT entry. -Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR> +Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR> This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -205,19 +205,20 @@ PartitionInstallGptChildHandles ( IN EFI_DEVICE_PATH_PROTOCOL *DevicePath ) { - EFI_STATUS Status; - UINT32 BlockSize; - EFI_LBA LastBlock; - MASTER_BOOT_RECORD *ProtectiveMbr; - EFI_PARTITION_TABLE_HEADER *PrimaryHeader; - EFI_PARTITION_TABLE_HEADER *BackupHeader; - EFI_PARTITION_ENTRY *PartEntry; - EFI_PARTITION_ENTRY *Entry; - EFI_PARTITION_ENTRY_STATUS *PEntryStatus; - UINTN Index; - EFI_STATUS GptValidStatus; - HARDDRIVE_DEVICE_PATH HdDev; - UINT32 MediaId; + EFI_STATUS Status; + UINT32 BlockSize; + EFI_LBA LastBlock; + MASTER_BOOT_RECORD *ProtectiveMbr; + EFI_PARTITION_TABLE_HEADER *PrimaryHeader; + EFI_PARTITION_TABLE_HEADER *BackupHeader; + EFI_PARTITION_ENTRY *PartEntry; + EFI_PARTITION_ENTRY *Entry; + EFI_PARTITION_ENTRY_STATUS *PEntryStatus; + UINTN Index; + EFI_STATUS GptValidStatus; + HARDDRIVE_DEVICE_PATH HdDev; + UINT32 MediaId; + EFI_PARTITION_INFO_PROTOCOL PartitionInfo; ProtectiveMbr = NULL; PrimaryHeader = NULL; @@ -380,17 +381,25 @@ PartitionInstallGptChildHandles ( } ZeroMem (&HdDev, sizeof (HdDev)); - HdDev.Header.Type = MEDIA_DEVICE_PATH; - HdDev.Header.SubType = MEDIA_HARDDRIVE_DP; + HdDev.Header.Type = MEDIA_DEVICE_PATH; + HdDev.Header.SubType = MEDIA_HARDDRIVE_DP; SetDevicePathNodeLength (&HdDev.Header, sizeof (HdDev)); - HdDev.PartitionNumber = (UINT32) Index + 1; - HdDev.MBRType = MBR_TYPE_EFI_PARTITION_TABLE_HEADER; - HdDev.SignatureType = SIGNATURE_TYPE_GUID; - HdDev.PartitionStart = Entry->StartingLBA; - HdDev.PartitionSize = Entry->EndingLBA - Entry->StartingLBA + 1; + HdDev.PartitionNumber = (UINT32) Index + 1; + HdDev.MBRType = MBR_TYPE_EFI_PARTITION_TABLE_HEADER; + HdDev.SignatureType = SIGNATURE_TYPE_GUID; + HdDev.PartitionStart = Entry->StartingLBA; + HdDev.PartitionSize = Entry->EndingLBA - Entry->StartingLBA + 1; CopyMem (HdDev.Signature, &Entry->UniquePartitionGUID, sizeof (EFI_GUID)); + ZeroMem (&PartitionInfo, sizeof (EFI_PARTITION_INFO_PROTOCOL)); + PartitionInfo.Revision = EFI_PARTITION_INFO_PROTOCOL_REVISION; + PartitionInfo.Type = PARTITION_TYPE_GPT; + if (CompareGuid (&Entry->PartitionTypeGUID, &gEfiPartTypeSystemPartGuid)) { + PartitionInfo.System = 1; + } + CopyMem (&PartitionInfo.Info.Gpt, Entry, sizeof (EFI_PARTITION_ENTRY)); + DEBUG ((EFI_D_INFO, " Index : %d\n", (UINT32) Index)); DEBUG ((EFI_D_INFO, " Start LBA : %lx\n", (UINT64) HdDev.PartitionStart)); DEBUG ((EFI_D_INFO, " End LBA : %lx\n", (UINT64) Entry->EndingLBA)); @@ -407,10 +416,10 @@ PartitionInstallGptChildHandles ( BlockIo2, DevicePath, (EFI_DEVICE_PATH_PROTOCOL *) &HdDev, + &PartitionInfo, Entry->StartingLBA, Entry->EndingLBA, - BlockSize, - CompareGuid(&Entry->PartitionTypeGUID, &gEfiPartTypeSystemPartGuid) + BlockSize ); } diff --git a/MdeModulePkg/Universal/Disk/PartitionDxe/Mbr.c b/MdeModulePkg/Universal/Disk/PartitionDxe/Mbr.c index 377fb19319..55e9d26bae 100644 --- a/MdeModulePkg/Universal/Disk/PartitionDxe/Mbr.c +++ b/MdeModulePkg/Universal/Disk/PartitionDxe/Mbr.c @@ -12,7 +12,7 @@ the legacy boot strap code. Copyright (c) 2014, Hewlett-Packard Development Company, L.P.<BR> -Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR> +Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR> This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -129,18 +129,19 @@ PartitionInstallMbrChildHandles ( IN EFI_DEVICE_PATH_PROTOCOL *DevicePath ) { - EFI_STATUS Status; - MASTER_BOOT_RECORD *Mbr; - UINT32 ExtMbrStartingLba; - UINT32 Index; - HARDDRIVE_DEVICE_PATH HdDev; - HARDDRIVE_DEVICE_PATH ParentHdDev; - EFI_STATUS Found; - EFI_DEVICE_PATH_PROTOCOL *DevicePathNode; - EFI_DEVICE_PATH_PROTOCOL *LastDevicePathNode; - UINT32 BlockSize; - UINT32 MediaId; - EFI_LBA LastBlock; + EFI_STATUS Status; + MASTER_BOOT_RECORD *Mbr; + UINT32 ExtMbrStartingLba; + UINT32 Index; + HARDDRIVE_DEVICE_PATH HdDev; + HARDDRIVE_DEVICE_PATH ParentHdDev; + EFI_STATUS Found; + EFI_DEVICE_PATH_PROTOCOL *DevicePathNode; + EFI_DEVICE_PATH_PROTOCOL *LastDevicePathNode; + UINT32 BlockSize; + UINT32 MediaId; + EFI_LBA LastBlock; + EFI_PARTITION_INFO_PROTOCOL PartitionInfo; Found = EFI_NOT_FOUND; @@ -225,6 +226,14 @@ PartitionInstallMbrChildHandles ( HdDev.PartitionSize = UNPACK_UINT32 (Mbr->Partition[Index].SizeInLBA); CopyMem (HdDev.Signature, &(Mbr->UniqueMbrSignature[0]), sizeof (Mbr->UniqueMbrSignature)); + ZeroMem (&PartitionInfo, sizeof (EFI_PARTITION_INFO_PROTOCOL)); + PartitionInfo.Revision = EFI_PARTITION_INFO_PROTOCOL_REVISION; + PartitionInfo.Type = PARTITION_TYPE_MBR; + if (Mbr->Partition[Index].OSIndicator == EFI_PARTITION) { + PartitionInfo.System = 1; + } + CopyMem (&PartitionInfo.Info.Mbr, &Mbr->Partition[Index], sizeof (MBR_PARTITION_RECORD)); + Status = PartitionInstallChildHandle ( This, Handle, @@ -234,10 +243,10 @@ PartitionInstallMbrChildHandles ( BlockIo2, DevicePath, (EFI_DEVICE_PATH_PROTOCOL *) &HdDev, + &PartitionInfo, HdDev.PartitionStart, HdDev.PartitionStart + HdDev.PartitionSize - 1, - MBR_SIZE, - (BOOLEAN) (Mbr->Partition[Index].OSIndicator == EFI_PARTITION) + MBR_SIZE ); if (!EFI_ERROR (Status)) { @@ -288,6 +297,14 @@ PartitionInstallMbrChildHandles ( // *((UINT32 *) &HdDev.Signature[0]) = 0; + ZeroMem (&PartitionInfo, sizeof (EFI_PARTITION_INFO_PROTOCOL)); + PartitionInfo.Revision = EFI_PARTITION_INFO_PROTOCOL_REVISION; + PartitionInfo.Type = PARTITION_TYPE_MBR; + if (Mbr->Partition[0].OSIndicator == EFI_PARTITION) { + PartitionInfo.System = 1; + } + CopyMem (&PartitionInfo.Info.Mbr, &Mbr->Partition[0], sizeof (MBR_PARTITION_RECORD)); + Status = PartitionInstallChildHandle ( This, Handle, @@ -297,10 +314,10 @@ PartitionInstallMbrChildHandles ( BlockIo2, DevicePath, (EFI_DEVICE_PATH_PROTOCOL *) &HdDev, + &PartitionInfo, HdDev.PartitionStart - ParentHdDev.PartitionStart, HdDev.PartitionStart - ParentHdDev.PartitionStart + HdDev.PartitionSize - 1, - MBR_SIZE, - (BOOLEAN) (Mbr->Partition[0].OSIndicator == EFI_PARTITION) + MBR_SIZE ); if (!EFI_ERROR (Status)) { Found = EFI_SUCCESS; diff --git a/MdeModulePkg/Universal/Disk/PartitionDxe/Partition.c b/MdeModulePkg/Universal/Disk/PartitionDxe/Partition.c index 1c53bf0233..5a7d119b43 100644 --- a/MdeModulePkg/Universal/Disk/PartitionDxe/Partition.c +++ b/MdeModulePkg/Universal/Disk/PartitionDxe/Partition.c @@ -4,7 +4,7 @@ of the raw block devices media. Currently "El Torito CD-ROM", Legacy MBR, and GPT partition schemes are supported. -Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR> +Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR> This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -514,6 +514,8 @@ PartitionDriverBindingStop ( &Private->BlockIo, &gEfiBlockIo2ProtocolGuid, &Private->BlockIo2, + &gEfiPartitionInfoProtocolGuid, + &Private->PartitionInfo, Private->EspGuid, NULL, NULL @@ -526,6 +528,8 @@ PartitionDriverBindingStop ( Private->DevicePath, &gEfiBlockIoProtocolGuid, &Private->BlockIo, + &gEfiPartitionInfoProtocolGuid, + &Private->PartitionInfo, Private->EspGuid, NULL, NULL @@ -1092,10 +1096,10 @@ PartitionFlushBlocksEx ( @param[in] ParentBlockIo2 Parent BlockIo2 interface. @param[in] ParentDevicePath Parent Device Path. @param[in] DevicePathNode Child Device Path node. + @param[in] PartitionInfo Child Partition Information interface. @param[in] Start Start Block. @param[in] End End Block. @param[in] BlockSize Child block size. - @param[in] InstallEspGuid Flag to install EFI System Partition GUID on handle. @retval EFI_SUCCESS A child handle was added. @retval other A child handle was not added. @@ -1111,10 +1115,10 @@ PartitionInstallChildHandle ( IN EFI_BLOCK_IO2_PROTOCOL *ParentBlockIo2, IN EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath, IN EFI_DEVICE_PATH_PROTOCOL *DevicePathNode, + IN EFI_PARTITION_INFO_PROTOCOL *PartitionInfo, IN EFI_LBA Start, IN EFI_LBA End, - IN UINT32 BlockSize, - IN BOOLEAN InstallEspGuid + IN UINT32 BlockSize ) { EFI_STATUS Status; @@ -1203,7 +1207,12 @@ PartitionInstallChildHandle ( return EFI_OUT_OF_RESOURCES; } - if (InstallEspGuid) { + // + // Set the PartitionInfo into Private Data. + // + CopyMem (&Private->PartitionInfo, PartitionInfo, sizeof (EFI_PARTITION_INFO_PROTOCOL)); + + if ((PartitionInfo->System == 1)) { Private->EspGuid = &gEfiPartTypeSystemPartGuid; } else { // @@ -1225,6 +1234,8 @@ PartitionInstallChildHandle ( &Private->BlockIo, &gEfiBlockIo2ProtocolGuid, &Private->BlockIo2, + &gEfiPartitionInfoProtocolGuid, + &Private->PartitionInfo, Private->EspGuid, NULL, NULL @@ -1236,6 +1247,8 @@ PartitionInstallChildHandle ( Private->DevicePath, &gEfiBlockIoProtocolGuid, &Private->BlockIo, + &gEfiPartitionInfoProtocolGuid, + &Private->PartitionInfo, Private->EspGuid, NULL, NULL diff --git a/MdeModulePkg/Universal/Disk/PartitionDxe/Partition.h b/MdeModulePkg/Universal/Disk/PartitionDxe/Partition.h index 7cb19882cb..f2f6185317 100644 --- a/MdeModulePkg/Universal/Disk/PartitionDxe/Partition.h +++ b/MdeModulePkg/Universal/Disk/PartitionDxe/Partition.h @@ -4,7 +4,7 @@ of the raw block devices media. Currently "El Torito CD-ROM", Legacy MBR, and GPT partition schemes are supported. -Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR> +Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR> This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -27,6 +27,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include <Protocol/DriverBinding.h> #include <Protocol/DiskIo.h> #include <Protocol/DiskIo2.h> +#include <Protocol/PartitionInfo.h> #include <Library/DebugLib.h> #include <Library/UefiDriverEntryPoint.h> #include <Library/BaseLib.h> @@ -45,25 +46,26 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. // #define PARTITION_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('P', 'a', 'r', 't') typedef struct { - UINT64 Signature; - - EFI_HANDLE Handle; - EFI_DEVICE_PATH_PROTOCOL *DevicePath; - EFI_BLOCK_IO_PROTOCOL BlockIo; - EFI_BLOCK_IO2_PROTOCOL BlockIo2; - EFI_BLOCK_IO_MEDIA Media; - EFI_BLOCK_IO_MEDIA Media2;//For BlockIO2 - - EFI_DISK_IO_PROTOCOL *DiskIo; - EFI_DISK_IO2_PROTOCOL *DiskIo2; - EFI_BLOCK_IO_PROTOCOL *ParentBlockIo; - EFI_BLOCK_IO2_PROTOCOL *ParentBlockIo2; - UINT64 Start; - UINT64 End; - UINT32 BlockSize; - BOOLEAN InStop; - - EFI_GUID *EspGuid; + UINT64 Signature; + + EFI_HANDLE Handle; + EFI_DEVICE_PATH_PROTOCOL *DevicePath; + EFI_BLOCK_IO_PROTOCOL BlockIo; + EFI_BLOCK_IO2_PROTOCOL BlockIo2; + EFI_BLOCK_IO_MEDIA Media; + EFI_BLOCK_IO_MEDIA Media2;//For BlockIO2 + EFI_PARTITION_INFO_PROTOCOL PartitionInfo; + + EFI_DISK_IO_PROTOCOL *DiskIo; + EFI_DISK_IO2_PROTOCOL *DiskIo2; + EFI_BLOCK_IO_PROTOCOL *ParentBlockIo; + EFI_BLOCK_IO2_PROTOCOL *ParentBlockIo2; + UINT64 Start; + UINT64 End; + UINT32 BlockSize; + BOOLEAN InStop; + + EFI_GUID *EspGuid; } PARTITION_PRIVATE_DATA; @@ -321,10 +323,10 @@ PartitionComponentNameGetControllerName ( @param[in] ParentBlockIo2 Parent BlockIo2 interface. @param[in] ParentDevicePath Parent Device Path. @param[in] DevicePathNode Child Device Path node. + @param[in] PartitionInfo Child Partition Information interface. @param[in] Start Start Block. @param[in] End End Block. @param[in] BlockSize Child block size. - @param[in] InstallEspGuid Flag to install EFI System Partition GUID on handle. @retval EFI_SUCCESS A child handle was added. @retval other A child handle was not added. @@ -340,10 +342,10 @@ PartitionInstallChildHandle ( IN EFI_BLOCK_IO2_PROTOCOL *ParentBlockIo2, IN EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath, IN EFI_DEVICE_PATH_PROTOCOL *DevicePathNode, + IN EFI_PARTITION_INFO_PROTOCOL *PartitionInfo, IN EFI_LBA Start, IN EFI_LBA End, - IN UINT32 BlockSize, - IN BOOLEAN InstallEspGuid + IN UINT32 BlockSize ); /** diff --git a/MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.inf b/MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.inf index 680626378f..48212773e8 100644 --- a/MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.inf +++ b/MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.inf @@ -11,7 +11,7 @@ # This external input must be validated carefully to avoid security issue like # buffer overflow, integer overflow. # -# Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR> +# Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR> # This program and the accompanying materials # are licensed and made available under the terms and conditions of the BSD License # which accompanies this distribution. The full text of the license may be found at @@ -82,6 +82,7 @@ ## BY_START ## TO_START gEfiDevicePathProtocolGuid + gEfiPartitionInfoProtocolGuid ## BY_START gEfiDiskIoProtocolGuid ## TO_START gEfiDiskIo2ProtocolGuid ## TO_START -- 2.12.0.windows.1 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] MdeModulePkg/PartitionDxe: Add impl of Partition Information Protocol 2017-06-22 8:44 ` [PATCH 2/2] MdeModulePkg/PartitionDxe: Add impl of Partition Information Protocol Hao Wu @ 2017-07-07 2:24 ` Ni, Ruiyu 0 siblings, 0 replies; 6+ messages in thread From: Ni, Ruiyu @ 2017-07-07 2:24 UTC (permalink / raw) To: Wu, Hao A, edk2-devel@lists.01.org Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com> Thanks/Ray > -----Original Message----- > From: Wu, Hao A > Sent: Thursday, June 22, 2017 4:45 PM > To: edk2-devel@lists.01.org > Cc: Wu, Hao A <hao.a.wu@intel.com>; Ni, Ruiyu <ruiyu.ni@intel.com>; Bret > Barkelew <brbarkel@microsoft.com> > Subject: [PATCH 2/2] MdeModulePkg/PartitionDxe: Add impl of Partition > Information Protocol > > Cc: Ruiyu Ni <ruiyu.ni@intel.com> > Contributed-under: TianoCore Contribution Agreement 1.0 > Signed-off-by: Bret Barkelew <brbarkel@microsoft.com> > Signed-off-by: Hao Wu <hao.a.wu@intel.com> > --- > MdeModulePkg/Universal/Disk/PartitionDxe/ElTorito.c | 43 ++++++++--- > ---- > MdeModulePkg/Universal/Disk/PartitionDxe/Gpt.c | 55 > ++++++++++++-------- > MdeModulePkg/Universal/Disk/PartitionDxe/Mbr.c | 51 > ++++++++++++------ > MdeModulePkg/Universal/Disk/PartitionDxe/Partition.c | 23 ++++++-- > MdeModulePkg/Universal/Disk/PartitionDxe/Partition.h | 48 +++++++++- > ------- > MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.inf | 3 +- > 6 files changed, 135 insertions(+), 88 deletions(-) > > diff --git a/MdeModulePkg/Universal/Disk/PartitionDxe/ElTorito.c > b/MdeModulePkg/Universal/Disk/PartitionDxe/ElTorito.c > index 2af38429dd..2084ee5abe 100644 > --- a/MdeModulePkg/Universal/Disk/PartitionDxe/ElTorito.c > +++ b/MdeModulePkg/Universal/Disk/PartitionDxe/ElTorito.c > @@ -1,7 +1,7 @@ > /** @file > Decode an El Torito formatted CD-ROM > > -Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR> > +Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR> > This program and the accompanying materials are licensed and made > available under the terms and conditions of the BSD License which > accompanies this distribution. The full text of the license may be found at > @@ -44,22 +44,23 @@ PartitionInstallElToritoChildHandles ( > IN EFI_DEVICE_PATH_PROTOCOL *DevicePath > ) > { > - EFI_STATUS Status; > - UINT64 VolDescriptorOffset; > - UINT32 Lba2KB; > - EFI_BLOCK_IO_MEDIA *Media; > - CDROM_VOLUME_DESCRIPTOR *VolDescriptor; > - ELTORITO_CATALOG *Catalog; > - UINTN Check; > - UINTN Index; > - UINTN BootEntry; > - UINTN MaxIndex; > - UINT16 *CheckBuffer; > - CDROM_DEVICE_PATH CdDev; > - UINT32 SubBlockSize; > - UINT32 SectorCount; > - EFI_STATUS Found; > - UINT32 VolSpaceSize; > + EFI_STATUS Status; > + UINT64 VolDescriptorOffset; > + UINT32 Lba2KB; > + EFI_BLOCK_IO_MEDIA *Media; > + CDROM_VOLUME_DESCRIPTOR *VolDescriptor; > + ELTORITO_CATALOG *Catalog; > + UINTN Check; > + UINTN Index; > + UINTN BootEntry; > + UINTN MaxIndex; > + UINT16 *CheckBuffer; > + CDROM_DEVICE_PATH CdDev; > + UINT32 SubBlockSize; > + UINT32 SectorCount; > + EFI_STATUS Found; > + UINT32 VolSpaceSize; > + EFI_PARTITION_INFO_PROTOCOL PartitionInfo; > > Found = EFI_NOT_FOUND; > Media = BlockIo->Media; > @@ -248,6 +249,10 @@ PartitionInstallElToritoChildHandles ( > ); > } > > + ZeroMem (&PartitionInfo, sizeof (EFI_PARTITION_INFO_PROTOCOL)); > + PartitionInfo.Revision = EFI_PARTITION_INFO_PROTOCOL_REVISION; > + PartitionInfo.Type = PARTITION_TYPE_OTHER; > + > Status = PartitionInstallChildHandle ( > This, > Handle, > @@ -257,10 +262,10 @@ PartitionInstallElToritoChildHandles ( > BlockIo2, > DevicePath, > (EFI_DEVICE_PATH_PROTOCOL *) &CdDev, > + &PartitionInfo, > Catalog->Boot.Lba * (SIZE_2KB / Media->BlockSize), > Catalog->Boot.Lba * (SIZE_2KB / Media->BlockSize) + > CdDev.PartitionSize - 1, > - SubBlockSize, > - FALSE > + SubBlockSize > ); > if (!EFI_ERROR (Status)) { > Found = EFI_SUCCESS; > diff --git a/MdeModulePkg/Universal/Disk/PartitionDxe/Gpt.c > b/MdeModulePkg/Universal/Disk/PartitionDxe/Gpt.c > index 35860515c1..2cd3e15e8a 100644 > --- a/MdeModulePkg/Universal/Disk/PartitionDxe/Gpt.c > +++ b/MdeModulePkg/Universal/Disk/PartitionDxe/Gpt.c > @@ -13,7 +13,7 @@ > PartitionValidGptTable(), PartitionCheckGptEntry() routine will accept disk > partition content and validate the GPT table and GPT entry. > > -Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR> > +Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR> > This program and the accompanying materials are licensed and made > available under the terms and conditions of the BSD License which > accompanies this distribution. The full text of the license may be found at > @@ -205,19 +205,20 @@ PartitionInstallGptChildHandles ( > IN EFI_DEVICE_PATH_PROTOCOL *DevicePath > ) > { > - EFI_STATUS Status; > - UINT32 BlockSize; > - EFI_LBA LastBlock; > - MASTER_BOOT_RECORD *ProtectiveMbr; > - EFI_PARTITION_TABLE_HEADER *PrimaryHeader; > - EFI_PARTITION_TABLE_HEADER *BackupHeader; > - EFI_PARTITION_ENTRY *PartEntry; > - EFI_PARTITION_ENTRY *Entry; > - EFI_PARTITION_ENTRY_STATUS *PEntryStatus; > - UINTN Index; > - EFI_STATUS GptValidStatus; > - HARDDRIVE_DEVICE_PATH HdDev; > - UINT32 MediaId; > + EFI_STATUS Status; > + UINT32 BlockSize; > + EFI_LBA LastBlock; > + MASTER_BOOT_RECORD *ProtectiveMbr; > + EFI_PARTITION_TABLE_HEADER *PrimaryHeader; > + EFI_PARTITION_TABLE_HEADER *BackupHeader; > + EFI_PARTITION_ENTRY *PartEntry; > + EFI_PARTITION_ENTRY *Entry; > + EFI_PARTITION_ENTRY_STATUS *PEntryStatus; > + UINTN Index; > + EFI_STATUS GptValidStatus; > + HARDDRIVE_DEVICE_PATH HdDev; > + UINT32 MediaId; > + EFI_PARTITION_INFO_PROTOCOL PartitionInfo; > > ProtectiveMbr = NULL; > PrimaryHeader = NULL; > @@ -380,17 +381,25 @@ PartitionInstallGptChildHandles ( > } > > ZeroMem (&HdDev, sizeof (HdDev)); > - HdDev.Header.Type = MEDIA_DEVICE_PATH; > - HdDev.Header.SubType = MEDIA_HARDDRIVE_DP; > + HdDev.Header.Type = MEDIA_DEVICE_PATH; > + HdDev.Header.SubType = MEDIA_HARDDRIVE_DP; > SetDevicePathNodeLength (&HdDev.Header, sizeof (HdDev)); > > - HdDev.PartitionNumber = (UINT32) Index + 1; > - HdDev.MBRType = MBR_TYPE_EFI_PARTITION_TABLE_HEADER; > - HdDev.SignatureType = SIGNATURE_TYPE_GUID; > - HdDev.PartitionStart = Entry->StartingLBA; > - HdDev.PartitionSize = Entry->EndingLBA - Entry->StartingLBA + 1; > + HdDev.PartitionNumber = (UINT32) Index + 1; > + HdDev.MBRType = MBR_TYPE_EFI_PARTITION_TABLE_HEADER; > + HdDev.SignatureType = SIGNATURE_TYPE_GUID; > + HdDev.PartitionStart = Entry->StartingLBA; > + HdDev.PartitionSize = Entry->EndingLBA - Entry->StartingLBA + 1; > CopyMem (HdDev.Signature, &Entry->UniquePartitionGUID, sizeof > (EFI_GUID)); > > + ZeroMem (&PartitionInfo, sizeof (EFI_PARTITION_INFO_PROTOCOL)); > + PartitionInfo.Revision = EFI_PARTITION_INFO_PROTOCOL_REVISION; > + PartitionInfo.Type = PARTITION_TYPE_GPT; > + if (CompareGuid (&Entry->PartitionTypeGUID, > &gEfiPartTypeSystemPartGuid)) { > + PartitionInfo.System = 1; > + } > + CopyMem (&PartitionInfo.Info.Gpt, Entry, sizeof > + (EFI_PARTITION_ENTRY)); > + > DEBUG ((EFI_D_INFO, " Index : %d\n", (UINT32) Index)); > DEBUG ((EFI_D_INFO, " Start LBA : %lx\n", (UINT64) HdDev.PartitionStart)); > DEBUG ((EFI_D_INFO, " End LBA : %lx\n", (UINT64) Entry->EndingLBA)); > @@ -407,10 +416,10 @@ PartitionInstallGptChildHandles ( > BlockIo2, > DevicePath, > (EFI_DEVICE_PATH_PROTOCOL *) &HdDev, > + &PartitionInfo, > Entry->StartingLBA, > Entry->EndingLBA, > - BlockSize, > - CompareGuid(&Entry->PartitionTypeGUID, > &gEfiPartTypeSystemPartGuid) > + BlockSize > ); > } > > diff --git a/MdeModulePkg/Universal/Disk/PartitionDxe/Mbr.c > b/MdeModulePkg/Universal/Disk/PartitionDxe/Mbr.c > index 377fb19319..55e9d26bae 100644 > --- a/MdeModulePkg/Universal/Disk/PartitionDxe/Mbr.c > +++ b/MdeModulePkg/Universal/Disk/PartitionDxe/Mbr.c > @@ -12,7 +12,7 @@ > the legacy boot strap code. > > Copyright (c) 2014, Hewlett-Packard Development Company, L.P.<BR> - > Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR> > +Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR> > This program and the accompanying materials are licensed and made > available under the terms and conditions of the BSD License which > accompanies this distribution. The full text of the license may be found at > @@ -129,18 +129,19 @@ PartitionInstallMbrChildHandles ( > IN EFI_DEVICE_PATH_PROTOCOL *DevicePath > ) > { > - EFI_STATUS Status; > - MASTER_BOOT_RECORD *Mbr; > - UINT32 ExtMbrStartingLba; > - UINT32 Index; > - HARDDRIVE_DEVICE_PATH HdDev; > - HARDDRIVE_DEVICE_PATH ParentHdDev; > - EFI_STATUS Found; > - EFI_DEVICE_PATH_PROTOCOL *DevicePathNode; > - EFI_DEVICE_PATH_PROTOCOL *LastDevicePathNode; > - UINT32 BlockSize; > - UINT32 MediaId; > - EFI_LBA LastBlock; > + EFI_STATUS Status; > + MASTER_BOOT_RECORD *Mbr; > + UINT32 ExtMbrStartingLba; > + UINT32 Index; > + HARDDRIVE_DEVICE_PATH HdDev; > + HARDDRIVE_DEVICE_PATH ParentHdDev; > + EFI_STATUS Found; > + EFI_DEVICE_PATH_PROTOCOL *DevicePathNode; > + EFI_DEVICE_PATH_PROTOCOL *LastDevicePathNode; > + UINT32 BlockSize; > + UINT32 MediaId; > + EFI_LBA LastBlock; > + EFI_PARTITION_INFO_PROTOCOL PartitionInfo; > > Found = EFI_NOT_FOUND; > > @@ -225,6 +226,14 @@ PartitionInstallMbrChildHandles ( > HdDev.PartitionSize = UNPACK_UINT32 (Mbr- > >Partition[Index].SizeInLBA); > CopyMem (HdDev.Signature, &(Mbr->UniqueMbrSignature[0]), sizeof > (Mbr->UniqueMbrSignature)); > > + ZeroMem (&PartitionInfo, sizeof (EFI_PARTITION_INFO_PROTOCOL)); > + PartitionInfo.Revision = EFI_PARTITION_INFO_PROTOCOL_REVISION; > + PartitionInfo.Type = PARTITION_TYPE_MBR; > + if (Mbr->Partition[Index].OSIndicator == EFI_PARTITION) { > + PartitionInfo.System = 1; > + } > + CopyMem (&PartitionInfo.Info.Mbr, &Mbr->Partition[Index], sizeof > + (MBR_PARTITION_RECORD)); > + > Status = PartitionInstallChildHandle ( > This, > Handle, > @@ -234,10 +243,10 @@ PartitionInstallMbrChildHandles ( > BlockIo2, > DevicePath, > (EFI_DEVICE_PATH_PROTOCOL *) &HdDev, > + &PartitionInfo, > HdDev.PartitionStart, > HdDev.PartitionStart + HdDev.PartitionSize - 1, > - MBR_SIZE, > - (BOOLEAN) (Mbr->Partition[Index].OSIndicator == EFI_PARTITION) > + MBR_SIZE > ); > > if (!EFI_ERROR (Status)) { > @@ -288,6 +297,14 @@ PartitionInstallMbrChildHandles ( > // > *((UINT32 *) &HdDev.Signature[0]) = 0; > > + ZeroMem (&PartitionInfo, sizeof (EFI_PARTITION_INFO_PROTOCOL)); > + PartitionInfo.Revision = EFI_PARTITION_INFO_PROTOCOL_REVISION; > + PartitionInfo.Type = PARTITION_TYPE_MBR; > + if (Mbr->Partition[0].OSIndicator == EFI_PARTITION) { > + PartitionInfo.System = 1; > + } > + CopyMem (&PartitionInfo.Info.Mbr, &Mbr->Partition[0], sizeof > + (MBR_PARTITION_RECORD)); > + > Status = PartitionInstallChildHandle ( > This, > Handle, > @@ -297,10 +314,10 @@ PartitionInstallMbrChildHandles ( > BlockIo2, > DevicePath, > (EFI_DEVICE_PATH_PROTOCOL *) &HdDev, > + &PartitionInfo, > HdDev.PartitionStart - ParentHdDev.PartitionStart, > HdDev.PartitionStart - ParentHdDev.PartitionStart + > HdDev.PartitionSize - 1, > - MBR_SIZE, > - (BOOLEAN) (Mbr->Partition[0].OSIndicator == EFI_PARTITION) > + MBR_SIZE > ); > if (!EFI_ERROR (Status)) { > Found = EFI_SUCCESS; > diff --git a/MdeModulePkg/Universal/Disk/PartitionDxe/Partition.c > b/MdeModulePkg/Universal/Disk/PartitionDxe/Partition.c > index 1c53bf0233..5a7d119b43 100644 > --- a/MdeModulePkg/Universal/Disk/PartitionDxe/Partition.c > +++ b/MdeModulePkg/Universal/Disk/PartitionDxe/Partition.c > @@ -4,7 +4,7 @@ > of the raw block devices media. Currently "El Torito CD-ROM", Legacy > MBR, and GPT partition schemes are supported. > > -Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR> > +Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR> > This program and the accompanying materials are licensed and made > available under the terms and conditions of the BSD License which > accompanies this distribution. The full text of the license may be found at > @@ -514,6 +514,8 @@ PartitionDriverBindingStop ( > &Private->BlockIo, > &gEfiBlockIo2ProtocolGuid, > &Private->BlockIo2, > + &gEfiPartitionInfoProtocolGuid, > + &Private->PartitionInfo, > Private->EspGuid, > NULL, > NULL > @@ -526,6 +528,8 @@ PartitionDriverBindingStop ( > Private->DevicePath, > &gEfiBlockIoProtocolGuid, > &Private->BlockIo, > + &gEfiPartitionInfoProtocolGuid, > + &Private->PartitionInfo, > Private->EspGuid, > NULL, > NULL > @@ -1092,10 +1096,10 @@ PartitionFlushBlocksEx ( > @param[in] ParentBlockIo2 Parent BlockIo2 interface. > @param[in] ParentDevicePath Parent Device Path. > @param[in] DevicePathNode Child Device Path node. > + @param[in] PartitionInfo Child Partition Information interface. > @param[in] Start Start Block. > @param[in] End End Block. > @param[in] BlockSize Child block size. > - @param[in] InstallEspGuid Flag to install EFI System Partition GUID on > handle. > > @retval EFI_SUCCESS A child handle was added. > @retval other A child handle was not added. > @@ -1111,10 +1115,10 @@ PartitionInstallChildHandle ( > IN EFI_BLOCK_IO2_PROTOCOL *ParentBlockIo2, > IN EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath, > IN EFI_DEVICE_PATH_PROTOCOL *DevicePathNode, > + IN EFI_PARTITION_INFO_PROTOCOL *PartitionInfo, > IN EFI_LBA Start, > IN EFI_LBA End, > - IN UINT32 BlockSize, > - IN BOOLEAN InstallEspGuid > + IN UINT32 BlockSize > ) > { > EFI_STATUS Status; > @@ -1203,7 +1207,12 @@ PartitionInstallChildHandle ( > return EFI_OUT_OF_RESOURCES; > } > > - if (InstallEspGuid) { > + // > + // Set the PartitionInfo into Private Data. > + // > + CopyMem (&Private->PartitionInfo, PartitionInfo, sizeof > + (EFI_PARTITION_INFO_PROTOCOL)); > + > + if ((PartitionInfo->System == 1)) { > Private->EspGuid = &gEfiPartTypeSystemPartGuid; > } else { > // > @@ -1225,6 +1234,8 @@ PartitionInstallChildHandle ( > &Private->BlockIo, > &gEfiBlockIo2ProtocolGuid, > &Private->BlockIo2, > + &gEfiPartitionInfoProtocolGuid, > + &Private->PartitionInfo, > Private->EspGuid, > NULL, > NULL > @@ -1236,6 +1247,8 @@ PartitionInstallChildHandle ( > Private->DevicePath, > &gEfiBlockIoProtocolGuid, > &Private->BlockIo, > + &gEfiPartitionInfoProtocolGuid, > + &Private->PartitionInfo, > Private->EspGuid, > NULL, > NULL > diff --git a/MdeModulePkg/Universal/Disk/PartitionDxe/Partition.h > b/MdeModulePkg/Universal/Disk/PartitionDxe/Partition.h > index 7cb19882cb..f2f6185317 100644 > --- a/MdeModulePkg/Universal/Disk/PartitionDxe/Partition.h > +++ b/MdeModulePkg/Universal/Disk/PartitionDxe/Partition.h > @@ -4,7 +4,7 @@ > of the raw block devices media. Currently "El Torito CD-ROM", Legacy > MBR, and GPT partition schemes are supported. > > -Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR> > +Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR> > This program and the accompanying materials are licensed and made > available under the terms and conditions of the BSD License which > accompanies this distribution. The full text of the license may be found at > @@ -27,6 +27,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY > KIND, EITHER EXPRESS OR IMPLIED. > #include <Protocol/DriverBinding.h> > #include <Protocol/DiskIo.h> > #include <Protocol/DiskIo2.h> > +#include <Protocol/PartitionInfo.h> > #include <Library/DebugLib.h> > #include <Library/UefiDriverEntryPoint.h> #include <Library/BaseLib.h> > @@ -45,25 +46,26 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF > ANY KIND, EITHER EXPRESS OR IMPLIED. > // > #define PARTITION_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('P', 'a', 'r', > 't') typedef struct { > - UINT64 Signature; > - > - EFI_HANDLE Handle; > - EFI_DEVICE_PATH_PROTOCOL *DevicePath; > - EFI_BLOCK_IO_PROTOCOL BlockIo; > - EFI_BLOCK_IO2_PROTOCOL BlockIo2; > - EFI_BLOCK_IO_MEDIA Media; > - EFI_BLOCK_IO_MEDIA Media2;//For BlockIO2 > - > - EFI_DISK_IO_PROTOCOL *DiskIo; > - EFI_DISK_IO2_PROTOCOL *DiskIo2; > - EFI_BLOCK_IO_PROTOCOL *ParentBlockIo; > - EFI_BLOCK_IO2_PROTOCOL *ParentBlockIo2; > - UINT64 Start; > - UINT64 End; > - UINT32 BlockSize; > - BOOLEAN InStop; > - > - EFI_GUID *EspGuid; > + UINT64 Signature; > + > + EFI_HANDLE Handle; > + EFI_DEVICE_PATH_PROTOCOL *DevicePath; > + EFI_BLOCK_IO_PROTOCOL BlockIo; > + EFI_BLOCK_IO2_PROTOCOL BlockIo2; > + EFI_BLOCK_IO_MEDIA Media; > + EFI_BLOCK_IO_MEDIA Media2;//For BlockIO2 > + EFI_PARTITION_INFO_PROTOCOL PartitionInfo; > + > + EFI_DISK_IO_PROTOCOL *DiskIo; > + EFI_DISK_IO2_PROTOCOL *DiskIo2; > + EFI_BLOCK_IO_PROTOCOL *ParentBlockIo; > + EFI_BLOCK_IO2_PROTOCOL *ParentBlockIo2; > + UINT64 Start; > + UINT64 End; > + UINT32 BlockSize; > + BOOLEAN InStop; > + > + EFI_GUID *EspGuid; > > } PARTITION_PRIVATE_DATA; > > @@ -321,10 +323,10 @@ PartitionComponentNameGetControllerName ( > @param[in] ParentBlockIo2 Parent BlockIo2 interface. > @param[in] ParentDevicePath Parent Device Path. > @param[in] DevicePathNode Child Device Path node. > + @param[in] PartitionInfo Child Partition Information interface. > @param[in] Start Start Block. > @param[in] End End Block. > @param[in] BlockSize Child block size. > - @param[in] InstallEspGuid Flag to install EFI System Partition GUID on > handle. > > @retval EFI_SUCCESS A child handle was added. > @retval other A child handle was not added. > @@ -340,10 +342,10 @@ PartitionInstallChildHandle ( > IN EFI_BLOCK_IO2_PROTOCOL *ParentBlockIo2, > IN EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath, > IN EFI_DEVICE_PATH_PROTOCOL *DevicePathNode, > + IN EFI_PARTITION_INFO_PROTOCOL *PartitionInfo, > IN EFI_LBA Start, > IN EFI_LBA End, > - IN UINT32 BlockSize, > - IN BOOLEAN InstallEspGuid > + IN UINT32 BlockSize > ); > > /** > diff --git a/MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.inf > b/MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.inf > index 680626378f..48212773e8 100644 > --- a/MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.inf > +++ b/MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.inf > @@ -11,7 +11,7 @@ > # This external input must be validated carefully to avoid security issue like > # buffer overflow, integer overflow. > # > -# Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR> > +# Copyright (c) 2006 - 2017, Intel Corporation. All rights > +reserved.<BR> > # This program and the accompanying materials # are licensed and made > available under the terms and conditions of the BSD License # which > accompanies this distribution. The full text of the license may be found at > @@ -82,6 +82,7 @@ > ## BY_START > ## TO_START > gEfiDevicePathProtocolGuid > + gEfiPartitionInfoProtocolGuid ## BY_START > gEfiDiskIoProtocolGuid ## TO_START > gEfiDiskIo2ProtocolGuid ## TO_START > > -- > 2.12.0.windows.1 ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2017-07-07 5:38 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2017-06-22 8:44 [PATCH 0/2] Add EFI Partition Information Protocol Hao Wu 2017-06-22 8:44 ` [PATCH 1/2] MdePkg: Add EFI Partition Information Protocol definitions Hao Wu 2017-07-07 2:26 ` Ni, Ruiyu 2017-07-07 5:40 ` Wu, Hao A 2017-06-22 8:44 ` [PATCH 2/2] MdeModulePkg/PartitionDxe: Add impl of Partition Information Protocol Hao Wu 2017-07-07 2:24 ` Ni, Ruiyu
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox