From patchwork Wed Jan 13 11:11:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilias Apalodimas X-Patchwork-Id: 362079 Delivered-To: patch@linaro.org Received: by 2002:a02:ccad:0:0:0:0:0 with SMTP id t13csp428103jap; Wed, 13 Jan 2021 03:12:45 -0800 (PST) X-Google-Smtp-Source: ABdhPJz7QEtu6ij0fAOebAjlLD9FmDXefoXCLb+sU7lNGc4NbZ5Wp5Y2DWwQjyCMjW6x8EDhQbFV X-Received: by 2002:a17:907:c01:: with SMTP id ga1mr1147109ejc.488.1610536365635; Wed, 13 Jan 2021 03:12:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610536365; cv=none; d=google.com; s=arc-20160816; b=sGaks18DdYyA6uL4dv0UyPJMJNrlRaCsaRSqbKHkJPkW/V6liarb888gvqbuhBPkto QBcZ4qEkz4rPlEoo4HZwVxcsSFgi1R+TcAx27yQx/4pigp/O0lYedWtBmzxvQWdhM3At Hc1dssd+GTjExNOKGXAFTpaeXDZNFSOAWV+mBwTQVxDg3rFRlC8YA+MHUBfvqhygt0QR 8leRSh49OGO6+lTPek/WKW1m5sHraXtcpCM/z7SU4FU/4R31G6hA5/PutA5yrJZljtME C1C2Psg3Ou/3zF4/wuGTlcm+tinQJTGWyetkIfUgMfeOp/KCK5bdVSzdQQcoUDoGMcSj r/8Q== 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=fBK3v0d2ioh+ddkusX4EgOxnF0hLYP9doAyNXA0TK4s=; b=RJ0EZysRFm9BfhiioG2o9zhSznT9MmMX5mRBYBPsZrJSeXtZ5MJKumTG2m2ULmfp2Y 381bPY375ow025AX2zmB9Eig/XnIMrR3RafV6h78Xudl034q86DgGR/L1ibINJwpgVAg +H4j/rVHUbvxFaB9lJ5DY28JzkOsZ4g6CIX18APGzLA8OKnk/wLtcUuGi2Q/mat/8FGK ZGbxiiLy2AxcUe9GHht7qCoxyaYDfzFaekTNA3NU+KlrOnWOLQMPr65dxGHmR9wyCSFS M1uHKPIBaEgcJ7949Spb3UgkMfUP7qKvIeYd5fOALbXEYclQSfgAqjZarKvqXyBcpHWY LkLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Htd4or+U; 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 ch17si856870edb.430.2021.01.13.03.12.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Jan 2021 03:12:45 -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=Htd4or+U; 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 548B482663; Wed, 13 Jan 2021 12:12:23 +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="Htd4or+U"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id E1F318263A; Wed, 13 Jan 2021 12:12:10 +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.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) (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 20A448250D for ; Wed, 13 Jan 2021 12:11:57 +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=ilias.apalodimas@linaro.org Received: by mail-wm1-x331.google.com with SMTP id 3so1235138wmg.4 for ; Wed, 13 Jan 2021 03:11:57 -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=fBK3v0d2ioh+ddkusX4EgOxnF0hLYP9doAyNXA0TK4s=; b=Htd4or+UunScou/qSMvj+fUbwk/HJ5JEaF7OEnS+Yc+1Hqx+aGMsza9A8n6mJ03sI0 DYjPi3N4Of8bZSoS8YbNzyAYcZUGwQFGQOc7h9pylSLrxDNay2Tw7UnNM9oEolNZ+cC4 TPwcTtPTuE8tWBoiM+JYxOC9rpzoCP6/YI3zLRDY56oMnjtMv/MOdJMrgH5dsYyB7a6D tMU7qEYnMvsxbBPtEgwt5pY1JgpWhO60aGAPwr4JKs1KJnte7C/Q3SWMWo3/1UhuqYD2 VFtj5WDyweHWMtBrRP11DkXrCjpOFPLcqGKjWZrmtb91hd5941IkTYARTJNx2kXp9ux5 e9Mg== 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=fBK3v0d2ioh+ddkusX4EgOxnF0hLYP9doAyNXA0TK4s=; b=Xn2p8SEhqwC+v/AVmzgZCq3CW4nIEETQpogfXFrGIk2XWru/T+8ofCBGQhwB3zAXQA UdvtWtH1AIVm/tcz6+KFWM9WPRu1c6KNVBeH+NBW3KsIAzlM7ZiIUP6+VrD4pZyoD/wg 65xi3HzXomDfBo2fuec2d5c12jd+OdjE7iDLN9U3bo+2Ee939COlNqDqDLEDNk1US2Me +qFMoBSB/fX4CHHXTFxLt2dguvO4JWWvsDL5Vvqgb3Xe9812JSYG9EgmO8MujbzEtbLk noe31NHGWz2p38bF6G1K7keXHM6IB/A1Cp5PrqemOyjsUx0hzMKmuNLvcK4ARKbl0mUA 0Uig== X-Gm-Message-State: AOAM533HENuv0W6ge8CrEelISwGvvN/TqAA4yxQFzfoMCpyXdDh8+YBd 3GZ0comLgOUSvQGW84G19BtAAw== X-Received: by 2002:a1c:4d05:: with SMTP id o5mr1745250wmh.85.1610536316736; Wed, 13 Jan 2021 03:11:56 -0800 (PST) Received: from apalos.home ([2a02:587:4667:3e9:2e56:dcff:fe9a:8f06]) by smtp.gmail.com with ESMTPSA id r2sm2589869wrn.83.2021.01.13.03.11.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Jan 2021 03:11:56 -0800 (PST) From: Ilias Apalodimas To: xypron.glpk@gmx.de Cc: takahiro.akashi@linaro.org, Ilias Apalodimas , Alexander Graf , u-boot@lists.denx.de Subject: [RFC PATCH 3/3] efidebug: add multiple device path instances on Boot#### Date: Wed, 13 Jan 2021 13:11:49 +0200 Message-Id: <20210113111149.64567-4-ilias.apalodimas@linaro.org> X-Mailer: git-send-email 2.30.0.rc2 In-Reply-To: <20210113111149.64567-1-ilias.apalodimas@linaro.org> References: <20210113111149.64567-1-ilias.apalodimas@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.102.3 at phobos.denx.de X-Virus-Status: Clean The UEFI spec allow a packed array of UEFI device paths in the FilePathList[] of an EFI_LOAD_OPTION. The first file path must describe the laoded image but the rest are OS specific. Previous patches parse the device path and try to use the second member of the array as an initrd. So let's modify efidebug slightly and install the second file described in the command line as the initrd device path. Signed-off-by: Ilias Apalodimas --- cmd/efidebug.c | 89 +++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 81 insertions(+), 8 deletions(-) -- 2.30.0.rc2 diff --git a/cmd/efidebug.c b/cmd/efidebug.c index 5fb7b1e3c6a9..8d62981aca92 100644 --- a/cmd/efidebug.c +++ b/cmd/efidebug.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -17,6 +18,7 @@ #include #include #include +#include #define BS systab.boottime #define RT systab.runtime @@ -782,6 +784,42 @@ static int do_efi_show_tables(struct cmd_tbl *cmdtp, int flag, return CMD_RET_SUCCESS; } +/** + * add_initrd_instance() - Append a device path to load_options pointing to an + * inirtd + * + * @argc: Number of arguments + * @argv: Argument array + * @file_path Existing device path, the new instance will be appended + * Return: Pointer to the device path or ERR_PTR + * + */ +static struct efi_device_path *add_initrd_instance(int argc, char *const argv[], + struct efi_device_path *file_path) +{ + struct efi_device_path *tmp_dp = NULL, *tmp_fp = NULL; + struct efi_device_path *final_fp = NULL; + efi_status_t ret; + + if (argc < 8) + return ERR_PTR(-EINVAL); + + ret = efi_dp_from_name(argv[6], argv[7], argv[8], &tmp_dp, + &tmp_fp); + if (ret != EFI_SUCCESS) { + printf("Cannot create device path for \"%s %s\"\n", + argv[6], argv[7]); + goto out; + } + + final_fp = efi_dp_append_instance(file_path, tmp_fp); + +out: + efi_free_pool(tmp_dp); + efi_free_pool(tmp_fp); + return final_fp ? final_fp : ERR_PTR(-EINVAL); +} + /** * do_efi_boot_add() - set UEFI load option * @@ -794,7 +832,11 @@ static int do_efi_show_tables(struct cmd_tbl *cmdtp, int flag, * * Implement efidebug "boot add" sub-command. Create or change UEFI load option. * - * efidebug boot add