aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDmitry Shmidt <dimitrysh@google.com>2017-06-22 19:22:15 +0000
committerandroid-build-merger <android-build-merger@google.com>2017-06-22 19:22:15 +0000
commit47556fcdf84919309623b6474e80b09a087b9e26 (patch)
tree233bb78bb6944bf4f89bdb6bd2e2c5b30f99d830
parent05aa9c66b310f7fb7aa748de7131af4c61f29430 (diff)
parent83e57f1e303ae8517b0d20f094538748bfb0a835 (diff)
downloaddevice_linaro_bootloader_OpenPlatformPkg-oreo-mr1-dev.tar.gz
device_linaro_bootloader_OpenPlatformPkg-oreo-mr1-dev.tar.bz2
device_linaro_bootloader_OpenPlatformPkg-oreo-mr1-dev.zip
Merge remote-tracking branch 'aosp/upstream-hikey-aosp' into opp am: 71183d6eab am: 466e090f06 am: ca8a8eebc2oreo-mr1-dev
am: 83e57f1e30 Change-Id: I20a6bc9bfdf857769b12bbd3fcc37fe1e89cda3f
-rw-r--r--Platforms/Hisilicon/HiKey/HiKeyFastbootDxe/HiKeyFastboot.c113
1 files changed, 95 insertions, 18 deletions
diff --git a/Platforms/Hisilicon/HiKey/HiKeyFastbootDxe/HiKeyFastboot.c b/Platforms/Hisilicon/HiKey/HiKeyFastbootDxe/HiKeyFastboot.c
index 49551ae..81e4d17 100644
--- a/Platforms/Hisilicon/HiKey/HiKeyFastbootDxe/HiKeyFastboot.c
+++ b/Platforms/Hisilicon/HiKey/HiKeyFastbootDxe/HiKeyFastboot.c
@@ -43,7 +43,7 @@
#define PARTITION_NAME_MAX_LENGTH 72/2
#define IS_ALPHA(Char) (((Char) <= L'z' && (Char) >= L'a') || \
- ((Char) <= L'Z' && (Char) >= L'Z'))
+ ((Char) <= L'Z' && (Char) >= L'A'))
#define IS_HEXCHAR(Char) (((Char) <= L'9' && (Char) >= L'0') || \
IS_ALPHA(Char))
@@ -154,14 +154,8 @@ ReadPartitionEntries (
}
-/*
- Initialise: Open the Android NVM device and find the partitions on it. Save them in
- a list along with the "PartitionName" fields for their GPT entries.
- We will use these partition names as the key in
- HiKeyFastbootPlatformFlashPartition.
-*/
EFI_STATUS
-HiKeyFastbootPlatformInit (
+HiKeyFastbootLoadPtable (
VOID
)
{
@@ -179,15 +173,8 @@ HiKeyFastbootPlatformInit (
EFI_PARTITION_ENTRY *PartitionEntries;
FASTBOOT_PARTITION_LIST *Entry;
- InitializeListHead (&mPartitionListHead);
-
- Status = gBS->LocateProtocol (&gEfiSimpleTextOutProtocolGuid, NULL, (VOID **) &mTextOut);
- if (EFI_ERROR (Status)) {
- DEBUG ((EFI_D_ERROR,
- "Fastboot platform: Couldn't open Text Output Protocol: %r\n", Status
- ));
- return Status;
- }
+ // Free any entries in partitionlist
+ FreePartitionList ();
//
// Get EFI_HANDLES for all the partitions on the block devices pointed to by
@@ -334,7 +321,32 @@ Exit:
FreePool (FlashDevicePath);
FreePool (AllHandles);
return Status;
+}
+
+/*
+ Initialise: Open the Android NVM device and find the partitions on it. Save them in
+ a list along with the "PartitionName" fields for their GPT entries.
+ We will use these partition names as the key in
+ HiKeyFastbootPlatformFlashPartition.
+*/
+EFI_STATUS
+HiKeyFastbootPlatformInit (
+ VOID
+ )
+{
+ EFI_STATUS Status;
+
+ InitializeListHead (&mPartitionListHead);
+
+ Status = gBS->LocateProtocol (&gEfiSimpleTextOutProtocolGuid, NULL, (VOID **) &mTextOut);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((EFI_D_ERROR,
+ "Fastboot platform: Couldn't open Text Output Protocol: %r\n", Status
+ ));
+ return Status;
+ }
+ return HiKeyFastbootLoadPtable();
}
VOID
@@ -529,6 +541,8 @@ HiKeyFastbootPlatformFlashPartition (
}
Buffer = Image + 512;
Status = DiskIo->WriteDisk (DiskIo, MediaId, EntryOffset, EntrySize, Buffer);
+ DEBUG ((EFI_D_ERROR, "Flashed Ptable hence reloading partition Entries for future flash commands\n"));
+ HiKeyFastbootLoadPtable();
if (EFI_ERROR (Status)) {
return Status;
}
@@ -784,13 +798,76 @@ out:
return EFI_NOT_FOUND;
}
+EFI_STATUS
+HikeyFastbootPlatformReadPartition(
+ IN CHAR8 *PartitionName,
+ IN OUT UINTN *BufferSize,
+ OUT VOID **Buffer
+ )
+{
+ EFI_STATUS Status;
+ EFI_BLOCK_IO_PROTOCOL *BlockIo;
+ UINT32 MediaId;
+ UINTN PartitionSize;
+ FASTBOOT_PARTITION_LIST *Entry;
+ CHAR16 PartitionNameUnicode[60];
+ BOOLEAN PartitionFound;
+
+ AsciiStrToUnicodeStr (PartitionName, PartitionNameUnicode);
+
+ PartitionFound = FALSE;
+ Entry = (FASTBOOT_PARTITION_LIST *) GetFirstNode (&(mPartitionListHead));
+ while (!IsNull (&mPartitionListHead, &Entry->Link)) {
+ // Search the partition list for the partition named by PartitionName
+ if (StrCmp (Entry->PartitionName, PartitionNameUnicode) == 0) {
+ PartitionFound = TRUE;
+ break;
+ }
+
+ Entry = (FASTBOOT_PARTITION_LIST *) GetNextNode (&mPartitionListHead, &(Entry)->Link);
+ }
+ if (!PartitionFound) {
+ return EFI_NOT_FOUND;
+ }
+
+ Status = gBS->OpenProtocol (
+ Entry->PartitionHandle,
+ &gEfiBlockIoProtocolGuid,
+ (VOID **) &BlockIo,
+ gImageHandle,
+ NULL,
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL
+ );
+ if (EFI_ERROR (Status)) {
+ DEBUG ((EFI_D_ERROR, "Fastboot platform: couldn't open Block IO for read: %r\n", Status));
+ return EFI_NOT_FOUND;
+ }
+
+ // Check image will fit the memory
+ PartitionSize = (BlockIo->Media->LastBlock + 1) * BlockIo->Media->BlockSize;
+ if ((*BufferSize == 0) || (*BufferSize > PartitionSize))
+ *BufferSize = PartitionSize;
+ *Buffer = AllocatePages (EFI_SIZE_TO_PAGES(*BufferSize));
+ if (*Buffer == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ MediaId = BlockIo->Media->MediaId;
+ Status = BlockIo->ReadBlocks (BlockIo, MediaId, 0, *BufferSize, *Buffer);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((EFI_D_ERROR, "Fastboot platform: Fail to read: %r\n", Status));
+ }
+ return Status;
+}
+
FASTBOOT_PLATFORM_PROTOCOL mPlatformProtocol = {
HiKeyFastbootPlatformInit,
HiKeyFastbootPlatformUnInit,
HiKeyFastbootPlatformFlashPartition,
HiKeyFastbootPlatformErasePartition,
HiKeyFastbootPlatformGetVar,
- HiKeyFastbootPlatformOemCommand
+ HiKeyFastbootPlatformOemCommand,
+ HikeyFastbootPlatformReadPartition,
};
EFI_STATUS