Skip to content
This repository has been archived by the owner on Oct 28, 2019. It is now read-only.

Load fastboot #66

Open
wants to merge 6 commits into
base: hikey
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.
28 changes: 28 additions & 0 deletions AndroidFastbootBinPkg/AndroidFastboot.inf
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
## @file
# This is the UEFI Shell application binary file.
#
# Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
#
# 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|*
Binary file added AndroidFastbootBinPkg/Arm/AndroidFastbootApp.efi
Binary file not shown.
143 changes: 80 additions & 63 deletions ArmPkg/Library/BdsLib/BdsFilePath.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
}
}
}
}
Expand Down
78 changes: 78 additions & 0 deletions EmbeddedPkg/Application/AndroidFastboot/AndroidFastbootApp.dsc
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion HisiPkg/HiKeyPkg/Drivers/HiKeyDxe/InstallBootMenu.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions HisiPkg/HiKeyPkg/HiKey.fdf
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ READ_LOCK_STATUS = TRUE

INF MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf

INF AndroidFastbootBinPkg/AndroidFastboot.inf

#
# UEFI applications
#
Expand Down