49 ASSERT (ImageHandle !=
NULL);
51 Status =
gBS->HandleProtocol (
53 &gEfiLoadedImageProtocolGuid,
115 IN EFI_SECTION_TYPE SectionType,
123 UINT32 AuthenticationStatus;
125 ASSERT (NameGuid !=
NULL);
126 ASSERT (Buffer !=
NULL);
127 ASSERT (Size !=
NULL);
129 if (FvHandle ==
NULL) {
133 return EFI_NOT_FOUND;
136 Status =
gBS->HandleProtocol (
138 &gEfiFirmwareVolume2ProtocolGuid,
141 if (EFI_ERROR (Status)) {
142 return EFI_NOT_FOUND;
150 Status = Fv->ReadSection (
157 &AuthenticationStatus
160 if (EFI_ERROR (Status) && (SectionType == EFI_SECTION_TE)) {
166 Status = Fv->ReadSection (
173 &AuthenticationStatus
231 IN EFI_FV_FILETYPE FileType,
233 IN EFI_SECTION_TYPE SectionType,
249 ASSERT (Buffer !=
NULL);
250 ASSERT (Size !=
NULL);
256 Status =
gBS->LocateHandleBuffer (
258 &gEfiFirmwareVolume2ProtocolGuid,
263 if (EFI_ERROR (Status)) {
270 for (IndexFv = 0; IndexFv < HandleCount; IndexFv++) {
271 Status =
gBS->HandleProtocol (
272 HandleBuffer[IndexFv],
273 &gEfiFirmwareVolume2ProtocolGuid,
276 if (EFI_ERROR (Status)) {
283 IndexFile = FileInstance + 1;
286 Status = Fv->GetNextFile (Fv, &Key, &FileType, &NameGuid, &Attributes, Size);
287 if (EFI_ERROR (Status)) {
292 }
while (IndexFile > 0);
298 if (IndexFile == 0) {
300 HandleBuffer[IndexFv],
308 if (!EFI_ERROR (Status)) {
317 if (IndexFv == HandleCount) {
318 Status = EFI_NOT_FOUND;
322 if (HandleBuffer !=
NULL) {
376 IN EFI_SECTION_TYPE SectionType,
403 if (!EFI_ERROR (Status)) {
408 Status =
gBS->LocateHandleBuffer (
410 &gEfiFirmwareVolume2ProtocolGuid,
415 if (EFI_ERROR (Status)) {
419 for (Index = 0; Index < HandleCount; Index++) {
423 if (HandleBuffer[Index] != FvHandle) {
433 if (!EFI_ERROR (Status)) {
439 if (Index == HandleCount) {
440 Status = EFI_NOT_FOUND;
445 if (HandleBuffer !=
NULL) {
501 IN EFI_SECTION_TYPE SectionType,
562 IN EFI_SECTION_TYPE SectionType,
608 IN BOOLEAN BootPolicy,
611 OUT UINT32 *AuthenticationStatus
620 EFI_SECTION_TYPE SectionType;
622 UINTN ImageBufferSize;
623 EFI_FV_FILETYPE Type;
637 if ((FilePath ==
NULL) || (FileSize ==
NULL) || (AuthenticationStatus ==
NULL)) {
644 TempDevicePathNode =
NULL;
650 *AuthenticationStatus = 0;
656 if (OrigDevicePathNode ==
NULL) {
664 DevicePathNode = OrigDevicePathNode;
665 Status =
gBS->LocateDevicePath (&gEfiFirmwareVolume2ProtocolGuid, &DevicePathNode, &Handle);
666 if (!EFI_ERROR (Status)) {
671 if (FvNameGuid ==
NULL) {
672 Status = EFI_INVALID_PARAMETER;
677 Status =
gBS->HandleProtocol (Handle, &gEfiFirmwareVolume2ProtocolGuid, (VOID **)&FwVol);
678 if (!EFI_ERROR (Status)) {
681 Status = FwVol->ReadSection (
686 (VOID **)&ImageBuffer,
690 if (EFI_ERROR (Status)) {
694 if (ImageBuffer !=
NULL) {
696 *AuthenticationStatus = 0;
700 Status = FwVol->ReadFile (
703 (VOID **)&ImageBuffer,
713 if (!EFI_ERROR (Status)) {
721 DevicePathNode = OrigDevicePathNode;
722 Status =
gBS->LocateDevicePath (&gEfiSimpleFileSystemProtocolGuid, &DevicePathNode, &Handle);
723 if (!EFI_ERROR (Status)) {
724 Status =
gBS->HandleProtocol (Handle, &gEfiSimpleFileSystemProtocolGuid, (VOID **)&Volume);
725 if (!EFI_ERROR (Status)) {
729 Status = Volume->OpenVolume (Volume, &FileHandle);
730 if (!EFI_ERROR (Status)) {
737 if (TempDevicePathNode ==
NULL) {
738 FileHandle->Close (FileHandle);
743 Status = EFI_OUT_OF_RESOURCES;
751 DevicePathNode = TempDevicePathNode;
756 Status = EFI_UNSUPPORTED;
760 LastHandle = FileHandle;
763 Status = LastHandle->Open (
774 LastHandle->Close (LastHandle);
779 if (!EFI_ERROR (Status)) {
786 Status = FileHandle->GetInfo (
793 if (Status == EFI_BUFFER_TOO_SMALL) {
796 Status = EFI_OUT_OF_RESOURCES;
798 Status = FileHandle->GetInfo (
813 if (ImageBuffer ==
NULL) {
814 Status = EFI_OUT_OF_RESOURCES;
820 Status = FileHandle->Read (FileHandle, &ImageBufferSize, ImageBuffer);
833 if (FileHandle !=
NULL) {
834 FileHandle->Close (FileHandle);
837 if (TempDevicePathNode !=
NULL) {
843 if (!EFI_ERROR (Status)) {
852 DevicePathNode = OrigDevicePathNode;
853 Status =
gBS->LocateDevicePath (&gEfiLoadFile2ProtocolGuid, &DevicePathNode, &Handle);
854 if (!EFI_ERROR (Status)) {
855 Status =
gBS->HandleProtocol (Handle, &gEfiLoadFile2ProtocolGuid, (VOID **)&
LoadFile2);
856 if (!EFI_ERROR (Status)) {
869 if (Status == EFI_BUFFER_TOO_SMALL) {
871 if (ImageBuffer ==
NULL) {
872 Status = EFI_OUT_OF_RESOURCES;
885 if (!EFI_ERROR (Status)) {
894 DevicePathNode = OrigDevicePathNode;
895 Status =
gBS->LocateDevicePath (&gEfiLoadFileProtocolGuid, &DevicePathNode, &Handle);
896 if (!EFI_ERROR (Status)) {
897 Status =
gBS->HandleProtocol (Handle, &gEfiLoadFileProtocolGuid, (VOID **)&LoadFile);
898 if (!EFI_ERROR (Status)) {
904 Status = LoadFile->LoadFile (
911 if (Status == EFI_BUFFER_TOO_SMALL) {
913 if (ImageBuffer ==
NULL) {
914 Status = EFI_OUT_OF_RESOURCES;
916 Status = LoadFile->LoadFile (
930 if (EFI_ERROR (Status)) {
931 if (ImageBuffer !=
NULL) {
938 *FileSize = ImageBufferSize;
983 IN EFI_SECTION_TYPE SectionType,
998 if (FvFileDevicePath ==
NULL) {
999 return EFI_INVALID_PARAMETER;
1002 HandleBuffer =
NULL;
1003 FvDevicePath =
NULL;
1004 TempFvFileDevicePath =
NULL;
1023 if (!EFI_ERROR (Status)) {
1027 Status =
gBS->LocateHandleBuffer (
1029 &gEfiFirmwareVolume2ProtocolGuid,
1034 if (EFI_ERROR (Status)) {
1038 for (Index = 0; Index < HandleCount; Index++) {
1042 if (HandleBuffer[Index] != FvHandle) {
1044 HandleBuffer[Index],
1052 if (!EFI_ERROR (Status)) {
1056 FvHandle = HandleBuffer[Index];
1062 if (Index == HandleCount) {
1063 Status = EFI_NOT_FOUND;
1071 Status =
gBS->HandleProtocol (FvHandle, &gEfiDevicePathProtocolGuid, (VOID **)&FvDevicePath);
1072 if (EFI_ERROR (Status)) {
1073 *FvFileDevicePath =
NULL;
1076 if (TempFvFileDevicePath ==
NULL) {
1077 *FvFileDevicePath =
NULL;
1078 return EFI_OUT_OF_RESOURCES;
1091 if (Buffer !=
NULL) {
1095 if (HandleBuffer !=
NULL) {
#define MEDIA_FILEPATH_DP
UINT8 EFIAPI DevicePathType(IN CONST VOID *Node)
UINT8 EFIAPI DevicePathSubType(IN CONST VOID *Node)
BOOLEAN EFIAPI IsDevicePathEnd(IN CONST VOID *Node)
EFI_DEVICE_PATH_PROTOCOL *EFIAPI NextDevicePathNode(IN CONST VOID *Node)
EFI_DEVICE_PATH_PROTOCOL *EFIAPI AppendDevicePath(IN CONST EFI_DEVICE_PATH_PROTOCOL *FirstDevicePath OPTIONAL, IN CONST EFI_DEVICE_PATH_PROTOCOL *SecondDevicePath OPTIONAL)
EFI_DEVICE_PATH_PROTOCOL *EFIAPI DuplicateDevicePath(IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath)
VOID EFIAPI SetDevicePathEndNode(OUT VOID *Node)
EFI_STATUS InternalGetSectionFromFv(IN EFI_HANDLE FvHandle, IN CONST EFI_GUID *NameGuid, IN EFI_SECTION_TYPE SectionType, IN UINTN SectionInstance, OUT VOID **Buffer, OUT UINTN *Size)
EFI_STATUS EFIAPI GetSectionFromFfs(IN EFI_SECTION_TYPE SectionType, IN UINTN SectionInstance, OUT VOID **Buffer, OUT UINTN *Size)
EFI_STATUS EFIAPI GetFileDevicePathFromAnyFv(IN CONST EFI_GUID *NameGuid, IN EFI_SECTION_TYPE SectionType, IN UINTN SectionInstance, OUT EFI_DEVICE_PATH_PROTOCOL **FvFileDevicePath)
EFI_STATUS EFIAPI GetSectionFromAnyFvByFileType(IN EFI_FV_FILETYPE FileType, IN UINTN FileInstance, IN EFI_SECTION_TYPE SectionType, IN UINTN SectionInstance, OUT VOID **Buffer, OUT UINTN *Size)
VOID *EFIAPI GetFileBufferByFilePath(IN BOOLEAN BootPolicy, IN CONST EFI_DEVICE_PATH_PROTOCOL *FilePath, OUT UINTN *FileSize, OUT UINT32 *AuthenticationStatus)
EFI_STATUS EFIAPI GetSectionFromAnyFv(IN CONST EFI_GUID *NameGuid, IN EFI_SECTION_TYPE SectionType, IN UINTN SectionInstance, OUT VOID **Buffer, OUT UINTN *Size)
EFI_STATUS EFIAPI GetSectionFromFv(IN CONST EFI_GUID *NameGuid, IN EFI_SECTION_TYPE SectionType, IN UINTN SectionInstance, OUT VOID **Buffer, OUT UINTN *Size)
EFI_HANDLE InternalImageHandleToFvHandle(EFI_HANDLE ImageHandle)
VOID *EFIAPI AllocateZeroPool(IN UINTN AllocationSize)
VOID EFIAPI FreePool(IN VOID *Buffer)
#define ASSERT_EFI_ERROR(StatusParameter)
EFI_STATUS EFIAPI LoadFile2(IN EFI_LOAD_FILE2_PROTOCOL *This, IN EFI_DEVICE_PATH_PROTOCOL *FilePath, IN BOOLEAN BootPolicy, IN OUT UINTN *BufferSize, IN VOID *Buffer OPTIONAL)
UINT32 EFI_FV_FILE_ATTRIBUTES
VOID *EFIAPI AllocatePool(IN UINTN AllocationSize)
EFI_FILE_INFO * FileInfo(IN EFI_FILE_HANDLE FHand)
VOID EFIAPI EfiInitializeFwVolDevicepathNode(IN OUT MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvDevicePathNode, IN CONST EFI_GUID *NameGuid)
EFI_GUID *EFIAPI EfiGetNameGuidFromFwVolDevicePathNode(IN CONST MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvDevicePathNode)
EFI_HANDLE DeviceHandle
The device handle that the EFI Image was loaded from.