Skip to content

Commit

Permalink
Platforms/Hisilicon: fastboot: add support for getvar partition-<size…
Browse files Browse the repository at this point in the history
…/type>

fastboot requests for partition-type and partition-size while flashing
userdata/system partitions.

NOTE: Currently with this support we return the right partition size and type
but fastboot invokes erase after that which is currently very slow on hikey.

Signed-off-by: Vishal Bhoj <[email protected]>
  • Loading branch information
vishalbhoj committed Feb 11, 2016
1 parent 83e1194 commit a1142af
Showing 1 changed file with 52 additions and 2 deletions.
54 changes: 52 additions & 2 deletions Platforms/Hisilicon/HiKey/HiKeyFastbootDxe/HiKeyFastboot.c
Original file line number Diff line number Diff line change
Expand Up @@ -614,11 +614,61 @@ HiKeyFastbootPlatformGetVar (
OUT CHAR8 *Value
)
{
EFI_STATUS Status;
EFI_BLOCK_IO_PROTOCOL *BlockIo;
UINTN PartitionSize;
FASTBOOT_PARTITION_LIST *Entry;
CHAR16 PartitionNameUnicode[60];
BOOLEAN PartitionFound;

if (!AsciiStrCmp (Name, "max-download-size")) {
AsciiStrCpy (Value, FixedPcdGetPtr (PcdArmFastbootFlashLimit));
} else if (AsciiStrCmp (Name, "product")) {
} else if (!AsciiStrCmp (Name, "product")) {
AsciiStrCpy (Value, FixedPcdGetPtr (PcdFirmwareVendor));
} else {
} else if (!AsciiStrnCmp (Name, "partition-size", 14)) {
AsciiStrToUnicodeStr ((Name + 15), 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) {
*Value = '\0';
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 flash: %r\n", Status));
*Value = '\0';
return EFI_NOT_FOUND;
}

PartitionSize = (BlockIo->Media->LastBlock + 1) * BlockIo->Media->BlockSize;
DEBUG ((EFI_D_ERROR, "Fastboot platform: check for partition-size:%a 0X%08x\n", Name, PartitionSize ));
AsciiSPrint (Value, 11, "0x%08x", PartitionSize);
} else if ( !AsciiStrnCmp (Name, "partition-type", 14)) {
DEBUG ((EFI_D_ERROR, "Fastboot platform: check for partition-type:%a\n", (Name + 15) ));
if ( !AsciiStrnCmp ( (Name + 15) , "system", 6) || !AsciiStrnCmp ( (Name + 15) , "userdata", 8)
|| !AsciiStrnCmp ( (Name + 15) , "cache", 5)) {
AsciiStrCpy (Value, "ext4");
}
else
AsciiStrCpy (Value, "raw");
} else {
*Value = '\0';
}
return EFI_SUCCESS;
Expand Down

0 comments on commit a1142af

Please sign in to comment.