From patchwork Tue Jan 15 02:54:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 155608 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp4387149jaa; Mon, 14 Jan 2019 19:00:31 -0800 (PST) X-Google-Smtp-Source: ALg8bN6sj3TrZgzhnksxT99AvzVsSMG7nWwjZ1BJQoiAajlnBdd+S0cAEJ0CWafPZ3qzv7vQODKH X-Received: by 2002:a17:906:6d59:: with SMTP id a25-v6mr1468375ejt.54.1547521230900; Mon, 14 Jan 2019 19:00:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547521230; cv=none; d=google.com; s=arc-20160816; b=MxHISuazcVZUqr1YhZjko0vXLu5mjC3PsX3MdpvkSBnrs1J7Xl2JLKbCfQkkfx8P6W spJ8hJ/QKUcGXcjuB5WAEKAs3IdUwSA/Xa8UUmLURTfWYZFXA3bfkfkLwYskDVIGhW8U xZFQBQARRARSpHCy5ZBYtqq5yACBGQrVc1CE4o3OJvRISpx/Fco7yAyHWdN8JUf22ZYf Gn+w84Ggq7PtQAIAj0fhrSkzIlRcGGM66KEEWdfhE3arMzRmIsY5ItYIVS57yxqc2U9B NS1PovIVrAtNkABWB8kI6QSvklhHqP/GI+n29LTqXzGONWWbfIcB1KsYzkSxSjPyS1KQ frrw== 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=Sj5GK2tyMUjQ/UHTwDDcsQmG5kA5AR17ShWNve0P6rQ=; b=zLq+wqcCv2k3xWLL+As++SgPV5uTha/SGixKCwdej0nBBD2GDPyLa5L232pCJm4Y5j w+PvTeUfCcByGQOq6c9YdVGzOo8IP7bK5XwF7X9mLqRZm5st+3VVYh0rFi2xoppbwNdH P47xiR8dca4mNrssamBA/Hs/b1L+4tKAr6ipFHQtLWOPcKHxffhyUweBnNpn+H1bWE6s BitNJC1eb08d3brcjqm+MD4oR1yl0CsbIG/iMmU73fgLqLSsTrlaoWMBUY7tIOr6I715 xom9eqh5KOpLS6Htmcd7EKXv5m6GtnJEAkZXvKY3Hy+y29wkUPeGO0PKw5iWqY77KzV1 I+/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=YSi0eUnJ; 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 k22si3304023edd.408.2019.01.14.19.00.30; Mon, 14 Jan 2019 19:00:30 -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=YSi0eUnJ; 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 84830C21FE2; Tue, 15 Jan 2019 02:55:54 +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_DNSWL_BLOCKED, 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 D53C0C22005; Tue, 15 Jan 2019 02:55:07 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 79796C222D3; Tue, 15 Jan 2019 02:54:48 +0000 (UTC) Received: from mail-yw1-f67.google.com (mail-yw1-f67.google.com [209.85.161.67]) by lists.denx.de (Postfix) with ESMTPS id 62CF9C21F88 for ; Tue, 15 Jan 2019 02:54:44 +0000 (UTC) Received: by mail-yw1-f67.google.com with SMTP id d190so510025ywb.5 for ; Mon, 14 Jan 2019 18:54:44 -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=Psc4+NKvUhkn/AOE6o2bg1AHk+i0ed6a/jH7VGguJRg=; b=YSi0eUnJhnHFwmer/Xi1+6oTnkRMob1G2Z+medGEPP6HotBdY/1vrvhGCJUttDxWu0 M1YnOxQp+z+ojoU2XsNx8ugKC1p4zwi5WEpRcUJgmy1SarNUr2Mz7xNZn2VLmbicM7+l VKQhUgfzJhqYb9CBM6f55zdqXe1AanNw2HfRI= 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=Psc4+NKvUhkn/AOE6o2bg1AHk+i0ed6a/jH7VGguJRg=; b=fT7NfpF2cz1fZrN9AOdRSEhkufTx5d5idbZkM16rNys23r3I41+tCeLUI2c1h4iK85 qzCMlj4ybRXN2bDvJ/QBF/l7lbbEDkamqBAuELrFwtn3Cu9tVmBAQ19j1NK1BTodSudI qumGvEIg2iKKPGKVW8uE2kcAyuGsJDal1jEBv5VSyub3Vf7i0cNIqyNCcHPQH218dKpl 0KNaICifsvW61VruIULrFgLL+tIgYouvtbMk05GRceOCjvPsuhRXOkRJu1aiIuBxYRhr BHyZZ6KnVTzdH18Jt4iOJJWZsj36MjOGa0mfJ33gQtG3OGe3PCLAZS0ACzG9nzzwahYT KahQ== X-Gm-Message-State: AJcUukdrUdP8HSxLNlgMlsJumrnFGX6rBEbzbcmwHRQTE1hkHhq4X5mZ KeyZBM+OBofPtL7wiGttxprUhQ== X-Received: by 2002:a81:2891:: with SMTP id o139mr1297139ywo.100.1547520883371; Mon, 14 Jan 2019 18:54:43 -0800 (PST) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id d3sm1285976ywh.58.2019.01.14.18.54.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 14 Jan 2019 18:54:42 -0800 (PST) From: AKASHI Takahiro To: trini@konsulko.com, agraf@suse.de, xypron.glpk@gmx.de Date: Tue, 15 Jan 2019 11:54:35 +0900 Message-Id: <20190115025437.11966-4-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190115025437.11966-1-takahiro.akashi@linaro.org> References: <20190115025437.11966-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 Cc: u-boot@lists.denx.de Subject: [U-Boot] [PATCH v2 3/5] 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 | 49 +++++++++++++++++++++++++++++++++---------------- 1 file changed, 33 insertions(+), 16 deletions(-) diff --git a/cmd/bootefi.c b/cmd/bootefi.c index 76171ab679c3..3be01b49b589 100644 --- a/cmd/bootefi.c +++ b/cmd/bootefi.c @@ -279,6 +279,31 @@ static void bootefi_run_finish(struct efi_loaded_image_obj *image_obj, efi_delete_handle(&image_obj->header); } +static 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 * @@ -474,7 +499,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(); @@ -490,21 +514,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; @@ -522,6 +531,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; + if (bootefi_test_prepare(&image_obj, &loaded_image_info, "\\selftest", (uintptr_t)&efi_selftest, "efi_selftest")) @@ -534,6 +546,9 @@ static int do_bootefi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) } else #endif if (!strcmp(argv[1], "bootmgr")) { + if (efi_handle_fdt(argc > 2 ? argv[2] : NULL)) + return CMD_RET_FAILURE; + return do_bootefi_bootmgr_exec(); } else { saddr = argv[1]; @@ -543,6 +558,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);