3 Copyright (c) 2006, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
18 BDS routines to handle capsules.
25 BdsLockNonUpdatableFlash (
33 EFI_BOOT_MODE BootMode
39 This routine is called to see if there are any capsules we need to process.
40 If the boot mode is not UPDATE, then we do nothing. Otherwise find the
41 capsule HOBS and produce firmware volumes for them via the DXE service.
42 Then call the dispatcher to dispatch drivers from them. Finally, check
43 the status of the updates.
47 BootMode - the current boot mode
51 EFI_INVALID_PARAMETER - boot mode is not correct for an update
55 This function should be called by BDS in case we need to do some
56 sort of processing even if there is no capsule to process. We
57 need to do this if an earlier update went awry and we need to
58 clear the capsule variable so on the next reset PEI does not see it and
59 think there is a capsule available.
64 EFI_HOB_CAPSULE_VOLUME
*CvHob
;
65 EFI_PHYSICAL_ADDRESS BaseAddress
;
67 EFI_FIRMWARE_VOLUME_HEADER
*FwVolHeader
;
68 EFI_HANDLE FvProtocolHandle
;
71 // We don't do anything else if the boot mode is not flash-update
73 if (BootMode
!= BOOT_ON_FLASH_UPDATE
) {
74 return EFI_INVALID_PARAMETER
;
77 // Only one capsule HOB allowed.
79 CvHob
= GetFirstHob (EFI_HOB_TYPE_CV
);
82 // We didn't find a hob, so had no errors.
84 BdsLockNonUpdatableFlash ();
88 BaseAddress
= CvHob
->BaseAddress
;
89 Length
= CvHob
->Length
;
93 // Now walk the capsule and call the core to process each
94 // firmware volume in it.
98 // Point to the next firmware volume header, and then
99 // call the DXE service to process it.
101 FwVolHeader
= (EFI_FIRMWARE_VOLUME_HEADER
*) (UINTN
) BaseAddress
;
102 if (FwVolHeader
->FvLength
> Length
) {
104 // Notes: need to stuff this status somewhere so that the
105 // error can be detected at OS runtime
107 Status
= EFI_VOLUME_CORRUPTED
;
111 Status
= gDS
->ProcessFirmwareVolume (
112 (VOID
*) (UINTN
) BaseAddress
,
113 (UINTN
) FwVolHeader
->FvLength
,
116 if (EFI_ERROR (Status
)) {
120 // Call the dispatcher to dispatch any drivers from the produced firmware volume
124 // On to the next FV in the capsule
126 Length
-= FwVolHeader
->FvLength
;
127 BaseAddress
= (EFI_PHYSICAL_ADDRESS
) ((UINTN
) BaseAddress
+ FwVolHeader
->FvLength
);
129 // Notes: when capsule spec is finalized, if the requirement is made to
130 // have each FV in a capsule aligned, then we will need to align the
131 // BaseAddress and Length here.
136 BdsLockNonUpdatableFlash ();