ArmPkg/BdsLib: Add support to pass argument to a loaded EFI application

OptionalData argument has to be set in the Loaded Image Protocol of the
new EFI application.



git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12313 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
oliviermartin 2011-09-09 10:53:42 +00:00
parent a6e97d28aa
commit 2755d844f9
5 changed files with 29 additions and 8 deletions

View File

@ -100,7 +100,9 @@ BdsBootLinux (
EFI_STATUS EFI_STATUS
BdsStartEfiApplication ( BdsStartEfiApplication (
IN EFI_HANDLE ParentImageHandle, IN EFI_HANDLE ParentImageHandle,
IN EFI_DEVICE_PATH_PROTOCOL *DevicePath IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,
IN UINTN LoadOptionsSize,
IN VOID* LoadOptions
); );
/** /**
@ -116,7 +118,9 @@ BdsStartEfiApplication (
EFI_STATUS EFI_STATUS
BdsLoadApplication ( BdsLoadApplication (
IN EFI_HANDLE ParentImageHandle, IN EFI_HANDLE ParentImageHandle,
IN CHAR16* EfiApp IN CHAR16* EfiApp,
IN UINTN LoadOptionsSize,
IN VOID* LoadOptions
); );
#endif #endif

View File

@ -105,7 +105,9 @@ BdsLoadFileFromFirmwareVolume (
EFI_STATUS EFI_STATUS
BdsLoadApplication ( BdsLoadApplication (
IN EFI_HANDLE ParentImageHandle, IN EFI_HANDLE ParentImageHandle,
IN CHAR16* EfiApp IN CHAR16* EfiApp,
IN UINTN LoadOptionsSize,
IN VOID* LoadOptions
) )
{ {
EFI_STATUS Status; EFI_STATUS Status;
@ -133,7 +135,7 @@ BdsLoadApplication (
Status = BdsLoadFileFromFirmwareVolume (Handles[HandleIndex], EfiApp, EFI_FV_FILETYPE_APPLICATION, &EfiAppDevicePath); Status = BdsLoadFileFromFirmwareVolume (Handles[HandleIndex], EfiApp, EFI_FV_FILETYPE_APPLICATION, &EfiAppDevicePath);
if (!EFI_ERROR (Status)) { if (!EFI_ERROR (Status)) {
// Start the application // Start the application
Status = BdsStartEfiApplication (ParentImageHandle, EfiAppDevicePath); Status = BdsStartEfiApplication (ParentImageHandle, EfiAppDevicePath, LoadOptionsSize, LoadOptions);
return Status; return Status;
} }
} }

View File

@ -16,6 +16,7 @@
#include <Protocol/UsbIo.h> #include <Protocol/UsbIo.h>
#include <Protocol/DiskIo.h> #include <Protocol/DiskIo.h>
#include <Protocol/LoadedImage.h>
#define IS_DEVICE_PATH_NODE(node,type,subtype) (((node)->Type == (type)) && ((node)->SubType == (subtype))) #define IS_DEVICE_PATH_NODE(node,type,subtype) (((node)->Type == (type)) && ((node)->SubType == (subtype)))
@ -856,13 +857,16 @@ BdsLoadImage (
EFI_STATUS EFI_STATUS
BdsStartEfiApplication ( BdsStartEfiApplication (
IN EFI_HANDLE ParentImageHandle, IN EFI_HANDLE ParentImageHandle,
IN EFI_DEVICE_PATH_PROTOCOL *DevicePath IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,
IN UINTN LoadOptionsSize,
IN VOID* LoadOptions
) )
{ {
EFI_STATUS Status; EFI_STATUS Status;
EFI_HANDLE ImageHandle; EFI_HANDLE ImageHandle;
EFI_PHYSICAL_ADDRESS BinaryBuffer; EFI_PHYSICAL_ADDRESS BinaryBuffer;
UINTN BinarySize; UINTN BinarySize;
EFI_LOADED_IMAGE_PROTOCOL* LoadedImage;
// Find the nearest supported file loader // Find the nearest supported file loader
Status = BdsLoadImage (DevicePath, AllocateAnyPages, &BinaryBuffer, &BinarySize); Status = BdsLoadImage (DevicePath, AllocateAnyPages, &BinaryBuffer, &BinarySize);
@ -876,6 +880,17 @@ BdsStartEfiApplication (
return Status; return Status;
} }
// Passed LoadOptions to the EFI Application
if (LoadOptionsSize != 0) {
Status = gBS->HandleProtocol (ImageHandle, &gEfiLoadedImageProtocolGuid, (VOID **) &LoadedImage);
if (EFI_ERROR(Status)) {
return Status;
}
LoadedImage->LoadOptionsSize = LoadOptionsSize;
LoadedImage->LoadOptions = LoadOptions;
}
// Before calling the image, enable the Watchdog Timer for the 5 Minute period // Before calling the image, enable the Watchdog Timer for the 5 Minute period
gBS->SetWatchdogTimer (5 * 60, 0x0000, 0x00, NULL); gBS->SetWatchdogTimer (5 * 60, 0x0000, 0x00, NULL);
// Start the image // Start the image

View File

@ -478,7 +478,7 @@ BootEBL (
EFI_STATUS Status; EFI_STATUS Status;
// Start EFI Shell // Start EFI Shell
Status = BdsLoadApplication(mImageHandle, L"Ebl"); Status = BdsLoadApplication (mImageHandle, L"Ebl", 0, NULL);
if (Status == EFI_NOT_FOUND) { if (Status == EFI_NOT_FOUND) {
Print (L"Error: EFI Application not found.\n"); Print (L"Error: EFI Application not found.\n");
} else if (EFI_ERROR(Status)) { } else if (EFI_ERROR(Status)) {

View File

@ -85,7 +85,7 @@ BootOptionStart (
FdtDevicePath); FdtDevicePath);
} }
} else { } else {
Status = BdsStartEfiApplication (mImageHandle, BootOption->FilePathList); Status = BdsStartEfiApplication (mImageHandle, BootOption->FilePathList, BootOption->OptionalDataSize, BootOption->OptionalData);
} }
return Status; return Status;