diff --git a/AndroidFastbootBinPkg/AArch64/AndroidFastbootApp.efi b/AndroidFastbootBinPkg/AArch64/AndroidFastbootApp.efi new file mode 100644 index 000000000000..e681ffc5a136 Binary files /dev/null and b/AndroidFastbootBinPkg/AArch64/AndroidFastbootApp.efi differ diff --git a/AndroidFastbootBinPkg/AndroidFastboot.inf b/AndroidFastbootBinPkg/AndroidFastboot.inf new file mode 100644 index 000000000000..1952cc432b87 --- /dev/null +++ b/AndroidFastbootBinPkg/AndroidFastboot.inf @@ -0,0 +1,28 @@ +## @file +# This is the UEFI Shell application binary file. +# +# Copyright (c) 2011, Intel Corporation. All rights reserved.
+# +# This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# +## +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = AndroidFastbootApp + FILE_GUID = 9588502a-5370-11e3-8631-d7c5951364c8 + MODULE_TYPE = UEFI_APPLICATION + VERSION_STRING = 1.0 + +[Binaries.ARM] + PE32|Arm/AndroidFastbootApp.efi|* + +[Binaries.AArch64] + PE32|AArch64/AndroidFastbootApp.efi|* diff --git a/AndroidFastbootBinPkg/Arm/AndroidFastbootApp.efi b/AndroidFastbootBinPkg/Arm/AndroidFastbootApp.efi new file mode 100644 index 000000000000..3067969398a7 Binary files /dev/null and b/AndroidFastbootBinPkg/Arm/AndroidFastbootApp.efi differ diff --git a/ArmPkg/Library/BdsLib/BdsFilePath.c b/ArmPkg/Library/BdsLib/BdsFilePath.c index 924c61ed34f7..a868e1993403 100644 --- a/ArmPkg/Library/BdsLib/BdsFilePath.c +++ b/ArmPkg/Library/BdsLib/BdsFilePath.c @@ -460,9 +460,11 @@ BdsFileSystemSupport ( EFI_STATUS Status; EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *FsProtocol; - Status = gBS->HandleProtocol (Handle, &gEfiSimpleFileSystemProtocolGuid, (VOID **)&FsProtocol); - - return (!EFI_ERROR (Status) && IS_DEVICE_PATH_NODE (RemainingDevicePath, MEDIA_DEVICE_PATH, MEDIA_FILEPATH_DP)); + if (IS_DEVICE_PATH_NODE (RemainingDevicePath, MEDIA_DEVICE_PATH, MEDIA_FILEPATH_DP)) { + Status = gBS->HandleProtocol (Handle, &gEfiSimpleFileSystemProtocolGuid, (VOID **)&FsProtocol); + return (!EFI_ERROR (Status)); + } + return FALSE; } EFI_STATUS @@ -628,81 +630,96 @@ BdsFirmwareVolumeLoadImage ( EFI_FV_FILE_ATTRIBUTES Attrib; UINT32 AuthenticationStatus; VOID* ImageBuffer; + UINTN NoHandles, HandleIndex; + EFI_HANDLE *Handles; + MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FwDevicePath; ASSERT (IS_DEVICE_PATH_NODE (RemainingDevicePath, MEDIA_DEVICE_PATH, MEDIA_PIWG_FW_FILE_DP)); - Status = gBS->HandleProtocol (Handle, &gEfiFirmwareVolume2ProtocolGuid, (VOID **)&FwVol); - if (EFI_ERROR (Status)) { + Status = gBS->LocateHandleBuffer (ByProtocol, &gEfiFirmwareVolume2ProtocolGuid, NULL, &NoHandles, &Handles); + if (EFI_ERROR (Status) || (NoHandles == 0)) { + DEBUG ((EFI_D_ERROR, "FAIL to find Firmware Volume\n")); return Status; } + // Search in all Firmware Volume for the EFI Application + for (HandleIndex = 0; HandleIndex < NoHandles; HandleIndex++) { + Status = gBS->HandleProtocol (Handles[HandleIndex], &gEfiFirmwareVolume2ProtocolGuid, (VOID **)&FwVol); + if (EFI_ERROR (Status)) + continue; + + FwDevicePath = (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *)RemainingDevicePath; + FvNameGuid = &(FwDevicePath->FvFileName); + if (FvNameGuid == NULL) { + Status = EFI_INVALID_PARAMETER; + continue; + } - FvNameGuid = EfiGetNameGuidFromFwVolDevicePathNode ((CONST MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *)RemainingDevicePath); - if (FvNameGuid == NULL) { - Status = EFI_INVALID_PARAMETER; - } - - SectionType = EFI_SECTION_PE32; - AuthenticationStatus = 0; - //Note: ReadSection at the opposite of ReadFile does not allow to pass ImageBuffer == NULL to get the size of the file. - ImageBuffer = NULL; - Status = FwVol->ReadSection ( - FwVol, - FvNameGuid, - SectionType, - 0, - &ImageBuffer, - ImageSize, - &AuthenticationStatus - ); - if (!EFI_ERROR (Status)) { + SectionType = EFI_SECTION_PE32; + AuthenticationStatus = 0; + //Note: ReadSection at the opposite of ReadFile does not allow to pass ImageBuffer == NULL to get the size of the file. + ImageBuffer = NULL; + Status = FwVol->ReadSection ( + FwVol, + FvNameGuid, + SectionType, + 0, + &ImageBuffer, + ImageSize, + &AuthenticationStatus + ); + if (!EFI_ERROR (Status)) { #if 0 - // In case the buffer has some address requirements, we must copy the buffer to a buffer following the requirements - if (Type != AllocateAnyPages) { - Status = gBS->AllocatePages (Type, EfiBootServicesCode, EFI_SIZE_TO_PAGES(*ImageSize),Image); - if (!EFI_ERROR (Status)) { - CopyMem ((VOID*)(UINTN)(*Image), ImageBuffer, *ImageSize); - FreePool (ImageBuffer); + // In case the buffer has some address requirements, we must copy the buffer to a buffer following the requirements + if (Type != AllocateAnyPages) { + Status = gBS->AllocatePages (Type, EfiBootServicesCode, EFI_SIZE_TO_PAGES(*ImageSize),Image); + if (!EFI_ERROR (Status)) { + CopyMem ((VOID*)(UINTN)(*Image), ImageBuffer, *ImageSize); + FreePool (ImageBuffer); + } } - } #else - // We must copy the buffer into a page allocations. Otherwise, the caller could call gBS->FreePages() on the pool allocation - Status = gBS->AllocatePages (Type, EfiBootServicesCode, EFI_SIZE_TO_PAGES(*ImageSize), Image); - // Try to allocate in any pages if failed to allocate memory at the defined location - if ((Status == EFI_OUT_OF_RESOURCES) && (Type != AllocateAnyPages)) { - Status = gBS->AllocatePages (AllocateAnyPages, EfiBootServicesCode, EFI_SIZE_TO_PAGES(*ImageSize), Image); - } - if (!EFI_ERROR (Status)) { - CopyMem ((VOID*)(UINTN)(*Image), ImageBuffer, *ImageSize); - FreePool (ImageBuffer); - } -#endif - } else { - // Try a raw file, since a PE32 SECTION does not exist - Status = FwVol->ReadFile ( - FwVol, - FvNameGuid, - NULL, - ImageSize, - &FvType, - &Attrib, - &AuthenticationStatus - ); - if (!EFI_ERROR (Status)) { + // We must copy the buffer into a page allocations. Otherwise, the caller could call gBS->FreePages() on the pool allocation Status = gBS->AllocatePages (Type, EfiBootServicesCode, EFI_SIZE_TO_PAGES(*ImageSize), Image); // Try to allocate in any pages if failed to allocate memory at the defined location if ((Status == EFI_OUT_OF_RESOURCES) && (Type != AllocateAnyPages)) { Status = gBS->AllocatePages (AllocateAnyPages, EfiBootServicesCode, EFI_SIZE_TO_PAGES(*ImageSize), Image); } if (!EFI_ERROR (Status)) { - Status = FwVol->ReadFile ( - FwVol, - FvNameGuid, - (VOID*)(UINTN)(*Image), - ImageSize, - &FvType, - &Attrib, - &AuthenticationStatus - ); + CopyMem ((VOID*)(UINTN)(*Image), ImageBuffer, *ImageSize); + FreePool (ImageBuffer); + return Status; + } +#endif + } else { + // Try a raw file, since a PE32 SECTION does not exist + Status = FwVol->ReadFile ( + FwVol, + FvNameGuid, + NULL, + ImageSize, + &FvType, + &Attrib, + &AuthenticationStatus + ); + if (!EFI_ERROR (Status)) { + Status = gBS->AllocatePages (Type, EfiBootServicesCode, EFI_SIZE_TO_PAGES(*ImageSize), Image); + // Try to allocate in any pages if failed to allocate memory at the defined location + if ((Status == EFI_OUT_OF_RESOURCES) && (Type != AllocateAnyPages)) { + Status = gBS->AllocatePages (AllocateAnyPages, EfiBootServicesCode, EFI_SIZE_TO_PAGES(*ImageSize), Image); + } + if (!EFI_ERROR (Status)) { + Status = FwVol->ReadFile ( + FwVol, + FvNameGuid, + (VOID*)(UINTN)(*Image), + ImageSize, + &FvType, + &Attrib, + &AuthenticationStatus + ); + if (!EFI_ERROR (Status)) + return Status; + } } } } diff --git a/EmbeddedPkg/Application/AndroidFastboot/AndroidFastbootApp.dsc b/EmbeddedPkg/Application/AndroidFastboot/AndroidFastbootApp.dsc new file mode 100644 index 000000000000..9a61376c53e0 --- /dev/null +++ b/EmbeddedPkg/Application/AndroidFastboot/AndroidFastbootApp.dsc @@ -0,0 +1,78 @@ +# This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +## + +[Defines] + PLATFORM_NAME = AndroidFastbootApp + PLATFORM_GUID = 5C4690F0-4B99-46B8-9464-D5F6D9FF9DDD + PLATFORM_VERSION = 1.0 + DSC_SPECIFICATION = 0x00010006 + OUTPUT_DIRECTORY = Build/AndroidFastboot + SUPPORTED_ARCHITECTURES = ARM|AARCH64 + BUILD_TARGETS = DEBUG|RELEASE + SKUID_IDENTIFIER = DEFAULT + +[LibraryClasses.common] + UefiApplicationEntryPoint|MdePkg/Library/UefiApplicationEntryPoint/UefiApplicationEntryPoint.inf + UefiBootServicesTableLib|MdePkg/Library/UefiBootServicesTableLib/UefiBootServicesTableLib.inf + DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLibOptionalDevicePathProtocol.inf + DebugLib|MdePkg/Library/UefiDebugLibConOut/UefiDebugLibConOut.inf + DebugPrintErrorLevelLib|MdePkg/Library/BaseDebugPrintErrorLevelLib/BaseDebugPrintErrorLevelLib.inf + PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf + MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf + UefiLib|MdePkg/Library/UefiLib/UefiLib.inf + BaseLib|MdePkg/Library/BaseLib/BaseLib.inf + BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf + PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf + FileHandleLib|MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.inf + SortLib|MdeModulePkg/Library/UefiSortLib/UefiSortLib.inf + UefiRuntimeServicesTableLib|MdePkg/Library/UefiRuntimeServicesTableLib/UefiRuntimeServicesTableLib.inf + UefiHiiServicesLib|MdeModulePkg/Library/UefiHiiServicesLib/UefiHiiServicesLib.inf + HiiLib|MdeModulePkg/Library/UefiHiiLib/UefiHiiLib.inf + NetLib|MdeModulePkg/Library/DxeNetLib/DxeNetLib.inf + + PeCoffGetEntryPointLib|MdePkg/Library/BasePeCoffGetEntryPointLib/BasePeCoffGetEntryPointLib.inf + + ArmGicLib|ArmPkg/Drivers/ArmGic/ArmGicLib.inf + DxeServicesTableLib|MdePkg/Library/DxeServicesTableLib/DxeServicesTableLib.inf + FdtLib|EmbeddedPkg/Library/FdtLib/FdtLib.inf + HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf + IoLib|MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf + PerformanceLib|MdePkg/Library/BasePerformanceLibNull/BasePerformanceLibNull.inf + SerialPortLib|MdePkg/Library/BaseSerialPortLibNull/BaseSerialPortLibNull.inf + TimerLib|MdePkg/Library/BaseTimerLibNullTemplate/BaseTimerLibNullTemplate.inf + +[LibraryClasses.ARM] + # + # It is not possible to prevent the ARM compiler for generic intrinsic functions. + # This library provides the instrinsic functions generate by a given compiler. + # [LibraryClasses.ARM] and NULL mean link this library into all ARM images. + # + NULL|ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf + + # Add support for GCC stack protector + NULL|MdePkg/Library/BaseStackCheckLib/BaseStackCheckLib.inf + + ArmLib|ArmPkg/Library/ArmLib/ArmV7/ArmV7Lib.inf + ArmSmcLib|ArmPkg/Library/ArmSmcLib/ArmSmcLib.inf + BdsLib|ArmPkg/Library/BdsLib/BdsLib.inf + +[LibraryClasses.AARCH64] + NULL|ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf + + ArmLib|ArmPkg/Library/ArmLib/AArch64/AArch64Lib.inf + ArmSmcLib|ArmPkg/Library/ArmSmcLib/ArmSmcLib.inf + BdsLib|ArmPkg/Library/BdsLib/BdsLib.inf + +[PcdsFixedAtBuild] + gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0xFF + gEfiMdePkgTokenSpaceGuid.PcdUefiLibMaxPrintBufferSize|16000 + +[Components] + EmbeddedPkg/Application/AndroidFastboot/AndroidFastbootApp.inf diff --git a/HisiPkg/HiKeyPkg/Drivers/HiKeyDxe/InstallBootMenu.c b/HisiPkg/HiKeyPkg/Drivers/HiKeyDxe/InstallBootMenu.c index 90507d2bd9f3..8157d35b24ff 100644 --- a/HisiPkg/HiKeyPkg/Drivers/HiKeyDxe/InstallBootMenu.c +++ b/HisiPkg/HiKeyPkg/Drivers/HiKeyDxe/InstallBootMenu.c @@ -61,7 +61,7 @@ STATIC UINT16 mBootIndex = 0; STATIC struct HiKeyBootEntry Entries[] = { [HIKEY_BOOT_ENTRY_FASTBOOT] = { - L"VenHw(B549F005-4BD4-4020-A0CB-06F42BDA68C3)/HD(6,GPT,5C0F213C-17E1-4149-88C8-8B50FB4EC70E,0x7000,0x20000)/\\EFI\\BOOT\\FASTBOOT.EFI", + L"FvFile(9588502a-5370-11e3-8631-d7c5951364c8)", NULL, L"fastboot", LOAD_OPTION_CATEGORY_APP diff --git a/HisiPkg/HiKeyPkg/HiKey.fdf b/HisiPkg/HiKeyPkg/HiKey.fdf index 91eb9ba79eb6..16457d1656b0 100644 --- a/HisiPkg/HiKeyPkg/HiKey.fdf +++ b/HisiPkg/HiKeyPkg/HiKey.fdf @@ -151,6 +151,8 @@ READ_LOCK_STATUS = TRUE INF MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf + INF AndroidFastbootBinPkg/AndroidFastboot.inf + # # UEFI applications #