FatPkg: Add GPT check in FatPei to support Capsule-on-Disk feature.

BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=1470
This feature is used for finding GPT partition.
Follow the following step to check.
1) Check Protective MBR.
2) Check GPT primary/backup header.
3) Check GPT primary/backup entry array.

Cc: Ruiyu Ni <ray.ni@intel.com>
Cc: Zhang Chao B <chao.b.zhang@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Chen A Chen <chen.a.chen@intel.com>
Reviewed-by: Hao Wu <hao.a.wu@intel.com>
This commit is contained in:
Chen A Chen
2019-01-16 14:59:57 +08:00
committed by Hao Wu
parent 0d47abeff6
commit 0d18f5db32
4 changed files with 585 additions and 5 deletions

View File

@@ -52,6 +52,25 @@ FatFindMbrPartitions (
IN UINTN ParentBlockDevNo
);
/**
This function is used for finding GPT partition on block device.
As follow UEFI spec we should check protective MBR first and then
try to check both primary/backup GPT structures.
@param[in] PrivateData The global memory map
@param[in] ParentBlockDevNo The parent block device
@retval TRUE New partitions are detected and logical block devices
are added to block device array
@retval FALSE No new partitions are added
**/
BOOLEAN
FatFindGptPartitions (
IN PEI_FAT_PRIVATE_DATA *PrivateData,
IN UINTN ParentBlockDevNo
);
/**
This function finds partitions (logical devices) in physical block devices.
@@ -71,12 +90,21 @@ FatFindPartitions (
for (Index = 0; Index < PrivateData->BlockDeviceCount; Index++) {
if (!PrivateData->BlockDevice[Index].PartitionChecked) {
Found = FatFindMbrPartitions (PrivateData, Index);
if (!Found) {
Found = FatFindEltoritoPartitions (PrivateData, Index);
if (FatFindGptPartitions (PrivateData, Index)) {
Found = TRUE;
continue;
}
if (FatFindMbrPartitions (PrivateData, Index)) {
Found = TRUE;
continue;
}
if (FatFindEltoritoPartitions (PrivateData, Index)) {
Found = TRUE;
continue;
}
}
}
} while (Found && PrivateData->BlockDeviceCount <= PEI_FAT_MAX_BLOCK_DEVICE);
}