From patchwork Fri Apr 19 03:22:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 1087938 X-Patchwork-Delegate: xypron.glpk@gmx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="vZrafarD"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 44lhG86FBLz9s4V for ; Fri, 19 Apr 2019 13:26:24 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 8E05CC21E1A; Fri, 19 Apr 2019 03:24:33 +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=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 BBB71C21E1B; Fri, 19 Apr 2019 03:24:05 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 9146FC21E30; Fri, 19 Apr 2019 03:23:33 +0000 (UTC) Received: from mail-yb1-f195.google.com (mail-yb1-f195.google.com [209.85.219.195]) by lists.denx.de (Postfix) with ESMTPS id 01FE2C21E0F for ; Fri, 19 Apr 2019 03:23:30 +0000 (UTC) Received: by mail-yb1-f195.google.com with SMTP id a13so1595760ybl.8 for ; Thu, 18 Apr 2019 20:23:29 -0700 (PDT) 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=TQoF2a1HWGmgGIbqwp+4l52pXJRvRxQSGR9hY5U4A6A=; b=vZrafarDB1xh2V0cRosMTVt6TNiEjKiqAV0QmQ2khweHdmg75+AJwsOygSKySD1nBv mORRId6PsFbBKkVN60wW+K8QIjPl8n3ZMPK+hxEhF5wY3qwnEuLrbcmT3i4hU/Dc2qJa N8+coxZYnguGfUURRCAoCRQtmlSVlxDScyilmTI7ORZHnzOMjyP4Z5NCUKxcd87Uzh5r VSObvPYUredmr1fWRIpkR/nE+curfitc5RV960sHDP626qHnwwZFJIGZEeMiwZ7FoypP pSAsL24A248wiFyPLz5PBiY/VFXE8ogl2A9tWLdjZWWql1UBAYPw8eIDwoX5su2HRPj1 dqLQ== 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=TQoF2a1HWGmgGIbqwp+4l52pXJRvRxQSGR9hY5U4A6A=; b=qykwmt6NEZZTUAx1AtBu9eSFiPOjHC2jaThMrQH6KrAyhsc4Lo+ksGEQckrhQQJApY 93wmuPjwwIBls2XcyGD8m1qFSEWHYQlz8maK3T6PiVWzgLTTSgoa68r/9OImAAPG7NgS bn9lxx0H1dfzv/dYjk/XrxXQUs7IMIQEcJW0j+VumClfzr+S6TIlGlei7WFYH/cr89QD xDh/Bh3PZsVJPj9ucG/ud24EVKlrJ1f/l66ylBqWrHL0KjsSEAmwW/N1FcVufx1PTx7R 8Impd3BFIGF7u4C96QxLXBJ0SF3iq19c/Jn047PvKJ35HmB2cekcKBOt8hcrbLQvOEo+ cVgQ== X-Gm-Message-State: APjAAAUbWIasOGTmlEOa9+NAT5Zk+xbZybFsw0ZSDAM0wXblgeUQMnAp anNu30u6oSaLJllYi9V0l4x33w== X-Google-Smtp-Source: APXvYqwmO3PNU05CLMFQ6b1QyF+ufHRv7ykdRcyFNMT5tZ3msqWa0AOxFMKyjS/5I3mvgyNLeIww/Q== X-Received: by 2002:a25:320a:: with SMTP id y10mr1016345yby.215.1555644208972; Thu, 18 Apr 2019 20:23:28 -0700 (PDT) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id e14sm2587621ywa.8.2019.04.18.20.23.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 18 Apr 2019 20:23:28 -0700 (PDT) From: AKASHI Takahiro To: xypron.glpk@gmx.de, agraf@csgraf.de Date: Fri, 19 Apr 2019 12:22:29 +0900 Message-Id: <20190419032236.8242-3-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190419032236.8242-1-takahiro.akashi@linaro.org> References: <20190419032236.8242-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 Cc: u-boot@lists.denx.de Subject: [U-Boot] [PATCH 2/9] cmd: bootefi: carve out fdt handling from do_bootefi() 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" This is a preparatory patch for reworking do_bootefi() in later patch. Carve out a function to handle the installation of the device tree as a configuration table in system table. Signed-off-by: AKASHI Takahiro Reviewed-by: Heinrich Schuchardt --- cmd/bootefi.c | 54 ++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 38 insertions(+), 16 deletions(-) diff --git a/cmd/bootefi.c b/cmd/bootefi.c index d8ca4ed703ef..fb6703ce84f3 100644 --- a/cmd/bootefi.c +++ b/cmd/bootefi.c @@ -218,6 +218,38 @@ static efi_status_t efi_install_fdt(ulong fdt_addr) return ret; } +/** + * efi_process_fdt() - process fdt passed by a command argument + * @fdt_opt: pointer to argument + * Return: status code + * + * If specified, fdt will be installed as configuration table, + * otherwise no fdt will be passed. + */ +static efi_status_t efi_process_fdt(const char *fdt_opt) +{ + unsigned long fdt_addr; + efi_status_t ret; + + if (fdt_opt) { + fdt_addr = simple_strtoul(fdt_opt, NULL, 16); + if (!fdt_addr && *fdt_opt != '0') + return EFI_INVALID_PARAMETER; + + /* Install device tree */ + ret = efi_install_fdt(fdt_addr); + if (ret != EFI_SUCCESS) { + printf("ERROR: failed to install device tree\n"); + return ret; + } + } else { + /* Remove device tree. EFI_NOT_FOUND can be ignored here */ + efi_install_configuration_table(&efi_guid_fdt, NULL); + } + + return EFI_SUCCESS; +} + static efi_status_t bootefi_run_prepare(const char *load_options_path, struct efi_device_path *device_path, struct efi_device_path *image_path, @@ -407,7 +439,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(); @@ -425,21 +456,12 @@ 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"); - } + r = efi_process_fdt(argc > 2 ? argv[2] : NULL); + if (r == EFI_INVALID_PARAMETER) + return CMD_RET_USAGE; + else if (r != EFI_SUCCESS) + return CMD_RET_FAILURE; + #ifdef CONFIG_CMD_BOOTEFI_HELLO if (!strcmp(argv[1], "hello")) { ulong size = __efi_helloworld_end - __efi_helloworld_begin;