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.
23 #include <Guid/FlashMapHob.h>
27 IN EFI_CPU_IO_PROTOCOL
*CpuIo
,
28 IN EFI_FLASH_SUBAREA_ENTRY
*FlashEntry
33 IN EFI_CPU_IO_PROTOCOL
*CpuIo
,
34 IN EFI_FLASH_SUBAREA_ENTRY
*FlashEntry
40 BdsLockNonUpdatableFlash (
48 EFI_BOOT_MODE BootMode
54 This routine is called to see if there are any capsules we need to process.
55 If the boot mode is not UPDATE, then we do nothing. Otherwise find the
56 capsule HOBS and produce firmware volumes for them via the DXE service.
57 Then call the dispatcher to dispatch drivers from them. Finally, check
58 the status of the updates.
62 BootMode - the current boot mode
66 EFI_INVALID_PARAMETER - boot mode is not correct for an update
70 This function should be called by BDS in case we need to do some
71 sort of processing even if there is no capsule to process. We
72 need to do this if an earlier update went awry and we need to
73 clear the capsule variable so on the next reset PEI does not see it and
74 think there is a capsule available.
79 EFI_HOB_CAPSULE_VOLUME
*CvHob
;
80 EFI_PHYSICAL_ADDRESS BaseAddress
;
82 EFI_FIRMWARE_VOLUME_HEADER
*FwVolHeader
;
83 EFI_HANDLE FvProtocolHandle
;
86 // We don't do anything else if the boot mode is not flash-update
88 if (BootMode
!= BOOT_ON_FLASH_UPDATE
) {
89 return EFI_INVALID_PARAMETER
;
92 // Only one capsule HOB allowed.
94 CvHob
= GetFirstHob (EFI_HOB_TYPE_CV
);
97 // We didn't find a hob, so had no errors.
99 BdsLockNonUpdatableFlash ();
103 BaseAddress
= CvHob
->BaseAddress
;
104 Length
= CvHob
->Length
;
106 Status
= EFI_SUCCESS
;
108 // Now walk the capsule and call the core to process each
109 // firmware volume in it.
111 while (Length
!= 0) {
113 // Point to the next firmware volume header, and then
114 // call the DXE service to process it.
116 FwVolHeader
= (EFI_FIRMWARE_VOLUME_HEADER
*) (UINTN
) BaseAddress
;
117 if (FwVolHeader
->FvLength
> Length
) {
119 // Notes: need to stuff this status somewhere so that the
120 // error can be detected at OS runtime
122 Status
= EFI_VOLUME_CORRUPTED
;
126 Status
= gDS
->ProcessFirmwareVolume (
127 (VOID
*) (UINTN
) BaseAddress
,
128 (UINTN
) FwVolHeader
->FvLength
,
131 if (EFI_ERROR (Status
)) {
135 // Call the dispatcher to dispatch any drivers from the produced firmware volume
139 // On to the next FV in the capsule
141 Length
-= FwVolHeader
->FvLength
;
142 BaseAddress
= (EFI_PHYSICAL_ADDRESS
) ((UINTN
) BaseAddress
+ FwVolHeader
->FvLength
);
144 // Notes: when capsule spec is finalized, if the requirement is made to
145 // have each FV in a capsule aligned, then we will need to align the
146 // BaseAddress and Length here.
151 BdsLockNonUpdatableFlash ();