mirror of https://github.com/acidanthera/audk.git
Update CapsuleDriver to use capsule library.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@4365 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
95be2c94e1
commit
6ee65722c7
|
@ -70,6 +70,7 @@
|
||||||
UdpIoLib|MdeModulePkg/Library/DxeUdpIoLib/DxeUdpIoLib.inf
|
UdpIoLib|MdeModulePkg/Library/DxeUdpIoLib/DxeUdpIoLib.inf
|
||||||
DpcLib|MdeModulePkg/Library/DxeDpcLib/DxeDpcLib.inf
|
DpcLib|MdeModulePkg/Library/DxeDpcLib/DxeDpcLib.inf
|
||||||
PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
|
PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
|
||||||
|
CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.inf
|
||||||
|
|
||||||
[LibraryClasses.IA32]
|
[LibraryClasses.IA32]
|
||||||
IoLib|MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf
|
IoLib|MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf
|
||||||
|
|
|
@ -41,13 +41,11 @@
|
||||||
|
|
||||||
[LibraryClasses]
|
[LibraryClasses]
|
||||||
UefiBootServicesTableLib
|
UefiBootServicesTableLib
|
||||||
MemoryAllocationLib
|
|
||||||
BaseMemoryLib
|
|
||||||
PcdLib
|
PcdLib
|
||||||
DebugLib
|
DebugLib
|
||||||
UefiRuntimeLib
|
UefiRuntimeLib
|
||||||
DxeServicesTableLib
|
|
||||||
UefiDriverEntryPoint
|
UefiDriverEntryPoint
|
||||||
|
CapsuleLib
|
||||||
|
|
||||||
[Guids]
|
[Guids]
|
||||||
gEfiCapsuleVendorGuid # SOMETIMES_CONSUMED
|
gEfiCapsuleVendorGuid # SOMETIMES_CONSUMED
|
||||||
|
|
|
@ -47,22 +47,18 @@ Returns:
|
||||||
not set, the capsule has been successfully processed by the firmware.
|
not set, the capsule has been successfully processed by the firmware.
|
||||||
If it set, the ScattlerGatherList is successfully to be set.
|
If it set, the ScattlerGatherList is successfully to be set.
|
||||||
EFI_INVALID_PARAMETER CapsuleCount is less than 1,CapsuleGuid is not supported.
|
EFI_INVALID_PARAMETER CapsuleCount is less than 1,CapsuleGuid is not supported.
|
||||||
EFI_DEVICE_ERROR Failed to SetVariable or AllocatePool or ProcessFirmwareVolume.
|
EFI_DEVICE_ERROR Failed to SetVariable or ProcessFirmwareVolume.
|
||||||
|
|
||||||
--*/
|
--*/
|
||||||
{
|
{
|
||||||
UINTN CapsuleSize;
|
|
||||||
UINTN ArrayNumber;
|
UINTN ArrayNumber;
|
||||||
VOID *BufferPtr;
|
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
EFI_HANDLE FvHandle;
|
|
||||||
EFI_CAPSULE_HEADER *CapsuleHeader;
|
EFI_CAPSULE_HEADER *CapsuleHeader;
|
||||||
|
|
||||||
if (CapsuleCount < 1) {
|
if (CapsuleCount < 1) {
|
||||||
return EFI_INVALID_PARAMETER;
|
return EFI_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
BufferPtr = NULL;
|
|
||||||
CapsuleHeader = NULL;
|
CapsuleHeader = NULL;
|
||||||
|
|
||||||
for (ArrayNumber = 0; ArrayNumber < CapsuleCount; ArrayNumber++) {
|
for (ArrayNumber = 0; ArrayNumber < CapsuleCount; ArrayNumber++) {
|
||||||
|
@ -75,25 +71,22 @@ Returns:
|
||||||
return EFI_INVALID_PARAMETER;
|
return EFI_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
// To remove this check. Capsule update supports non reset image.
|
// Check Capsule image without populate flag by firmware support capsule function
|
||||||
//
|
//
|
||||||
// if ((CapsuleHeader->Flags & CAPSULE_FLAGS_POPULATE_SYSTEM_TABLE) == 0) {
|
if (((CapsuleHeader->Flags & CAPSULE_FLAGS_POPULATE_SYSTEM_TABLE) == 0) &&
|
||||||
// return EFI_UNSUPPORTED;
|
(SupportCapsuleImage (CapsuleHeader) != EFI_SUCCESS)) {
|
||||||
// }
|
return EFI_UNSUPPORTED;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Check capsule guid is suppored by this platform. To do
|
// Assume that capsules have the same flags on reseting or not.
|
||||||
//
|
|
||||||
|
|
||||||
//
|
|
||||||
//Assume that capsules have the same flags on reseting or not.
|
|
||||||
//
|
//
|
||||||
CapsuleHeader = CapsuleHeaderArray[0];
|
CapsuleHeader = CapsuleHeaderArray[0];
|
||||||
|
|
||||||
if ((CapsuleHeader->Flags & CAPSULE_FLAGS_PERSIST_ACROSS_RESET) != 0) {
|
if ((CapsuleHeader->Flags & CAPSULE_FLAGS_PERSIST_ACROSS_RESET) != 0) {
|
||||||
//
|
//
|
||||||
//Check if the platform supports update capsule across a system reset
|
// Check if the platform supports update capsule across a system reset
|
||||||
//
|
//
|
||||||
if (!FeaturePcdGet(PcdSupportUpdateCapsuleRest)) {
|
if (!FeaturePcdGet(PcdSupportUpdateCapsuleRest)) {
|
||||||
return EFI_UNSUPPORTED;
|
return EFI_UNSUPPORTED;
|
||||||
|
@ -120,13 +113,16 @@ Returns:
|
||||||
if (Status != EFI_SUCCESS) {
|
if (Status != EFI_SUCCESS) {
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
//
|
||||||
|
// Successfully set the capsule image address into variable.
|
||||||
|
//
|
||||||
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
return EFI_SUCCESS;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// The rest occurs in the condition of non-reset mode
|
// The rest occurs in the condition of non-reset mode
|
||||||
// Current Runtime mode doesn't support the non-reset capsule image.
|
// Now Runtime mode doesn't support the non-reset capsule image.
|
||||||
//
|
//
|
||||||
if (EfiAtRuntime ()) {
|
if (EfiAtRuntime ()) {
|
||||||
return EFI_INVALID_PARAMETER;
|
return EFI_INVALID_PARAMETER;
|
||||||
|
@ -134,29 +130,13 @@ Returns:
|
||||||
|
|
||||||
//
|
//
|
||||||
// Here should be in the boot-time for non-reset capsule image
|
// Here should be in the boot-time for non-reset capsule image
|
||||||
// Default process to Update Capsule image into Flash for any guid image.
|
// Default process to Update Capsule image into Flash.
|
||||||
//
|
//
|
||||||
for (ArrayNumber = 0; ArrayNumber < CapsuleCount ; ArrayNumber++) {
|
for (ArrayNumber = 0; ArrayNumber < CapsuleCount ; ArrayNumber++) {
|
||||||
CapsuleHeader = CapsuleHeaderArray[ArrayNumber];
|
Status = ProcessCapsuleImage (CapsuleHeaderArray[ArrayNumber]);
|
||||||
CapsuleSize = CapsuleHeader->CapsuleImageSize - CapsuleHeader->HeaderSize;
|
if (EFI_ERROR (Status)) {
|
||||||
|
|
||||||
BufferPtr = AllocatePool (CapsuleSize);
|
|
||||||
if (BufferPtr == NULL) {
|
|
||||||
return EFI_OUT_OF_RESOURCES;
|
|
||||||
}
|
|
||||||
|
|
||||||
CopyMem (BufferPtr, (UINT8*)CapsuleHeader+ CapsuleHeader->HeaderSize, CapsuleSize);
|
|
||||||
|
|
||||||
//
|
|
||||||
//Call DXE service ProcessFirmwareVolume to process immediatelly
|
|
||||||
//
|
|
||||||
Status = gDS->ProcessFirmwareVolume (BufferPtr, CapsuleSize, &FvHandle);
|
|
||||||
if (Status != EFI_SUCCESS) {
|
|
||||||
FreePool (BufferPtr);
|
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
gDS->Dispatch ();
|
|
||||||
FreePool (BufferPtr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
|
@ -218,11 +198,12 @@ Returns:
|
||||||
return EFI_INVALID_PARAMETER;
|
return EFI_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
// To remove this check. Capsule update supports non reset image.
|
// Check Capsule image without populate flag by firmware support capsule function
|
||||||
//
|
//
|
||||||
// if ((CapsuleHeader->Flags & CAPSULE_FLAGS_POPULATE_SYSTEM_TABLE) == 0) {
|
if (((CapsuleHeader->Flags & CAPSULE_FLAGS_POPULATE_SYSTEM_TABLE) == 0) &&
|
||||||
// return EFI_UNSUPPORTED;
|
(SupportCapsuleImage (CapsuleHeader) != EFI_SUCCESS)) {
|
||||||
// }
|
return EFI_UNSUPPORTED;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
|
@ -29,15 +29,11 @@ Abstract:
|
||||||
#include <Guid/CapsuleVendor.h>
|
#include <Guid/CapsuleVendor.h>
|
||||||
|
|
||||||
#include <Library/UefiDriverEntryPoint.h>
|
#include <Library/UefiDriverEntryPoint.h>
|
||||||
#include <Library/DxeServicesTableLib.h>
|
|
||||||
#include <Library/UefiRuntimeLib.h>
|
#include <Library/UefiRuntimeLib.h>
|
||||||
#include <Library/DebugLib.h>
|
#include <Library/DebugLib.h>
|
||||||
#include <Library/PcdLib.h>
|
#include <Library/PcdLib.h>
|
||||||
#include <Library/BaseMemoryLib.h>
|
|
||||||
#include <Library/MemoryAllocationLib.h>
|
|
||||||
#include <Library/UefiBootServicesTableLib.h>
|
#include <Library/UefiBootServicesTableLib.h>
|
||||||
|
#include <Library/CapsuleLib.h>
|
||||||
extern EFI_GUID gEfiCapsuleGuid;
|
|
||||||
|
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
EFIAPI
|
EFIAPI
|
||||||
|
|
Loading…
Reference in New Issue