Merge pull request #75 from shawnguo2/fix-mmc
Fix mmc
diff --git a/Platforms/Hisilicon/HiKey/HiKey.dsc b/Platforms/Hisilicon/HiKey/HiKey.dsc
index 3b99cf5..28bc47d 100644
--- a/Platforms/Hisilicon/HiKey/HiKey.dsc
+++ b/Platforms/Hisilicon/HiKey/HiKey.dsc
@@ -131,7 +131,7 @@
[LibraryClasses.common.SEC]
PrePiLib|EmbeddedPkg/Library/PrePiLib/PrePiLib.inf
ExtractGuidedSectionLib|EmbeddedPkg/Library/PrePiExtractGuidedSectionLib/PrePiExtractGuidedSectionLib.inf
- LzmaDecompressLib|IntelFrameworkModulePkg/Library/LzmaCustomDecompressLib/LzmaCustomDecompressLib.inf
+ LzmaDecompressLib|MdeModulePkg/Library/LzmaCustomDecompressLib/LzmaCustomDecompressLib.inf
MemoryAllocationLib|EmbeddedPkg/Library/PrePiMemoryAllocationLib/PrePiMemoryAllocationLib.inf
HobLib|EmbeddedPkg/Library/PrePiHobLib/PrePiHobLib.inf
PrePiHobListPointerLib|ArmPlatformPkg/Library/PrePiHobListPointerLib/PrePiHobListPointerLib.inf
@@ -455,7 +455,9 @@
#
EmbeddedPkg/Application/AndroidFastboot/AndroidFastbootApp.inf {
<LibraryClasses>
+ AbootimgLib|EmbeddedPkg/Library/AbootimgLib/AbootimgLib.inf
BdsLib|ArmPkg/Library/BdsLib/BdsLib.inf
+ ZLib|EmbeddedPkg/Library/ZLib/ZLib.inf
}
#
@@ -463,7 +465,9 @@
#
EmbeddedPkg/Application/AndroidBoot/AndroidBootApp.inf {
<LibraryClasses>
+ AbootimgLib|EmbeddedPkg/Library/AbootimgLib/AbootimgLib.inf
BdsLib|ArmPkg/Library/BdsLib/BdsLib.inf
+ ZLib|EmbeddedPkg/Library/ZLib/ZLib.inf
}
#
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 @@
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 @@
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 @@
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 ();
diff --git a/Platforms/Hisilicon/HiKey960/HiKey960.dsc b/Platforms/Hisilicon/HiKey960/HiKey960.dsc
index 4f40969..bf02a29 100644
--- a/Platforms/Hisilicon/HiKey960/HiKey960.dsc
+++ b/Platforms/Hisilicon/HiKey960/HiKey960.dsc
@@ -62,7 +62,6 @@
CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.inf
GenericBdsLib|IntelFrameworkModulePkg/Library/GenericBdsLib/GenericBdsLib.inf
PlatformBdsLib|OpenPlatformPkg/Chips/Hisilicon/Library/PlatformIntelBdsLib/PlatformIntelBdsLib.inf
- AbootimgLib|EmbeddedPkg/Library/AbootimgLib/AbootimgLib.inf
FdtLib|EmbeddedPkg/Library/FdtLib/FdtLib.inf
HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf
IoLib|MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf
@@ -133,7 +132,6 @@
PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
PrePiLib|EmbeddedPkg/Library/PrePiLib/PrePiLib.inf
ExtractGuidedSectionLib|EmbeddedPkg/Library/PrePiExtractGuidedSectionLib/PrePiExtractGuidedSectionLib.inf
- LzmaDecompressLib|IntelFrameworkModulePkg/Library/LzmaCustomDecompressLib/LzmaCustomDecompressLib.inf
MemoryAllocationLib|EmbeddedPkg/Library/PrePiMemoryAllocationLib/PrePiMemoryAllocationLib.inf
HobLib|EmbeddedPkg/Library/PrePiHobLib/PrePiHobLib.inf
PrePiHobListPointerLib|ArmPlatformPkg/Library/PrePiHobListPointerLib/PrePiHobListPointerLib.inf
@@ -142,6 +140,7 @@
MemoryInitPeiLib|ArmPlatformPkg/MemoryInitPei/MemoryInitPeiLib.inf
ArmGicArchLib|ArmPkg/Library/ArmGicArchSecLib/ArmGicArchSecLib.inf
DefaultExceptionHandlerLib|ArmPkg/Library/DefaultExceptionHandlerLib/DefaultExceptionHandlerLibBase.inf
+ LzmaDecompressLib|MdeModulePkg/Library/LzmaCustomDecompressLib/LzmaCustomDecompressLib.inf
[LibraryClasses.common.DXE_CORE]
DxeCoreEntryPoint|MdePkg/Library/DxeCoreEntryPoint/DxeCoreEntryPoint.inf
@@ -501,7 +500,9 @@
#
EmbeddedPkg/Application/AndroidFastboot/AndroidFastbootApp.inf {
<LibraryClasses>
+ AbootimgLib|EmbeddedPkg/Library/AbootimgLib/AbootimgLib.inf
BdsLib|ArmPkg/Library/BdsLib/BdsLib.inf
+ ZLib|EmbeddedPkg/Library/ZLib/ZLib.inf
}
#
@@ -509,7 +510,9 @@
#
EmbeddedPkg/Application/AndroidBoot/AndroidBootApp.inf {
<LibraryClasses>
+ AbootimgLib|EmbeddedPkg/Library/AbootimgLib/AbootimgLib.inf
BdsLib|ArmPkg/Library/BdsLib/BdsLib.inf
+ ZLib|EmbeddedPkg/Library/ZLib/ZLib.inf
}
#