31 END_ENTIRE_DEVICE_PATH_SUBTYPE,
33 END_DEVICE_PATH_LENGTH,
53 END_ENTIRE_DEVICE_PATH_SUBTYPE,
55 END_DEVICE_PATH_LENGTH,
100 FvbDevice = FVB_DEVICE_FROM_THIS (This);
105 *Attributes = FvbDevice->FvbAttributes & ~EFI_FVB2_WRITE_STATUS;
130 return EFI_UNSUPPORTED;
163 return EFI_UNSUPPORTED;
200 UINTN NumOfBytesRead;
203 FvbDevice = FVB_DEVICE_FROM_THIS (This);
208 if ((FvbDevice->FvbAttributes & EFI_FVB2_READ_STATUS) == 0) {
209 return EFI_ACCESS_DENIED;
212 LbaIndex = (
UINTN)Lba;
213 if (LbaIndex >= FvbDevice->NumBlocks) {
218 return EFI_BAD_BUFFER_SIZE;
221 if (Offset > FvbDevice->LbaCache[LbaIndex].Length) {
226 return EFI_BAD_BUFFER_SIZE;
229 NumOfBytesRead = *NumBytes;
230 if (Offset + NumOfBytesRead > FvbDevice->LbaCache[LbaIndex].Length) {
234 NumOfBytesRead = FvbDevice->LbaCache[LbaIndex].Length - Offset;
237 LbaStart = FvbDevice->LbaCache[LbaIndex].Base;
239 LbaOffset = (UINT8 *)FwVolHeader + LbaStart + Offset;
244 CopyMem (Buffer, LbaOffset, NumOfBytesRead);
246 if (NumOfBytesRead == *NumBytes) {
250 *NumBytes = NumOfBytesRead;
251 return EFI_BAD_BUFFER_SIZE;
288 return EFI_UNSUPPORTED;
310 FvbDevice = FVB_DEVICE_FROM_THIS (This);
312 if ((FvbDevice->FvbAttributes & EFI_FVB2_MEMORY_MAPPED) != 0) {
313 *Address = FvbDevice->BaseAddress;
317 return EFI_UNSUPPORTED;
351 FvbDevice = FVB_DEVICE_FROM_THIS (This);
356 if (Lba >= FvbDevice->NumBlocks) {
357 return EFI_INVALID_PARAMETER;
362 PtrBlockMapEntry = FwVolHeader->
BlockMap;
368 while ((PtrBlockMapEntry->
NumBlocks != 0) || (PtrBlockMapEntry->
Length != 0)) {
369 TotalBlocks += PtrBlockMapEntry->
NumBlocks;
370 if (Lba < TotalBlocks) {
380 *BlockSize = PtrBlockMapEntry->
Length;
381 *NumberOfBlocks = TotalBlocks - (
UINTN)Lba;
401 UINT32 AuthenticationStatus;
403 AuthenticationStatus = 0;
405 if (FvbDevice->Signature == FVB_DEVICE_SIGNATURE) {
406 AuthenticationStatus = FvbDevice->AuthenticationStatus;
409 return AuthenticationStatus;
436 IN UINT32 AuthenticationStatus,
454 if (FwVolHeader->
Signature != EFI_FVH_SIGNATURE) {
455 return EFI_VOLUME_CORRUPTED;
463 if ((FwVolHeader->
Attributes & EFI_FVB2_WEAK_ALIGNMENT) != EFI_FVB2_WEAK_ALIGNMENT) {
467 FvAlignment = 1 << ((FwVolHeader->
Attributes & EFI_FVB2_ALIGNMENT) >> 16);
471 if (FvAlignment < 8) {
475 if ((
UINTN)BaseAddress % FvAlignment != 0) {
481 "Unaligned FvImage found at 0x%lx:0x%lx, the required alignment is 0x%x\n",
486 return EFI_VOLUME_CORRUPTED;
494 if (FvbDev ==
NULL) {
495 return EFI_OUT_OF_RESOURCES;
498 FvbDev->BaseAddress = BaseAddress;
499 FvbDev->FvbAttributes = FwVolHeader->
Attributes;
501 FvbDev->AuthenticationStatus = AuthenticationStatus;
507 FvbDev->NumBlocks = 0;
508 for (PtrBlockMapEntry = FwVolHeader->
BlockMap;
512 FvbDev->NumBlocks += PtrBlockMapEntry->
NumBlocks;
520 return EFI_OUT_OF_RESOURCES;
524 if (FvbDev->LbaCache ==
NULL) {
526 return EFI_OUT_OF_RESOURCES;
534 for (PtrBlockMapEntry = FwVolHeader->
BlockMap;
535 PtrBlockMapEntry->
NumBlocks != 0; PtrBlockMapEntry++)
537 for (BlockIndex2 = 0; BlockIndex2 < PtrBlockMapEntry->
NumBlocks; BlockIndex2++) {
538 FvbDev->LbaCache[BlockIndex].Base = LinearOffset;
539 FvbDev->LbaCache[BlockIndex].Length = PtrBlockMapEntry->
Length;
540 LinearOffset += PtrBlockMapEntry->
Length;
553 if (FvbDev->DevicePath ==
NULL) {
556 return EFI_OUT_OF_RESOURCES;
566 if (FvbDev->DevicePath ==
NULL) {
569 return EFI_OUT_OF_RESOURCES;
584 &gEfiFirmwareVolumeBlockProtocolGuid,
585 &FvbDev->FwVolBlockInstance,
586 &gEfiDevicePathProtocolGuid,
594 if (FvProtocol !=
NULL) {
595 *FvProtocol = FvbDev->Handle;
620 UINT32 AuthenticationStatus;
626 while ((FvHob.Raw =
GetNextHob (EFI_HOB_TYPE_FV, FvHob.Raw)) !=
NULL) {
627 AuthenticationStatus = 0;
632 while ((Fv3Hob.Raw =
GetNextHob (EFI_HOB_TYPE_FV3, Fv3Hob.Raw)) !=
NULL) {
634 (Fv3Hob.FirmwareVolume3->
Length == FvHob.FirmwareVolume->
Length))
640 Fv3Hob.Raw = GET_NEXT_HOB (Fv3Hob);
647 FvHob.Raw = GET_NEXT_HOB (FvHob);
685 *FVProtocolHandle =
NULL;
701 if (!EFI_ERROR (Status)) {
702 ASSERT (*FVProtocolHandle !=
NULL);
704 Status =
CoreHandleProtocol (*FVProtocolHandle, &gEfiFirmwareVolume2ProtocolGuid, (VOID **)&Ptr);
705 if (EFI_ERROR (Status) || (Ptr ==
NULL)) {
706 return EFI_VOLUME_CORRUPTED;
VOID *EFIAPI GetNextHob(IN UINT16 Type, IN CONST VOID *HobStart)
VOID *EFIAPI GetHobList(VOID)
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
GUID *EFIAPI CopyGuid(OUT GUID *DestinationGuid, IN CONST GUID *SourceGuid)
#define HARDWARE_DEVICE_PATH
#define MEDIA_PIWG_FW_VOL_DP
EFI_STATUS EFIAPI CoreHandleProtocol(IN EFI_HANDLE UserHandle, IN EFI_GUID *Protocol, OUT VOID **Interface)
EFI_STATUS EFIAPI CoreInstallMultipleProtocolInterfaces(IN OUT EFI_HANDLE *Handle,...)
EFI_STATUS EFIAPI CoreFreePool(IN VOID *Buffer)
VOID EFIAPI FreePool(IN VOID *Buffer)
VOID *EFIAPI AllocateCopyPool(IN UINTN AllocationSize, IN CONST VOID *Buffer)
EFI_STATUS(EFIAPI * EFI_FVB_WRITE)(IN CONST EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL *This, IN EFI_LBA Lba, IN UINTN Offset, IN OUT UINTN *NumBytes, IN UINT8 *Buffer)
EFI_STATUS(EFIAPI * EFI_FVB_SET_ATTRIBUTES)(IN CONST EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL *This, IN OUT EFI_FVB_ATTRIBUTES_2 *Attributes)
EFI_STATUS(EFIAPI * EFI_FVB_ERASE_BLOCKS)(IN CONST EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL *This,...)
EFI_STATUS EFIAPI FwVolBlockGetBlockSize(IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This, IN CONST EFI_LBA Lba, IN OUT UINTN *BlockSize, IN OUT UINTN *NumberOfBlocks)
EFI_STATUS EFIAPI FwVolBlockGetPhysicalAddress(IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This, OUT EFI_PHYSICAL_ADDRESS *Address)
EFI_STATUS ProduceFVBProtocolOnBuffer(IN EFI_PHYSICAL_ADDRESS BaseAddress, IN UINT64 Length, IN EFI_HANDLE ParentHandle, IN UINT32 AuthenticationStatus, OUT EFI_HANDLE *FvProtocol OPTIONAL)
EFI_STATUS EFIAPI FwVolBlockSetAttributes(IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This, IN CONST EFI_FVB_ATTRIBUTES_2 *Attributes)
EFI_STATUS EFIAPI CoreProcessFirmwareVolume(IN VOID *FvHeader, IN UINTN Size, OUT EFI_HANDLE *FVProtocolHandle)
UINT32 GetFvbAuthenticationStatus(IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *FvbProtocol)
EFI_STATUS EFIAPI FwVolBlockWriteBlock(IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This, IN EFI_LBA Lba, IN UINTN Offset, IN OUT UINTN *NumBytes, IN UINT8 *Buffer)
EFI_STATUS EFIAPI FwVolBlockReadBlock(IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This, IN CONST EFI_LBA Lba, IN CONST UINTN Offset, IN OUT UINTN *NumBytes, IN OUT UINT8 *Buffer)
EFI_STATUS EFIAPI FwVolBlockDriverInit(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
EFI_STATUS EFIAPI FwVolBlockGetAttributes(IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This, OUT EFI_FVB_ATTRIBUTES_2 *Attributes)
EFI_STATUS EFIAPI FwVolBlockEraseBlock(IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,...)
#define BASE_CR(Record, TYPE, Field)
#define DEBUG(Expression)
UINT32 EFI_FVB_ATTRIBUTES_2
VOID *EFIAPI AllocatePool(IN UINTN AllocationSize)
UINT64 EFI_PHYSICAL_ADDRESS
EFI_FV_BLOCK_MAP_ENTRY BlockMap[1]
EFI_FVB_ATTRIBUTES_2 Attributes
UINT32 AuthenticationStatus
EFI_PHYSICAL_ADDRESS BaseAddress
EFI_PHYSICAL_ADDRESS BaseAddress