From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2607:f8b0:400e:c05::242; helo=mail-pg0-x242.google.com; envelope-from=haojian.zhuang@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-pg0-x242.google.com (mail-pg0-x242.google.com [IPv6:2607:f8b0:400e:c05::242]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 3E17922683917 for ; Thu, 19 Apr 2018 03:42:57 -0700 (PDT) Received: by mail-pg0-x242.google.com with SMTP id f132so2308469pgc.10 for ; Thu, 19 Apr 2018 03:42:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=pStaFyGIW3ZDKMituvHvqkhqMGagIv8PP0nGuE5J4LY=; b=EmLd8oVk7YyrpPQXrEccHrM99thJOk5cK2YBrJuOOLQbGwh+0ZKrO0bz+mAhLkryUM /q/l3Dt1a5rBNqTZpcRRwKZtwbnFJ1t8LkezwJ/BOP/pcXRbwUCB0bDjWY5PlhWfX8Bv prZm9O7Dw08m1E/QYOjeDW58Wl49KnG5oElXk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=pStaFyGIW3ZDKMituvHvqkhqMGagIv8PP0nGuE5J4LY=; b=ZLn2x99KGYDgnSYK+8HZpOj7u+JuksCPEvhxX/a0K0qSPZTj3G/JU77q9LJbHTMOMc m877VZTot15OW4rbwQYCIRL72JqjmGxYKNWHnYyVQciK7QYPAk72r19yckBLNzQPPpHT XX5Bi/FIed9Rq+MTZ78yvGcF/7tj/rWXvTzdZZ9sGzrPEwTFKOWnBfm4dEtQCjvWm4bs x1pVUty9G5Sxbi/7J/P8zJtDADR4JbfAO1SJ7E1ey8yRYapFQkyOkQajXmumEtgCMTRR AYjJcpQGV7zZEctB+HaLSXnrwaIeS/3u8ao9qYVhcRivOxZ6Q/Dc8XxGjrgYJhSvnOcn SItQ== X-Gm-Message-State: ALQs6tB8InkXyKF/+s3LZO5UlmZA0+dYTUAGZchegdZLwS+ZsLB5zdra IRfcU94bhtjFJh0JSPvlfmGt0iDRHA4= X-Google-Smtp-Source: AIpwx4/GLz2zerJz3vJGXgo2MFNNF22oeMXe0OMVEF+zvbsyWW9ZiSJoY58nfoP/purjkEtzrqN8AA== X-Received: by 10.98.66.203 with SMTP id h72mr5382975pfd.156.1524134576640; Thu, 19 Apr 2018 03:42:56 -0700 (PDT) Received: from localhost.localdomain ([64.64.108.105]) by smtp.gmail.com with ESMTPSA id d4sm8593913pgc.43.2018.04.19.03.42.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 19 Apr 2018 03:42:55 -0700 (PDT) From: Haojian Zhuang To: edk2-devel@lists.01.org Cc: Haojian Zhuang , Laszlo Ersek , Leif Lindholm , Ard Biesheuvel Date: Thu, 19 Apr 2018 18:42:40 +0800 Message-Id: <1524134560-1245-3-git-send-email-haojian.zhuang@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1524134560-1245-1-git-send-email-haojian.zhuang@linaro.org> References: <1524134560-1245-1-git-send-email-haojian.zhuang@linaro.org> Subject: [PATCH v3 2/2] ArmPkg/PlatformBootManagerLib: load platform boot options X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Apr 2018 10:42:57 -0000 Make platform driver to create predefined boot options and related hot keys. Cc: Laszlo Ersek Cc: Leif Lindholm Cc: Ard Biesheuvel Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Haojian Zhuang --- ArmPkg/Library/PlatformBootManagerLib/PlatformBm.c | 83 ++++++++++++++++++++++ .../PlatformBootManagerLib.inf | 2 + 2 files changed, 85 insertions(+) diff --git a/ArmPkg/Library/PlatformBootManagerLib/PlatformBm.c b/ArmPkg/Library/PlatformBootManagerLib/PlatformBm.c index 61ab61ccc780..3a40592b58dd 100644 --- a/ArmPkg/Library/PlatformBootManagerLib/PlatformBm.c +++ b/ArmPkg/Library/PlatformBootManagerLib/PlatformBm.c @@ -30,6 +30,7 @@ #include #include #include +#include #include #include @@ -392,6 +393,86 @@ PlatformRegisterFvBootOption ( STATIC VOID +GetPlatformOptions ( + VOID + ) +{ + EFI_STATUS Status; + EFI_BOOT_MANAGER_LOAD_OPTION *CurrentBootOptions; + EFI_BOOT_MANAGER_LOAD_OPTION *PlatformBootOptionArray; + EFI_INPUT_KEY *PlatformKeyArray; + PLATFORM_BOOT_MANAGER_PROTOCOL *PlatformBootManager; + UINTN CurrentBootOptionCount; + UINTN OptionIndex; + UINTN Index; + + Status = gBS->LocateProtocol (&gPlatformBootManagerProtocolGuid, NULL, + (VOID **)&PlatformBootManager); + if (EFI_ERROR (Status)) { + return; + } + Status = PlatformBootManager->GetPlatformBootOptionsAndKeys ( + &PlatformBootOptionArray, + &PlatformKeyArray + ); + if (EFI_ERROR (Status)) { + return; + } + CurrentBootOptions = EfiBootManagerGetLoadOptions ( + &CurrentBootOptionCount, LoadOptionTypeBoot + ); + OptionIndex = EfiBootManagerFindLoadOption ( + &PlatformBootOptionArray[0], + CurrentBootOptions, + CurrentBootOptionCount + ); + if (OptionIndex == -1) { + OptionIndex = 1; + } else { + OptionIndex = OptionIndex + 1; + } + Index = 0; + // + // Last entries of PlatformBootOptionArray and PlatformKeyArray are empty. + // + while (PlatformBootOptionArray[Index].Description != NULL) { + if (OptionIndex == 1) { + // + // Append the BootLoadOption + // + Status = EfiBootManagerAddLoadOptionVariable ( + &PlatformBootOptionArray[Index], + OptionIndex + Index + ); + ASSERT_EFI_ERROR (Status); + } + // + // If UnicodeChar isn't empty, there's a hot key. + // + if (PlatformKeyArray[Index].UnicodeChar) { + // + // The index of Boot Options counts from 1. + // The last index equals to the count of total Boot Options. + // + Status = EfiBootManagerAddKeyOptionVariable ( + NULL, OptionIndex + Index, 0, + PlatformKeyArray[Index], NULL + ); + ASSERT_EFI_ERROR (Status); + } + Index++; + } + EfiBootManagerFreeLoadOptions ( + CurrentBootOptions, CurrentBootOptionCount + ); + EfiBootManagerFreeLoadOptions ( + PlatformBootOptionArray, Index + ); + FreePool (PlatformKeyArray); +} + +STATIC +VOID PlatformRegisterOptionsAndKeys ( VOID ) @@ -402,6 +483,8 @@ PlatformRegisterOptionsAndKeys ( EFI_INPUT_KEY Esc; EFI_BOOT_MANAGER_LOAD_OPTION BootOption; + GetPlatformOptions (); + // // Register ENTER as CONTINUE key // diff --git a/ArmPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf b/ArmPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf index 71f1d04a87ee..e8cbb10dabdd 100644 --- a/ArmPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf +++ b/ArmPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf @@ -35,6 +35,7 @@ [Sources] PlatformBm.c [Packages] + EmbeddedPkg/EmbeddedPkg.dec MdeModulePkg/MdeModulePkg.dec MdePkg/MdePkg.dec ShellPkg/ShellPkg.dec @@ -84,3 +85,4 @@ [Protocols] gEfiPciRootBridgeIoProtocolGuid gEfiSimpleFileSystemProtocolGuid gEsrtManagementProtocolGuid + gPlatformBootManagerProtocolGuid -- 2.7.4