From patchwork Mon Apr 23 06:21:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haojian Zhuang X-Patchwork-Id: 133961 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp631763lji; Sun, 22 Apr 2018 23:22:09 -0700 (PDT) X-Google-Smtp-Source: AIpwx48OlvGx09AwTDBjeWYqD9AdPWU2jSxTgc9WFUKYEx/Uj/FTgNTeCJikAaMivj9moVAY/TeN X-Received: by 10.98.12.202 with SMTP id 71mr18701720pfm.61.1524464529773; Sun, 22 Apr 2018 23:22:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524464529; cv=none; d=google.com; s=arc-20160816; b=QqdsuakFznTDpHG7+LVDKVs1bHe3EKAF9RuySkYSWNzBvD2EFT600Hzib28Zox0nfm WMCcf2IgWYwJbw1aW59GBA7syH4yNxISPpJJLeDDVrTDhO35S53Ufb7jPFcN+4NYEX9I tpbbkWlqruEvMWZztTPrDMkVmK++A2LgtE2SgjQXsk+T5Qbkp5c3fRs3YdORx/TdgveS TjP+C/wtJrnx1ksCsxagVqzGfFFU76PI+NE25hjfzyBtf2zm1rNlBzjotkLGaNspPPTu WO5YWm4u7ucQb1UANqlvyDQ1ZOOdKzu0Jdz2P/mKV1ot5ANhEZUEt6zlzX4wYp/wYDsc dc/w== 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=pJylBDJNOJc90NvqRPb5WHNtLSwt8GgDqtPMZ29gNSg=; b=RPEdjwQoM5ermWXS1Orh/RBA/DRbBHG0S9FGPK2/O47iR/n6/5t1B8/ZVG9sj4zQRG mk6IoMP7LALvuAdaeGwZY7ZWx4UrN40P8/YBOpA+wSBChV1JYwBdg9YTtdTHJrV5aFGn aWbODEfPf6ibWw7tNsRWZFRPnK8n+m9yJn7v/JyvqbMicZX/zGvZgXRfsA39VwHa5Bkd qYNnpXsFbxWe7Zd+PRU8j2Gptdspm2tpcH2SqQ/QK86Np9MReX9mjghTXalwN9wN7abb AXO/atIsZINcEPmoaYHYq4WZXzhn3KUepCscofAXqf1xqJDkBf/da4DAJ0t7uOhYLjEM GbGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=aBt3Gdaq; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 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. [198.145.21.10]) by mx.google.com with ESMTPS id o3-v6si11198344pld.384.2018.04.22.23.22.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 22 Apr 2018 23:22:09 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) client-ip=198.145.21.10; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=aBt3Gdaq; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 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 67675226CD63F; Sun, 22 Apr 2018 23:22:09 -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: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 CAFDB226CD63C for ; Sun, 22 Apr 2018 23:22:08 -0700 (PDT) Received: by mail-pg0-x242.google.com with SMTP id b5so7672466pgv.5 for ; Sun, 22 Apr 2018 23:22:08 -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=YXaEofEgy0zGwmwoaBdhiEYaIx0+rGdHSgeXOI2g7OU=; b=aBt3GdaqL4oG7PzBvBXeQH0qnBvl2cyBGHWAiGxq6bk2vcmBkkANoeuVyWYDNhNduf WT1DALihW1pKvxIez2kspFOJrQNsG/ptPAGSg87DAZSajSdv2YfKBVPBV+7y83IH+rZb MyNa0fn0Sc5QRgfO9GRZHbgujoZcO56Lwoe0s= 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=YXaEofEgy0zGwmwoaBdhiEYaIx0+rGdHSgeXOI2g7OU=; b=PU3TxuKz/nzXhwwNFKuUxd3Omx2HAvhyHGgKBgZABMLv0TUn4ibDi639UbwXxJXq9f gWZqQtHRGlNt63TUPEnHOfVT3Ki+cgCS+IhJKMAC32lALR8FSUO9aVoJuPFIsYuh7Prc 1r/ZPFyZGsukJT65S+3rfiyQDUYapAs3jBSGkzwOvEH+OBxqlBnjFZzDILwTEL/InPkh xYlCgNQmxdJxPcN8fMusskI3xFp2WDWuBPe9r7CrM/A/dE0CDfmoHcPcaR6G61gc2SG/ kqXLcRY49/RgJ+5Y73n3kMiAgsX7QToq30KJPVo4/dWVy6kGpF04YeuL1JfbQAD5na8o q/aw== X-Gm-Message-State: ALQs6tAB65UMfZSrufVUUy1wQM4BzpeVl7XQUxFgG4HHANwgA0/V0Lvi MqEfpu3YLcIzVn5LubRpjq2BCsNW11Y= X-Received: by 10.99.165.79 with SMTP id r15mr16489513pgu.236.1524464528155; Sun, 22 Apr 2018 23:22:08 -0700 (PDT) Received: from localhost.localdomain ([64.64.108.101]) by smtp.gmail.com with ESMTPSA id u4sm8258771pfn.3.2018.04.22.23.22.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 22 Apr 2018 23:22:07 -0700 (PDT) From: Haojian Zhuang To: edk2-devel@lists.01.org Date: Mon, 23 Apr 2018 14:21:53 +0800 Message-Id: <1524464514-14454-2-git-send-email-haojian.zhuang@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1524464514-14454-1-git-send-email-haojian.zhuang@linaro.org> References: <1524464514-14454-1-git-send-email-haojian.zhuang@linaro.org> Subject: [edk2] [PATCH v4 1/2] EmbeddedPkg: add platform boot manager protocol 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: Laszlo Ersek , Haojian Zhuang , Leif Lindholm , Ard Biesheuvel MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" Create the PlatformBootManagerProtocol that is used to add predefined boot options in platform driver. This interface will be used in ArmPkg/PlatformBootManagerLib. Cc: Laszlo Ersek Cc: Leif Lindholm Cc: Ard Biesheuvel Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Haojian Zhuang --- EmbeddedPkg/EmbeddedPkg.dec | 1 + EmbeddedPkg/Include/Protocol/PlatformBootManager.h | 86 ++++++++++++++++++++++ 2 files changed, 87 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/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..9fa27985b469 --- /dev/null +++ b/EmbeddedPkg/Include/Protocol/PlatformBootManager.h @@ -0,0 +1,86 @@ +/** @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 +// + +/* + Get predefined boot options for platform. + + @param[out] Count The number of elements in each of + BootOptions and BootKeys. On successful + return, Count is at least one. + + @param[out] BootOptions An array of platform boot options. + BootOptions is pool-allocated by + GET_PLATFORM_BOOT_OPTIONS_AND_KEYS, and + GET_PLATFORM_BOOT_OPTIONS_AND_KEYS populates + every element in BootOptions with + EfiBootManagerInitializeLoadOption(). + BootOptions shall not contain duplicate + entries. The caller is responsible for + releasing BootOptions after use with + EfiBootManagerFreeLoadOptions(). + + @param[out] BootKeys A pool-allocated array of platform boot + hotkeys. For every 0 <= Index < Count, if + BootOptions[Index] is not to be associated + with a hotkey, then BootKeys[Index] is + zero-filled. Otherwise, BootKeys[Index] + specifies the boot hotkey for + BootOptions[Index]. BootKeys shall not + contain duplicate entries (other than + zero-filled entries). The caller is + responsible for releasing BootKeys with + FreePool() after use. + + @retval EFI_SUCCESS Count, BootOptions and BootKeys have + been set. + + @retval EFI_OUT_OF_RESOURCES Memory allocation failed. + + @retval EFI_UNSUPPORTED The platform doesn't provide boot options + as a feature. + + @retval EFI_NOT_FOUND The platform could provide boot options + as a feature, but none have been + configured. + + @return Error codes propagated from underlying + functions. +*/ +typedef +EFI_STATUS +(EFIAPI *GET_PLATFORM_BOOT_OPTIONS_AND_KEYS) ( + OUT UINTN *Count, + OUT EFI_BOOT_MANAGER_LOAD_OPTION **BootOptions, + OUT EFI_INPUT_KEY **BootKeys + ); + +struct _PLATFORM_BOOT_MANAGER_PROTOCOL { + GET_PLATFORM_BOOT_OPTIONS_AND_KEYS GetPlatformBootOptionsAndKeys; +}; + +extern EFI_GUID gPlatformBootManagerProtocolGuid; + +#endif /* __PLATFORM_BOOT_MANAGER_PROTOCOL_H__ */ From patchwork Mon Apr 23 06:21:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haojian Zhuang X-Patchwork-Id: 133962 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp631822lji; Sun, 22 Apr 2018 23:22:14 -0700 (PDT) X-Google-Smtp-Source: AIpwx49LVBqiPNYRMWubWO4CZ8JZ8CvvhLEB4e90lAahOGFRWn/IzIJBtjLJRbafJXdkdi86SBMm X-Received: by 10.101.65.4 with SMTP id w4mr15609228pgp.181.1524464533974; Sun, 22 Apr 2018 23:22:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524464533; cv=none; d=google.com; s=arc-20160816; b=dlEWWA9Jqfi9xtT13pkgVBZkt3r9ZmhZnZCxVr8w76ItB8VDx5N6sSC4QF4TfqSitQ kOqadaNAfR5yXMy0eO+km6D0H1XEqebdhAB0Wb3AUfFFHXqiYIs6NK0UWQpswkJNOvTH zsUyzevoaYR1Zp/+3CyIlN/USmV5uoaXWRdIdHg/+kkPH7MkHRi307Yhzwm+BxoE6Pqa yTAxFnGgn3pS4Zn/fLqPQcE3K4dHa/wEyPDBPVjqs/lhxjtvKVNWdHVoPe3bdbH+ZcA2 78fmKhDXrQrZl8tU6mZX7hG9FMbKRyPDeVrYcqsi9L03nNN/ty/dgAA+UukoFnoX6bYD ZZ7Q== 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=pAH3rVk87jt8CbTP4iIVFi0bJLIP2Pcky/Cy7U2yTU4=; b=ek9qVza9ItW5p3I4ryY+QkH121NgQNqEt0DpK901naslrx6ICRu2gAljWpuadXaBsh Fi/X2/xmBSpw+bkLuFS3daARG/7GvPYYp6G7caA44bWnXvYK8YELrsTbXJZWKWSAhHqO vRYo4LifAPl5wS/L1InSHsfu8oZtvQNeMCwaydLx1WwRG1uclzIlBsz2yCq2GxwTG7nA QMU4W2BLewQxyWcCeH94TxPe7jk0fY9/mw89O7/MxSA3GH7EWrOFBkqyufUhtfNiIBAl djf6lrbWfrSpckQwTaHuyxQIe15BEHvRH+sk8YLpFYZbn/++T3GLAB6reD/fxKc9nJZg UcAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=MBXP3x+S; 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 b129si9028949pgc.387.2018.04.22.23.22.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 22 Apr 2018 23:22:13 -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=MBXP3x+S; 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 9359822590E1C; Sun, 22 Apr 2018 23:22:13 -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:c05::244; helo=mail-pg0-x244.google.com; envelope-from=haojian.zhuang@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-pg0-x244.google.com (mail-pg0-x244.google.com [IPv6:2607:f8b0:400e:c05::244]) (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 9E335226CD63E for ; Sun, 22 Apr 2018 23:22:12 -0700 (PDT) Received: by mail-pg0-x244.google.com with SMTP id i29so6163863pgn.12 for ; Sun, 22 Apr 2018 23:22:12 -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=2oGz7se8Gs55Anf7Y/r9y2yNCg2AXWcg/IfkLB0lMq4=; b=MBXP3x+Seqahv00GknPyweYqaryVcXE6R3KBrIkQSsq+mM+2cZOmNi9crkQB4wCmEq SyBPSmKoh/KXsLUUDvXJD9w44Xo1N5FqDQFXgu/lMKVNB7esnGvMdzT6udn3hG4AOQI2 c8cUMRdK5v6j4LTuBIHywmwYbvfd9oABJDVfE= 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=2oGz7se8Gs55Anf7Y/r9y2yNCg2AXWcg/IfkLB0lMq4=; b=KqrGH+bxDYqF8NJqJUvUcznY1gwc2+w3A5B3e+8M1+SW4vOZN5tjq81133B2zvhmQr ezU9yfjT9m5HvbRQYQYSOdR56FLivX/GnPKRL8YVyH+7niYh+qusUsEbXdaVVMUpRCZ3 OIDgqeokD5ATy6P20SY6c44lQeb4wZe06ie16ZxF8pa1M5ixHA3GaJ98uv4jMJa6za06 EH4rhfrBKy/T1utSMh6Tk+iJi1wVfNDabR9/ih9+Zi63Z/W2AO02+VMvRZ2j3DV/ZBhw 1bfuuHHZ25WICpLeC3faSzT3SlZ6Qb19PTg9fzWlkS0kddODqxSVfaLAGN0jFbVzttRz U1Ew== X-Gm-Message-State: ALQs6tDWL62lCjRKXc2qtR5RlCOSvBXKSRvRnh9EchKxG5r/9YCbcPM3 Y3je+fucDUw2VUNF6TM4tor0nh9VZRk= X-Received: by 10.99.123.17 with SMTP id w17mr15940503pgc.8.1524464531897; Sun, 22 Apr 2018 23:22:11 -0700 (PDT) Received: from localhost.localdomain ([64.64.108.101]) by smtp.gmail.com with ESMTPSA id u4sm8258771pfn.3.2018.04.22.23.22.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 22 Apr 2018 23:22:10 -0700 (PDT) From: Haojian Zhuang To: edk2-devel@lists.01.org Date: Mon, 23 Apr 2018 14:21:54 +0800 Message-Id: <1524464514-14454-3-git-send-email-haojian.zhuang@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1524464514-14454-1-git-send-email-haojian.zhuang@linaro.org> References: <1524464514-14454-1-git-send-email-haojian.zhuang@linaro.org> Subject: [edk2] [PATCH v4 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: , Cc: Laszlo Ersek , Haojian Zhuang , Leif Lindholm , Ard Biesheuvel MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" 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 | 103 +++++++++++++++++++++ .../PlatformBootManagerLib.inf | 2 + 2 files changed, 105 insertions(+) -- 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..3456a71fbb9c 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,106 @@ PlatformRegisterFvBootOption ( STATIC VOID +GetPlatformOptions ( + VOID + ) +{ + EFI_STATUS Status; + EFI_BOOT_MANAGER_LOAD_OPTION *CurrentBootOptions; + EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions; + EFI_INPUT_KEY *BootKeys; + PLATFORM_BOOT_MANAGER_PROTOCOL *PlatformBootManager; + UINTN CurrentBootOptionCount; + UINTN Index; + UINTN BootCount; + + Status = gBS->LocateProtocol (&gPlatformBootManagerProtocolGuid, NULL, + (VOID **)&PlatformBootManager); + if (EFI_ERROR (Status)) { + return; + } + Status = PlatformBootManager->GetPlatformBootOptionsAndKeys ( + &BootCount, + &BootOptions, + &BootKeys + ); + if (EFI_ERROR (Status)) { + return; + } + // + // Fetch the existent boot options. If there are none, CurrentBootCount + // will be zeroed. + // + CurrentBootOptions = EfiBootManagerGetLoadOptions ( + &CurrentBootOptionCount, + LoadOptionTypeBoot + ); + // + // Process the platform boot options. + // + for (Index = 0; Index < BootCount; Index++) { + INTN Match; + UINTN BootOptionNumber; + + // + // If there are any preexistent boot options, and the subject platform boot + // option is already among them, then don't try to add it. Just get its + // assigned boot option number so we can associate a hotkey with it. Note + // that EfiBootManagerFindLoadOption() deals fine with (CurrentBootOptions + // == NULL) if (CurrentBootCount == 0). + // + Match = EfiBootManagerFindLoadOption ( + &BootOptions[Index], + CurrentBootOptions, + CurrentBootOptionCount + ); + if (Match >= 0) { + BootOptionNumber = CurrentBootOptions[Match].OptionNumber; + } else { + // + // Add the platform boot options as a new one, at the end of the boot + // order. Note that if the platform provided this boot option with an + // unassigned option number, then the below function call will assign a + // number. + // + Status = EfiBootManagerAddLoadOptionVariable ( + &BootOptions[Index], + MAX_UINTN + ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: failed to register \"%s\": %r\n", + __FUNCTION__, BootOptions[Index].Description, Status)); + continue; + } + BootOptionNumber = BootOptions[Index].OptionNumber; + } + + // + // Register a hotkey with the boot option, if requested. + // + if (BootKeys[Index].UnicodeChar == L'\0') { + continue; + } + + Status = EfiBootManagerAddKeyOptionVariable ( + NULL, + BootOptionNumber, + 0, + BootKeys[Index], + NULL + ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: failed to register hotkey for \"%s\": %r\n", + __FUNCTION__, BootOptions[Index].Description, Status)); + } + } + EfiBootManagerFreeLoadOptions (CurrentBootOptions, CurrentBootOptionCount); + EfiBootManagerFreeLoadOptions (BootOptions, BootCount); + FreePool (BootKeys); +} + +STATIC +VOID PlatformRegisterOptionsAndKeys ( VOID ) @@ -402,6 +503,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