diff options
author | Fathi Boudra <fathi.boudra@linaro.org> | 2015-11-17 09:31:59 +0200 |
---|---|---|
committer | Fathi Boudra <fathi.boudra@linaro.org> | 2015-11-17 09:31:59 +0200 |
commit | b4a0153e57273ab9e1f29c29d844531d4772d30b (patch) | |
tree | 549b52196c2c61aaa6b64f0249533853c91cb861 | |
parent | 96e66b7a3fee9947e76e1f96465aca76c8cf094e (diff) | |
parent | 1cfac11eb5df26e0d5fe3cfabee8dd01a9055c17 (diff) |
Merge pull request #62 from hzhuang1/enhance_boot_sd
Enhance boot sd
-rw-r--r-- | HisiPkg/HiKeyPkg/Drivers/HiKeyDxe/HiKeyDxe.c | 33 | ||||
-rw-r--r-- | HisiPkg/HiKeyPkg/Drivers/HiKeyDxe/InstallBootMenu.c | 44 | ||||
-rw-r--r-- | HisiPkg/HiKeyPkg/Drivers/HiKeyFastbootDxe/HiKeyFastboot.c | 44 |
3 files changed, 111 insertions, 10 deletions
diff --git a/HisiPkg/HiKeyPkg/Drivers/HiKeyDxe/HiKeyDxe.c b/HisiPkg/HiKeyPkg/Drivers/HiKeyDxe/HiKeyDxe.c index 5f3e10b09..dc2da1044 100644 --- a/HisiPkg/HiKeyPkg/Drivers/HiKeyDxe/HiKeyDxe.c +++ b/HisiPkg/HiKeyPkg/Drivers/HiKeyDxe/HiKeyDxe.c @@ -132,6 +132,38 @@ exit: return Status; } +STATIC +VOID +EFIAPI +HiKeyInitBootDevice ( + IN VOID + ) +{ + EFI_STATUS Status; + UINTN VariableSize; + CHAR16 DefaultBootDevice[BOOT_DEVICE_LENGTH] = L"sd"; + + VariableSize = BOOT_DEVICE_LENGTH * sizeof (CHAR16); + Status = gRT->GetVariable ( + (CHAR16 *)L"HiKeyBootDevice", + &gArmGlobalVariableGuid, + NULL, + &VariableSize, + &DefaultBootDevice + ); + if (Status == EFI_NOT_FOUND) { + Status = gRT->SetVariable ( + (CHAR16*)L"HiKeyBootDevice", + &gArmGlobalVariableGuid, + EFI_VARIABLE_NON_VOLATILE | + EFI_VARIABLE_BOOTSERVICE_ACCESS | + EFI_VARIABLE_RUNTIME_ACCESS, + VariableSize, + DefaultBootDevice + ); + } +} + EFI_STATUS EFIAPI HiKeyEntryPoint ( @@ -142,6 +174,7 @@ HiKeyEntryPoint ( EFI_STATUS Status; HiKeyInitSerialNo (); + HiKeyInitBootDevice (); HiKeyInitPeripherals (); Status = HiKeyBootMenuInstall (); diff --git a/HisiPkg/HiKeyPkg/Drivers/HiKeyDxe/InstallBootMenu.c b/HisiPkg/HiKeyPkg/Drivers/HiKeyDxe/InstallBootMenu.c index 4ec98f365..84fdea184 100644 --- a/HisiPkg/HiKeyPkg/Drivers/HiKeyDxe/InstallBootMenu.c +++ b/HisiPkg/HiKeyPkg/Drivers/HiKeyDxe/InstallBootMenu.c @@ -478,6 +478,7 @@ HiKeyOnEndOfDxe ( EFI_STATUS Status; UINTN VariableSize; UINT16 AutoBoot, Count, Index; + CHAR16 BootDevice[BOOT_DEVICE_LENGTH]; VariableSize = sizeof (UINT16); Status = gRT->GetVariable ( @@ -540,21 +541,44 @@ HiKeyOnEndOfDxe ( HiKeyDetectJumper (); - if (mBootIndex > 0) { - // If SD card is present, boot from SD card directly. - if (HiKeySDCardIsPresent () == TRUE) { - mBootIndex = HIKEY_BOOT_ENTRY_BOOT_SD; - } else { - mBootIndex = HIKEY_BOOT_ENTRY_BOOT_EMMC; - } + // Check boot device. + // If boot device is eMMC, it's always higher priority. + // If boot device is SD card, SD card is higher priority. + // If SD card is present, boot SD. Otherwise, still boot eMMC. + VariableSize = BOOT_DEVICE_LENGTH * sizeof (UINT16); + Status = gRT->GetVariable ( + (CHAR16 *)L"HiKeyBootDevice", + &gArmGlobalVariableGuid, + NULL, + &VariableSize, + &BootDevice + ); + if (EFI_ERROR (Status) == 0) { + if (StrnCmp (BootDevice, L"emmc", StrLen (L"emmc")) == 0) { + if (mBootIndex > 0) { + mBootIndex = HIKEY_BOOT_ENTRY_BOOT_EMMC; + } + } else if (StrnCmp (BootDevice, L"sd", StrLen (L"sd")) == 0) { + if (mBootIndex > 0) { + // If SD card is present, boot from SD card directly. + if (HiKeySDCardIsPresent () == TRUE) { + mBootIndex = HIKEY_BOOT_ENTRY_BOOT_SD; + } else { + mBootIndex = HIKEY_BOOT_ENTRY_BOOT_EMMC; + } + } + } else { + DEBUG ((EFI_D_ERROR, "%a: invalid boot device (%a) is specified\n", __func__, BootDevice)); + mBootIndex = HIKEY_BOOT_ENTRY_BOOT_EMMC; + } + } else { + DEBUG ((EFI_D_ERROR, "failed to get HiKeyBootDevice variable, %r\n", Status)); } // Fdt variable should be aligned with Image path. // In another word, Fdt and Image file should be located in the same path. + // Since grub is used for eMMC boot, don't need to assign Fdt and Image path. switch (mBootIndex) { - case HIKEY_BOOT_ENTRY_BOOT_EMMC: - HiKeyCreateFdtVariable (L"VenHw(B549F005-4BD4-4020-A0CB-06F42BDA68C3)/HD(6,GPT,5C0F213C-17E1-4149-88C8-8B50FB4EC70E,0x7000,0x20000)/hi6220-hikey.dtb"); - break; case HIKEY_BOOT_ENTRY_BOOT_SD: HiKeyCreateFdtVariable (L"VenHw(594BFE73-5E18-4F12-8119-19DB8C5FC849)/HD(1,MBR,0x00000000,0x3F,0x21FC0)/hi6220-hikey.dtb"); break; diff --git a/HisiPkg/HiKeyPkg/Drivers/HiKeyFastbootDxe/HiKeyFastboot.c b/HisiPkg/HiKeyPkg/Drivers/HiKeyFastbootDxe/HiKeyFastboot.c index 59f7375f8..834aa4daa 100644 --- a/HisiPkg/HiKeyPkg/Drivers/HiKeyFastbootDxe/HiKeyFastboot.c +++ b/HisiPkg/HiKeyPkg/Drivers/HiKeyFastbootDxe/HiKeyFastboot.c @@ -630,6 +630,7 @@ HiKeyFastbootPlatformOemCommand ( )
{
CHAR16 CommandUnicode[65];
+ CHAR16 BootDevice[BOOT_DEVICE_LENGTH];
UINTN Index = 0, VariableSize;
UINT16 AutoBoot, Data;
EFI_STATUS Status;
@@ -671,6 +672,49 @@ HiKeyFastbootPlatformOemCommand ( &AutoBoot
);
return Status;
+ } else if (AsciiStrnCmp (Command, "bootdevice", AsciiStrLen ("bootdevice")) == 0) {
+ Index += sizeof ("bootdevice");
+ while (TRUE) {
+ if (Command[Index] == '\0')
+ goto out;
+ else if (Command[Index] == ' ')
+ Index++;
+ else
+ break;
+ }
+ AsciiStrToUnicodeStr (Command + Index, CommandUnicode);
+ for (Index = 0; Index < BOOT_DEVICE_LENGTH; Index++) {
+ if (IS_ALPHA (CommandUnicode[Index]) == 0)
+ break;
+ }
+ if ((Index == 0) || (Index > BOOT_DEVICE_LENGTH)) {
+ DEBUG ((EFI_D_ERROR,
+ "HiKey: Invalid Fastboot OEM bootdevice command: %s\n",
+ CommandUnicode
+ ));
+ return EFI_NOT_FOUND;
+ }
+
+ VariableSize = BOOT_DEVICE_LENGTH * sizeof (UINT16);
+ Status = gRT->GetVariable (
+ (CHAR16 *)L"HiKeyBootDevice",
+ &gArmGlobalVariableGuid,
+ NULL,
+ &VariableSize,
+ &BootDevice
+ );
+ if (EFI_ERROR (Status) == 0) {
+ Status = gRT->SetVariable (
+ (CHAR16*)L"HiKeyBootDevice",
+ &gArmGlobalVariableGuid,
+ EFI_VARIABLE_NON_VOLATILE |
+ EFI_VARIABLE_BOOTSERVICE_ACCESS |
+ EFI_VARIABLE_RUNTIME_ACCESS,
+ VariableSize,
+ CommandUnicode
+ );
+ }
+ return Status;
} else {
AsciiStrToUnicodeStr (Command + Index, CommandUnicode);
DEBUG ((EFI_D_ERROR,
|