From patchwork Wed Dec 30 15:07:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilias Apalodimas X-Patchwork-Id: 355275 Delivered-To: patch@linaro.org Received: by 2002:a02:85a7:0:0:0:0:0 with SMTP id d36csp11403875jai; Wed, 30 Dec 2020 07:08:39 -0800 (PST) X-Google-Smtp-Source: ABdhPJyCTrUtUveVsogrn3kVkWit3uy3RxTWjp4fBGoiFFFL0pfyOhfAjmFdGB7a8cDqFgZk7Rs9 X-Received: by 2002:a17:907:20cc:: with SMTP id qq12mr52175706ejb.316.1609340918969; Wed, 30 Dec 2020 07:08:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609340918; cv=none; d=google.com; s=arc-20160816; b=ODRGzRKbwq8bAYZnONX245uQTgNPqZO4Fb9xmMu6zQaI7S5QFyd7TcZjrD8U2W59NO M5Q5j/z+rSZ1kf6+DMXfIz7Y34+lX6BHGbqgYJaqh0oUC4IAXOQr0iwqwLO99bclbNLC muLDVFzv4EM+ZObvz8UsxZAAko25kEBH7XZeEfsRx4nsZ3kd3G+UHI8z6GaG7uojj67/ FLHdETuovQAQu3GwSDs/HuV5isyEc0xJNkxUTcwenpFZkBqdaEZxxn27Gj86JZ5BxUZV IARoXMsO9pTKDDBbFb10YO/RTSIJviYQD7w0EBj4DCl3gCcLrJSBR/voQfyNe1HoAO6q pwJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=XbvGNj9JiPMOw6hIAfTTsU/7r+RZQTIgZIIQru7dizA=; b=x0o5P306hNhZQsLl86u77+tSpO7CL23Y5WtxbA3OSCQ5SmRZAi+6HZfMx03I9vJdK+ SdgDWWmTaJYMHbYTm6GH2/83PVmgctR5bSmqkFj+0V0tfKqlQYjx4pcdkJ3f9pcJ5y0m TlAL68HRlJ5uTvDOoQrC7v34srAYX64Jh+Wz4FeJu7HNqpD+JkNhZaxlpqMnHzrbsopX Eoc1cjfsTttkkyFcR0cKzDuF7YU+41BTqD1b8qcFxLBsaL7unsGMgPgMcchzeBG0SXtn RwObiGTNiXy0/QgUjqa46crfE0HbGfWfFdCXOVocaoj1ffwfGw6Th2mX4onswPBWKIpm 0EYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=xKZakAaR; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id 30si24001144edv.385.2020.12.30.07.08.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Dec 2020 07:08:38 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=xKZakAaR; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 65EA98263F; Wed, 30 Dec 2020 16:08:04 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="xKZakAaR"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 38CB882625; Wed, 30 Dec 2020 16:07:47 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 06CE182608 for ; Wed, 30 Dec 2020 16:07:41 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=ilias.apalodimas@linaro.org Received: by mail-wm1-x32a.google.com with SMTP id e25so4965517wme.0 for ; Wed, 30 Dec 2020 07:07:41 -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 :mime-version:content-transfer-encoding; bh=XbvGNj9JiPMOw6hIAfTTsU/7r+RZQTIgZIIQru7dizA=; b=xKZakAaRgD/julKobcTaFDSk6sMx8dAFOSQDv/B/yowtTVeecAeJ/4Nyeu2saIA3Zb AsLQjUrB6q9LiB7ZRzVJsqfOQnaMW6N3YR4vlGfPHTmCyGivok6CIEZ9gLXa5jWFT46S KdexshYM8u+fC5z5KhedRI48BfkEgjAzTgiunvAAFTW0ZECdPzI4YYDpBx10Wg9pmLmO Qm3m8Gc/ymkldb40ICFT5PKwz73cjK4pmsFEMiYxBm9G7cCNbhhagjEY/WTDXIv89lxg FMLoayqWoIVfReY4uJA9v8YBnKO7UT9LPjXSrvRc4KIzJNbFI388srXKPwOL0465SgKd IYWQ== 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:mime-version:content-transfer-encoding; bh=XbvGNj9JiPMOw6hIAfTTsU/7r+RZQTIgZIIQru7dizA=; b=FuEcSZum6g5boZrLSeK6cWdPv2PXDIvfdICnDIGboDq3xMItDRcCMYPYqWZUQ2kQQe ez8aV6zQMXhOO1iqd9BZ3DKTBHjGgkCsBumqdrfLeLB7gJ2B4Asme3u+RvrmG+wBpNbD 5REGt+pYVsgsPOuGhCSlbzIqHmzjw7ChE9/d5lhPC0M2kgLvdnY3k3yr6dPOtJ8qRG6T 4z4XJc8sQUsoWjtuHCosbZtNxNjLH3xCj8qe7g+g5EoCwd8QCNHylMwql5vv0cfAEj/n v00wSwFlrgYRkONbL4gbDpS01ZPvI3gMSs+JqTu+7zV8Dv38FAYgl8ygS0aVm/QL16cz uWZA== X-Gm-Message-State: AOAM531S7LRmPUxbhBJz3lQoziLeDrV9RsN2Us6gADrk8G0pCX/FzEDg 8p+z4W99iiHWLs8rinpIULCTtg== X-Received: by 2002:a7b:c8da:: with SMTP id f26mr8066334wml.50.1609340860673; Wed, 30 Dec 2020 07:07:40 -0800 (PST) Received: from localhost.localdomain (athedsl-4484548.home.otenet.gr. [94.71.57.204]) by smtp.gmail.com with ESMTPSA id k10sm62062721wrq.38.2020.12.30.07.07.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Dec 2020 07:07:40 -0800 (PST) From: Ilias Apalodimas To: xypron.glpk@gmx.de Cc: takahiro.akashi@linaro.org, ard.biesheuvel@arm.com, Ilias Apalodimas , Alexander Graf , u-boot@lists.denx.de Subject: [PATCH 5/8 v2] efi_loader: bootmgr: Use get_var from efi_helper file Date: Wed, 30 Dec 2020 17:07:17 +0200 Message-Id: <20201230150722.154663-6-ilias.apalodimas@linaro.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20201230150722.154663-1-ilias.apalodimas@linaro.org> References: <20201230150722.154663-1-ilias.apalodimas@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.3 at phobos.denx.de X-Virus-Status: Clean A few patches before we introduced a file which includes the get_var_efi() function defined in the efi bootmanager. So let's replace it here and use the common function as much as we can. Signed-off-by: Ilias Apalodimas --- lib/efi_loader/Makefile | 2 +- lib/efi_loader/efi_bootmgr.c | 37 +++--------------------------------- 2 files changed, 4 insertions(+), 35 deletions(-) -- 2.30.0 diff --git a/lib/efi_loader/Makefile b/lib/efi_loader/Makefile index cd4b252a417c..a47160189c42 100644 --- a/lib/efi_loader/Makefile +++ b/lib/efi_loader/Makefile @@ -21,7 +21,7 @@ targets += helloworld.o endif obj-$(CONFIG_CMD_BOOTEFI_HELLO) += helloworld_efi.o -obj-y += efi_bootmgr.o +obj-y += efi_helper.o efi_bootmgr.o obj-y += efi_boottime.o obj-y += efi_console.o obj-y += efi_device_path.o diff --git a/lib/efi_loader/efi_bootmgr.c b/lib/efi_loader/efi_bootmgr.c index 61dc72a23da8..0221fd1261b3 100644 --- a/lib/efi_loader/efi_bootmgr.c +++ b/lib/efi_loader/efi_bootmgr.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -165,38 +166,6 @@ unsigned long efi_serialize_load_option(struct efi_load_option *lo, u8 **data) return size; } -/** - * get_var() - get UEFI variable - * - * It is the caller's duty to free the returned buffer. - * - * @name: name of variable - * @vendor: vendor GUID of variable - * @size: size of allocated buffer - * Return: buffer with variable data or NULL - */ -static void *get_var(u16 *name, const efi_guid_t *vendor, - efi_uintn_t *size) -{ - efi_status_t ret; - void *buf = NULL; - - *size = 0; - ret = efi_get_variable_int(name, vendor, NULL, size, buf, NULL); - if (ret == EFI_BUFFER_TOO_SMALL) { - buf = malloc(*size); - ret = efi_get_variable_int(name, vendor, NULL, size, buf, NULL); - } - - if (ret != EFI_SUCCESS) { - free(buf); - *size = 0; - return NULL; - } - - return buf; -} - /** * try_load_entry() - try to load image for boot option * @@ -224,7 +193,7 @@ static efi_status_t try_load_entry(u16 n, efi_handle_t *handle, varname[6] = hexmap[(n & 0x00f0) >> 4]; varname[7] = hexmap[(n & 0x000f) >> 0]; - load_option = get_var(varname, &efi_global_variable_guid, &size); + load_option = get_var_efi(varname, &efi_global_variable_guid, &size); if (!load_option) return EFI_LOAD_ERROR; @@ -336,7 +305,7 @@ efi_status_t efi_bootmgr_load(efi_handle_t *handle, void **load_options) } /* BootOrder */ - bootorder = get_var(L"BootOrder", &efi_global_variable_guid, &size); + bootorder = get_var_efi(L"BootOrder", &efi_global_variable_guid, &size); if (!bootorder) { log_info("BootOrder not defined\n"); ret = EFI_NOT_FOUND;