From patchwork Mon Nov 5 09:06:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 150165 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp2360541ljp; Mon, 5 Nov 2018 01:13:51 -0800 (PST) X-Google-Smtp-Source: AJdET5dtiS6Qfi6cRLndLX/kEX07+/Bq+B2JFIsQVDfd6esXQGoZhi9gyMtcbNcfUYCAdy+4HB6q X-Received: by 2002:a50:f0dc:: with SMTP id a28-v6mr17239364edm.78.1541409231017; Mon, 05 Nov 2018 01:13:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541409231; cv=none; d=google.com; s=arc-20160816; b=HiPPpqqbL8NtAKtmtcmKN7h954V69wmz5vmL/ir2KsY4wm1SxttZcIAVaN8HUGtt4l 68ksr6lpJqie/2gs73CMFTuVNjyY2lCXj7FHBpXedzo1rkqZbxNEARleRu5ie1y5/380 U+3V+CxJkT7MsLBMpN7RGk/bp26NitHyJYAfZVLKmQhUQ06iUa+0WRO91YLW0ZRZd+qW tELXKq1x8ecijMnhQ9EDorkLl8YFJ60Bqy2sA1sLYfi+BHCMBd2w8Uz9XFJcIA1MdqiH oq7mPe/QP87HVJuRGGoYEQdHPT3WUjKU/4RIex4Sa39Wp9QF9NsePp5ELaFLfFancATq ae+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :cc:mime-version:references:in-reply-to:message-id:date:to:from :dkim-signature; bh=u80+68wLxDa9Y6NuWBw5uAo2AyftnABACoJs1lzJZ5s=; b=hxrzVFlaV9Vwvngkm83eENqousT69toNVNUokdNpOMTjVk3FWz6mmAJEwf78eAUCrN v1ExzCoJDGD0Md3BPT/fOHj6jTtd0gaahbRkICH+omTkWbWpAU5Jgxrt9NqlxbG/gPj9 DYW+C+9N4huRjguq+l3yUXeQU8PfaPFKea6lqMC2UZtQoNi+10ak5nSAKeDlYgkuvjyu hWuxXucYswmiizY7KbCmAX2h4h9NFkU97qd6rHH2216rjiRLvXsNaGrZtQSvAyNw40tz qgifAWK47PUxU6Rq9Je4Tjcasoy7O9BmmwXjwh1rKZqduSq6Ehw9YCgATVj6Qs/62utM 098Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=N6K3XLDt; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.denx.de (dione.denx.de. [81.169.180.215]) by mx.google.com with ESMTP id v1-v6si1642570eja.44.2018.11.05.01.13.50; Mon, 05 Nov 2018 01:13:51 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) client-ip=81.169.180.215; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=N6K3XLDt; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by lists.denx.de (Postfix, from userid 105) id 99162C22229; Mon, 5 Nov 2018 09:07:43 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=RCVD_IN_MSPIKE_H2, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 99EB8C221FB; Mon, 5 Nov 2018 09:06:54 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 0D178C22229; Mon, 5 Nov 2018 09:05:17 +0000 (UTC) Received: from mail-yb1-f196.google.com (mail-yb1-f196.google.com [209.85.219.196]) by lists.denx.de (Postfix) with ESMTPS id AF6AAC22205 for ; Mon, 5 Nov 2018 09:05:13 +0000 (UTC) Received: by mail-yb1-f196.google.com with SMTP id h187-v6so1142502ybg.10 for ; Mon, 05 Nov 2018 01:05:13 -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=lel+yNRURJUJ/dF4EwEoLObz3vXjOlgvG3SBirZfMzg=; b=N6K3XLDtFgSKnYQ79MlOP7VkhPKH4AbqhiVteX7bgDP/lAL6gq4+ecMmheqo9mleHH RzHe5XNuct2yNrAnjxNb0MxDX1TrfJRaC7hxSJwm9XC37wkqY/k0VB3XvLRcsFbAM2eI 78Yj2bRFBAoCE7TNMrB5yxIPNrWJNU/UZm/Xs= 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=lel+yNRURJUJ/dF4EwEoLObz3vXjOlgvG3SBirZfMzg=; b=eCRJ5lJNqhTL4ezVvrc5xZkW4yPIYEalHOZ7qjqgf3ZJDgWC5U/95sw3gPvaGPNMeE oCDpQwss1lpTosCLUfxoaIZTA6O7mJ1a3aRa1PaxkLIlM+CGb2zAsGIf80MX4BeXChSd AL4Gywo6pb2/DxeSUIGJMp4MY46wsRriUl2xRu0FjrnehSagfoPqrtLPcw8Y1Y0A0D+V Vwhx/A3JeR7CbtUFaSYoQm+UCLqiJHtWQLsxLaYJaUE7WeOwMKn0qiYfoooV2pX7nJ7+ kDEQbB3zSfte5IFAHPl7mmZLR4CIv0+XIncTcifREfXwNktA4szrZObNe/MlcH75JCaS zxiw== X-Gm-Message-State: AGRZ1gIi3qedghDNHq2AhM5Tvo6/7kuR6+/nGRZz8FTEWb2oIAQ4CjaX 5jRRp4uxcRvonPO5yP+YOReBcA== X-Received: by 2002:a25:3fc5:: with SMTP id m188-v6mr21199524yba.359.1541408712520; Mon, 05 Nov 2018 01:05:12 -0800 (PST) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id m16-v6sm20515574ywh.18.2018.11.05.01.05.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Nov 2018 01:05:12 -0800 (PST) From: AKASHI Takahiro To: trini@konsulko.com, agraf@suse.de Date: Mon, 5 Nov 2018 18:06:49 +0900 Message-Id: <20181105090653.7409-11-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181105090653.7409-1-takahiro.akashi@linaro.org> References: <20181105090653.7409-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 Cc: xypron.glpk@gmx.de, u-boot@lists.denx.de Subject: [U-Boot] [PATCH v2 10/14] cmd: bootefi: carve out fdt parameter handling X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 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" The current way how command parameters, particularly "fdt addr," are handled makes it a bit complicated to add a subcommand-specific parameter. So just refactor the code and extract efi_handle_fdt(). This commit is a preparatory change for enhancing bootmgr sub-command. Signed-off-by: AKASHI Takahiro --- cmd/bootefi.c | 51 +++++++++++++++++++++++++++++++++----------------- cmd/efishell.h | 1 + 2 files changed, 35 insertions(+), 17 deletions(-) diff --git a/cmd/bootefi.c b/cmd/bootefi.c index 5d61819f1f5c..3aedf5a09f93 100644 --- a/cmd/bootefi.c +++ b/cmd/bootefi.c @@ -356,6 +356,31 @@ static efi_status_t efi_install_fdt(ulong fdt_addr) return ret; } +int efi_handle_fdt(char *fdt_opt) +{ + unsigned long fdt_addr; + efi_status_t r; + + if (fdt_opt) { + fdt_addr = simple_strtoul(fdt_opt, NULL, 16); + if (!fdt_addr && *fdt_opt != '0') + return CMD_RET_USAGE; + + /* Install device tree */ + r = efi_install_fdt(fdt_addr); + if (r != EFI_SUCCESS) { + printf("ERROR: failed to install device tree\n"); + return CMD_RET_FAILURE; + } + } else { + /* Remove device tree. EFI_NOT_FOUND can be ignored here */ + efi_install_configuration_table(&efi_guid_fdt, NULL); + printf("WARNING: booting without device tree\n"); + } + + return CMD_RET_SUCCESS; +} + /** * do_bootefi_exec() - execute EFI binary * @@ -511,7 +536,6 @@ static int do_bootefi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) unsigned long addr; char *saddr; efi_status_t r; - unsigned long fdt_addr; /* Allow unaligned memory access */ allow_unaligned(); @@ -527,21 +551,6 @@ static int do_bootefi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) if (argc < 2) return CMD_RET_USAGE; - if (argc > 2) { - fdt_addr = simple_strtoul(argv[2], NULL, 16); - if (!fdt_addr && *argv[2] != '0') - return CMD_RET_USAGE; - /* Install device tree */ - r = efi_install_fdt(fdt_addr); - if (r != EFI_SUCCESS) { - printf("ERROR: failed to install device tree\n"); - return CMD_RET_FAILURE; - } - } else { - /* Remove device tree. EFI_NOT_FOUND can be ignored here */ - efi_install_configuration_table(&efi_guid_fdt, NULL); - printf("WARNING: booting without device tree\n"); - } #ifdef CONFIG_CMD_BOOTEFI_HELLO if (!strcmp(argv[1], "hello")) { ulong size = __efi_helloworld_end - __efi_helloworld_begin; @@ -559,6 +568,9 @@ static int do_bootefi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) struct efi_loaded_image_obj *image_obj; struct efi_loaded_image *loaded_image_info; + if (efi_handle_fdt(argc > 2 ? argv[2] : NULL)) + return CMD_RET_FAILURE; + /* Construct a dummy device path. */ bootefi_device_path = efi_dp_from_mem(EFI_RESERVED_MEMORY_TYPE, (uintptr_t)&efi_selftest, @@ -583,7 +595,10 @@ static int do_bootefi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) } else #endif if (!strcmp(argv[1], "bootmgr")) { - return do_bootefi_bootmgr_exec(); + if (efi_handle_fdt(argc > 2 ? argv[2] : NULL)) + return CMD_RET_FAILURE; + + return do_bootefi_bootmgr_exec(boot_id); } else { saddr = argv[1]; @@ -592,6 +607,8 @@ static int do_bootefi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) if (!addr && *saddr != '0') return CMD_RET_USAGE; + if (efi_handle_fdt(argc > 2 ? argv[2] : NULL)) + return CMD_RET_FAILURE; } printf("## Starting EFI application at %08lx ...\n", addr); diff --git a/cmd/efishell.h b/cmd/efishell.h index 6f70b402b26b..1e5764a8a38d 100644 --- a/cmd/efishell.h +++ b/cmd/efishell.h @@ -3,3 +3,4 @@ #include efi_status_t efi_init_obj_list(void); +int efi_handle_fdt(char *fdt_opt);