From patchwork Tue Nov 21 01:29:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 745671 Delivered-To: patch@linaro.org Received: by 2002:a5d:5052:0:b0:32d:baff:b0ca with SMTP id h18csp1628196wrt; Mon, 20 Nov 2023 17:32:39 -0800 (PST) X-Google-Smtp-Source: AGHT+IFJbaVyPMFxKHE/PBKtWnv6gXRF3dI7KPedB5tvUp8ILmEprqfCrF5JGmtCB265OV+B5upY X-Received: by 2002:a19:c511:0:b0:50a:a31e:55eb with SMTP id w17-20020a19c511000000b0050aa31e55ebmr6061429lfe.37.1700530359680; Mon, 20 Nov 2023 17:32:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700530359; cv=none; d=google.com; s=arc-20160816; b=oAWvEhUqDQNWwPYcduAiCjauxfb1IqUvnwIcRWTXBZ2qLhVb23GQdfw4SznRQx4TPF gk4VZj1/PCihTcVzM6jMHresyvhFpJsdB8aWMf9I1PsLAlcXh9QQNwv6rSndpUFzx74g bdNUKuDhbMpHklQD1q8EsueY3D+Z83/JuNdQuXp1vXH9PS6raIem1T6OBxYr6OsnPYCU 74Nse1bi3hXNjIdV6srm5MDaSjYKnRNvG/41Kx5bkS6H5cNtYp/o3JmPqg6+0JzYkuYu QBvohNEZD1xlSXN9cnC1Axjl9Zcd8Ns5mlE0bKPZPFWwA7OFxylDjgQ3x88a1he1bccv 42yA== 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=Azv2jiokxdDjjZVQpsj4tHdv10eu4UK1JN/knIvXPu4=; fh=p8OTi/tJSbfUA0ykVxDxRCnpqUhQqJazFYHXT9edm5U=; b=Xzg2xdnoa9oIw/uXxo3z63ctXHHD5MG2o1WYblSnDFnlC9gS5n3q3eF9rzbkhWxGB8 3BeM/DytMrCR7LricwqfZvPJvK117IjkT4vkTDock8YvvxhCvzdfj0JC6LlvkD3gadRA 086Do2pYZECSg0i8u7yPJ3rTwTfi0aTfdB1GFxNpnHOilOK7uNLqLM2gDzJWHeytN1rf ervWydrExOkWJkHMHsfz8yPx7F7I0V1EHRSqJgUBj9DFbRLIzL9HoydutfPr2lcb/p7y zdMeyHrGEGgu4Rw12UqhagikJ0teip2Y6hqmDcVpeQ2jnALcdHgRSlZZXqwKCwQhKmaS XOWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=to8s09Rl; 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 by26-20020a0564021b1a00b00548bc81607fsi1668499edb.6.2023.11.20.17.32.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Nov 2023 17:32:39 -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=to8s09Rl; 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 580C7875A7; Tue, 21 Nov 2023 02:30:48 +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="to8s09Rl"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 0887A87582; Tue, 21 Nov 2023 02:30: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.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pl1-x62b.google.com (mail-pl1-x62b.google.com [IPv6:2607:f8b0:4864:20::62b]) (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 39EDD875A7 for ; Tue, 21 Nov 2023 02:30:40 +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=takahiro.akashi@linaro.org Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-1cc703d2633so10670275ad.0 for ; Mon, 20 Nov 2023 17:30:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1700530238; x=1701135038; 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=Azv2jiokxdDjjZVQpsj4tHdv10eu4UK1JN/knIvXPu4=; b=to8s09RlkP4KblHZ4l5HzIY2Kgl33PqP7HPOiHo2NPH54FVlNoShcsinFElqF2729w YzgfDmJCO2+OL957r33LMGSVL7lifcluUL+/K4SGiFXUTILnvLhYlLtBQFQoIBOplLrF FbQcpuOVODErPp/BM1G8b01bQsLr9bibMZ7/zo1R0rtEe0RbQ7WoPfVN+vhXwsvnxxSF fq2dYm1lk1QMz3D16LmoRfaU8p+dHF9KRjKkBrnuyvaFPIAYZf/op41Y73pmKs5g3qDF m9oNLsiNXGB1O7mki1yifJ4iqshqRPA7uIoNzz8FF87lXzhqP+8cup2Nh9gJGwRWZk5J fSFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700530238; x=1701135038; 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=Azv2jiokxdDjjZVQpsj4tHdv10eu4UK1JN/knIvXPu4=; b=elAG2+qQlHDIGakrFSNDjcfE3EZZc7frGmD4+NEBzLAyMDVORKSAMnc6HrMOThCgBt qvpgoylLFqsb+A4SI4/vxOYoSiQcDQwnzZ4UbTL1u92ZXcmeOhqXnfqxJfcXRfwJ3nPQ iJkeFdb/iO7mdjzcKzF8fjgAygcBPNyDgJGJvF8/T4zMHEXiZv813JOKzOpwGNUh50uE pCJA52hZmxZRvYFX6twdOZ56ZJz4nuKCNkMZWYM4TZnLiWBwjs791eXfRUv6KAdiRN91 rLNcbxYCa0EIgUTEkKFyzLTYO8oHBMOvAF1eRl1IhYdKYRqAm62/62RMA6zP7/b/iIXg aw6Q== X-Gm-Message-State: AOJu0YyDZvjjGbxjJOzrpH63OU7XQ3+bTBjechxYfZZkiDK6a6aI0dng px+PgQGyYQ+yMAl5L9N2o601dg== X-Received: by 2002:a17:902:e74b:b0:1cc:32c6:e5fa with SMTP id p11-20020a170902e74b00b001cc32c6e5famr11564552plf.6.1700530238103; Mon, 20 Nov 2023 17:30:38 -0800 (PST) Received: from octopus.. ([2400:4050:c3e1:100:f6af:a59c:7ca:897f]) by smtp.gmail.com with ESMTPSA id e9-20020a170902d38900b001c8a0879805sm3612508pld.206.2023.11.20.17.30.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Nov 2023 17:30:37 -0800 (PST) From: AKASHI Takahiro To: trini@konsulko.com, sjg@chromium.org, xypron.glpk@gmx.de, ilias.apalodimas@linaro.org Cc: u-boot@lists.denx.de, AKASHI Takahiro Subject: [PATCH v2 03/12] cmd: bootefi: carve out EFI boot manager interface Date: Tue, 21 Nov 2023 10:29:41 +0900 Message-Id: <20231121012950.156539-4-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231121012950.156539-1-takahiro.akashi@linaro.org> References: <20231121012950.156539-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() in order to move boot manager specific code into library directory in the later commit. 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 e9e5ab67a1f5..87910c42333a 100644 --- a/cmd/bootefi.c +++ b/cmd/bootefi.c @@ -413,28 +413,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); } /** @@ -624,21 +636,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) &&