70 (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
71 &gEdkiiPeiCapsuleOnDiskPpiGuid,
94 &gEfiPeiCapsulePpiGuid,
99 if (!EFI_ERROR (Status)) {
101 if (!EFI_ERROR (Status)) {
125 BOOLEAN CodRelocInfo;
128 &gEfiPeiReadOnlyVariable2PpiGuid,
131 (VOID **)&PPIVariableServices
135 Size =
sizeof (BOOLEAN);
136 Status = PPIVariableServices->GetVariable (
138 COD_RELOCATION_INFO_VAR_NAME,
139 &gEfiCapsuleVendorGuid,
145 if (EFI_ERROR (Status) || (Size !=
sizeof (BOOLEAN)) || !CodRelocInfo) {
146 DEBUG ((DEBUG_ERROR,
"Error Get CodRelocationInfo variable %r!\n", Status));
171RetrieveRelocatedCapsule (
172 IN UINT8 *RelocCapsuleBuf,
177 UINT8 *CapsuleDataBufEnd;
180 UINT64 TotalImageSize;
187 return EFI_INVALID_PARAMETER;
190 CopyMem (&TotalImageSize, RelocCapsuleBuf,
sizeof (UINT64));
194 "ProcessRelocatedCapsule CapsuleBuf %x TotalCapSize %lx\n",
199 RelocCapsuleBuf +=
sizeof (UINT64);
204 if ((
MAX_ADDRESS - TotalImageSize <=
sizeof (UINT64)) ||
205 ((UINT64)RelocCapsuleTotalSize != TotalImageSize +
sizeof (UINT64)) ||
208 return EFI_INVALID_PARAMETER;
211 CapsuleDataBufEnd = RelocCapsuleBuf + TotalImageSize;
216 CapsulePtr = RelocCapsuleBuf;
219 while (CapsulePtr < CapsuleDataBufEnd) {
232 if (CapsulePtr != CapsuleDataBufEnd) {
233 return EFI_INVALID_PARAMETER;
239 if (CapsuleNum >
PcdGet16 (PcdCapsuleMax)) {
240 return EFI_INVALID_PARAMETER;
246 CapsulePtr = RelocCapsuleBuf;
248 while (CapsulePtr < CapsuleDataBufEnd) {
252 DEBUG ((DEBUG_INFO,
"Capsule saved in address %x size %x\n", CapsulePtr, CapsuleSize));
254 CapsulePtr += CapsuleSize;
281 ASSERT (BootMode == BOOT_ON_FLASH_UPDATE);
287 if (CheckCapsuleFromRam (PeiServices)) {
288 DEBUG ((DEBUG_ERROR,
"Capsule On Memory Detected! Quit.\n"));
293 VOID *CapsuleOnDiskModePpi;
295 if (!IsCapsuleOnDiskMode ()) {
296 return EFI_NOT_FOUND;
303 &gEdkiiPeiBootInCapsuleOnDiskModePpiGuid,
306 (VOID **)&CapsuleOnDiskModePpi
308 if (EFI_ERROR (Status)) {
309 DEBUG ((DEBUG_ERROR,
"Locate CapsuleOnDiskModePpi error %x\n", Status));
318 FileNameSize =
PcdGetSize (PcdCoDRelocationFileName);
319 Status =
PcdSetPtrS (PcdRecoveryFileName, &FileNameSize, (VOID *)
PcdGetPtr (PcdCoDRelocationFileName));
346 UINTN NumberRecoveryCapsules;
348 UINTN CapsuleInstance;
353 DEBUG ((DEBUG_INFO | DEBUG_LOAD,
"Load Capsule On Disk Entry\n"));
355 for (Instance = 0; ; Instance++) {
357 &gEfiPeiDeviceRecoveryModulePpiGuid,
360 (VOID **)&DeviceRecoveryPpi
362 DEBUG ((DEBUG_INFO,
"LoadCapsuleOnDisk - LocateRecoveryPpi (%d) - %r\n", Instance, Status));
363 if (EFI_ERROR (Status)) {
366 EFI_ERROR_CODE | EFI_ERROR_MAJOR,
367 (EFI_SOFTWARE_PEI_MODULE | EFI_SW_PEI_EC_RECOVERY_PPI_NOT_FOUND)
374 NumberRecoveryCapsules = 0;
375 Status = DeviceRecoveryPpi->GetNumberRecoveryCapsules (
378 &NumberRecoveryCapsules
380 DEBUG ((DEBUG_INFO,
"LoadCapsuleOnDisk - GetNumberRecoveryCapsules (%d) - %r\n", NumberRecoveryCapsules, Status));
381 if (EFI_ERROR (Status)) {
385 for (CapsuleInstance = 1; CapsuleInstance <= NumberRecoveryCapsules; CapsuleInstance++) {
387 Status = DeviceRecoveryPpi->GetRecoveryCapsuleInfo (
394 DEBUG ((DEBUG_INFO,
"LoadCapsuleOnDisk - GetRecoveryCapsuleInfo (%d - %x) - %r\n", CapsuleInstance, CapsuleSize, Status));
395 if (EFI_ERROR (Status)) {
405 if (CapsuleBuffer ==
NULL) {
406 DEBUG ((DEBUG_ERROR,
"LoadCapsuleOnDisk - AllocateRuntimePages fail\n"));
410 Status = DeviceRecoveryPpi->LoadRecoveryCapsule (
416 DEBUG ((DEBUG_INFO,
"LoadCapsuleOnDisk - LoadRecoveryCapsule (%d) - %r\n", CapsuleInstance, Status));
417 if (EFI_ERROR (Status)) {
425 Status = RetrieveRelocatedCapsule (CapsuleBuffer, CapsuleSize);
430 if (EFI_ERROR (Status)) {
432 EFI_ERROR_CODE | EFI_ERROR_MAJOR,
446 return EFI_NOT_FOUND;
VOID EFIAPI BuildCvHob(IN EFI_PHYSICAL_ADDRESS BaseAddress, IN UINT64 Length)
EFI_BOOT_MODE EFIAPI GetBootModeHob(VOID)
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
EFI_STATUS EFIAPI LoadCapsuleOnDisk(IN EFI_PEI_SERVICES **PeiServices, IN EDKII_PEI_CAPSULE_ON_DISK_PPI *This)
EFI_STATUS EFIAPI InitializeCapsuleOnDiskLoad(IN EFI_PEI_FILE_HANDLE FileHandle, IN CONST EFI_PEI_SERVICES **PeiServices)
VOID EFIAPI FreePages(IN VOID *Buffer, IN UINTN Pages)
EFI_STATUS EFIAPI PeiServicesLocatePpi(IN CONST EFI_GUID *Guid, IN UINTN Instance, IN OUT EFI_PEI_PPI_DESCRIPTOR **PpiDescriptor, IN OUT VOID **Ppi)
EFI_STATUS EFIAPI PeiServicesInstallPpi(IN CONST EFI_PEI_PPI_DESCRIPTOR *PpiList)
#define ASSERT_EFI_ERROR(StatusParameter)
#define DEBUG_CODE_BEGIN()
#define DEBUG(Expression)
#define REPORT_STATUS_CODE(Type, Value)
#define PcdGet16(TokenName)
#define PcdGetSize(TokenName)
#define PcdSetPtrS(TokenName, SizeOfBuffer, Buffer)
#define PcdGetPtr(TokenName)
VOID * EFI_PEI_FILE_HANDLE
#define EFI_SW_PEI_EC_NO_RECOVERY_CAPSULE
VOID *EFIAPI AllocateRuntimePages(IN UINTN Pages)
UINT64 EFI_PHYSICAL_ADDRESS
#define EFI_SIZE_TO_PAGES(Size)