From patchwork Tue Apr 17 05:11:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haojian Zhuang X-Patchwork-Id: 133506 Delivered-To: patch@linaro.org Received: by 10.46.84.18 with SMTP id i18csp4320931ljb; Mon, 16 Apr 2018 22:11:27 -0700 (PDT) X-Google-Smtp-Source: AIpwx49RAP2XyJPw9Z/FdfM88+11NVv6VSXrBKJcTu4NgmZTNg28Fzg64hE1J+WXcdQYQ52iba9J X-Received: by 10.98.0.15 with SMTP id 15mr683150pfa.72.1523941887122; Mon, 16 Apr 2018 22:11:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523941887; cv=none; d=google.com; s=arc-20160816; b=CJ+ytlwAf3IhiCMWXbpZ2U9h6JaAGgZgiWmb1twTzkv/MRjumlggIEUm1g3dLlxWXd AYO+JdBxRY+pmy6Rw/RxUa2jwqkgodNpU5StkVsK+meCiDR0fIW+ywZkHyT5iel81vMW HxFFUGlxI6DCmUl2693l916g26uqLteOiy0fksWihehjsKM6gjY4km2rMxoyaobpORaM E6/7gpzH++Re60AJOz/eZDaeRu29wO2GTX4IGlNqsk9EBO1vCcis8/8Jp2Ej/NkZnc2+ UJQzKTj/QQHfbh6OYFZK/2wDZ4Lgk8vofR0CWOZtd+37OZ0WFYLAOCabtCTXzNAw/8E+ wk1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:dkim-signature:delivered-to:arc-authentication-results; bh=UjlJWLzqkYScFEAQIPR1IA1PCIika4Tu7Sp0JcRKhMU=; b=HwBJlh2yqGCAmdnFSyRIzzDc9d/MX3PEswTCnBZ3bMxHar/VIUv5dWBRshHHStJyBr 1seFJ+I2S0g4epuqnpsXMuxfQo6OnmUf9d2ya+ps3xeW2QmCGUfmx9gSVWTX3ZAZQ9y5 hhFpqrJGNvC5suoBH4lCPQyNjvD8VDIvjbaSuMoamrKdQfpjtymY4UkUTmIgIsR8q+7F GpVkIqz7NWqHNm4v3zOt2WRkbR2kcEqEyHZbvr7yWbAfoWygAf4VGOuqV49ivTDQH/Fd LD2a03+DRMUVUzNfEgWTTRk2vfyAyx+fBR7F/p119Zp15Af9ivEa+N1ak7kt+VnLT4li ZV8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=KHZLU6YX; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from ml01.01.org (ml01.01.org. [2001:19d0:306:5::1]) by mx.google.com with ESMTPS id c1-v6si14114785pll.449.2018.04.16.22.11.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 16 Apr 2018 22:11:27 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) client-ip=2001:19d0:306:5::1; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=KHZLU6YX; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id B9F2E2244E410; Mon, 16 Apr 2018 22:11:26 -0700 (PDT) X-Original-To: edk2-devel@lists.01.org Delivered-To: edk2-devel@lists.01.org Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2607:f8b0:400e:c01::241; helo=mail-pl0-x241.google.com; envelope-from=haojian.zhuang@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-pl0-x241.google.com (mail-pl0-x241.google.com [IPv6:2607:f8b0:400e:c01::241]) (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 D903C22590E38 for ; Mon, 16 Apr 2018 22:11:24 -0700 (PDT) Received: by mail-pl0-x241.google.com with SMTP id f7-v6so4283639plr.4 for ; Mon, 16 Apr 2018 22:11:24 -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=RrG9xNjZDCJzskPHnxa6OoDF57/r4inl9db139qWFlE=; b=KHZLU6YXzMw0FEbVjykUnnCT8cWS9FbVYlAm0HLkmvZu5I7h3OM+B42n6g201ypd5r pVyuL9dxVTctI0a2RjyM+ooIN6zrlYqYM0yHV1AJ3Z08pbmRP9UqN2w0x7iy3u18ZFxj V2GQkF+SLPDIK4KLbdxadJcWEc4c1n++1abi0= 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=RrG9xNjZDCJzskPHnxa6OoDF57/r4inl9db139qWFlE=; b=ZLImEJb/2DrTKGgcp3fq8tPImjcSUjenvJae9Dv3zaN1rwIG4X4HfpUgRCAPX1ULPr w+rfGmevEaUlYaWqSNRwz+y4iZE4UcrupSM3b95joq3pvTmU+xHrVlkVXBiE0HKDha+f P5CzPdSUZRayiCuVWlRs/PJ3vdpc+oxz5YTlrIDE23Gx9DeRoPwOvlNdtd7UK5/L1OOl 1pU1jrIW4E+ZZBz2Za0XoC5/BavBMBsqCCjX3Up/DsdFaIQm+JA1VdFwJIrNZ4+f1E2V JJuDBsHfZZaTtJGYdXR2CGxrRRVqrVl9O7r/7tj3qPsqOZpOOlfGhggJIK/B0tRns5EA tjJw== X-Gm-Message-State: ALQs6tDmuwK61udnwdSaI+r3tHha2Vfae9kCmLZ6ROlfvQdjwnoc+RqQ ebXy/PjuSFBODNXJkP2lmnZrbXW4LxM= X-Received: by 2002:a17:902:788b:: with SMTP id q11-v6mr706989pll.76.1523941884114; Mon, 16 Apr 2018 22:11:24 -0700 (PDT) Received: from localhost.localdomain ([64.64.108.57]) by smtp.gmail.com with ESMTPSA id b184sm25545499pfg.110.2018.04.16.22.11.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 16 Apr 2018 22:11:23 -0700 (PDT) From: Haojian Zhuang To: edk2-devel@lists.01.org Date: Tue, 17 Apr 2018 13:11:12 +0800 Message-Id: <1523941872-16197-2-git-send-email-haojian.zhuang@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1523941872-16197-1-git-send-email-haojian.zhuang@linaro.org> References: <1523941872-16197-1-git-send-email-haojian.zhuang@linaro.org> Subject: [edk2] [PATCH v2 1/1] ArmPkg/PlatformBootManagerLib: load boot options from platform 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: , Cc: Haojian Zhuang MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" Platform drivers sets up the array of predefined boot options. ArmPkg/PlatformBootManager converts the array to boot options. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Haojian Zhuang --- ArmPkg/Library/PlatformBootManagerLib/PlatformBm.c | 81 ++++++++++++++++++++++ .../PlatformBootManagerLib.inf | 2 + EmbeddedPkg/EmbeddedPkg.dec | 1 + EmbeddedPkg/Include/Protocol/PlatformBootManager.h | 39 +++++++++++ 4 files changed, 123 insertions(+) create mode 100644 EmbeddedPkg/Include/Protocol/PlatformBootManager.h -- 2.7.4 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel diff --git a/ArmPkg/Library/PlatformBootManagerLib/PlatformBm.c b/ArmPkg/Library/PlatformBootManagerLib/PlatformBm.c index 61ab61ccc780..68a06f5855d8 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,84 @@ PlatformRegisterFvBootOption ( STATIC VOID +GetPlatformOptions ( + VOID + ) +{ + EFI_STATUS Status; + EFI_BOOT_MANAGER_LOAD_OPTION NewOption; + EFI_BOOT_MANAGER_LOAD_OPTION *CurrentBootOptions; + EFI_BOOT_MANAGER_LOAD_OPTION *PlatformOption; + EFI_BOOT_MANAGER_LOAD_OPTION *PlatformBootOptionArray; + EFI_INPUT_KEY *PlatformKeyArray; + EFI_INPUT_KEY *PlatformKey; + PLATFORM_BOOT_MANAGER_PROTOCOL *PlatformBootManager; + UINTN CurrentBootOptionCount; + UINTN OptionIndex; + + Status = gBS->LocateProtocol (&gPlatformBootManagerProtocolGuid, NULL, + (VOID **)&PlatformBootManager); + if (!EFI_ERROR (Status)) { + if (PlatformBootManager->Register) { + // Last entries of PlatformBootOptionArray and PlatformKeyArray are empty. + Status = PlatformBootManager->Register ( + &PlatformBootOptionArray, + &PlatformKeyArray + ); + if (!EFI_ERROR (Status)) { + PlatformOption = PlatformBootOptionArray; + PlatformKey = PlatformKeyArray; + while (PlatformOption->Description != NULL) { + Status = EfiBootManagerInitializeLoadOption ( + &NewOption, + LoadOptionNumberUnassigned, + LoadOptionTypeBoot, + LOAD_OPTION_ACTIVE, + PlatformOption->Description, + PlatformOption->FilePath, + NULL, + 0 + ); + ASSERT_EFI_ERROR (Status); + CurrentBootOptions = EfiBootManagerGetLoadOptions ( + &CurrentBootOptionCount, LoadOptionTypeBoot + ); + OptionIndex = EfiBootManagerFindLoadOption ( + &NewOption, CurrentBootOptions, CurrentBootOptionCount + ); + if (OptionIndex == -1) { + // Append the BootLoadOption + Status = EfiBootManagerAddLoadOptionVariable (&NewOption, MAX_UINTN); + ASSERT_EFI_ERROR (Status); + } + + // If UnicodeChar isn't empty, there's a hot key. + if (PlatformKey->UnicodeChar) { + // The index of Boot Options counts from 1. + // The last index equals to the count of total Boot Options. + Status = EfiBootManagerAddKeyOptionVariable ( + NULL, CurrentBootOptionCount, 0, PlatformKey, NULL + ); + } + + EfiBootManagerFreeLoadOption (&NewOption); + EfiBootManagerFreeLoadOptions ( + CurrentBootOptions, CurrentBootOptionCount + ); + + PlatformOption++; + PlatformKey++; + } + FreePool (PlatformBootOptionArray); + FreePool (PlatformKeyArray); + } + } + } + +} + +STATIC +VOID PlatformRegisterOptionsAndKeys ( VOID ) @@ -402,6 +481,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 diff --git a/EmbeddedPkg/EmbeddedPkg.dec b/EmbeddedPkg/EmbeddedPkg.dec index eb135340b173..9cd50738363b 100644 --- a/EmbeddedPkg/EmbeddedPkg.dec +++ b/EmbeddedPkg/EmbeddedPkg.dec @@ -81,6 +81,7 @@ [Protocols.common] gPlatformGpioProtocolGuid = { 0x52ce9845, 0x5af4, 0x43e2, {0xba, 0xfd, 0x23, 0x08, 0x12, 0x54, 0x7a, 0xc2 }} gAndroidBootImgProtocolGuid = { 0x9859bb19, 0x407c, 0x4f8b, {0xbc, 0xe1, 0xf8, 0xda, 0x65, 0x65, 0xf4, 0xa5 }} gPlatformVirtualKeyboardProtocolGuid = { 0x0e3606d2, 0x1dc3, 0x4e6f, { 0xbe, 0x65, 0x39, 0x49, 0x82, 0xa2, 0x65, 0x47 }} + gPlatformBootManagerProtocolGuid = { 0x7197c8a7, 0x6559, 0x4c93, { 0x93, 0xd5, 0x8a, 0x84, 0xf9, 0x88, 0x79, 0x8b }} [Ppis] gEdkiiEmbeddedGpioPpiGuid = { 0x21c3b115, 0x4e0b, 0x470c, { 0x85, 0xc7, 0xe1, 0x05, 0xa5, 0x75, 0xc9, 0x7b }} diff --git a/EmbeddedPkg/Include/Protocol/PlatformBootManager.h b/EmbeddedPkg/Include/Protocol/PlatformBootManager.h new file mode 100644 index 000000000000..9335cb143585 --- /dev/null +++ b/EmbeddedPkg/Include/Protocol/PlatformBootManager.h @@ -0,0 +1,39 @@ +/** @file + + Copyright (c) 2018, Linaro. All rights reserved.
+ + This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#ifndef __PLATFORM_BOOT_MANAGER_PROTOCOL_H__ +#define __PLATFORM_BOOT_MANAGER_PROTOCOL_H__ + +// +// Protocol interface structure +// +typedef struct _PLATFORM_BOOT_MANAGER_PROTOCOL PLATFORM_BOOT_MANAGER_PROTOCOL; + +// +// Function Prototypes +// +typedef +EFI_STATUS +(EFIAPI *REGISTER_PLATFORM_BOOT_MANAGER) ( + OUT EFI_BOOT_MANAGER_LOAD_OPTION **BootOptions, + OUT EFI_INPUT_KEY **BootKeys + ); + +struct _PLATFORM_BOOT_MANAGER_PROTOCOL { + REGISTER_PLATFORM_BOOT_MANAGER Register; +}; + +extern EFI_GUID gPlatformBootManagerProtocolGuid; + +#endif /* __PLATFORM_BOOT_PROTOCOL_H__ */