From patchwork Fri Nov 23 08:44:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 151847 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp1799644ljp; Fri, 23 Nov 2018 00:46:06 -0800 (PST) X-Google-Smtp-Source: AFSGD/X7ihDqBuvGDdfrVuU3DR0TO92ph5PNi2PouKQgSTQQMqZuuiCgWMIzCkbcLrs6kYrTmWqw X-Received: by 2002:a24:6c55:: with SMTP id w82-v6mr12295716itb.106.1542962766270; Fri, 23 Nov 2018 00:46:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542962766; cv=none; d=google.com; s=arc-20160816; b=p8zk4XPjWXUGhYoXfXkYtdmiclsJGgahVJfDWrx3an0jHrLASsduxa82cxmoPKkPJz zPKMcOrYgGp2DN57MFWjXS2t2TgVMj+F4PUzQvPA5NpO4STn5LO9WQi4pd+OASx9i8Eh qDdR7DfymHBcRZRuzYIwBajQBG7KqHeXqyaVn+fVra5Nmz04WRvLlCq3D66GhwKmS5m/ bZJSebcoMUUSrnHADyUxl5xV1lbCzEkvWDA4tsZVAlJlLLId/shrwsXOBcVLHTcn0sAy ZI9Azoxtsyfw40nvoPxsGllwx/lxldPcLpPqGrhiRiW70y06yoeUkODIYADVBnEBYCAk 1uYQ== 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; bh=lzcNshS9lYGvbbRFcsvp2Pluvgd7EDsT02DY1Pxa2oI=; b=wS+wIBf+vKWV6gkezldNYK1K3ViyMwBPcV5WdZFbZdGf9uTT5Mq5sGGA9h7ut1+rsl hxpX6AMSKNfgg/azNQKbLNJfR95G++22jIJt3OLL8C2tc3hhItBVlWnOe+7lxdl7mvSf spn2j2uJSrkHKWQe6KNdTQyOlQpho5rdSsyb+Wo9i94TnGQX3Z0a2EmRmd2TQGfTEeKP bP4Py2RNHqAz+JVl3cvTtMIsMvVq3KpSkzgIelMEl/lataYtHrQNlPazpt7zRW+v9MWL 64MzXpiKyvjJLZ/OtijUoPmHD6juu44uDyHYas3OVtz9S6I8ultoyXsWKwu+zKA9E9dP Z7oA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=eobBMSCB; 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 b87si10459178jad.14.2018.11.23.00.46.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 23 Nov 2018 00:46:06 -0800 (PST) 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=eobBMSCB; 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 BCD392119489C; Fri, 23 Nov 2018 00:46:03 -0800 (PST) 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=2a00:1450:4864:20::343; helo=mail-wm1-x343.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wm1-x343.google.com (mail-wm1-x343.google.com [IPv6:2a00:1450:4864:20::343]) (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 DA49921B02822 for ; Fri, 23 Nov 2018 00:44:11 -0800 (PST) Received: by mail-wm1-x343.google.com with SMTP id j207so4005531wmj.1 for ; Fri, 23 Nov 2018 00:44:11 -0800 (PST) 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=UX/tnPRDV7bVuqZkFVOZeCPRfEQbLG1b/YdZS8TcTUI=; b=eobBMSCBBiE59cyWpRk9eFd5gVT4dObN68s6joUAK5d9B+xDTL2t9c54vpriXpfh9c TbQncxaA1TstnsdHocvOgozoohP4fgAO8vml5IpBE4qvEL2LsK9DWPVXGdbuZ7IjjEax GImUtOGaAPEjMkLA0lC3Y+GsTVOOrNdiykwyE= 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=UX/tnPRDV7bVuqZkFVOZeCPRfEQbLG1b/YdZS8TcTUI=; b=rda1LBtHYRpF8qg2zhpUPX7drI+2ONmGrvzsvWFS+SrjyDCtCx8652ZjzXPvHF/Daz I6A4qf1TmHq6H0TshnoRyMGA1UqY6nreqHh9pLlPYVO8fCB6DXoyNOBQ+QXxm0n+VMbw gx03PArzANRvT2cDOyxkq4KyseXxktUYDHr73UDDAqYZWMtk0BMP4X9e+s1LLcES2BQ9 T70o1IKiC7oOVrtzO46Z8Va4kKd6aOF6HzrVE0VXAnk6fTlD7mEtJj+3ZKGnnSgiDyus HRpeQOG3xHkli7XkyX16pYZRwvse/rQen1r4RmYsEWFgG/6AYUOWEjjEC4q/ObQMybUF MTaA== X-Gm-Message-State: AA+aEWYO/suPnqzRnWlbq6DZjoFYLt/AFAW66JENY1ksDYkXS85NOUEj MOYnH7Q+3UJI5e6F7nHg8MLrjnhb5CgyZA== X-Received: by 2002:a7b:c404:: with SMTP id k4mr12923667wmi.144.1542962650040; Fri, 23 Nov 2018 00:44:10 -0800 (PST) Received: from mba13.wifi.ns.nl (33.153.69.91.rev.sfr.net. [91.69.153.33]) by smtp.gmail.com with ESMTPSA id c8sm807377wrx.42.2018.11.23.00.44.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 23 Nov 2018 00:44:09 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.01.org Date: Fri, 23 Nov 2018 09:44:04 +0100 Message-Id: <20181123084406.27192-2-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181123084406.27192-1-ard.biesheuvel@linaro.org> References: <20181123084406.27192-1-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH v2 edk2-platforms 1/3] Platform/ARM: import ARM platform specific BdsLib header X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lersek@redhat.com, nariman.poushin@linaro.org MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" The BdsLib library has been moved into Platform/ARM a while ago, but the BdsLib.h header was left behind, and so all users in Platform/ARM are still relying on it to be available in ArmPkg. So let's add a copy to Platform/ARM and wire it up, so we can drop it from ArmPkg going forward. Note that the BdsLib implementation included ArmLib.h from ArmPkg without using anything it provides, so drop that false dependency as well. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel Acked-by: Laszlo Ersek --- Platform/ARM/ARM.dec | 3 + Platform/ARM/Drivers/FdtPlatformDxe/FdtPlatformDxe.inf | 2 +- Platform/ARM/Include/Library/BdsLib.h | 212 ++++++++++++++++++++ Platform/ARM/Library/BdsLib/BdsInternal.h | 1 - Platform/ARM/Library/BdsLib/BdsLib.inf | 2 +- 5 files changed, 217 insertions(+), 3 deletions(-) -- 2.17.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel diff --git a/Platform/ARM/ARM.dec b/Platform/ARM/ARM.dec index f9bf3294a0ca..6a6eeb6559fd 100644 --- a/Platform/ARM/ARM.dec +++ b/Platform/ARM/ARM.dec @@ -21,5 +21,8 @@ [Includes] Include # Root include for the package +[LibraryClasses] + BdsLib|Include/Library/BdsLib.h + [Guids] gArmBootMonFsFileInfoGuid = { 0x41e26b9c, 0xada6, 0x45b3, { 0x80, 0x8e, 0x23, 0x57, 0xa3, 0x5b, 0x60, 0xd6 } } diff --git a/Platform/ARM/Drivers/FdtPlatformDxe/FdtPlatformDxe.inf b/Platform/ARM/Drivers/FdtPlatformDxe/FdtPlatformDxe.inf index f9a5aee3596e..d4aef4bfce92 100644 --- a/Platform/ARM/Drivers/FdtPlatformDxe/FdtPlatformDxe.inf +++ b/Platform/ARM/Drivers/FdtPlatformDxe/FdtPlatformDxe.inf @@ -28,10 +28,10 @@ ShellSetFdt.c [Packages] - ArmPkg/ArmPkg.dec EmbeddedPkg/EmbeddedPkg.dec MdeModulePkg/MdeModulePkg.dec MdePkg/MdePkg.dec + Platform/ARM/ARM.dec Platform/ARM/Drivers/FdtPlatformDxe/FdtPlatformDxe.dec ShellPkg/ShellPkg.dec diff --git a/Platform/ARM/Include/Library/BdsLib.h b/Platform/ARM/Include/Library/BdsLib.h new file mode 100644 index 000000000000..4528c2e8739b --- /dev/null +++ b/Platform/ARM/Include/Library/BdsLib.h @@ -0,0 +1,212 @@ +/** @file +* +* Copyright (c) 2013-2015, ARM Limited. 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 __BDS_ENTRY_H__ +#define __BDS_ENTRY_H__ + +#define IS_DEVICE_PATH_NODE(node,type,subtype) \ + (((node)->Type == (type)) && ((node)->SubType == (subtype))) + +/** + This is defined by the UEFI specs, don't change it +**/ +typedef struct { + UINT16 LoadOptionIndex; + EFI_LOAD_OPTION *LoadOption; + UINTN LoadOptionSize; + + UINT32 Attributes; + UINT16 FilePathListLength; + CHAR16 *Description; + EFI_DEVICE_PATH_PROTOCOL *FilePathList; + + VOID* OptionalData; + UINTN OptionalDataSize; +} BDS_LOAD_OPTION; + +/** + Connect a Device Path and return the handle of the driver that support this DevicePath + + @param DevicePath Device Path of the File to connect + @param Handle Handle of the driver that support this DevicePath + @param RemainingDevicePath Remaining DevicePath nodes that do not match the driver DevicePath + + @retval EFI_SUCCESS A driver that matches the Device Path has been found + @retval EFI_NOT_FOUND No handles match the search. + @retval EFI_INVALID_PARAMETER DevicePath or Handle is NULL + +**/ +EFI_STATUS +BdsConnectDevicePath ( + IN EFI_DEVICE_PATH_PROTOCOL* DevicePath, + OUT EFI_HANDLE *Handle, + OUT EFI_DEVICE_PATH_PROTOCOL **RemainingDevicePath + ); + +/** + Connect all DXE drivers + + @retval EFI_SUCCESS All drivers have been connected + @retval EFI_NOT_FOUND No handles match the search. + @retval EFI_OUT_OF_RESOURCES There is not resource pool memory to store the matching results. + +**/ +EFI_STATUS +BdsConnectAllDrivers ( + VOID + ); + +/** + Return the value of a global variable defined by its VariableName. + The variable must be defined with the VendorGuid gEfiGlobalVariableGuid. + + @param VariableName A Null-terminated string that is the name of the vendor's + variable. + @param DefaultValue Value returned by the function if the variable does not exist + @param DataSize On input, the size in bytes of the return Data buffer. + On output the size of data returned in Data. + @param Value Value read from the UEFI Variable or copy of the default value + if the UEFI Variable does not exist + + @retval EFI_SUCCESS All drivers have been connected + @retval EFI_NOT_FOUND No handles match the search. + @retval EFI_OUT_OF_RESOURCES There is not resource pool memory to store the matching results. + +**/ +EFI_STATUS +GetGlobalEnvironmentVariable ( + IN CONST CHAR16* VariableName, + IN VOID* DefaultValue, + IN OUT UINTN* Size, + OUT VOID** Value + ); + +/** + Return the value of the variable defined by its VariableName and VendorGuid + + @param VariableName A Null-terminated string that is the name of the vendor's + variable. + @param VendorGuid A unique identifier for the vendor. + @param DefaultValue Value returned by the function if the variable does not exist + @param DataSize On input, the size in bytes of the return Data buffer. + On output the size of data returned in Data. + @param Value Value read from the UEFI Variable or copy of the default value + if the UEFI Variable does not exist + + @retval EFI_SUCCESS All drivers have been connected + @retval EFI_NOT_FOUND No handles match the search. + @retval EFI_OUT_OF_RESOURCES There is not resource pool memory to store the matching results. + +**/ +EFI_STATUS +GetEnvironmentVariable ( + IN CONST CHAR16* VariableName, + IN EFI_GUID* VendorGuid, + IN VOID* DefaultValue, + IN OUT UINTN* Size, + OUT VOID** Value + ); + +EFI_STATUS +BootOptionFromLoadOptionIndex ( + IN UINT16 LoadOptionIndex, + OUT BDS_LOAD_OPTION** BdsLoadOption + ); + +EFI_STATUS +BootOptionFromLoadOptionVariable ( + IN CHAR16* BootVariableName, + OUT BDS_LOAD_OPTION** BdsLoadOption + ); + +EFI_STATUS +BootOptionToLoadOptionVariable ( + IN BDS_LOAD_OPTION* BdsLoadOption + ); + +UINT16 +BootOptionAllocateBootIndex ( + VOID + ); + +/** + Start an EFI Application from a Device Path + + @param ParentImageHandle Handle of the calling image + @param DevicePath Location of the EFI Application + + @retval EFI_SUCCESS All drivers have been connected + @retval EFI_NOT_FOUND The Linux kernel Device Path has not been found + @retval EFI_OUT_OF_RESOURCES There is not enough resource memory to store the matching results. + +**/ +EFI_STATUS +BdsStartEfiApplication ( + IN EFI_HANDLE ParentImageHandle, + IN EFI_DEVICE_PATH_PROTOCOL *DevicePath, + IN UINTN LoadOptionsSize, + IN VOID* LoadOptions + ); + +EFI_STATUS +BdsLoadImage ( + IN EFI_DEVICE_PATH *DevicePath, + IN EFI_ALLOCATE_TYPE Type, + IN OUT EFI_PHYSICAL_ADDRESS* Image, + OUT UINTN *FileSize + ); + +/** + * Call BS.ExitBootServices with the appropriate Memory Map information + */ +EFI_STATUS +ShutdownUefiBootServices ( + VOID + ); + +/** + Locate an EFI application in a the Firmware Volumes by its name + + @param EfiAppGuid Guid of the EFI Application into the Firmware Volume + @param DevicePath EFI Device Path of the EFI application + + @return EFI_SUCCESS The function completed successfully. + @return EFI_NOT_FOUND The protocol could not be located. + @return EFI_OUT_OF_RESOURCES There are not enough resources to find the protocol. + +**/ +EFI_STATUS +LocateEfiApplicationInFvByName ( + IN CONST CHAR16* EfiAppName, + OUT EFI_DEVICE_PATH **DevicePath + ); + +/** + Locate an EFI application in a the Firmware Volumes by its GUID + + @param EfiAppGuid Guid of the EFI Application into the Firmware Volume + @param DevicePath EFI Device Path of the EFI application + + @return EFI_SUCCESS The function completed successfully. + @return EFI_NOT_FOUND The protocol could not be located. + @return EFI_OUT_OF_RESOURCES There are not enough resources to find the protocol. + +**/ +EFI_STATUS +LocateEfiApplicationInFvByGuid ( + IN CONST EFI_GUID *EfiAppGuid, + OUT EFI_DEVICE_PATH **DevicePath + ); + +#endif diff --git a/Platform/ARM/Library/BdsLib/BdsInternal.h b/Platform/ARM/Library/BdsLib/BdsInternal.h index f70aae603d69..bb4566e3a6c4 100644 --- a/Platform/ARM/Library/BdsLib/BdsInternal.h +++ b/Platform/ARM/Library/BdsLib/BdsInternal.h @@ -16,7 +16,6 @@ #define __BDS_INTERNAL_H__ #include -#include #include #include #include diff --git a/Platform/ARM/Library/BdsLib/BdsLib.inf b/Platform/ARM/Library/BdsLib/BdsLib.inf index 96c1d6e7e200..637ef5a08128 100644 --- a/Platform/ARM/Library/BdsLib/BdsLib.inf +++ b/Platform/ARM/Library/BdsLib/BdsLib.inf @@ -27,10 +27,10 @@ BdsLoadOption.c [Packages] - ArmPkg/ArmPkg.dec EmbeddedPkg/EmbeddedPkg.dec MdeModulePkg/MdeModulePkg.dec MdePkg/MdePkg.dec + Platform/ARM/ARM.dec [LibraryClasses] ArmLib From patchwork Fri Nov 23 08:44:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 151848 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp1799733ljp; Fri, 23 Nov 2018 00:46:12 -0800 (PST) X-Google-Smtp-Source: AFSGD/XMx2KVIP3ni97Dsw5M9G7y5dn3sOJUxXeACn8hrch3V9PEXoiMCi7d6XuQIrrWTIl0bpow X-Received: by 2002:a24:4b84:: with SMTP id q126mr1082725ita.138.1542962772180; Fri, 23 Nov 2018 00:46:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542962772; cv=none; d=google.com; s=arc-20160816; b=h1TxBr7mAs7nTnaDIMi87O7VFLDgpcMHr56SYENGksAUhFAdk6ytHCTR0aX3mVJ9Uj 1GxxDPOQiV+lgBl25CapWen7W8VKxmT89znKdrqDehN7tm59DsR4eoNiQWdm4Rn3eZvY MTfF6FUaOZzo8MvyBQnqXm2T+TYZlraSgHnOEbUcyPcuwhC8aK3AzebHVmMp21PMKGtS t2Ue8RtUP5i/XSNb8Po8FS1COy6Zf/OuPwJvwB2VAPFmtBzHqj3YAUBrpnzJ9jUaG70g YdysutShjFl+x9ul7ckQcB++KZ0lkhrz/CG+HLGFvDSm2rzImBcN9K6EpUpOUPp/lVls IioQ== 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; bh=rYzHrriJMylzyxr2weyvTvZBfpBnWEKbRAgASzzljrU=; b=wpju8NapXr9jDVFX/arp7RFQOdcR13fTKj7caiPO8CK4y6LC0z9fAEz2/iGT45lGtG mnCQiCCwSU0NzboNIyb/6U6bCQtUVkJNNJRSL/I1PmME6ZOoaTH0xQQlrQVCyj3TZgGv gpP0Y1AbT0B/WAvKdAS1cRmFhoyK71+Te07vru3q45UJz48x4O1zrQYmSOeRpBv8BcOQ iHD52B1WHNtX9DaZn/t5rLGsIPGnLAnwK5K6gWfYuIyaH68g6jdcNzj6/LidFBzhaoYQ yrhhLNurjkZYzLGmPlvwXfHiwiovbFExRozPTqEYmKOvaL0KeqF8VS5ZTCmr1KBoWY2u GJ2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=hzLRA+j0; 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 v193-v6si5525174itv.106.2018.11.23.00.46.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 23 Nov 2018 00:46:12 -0800 (PST) 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=hzLRA+j0; 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 2DB9F21194898; Fri, 23 Nov 2018 00:46:04 -0800 (PST) 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=2a00:1450:4864:20::342; helo=mail-wm1-x342.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wm1-x342.google.com (mail-wm1-x342.google.com [IPv6:2a00:1450:4864:20::342]) (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 48C3321B02822 for ; Fri, 23 Nov 2018 00:44:14 -0800 (PST) Received: by mail-wm1-x342.google.com with SMTP id y1so7861210wmi.3 for ; Fri, 23 Nov 2018 00:44:14 -0800 (PST) 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=IcMYXc1CfWhFZ3qatrhSSmNhZC2Z1L49lnJ18UigHDE=; b=hzLRA+j00urqr9DxPkt3Zkv2h7vlb3e2fTIYBBrDB3a5hM86PsjR0TwmlMYcgtppqJ TUXA7Exa3AsiQ+hJLMmGxvO9fla82nXp1GXHQbgqMCaHGO4mcGhZHvp/s/LBqDFmYGzo 1XYjV8jDzqAXy2KEL9ScH+SZhLzy+jv5o8mK0= 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=IcMYXc1CfWhFZ3qatrhSSmNhZC2Z1L49lnJ18UigHDE=; b=FEOk5gHdtTIOo3pxdUqYzNsJ/vqcT8F3hjOi01mVgbCmMMVfuxavaKJlMsjjC2ajDj +NPenvxw7AqZQ/0RUkI8buIqj2fP01gzsUGbnyAuQZWrdXvqtQnLJ337p/eOWgUgXTED XRtD6Jpm2GoL2OGibc2ub5XgcbCqVmpN2eTPAi9Nduj7egC0zK1WTgjJasbRZnW1I+B0 R/LhuKK9Bm16gHAAecLfMU/VBPp8kdCFfQdab2xVeNoAgi8fTgknDzzJ+aWRNDBDiugX gZ42m9Me3n9jB2Y1PXK4jR7KuZK1uQJkM/KJaydrVgZ7tnQG/p8MuZrRUjzQRoAnolCp +wiw== X-Gm-Message-State: AGRZ1gJxJyj1RcR+mijHIJpxNJohMLDwLEqvnmNAJluRe0Xby6Zk8G8W 4a5UJkT372o1HiXglOXhNSaWHetQrYd1yw== X-Received: by 2002:a1c:5dd1:: with SMTP id r200mr13325449wmb.93.1542962651888; Fri, 23 Nov 2018 00:44:11 -0800 (PST) Received: from mba13.wifi.ns.nl (33.153.69.91.rev.sfr.net. [91.69.153.33]) by smtp.gmail.com with ESMTPSA id c8sm807377wrx.42.2018.11.23.00.44.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 23 Nov 2018 00:44:11 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.01.org Date: Fri, 23 Nov 2018 09:44:05 +0100 Message-Id: <20181123084406.27192-3-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181123084406.27192-1-ard.biesheuvel@linaro.org> References: <20181123084406.27192-1-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH v2 edk2-platforms 2/3] Platform/ARM/BdsLib: drop unused functions X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lersek@redhat.com, nariman.poushin@linaro.org MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" Clean up BdsLib (which is deprecated and should not be used for future development) by removing all the pieces that are not being used at the moment. After this patch, only BdsLoadImage() remains, and the pieces it relies upon. This function is used by FdtPlatformDxe to load device tree binaries from device paths. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel --- Platform/ARM/Include/Library/BdsLib.h | 186 ------------- Platform/ARM/Library/BdsLib/BdsAppLoader.c | 253 ------------------ Platform/ARM/Library/BdsLib/BdsFilePath.c | 83 +----- Platform/ARM/Library/BdsLib/BdsHelper.c | 122 --------- Platform/ARM/Library/BdsLib/BdsInternal.h | 15 +- Platform/ARM/Library/BdsLib/BdsLib.inf | 2 - Platform/ARM/Library/BdsLib/BdsLoadOption.c | 272 -------------------- 7 files changed, 13 insertions(+), 920 deletions(-) -- 2.17.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel Acked-by: Laszlo Ersek diff --git a/Platform/ARM/Include/Library/BdsLib.h b/Platform/ARM/Include/Library/BdsLib.h index 4528c2e8739b..eab868439207 100644 --- a/Platform/ARM/Include/Library/BdsLib.h +++ b/Platform/ARM/Include/Library/BdsLib.h @@ -15,150 +15,6 @@ #ifndef __BDS_ENTRY_H__ #define __BDS_ENTRY_H__ -#define IS_DEVICE_PATH_NODE(node,type,subtype) \ - (((node)->Type == (type)) && ((node)->SubType == (subtype))) - -/** - This is defined by the UEFI specs, don't change it -**/ -typedef struct { - UINT16 LoadOptionIndex; - EFI_LOAD_OPTION *LoadOption; - UINTN LoadOptionSize; - - UINT32 Attributes; - UINT16 FilePathListLength; - CHAR16 *Description; - EFI_DEVICE_PATH_PROTOCOL *FilePathList; - - VOID* OptionalData; - UINTN OptionalDataSize; -} BDS_LOAD_OPTION; - -/** - Connect a Device Path and return the handle of the driver that support this DevicePath - - @param DevicePath Device Path of the File to connect - @param Handle Handle of the driver that support this DevicePath - @param RemainingDevicePath Remaining DevicePath nodes that do not match the driver DevicePath - - @retval EFI_SUCCESS A driver that matches the Device Path has been found - @retval EFI_NOT_FOUND No handles match the search. - @retval EFI_INVALID_PARAMETER DevicePath or Handle is NULL - -**/ -EFI_STATUS -BdsConnectDevicePath ( - IN EFI_DEVICE_PATH_PROTOCOL* DevicePath, - OUT EFI_HANDLE *Handle, - OUT EFI_DEVICE_PATH_PROTOCOL **RemainingDevicePath - ); - -/** - Connect all DXE drivers - - @retval EFI_SUCCESS All drivers have been connected - @retval EFI_NOT_FOUND No handles match the search. - @retval EFI_OUT_OF_RESOURCES There is not resource pool memory to store the matching results. - -**/ -EFI_STATUS -BdsConnectAllDrivers ( - VOID - ); - -/** - Return the value of a global variable defined by its VariableName. - The variable must be defined with the VendorGuid gEfiGlobalVariableGuid. - - @param VariableName A Null-terminated string that is the name of the vendor's - variable. - @param DefaultValue Value returned by the function if the variable does not exist - @param DataSize On input, the size in bytes of the return Data buffer. - On output the size of data returned in Data. - @param Value Value read from the UEFI Variable or copy of the default value - if the UEFI Variable does not exist - - @retval EFI_SUCCESS All drivers have been connected - @retval EFI_NOT_FOUND No handles match the search. - @retval EFI_OUT_OF_RESOURCES There is not resource pool memory to store the matching results. - -**/ -EFI_STATUS -GetGlobalEnvironmentVariable ( - IN CONST CHAR16* VariableName, - IN VOID* DefaultValue, - IN OUT UINTN* Size, - OUT VOID** Value - ); - -/** - Return the value of the variable defined by its VariableName and VendorGuid - - @param VariableName A Null-terminated string that is the name of the vendor's - variable. - @param VendorGuid A unique identifier for the vendor. - @param DefaultValue Value returned by the function if the variable does not exist - @param DataSize On input, the size in bytes of the return Data buffer. - On output the size of data returned in Data. - @param Value Value read from the UEFI Variable or copy of the default value - if the UEFI Variable does not exist - - @retval EFI_SUCCESS All drivers have been connected - @retval EFI_NOT_FOUND No handles match the search. - @retval EFI_OUT_OF_RESOURCES There is not resource pool memory to store the matching results. - -**/ -EFI_STATUS -GetEnvironmentVariable ( - IN CONST CHAR16* VariableName, - IN EFI_GUID* VendorGuid, - IN VOID* DefaultValue, - IN OUT UINTN* Size, - OUT VOID** Value - ); - -EFI_STATUS -BootOptionFromLoadOptionIndex ( - IN UINT16 LoadOptionIndex, - OUT BDS_LOAD_OPTION** BdsLoadOption - ); - -EFI_STATUS -BootOptionFromLoadOptionVariable ( - IN CHAR16* BootVariableName, - OUT BDS_LOAD_OPTION** BdsLoadOption - ); - -EFI_STATUS -BootOptionToLoadOptionVariable ( - IN BDS_LOAD_OPTION* BdsLoadOption - ); - -UINT16 -BootOptionAllocateBootIndex ( - VOID - ); - -/** - Start an EFI Application from a Device Path - - @param ParentImageHandle Handle of the calling image - @param DevicePath Location of the EFI Application - - @retval EFI_SUCCESS All drivers have been connected - @retval EFI_NOT_FOUND The Linux kernel Device Path has not been found - @retval EFI_OUT_OF_RESOURCES There is not enough resource memory to store the matching results. - -**/ -EFI_STATUS -BdsStartEfiApplication ( - IN EFI_HANDLE ParentImageHandle, - IN EFI_DEVICE_PATH_PROTOCOL *DevicePath, - IN UINTN LoadOptionsSize, - IN VOID* LoadOptions - ); - EFI_STATUS BdsLoadImage ( IN EFI_DEVICE_PATH *DevicePath, @@ -167,46 +23,4 @@ BdsLoadImage ( OUT UINTN *FileSize ); -/** - * Call BS.ExitBootServices with the appropriate Memory Map information - */ -EFI_STATUS -ShutdownUefiBootServices ( - VOID - ); - -/** - Locate an EFI application in a the Firmware Volumes by its name - - @param EfiAppGuid Guid of the EFI Application into the Firmware Volume - @param DevicePath EFI Device Path of the EFI application - - @return EFI_SUCCESS The function completed successfully. - @return EFI_NOT_FOUND The protocol could not be located. - @return EFI_OUT_OF_RESOURCES There are not enough resources to find the protocol. - -**/ -EFI_STATUS -LocateEfiApplicationInFvByName ( - IN CONST CHAR16* EfiAppName, - OUT EFI_DEVICE_PATH **DevicePath - ); - -/** - Locate an EFI application in a the Firmware Volumes by its GUID - - @param EfiAppGuid Guid of the EFI Application into the Firmware Volume - @param DevicePath EFI Device Path of the EFI application - - @return EFI_SUCCESS The function completed successfully. - @return EFI_NOT_FOUND The protocol could not be located. - @return EFI_OUT_OF_RESOURCES There are not enough resources to find the protocol. - -**/ -EFI_STATUS -LocateEfiApplicationInFvByGuid ( - IN CONST EFI_GUID *EfiAppGuid, - OUT EFI_DEVICE_PATH **DevicePath - ); - #endif diff --git a/Platform/ARM/Library/BdsLib/BdsAppLoader.c b/Platform/ARM/Library/BdsLib/BdsAppLoader.c deleted file mode 100644 index 1f208f8dd796..000000000000 --- a/Platform/ARM/Library/BdsLib/BdsAppLoader.c +++ /dev/null @@ -1,253 +0,0 @@ -/** @file -* -* Copyright (c) 2011-2015, ARM Limited. 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. -* -**/ - -#include "BdsInternal.h" - -/** - Locate an EFI application in a the Firmware Volumes by its Name - - @param EfiAppGuid Guid of the EFI Application into the Firmware Volume - @param DevicePath EFI Device Path of the EFI application - - @return EFI_SUCCESS The function completed successfully. - @return EFI_NOT_FOUND The protocol could not be located. - @return EFI_OUT_OF_RESOURCES There are not enough resources to find the protocol. - -**/ -EFI_STATUS -LocateEfiApplicationInFvByName ( - IN CONST CHAR16* EfiAppName, - OUT EFI_DEVICE_PATH **DevicePath - ) -{ - VOID *Key; - EFI_STATUS Status, FileStatus; - EFI_GUID NameGuid; - EFI_FV_FILETYPE FileType; - EFI_FV_FILE_ATTRIBUTES Attributes; - UINTN Size; - UINTN UiStringLen; - CHAR16 *UiSection; - UINT32 Authentication; - EFI_DEVICE_PATH *FvDevicePath; - MEDIA_FW_VOL_FILEPATH_DEVICE_PATH FileDevicePath; - EFI_HANDLE *HandleBuffer; - UINTN NumberOfHandles; - UINTN Index; - EFI_FIRMWARE_VOLUME2_PROTOCOL *FvInstance; - - ASSERT (DevicePath != NULL); - - // Length of FilePath - UiStringLen = StrLen (EfiAppName); - - // Locate all the Firmware Volume protocols. - Status = gBS->LocateHandleBuffer ( - ByProtocol, - &gEfiFirmwareVolume2ProtocolGuid, - NULL, - &NumberOfHandles, - &HandleBuffer - ); - if (EFI_ERROR (Status)) { - return Status; - } - - *DevicePath = NULL; - - // Looking for FV with ACPI storage file - for (Index = 0; Index < NumberOfHandles; Index++) { - // - // Get the protocol on this handle - // This should not fail because of LocateHandleBuffer - // - Status = gBS->HandleProtocol ( - HandleBuffer[Index], - &gEfiFirmwareVolume2ProtocolGuid, - (VOID**) &FvInstance - ); - if (EFI_ERROR (Status)) { - goto FREE_HANDLE_BUFFER; - } - - // Allocate Key - Key = AllocatePool (FvInstance->KeySize); - ASSERT (Key != NULL); - ZeroMem (Key, FvInstance->KeySize); - - do { - // Search in all files - FileType = EFI_FV_FILETYPE_ALL; - - Status = FvInstance->GetNextFile (FvInstance, Key, &FileType, &NameGuid, &Attributes, &Size); - if (!EFI_ERROR (Status)) { - UiSection = NULL; - FileStatus = FvInstance->ReadSection ( - FvInstance, - &NameGuid, - EFI_SECTION_USER_INTERFACE, - 0, - (VOID **)&UiSection, - &Size, - &Authentication - ); - if (!EFI_ERROR (FileStatus)) { - if (StrnCmp (EfiAppName, UiSection, UiStringLen) == 0) { - // - // We found a UiString match. - // - Status = gBS->HandleProtocol (HandleBuffer[Index], &gEfiDevicePathProtocolGuid, (VOID **)&FvDevicePath); - - // Generate the Device Path for the file - EfiInitializeFwVolDevicepathNode (&FileDevicePath, &NameGuid); - *DevicePath = AppendDevicePathNode (FvDevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&FileDevicePath); - ASSERT (*DevicePath != NULL); - - FreePool (Key); - FreePool (UiSection); - FreePool (HandleBuffer); - return FileStatus; - } - FreePool (UiSection); - } - } - } while (!EFI_ERROR (Status)); - - FreePool (Key); - } - -FREE_HANDLE_BUFFER: - FreePool (HandleBuffer); - return EFI_NOT_FOUND; -} - -/** - Locate an EFI application in a the Firmware Volumes by its GUID - - @param EfiAppGuid Guid of the EFI Application into the Firmware Volume - @param DevicePath EFI Device Path of the EFI application - - @return EFI_SUCCESS The function completed successfully. - @return EFI_NOT_FOUND The protocol could not be located. - @return EFI_OUT_OF_RESOURCES There are not enough resources to find the protocol. - -**/ -EFI_STATUS -LocateEfiApplicationInFvByGuid ( - IN CONST EFI_GUID *EfiAppGuid, - OUT EFI_DEVICE_PATH **DevicePath - ) -{ - EFI_STATUS Status; - EFI_DEVICE_PATH *FvDevicePath; - EFI_HANDLE *HandleBuffer; - UINTN NumberOfHandles; - UINTN Index; - EFI_FIRMWARE_VOLUME2_PROTOCOL *FvInstance; - EFI_FV_FILE_ATTRIBUTES Attributes; - UINT32 AuthenticationStatus; - EFI_FV_FILETYPE Type; - UINTN Size; - CHAR16 *UiSection; - MEDIA_FW_VOL_FILEPATH_DEVICE_PATH FvFileDevicePath; - - ASSERT (DevicePath != NULL); - - // Locate all the Firmware Volume protocols. - Status = gBS->LocateHandleBuffer ( - ByProtocol, - &gEfiFirmwareVolume2ProtocolGuid, - NULL, - &NumberOfHandles, - &HandleBuffer - ); - if (EFI_ERROR (Status)) { - return Status; - } - - *DevicePath = NULL; - - // Looking for FV with ACPI storage file - for (Index = 0; Index < NumberOfHandles; Index++) { - // - // Get the protocol on this handle - // This should not fail because of LocateHandleBuffer - // - Status = gBS->HandleProtocol ( - HandleBuffer[Index], - &gEfiFirmwareVolume2ProtocolGuid, - (VOID**) &FvInstance - ); - if (EFI_ERROR (Status)) { - goto FREE_HANDLE_BUFFER; - } - - Status = FvInstance->ReadFile ( - FvInstance, - EfiAppGuid, - NULL, - &Size, - &Type, - &Attributes, - &AuthenticationStatus - ); - if (EFI_ERROR (Status)) { - // - // Skip if no EFI application file in the FV - // - continue; - } else { - UiSection = NULL; - Status = FvInstance->ReadSection ( - FvInstance, - EfiAppGuid, - EFI_SECTION_USER_INTERFACE, - 0, - (VOID **)&UiSection, - &Size, - &AuthenticationStatus - ); - if (!EFI_ERROR (Status)) { - // - // Create the EFI Device Path for the application using the Filename of the application - // - *DevicePath = FileDevicePath (HandleBuffer[Index], UiSection); - } else { - Status = gBS->HandleProtocol (HandleBuffer[Index], &gEfiDevicePathProtocolGuid, (VOID**)&FvDevicePath); - ASSERT_EFI_ERROR (Status); - - // - // Create the EFI Device Path for the application using the EFI GUID of the application - // - EfiInitializeFwVolDevicepathNode (&FvFileDevicePath, EfiAppGuid); - - *DevicePath = AppendDevicePathNode (FvDevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&FvFileDevicePath); - ASSERT (*DevicePath != NULL); - } - break; - } - } - -FREE_HANDLE_BUFFER: - // - // Free any allocated buffers - // - FreePool (HandleBuffer); - - if (*DevicePath == NULL) { - return EFI_NOT_FOUND; - } else { - return EFI_SUCCESS; - } -} diff --git a/Platform/ARM/Library/BdsLib/BdsFilePath.c b/Platform/ARM/Library/BdsLib/BdsFilePath.c index 7a4a5052a786..62f796e5526d 100644 --- a/Platform/ARM/Library/BdsLib/BdsFilePath.c +++ b/Platform/ARM/Library/BdsLib/BdsFilePath.c @@ -24,6 +24,9 @@ #include #include +#define IS_DEVICE_PATH_NODE(node,type,subtype) \ + (((node)->Type == (type)) && ((node)->SubType == (subtype))) + #define MAX_TFTP_FILE_SIZE 0x01000000 /* Type and defines to set up the DHCP4 options */ @@ -427,28 +430,6 @@ BdsConnectAndUpdateDevicePath ( return Status; } -/** - Connect a Device Path and return the handle of the driver that support this DevicePath - - @param DevicePath Device Path of the File to connect - @param Handle Handle of the driver that support this DevicePath - @param RemainingDevicePath Remaining DevicePath nodes that do not match the driver DevicePath - - @retval EFI_SUCCESS A driver that matches the Device Path has been found - @retval EFI_NOT_FOUND No handles match the search. - @retval EFI_INVALID_PARAMETER DevicePath or Handle is NULL - -**/ -EFI_STATUS -BdsConnectDevicePath ( - IN EFI_DEVICE_PATH_PROTOCOL* DevicePath, - OUT EFI_HANDLE *Handle, - OUT EFI_DEVICE_PATH_PROTOCOL **RemainingDevicePath - ) -{ - return BdsConnectAndUpdateDevicePath (&DevicePath, Handle, RemainingDevicePath); -} - BOOLEAN BdsFileSystemSupport ( IN EFI_DEVICE_PATH *DevicePath, @@ -1353,61 +1334,3 @@ BdsLoadImage ( { return BdsLoadImageAndUpdateDevicePath (&DevicePath, Type, Image, FileSize); } - -/** - Start an EFI Application from a Device Path - - @param ParentImageHandle Handle of the calling image - @param DevicePath Location of the EFI Application - - @retval EFI_SUCCESS All drivers have been connected - @retval EFI_NOT_FOUND The Linux kernel Device Path has not been found - @retval EFI_OUT_OF_RESOURCES There is not enough resource memory to store the matching results. - -**/ -EFI_STATUS -BdsStartEfiApplication ( - IN EFI_HANDLE ParentImageHandle, - IN EFI_DEVICE_PATH_PROTOCOL *DevicePath, - IN UINTN LoadOptionsSize, - IN VOID* LoadOptions - ) -{ - EFI_STATUS Status; - EFI_HANDLE ImageHandle; - EFI_PHYSICAL_ADDRESS BinaryBuffer; - UINTN BinarySize; - EFI_LOADED_IMAGE_PROTOCOL* LoadedImage; - - // Find the nearest supported file loader - Status = BdsLoadImageAndUpdateDevicePath (&DevicePath, AllocateAnyPages, &BinaryBuffer, &BinarySize); - if (EFI_ERROR (Status)) { - return Status; - } - - // Load the image from the Buffer with Boot Services function - Status = gBS->LoadImage (TRUE, ParentImageHandle, DevicePath, (VOID*)(UINTN)BinaryBuffer, BinarySize, &ImageHandle); - if (EFI_ERROR (Status)) { - return Status; - } - - // Passed LoadOptions to the EFI Application - if (LoadOptionsSize != 0) { - Status = gBS->HandleProtocol (ImageHandle, &gEfiLoadedImageProtocolGuid, (VOID **) &LoadedImage); - if (EFI_ERROR (Status)) { - return Status; - } - - LoadedImage->LoadOptionsSize = LoadOptionsSize; - LoadedImage->LoadOptions = LoadOptions; - } - - // Before calling the image, enable the Watchdog Timer for the 5 Minute period - gBS->SetWatchdogTimer (5 * 60, 0x0000, 0x00, NULL); - // Start the image - Status = gBS->StartImage (ImageHandle, NULL, NULL); - // Clear the Watchdog Timer after the image returns - gBS->SetWatchdogTimer (0x0000, 0x0000, 0x0000, NULL); - - return Status; -} diff --git a/Platform/ARM/Library/BdsLib/BdsHelper.c b/Platform/ARM/Library/BdsLib/BdsHelper.c index b10fe2074d53..de40fb5cf639 100644 --- a/Platform/ARM/Library/BdsLib/BdsHelper.c +++ b/Platform/ARM/Library/BdsLib/BdsHelper.c @@ -14,62 +14,6 @@ #include "BdsInternal.h" -EFI_STATUS -ShutdownUefiBootServices ( - VOID - ) -{ - EFI_STATUS Status; - UINTN MemoryMapSize; - EFI_MEMORY_DESCRIPTOR *MemoryMap; - UINTN MapKey; - UINTN DescriptorSize; - UINT32 DescriptorVersion; - UINTN Pages; - - MemoryMap = NULL; - MemoryMapSize = 0; - Pages = 0; - - do { - Status = gBS->GetMemoryMap ( - &MemoryMapSize, - MemoryMap, - &MapKey, - &DescriptorSize, - &DescriptorVersion - ); - if (Status == EFI_BUFFER_TOO_SMALL) { - - Pages = EFI_SIZE_TO_PAGES (MemoryMapSize) + 1; - MemoryMap = AllocatePages (Pages); - - // - // Get System MemoryMap - // - Status = gBS->GetMemoryMap ( - &MemoryMapSize, - MemoryMap, - &MapKey, - &DescriptorSize, - &DescriptorVersion - ); - } - - // Don't do anything between the GetMemoryMap() and ExitBootServices() - if (!EFI_ERROR(Status)) { - Status = gBS->ExitBootServices (gImageHandle, MapKey); - if (EFI_ERROR(Status)) { - FreePages (MemoryMap, Pages); - MemoryMap = NULL; - MemoryMapSize = 0; - } - } - } while (EFI_ERROR(Status)); - - return Status; -} - /** Connect all DXE drivers @@ -115,69 +59,3 @@ BdsConnectAllDrivers ( return EFI_SUCCESS; } - -EFI_STATUS -GetGlobalEnvironmentVariable ( - IN CONST CHAR16* VariableName, - IN VOID* DefaultValue, - IN OUT UINTN* Size, - OUT VOID** Value - ) -{ - return GetEnvironmentVariable (VariableName, &gEfiGlobalVariableGuid, - DefaultValue, Size, Value); -} - -EFI_STATUS -GetEnvironmentVariable ( - IN CONST CHAR16* VariableName, - IN EFI_GUID* VendorGuid, - IN VOID* DefaultValue, - IN OUT UINTN* Size, - OUT VOID** Value - ) -{ - EFI_STATUS Status; - UINTN VariableSize; - - // Try to get the variable size. - *Value = NULL; - VariableSize = 0; - Status = gRT->GetVariable ((CHAR16 *) VariableName, VendorGuid, NULL, &VariableSize, *Value); - if (Status == EFI_NOT_FOUND) { - if ((DefaultValue != NULL) && (Size != NULL) && (*Size != 0)) { - // If the environment variable does not exist yet then set it with the default value - Status = gRT->SetVariable ( - (CHAR16*)VariableName, - VendorGuid, - EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS, - *Size, - DefaultValue - ); - *Value = AllocateCopyPool (*Size, DefaultValue); - } else { - return EFI_NOT_FOUND; - } - } else if (Status == EFI_BUFFER_TOO_SMALL) { - // Get the environment variable value - *Value = AllocatePool (VariableSize); - if (*Value == NULL) { - return EFI_OUT_OF_RESOURCES; - } - - Status = gRT->GetVariable ((CHAR16 *)VariableName, VendorGuid, NULL, &VariableSize, *Value); - if (EFI_ERROR (Status)) { - FreePool(*Value); - return EFI_INVALID_PARAMETER; - } - - if (Size) { - *Size = VariableSize; - } - } else { - *Value = AllocateCopyPool (*Size, DefaultValue); - return Status; - } - - return EFI_SUCCESS; -} diff --git a/Platform/ARM/Library/BdsLib/BdsInternal.h b/Platform/ARM/Library/BdsLib/BdsInternal.h index bb4566e3a6c4..850618c624c5 100644 --- a/Platform/ARM/Library/BdsLib/BdsInternal.h +++ b/Platform/ARM/Library/BdsLib/BdsInternal.h @@ -99,12 +99,17 @@ typedef struct { UINT64 LastReportedNbOfBytes; } BDS_TFTP_CONTEXT; +/** + Connect all DXE drivers + + @retval EFI_SUCCESS All drivers have been connected + @retval EFI_NOT_FOUND No handles match the search. + @retval EFI_OUT_OF_RESOURCES There is not resource pool memory to store the matching results. + +**/ EFI_STATUS -BdsLoadImage ( - IN EFI_DEVICE_PATH *DevicePath, - IN EFI_ALLOCATE_TYPE Type, - IN OUT EFI_PHYSICAL_ADDRESS* Image, - OUT UINTN *FileSize +BdsConnectAllDrivers ( + VOID ); #endif diff --git a/Platform/ARM/Library/BdsLib/BdsLib.inf b/Platform/ARM/Library/BdsLib/BdsLib.inf index 637ef5a08128..7441fe539be1 100644 --- a/Platform/ARM/Library/BdsLib/BdsLib.inf +++ b/Platform/ARM/Library/BdsLib/BdsLib.inf @@ -22,9 +22,7 @@ [Sources.common] BdsFilePath.c - BdsAppLoader.c BdsHelper.c - BdsLoadOption.c [Packages] EmbeddedPkg/EmbeddedPkg.dec diff --git a/Platform/ARM/Library/BdsLib/BdsLoadOption.c b/Platform/ARM/Library/BdsLib/BdsLoadOption.c deleted file mode 100644 index 766a9890fc09..000000000000 --- a/Platform/ARM/Library/BdsLib/BdsLoadOption.c +++ /dev/null @@ -1,272 +0,0 @@ -/** @file -* -* Copyright (c) 2011-2013, ARM Limited. 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. -* -**/ - -#include "BdsInternal.h" - -EFI_STATUS -BootOptionParseLoadOption ( - IN EFI_LOAD_OPTION *EfiLoadOption, - IN UINTN EfiLoadOptionSize, - IN OUT BDS_LOAD_OPTION **BdsLoadOption - ) -{ - BDS_LOAD_OPTION *LoadOption; - UINTN DescriptionLength; - UINTN EfiLoadOptionPtr; - - if (EfiLoadOption == NULL) { - return EFI_INVALID_PARAMETER; - } - - if (EfiLoadOptionSize < sizeof(UINT32) + sizeof(UINT16) + sizeof(CHAR16) + sizeof(EFI_DEVICE_PATH_PROTOCOL)) { - return EFI_BAD_BUFFER_SIZE; - } - - if (*BdsLoadOption == NULL) { - LoadOption = (BDS_LOAD_OPTION*)AllocateZeroPool (sizeof(BDS_LOAD_OPTION)); - if (LoadOption == NULL) { - return EFI_OUT_OF_RESOURCES; - } - } else { - LoadOption = *BdsLoadOption; - } - - EfiLoadOptionPtr = (UINTN)EfiLoadOption; - LoadOption->LoadOption = EfiLoadOption; - LoadOption->LoadOptionSize = EfiLoadOptionSize; - - LoadOption->Attributes = *(UINT32*)EfiLoadOptionPtr; - LoadOption->FilePathListLength = *(UINT16*)(EfiLoadOptionPtr + sizeof(UINT32)); - LoadOption->Description = (CHAR16*)(EfiLoadOptionPtr + sizeof(UINT32) + sizeof(UINT16)); - DescriptionLength = StrSize (LoadOption->Description); - LoadOption->FilePathList = (EFI_DEVICE_PATH_PROTOCOL*)(EfiLoadOptionPtr + sizeof(UINT32) + sizeof(UINT16) + DescriptionLength); - - // If ((End of EfiLoadOptiony - Start of EfiLoadOption) == EfiLoadOptionSize) then No Optional Data - if ((UINTN)((UINTN)LoadOption->FilePathList + LoadOption->FilePathListLength - EfiLoadOptionPtr) == EfiLoadOptionSize) { - LoadOption->OptionalData = NULL; - LoadOption->OptionalDataSize = 0; - } else { - LoadOption->OptionalData = (VOID*)((UINTN)(LoadOption->FilePathList) + LoadOption->FilePathListLength); - LoadOption->OptionalDataSize = EfiLoadOptionSize - ((UINTN)LoadOption->OptionalData - EfiLoadOptionPtr); - } - - if (*BdsLoadOption == NULL) { - *BdsLoadOption = LoadOption; - } - - return EFI_SUCCESS; -} - -EFI_STATUS -BootOptionFromLoadOptionVariable ( - IN CHAR16* BootVariableName, - OUT BDS_LOAD_OPTION** BdsLoadOption - ) -{ - EFI_STATUS Status; - EFI_LOAD_OPTION *EfiLoadOption; - UINTN EfiLoadOptionSize; - - Status = GetGlobalEnvironmentVariable (BootVariableName, NULL, &EfiLoadOptionSize, (VOID**)&EfiLoadOption); - if (!EFI_ERROR(Status)) { - *BdsLoadOption = NULL; - Status = BootOptionParseLoadOption (EfiLoadOption, EfiLoadOptionSize, BdsLoadOption); - } - - return Status; -} - -EFI_STATUS -BootOptionFromLoadOptionIndex ( - IN UINT16 LoadOptionIndex, - OUT BDS_LOAD_OPTION **BdsLoadOption - ) -{ - CHAR16 BootVariableName[9]; - EFI_STATUS Status; - - UnicodeSPrint (BootVariableName, 9 * sizeof(CHAR16), L"Boot%04X", LoadOptionIndex); - - Status = BootOptionFromLoadOptionVariable (BootVariableName, BdsLoadOption); - if (!EFI_ERROR(Status)) { - (*BdsLoadOption)->LoadOptionIndex = LoadOptionIndex; - } - - return Status; -} - -EFI_STATUS -BootOptionToLoadOptionVariable ( - IN BDS_LOAD_OPTION* BdsLoadOption - ) -{ - EFI_STATUS Status; - UINTN DescriptionSize; - //UINT16 FilePathListLength; - EFI_DEVICE_PATH_PROTOCOL* DevicePathNode; - UINTN NodeLength; - UINT8* EfiLoadOptionPtr; - VOID* OldLoadOption; - CHAR16 BootVariableName[9]; - UINTN BootOrderSize; - UINT16* BootOrder; - - // If we are overwriting an existent Boot Option then we have to free previously allocated memory - if (BdsLoadOption->LoadOptionSize > 0) { - OldLoadOption = BdsLoadOption->LoadOption; - } else { - OldLoadOption = NULL; - - // If this function is called at the creation of the Boot Device entry (not at the update) the - // BootOption->LoadOptionSize must be zero then we get a new BootIndex for this entry - BdsLoadOption->LoadOptionIndex = BootOptionAllocateBootIndex (); - - //TODO: Add to the the Boot Entry List - } - - DescriptionSize = StrSize(BdsLoadOption->Description); - - // Ensure the FilePathListLength information is correct - ASSERT (GetDevicePathSize (BdsLoadOption->FilePathList) == BdsLoadOption->FilePathListLength); - - // Allocate the memory for the EFI Load Option - BdsLoadOption->LoadOptionSize = sizeof(UINT32) + sizeof(UINT16) + DescriptionSize + BdsLoadOption->FilePathListLength + BdsLoadOption->OptionalDataSize; - - BdsLoadOption->LoadOption = (EFI_LOAD_OPTION *)AllocateZeroPool (BdsLoadOption->LoadOptionSize); - if (BdsLoadOption->LoadOption == NULL) { - return EFI_OUT_OF_RESOURCES; - } - - EfiLoadOptionPtr = (UINT8 *) BdsLoadOption->LoadOption; - - // - // Populate the EFI Load Option and BDS Boot Option structures - // - - // Attributes fields - *(UINT32*)EfiLoadOptionPtr = BdsLoadOption->Attributes; - EfiLoadOptionPtr += sizeof(UINT32); - - // FilePath List fields - *(UINT16*)EfiLoadOptionPtr = BdsLoadOption->FilePathListLength; - EfiLoadOptionPtr += sizeof(UINT16); - - // Boot description fields - CopyMem (EfiLoadOptionPtr, BdsLoadOption->Description, DescriptionSize); - EfiLoadOptionPtr += DescriptionSize; - - // File path fields - DevicePathNode = BdsLoadOption->FilePathList; - while (!IsDevicePathEndType (DevicePathNode)) { - NodeLength = DevicePathNodeLength(DevicePathNode); - CopyMem (EfiLoadOptionPtr, DevicePathNode, NodeLength); - EfiLoadOptionPtr += NodeLength; - DevicePathNode = NextDevicePathNode (DevicePathNode); - } - - // Set the End Device Path Type - SetDevicePathEndNode (EfiLoadOptionPtr); - EfiLoadOptionPtr += sizeof(EFI_DEVICE_PATH); - - // Fill the Optional Data - if (BdsLoadOption->OptionalDataSize > 0) { - CopyMem (EfiLoadOptionPtr, BdsLoadOption->OptionalData, BdsLoadOption->OptionalDataSize); - } - - // Case where the fields have been updated - if (OldLoadOption) { - // Now, the old data has been copied to the new allocated packed structure, we need to update the pointers of BdsLoadOption - BootOptionParseLoadOption (BdsLoadOption->LoadOption, BdsLoadOption->LoadOptionSize, &BdsLoadOption); - // Free the old packed structure - FreePool (OldLoadOption); - } - - // Create/Update Boot#### environment variable - UnicodeSPrint (BootVariableName, 9 * sizeof(CHAR16), L"Boot%04X", BdsLoadOption->LoadOptionIndex); - Status = gRT->SetVariable ( - BootVariableName, - &gEfiGlobalVariableGuid, - EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS, - BdsLoadOption->LoadOptionSize, - BdsLoadOption->LoadOption - ); - - // When it is a new entry we must add the entry to the BootOrder - if (OldLoadOption == NULL) { - // Add the new Boot Index to the list - Status = GetGlobalEnvironmentVariable (L"BootOrder", NULL, &BootOrderSize, (VOID**)&BootOrder); - if (!EFI_ERROR(Status)) { - BootOrder = ReallocatePool (BootOrderSize, BootOrderSize + sizeof(UINT16), BootOrder); - // Add the new index at the end - BootOrder[BootOrderSize / sizeof(UINT16)] = BdsLoadOption->LoadOptionIndex; - BootOrderSize += sizeof(UINT16); - } else { - // BootOrder does not exist. Create it - BootOrderSize = sizeof(UINT16); - BootOrder = &(BdsLoadOption->LoadOptionIndex); - } - - // Update (or Create) the BootOrder environment variable - gRT->SetVariable ( - L"BootOrder", - &gEfiGlobalVariableGuid, - EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS, - BootOrderSize, - BootOrder - ); - DEBUG((EFI_D_ERROR,"Create %s\n",BootVariableName)); - - // Free memory allocated by GetGlobalEnvironmentVariable - if (!EFI_ERROR(Status)) { - FreePool (BootOrder); - } - } else { - DEBUG((EFI_D_ERROR,"Update %s\n",BootVariableName)); - } - - return EFI_SUCCESS; -} - -UINT16 -BootOptionAllocateBootIndex ( - VOID - ) -{ - EFI_STATUS Status; - UINTN Index; - UINT32 BootIndex; - UINT16 *BootOrder; - UINTN BootOrderSize; - BOOLEAN Found; - - // Get the Boot Option Order from the environment variable - Status = GetGlobalEnvironmentVariable (L"BootOrder", NULL, &BootOrderSize, (VOID**)&BootOrder); - if (!EFI_ERROR(Status)) { - for (BootIndex = 0; BootIndex <= 0xFFFF; BootIndex++) { - Found = FALSE; - for (Index = 0; Index < BootOrderSize / sizeof (UINT16); Index++) { - if (BootOrder[Index] == BootIndex) { - Found = TRUE; - break; - } - } - if (!Found) { - return BootIndex; - } - } - FreePool (BootOrder); - } - // Return the first index - return 0; -} From patchwork Fri Nov 23 08:44:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 151849 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp1799795ljp; Fri, 23 Nov 2018 00:46:16 -0800 (PST) X-Google-Smtp-Source: AFSGD/XpztX5hqrdzWIN5W/mbPgp8Njnq1isZ+GzxIUNGfRrib2Rf4skbeJkfyoFBMya4hA5n3Iv X-Received: by 2002:a05:660c:648:: with SMTP id y8mr2548895itk.48.1542962775968; Fri, 23 Nov 2018 00:46:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542962775; cv=none; d=google.com; s=arc-20160816; b=m+tYkeo9dZfWJQ5Orh8kFLAdnPWcuVZKRmJPV4qn9ReFHvF5+3sFyh9UrpGWEp5dIc b56YdX6s0xdIkYPwpMfL4BtyLSeTa+4OGGfgN+nnMyN3q6vjGwTawS4o8VEe2514dWFR 0eq8y7p74dDHPwZJiaVVsfpVpCoQSWhBNGyiJGP0x7/IMZNhxlv4He+fxpwj0t7BmJ12 Smn3duQH8dxXVc67SZEPmLMUnABhqpCxbllTPErYxWhcgQo6AYgyfcYmPA46JxUsbyQm 5ImxxLVxdqZ53tB0lcotkg7zACaEFov6eNIJwZrL6hiQjYkih5bYOF+9uoEc9d7xzYRQ YDJg== 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; bh=a+oJUUGF6RGQapbSlaaGTXNWIWL5lBV740bYAy0ekAg=; b=OIpfVgLBHFcK550EgMsCFZxoEDXF6hw/VvrFJiUeEYNyA2L+8b5jLhyVkVCj2YLbQx bhLIKhB4eClp+E9HPMb1AnYxLlcZ6rQQe3xed2KcKHwUEEOV3UVZxh0D8BdRqnshRPDj 2NTHv3tebKMOWjLSgEW6xn04AnoRSqONP2/W1EgJpzyWwM/VeMh62N9gN5Zik0AwS53F KbyGaITbHKO1U+hdnBelhdeWdI0twAcKimuO0m4eorHpYoibd4aE/4nx76+7IIenkkPj KaQXJLfIxvdMfT/3dyycVFJwN5NUWihwtT6p5QpLQUPgVEx3xASMqxVCxnrY6IKPgi6B s2Pg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=aI8d3g3d; 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 t1si4670232itf.51.2018.11.23.00.46.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 23 Nov 2018 00:46:15 -0800 (PST) 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=aI8d3g3d; 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 7A0F821CB74A4; Fri, 23 Nov 2018 00:46:04 -0800 (PST) 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=2a00:1450:4864:20::442; helo=mail-wr1-x442.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wr1-x442.google.com (mail-wr1-x442.google.com [IPv6:2a00:1450:4864:20::442]) (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 9592D21B02822 for ; Fri, 23 Nov 2018 00:44:15 -0800 (PST) Received: by mail-wr1-x442.google.com with SMTP id 96so11520172wrb.2 for ; Fri, 23 Nov 2018 00:44:15 -0800 (PST) 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=Bb0R1IDjBPOBtw/Ni+Lped4iTM7acK5mOh+cMkl4yxk=; b=aI8d3g3d5KNgwEmiy2rB5c213VvW0feiH2G76snXI9wl9YXXUazmLrQjYPgCPBPnnu lWnupMzd7uYC19K3H1SXsdOb2P15aBLUL/UVg36GwpETXfwXnqoyKyZ6o4z03q4BJae4 l156y53w3cjuFAOXsXYiYb4MQu0a0+d+oKAXI= 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=Bb0R1IDjBPOBtw/Ni+Lped4iTM7acK5mOh+cMkl4yxk=; b=eraRl97vepgE1hjYHx8voJmz8hjkyc/Gt5YvYiy0YWyheu58oSTNzW2Lsh//Sk3+wU ZeJHY8F5SiKwez1+loWsAEMnCgve6Q97A8CitwH8yvMJOLDhWvXLD5RTzPu9gYHzxMcE 1KemUWuqWGeCqbuM/2qdklMqM62aqshDbh+/C7vEs2Jw+yriGstansR8X6dc3mCyrklu rd0Fefc6IyHECNtDk4pMEwho8YGGvkbqKFbVs5ws5erchjvkmeI+cP8jTAuJYL4UqowT C8990KuMsoXnMym0njlx91Sp7o+IniF4QUgUdkcQRd23DhoL0un9Fv6E2cmLtGnrxiz5 hOpA== X-Gm-Message-State: AA+aEWbHkVlwS14/k1yxWHwBraGmRgXgIGQOoGKmNpJWQayQqTXW4ew2 aeNxvoxwTLPzK+uEqlerzK14qfv5IKcluQ== X-Received: by 2002:adf:b201:: with SMTP id u1mr4778170wra.165.1542962653711; Fri, 23 Nov 2018 00:44:13 -0800 (PST) Received: from mba13.wifi.ns.nl (33.153.69.91.rev.sfr.net. [91.69.153.33]) by smtp.gmail.com with ESMTPSA id c8sm807377wrx.42.2018.11.23.00.44.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 23 Nov 2018 00:44:12 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.01.org Date: Fri, 23 Nov 2018 09:44:06 +0100 Message-Id: <20181123084406.27192-4-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181123084406.27192-1-ard.biesheuvel@linaro.org> References: <20181123084406.27192-1-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH v2 edk2-platforms 3/3] Platform/ARM/BdsLib: maintain alignment for DevicePaths X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lersek@redhat.com, nariman.poushin@linaro.org MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" DevicePath node types may have any size, and so it is up to the code that manipulates them to ensure that dereferencing them only occurs when the pointer is aligned explicitly. Since BdsConnectAndUpdateDevicePath() has only two callers, one of which itself, we can simply duplicate the device path (similar to how DxeCore's CoreConnectController () does it), and free the pool allocation again on the way out. (Note that the allocation only occurs when the non-recursive path is taken and the function returns EFI_SUCCESS) Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel --- Platform/ARM/Library/BdsLib/BdsFilePath.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) -- 2.17.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel Reviewed-by: Laszlo Ersek diff --git a/Platform/ARM/Library/BdsLib/BdsFilePath.c b/Platform/ARM/Library/BdsLib/BdsFilePath.c index 62f796e5526d..ad66b2f82718 100644 --- a/Platform/ARM/Library/BdsLib/BdsFilePath.c +++ b/Platform/ARM/Library/BdsLib/BdsFilePath.c @@ -423,8 +423,8 @@ BdsConnectAndUpdateDevicePath ( } } - if (RemainingDevicePath) { - *RemainingDevicePath = Remaining; + if (!EFI_ERROR (Status) && RemainingDevicePath != NULL) { + *RemainingDevicePath = DuplicateDevicePath (Remaining); } return Status; @@ -1314,14 +1314,18 @@ BdsLoadImageAndUpdateDevicePath ( } FileLoader = FileLoaders; + Status = EFI_UNSUPPORTED; while (FileLoader->Support != NULL) { if (FileLoader->Support (*DevicePath, Handle, RemainingDevicePath)) { - return FileLoader->LoadImage (DevicePath, Handle, RemainingDevicePath, Type, Image, FileSize); + Status = FileLoader->LoadImage (DevicePath, Handle, RemainingDevicePath, + Type, Image, FileSize); + break; } FileLoader++; } - return EFI_UNSUPPORTED; + FreePool (RemainingDevicePath); + return Status; } EFI_STATUS