mirror of https://github.com/acidanthera/audk.git
EmbeddedPkg/AndroidFastboot: drop dependency on the LinuxLoader
When booting the kernel via Fastboot, invoke the kernel image directly rather than passing it to the LinuxLoader app. This requires the kernel image to be built with UEFI stub support. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Tested-by: Ryan Harkin <ryan.harkin@linaro.org> Reviewed-by: Ryan Harkin <ryan.harkin@linaro.org>
This commit is contained in:
parent
45b18ce5b1
commit
34e0bceabf
|
@ -21,11 +21,6 @@
|
||||||
#include <Library/UefiBootServicesTableLib.h>
|
#include <Library/UefiBootServicesTableLib.h>
|
||||||
#include <Library/UefiLib.h>
|
#include <Library/UefiLib.h>
|
||||||
|
|
||||||
#define LINUX_LOADER_COMMAND_LINE L"%s -f %s -c %s"
|
|
||||||
|
|
||||||
// This GUID is defined in the INGF file of ArmPkg/Application/LinuxLoader
|
|
||||||
CONST EFI_GUID mLinuxLoaderAppGuid = { 0x701f54f2, 0x0d70, 0x4b89, { 0xbc, 0x0a, 0xd9, 0xca, 0x25, 0x37, 0x90, 0x59 }};
|
|
||||||
|
|
||||||
// Device Path representing an image in memory
|
// Device Path representing an image in memory
|
||||||
#pragma pack(1)
|
#pragma pack(1)
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -68,11 +63,7 @@ BootAndroidBootImg (
|
||||||
VOID *Ramdisk;
|
VOID *Ramdisk;
|
||||||
UINTN RamdiskSize;
|
UINTN RamdiskSize;
|
||||||
MEMORY_DEVICE_PATH KernelDevicePath;
|
MEMORY_DEVICE_PATH KernelDevicePath;
|
||||||
MEMORY_DEVICE_PATH* RamdiskDevicePath;
|
CHAR16 *LoadOptions, *NewLoadOptions;
|
||||||
CHAR16* KernelDevicePathTxt;
|
|
||||||
CHAR16* RamdiskDevicePathTxt;
|
|
||||||
EFI_DEVICE_PATH* LinuxLoaderDevicePath;
|
|
||||||
CHAR16* LoadOptions;
|
|
||||||
|
|
||||||
Status = ParseAndroidBootImg (
|
Status = ParseAndroidBootImg (
|
||||||
Buffer,
|
Buffer,
|
||||||
|
@ -93,55 +84,38 @@ BootAndroidBootImg (
|
||||||
KernelDevicePath.Node1.StartingAddress = (EFI_PHYSICAL_ADDRESS)(UINTN) Kernel;
|
KernelDevicePath.Node1.StartingAddress = (EFI_PHYSICAL_ADDRESS)(UINTN) Kernel;
|
||||||
KernelDevicePath.Node1.EndingAddress = (EFI_PHYSICAL_ADDRESS)(UINTN) Kernel + KernelSize;
|
KernelDevicePath.Node1.EndingAddress = (EFI_PHYSICAL_ADDRESS)(UINTN) Kernel + KernelSize;
|
||||||
|
|
||||||
RamdiskDevicePath = NULL;
|
// Initialize Linux command line
|
||||||
if (RamdiskSize != 0) {
|
LoadOptions = CatSPrint (NULL, L"%a", KernelArgs);
|
||||||
RamdiskDevicePath = (MEMORY_DEVICE_PATH*)DuplicateDevicePath ((EFI_DEVICE_PATH_PROTOCOL*) &MemoryDevicePathTemplate);
|
|
||||||
|
|
||||||
RamdiskDevicePath->Node1.StartingAddress = (EFI_PHYSICAL_ADDRESS)(UINTN) Ramdisk;
|
|
||||||
RamdiskDevicePath->Node1.EndingAddress = ((EFI_PHYSICAL_ADDRESS)(UINTN) Ramdisk) + RamdiskSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Boot Linux using the Legacy Linux Loader
|
|
||||||
//
|
|
||||||
|
|
||||||
Status = LocateEfiApplicationInFvByGuid (&mLinuxLoaderAppGuid, &LinuxLoaderDevicePath);
|
|
||||||
if (EFI_ERROR (Status)) {
|
|
||||||
Print (L"Couldn't Boot Linux: %d\n", Status);
|
|
||||||
return EFI_DEVICE_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
KernelDevicePathTxt = ConvertDevicePathToText ((EFI_DEVICE_PATH_PROTOCOL *) &KernelDevicePath, FALSE, FALSE);
|
|
||||||
if (KernelDevicePathTxt == NULL) {
|
|
||||||
return EFI_OUT_OF_RESOURCES;
|
|
||||||
}
|
|
||||||
|
|
||||||
RamdiskDevicePathTxt = ConvertDevicePathToText ((EFI_DEVICE_PATH_PROTOCOL *) RamdiskDevicePath, FALSE, FALSE);
|
|
||||||
if (RamdiskDevicePathTxt == NULL) {
|
|
||||||
return EFI_OUT_OF_RESOURCES;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Initialize Legacy Linux loader command line
|
|
||||||
LoadOptions = CatSPrint (NULL, LINUX_LOADER_COMMAND_LINE, KernelDevicePathTxt, RamdiskDevicePathTxt, KernelArgs);
|
|
||||||
if (LoadOptions == NULL) {
|
if (LoadOptions == NULL) {
|
||||||
return EFI_OUT_OF_RESOURCES;
|
return EFI_OUT_OF_RESOURCES;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = BdsStartEfiApplication (gImageHandle, LinuxLoaderDevicePath, StrSize (LoadOptions), LoadOptions);
|
if (RamdiskSize != 0) {
|
||||||
|
NewLoadOptions = CatSPrint (LoadOptions, L" initrd=0x%x,0x%x",
|
||||||
|
(UINTN)Ramdisk, RamdiskSize);
|
||||||
|
FreePool (LoadOptions);
|
||||||
|
if (NewLoadOptions == NULL) {
|
||||||
|
return EFI_OUT_OF_RESOURCES;
|
||||||
|
}
|
||||||
|
LoadOptions = NewLoadOptions;
|
||||||
|
}
|
||||||
|
|
||||||
|
Status = BdsStartEfiApplication (gImageHandle,
|
||||||
|
(EFI_DEVICE_PATH_PROTOCOL *) &KernelDevicePath,
|
||||||
|
StrSize (LoadOptions),
|
||||||
|
LoadOptions);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
DEBUG ((EFI_D_ERROR, "Couldn't Boot Linux: %d\n", Status));
|
DEBUG ((EFI_D_ERROR, "Couldn't Boot Linux: %d\n", Status));
|
||||||
return EFI_DEVICE_ERROR;
|
Status = EFI_DEVICE_ERROR;
|
||||||
|
goto FreeLoadOptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (RamdiskDevicePath) {
|
|
||||||
FreePool (RamdiskDevicePathTxt);
|
|
||||||
FreePool (RamdiskDevicePath);
|
|
||||||
}
|
|
||||||
|
|
||||||
FreePool (KernelDevicePathTxt);
|
|
||||||
|
|
||||||
// If we got here we do a confused face because BootLinuxFdt returned,
|
// If we got here we do a confused face because BootLinuxFdt returned,
|
||||||
// reporting success.
|
// reporting success.
|
||||||
DEBUG ((EFI_D_ERROR, "WARNING: BdsBootLinuxFdt returned EFI_SUCCESS.\n"));
|
DEBUG ((EFI_D_ERROR, "WARNING: BdsBootLinuxFdt returned EFI_SUCCESS.\n"));
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
|
|
||||||
|
FreeLoadOptions:
|
||||||
|
FreePool (LoadOptions);
|
||||||
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue