Hi guys,
I’m writing a small EFI shim that will load the Windows UEFI loader
*bootmgfw.efi *and run it. Here’s the relevant code snippet:
bootProgramName = "boot\\x64\\bootmgfw.efi";
// Get the size of bootmgfw.efi from the TFTP server
status = pxeProtocol->Mtftp(pxeProtocol,
EFI_PXE_BASE_CODE_TFTP_GET_FILE_SIZE, NULL, FALSE, &bootProgramSize,
&tftpBlockSize, &bootServerIp, bootProgramName, NULL, FALSE);
// Allocate buffer and download bootmgfw.efi
bootProgramBuffer = AllocatePool(bootProgramSize);
status = pxeProtocol->Mtftp(pxeProtocol, EFI_PXE_BASE_CODE_TFTP_READ_FILE,
bootProgramBuffer, FALSE, &bootProgramSize, &tftpBlockSize, &bootServerIp,
bootProgramName, NULL, FALSE);
// Load it as an image
status = gBS->LoadImage(FALSE, NULL, NULL, bootProgramBuffer,
bootProgramSize, &loadedBootProgram);
FreePool(bootProgramBuffer);
// And start it.
status = gBS->StartImage(loadedBootProgram, NULL, NULL); *<--- This call
returns status 2 (EFI_INVALID_PARAMETER)*
The shim downloads the bootmgfw.efi file correctly and successfully loads
it with LoadImage(). However, when it tries to transfer control to it by
calling StartImage() an EFI_INVALID_PARAMETER status is returned. As per
UEFI documentation this status code means the image is not valid.
I’ve tried to tweak the PE headers of this image (file alignment and all),
but nothing has worked. I don’t know any other reason why the image can be
invalid.
The shim successfully loads and starts other .efi files that I’ve created
myself using EDK. So I can’t see what’s wrong with this code either.
Also *bootmgfw.efi* runs successfully if it is directly downloaded by the
machine firmware over PXE (without my shim being involved at all).
Could anyone please spot what I’m doing wrong in the above code and help
me? Or, if anyone has previous experience with this Microsoft boot loader,
is there something special about it that I'm missing?
Thanks in advance.
Here’s the relevant information about my environment:
*UEFI machine*: a HyperV virtual machine.
*TOOL_CHAIN_TAG value*: VS2012x86.
*Architecture I’m building this shim for*: x64
*Architecture of bootmgfw.efi*: x64
*My build command-line*:
cd /D D:\Projects\1E\tianocore-edk2
set WORKSPACE=D:\Projects\1E\tianocore-edk2
call edksetup.bat
Build -a X64 -p DuetPkg/DuetPkgX64.dsc
Cheers,
Gurinder
------------------------------------------------------------------------------
Open source business process management suite built on Java and Eclipse
Turn processes into business applications with Bonita BPM Community Edition
Quickly connect people, data, and systems into organized workflows
Winner of BOSSIE, CODIE, OW2 and Gartner awards
http://p.sf.net/sfu/Bonitasoft
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel