From patchwork Fri Apr 19 03:22:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 1087939 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="U8bHHDa3"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 44lhH10Vl2z9s4V for ; Fri, 19 Apr 2019 13:27:09 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id C3D41C21DF8; Fri, 19 Apr 2019 03:24:46 +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 4CA76C21E1A; Fri, 19 Apr 2019 03:24:12 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 92EB7C21DFD; Fri, 19 Apr 2019 03:23:35 +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 43E3BC21E18 for ; Fri, 19 Apr 2019 03:23:32 +0000 (UTC) Received: by mail-yb1-f196.google.com with SMTP id e190so1609165ybf.2 for ; Thu, 18 Apr 2019 20:23:32 -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=eTjdGD+6rrLXr0PvNJ44FJ15N/vxB2Hj6efQR2nePQ8=; b=U8bHHDa3cD8EyemuZhWCrFM16TUlY5Uv62YBkWTzNRGs4sLXWcP7B6F0hGwBPhg90w MWsFlqbnKYbYXFdCYatPMbJdc7yqSFXHWEuxEx0H6y5pIMizn16Ojt1PkBeFNafHGdpG hjOZJ3WwzFCap/Z86uE1xo4gIHmTlyhtD29ha2xzB0TVmnkMlgRAIln67HnuQUMmigN5 09VNfmjh6NXZyiugAaYV+bfAZlM48H6QjXI5LJawKxcHr3cycaBDlWD7g0lAB6qMHLTr 8Zl0hc/KhWB4clsD/FcPhgz0sFAIpcNvx5gAOt86eAV9DsjSQmi+CkJWGoGW4CANnqBk KpJw== 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=eTjdGD+6rrLXr0PvNJ44FJ15N/vxB2Hj6efQR2nePQ8=; b=qLBZyAmhmfI52zBSapTak2lL/QZmQeH0ZO4X0KV8dhypbntY1cCGwAIkequEPmpioT 7+uu1BmbGQXdQJFp2jcTkAvVwNthxy+YPy70SeO16Tfw2g0hFsJ7WOVMHssL3Vicw+Uq SZV7CO1/s3vYsQQskjgmDQvhejoDE8OSgPITTpe+8FSQ6F9F+b3QPsWlBlqdiSS7fRtM 8VFWfBmFjLp303MPQ78+dqg9q9npUNZSiKQZ7BAdGEQMUJKqgRZNg6YWhDRDrlghVTlc kjkUs4b+nDuNe0LScaR5/HZUp3xYL5gKAEJzRu12HPq88+9obf513TTRuxvx2xutEu+w YQeA== X-Gm-Message-State: APjAAAUV3R1PzJ0atDpnCFO4lpGoVY1UW6xKTfUXffishR6G1nHsZ3qR Z5cHWlt57WMVv+FmPNn2i3NAYE/Ee1Q= X-Google-Smtp-Source: APXvYqwvo8fICPpNauRGX7R5onb5qK1ZeTmhk7SWDl3Idd/gqBMRprMONegGsQtXdpNkDz7Br2CNJA== X-Received: by 2002:a25:1a45:: with SMTP id a66mr1057310yba.390.1555644211223; Thu, 18 Apr 2019 20:23:31 -0700 (PDT) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id 129sm2032692ywv.38.2019.04.18.20.23.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 18 Apr 2019 20:23:30 -0700 (PDT) From: AKASHI Takahiro To: xypron.glpk@gmx.de, agraf@csgraf.de Date: Fri, 19 Apr 2019 12:22:30 +0900 Message-Id: <20190419032236.8242-4-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 3/9] cmd: bootefi: merge efi_install_fdt() and efi_process_fdt() 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. For simplicity, merge two functions. Signed-off-by: AKASHI Takahiro Reviewed-by: Heinrich Schuchardt --- cmd/bootefi.c | 67 +++++++++++++++++++++------------------------------ 1 file changed, 28 insertions(+), 39 deletions(-) diff --git a/cmd/bootefi.c b/cmd/bootefi.c index fb6703ce84f3..c6d6eb7312e8 100644 --- a/cmd/bootefi.c +++ b/cmd/bootefi.c @@ -185,62 +185,51 @@ static void efi_carve_out_dt_rsv(void *fdt) } } -static efi_status_t efi_install_fdt(ulong fdt_addr) -{ - bootm_headers_t img = { 0 }; - efi_status_t ret; - void *fdt; - - fdt = map_sysmem(fdt_addr, 0); - if (fdt_check_header(fdt)) { - printf("ERROR: invalid device tree\n"); - return EFI_INVALID_PARAMETER; - } - - /* Create memory reservation as indicated by the device tree */ - efi_carve_out_dt_rsv(fdt); - - /* Prepare fdt for payload */ - ret = copy_fdt(&fdt); - if (ret) - return ret; - - if (image_setup_libfdt(&img, fdt, 0, NULL)) { - printf("ERROR: failed to process device tree\n"); - return EFI_LOAD_ERROR; - } - - /* Link to it in the efi tables */ - ret = efi_install_configuration_table(&efi_guid_fdt, fdt); - if (ret != EFI_SUCCESS) - return EFI_OUT_OF_RESOURCES; - - return ret; -} - /** - * efi_process_fdt() - process fdt passed by a command argument + * efi_install_fdt() - install 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) +static efi_status_t efi_install_fdt(const char *fdt_opt) { unsigned long fdt_addr; + void *fdt; + bootm_headers_t img = { 0 }; efi_status_t ret; if (fdt_opt) { + /* Install device tree */ 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); + fdt = map_sysmem(fdt_addr, 0); + if (fdt_check_header(fdt)) { + printf("ERROR: invalid device tree\n"); + return EFI_INVALID_PARAMETER; + } + + /* Create memory reservation as indicated by the device tree */ + efi_carve_out_dt_rsv(fdt); + + /* Prepare fdt for payload */ + ret = copy_fdt(&fdt); + if (ret) + return ret; + + if (image_setup_libfdt(&img, fdt, 0, NULL)) { + printf("ERROR: failed to process device tree\n"); + return EFI_LOAD_ERROR; + } + + /* Link to it in the efi tables */ + ret = efi_install_configuration_table(&efi_guid_fdt, fdt); if (ret != EFI_SUCCESS) { printf("ERROR: failed to install device tree\n"); - return ret; + return EFI_OUT_OF_RESOURCES; } } else { /* Remove device tree. EFI_NOT_FOUND can be ignored here */ @@ -456,7 +445,7 @@ static int do_bootefi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) if (argc < 2) return CMD_RET_USAGE; - r = efi_process_fdt(argc > 2 ? argv[2] : NULL); + r = efi_install_fdt(argc > 2 ? argv[2] : NULL); if (r == EFI_INVALID_PARAMETER) return CMD_RET_USAGE; else if (r != EFI_SUCCESS)