From patchwork Thu Oct 26 05:30:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 738320 Delivered-To: patch@linaro.org Received: by 2002:adf:f842:0:b0:32d:baff:b0ca with SMTP id d2csp638451wrq; Wed, 25 Oct 2023 22:31:56 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH0a/lG8Uu+LdmuB3MQVBDedJX+fHtH9dwLgO4zo21/TTCQr9UUumW9XE1cOC5AWNUHc4GK X-Received: by 2002:a5d:67d2:0:b0:32d:90e6:c477 with SMTP id n18-20020a5d67d2000000b0032d90e6c477mr6569147wrw.26.1698298316606; Wed, 25 Oct 2023 22:31:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698298316; cv=none; d=google.com; s=arc-20160816; b=e3kAX58WLQlAv5MkHgFwXHp7YCT4qFZjgPVp+1r4PGQNk73wlt8HGfkyL4GKWUjcVI ZLqWq8lTfoTYiPp0Z/mQ1m6/YgPZCH5nxrGxw8XD5GQNe4nlozvD0qYrUZ1K4bx843dF aipLmkkpyb7IiCw7o84kdjGONbsQvAgKYojXkWZK4tFrZ33+TpF/S9iG/rZ1jIy7+kBx UjimntkAFh2JY5LoNBZPcIhlaI84z7nUdS6yYc1QObRqgh5dH0P2FdqOpp4VwgFeU1Ci saKgHa3utF3vZUTp3J+VApXp/zDScF320SPlUOIRRLbh4vQPX2zNSsMHwjqmN9k2zXLa SKwg== 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=cJUUfPbIuNsqhILYNiWpep1gG/D41daasmggqowkL8Y=; fh=RsKNQde3hXRhkFNkXZDJxhxJUE2DI5qQDMHikPj4pmY=; b=kq151+az/MFDqfl4J/WmYreyth8JUMzN5zCzYCBkXGtsgAmNKam5RYe3HpoZJrv63p anEY6ZKTNdvM1hmeqWHIcgw2v1szlqFR2bus3I1aLcx+wPSq4x/N7y1jM/qddNU+UIx1 IAO1YiF0tavLu9UgvRdPmpQVdxwDjd0LysTbTqAKggJlk+N9Fn+MaiSE3gcTkMSGfjqT qsgOtGFs4oDelwVJVAuqdUhO+dDiD8uprjg6afzQCJ8QEM5/x6+0VlcKnnDb3QWgSrh4 iDNaPkz9WxiaUsB38KETEynQqC4OrwH3J4vUVl5JshkV1NH+81Gnx+My3mPb6a+239ik +v5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=T5y4xP9j; 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 u2-20020a5d4682000000b00327174cf8b3si8536279wrq.311.2023.10.25.22.31.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Oct 2023 22:31:56 -0700 (PDT) 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=T5y4xP9j; 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 AF05E87B1B; Thu, 26 Oct 2023 07:31:37 +0200 (CEST) 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="T5y4xP9j"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C5A0787B0F; Thu, 26 Oct 2023 07:31:36 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pg1-x530.google.com (mail-pg1-x530.google.com [IPv6:2607:f8b0:4864:20::530]) (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 9EAF88755E for ; Thu, 26 Oct 2023 07:31:27 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=takahiro.akashi@linaro.org Received: by mail-pg1-x530.google.com with SMTP id 41be03b00d2f7-51f64817809so54527a12.1 for ; Wed, 25 Oct 2023 22:31:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1698298286; x=1698903086; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=cJUUfPbIuNsqhILYNiWpep1gG/D41daasmggqowkL8Y=; b=T5y4xP9jE35M6zl5gBWUF5V5it0i43SkrXB7VgTVZUJObmjs2YF1fcdL1T4LwWNtVm AEEekA+XdMlYVsDmPIYdJBlQi5X8U1nGsrKvfQ0QkZoLp52IB+S7EV0LP3M3HdWJm2Ir G6sRys4CU1fTtnYcrFggWVFRhbDpFb4siKHlk+LaxMKCf0S7WfpKQBZt4SUB2kj9PPF1 TzBAOn5iwI8hqlGSCIJgI6UcJHrqejt8oen76XB8SU/5KqoBjxg5zAlGZYpmuQklOshg prj5z09vXTB1IClHtKqf3w3Htf5G0Tb72p1jhQobVFQP8MC9LgVkMnvMJ8GOjABHK6K8 lU4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698298286; x=1698903086; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=cJUUfPbIuNsqhILYNiWpep1gG/D41daasmggqowkL8Y=; b=wRdmelLankFAeVsBEYaQuNM/Jyci8xNvv2524W2bIMqdVHac/CRLmO45hLB2Mrstqx 3ysnD2myoBS3eJNtmzm/PijG6g1cmXQKawJMNM3Ju6ayOTDOFzyduNn8l13VZS9Wmb/4 cfhDCNTQkON5aV1Kpvvmotf+XRMoPYbKxA/8dmofAzeyDciQARETQR7rxhUFdIiO2M4Y zjOL37yfw4IRh0Um4Tead+BRhQ5JWGmh48WlslOtAMMUIRPU1zdA5cpn6/ctQYcAocCZ MaUKnN6VQARGa4VxpdRZJowH5kmE9d52Af0SPcXHixLcjkmTkumjWV9EuYONhf0mimUl 107w== X-Gm-Message-State: AOJu0YyotXgS+cvQTv4VB2DY0cB4MHGb+d653dXudJ4sEV+6Upy3gWSk PaKpbz82IImt8dF2bqU9ZGYmkQ== X-Received: by 2002:a05:6a00:3a0a:b0:690:d0d4:6fb0 with SMTP id fj10-20020a056a003a0a00b00690d0d46fb0mr17678650pfb.3.1698298285885; Wed, 25 Oct 2023 22:31:25 -0700 (PDT) Received: from octopus.. ([2400:4050:c3e1:100:bca9:3af7:89e9:80b7]) by smtp.gmail.com with ESMTPSA id fa13-20020a056a002d0d00b006c06804cd39sm440715pfb.153.2023.10.25.22.31.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Oct 2023 22:31:25 -0700 (PDT) From: AKASHI Takahiro To: trini@konsulko.com, sjg@chromium.org, xypron.glpk@gmx.de, ilias.apalodimas@linaro.org Cc: jbx6244@gmail.com, u-boot@lists.denx.de, AKASHI Takahiro Subject: [RFC 03/13] cmd: bootefi: carve out EFI boot manager interface Date: Thu, 26 Oct 2023 14:30:42 +0900 Message-Id: <20231026053052.622453-4-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231026053052.622453-1-takahiro.akashi@linaro.org> References: <20231026053052.622453-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.103.8 at phobos.denx.de X-Virus-Status: Clean Carve EFI boot manager related code out of do_bootefi_image(). Signed-off-by: AKASHI Takahiro --- cmd/bootefi.c | 43 ++++++++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 19 deletions(-) diff --git a/cmd/bootefi.c b/cmd/bootefi.c index ae00bba3b4f0..899ed90f6817 100644 --- a/cmd/bootefi.c +++ b/cmd/bootefi.c @@ -401,28 +401,40 @@ out: } /** - * do_efibootmgr() - execute EFI boot manager + * efi_bootmgr_run() - execute EFI boot manager + * fdt: Flat device tree + * + * Invoke EFI boot manager and execute a binary depending on + * boot options. If @fdt is not NULL, it will be passed to + * the executed binary. * * Return: status code */ -static int do_efibootmgr(void) +static efi_status_t efi_bootmgr_run(void *fdt) { efi_handle_t handle; - efi_status_t ret; void *load_options; + efi_status_t ret; - ret = efi_bootmgr_load(&handle, &load_options); + /* Initialize EFI drivers */ + ret = efi_init_obj_list(); if (ret != EFI_SUCCESS) { - log_notice("EFI boot manager: Cannot load any image\n"); + log_err("Error: Cannot initialize UEFI sub-system, r = %lu\n", + ret & ~EFI_ERROR_MASK); return CMD_RET_FAILURE; } - ret = do_bootefi_exec(handle, load_options); - + ret = efi_install_fdt(fdt); if (ret != EFI_SUCCESS) - return CMD_RET_FAILURE; + return ret; - return CMD_RET_SUCCESS; + ret = efi_bootmgr_load(&handle, &load_options); + if (ret != EFI_SUCCESS) { + log_notice("EFI boot manager: Cannot load any image\n"); + return ret; + } + + return do_bootefi_exec(handle, load_options); } /** @@ -612,21 +624,14 @@ static int do_bootefi(struct cmd_tbl *cmdtp, int flag, int argc, if (IS_ENABLED(CONFIG_CMD_BOOTEFI_BOOTMGR) && !strcmp(argv[1], "bootmgr")) { - /* Initialize EFI drivers */ - ret = efi_init_obj_list(); - if (ret != EFI_SUCCESS) { - log_err("Error: Cannot initialize UEFI sub-system, r = %lu\n", - ret & ~EFI_ERROR_MASK); - return CMD_RET_FAILURE; - } + ret = efi_bootmgr_run(fdt); - ret = efi_install_fdt(fdt); if (ret == EFI_INVALID_PARAMETER) return CMD_RET_USAGE; - else if (ret != EFI_SUCCESS) + else if (ret) return CMD_RET_FAILURE; - return do_efibootmgr(); + return CMD_RET_SUCCESS; } if (IS_ENABLED(CONFIG_CMD_BOOTEFI_SELFTEST) &&