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: 1425765 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=Htd4or+U; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4DG4YD501Zz9sWL for ; Wed, 13 Jan 2021 22:12:48 +1100 (AEDT) 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-Google-Smtp-Source: ABdhPJyV4f+HnRh/gPl47Q6Er80pNBPR1JQLLYndYgKCVMftyJstKKcMnGz7jV2yXp34mK5fxGy1MQ== 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(-) 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