public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Haojian Zhuang <haojian.zhuang@linaro.org>
To: edk2-devel@lists.01.org, leif.lindholm@linaro.org,
	ard.biesheuvel@linaro.org, linaro-uefi@lists.linaro.org
Cc: Haojian Zhuang <haojian.zhuang@linaro.org>
Subject: [PATCH] ArmPkg/PlatformBootManagerLib: add hotkey to fastboot
Date: Thu, 15 Feb 2018 23:15:33 +0800	[thread overview]
Message-ID: <1518707733-17012-1-git-send-email-haojian.zhuang@linaro.org> (raw)

It checkes whether AndroidFastbootApp exists in boot menu.
If it exists, add hotkey 'F' to AndroidFastbootApp.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Haojian Zhuang <haojian.zhuang@linaro.org>
---
 ArmPkg/Library/PlatformBootManagerLib/PlatformBm.c | 40 ++++++++++++++++++++++
 1 file changed, 40 insertions(+)

diff --git a/ArmPkg/Library/PlatformBootManagerLib/PlatformBm.c b/ArmPkg/Library/PlatformBootManagerLib/PlatformBm.c
index 61ab61c..54c297c 100644
--- a/ArmPkg/Library/PlatformBootManagerLib/PlatformBm.c
+++ b/ArmPkg/Library/PlatformBootManagerLib/PlatformBm.c
@@ -389,6 +389,31 @@ PlatformRegisterFvBootOption (
   EfiBootManagerFreeLoadOptions (BootOptions, BootOptionCount);
 }
 
+STATIC
+UINTN
+PlatformFindBootOptionByDescription (
+  IN CHAR16                  *Description
+  )
+{
+  UINTN                        BootOptionCount;
+  EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions;
+  UINTN                        Index;
+  UINTN                        OptionIndex;
+
+  OptionIndex = LoadOptionNumberUnassigned;
+  BootOptions = EfiBootManagerGetLoadOptions (&BootOptionCount, LoadOptionTypeBoot);
+
+  for (Index = 0; Index < BootOptionCount; Index++) {
+    if (StrnCmp (Description, BootOptions[Index].Description, StrLen (BootOptions[Index].Description)) == 0) {
+      OptionIndex = BootOptions[Index].OptionNumber;
+      break;
+    }
+  }
+
+  EfiBootManagerFreeLoadOptions (BootOptions, BootOptionCount);
+  return OptionIndex;
+}
+
 
 STATIC
 VOID
@@ -400,7 +425,9 @@ PlatformRegisterOptionsAndKeys (
   EFI_INPUT_KEY                Enter;
   EFI_INPUT_KEY                F2;
   EFI_INPUT_KEY                Esc;
+  EFI_INPUT_KEY                KeyF;
   EFI_BOOT_MANAGER_LOAD_OPTION BootOption;
+  UINTN                        OptionNumber;
 
   //
   // Register ENTER as CONTINUE key
@@ -427,6 +454,19 @@ PlatformRegisterOptionsAndKeys (
              NULL, (UINT16) BootOption.OptionNumber, 0, &Esc, NULL
              );
   ASSERT (Status == EFI_SUCCESS || Status == EFI_ALREADY_STARTED);
+
+  //
+  // Map F to "Android Fastboot App"
+  //
+  KeyF.ScanCode    = SCAN_NULL;
+  KeyF.UnicodeChar = 'f';
+  OptionNumber = PlatformFindBootOptionByDescription (L"Android Fastboot");
+  if (OptionNumber != LoadOptionNumberUnassigned) {
+    Status = EfiBootManagerAddKeyOptionVariable (
+               NULL, (UINT16) OptionNumber, 0, &KeyF, NULL
+               );
+    ASSERT (Status == EFI_SUCCESS || Status == EFI_ALREADY_STARTED);
+  }
 }
 
 
-- 
2.7.4



                 reply	other threads:[~2018-02-15 15:09 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1518707733-17012-1-git-send-email-haojian.zhuang@linaro.org \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox