aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHaojian Zhuang <haojian.zhuang@linaro.org>2017-12-21 15:50:05 +0800
committerGitHub <noreply@github.com>2017-12-21 15:50:05 +0800
commit9845da3dea023b05bd6bbe185fa615e620fba7c9 (patch)
tree0f1124bdabcd407ee2a7cb0dab3cc9b965bce70e
parentacd487145b888f3a3f31181567c4878de777f8a3 (diff)
parent68f0b509e1a27537f98e05f69432651b6f66bfd7 (diff)
downloaddevice_linaro_bootloader_OpenPlatformPkg-9845da3dea023b05bd6bbe185fa615e620fba7c9.tar.gz
device_linaro_bootloader_OpenPlatformPkg-9845da3dea023b05bd6bbe185fa615e620fba7c9.tar.bz2
device_linaro_bootloader_OpenPlatformPkg-9845da3dea023b05bd6bbe185fa615e620fba7c9.zip
Merge pull request #77 from hzhuang1/testing/ptable_2
Platforms/HiKey: make compatible with old ptable
-rw-r--r--Platforms/Hisilicon/HiKey/HiKeyFastbootDxe/HiKeyFastbootDxe.c36
1 files changed, 32 insertions, 4 deletions
diff --git a/Platforms/Hisilicon/HiKey/HiKeyFastbootDxe/HiKeyFastbootDxe.c b/Platforms/Hisilicon/HiKey/HiKeyFastbootDxe/HiKeyFastbootDxe.c
index 7e62ebb..a62c094 100644
--- a/Platforms/Hisilicon/HiKey/HiKeyFastbootDxe/HiKeyFastbootDxe.c
+++ b/Platforms/Hisilicon/HiKey/HiKeyFastbootDxe/HiKeyFastbootDxe.c
@@ -133,7 +133,7 @@ ReadPartitionEntries (
GptHeader->MyLBA != 1) {
DEBUG ((EFI_D_ERROR,
"Fastboot platform: No GPT on flash. "
- "Fastboot on Versatile Express does not support MBR.\n"
+ "Fastboot on HiKey does not support MBR.\n"
));
return EFI_DEVICE_ERROR;
}
@@ -280,8 +280,12 @@ HiKeyFlashPtable (
EFI_STATUS Status;
EFI_DISK_IO_PROTOCOL *DiskIo;
UINT32 MediaId;
+ VOID *Buffer;
+ UINT32 EntrySize, EntryOffset;
+ UINTN BlockSize;
MediaId = mFlashBlockIo->Media->MediaId;
+ BlockSize = mFlashBlockIo->Media->BlockSize;
Status = gBS->OpenProtocol (
mFlashHandle,
&gEfiDiskIoProtocolGuid,
@@ -293,9 +297,33 @@ HiKeyFlashPtable (
if (EFI_ERROR (Status)) {
return Status;
}
- Status = DiskIo->WriteDisk (DiskIo, MediaId, 0, Size, Image);
- if (EFI_ERROR (Status)) {
- return Status;
+ Buffer = Image;
+ if (AsciiStrnCmp (Buffer, "ENTRYHDR", 8) != 0) {
+ DEBUG ((EFI_D_ERROR, "It should be raw ptable image\n"));
+ Status = DiskIo->WriteDisk (DiskIo, MediaId, 0, Size, Image);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+ } else {
+ /* ptable with entry header */
+ Buffer += 8;
+ if (AsciiStrnCmp (Buffer, "primary", 7) != 0) {
+ DEBUG ((EFI_D_ERROR, "unknown ptable imag\n"));
+ return EFI_UNSUPPORTED;
+ }
+ Buffer += 8;
+ EntryOffset = *(UINT32 *)Buffer * BlockSize;
+ Buffer += 4;
+ EntrySize = *(UINT32 *)Buffer * BlockSize;
+ if ((EntrySize + BlockSize) > Size) {
+ DEBUG ((DEBUG_ERROR, "Entry size doesn't match\n"));
+ return EFI_UNSUPPORTED;
+ }
+ Buffer = Image + BlockSize;
+ Status = DiskIo->WriteDisk (DiskIo, MediaId, EntryOffset, EntrySize, Buffer);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
}
FreePartitionList ();
Status = LoadPtable ();