FatPkg: Add RecoveryBlockIo2Ppi support

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Feng Tian <feng.tian@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>

(based on FatPkg commit add52adf722d2b0f1db4c8780a30289dacd59e02)

[jordan.l.justen@intel.com: Use script to relicense to 2-clause BSD]
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
Acked-by: Mark Doran <mark.doran@intel.com>
Acked-by: Laszlo Ersek <lersek@redhat.com>
This commit is contained in:
Feng Tian 2015-05-20 05:57:50 +00:00 committed by Jordan Justen
parent 55248f85d1
commit 8a467be153
4 changed files with 144 additions and 65 deletions

View File

@ -1,7 +1,7 @@
/** @file /** @file
FAT recovery PEIM entry point, Ppi Functions and FAT Api functions. FAT recovery PEIM entry point, Ppi Functions and FAT Api functions.
Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR> Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials are licensed and made available This program and the accompanying materials are licensed and made available
under the terms and conditions of the BSD License which accompanies this under the terms and conditions of the BSD License which accompanies this
@ -45,22 +45,26 @@ BlockIoNotifyEntry (
@param PrivateData Global memory map for accessing global @param PrivateData Global memory map for accessing global
variables. variables.
@param BlockIo2 Boolean to show whether using BlockIo2 or BlockIo
@retval EFI_SUCCESS The function completed successfully. @retval EFI_SUCCESS The function completed successfully.
**/ **/
EFI_STATUS EFI_STATUS
UpdateBlocksAndVolumes ( UpdateBlocksAndVolumes (
IN OUT PEI_FAT_PRIVATE_DATA *PrivateData IN OUT PEI_FAT_PRIVATE_DATA *PrivateData,
IN BOOLEAN BlockIo2
) )
{ {
EFI_STATUS Status; EFI_STATUS Status;
EFI_PEI_PPI_DESCRIPTOR *TempPpiDescriptor; EFI_PEI_PPI_DESCRIPTOR *TempPpiDescriptor;
UINTN BlockIoPpiInstance; UINTN BlockIoPpiInstance;
EFI_PEI_RECOVERY_BLOCK_IO_PPI *BlockIoPpi; EFI_PEI_RECOVERY_BLOCK_IO_PPI *BlockIoPpi;
EFI_PEI_RECOVERY_BLOCK_IO2_PPI *BlockIo2Ppi;
UINTN NumberBlockDevices; UINTN NumberBlockDevices;
UINTN Index; UINTN Index;
EFI_PEI_BLOCK_IO_MEDIA Media; EFI_PEI_BLOCK_IO_MEDIA Media;
EFI_PEI_BLOCK_IO2_MEDIA Media2;
PEI_FAT_VOLUME Volume; PEI_FAT_VOLUME Volume;
EFI_PEI_SERVICES **PeiServices; EFI_PEI_SERVICES **PeiServices;
@ -80,12 +84,21 @@ UpdateBlocksAndVolumes (
// Assuming all device Block Io Peims are dispatched already // Assuming all device Block Io Peims are dispatched already
// //
for (BlockIoPpiInstance = 0; BlockIoPpiInstance < PEI_FAT_MAX_BLOCK_IO_PPI; BlockIoPpiInstance++) { for (BlockIoPpiInstance = 0; BlockIoPpiInstance < PEI_FAT_MAX_BLOCK_IO_PPI; BlockIoPpiInstance++) {
if (BlockIo2) {
Status = PeiServicesLocatePpi (
&gEfiPeiVirtualBlockIo2PpiGuid,
BlockIoPpiInstance,
&TempPpiDescriptor,
(VOID **) &BlockIo2Ppi
);
} else {
Status = PeiServicesLocatePpi ( Status = PeiServicesLocatePpi (
&gEfiPeiVirtualBlockIoPpiGuid, &gEfiPeiVirtualBlockIoPpiGuid,
BlockIoPpiInstance, BlockIoPpiInstance,
&TempPpiDescriptor, &TempPpiDescriptor,
(VOID **) &BlockIoPpi (VOID **) &BlockIoPpi
); );
}
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
// //
// Done with all Block Io Ppis // Done with all Block Io Ppis
@ -93,17 +106,36 @@ UpdateBlocksAndVolumes (
break; break;
} }
if (BlockIo2) {
Status = BlockIo2Ppi->GetNumberOfBlockDevices (
PeiServices,
BlockIo2Ppi,
&NumberBlockDevices
);
} else {
Status = BlockIoPpi->GetNumberOfBlockDevices ( Status = BlockIoPpi->GetNumberOfBlockDevices (
PeiServices, PeiServices,
BlockIoPpi, BlockIoPpi,
&NumberBlockDevices &NumberBlockDevices
); );
}
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
continue; continue;
} }
for (Index = 1; Index <= NumberBlockDevices && PrivateData->BlockDeviceCount < PEI_FAT_MAX_BLOCK_DEVICE; Index++) { for (Index = 1; Index <= NumberBlockDevices && PrivateData->BlockDeviceCount < PEI_FAT_MAX_BLOCK_DEVICE; Index++) {
if (BlockIo2) {
Status = BlockIo2Ppi->GetBlockDeviceMediaInfo (
PeiServices,
BlockIo2Ppi,
Index,
&Media2
);
if (EFI_ERROR (Status) || !Media2.MediaPresent) {
continue;
}
} else {
Status = BlockIoPpi->GetBlockDeviceMediaInfo ( Status = BlockIoPpi->GetBlockDeviceMediaInfo (
PeiServices, PeiServices,
BlockIoPpi, BlockIoPpi,
@ -113,9 +145,8 @@ UpdateBlocksAndVolumes (
if (EFI_ERROR (Status) || !Media.MediaPresent) { if (EFI_ERROR (Status) || !Media.MediaPresent) {
continue; continue;
} }
}
PrivateData->BlockDevice[PrivateData->BlockDeviceCount].BlockSize = (UINT32) Media.BlockSize;
PrivateData->BlockDevice[PrivateData->BlockDeviceCount].LastBlock = Media.LastBlock;
PrivateData->BlockDevice[PrivateData->BlockDeviceCount].IoAlign = 0; PrivateData->BlockDevice[PrivateData->BlockDeviceCount].IoAlign = 0;
// //
// Not used here // Not used here
@ -123,10 +154,18 @@ UpdateBlocksAndVolumes (
PrivateData->BlockDevice[PrivateData->BlockDeviceCount].Logical = FALSE; PrivateData->BlockDevice[PrivateData->BlockDeviceCount].Logical = FALSE;
PrivateData->BlockDevice[PrivateData->BlockDeviceCount].PartitionChecked = FALSE; PrivateData->BlockDevice[PrivateData->BlockDeviceCount].PartitionChecked = FALSE;
PrivateData->BlockDevice[PrivateData->BlockDeviceCount].BlockIo = BlockIoPpi;
PrivateData->BlockDevice[PrivateData->BlockDeviceCount].PhysicalDevNo = (UINT8) Index; PrivateData->BlockDevice[PrivateData->BlockDeviceCount].PhysicalDevNo = (UINT8) Index;
if (BlockIo2) {
PrivateData->BlockDevice[PrivateData->BlockDeviceCount].BlockIo2 = BlockIo2Ppi;
PrivateData->BlockDevice[PrivateData->BlockDeviceCount].InterfaceType = Media2.InterfaceType;
PrivateData->BlockDevice[PrivateData->BlockDeviceCount].LastBlock = Media2.LastBlock;
PrivateData->BlockDevice[PrivateData->BlockDeviceCount].BlockSize = Media2.BlockSize;
} else {
PrivateData->BlockDevice[PrivateData->BlockDeviceCount].BlockIo = BlockIoPpi;
PrivateData->BlockDevice[PrivateData->BlockDeviceCount].DevType = Media.DeviceType; PrivateData->BlockDevice[PrivateData->BlockDeviceCount].DevType = Media.DeviceType;
PrivateData->BlockDevice[PrivateData->BlockDeviceCount].LastBlock = Media.LastBlock;
PrivateData->BlockDevice[PrivateData->BlockDeviceCount].BlockSize = (UINT32) Media.BlockSize;
}
PrivateData->BlockDeviceCount++; PrivateData->BlockDeviceCount++;
} }
} }
@ -184,8 +223,11 @@ BlockIoNotifyEntry (
IN VOID *Ppi IN VOID *Ppi
) )
{ {
UpdateBlocksAndVolumes (mPrivateData); if (CompareGuid (NotifyDescriptor->Guid, &gEfiPeiVirtualBlockIo2PpiGuid)) {
UpdateBlocksAndVolumes (mPrivateData, TRUE);
} else {
UpdateBlocksAndVolumes (mPrivateData, FALSE);
}
return EFI_SUCCESS; return EFI_SUCCESS;
} }
@ -258,7 +300,8 @@ FatPeimEntry (
// //
PrivateData->BlockDeviceCount = 0; PrivateData->BlockDeviceCount = 0;
UpdateBlocksAndVolumes (PrivateData); UpdateBlocksAndVolumes (PrivateData, TRUE);
UpdateBlocksAndVolumes (PrivateData, FALSE);
// //
// PrivateData is allocated now, set it to the module variable // PrivateData is allocated now, set it to the module variable
@ -268,14 +311,20 @@ FatPeimEntry (
// //
// Installs Block Io Ppi notification function // Installs Block Io Ppi notification function
// //
PrivateData->NotifyDescriptor.Flags = PrivateData->NotifyDescriptor[0].Flags =
(
EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK
);
PrivateData->NotifyDescriptor[0].Guid = &gEfiPeiVirtualBlockIoPpiGuid;
PrivateData->NotifyDescriptor[0].Notify = BlockIoNotifyEntry;
PrivateData->NotifyDescriptor[1].Flags =
( (
EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK | EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK |
EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST
); );
PrivateData->NotifyDescriptor.Guid = &gEfiPeiVirtualBlockIoPpiGuid; PrivateData->NotifyDescriptor[1].Guid = &gEfiPeiVirtualBlockIo2PpiGuid;
PrivateData->NotifyDescriptor.Notify = BlockIoNotifyEntry; PrivateData->NotifyDescriptor[1].Notify = BlockIoNotifyEntry;
return PeiServicesNotifyPpi (&PrivateData->NotifyDescriptor); return PeiServicesNotifyPpi (&PrivateData->NotifyDescriptor[0]);
} }
@ -428,6 +477,21 @@ GetRecoveryCapsuleInfo (
// Fill in the Capsule Type GUID according to the block device type // Fill in the Capsule Type GUID according to the block device type
// //
if (BlockDeviceNo < PrivateData->BlockDeviceCount) { if (BlockDeviceNo < PrivateData->BlockDeviceCount) {
if (PrivateData->BlockDevice[BlockDeviceNo].BlockIo2 != NULL) {
switch (PrivateData->BlockDevice[BlockDeviceNo].InterfaceType) {
case MSG_ATAPI_DP:
CopyGuid (CapsuleType, &gRecoveryOnFatIdeDiskGuid);
break;
case MSG_USB_DP:
CopyGuid (CapsuleType, &gRecoveryOnFatUsbDiskGuid);
break;
default:
break;
}
}
if (PrivateData->BlockDevice[BlockDeviceNo].BlockIo != NULL) {
switch (PrivateData->BlockDevice[BlockDeviceNo].DevType) { switch (PrivateData->BlockDevice[BlockDeviceNo].DevType) {
case LegacyFloppy: case LegacyFloppy:
CopyGuid (CapsuleType, &gRecoveryOnFatFloppyDiskGuid); CopyGuid (CapsuleType, &gRecoveryOnFatFloppyDiskGuid);
@ -446,6 +510,7 @@ GetRecoveryCapsuleInfo (
break; break;
} }
} }
}
return EFI_SUCCESS; return EFI_SUCCESS;
} }

View File

@ -1,7 +1,7 @@
/** @file /** @file
General purpose supporting routines for FAT recovery PEIM General purpose supporting routines for FAT recovery PEIM
Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR> Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials are licensed and made available This program and the accompanying materials are licensed and made available
under the terms and conditions of the BSD License which accompanies this under the terms and conditions of the BSD License which accompanies this
@ -87,6 +87,16 @@ FatReadBlock (
// Status = BlockDev->ReadFunc // Status = BlockDev->ReadFunc
// (PrivateData->PeiServices, BlockDev->PhysicalDevNo, Lba, BufferSize, Buffer); // (PrivateData->PeiServices, BlockDev->PhysicalDevNo, Lba, BufferSize, Buffer);
// //
if (BlockDev->BlockIo2 != NULL) {
Status = BlockDev->BlockIo2->ReadBlocks (
(EFI_PEI_SERVICES **) GetPeiServicesTablePointer (),
BlockDev->BlockIo2,
BlockDev->PhysicalDevNo,
Lba,
BufferSize,
Buffer
);
} else {
Status = BlockDev->BlockIo->ReadBlocks ( Status = BlockDev->BlockIo->ReadBlocks (
(EFI_PEI_SERVICES **) GetPeiServicesTablePointer (), (EFI_PEI_SERVICES **) GetPeiServicesTablePointer (),
BlockDev->BlockIo, BlockDev->BlockIo,
@ -95,6 +105,7 @@ FatReadBlock (
BufferSize, BufferSize,
Buffer Buffer
); );
}
} else { } else {
Status = FatReadDisk ( Status = FatReadDisk (

View File

@ -1,7 +1,7 @@
/** @file /** @file
Data structures for FAT recovery PEIM Data structures for FAT recovery PEIM
Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR> Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials are licensed and made available This program and the accompanying materials are licensed and made available
under the terms and conditions of the BSD License which accompanies this under the terms and conditions of the BSD License which accompanies this
@ -20,6 +20,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <Guid/RecoveryDevice.h> #include <Guid/RecoveryDevice.h>
#include <Ppi/BlockIo.h> #include <Ppi/BlockIo.h>
#include <Ppi/BlockIo2.h>
#include <Ppi/DeviceRecoveryModule.h> #include <Ppi/DeviceRecoveryModule.h>
#include <Library/DebugLib.h> #include <Library/DebugLib.h>
@ -73,10 +74,12 @@ typedef struct {
// Following fields only valid for physical device // Following fields only valid for physical device
// //
EFI_PEI_BLOCK_DEVICE_TYPE DevType; EFI_PEI_BLOCK_DEVICE_TYPE DevType;
UINT8 InterfaceType;
// //
// EFI_PEI_READ_BLOCKS ReadFunc; // EFI_PEI_READ_BLOCKS ReadFunc;
// //
EFI_PEI_RECOVERY_BLOCK_IO_PPI *BlockIo; EFI_PEI_RECOVERY_BLOCK_IO_PPI *BlockIo;
EFI_PEI_RECOVERY_BLOCK_IO2_PPI *BlockIo2;
UINT8 PhysicalDevNo; UINT8 PhysicalDevNo;
} PEI_FAT_BLOCK_DEVICE; } PEI_FAT_BLOCK_DEVICE;
@ -150,7 +153,7 @@ typedef struct {
UINTN Signature; UINTN Signature;
EFI_PEI_DEVICE_RECOVERY_MODULE_PPI DeviceRecoveryPpi; EFI_PEI_DEVICE_RECOVERY_MODULE_PPI DeviceRecoveryPpi;
EFI_PEI_PPI_DESCRIPTOR PpiDescriptor; EFI_PEI_PPI_DESCRIPTOR PpiDescriptor;
EFI_PEI_NOTIFY_DESCRIPTOR NotifyDescriptor; EFI_PEI_NOTIFY_DESCRIPTOR NotifyDescriptor[2];
UINT8 UnicodeCaseMap[0x300]; UINT8 UnicodeCaseMap[0x300];
CHAR8 *EngUpperMap; CHAR8 *EngUpperMap;

View File

@ -1,7 +1,7 @@
## @file ## @file
# Lite Fat driver only used in Pei Phase. # Lite Fat driver only used in Pei Phase.
# #
# Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR> # Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>
# #
# This program and the accompanying materials are licensed and made available # This program and the accompanying materials are licensed and made available
# under the terms and conditions of the BSD License which accompanies this # under the terms and conditions of the BSD License which accompanies this
@ -62,13 +62,13 @@
[Ppis] [Ppis]
gEfiPeiVirtualBlockIoPpiGuid # PPI_NOTIFY SOMETIMES_CONSUMED gEfiPeiVirtualBlockIoPpiGuid # PPI_NOTIFY SOMETIMES_CONSUMED
gEfiPeiVirtualBlockIo2PpiGuid # PPI_NOTIFY SOMETIMES_CONSUMED
gEfiPeiDeviceRecoveryModulePpiGuid # SOMETIMES_PRODUCED gEfiPeiDeviceRecoveryModulePpiGuid # SOMETIMES_PRODUCED
[FeaturePcd] [FeaturePcd]
gEfiMdeModulePkgTokenSpaceGuid.PcdFrameworkCompatibilitySupport ## CONSUMES gEfiMdeModulePkgTokenSpaceGuid.PcdFrameworkCompatibilitySupport ## CONSUMES
[Depex] [Depex]
gEfiPeiMemoryDiscoveredPpiGuid AND gEfiPeiBootInRecoveryModePpiGuid gEfiPeiMemoryDiscoveredPpiGuid AND gEfiPeiBootInRecoveryModePpiGuid