diff options
author | Haojian Zhuang <haojian.zhuang@linaro.org> | 2017-06-22 12:19:26 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-06-22 12:19:26 +0800 |
commit | 56dec05002f6870928336da5da99d1e1027692e8 (patch) | |
tree | 233bb78bb6944bf4f89bdb6bd2e2c5b30f99d830 | |
parent | 2b1d60f6b9d99bb42b5b8ccb8d8aa14772074b8f (diff) | |
parent | 5abd3e3ecbd1e2559d30ea9ab8cdfc57a0a93a2c (diff) | |
download | device_linaro_bootloader_OpenPlatformPkg-56dec05002f6870928336da5da99d1e1027692e8.tar.gz device_linaro_bootloader_OpenPlatformPkg-56dec05002f6870928336da5da99d1e1027692e8.tar.bz2 device_linaro_bootloader_OpenPlatformPkg-56dec05002f6870928336da5da99d1e1027692e8.zip |
Merge pull request #42 from hzhuang1/aboot_ext
fastboot: Add ReadPartition functionality
-rw-r--r-- | Platforms/Hisilicon/HiKey/HiKeyFastbootDxe/HiKeyFastboot.c | 65 |
1 files changed, 64 insertions, 1 deletions
diff --git a/Platforms/Hisilicon/HiKey/HiKeyFastbootDxe/HiKeyFastboot.c b/Platforms/Hisilicon/HiKey/HiKeyFastbootDxe/HiKeyFastboot.c index dd99927..81e4d17 100644 --- a/Platforms/Hisilicon/HiKey/HiKeyFastbootDxe/HiKeyFastboot.c +++ b/Platforms/Hisilicon/HiKey/HiKeyFastbootDxe/HiKeyFastboot.c @@ -798,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
|