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; -}