From 0a9fe763390d9ba730e8bd0b017b0d51742543fb Mon Sep 17 00:00:00 2001 From: gikidy Date: Fri, 3 Apr 2009 08:13:16 +0000 Subject: [PATCH] Add loaded Image device paths for EFI Drivers loaded from PCI Option ROM. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@8022 6f19259b-4bc3-4df7-8a09-765794883524 --- MdeModulePkg/Core/Dxe/DxeMain.h | 1 + MdeModulePkg/Core/Dxe/DxeMain.inf | 1 + MdeModulePkg/Core/Dxe/Image/ImageFile.c | 47 +++++++++++++++++++++++++ 3 files changed, 49 insertions(+) diff --git a/MdeModulePkg/Core/Dxe/DxeMain.h b/MdeModulePkg/Core/Dxe/DxeMain.h index 1680e7d830..d499ab4850 100644 --- a/MdeModulePkg/Core/Dxe/DxeMain.h +++ b/MdeModulePkg/Core/Dxe/DxeMain.h @@ -25,6 +25,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include #include #include +#include #include #include #include diff --git a/MdeModulePkg/Core/Dxe/DxeMain.inf b/MdeModulePkg/Core/Dxe/DxeMain.inf index ead72162f8..9baef70b7e 100644 --- a/MdeModulePkg/Core/Dxe/DxeMain.inf +++ b/MdeModulePkg/Core/Dxe/DxeMain.inf @@ -110,6 +110,7 @@ gEfiLoadPeImageProtocolGuid ## PRODUCES gEfiSimpleFileSystemProtocolGuid ## CONSUMES gEfiLoadFileProtocolGuid ## CONSUMES + gEfiLoadFile2ProtocolGuid ## CONSUMES gEfiResetArchProtocolGuid ## CONSUMES gEfiRealTimeClockArchProtocolGuid ## CONSUMES gEfiRuntimeArchProtocolGuid ## CONSUMES diff --git a/MdeModulePkg/Core/Dxe/Image/ImageFile.c b/MdeModulePkg/Core/Dxe/Image/ImageFile.c index b132cf49d5..9c6729a8fd 100644 --- a/MdeModulePkg/Core/Dxe/Image/ImageFile.c +++ b/MdeModulePkg/Core/Dxe/Image/ImageFile.c @@ -90,6 +90,7 @@ CoreOpenImageFile ( EFI_FILE_HANDLE FileHandle; EFI_FILE_HANDLE LastHandle; EFI_LOAD_FILE_PROTOCOL *LoadFile; + EFI_LOAD_FILE2_PROTOCOL *LoadFile2; EFI_FIRMWARE_VOLUME2_PROTOCOL *FwVol; EFI_SECTION_TYPE SectionType; UINT8 *Pe32Buffer; @@ -315,6 +316,52 @@ CoreOpenImageFile ( } } + // + // Try LoadFile2 style + // + if (!BootPolicy) { + TempFilePath = *FilePath; + Status = CoreDevicePathToInterface ( + &gEfiLoadFile2ProtocolGuid, + &TempFilePath, + (VOID*)&LoadFile2, + DeviceHandle + ); + if (!EFI_ERROR (Status)) { + // + // Call LoadFile2 with the correct buffer size + // + ASSERT (ImageFileHandle->SourceSize == 0); + ASSERT (ImageFileHandle->Source == NULL); + + Status = LoadFile2->LoadFile ( + LoadFile2, + TempFilePath, + BootPolicy, + &ImageFileHandle->SourceSize, + ImageFileHandle->Source + ); + if (Status == EFI_BUFFER_TOO_SMALL) { + ImageFileHandle->Source = AllocatePool (ImageFileHandle->SourceSize); + if (ImageFileHandle->Source == NULL) { + Status = EFI_OUT_OF_RESOURCES; + } else { + Status = LoadFile2->LoadFile ( + LoadFile2, + TempFilePath, + BootPolicy, + &ImageFileHandle->SourceSize, + ImageFileHandle->Source + ); + } + } + + if (!EFI_ERROR (Status)) { + ImageFileHandle->FreeBuffer = TRUE; + goto Done; + } + } + } // // Try LoadFile style -- 2.39.2