From patchwork Fri Dec 6 02:35:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2019028 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=JscjGxcK; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Y4Fl228wcz1yRL for ; Fri, 6 Dec 2024 13:36:46 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id B013B89622; Fri, 6 Dec 2024 03:36:40 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="JscjGxcK"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 31476895E2; Fri, 6 Dec 2024 03:36:40 +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=-5.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-io1-xd2d.google.com (mail-io1-xd2d.google.com [IPv6:2607:f8b0:4864:20::d2d]) (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 0AD388918C for ; Fri, 6 Dec 2024 03:36:38 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-io1-xd2d.google.com with SMTP id ca18e2360f4ac-843e546c7f0so59042639f.1 for ; Thu, 05 Dec 2024 18:36:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1733452596; x=1734057396; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=u+zZG6fLQOAfN627Etd1WaVgdXszogCdbESqGfPpazw=; b=JscjGxcKPMG075iXdXLyBI98mBiEeKusajhi9mUWlLJHm5HANEpefPZb5bmLL9HDP4 kg0I3PK+tQPt5lf6BhxvXkiWcha3L4VcgvCR2q+NRl5top8cUNrutSIsDvwlZ1onShyB pn7DYiZtYa4H7osOh/Th5STwH1n2DCXU3kstA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733452596; x=1734057396; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=u+zZG6fLQOAfN627Etd1WaVgdXszogCdbESqGfPpazw=; b=wlvs0OqowS+0J5Y9HRoKPTIJDoj7U1TYlnDD/JCFsHp6h6lKSue5Am32uRWqXXgKwO RzRMhKDDotMjUPyWHt3Dr9MgHqOSY7OX9HqHtQhd/a/2dfD3KigdTqWZy+5olvp9fNy4 E/Hw+uZ5C0csV75rZ6ErAhT41kXHJVDr2UMXzbfzM+pJInDUjfy8m4s6jnLogMVmlvBq U9LKTDubvUwI/3+fWuejxQzH0/TUcoO0GHstD/NXJ462/xf8dakTFyfkJg9VAHqGVYcF JsyKtySVxCHPCgyQ5Or0CoERQfsxqp7/w5OWpk1luwo3Ah3j/mA0WkYr0tegYfEMM2b5 pRtQ== X-Gm-Message-State: AOJu0YzRm63+RbSOMUpfeYrYx87PpKxx+W18mMPTurEfRcnhqYVEyjHZ h0gpOpRDaiYYUmT9sBsxVCDVi22X5o8iRE6KQpv4H+11dnMT/sQk3my2+uaRr8B6cFYRORM1Px8 = X-Gm-Gg: ASbGncuWcX8k+NnmYSMhwAczVz6vE+dAnlQgCzIgE1poNVF7qsZz6xKx+VbuUpi6VMg OBhXYAUvQX6pQ/CtAWwarDv37bL5gqgySLzaXSyEmJEGKU1ZOeqKmVtJ0ucI1ruKpShjGRykiD+ Tx4QyXNC4Y7wo3yio+PfDCkcJo8UqeW6sSBZ/ywXf1aRikrSPrrqTWeDPPh9odJXkfuIjpJi426 c7iVVtA3vIzFJnGid7/alp/q3RWxs16EqDb/HNGpCw77+jN1a51vy3nuCKXUeLcZNBV7iek+9QO LXovBs/RB2o= X-Google-Smtp-Source: AGHT+IFG7pibK61Kjd8AVdxw7LHwubOAqIltuCSYH0BeQ0d7caLZljL0pyoG45pm7X8mrenapdMiBw== X-Received: by 2002:a05:6602:6d14:b0:83a:bd82:78e with SMTP id ca18e2360f4ac-8447e2d8b94mr227365139f.13.1733452596211; Thu, 05 Dec 2024 18:36:36 -0800 (PST) Received: from chromium.org (c-73-203-119-151.hsd1.co.comcast.net. [73.203.119.151]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4e2861f51bfsm575506173.112.2024.12.05.18.36.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Dec 2024 18:36:34 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Simon Glass , Bin Meng Subject: [PATCH v3 01/46] x86: Make do_zboot_states() static Date: Thu, 5 Dec 2024 19:35:40 -0700 Message-Id: <20241206023626.2456858-2-sjg@chromium.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241206023626.2456858-1-sjg@chromium.org> References: <20241206023626.2456858-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.103.8 at phobos.denx.de X-Virus-Status: Clean This function is only called within zboot.c so make the function private. Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- (no changes since v1) cmd/x86/zboot.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/x86/zboot.c b/cmd/x86/zboot.c index 94e602b8a5b..3035172352a 100644 --- a/cmd/x86/zboot.c +++ b/cmd/x86/zboot.c @@ -119,8 +119,8 @@ U_BOOT_SUBCMDS(zboot, U_BOOT_CMD_MKENT(dump, 2, 1, do_zboot_dump, "", ""), ) -int do_zboot_states(struct cmd_tbl *cmdtp, int flag, int argc, - char *const argv[], int state_mask) +static int do_zboot_states(struct cmd_tbl *cmdtp, int flag, int argc, + char *const argv[], int state_mask) { int ret = 0; From patchwork Fri Dec 6 02:35:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2019029 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=G74DK4et; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Y4Fl76WSPz1yRL for ; Fri, 6 Dec 2024 13:36:51 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 08F4B8951F; Fri, 6 Dec 2024 03:36:43 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="G74DK4et"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 521D18951F; Fri, 6 Dec 2024 03:36:42 +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=-5.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-io1-xd2d.google.com (mail-io1-xd2d.google.com [IPv6:2607:f8b0:4864:20::d2d]) (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 20D21895DE for ; Fri, 6 Dec 2024 03:36:40 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-io1-xd2d.google.com with SMTP id ca18e2360f4ac-84198252db1so56440339f.0 for ; Thu, 05 Dec 2024 18:36:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1733452598; x=1734057398; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=pSi9T0jwsyOTf7U8m2OZryThc774EjL0fNn9zqgfeG4=; b=G74DK4etDCTRHOeCLbx2XNELT4P00jE6jkbCChBuEps0bykWIB8SIzEfGrMMj8e1f+ 2SLGTd4y0bTsBXAMYadrGTEzFa2y78LMKHU5/8NlaamXVpDwEK0bVOzrW6MYETg7FUj1 qG8wZyOXdXXfm/m11SVU+IbusY4dL3Uz2NeTI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733452598; x=1734057398; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=pSi9T0jwsyOTf7U8m2OZryThc774EjL0fNn9zqgfeG4=; b=NdnhApIr6lKrYmjqxrIwCBsmo2Wj7sLXjjRhKdEUBw0RTY9hYowQJrMT3cO9IZtZXj wsoxZpfWDBm5oI/NZN5r62QcAvkQEwyZHJLMPnSRSfDAzH0Jjyf/Vkde6BqMU3UXR/aC 1zlYdyEAo4BhhXUUJaap3PbjGtZU+nFdzV4dtDrsF1hL/4sv2FB2axgNFarUxQKdPN/S XPLHh8vCs8BFin4t8FJVe05W911diRnxMFZqnbbBG5BJyttkHOpAe35+lHbxM/VpXXk6 OGMnQChJ1hRLkZRzrYtryGGqzA5hyw0/Z1NVuk44YNDC1/2u7htTmpH44c7Oxqg2zBtF hc5g== X-Gm-Message-State: AOJu0Yy3fsaTxW1ZqP5MgT2lUFdegUPoOrhEDQdUM34h35w/Rm9uZies ZQcDZFVE9Ij+eDE5guoBdQuQotd37fZZIem6r1II5iZh0yFvjNIB0GcLCJ34iek3q8zSmUnW+5Y = X-Gm-Gg: ASbGncud0PLRFezPaUuBnP7kIcQLTyNOBAdb3ilnfCZJXHX+4kjgx2SZpMbnGLNATLU XiQwPVKjnLE2CifjOSAYCe04qBYoaMAHRa2SG40sHVLDA3sWF2nPVz3gcZqQ4kRbM6qrpooDH0L Lwh6A7CIfllK1F0Nhusjj8WCFgMrXRxAOrFvNZCbkHu9Vb01pdQ17BK1xH83p8R7KMJqZbh9WNJ u8A3s30t9lup95gNfgfvQ8a3bhoCPelB6PK/tZTWjI1DwGm0xXEHt2vNvdFMaAmSgKSGYOpRqqs fB/T/7iPxgw= X-Google-Smtp-Source: AGHT+IHU+BBBOYQVwqo7Fjx+arNg7r5PgAyRP/6UcrtrJkzG+KeOvz+p7pq2cileNDRiUxU8sytR3A== X-Received: by 2002:a6b:6210:0:b0:844:2ef3:a95a with SMTP id ca18e2360f4ac-84471100818mr569072039f.7.1733452598353; Thu, 05 Dec 2024 18:36:38 -0800 (PST) Received: from chromium.org (c-73-203-119-151.hsd1.co.comcast.net. [73.203.119.151]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4e2861f51bfsm575506173.112.2024.12.05.18.36.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Dec 2024 18:36:37 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Simon Glass , Bin Meng , Mattijs Korpershoek , =?utf-8?q?Vincent_Stehl?= =?utf-8?q?=C3=A9?= Subject: [PATCH v3 02/46] x86: Rename zboot_run() to zboot_run_args() Date: Thu, 5 Dec 2024 19:35:41 -0700 Message-Id: <20241206023626.2456858-3-sjg@chromium.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241206023626.2456858-1-sjg@chromium.org> References: <20241206023626.2456858-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.103.8 at phobos.denx.de X-Virus-Status: Clean Rename this function so we can (later) create a zboot_run() function which looks the same as bootm_run() Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- (no changes since v1) arch/x86/lib/zimage.c | 4 ++-- boot/bootmeth_cros.c | 6 +++--- include/bootm.h | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/arch/x86/lib/zimage.c b/arch/x86/lib/zimage.c index 73a21bc8f03..53fc81f57a2 100644 --- a/arch/x86/lib/zimage.c +++ b/arch/x86/lib/zimage.c @@ -436,8 +436,8 @@ int zboot_go(void) return ret; } -int zboot_run(ulong addr, ulong size, ulong initrd, ulong initrd_size, - ulong base, char *cmdline) +int zboot_run_args(ulong addr, ulong size, ulong initrd, ulong initrd_size, + ulong base, char *cmdline) { int ret; diff --git a/boot/bootmeth_cros.c b/boot/bootmeth_cros.c index c7b862e512a..ea4c9ed830f 100644 --- a/boot/bootmeth_cros.c +++ b/boot/bootmeth_cros.c @@ -446,9 +446,9 @@ static int cros_boot(struct udevice *dev, struct bootflow *bflow) } if (IS_ENABLED(CONFIG_X86)) { - ret = zboot_run(map_to_sysmem(bflow->buf), bflow->size, 0, 0, - map_to_sysmem(bflow->x86_setup), - bflow->cmdline); + ret = zboot_run_args(map_to_sysmem(bflow->buf), bflow->size, 0, + 0, map_to_sysmem(bflow->x86_setup), + bflow->cmdline); } else { ret = bootm_boot_start(map_to_sysmem(bflow->buf), bflow->cmdline); diff --git a/include/bootm.h b/include/bootm.h index 61160705215..154fb98cfcd 100644 --- a/include/bootm.h +++ b/include/bootm.h @@ -273,7 +273,7 @@ int bootm_process_cmdline(char *buf, int maxlen, int flags); int bootm_process_cmdline_env(int flags); /** - * zboot_run() - Run through the various steps to boot a zimage + * zboot_run_args() - Run through the various steps to boot a zimage * * Boot a zimage, given the component parts * @@ -289,8 +289,8 @@ int bootm_process_cmdline_env(int flags); * to use for booting * Return: -EFAULT on error (normally it does not return) */ -int zboot_run(ulong addr, ulong size, ulong initrd, ulong initrd_size, - ulong base, char *cmdline); +int zboot_run_args(ulong addr, ulong size, ulong initrd, ulong initrd_size, + ulong base, char *cmdline); /* * zimage_get_kernel_version() - Get the version string from a kernel From patchwork Fri Dec 6 02:35:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2019030 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=MLWf+aLA; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Y4FlJ3Q1Rz1yRL for ; Fri, 6 Dec 2024 13:37:00 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 4FB0E895E2; Fri, 6 Dec 2024 03:36:47 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="MLWf+aLA"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id A4B5B8918C; Fri, 6 Dec 2024 03:36:45 +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=-5.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-io1-xd30.google.com (mail-io1-xd30.google.com [IPv6:2607:f8b0:4864:20::d30]) (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 728678962F for ; Fri, 6 Dec 2024 03:36:43 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-io1-xd30.google.com with SMTP id ca18e2360f4ac-843df3c4390so50362139f.3 for ; Thu, 05 Dec 2024 18:36:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1733452601; x=1734057401; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=El44hvYoArK6lqJKjv96dHFcIMtvoAoIYAra/BqgSOo=; b=MLWf+aLAfxi2JklkS9XgO/hvbT9YGrsriMA2MJ11gQ513m98+GWm5Erfj4myI/5PMr gkO84K9VN7sgvW27lJVLeHAsk0buIVnW9fttVNxwGHrDZ0n0HLEWMGMJBQGlbqetorIi O4wJcYt9Wny5dBq+j4IQIi/JRHnqaGIpqlxiU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733452601; x=1734057401; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=El44hvYoArK6lqJKjv96dHFcIMtvoAoIYAra/BqgSOo=; b=R4PrxGxr8u4IMmtFGrRYtStHdAoyWcmuIayWulU7TgEYGRHHYwmYA07h3vECKapv5+ eIbaGvkdf2cXYf1NyhgmATeNt7NYW6P0OUrXJiQvg9WR0n3ZoTWZ5i5z+HTQ4sKhP8yY 1V8dbaJdcRu/O9MKlLDCM2e/5Nbf8Ivi++sl9MBM4M0CFgK8BrlbaxHCHduNtioyRFJa U28RKjAc7pmUJ+H7I7oCWPZ52jS2H260m7r+LSEnqShUh7VL5Zo7s7qdU/pPbpsEYw1G Uvh3zcur4KZZoCuFKyWc7bfBoBy2yB3UqOPWITSKyVr+BUYUjjVUDgvDZOWoz7qTlavb GHmw== X-Gm-Message-State: AOJu0YzBbFoVPAog1RmD5/Jo4p/WD5Y12m6MRHBdbBUR8DwkL0zU7sBV wO8BZIygg5h4ZrJdfiVELWruSY7L7atmOgDm4z1e+a5bYUfgM5+gdJZlIHgOQWzzwJnuo5moqbA = X-Gm-Gg: ASbGncsQ+miQ5Z+8ZdQgqrpMAmqryIuQU5Ms1/9nhZq/tBrrV4510D/owM+ZwpWOftR pvysezz4YVOp2tYyb2X9XZ6+Rpw75nhF+cEsBJHFOkP8E37Vdir+K6r9aE2q1gIJP+CTrElAjo3 vBJW7s9WtSoT9WWk1CRJIymP32/1p1YLlCF868hj/Ac1fc7sTfefeT5lw7c2L1NMe0IVy9bZvCL sP2zvUYxHDRGSdoDUTHgh/3D9YyMk7wSrVrHXREr+IHKEi7Q72jcDdBTs5rfJTWBY8eijCZzoRT I2JKKQ83aVs= X-Google-Smtp-Source: AGHT+IFMC1uwF/5DclDB9YB+g8Lzx7hbfqSDYusJH8/5WTp4Fv8dMWyUtCpndSe8kyrzXTGYprwXLg== X-Received: by 2002:a05:6e02:b4a:b0:3a7:820c:180a with SMTP id e9e14a558f8ab-3a811e29ca0mr20137055ab.19.1733452601309; Thu, 05 Dec 2024 18:36:41 -0800 (PST) Received: from chromium.org (c-73-203-119-151.hsd1.co.comcast.net. [73.203.119.151]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4e2861f51bfsm575506173.112.2024.12.05.18.36.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Dec 2024 18:36:39 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Simon Glass , Bin Meng Subject: [PATCH v3 03/46] x86: Drop duplicate definition of zimage_dump() Date: Thu, 5 Dec 2024 19:35:42 -0700 Message-Id: <20241206023626.2456858-4-sjg@chromium.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241206023626.2456858-1-sjg@chromium.org> References: <20241206023626.2456858-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.103.8 at phobos.denx.de X-Virus-Status: Clean This is now defined in bootm.h so drop the duplicate in the x86 code. Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- (no changes since v1) arch/x86/include/asm/zimage.h | 8 -------- cmd/x86/zboot.c | 1 + 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/arch/x86/include/asm/zimage.h b/arch/x86/include/asm/zimage.h index 8b542605170..76b2a797ccf 100644 --- a/arch/x86/include/asm/zimage.h +++ b/arch/x86/include/asm/zimage.h @@ -71,14 +71,6 @@ struct zboot_state { extern struct zboot_state state; -/** - * zimage_dump() - Dump information about a zimage - * - * @base_ptr: Pointer to the boot parameters - * @show_cmdline: true to show the kernel command line - */ -void zimage_dump(struct boot_params *base_ptr, bool show_cmdline); - /** * zboot_load() - Load a zimage * diff --git a/cmd/x86/zboot.c b/cmd/x86/zboot.c index 3035172352a..40f67a75593 100644 --- a/cmd/x86/zboot.c +++ b/cmd/x86/zboot.c @@ -7,6 +7,7 @@ #define LOG_CATEGORY LOGC_BOOT +#include #include #include #include From patchwork Fri Dec 6 02:35:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2019031 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=mdh0e3oZ; dkim-atps=neutral Authentication-Results: legolas.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=patchwork.ozlabs.org) 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 ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Y4FlV4BSbz1yRL for ; Fri, 6 Dec 2024 13:37:10 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id A4AD08962F; Fri, 6 Dec 2024 03:36:49 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="mdh0e3oZ"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 34EC68960A; Fri, 6 Dec 2024 03:36:48 +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=-5.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-il1-x136.google.com (mail-il1-x136.google.com [IPv6:2607:f8b0:4864:20::136]) (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 D7B728918C for ; Fri, 6 Dec 2024 03:36:45 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-il1-x136.google.com with SMTP id e9e14a558f8ab-3a75c24f447so5190085ab.0 for ; Thu, 05 Dec 2024 18:36:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1733452604; x=1734057404; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=YS/lfNjCt9uJFlbUUQJxoIBmvwwgTuS68TmxZhy9qko=; b=mdh0e3oZUYFjCJZOaymLYQKDdi6b5gqCSVYkcuNaUiYOLVB/n5ygBiTrTkSksRHI+4 wAqicvUJzsjeJA9H4fjVD/XHUQfjZKEpgL3HsnPCllnFtr8tgIIkduA+txCiOP2uT9EM F73S30vm8Kgbr3bSbZwR1yIZCMHHKwyH7IDa4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733452604; x=1734057404; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=YS/lfNjCt9uJFlbUUQJxoIBmvwwgTuS68TmxZhy9qko=; b=F/5ZpA9K7gauyEsUqa7pYhIFfDhbIObJxkV8w1zPw7y0sDOMpYU+usLbXmM5MAhCEx QjUQxHKuFBduPBx363FDwWfOYd67XS8UhTRZ/BOkGPoZl/ob7W2KQg7JmhORgOFRFzpl XIU52xgafleDGahP9hAjd4+h88HTKJpCeYIyuy3myBvjngGCkMb+Sg30/RYgN6LhHBNR i34z6n6jVokNY1Qzd72oC7FgiXhUFKdhMDC25hYb3cgUylAkdjZKzNueRBcIzqd6sX9S 3bIMW0vgo/rBHZbZ5FhMFqOIF/jy7PSFAEI4YGOaUmau/899a5BgGhrJAzi+6NSkFrtg Bj1g== X-Gm-Message-State: AOJu0YxW4l+bi88chI13jD319K6WPAVmFsgDTjqoUttJd7ri6U8oA+wh cCsKyvgc7p2Qa2xBT5LXrCj/YJEXxfrdjz4ZAmqXuRdgzmY1QpuvJDcEZIrv8ThkeQGTJ+wwwYo = X-Gm-Gg: ASbGnctbpsvUeUo/Xr4J2P89x4X0NBi0lb2/Rh7ZW7lYk/jqdkdeQ4N2jKBIUU5GEB3 00htTNOuJz/SZvCZTfnPandSr0MY6m6aot1RgM7sakXx4dM/EK4AKUJQ5flasBRon+T8/ET0L0D NvN979GIFrO70m3p3Me4SqjpoHkb9LMsAsEdNE8w8ohEMLEY/Zb6Bh6acv78WqlSShCzy/SJHof TsiI6Y5d/uOfbzabpbPGlQjw9vFJCbM79jfw3riQqpZzbAigk5Zu6zk2fWK3/o8xukhBLVecvBA Fo9S0+V6x58= X-Google-Smtp-Source: AGHT+IEoWKlueDOvBOyKolyw4hkirDBFQ9sd8BmaSvuLJC0bSJt0IJ5ZFz3fzHRxZ/rjSzoFs7XAtw== X-Received: by 2002:a05:6e02:20cc:b0:3a7:172f:1299 with SMTP id e9e14a558f8ab-3a811de2885mr22395975ab.12.1733452604082; Thu, 05 Dec 2024 18:36:44 -0800 (PST) Received: from chromium.org (c-73-203-119-151.hsd1.co.comcast.net. [73.203.119.151]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4e2861f51bfsm575506173.112.2024.12.05.18.36.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Dec 2024 18:36:42 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Simon Glass , Bin Meng Subject: [PATCH v3 04/46] x86: Move x86 zboot state into struct bootm_info Date: Thu, 5 Dec 2024 19:35:43 -0700 Message-Id: <20241206023626.2456858-5-sjg@chromium.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241206023626.2456858-1-sjg@chromium.org> References: <20241206023626.2456858-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.103.8 at phobos.denx.de X-Virus-Status: Clean This structure is supposed to handle any type of booting programmatically, i.e. without needing a command to be executed. Move the x86-specific members into it and use it instead of struct zboot_state. Provide a macro so access is possible without adding lots of #ifdefs to the code. This will allow the struct to be used for all four types of booting (bootm, bootz, booti and zboot). Call bootm_init() to init the state, to match other boot methods. Note that some rationalisation could be performed on this. But this is tricky since addresses are stored as strings in several places. Also some strings combine multiple arguments into one. So to keep this task somewhat manageable, we content ourselves with just getting everything into the same struct Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- (no changes since v1) arch/x86/include/asm/zimage.h | 29 +---------------------------- arch/x86/lib/zimage.c | 4 ++-- include/bootm.h | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 36 insertions(+), 30 deletions(-) diff --git a/arch/x86/include/asm/zimage.h b/arch/x86/include/asm/zimage.h index 76b2a797ccf..13a08850dfb 100644 --- a/arch/x86/include/asm/zimage.h +++ b/arch/x86/include/asm/zimage.h @@ -42,34 +42,7 @@ enum { ZBOOT_STATE_COUNT = 5, }; -/** - * struct zboot_state - Current state of the boot - * - * @bzimage_addr: Address of the bzImage to boot, or 0 if the image has already - * been loaded and does not exist (as a cohesive whole) in memory - * @bzimage_size: Size of the bzImage, or 0 to detect this - * @initrd_addr: Address of the initial ramdisk, or 0 if none - * @initrd_size: Size of the initial ramdisk, or 0 if none - * @load_address: Address where the bzImage is moved before booting, either - * BZIMAGE_LOAD_ADDR or ZIMAGE_LOAD_ADDR - * This is set up when loading the zimage - * @base_ptr: Pointer to the boot parameters, typically at address - * DEFAULT_SETUP_BASE - * This is set up when loading the zimage - * @cmdline: Environment variable containing the 'override' command line, or - * NULL to use the one in the setup block - */ -struct zboot_state { - ulong bzimage_addr; - ulong bzimage_size; - ulong initrd_addr; - ulong initrd_size; - ulong load_address; - struct boot_params *base_ptr; - const char *cmdline; -}; - -extern struct zboot_state state; +extern struct bootm_info state; /** * zboot_load() - Load a zimage diff --git a/arch/x86/lib/zimage.c b/arch/x86/lib/zimage.c index 53fc81f57a2..c2cf52658e9 100644 --- a/arch/x86/lib/zimage.c +++ b/arch/x86/lib/zimage.c @@ -56,7 +56,7 @@ DECLARE_GLOBAL_DATA_PTR; #define COMMAND_LINE_SIZE 2048 /* Current state of the boot */ -struct zboot_state state; +struct bootm_info state; static void build_command_line(char *command_line, int auto_boot) { @@ -643,7 +643,7 @@ void zimage_dump(struct boot_params *base_ptr, bool show_cmdline) void zboot_start(ulong bzimage_addr, ulong bzimage_size, ulong initrd_addr, ulong initrd_size, ulong base_addr, const char *cmdline) { - memset(&state, '\0', sizeof(state)); + bootm_init(&state); state.bzimage_size = bzimage_size; state.initrd_addr = initrd_addr; diff --git a/include/bootm.h b/include/bootm.h index 154fb98cfcd..5fa9761629e 100644 --- a/include/bootm.h +++ b/include/bootm.h @@ -44,6 +44,21 @@ struct cmd_tbl; * @argc: Number of arguments to the command (excluding the actual command). * This is 0 if there are no arguments * @argv: NULL-terminated list of arguments, or NULL if there are no arguments + * + * For zboot: + * @bzimage_addr: Address of the bzImage to boot, or 0 if the image has already + * been loaded and does not exist (as a cohesive whole) in memory + * @bzimage_size: Size of the bzImage, or 0 to detect this + * @initrd_addr: Address of the initial ramdisk, or 0 if none + * @initrd_size: Size of the initial ramdisk, or 0 if none + * @load_address: Address where the bzImage is moved before booting, either + * BZIMAGE_LOAD_ADDR or ZIMAGE_LOAD_ADDR + * This is set up when loading the zimage + * @base_ptr: Pointer to the boot parameters, typically at address + * DEFAULT_SETUP_BASE + * This is set up when loading the zimage + * @cmdline: Environment variable containing the 'override' command line, or + * NULL to use the one in the setup block */ struct bootm_info { const char *addr_img; @@ -54,8 +69,26 @@ struct bootm_info { const char *cmd_name; int argc; char *const *argv; + + /* zboot items */ +#ifdef CONFIG_X86 + ulong bzimage_addr; + ulong bzimage_size; + ulong initrd_addr; + ulong initrd_size; + ulong load_address; + struct boot_params *base_ptr; + const char *cmdline; +#endif }; +/* macro to allow setting fields in generic code */ +#ifdef CONFIG_X86 +#define bootm_x86_set(_bmi, _field, _val) (_bmi)->_field = (_val) +#else +#define bootm_x86_set(_bmi, _field, _val) +#endif + /** * bootm_init() - Set up a bootm_info struct with useful defaults * From patchwork Fri Dec 6 02:35:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2019032 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=ZmgrGn8Z; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Y4Flf3QP2z1yRL for ; Fri, 6 Dec 2024 13:37:18 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id F349D89639; Fri, 6 Dec 2024 03:36:51 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="ZmgrGn8Z"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 1433989641; Fri, 6 Dec 2024 03:36:51 +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=-5.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-io1-xd2d.google.com (mail-io1-xd2d.google.com [IPv6:2607:f8b0:4864:20::d2d]) (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 AA1108918C for ; Fri, 6 Dec 2024 03:36:48 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-io1-xd2d.google.com with SMTP id ca18e2360f4ac-8418ecda128so56623139f.2 for ; Thu, 05 Dec 2024 18:36:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1733452607; x=1734057407; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=JoPhzhnTJIgh3cFnLV8Y5mcUSaG4DWjCwt+l8t03jaA=; b=ZmgrGn8ZCFpHN8Lihcr3aAu7i+mL5GllbRnoHh15a7YRDsRkNRu6degUvBCoUMD0y3 Z9P5A1Vd3z+6hZ2dn0Yj0tXvYKmUdY/lJYfl2e5zf1EzQ5lYbL+yxdTEDbElH/2Hy677 1omEXc5Af8vqffc/g+GnTUN5ar6OxlTHPL5+c= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733452607; x=1734057407; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=JoPhzhnTJIgh3cFnLV8Y5mcUSaG4DWjCwt+l8t03jaA=; b=ZMZRbL0y9bPT+3TvuVUlGN8rAb1YOsS3bVI3LmqgxwuPcNgFuWg8YqI0EYiRmOZX61 xF+wxJDRKaTeAOmgbhR24oLhMj0tO65iH0pd5KJV//CDdPBElwdgj4ewRobZ6lf1EV8B fwF62bH9kYHwCWEvxhX3oHN2yII8uFU1k5ZeKFrUKdjV79OFkCLBmzupSU4kvPmWswoK TQvgblrKWvteGxyTEayED2FR/gJD/Yp/b6o6XXIDY3IAymMHW6PwtJfdZ/WZOX3S47lN SbVCTQ4ntpKODgumtW9MEcVsGhdP9/KDNm+5iJhJ16bT4LLDSiih2MTeucI4JxmWvhIX YlBg== X-Gm-Message-State: AOJu0YzM6hMS6lAg5zqKUHnvNO1jF61ery+eRz+aQfGwqJE42z4MpXTC FlYqMF8GgHLNMDsmdu27hOLCqUqTeYkcoAGPHAQZQ7Gk9O4QrXnwHOKPLpLra/zWn1A90YfBLqo = X-Gm-Gg: ASbGnctJ28VeDbx6XkAuQMGyBGF7zJHJPKW9mEQBHroMwx0cH6I60YpIEr5Vl5yQ3Z0 kv7i4s7Uc+q4nmp9Etqlpq6m3HfyUZzmUtTBkTvBP9Iqg4t8ZQ6I0tkNgiTFzcCaVQA7OoAV+kS 8INvSkoiwtgBrl141SQ1FY6NJk23F/sY7YnjbZFvKCWYP73KmHXy4abYmqn/hPUdKEcaISa9BUO 8IZktidMpVJblW+De6x3iqcnWF1ay6ADC4gJCQuQbaUH7Xu1W8kiFy9ZW8U2+0HTP2pcverXnlw qHnmho6ya4o= X-Google-Smtp-Source: AGHT+IH/8Tdty+fDd9jujJO0n5CLBpwDYA7Q647IblEw7itNckMzrjX+kvVMZCXni5FOnwrAYVg8Cg== X-Received: by 2002:a05:6602:15ca:b0:83a:b79c:66b6 with SMTP id ca18e2360f4ac-8447e1fdd82mr224815639f.2.1733452606838; Thu, 05 Dec 2024 18:36:46 -0800 (PST) Received: from chromium.org (c-73-203-119-151.hsd1.co.comcast.net. [73.203.119.151]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4e2861f51bfsm575506173.112.2024.12.05.18.36.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Dec 2024 18:36:45 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Simon Glass , Bin Meng Subject: [PATCH v3 05/46] x86: Rename state to bmi Date: Thu, 5 Dec 2024 19:35:44 -0700 Message-Id: <20241206023626.2456858-6-sjg@chromium.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241206023626.2456858-1-sjg@chromium.org> References: <20241206023626.2456858-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.103.8 at phobos.denx.de X-Virus-Status: Clean Use the common name for the struct, in preparation for passing it around between functions. Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- (no changes since v1) arch/x86/include/asm/zimage.h | 2 +- arch/x86/lib/zimage.c | 48 +++++++++++++++++------------------ cmd/x86/zboot.c | 4 +-- 3 files changed, 27 insertions(+), 27 deletions(-) diff --git a/arch/x86/include/asm/zimage.h b/arch/x86/include/asm/zimage.h index 13a08850dfb..b592057e58b 100644 --- a/arch/x86/include/asm/zimage.h +++ b/arch/x86/include/asm/zimage.h @@ -42,7 +42,7 @@ enum { ZBOOT_STATE_COUNT = 5, }; -extern struct bootm_info state; +extern struct bootm_info bmi; /** * zboot_load() - Load a zimage diff --git a/arch/x86/lib/zimage.c b/arch/x86/lib/zimage.c index c2cf52658e9..1afd3084144 100644 --- a/arch/x86/lib/zimage.c +++ b/arch/x86/lib/zimage.c @@ -56,7 +56,7 @@ DECLARE_GLOBAL_DATA_PTR; #define COMMAND_LINE_SIZE 2048 /* Current state of the boot */ -struct bootm_info state; +struct bootm_info bmi; static void build_command_line(char *command_line, int auto_boot) { @@ -371,8 +371,8 @@ int zboot_load(void) struct boot_params *base_ptr; int ret; - if (state.base_ptr) { - struct boot_params *from = (struct boot_params *)state.base_ptr; + if (bmi.base_ptr) { + struct boot_params *from = (struct boot_params *)bmi.base_ptr; base_ptr = (struct boot_params *)DEFAULT_SETUP_BASE; log_debug("Building boot_params at 0x%8.8lx\n", @@ -380,18 +380,18 @@ int zboot_load(void) memset(base_ptr, '\0', sizeof(*base_ptr)); base_ptr->hdr = from->hdr; } else { - base_ptr = load_zimage((void *)state.bzimage_addr, state.bzimage_size, - &state.load_address); + base_ptr = load_zimage((void *)bmi.bzimage_addr, bmi.bzimage_size, + &bmi.load_address); if (!base_ptr) { puts("## Kernel loading failed ...\n"); return -EINVAL; } } - state.base_ptr = base_ptr; + bmi.base_ptr = base_ptr; - ret = env_set_hex("zbootbase", map_to_sysmem(state.base_ptr)); + ret = env_set_hex("zbootbase", map_to_sysmem(bmi.base_ptr)); if (!ret) - ret = env_set_hex("zbootaddr", state.load_address); + ret = env_set_hex("zbootaddr", bmi.load_address); if (ret) return ret; @@ -400,12 +400,12 @@ int zboot_load(void) int zboot_setup(void) { - struct boot_params *base_ptr = state.base_ptr; + struct boot_params *base_ptr = bmi.base_ptr; int ret; ret = setup_zimage(base_ptr, (char *)base_ptr + COMMAND_LINE_OFFSET, - 0, state.initrd_addr, state.initrd_size, - (ulong)state.cmdline); + 0, bmi.initrd_addr, bmi.initrd_size, + (ulong)bmi.cmdline); if (ret) return -EINVAL; @@ -414,7 +414,7 @@ int zboot_setup(void) int zboot_go(void) { - struct boot_params *params = state.base_ptr; + struct boot_params *params = bmi.base_ptr; struct setup_header *hdr = ¶ms->hdr; bool image_64bit; ulong entry; @@ -422,7 +422,7 @@ int zboot_go(void) disable_interrupts(); - entry = state.load_address; + entry = bmi.load_address; image_64bit = false; if (IS_ENABLED(CONFIG_X86_RUN_64BIT) && (hdr->xloadflags & XLF_KERNEL_64)) { @@ -431,7 +431,7 @@ int zboot_go(void) } /* we assume that the kernel is in place */ - ret = boot_linux_kernel((ulong)state.base_ptr, entry, image_64bit); + ret = boot_linux_kernel((ulong)bmi.base_ptr, entry, image_64bit); return ret; } @@ -597,7 +597,7 @@ void zimage_dump(struct boot_params *base_ptr, bool show_cmdline) print_num("Start sys seg", hdr->start_sys_seg); print_num("Kernel version", hdr->kernel_version); version = zimage_get_kernel_version(base_ptr, - (void *)state.bzimage_addr); + (void *)bmi.bzimage_addr); if (version) printf(" @%p: %s\n", version, version); print_num("Type of loader", hdr->type_of_loader); @@ -643,22 +643,22 @@ void zimage_dump(struct boot_params *base_ptr, bool show_cmdline) void zboot_start(ulong bzimage_addr, ulong bzimage_size, ulong initrd_addr, ulong initrd_size, ulong base_addr, const char *cmdline) { - bootm_init(&state); + bootm_init(&bmi); - state.bzimage_size = bzimage_size; - state.initrd_addr = initrd_addr; - state.initrd_size = initrd_size; + bmi.bzimage_size = bzimage_size; + bmi.initrd_addr = initrd_addr; + bmi.initrd_size = initrd_size; if (base_addr) { - state.base_ptr = map_sysmem(base_addr, 0); - state.load_address = bzimage_addr; + bmi.base_ptr = map_sysmem(base_addr, 0); + bmi.load_address = bzimage_addr; } else { - state.bzimage_addr = bzimage_addr; + bmi.bzimage_addr = bzimage_addr; } - state.cmdline = cmdline; + bmi.cmdline = cmdline; } void zboot_info(void) { printf("Kernel loaded at %08lx, setup_base=%p\n", - state.load_address, state.base_ptr); + bmi.load_address, bmi.base_ptr); } diff --git a/cmd/x86/zboot.c b/cmd/x86/zboot.c index 40f67a75593..0d0a8e53172 100644 --- a/cmd/x86/zboot.c +++ b/cmd/x86/zboot.c @@ -57,7 +57,7 @@ static int do_zboot_load(struct cmd_tbl *cmdtp, int flag, int argc, static int do_zboot_setup(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { - if (!state.base_ptr) { + if (!bmi.base_ptr) { printf("base is not set: use 'zboot load' first\n"); return CMD_RET_FAILURE; } @@ -97,7 +97,7 @@ static int do_zboot_go(struct cmd_tbl *cmdtp, int flag, int argc, static int do_zboot_dump(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { - struct boot_params *base_ptr = state.base_ptr; + struct boot_params *base_ptr = bmi.base_ptr; if (argc > 1) base_ptr = (void *)hextoul(argv[1], NULL); From patchwork Fri Dec 6 02:35:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2019033 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=OrnIRphk; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Y4Flr4Xsfz1yRL for ; Fri, 6 Dec 2024 13:37:28 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 5333B896BB; Fri, 6 Dec 2024 03:36:55 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="OrnIRphk"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 134308967B; Fri, 6 Dec 2024 03:36:54 +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=-5.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-il1-x12a.google.com (mail-il1-x12a.google.com [IPv6:2607:f8b0:4864:20::12a]) (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 527948918C for ; Fri, 6 Dec 2024 03:36:51 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-il1-x12a.google.com with SMTP id e9e14a558f8ab-3a813899384so880875ab.1 for ; Thu, 05 Dec 2024 18:36:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1733452609; x=1734057409; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ThJbMvvI97V5V2BNyjBZycQM63g/hRHqwrrsn22Kf6I=; b=OrnIRphkv+WA0N8q8cfnmP59KjZ5Wa3gPDCyc24TeZvOB+ooZosjtMv1BSwVea4jCB tn35fBtapBMYmMpxGlj6IHrFZLx3DTcf/ch1LF+I5W0vVOJB26mUmHky12oDJQNj8Bsl 860jE/Nd68EL325lsrJJf0o9wXkcWPPEQ5fN4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733452609; x=1734057409; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ThJbMvvI97V5V2BNyjBZycQM63g/hRHqwrrsn22Kf6I=; b=eaFem/1R2h+bGW8fZ2UOd3ubf14Pna84mPH6DAwd4jn3+WXPi1/Gj7H0COLDHJ2cF9 gCZpPM3+L1w96O4oYbjWrqWjdDZBP3oKarHrqsDHXKam/c6Y+Hw8+/4EABUiL8lI62EU Bk2GP1Est7aienKLck2y/zrXhgUOGahOa0QpRQAaua/1Pvv9E/DsbXmWTHfuegzfwekT F6mrMLmvaxqNXNAALWxuiMTtB6OthuEdWPlFo/Kbmc0KdeHg5Esus1D9+UvfrT07ZViw wNPBWJ8UES0VWd+877AWb9/tNjGdTpZek74eV4hUJMyTyUUolVt7NTQidM0M0+UmHEb/ VpTA== X-Gm-Message-State: AOJu0YyL2/YbeFZqpGknTniFAapyYvoQcJd8qJHfxGbsu+0rtMNef3cm DSxaFaDohZPDKpYI3SZWGUwwtzJIZcfrufp8UL4KOCXh1DQhpC3H7ve8J5QiUPL7v/n2PrQ1Epo = X-Gm-Gg: ASbGncvCBiFy6H5iXnsUAOB37s2kYmzdWe1jP3DfY4WGc1/FF2IYuBeXtS7GQA6nL5D yIlb/78RqmqkyFi5SIjWoL3LneIaSnv5c9Qnh1FZ66ujDygvX9RzdyPmiCjSzgKS9R30TqZGWk7 85ZIWKO+I4czgWu373lP6Nlo7Ms/DqZzzbVqPMYfXtvhSdbsghGwatUP5k2IhwgVoEjXdPqmTMp 4ODU7Uu1Y3yfilVDYJRd+khRyQuIC5Zy8zPtuZrShAsHv8ERW1xsMh6g4ybsWbS+EpZFPisuCuk ECtqRL/aGIo= X-Google-Smtp-Source: AGHT+IHQQofuaJEseb88OfLl5WRXdIGWHvgUsMyls8VlnjPiabne0DCoExd/Ens2TDzVslz3eL3TVg== X-Received: by 2002:a05:6e02:156d:b0:3a7:e436:5e00 with SMTP id e9e14a558f8ab-3a811df3eeemr16731635ab.14.1733452608991; Thu, 05 Dec 2024 18:36:48 -0800 (PST) Received: from chromium.org (c-73-203-119-151.hsd1.co.comcast.net. [73.203.119.151]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4e2861f51bfsm575506173.112.2024.12.05.18.36.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Dec 2024 18:36:48 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Simon Glass , Bin Meng , Heinrich Schuchardt Subject: [PATCH v3 06/46] x86: Move the bootm state for zimage into cmd/ Date: Thu, 5 Dec 2024 19:35:45 -0700 Message-Id: <20241206023626.2456858-7-sjg@chromium.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241206023626.2456858-1-sjg@chromium.org> References: <20241206023626.2456858-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.103.8 at phobos.denx.de X-Virus-Status: Clean Rather than holding the state in the implementation code, move it to the command code. The state is now passed to the implementation functions and can there (with future work) be pass in from bootstd, without going through the commands. Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- (no changes since v1) arch/x86/include/asm/zimage.h | 22 +++++----- arch/x86/lib/zimage.c | 75 +++++++++++++++++------------------ cmd/bootflow.c | 5 ++- cmd/x86/zboot.c | 20 ++++++---- include/bootm.h | 8 +++- 5 files changed, 73 insertions(+), 57 deletions(-) diff --git a/arch/x86/include/asm/zimage.h b/arch/x86/include/asm/zimage.h index b592057e58b..4ed6d8d5cc2 100644 --- a/arch/x86/include/asm/zimage.h +++ b/arch/x86/include/asm/zimage.h @@ -10,6 +10,8 @@ #include #include +struct bootm_info; + /* linux i386 zImage/bzImage header. Offsets relative to * the start of the image */ @@ -42,8 +44,6 @@ enum { ZBOOT_STATE_COUNT = 5, }; -extern struct bootm_info bmi; - /** * zboot_load() - Load a zimage * @@ -51,21 +51,21 @@ extern struct bootm_info bmi; * * Return: 0 if OK, -ve on error */ -int zboot_load(void); +int zboot_load(struct bootm_info *bmi); /** * zboot_setup() - Set up the zboot image reeady for booting * * Return: 0 if OK, -ve on error */ -int zboot_setup(void); +int zboot_setup(struct bootm_info *bmi); /** * zboot_go() - Start the image * * Return: 0 if OK, -ve on error */ -int zboot_go(void); +int zboot_go(struct bootm_info *bmi); /** * load_zimage() - Load a zImage or bzImage @@ -104,6 +104,7 @@ int setup_zimage(struct boot_params *setup_base, char *cmd_line, int auto_boot, * * Record information about a zimage so it can be booted * + * @bmi: Bootm information * @bzimage_addr: Address of the bzImage to boot * @bzimage_size: Size of the bzImage, or 0 to detect this * @initrd_addr: Address of the initial ramdisk, or 0 if none @@ -114,14 +115,17 @@ int setup_zimage(struct boot_params *setup_base, char *cmd_line, int auto_boot, * @cmdline: Environment variable containing the 'override' command line, or * NULL to use the one in the setup block */ -void zboot_start(ulong bzimage_addr, ulong bzimage_size, ulong initrd_addr, - ulong initrd_size, ulong base_addr, const char *cmdline); +void zboot_start(struct bootm_info *bmi, ulong bzimage_addr, ulong bzimage_size, + ulong initrd_addr, ulong initrd_size, ulong base_addr, + const char *cmdline); /** * zboot_info() - Show simple info about a zimage * - * Shows wherer the kernel was loaded and also the setup base + * Shows where the kernel was loaded and also the setup base + * + * @bmi: Bootm information */ -void zboot_info(void); +void zboot_info(struct bootm_info *bmi); #endif diff --git a/arch/x86/lib/zimage.c b/arch/x86/lib/zimage.c index 1afd3084144..fb69d0ef561 100644 --- a/arch/x86/lib/zimage.c +++ b/arch/x86/lib/zimage.c @@ -55,9 +55,6 @@ DECLARE_GLOBAL_DATA_PTR; #define COMMAND_LINE_SIZE 2048 -/* Current state of the boot */ -struct bootm_info bmi; - static void build_command_line(char *command_line, int auto_boot) { char *env_command_line; @@ -366,13 +363,13 @@ int setup_zimage(struct boot_params *setup_base, char *cmd_line, int auto_boot, return 0; } -int zboot_load(void) +int zboot_load(struct bootm_info *bmi) { struct boot_params *base_ptr; int ret; - if (bmi.base_ptr) { - struct boot_params *from = (struct boot_params *)bmi.base_ptr; + if (bmi->base_ptr) { + struct boot_params *from = (struct boot_params *)bmi->base_ptr; base_ptr = (struct boot_params *)DEFAULT_SETUP_BASE; log_debug("Building boot_params at 0x%8.8lx\n", @@ -380,41 +377,41 @@ int zboot_load(void) memset(base_ptr, '\0', sizeof(*base_ptr)); base_ptr->hdr = from->hdr; } else { - base_ptr = load_zimage((void *)bmi.bzimage_addr, bmi.bzimage_size, - &bmi.load_address); + base_ptr = load_zimage((void *)bmi->bzimage_addr, + bmi->bzimage_size, &bmi->load_address); if (!base_ptr) { puts("## Kernel loading failed ...\n"); return -EINVAL; } } - bmi.base_ptr = base_ptr; + bmi->base_ptr = base_ptr; - ret = env_set_hex("zbootbase", map_to_sysmem(bmi.base_ptr)); + ret = env_set_hex("zbootbase", map_to_sysmem(bmi->base_ptr)); if (!ret) - ret = env_set_hex("zbootaddr", bmi.load_address); + ret = env_set_hex("zbootaddr", bmi->load_address); if (ret) return ret; return 0; } -int zboot_setup(void) +int zboot_setup(struct bootm_info *bmi) { - struct boot_params *base_ptr = bmi.base_ptr; + struct boot_params *base_ptr = bmi->base_ptr; int ret; ret = setup_zimage(base_ptr, (char *)base_ptr + COMMAND_LINE_OFFSET, - 0, bmi.initrd_addr, bmi.initrd_size, - (ulong)bmi.cmdline); + 0, bmi->initrd_addr, bmi->initrd_size, + (ulong)bmi->cmdline); if (ret) return -EINVAL; return 0; } -int zboot_go(void) +int zboot_go(struct bootm_info *bmi) { - struct boot_params *params = bmi.base_ptr; + struct boot_params *params = bmi->base_ptr; struct setup_header *hdr = ¶ms->hdr; bool image_64bit; ulong entry; @@ -422,7 +419,7 @@ int zboot_go(void) disable_interrupts(); - entry = bmi.load_address; + entry = bmi->load_address; image_64bit = false; if (IS_ENABLED(CONFIG_X86_RUN_64BIT) && (hdr->xloadflags & XLF_KERNEL_64)) { @@ -431,7 +428,7 @@ int zboot_go(void) } /* we assume that the kernel is in place */ - ret = boot_linux_kernel((ulong)bmi.base_ptr, entry, image_64bit); + ret = boot_linux_kernel((ulong)bmi->base_ptr, entry, image_64bit); return ret; } @@ -439,16 +436,18 @@ int zboot_go(void) int zboot_run_args(ulong addr, ulong size, ulong initrd, ulong initrd_size, ulong base, char *cmdline) { + struct bootm_info bmi; int ret; - zboot_start(addr, size, initrd, initrd_size, base, cmdline); - ret = zboot_load(); + bootm_init(&bmi); + zboot_start(&bmi, addr, size, initrd, initrd_size, base, cmdline); + ret = zboot_load(&bmi); if (ret) return log_msg_ret("ld", ret); - ret = zboot_setup(); + ret = zboot_setup(&bmi); if (ret) return log_msg_ret("set", ret); - ret = zboot_go(); + ret = zboot_go(&bmi); if (ret) return log_msg_ret("go", ret); @@ -556,7 +555,8 @@ static void show_loader(struct setup_header *hdr) printf("\n"); } -void zimage_dump(struct boot_params *base_ptr, bool show_cmdline) +void zimage_dump(struct bootm_info *bmi, struct boot_params *base_ptr, + bool show_cmdline) { struct setup_header *hdr; const char *version; @@ -597,7 +597,7 @@ void zimage_dump(struct boot_params *base_ptr, bool show_cmdline) print_num("Start sys seg", hdr->start_sys_seg); print_num("Kernel version", hdr->kernel_version); version = zimage_get_kernel_version(base_ptr, - (void *)bmi.bzimage_addr); + (void *)bmi->bzimage_addr); if (version) printf(" @%p: %s\n", version, version); print_num("Type of loader", hdr->type_of_loader); @@ -640,25 +640,24 @@ void zimage_dump(struct boot_params *base_ptr, bool show_cmdline) print_num("Kernel info offset", hdr->kernel_info_offset); } -void zboot_start(ulong bzimage_addr, ulong bzimage_size, ulong initrd_addr, - ulong initrd_size, ulong base_addr, const char *cmdline) +void zboot_start(struct bootm_info *bmi, ulong bzimage_addr, ulong bzimage_size, + ulong initrd_addr, ulong initrd_size, ulong base_addr, + const char *cmdline) { - bootm_init(&bmi); - - bmi.bzimage_size = bzimage_size; - bmi.initrd_addr = initrd_addr; - bmi.initrd_size = initrd_size; + bmi->bzimage_size = bzimage_size; + bmi->initrd_addr = initrd_addr; + bmi->initrd_size = initrd_size; if (base_addr) { - bmi.base_ptr = map_sysmem(base_addr, 0); - bmi.load_address = bzimage_addr; + bmi->base_ptr = map_sysmem(base_addr, 0); + bmi->load_address = bzimage_addr; } else { - bmi.bzimage_addr = bzimage_addr; + bmi->bzimage_addr = bzimage_addr; } - bmi.cmdline = cmdline; + bmi->cmdline = cmdline; } -void zboot_info(void) +void zboot_info(struct bootm_info *bmi) { printf("Kernel loaded at %08lx, setup_base=%p\n", - bmi.load_address, bmi.base_ptr); + bmi->load_address, bmi->base_ptr); } diff --git a/cmd/bootflow.c b/cmd/bootflow.c index 5668a0c9b19..5ab322ef00d 100644 --- a/cmd/bootflow.c +++ b/cmd/bootflow.c @@ -381,7 +381,10 @@ static int do_bootflow_info(struct cmd_tbl *cmdtp, int flag, int argc, bflow = std->cur_bootflow; if (IS_ENABLED(CONFIG_X86) && x86_setup) { - zimage_dump(bflow->x86_setup, false); + struct bootm_info bmi; + + bootm_init(&bmi); + zimage_dump(&bmi, bflow->x86_setup, false); return 0; } diff --git a/cmd/x86/zboot.c b/cmd/x86/zboot.c index 0d0a8e53172..029ff4eb9fd 100644 --- a/cmd/x86/zboot.c +++ b/cmd/x86/zboot.c @@ -13,6 +13,9 @@ #include #include +/* Current state of the boot */ +static struct bootm_info bmi; + static int do_zboot_start(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { @@ -21,6 +24,8 @@ static int do_zboot_start(struct cmd_tbl *cmdtp, int flag, int argc, ulong base_addr; int i; + bootm_init(&bmi); + log_debug("argc %d:", argc); for (i = 0; i < argc; i++) log_debug(" %s", argv[i]); @@ -36,7 +41,7 @@ static int do_zboot_start(struct cmd_tbl *cmdtp, int flag, int argc, base_addr = argc > 5 ? hextoul(argv[5], NULL) : 0; cmdline = argc > 6 ? env_get(argv[6]) : NULL; - zboot_start(bzimage_addr, bzimage_size, initrd_addr, initrd_size, + zboot_start(&bmi, bzimage_addr, bzimage_size, initrd_addr, initrd_size, base_addr, cmdline); return 0; @@ -47,7 +52,7 @@ static int do_zboot_load(struct cmd_tbl *cmdtp, int flag, int argc, { int ret; - ret = zboot_load(); + ret = zboot_load(&bmi); if (ret) return ret; @@ -61,12 +66,13 @@ static int do_zboot_setup(struct cmd_tbl *cmdtp, int flag, int argc, printf("base is not set: use 'zboot load' first\n"); return CMD_RET_FAILURE; } - if (zboot_setup()) { + + if (zboot_setup(&bmi)) { puts("Setting up boot parameters failed ...\n"); return CMD_RET_FAILURE; } - if (zboot_setup()) + if (zboot_setup(&bmi)) return CMD_RET_FAILURE; return 0; @@ -75,7 +81,7 @@ static int do_zboot_setup(struct cmd_tbl *cmdtp, int flag, int argc, static int do_zboot_info(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { - zboot_info(); + zboot_info(&bmi); return 0; } @@ -85,7 +91,7 @@ static int do_zboot_go(struct cmd_tbl *cmdtp, int flag, int argc, { int ret; - ret = zboot_go(); + ret = zboot_go(&bmi); if (ret) { printf("Kernel returned! (err=%d)\n", ret); return CMD_RET_FAILURE; @@ -105,7 +111,7 @@ static int do_zboot_dump(struct cmd_tbl *cmdtp, int flag, int argc, printf("No zboot setup_base\n"); return CMD_RET_FAILURE; } - zimage_dump(base_ptr, true); + zimage_dump(&bmi, base_ptr, true); return 0; } diff --git a/include/bootm.h b/include/bootm.h index 5fa9761629e..fe7f80b88a5 100644 --- a/include/bootm.h +++ b/include/bootm.h @@ -92,6 +92,8 @@ struct bootm_info { /** * bootm_init() - Set up a bootm_info struct with useful defaults * + * @bmi: Bootm information + * * Set up the struct with default values for all members: * @boot_progress is set to true and @images is set to the global images * variable. Everything else is set to NULL except @argc which is 0 @@ -107,7 +109,7 @@ void bootm_init(struct bootm_info *bmi); * - disabled interrupts. * * @flag: Flags indicating what to do (BOOTM_STATE_...) - * bmi: Bootm information + * @bmi: Bootm information * Return: 1 on error. On success the OS boots so this function does * not return. */ @@ -340,11 +342,13 @@ const char *zimage_get_kernel_version(struct boot_params *params, * * This shows all available information in a zimage that has been loaded. * + * @bmi: Bootm information * @base_ptr: Pointer to the boot parameters, typically at address * DEFAULT_SETUP_BASE * @show_cmdline: true to show the full command line */ -void zimage_dump(struct boot_params *base_ptr, bool show_cmdline); +void zimage_dump(struct bootm_info *bmi, struct boot_params *base_ptr, + bool show_cmdline); /* * bootm_boot_start() - Boot an image at the given address From patchwork Fri Dec 6 02:35:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2019035 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=Lc+ZVQVx; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Y4Fm207dwz1yRL for ; Fri, 6 Dec 2024 13:37:37 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id A9AE88960A; Fri, 6 Dec 2024 03:36:57 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="Lc+ZVQVx"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 2080E89672; Fri, 6 Dec 2024 03:36:56 +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=-5.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-il1-x130.google.com (mail-il1-x130.google.com [IPv6:2607:f8b0:4864:20::130]) (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 8E62B8965C for ; Fri, 6 Dec 2024 03:36:53 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-il1-x130.google.com with SMTP id e9e14a558f8ab-3a8034f24a8so12795375ab.2 for ; Thu, 05 Dec 2024 18:36:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1733452611; x=1734057411; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=iE/ALBq6nkn1t/ePNsMu0Kga7vDUwmojevVesuygxq8=; b=Lc+ZVQVxwENRVnn0k12UQVqEuXvr+It+p+txTEBRdEbxiMRjCGtzSmviUndH6pnaVi AKsvMASR3Q8YL0G03pyvZhlST9H6bciUfLvI9tkESz2iSxcOIu0t6uKJFSPG28ugB8jB BPd3GddDDuzP4yh8kr19yxh9xnmk6kxRfxme8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733452611; x=1734057411; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=iE/ALBq6nkn1t/ePNsMu0Kga7vDUwmojevVesuygxq8=; b=a1VWN5c9itfQAbFUmSbTpybHVi8MtuoPMdE7x2PFRpzrmhoa4pq8JBb7SLhi8aU0EO jCX3Rs9pER6fNN+45kQTceijUqOdbJhZDLmlFYLpe5w4vBleDNuegIA/PMBeIYBPLmOr lgkx+8P3GT+iFAuiCr8NT1VpAaetMgD13LsZvVDEZdS3Ejf2GINVbudsCsMP8Lsqogni IzMAfGBFlJI9d3SRjYuQDz8bdyV4msluVmK5GU3aDXYx0XO9QFoo8+yhG/xD8fhFZ1Vo m2elul8mcbf8W0xSPbA/NGLXfcDdo1QuZC5Iqr7jH8ujnDuykhwup/N6UrOXfVvbQ6gh t7tQ== X-Gm-Message-State: AOJu0YxNSHHW4c1X0sg5ahcz9PCJwiR62BX422+fjOsWHG6yJdSXL7ag 3mHKUnt7jzIkuo9OF8Cwq9FnuPtIwpTe6HlW8qnvV3uZ+2n6JiLc+jQHetltcJZEUzIf+zju/qE = X-Gm-Gg: ASbGncvpnsTiL9Rg5W1DFlONlBhFYauK0TxQzEZDJZnkOsc37mZrxBu2MvMqYwVaj3N YEbAy6rz20YZ7eKeF18m2RaaXVo7yHm8mULLpBbgHCKgqPUigYtVPRSY8SjguxW7F7x7QyLqWkX DS97DFM0TtQjJntpapqNFmZRBd60ozZn+QULE/bKgEYCcYGiprlboCaWAWFqKeSoBfX/S+XNeGe 2R//cUr02JYTZL2/hQqNcZTeeXHxMbvko9BYwmqOhNG0nCa7HQlvE1IYNsuJ3N/YyVriRgwW1Uh R9nDO9VB1tA= X-Google-Smtp-Source: AGHT+IFq38z8i1P9zZGldvCucpc2QWXV24YLt052mF7gLtqnRpzyNti+eEAo8rpbkP7NqV0Dp2cUAw== X-Received: by 2002:a05:6e02:1389:b0:3a7:87f2:b00e with SMTP id e9e14a558f8ab-3a811e28220mr18385085ab.19.1733452611250; Thu, 05 Dec 2024 18:36:51 -0800 (PST) Received: from chromium.org (c-73-203-119-151.hsd1.co.comcast.net. [73.203.119.151]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4e2861f51bfsm575506173.112.2024.12.05.18.36.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Dec 2024 18:36:49 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Simon Glass , Bin Meng , Heinrich Schuchardt Subject: [PATCH v3 07/46] bootstd: Correct display of kernel version Date: Thu, 5 Dec 2024 19:35:46 -0700 Message-Id: <20241206023626.2456858-8-sjg@chromium.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241206023626.2456858-1-sjg@chromium.org> References: <20241206023626.2456858-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.103.8 at phobos.denx.de X-Virus-Status: Clean The address of the bzImage is not recorded in the bootflow, so we cannot actually locate the version at present. Handle this case, to avoid showing invalid data. Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- (no changes since v1) arch/x86/lib/zimage.c | 13 ++++++++----- cmd/bootflow.c | 2 ++ 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/arch/x86/lib/zimage.c b/arch/x86/lib/zimage.c index fb69d0ef561..d74c404464c 100644 --- a/arch/x86/lib/zimage.c +++ b/arch/x86/lib/zimage.c @@ -559,7 +559,6 @@ void zimage_dump(struct bootm_info *bmi, struct boot_params *base_ptr, bool show_cmdline) { struct setup_header *hdr; - const char *version; int i; printf("Setup located at %p:\n\n", base_ptr); @@ -596,10 +595,14 @@ void zimage_dump(struct bootm_info *bmi, struct boot_params *base_ptr, print_num("Real mode switch", hdr->realmode_swtch); print_num("Start sys seg", hdr->start_sys_seg); print_num("Kernel version", hdr->kernel_version); - version = zimage_get_kernel_version(base_ptr, - (void *)bmi->bzimage_addr); - if (version) - printf(" @%p: %s\n", version, version); + if (bmi->bzimage_addr) { + const char *version; + + version = zimage_get_kernel_version(base_ptr, + (void *)bmi->bzimage_addr); + if (version) + printf(" @%p: %s\n", version, version); + } print_num("Type of loader", hdr->type_of_loader); show_loader(hdr); print_num("Load flags", hdr->loadflags); diff --git a/cmd/bootflow.c b/cmd/bootflow.c index 5ab322ef00d..b3b78bebaed 100644 --- a/cmd/bootflow.c +++ b/cmd/bootflow.c @@ -384,6 +384,8 @@ static int do_bootflow_info(struct cmd_tbl *cmdtp, int flag, int argc, struct bootm_info bmi; bootm_init(&bmi); + /* we don't know this at present */ + bootm_x86_set(&bmi, bzimage_addr, 0); zimage_dump(&bmi, bflow->x86_setup, false); return 0; From patchwork Fri Dec 6 02:35:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2019036 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=meWxS7H/; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Y4FmC15bmz1yRL for ; Fri, 6 Dec 2024 13:37:47 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 0DE488967B; Fri, 6 Dec 2024 03:36:59 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="meWxS7H/"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 8F0548965E; Fri, 6 Dec 2024 03:36:58 +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=-5.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-il1-x12c.google.com (mail-il1-x12c.google.com [IPv6:2607:f8b0:4864:20::12c]) (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 1C7EB896A0 for ; Fri, 6 Dec 2024 03:36:55 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-il1-x12c.google.com with SMTP id e9e14a558f8ab-3a81324bbdcso2357895ab.1 for ; Thu, 05 Dec 2024 18:36:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1733452613; x=1734057413; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=r+z7xhHs6Fff2kbi3oQStxxohtKhNJ050PabMj88Bb4=; b=meWxS7H/9V8MYIPBAuwchkdP696OWivSu0J5yNHIYWlePtFda1tmS5Cai4R/tsEcu8 STUypAB43KhLK/M4AmybhK98TxKfaSKFAK1OvpDRq3nyLIFbPuelTp/+a+OVX7IzLrYV oYQXhstn+IUsCS8WmnK/jKcuNqCBkiGSQkh8A= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733452613; x=1734057413; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=r+z7xhHs6Fff2kbi3oQStxxohtKhNJ050PabMj88Bb4=; b=AHWm7xZn6Efk/WWr382L8fqVaDzdJqhOmjJuc5AMFKKIqdXEwotThW3z7qwwldZ8kh TCSsbRV/BBmdOppZlcsHU6IKIok2mZNo9Wgp+6O9FE3MLzCfC5NpZCzwmJ7o9yFhFm98 yDQIpX4Aio4IlsI1vM8TrDr+FSEXGjSQcMi+cz6Maq4YynlNLKZsw4FS94FGXlfzWXyN tqYqCPenxrsj768YKV8fxlbSXpBXfwUYOvkv7G2W/OWvBHygZwaHlakHTBafcKLSOARM 7XM/K1d1etb56KW08nnXGZrrZv0yE7ndYF7Wr8JvrIFhOKSWRYx40xExX/MUIK/SM+LO j2kA== X-Gm-Message-State: AOJu0Yw1B1WxA9EbOgHTz4CeL48i/1sPYRkiGQ8JMWM3vw9b00dAHiXX KclBhofq/HrF1LOAlmbjJUzmjHSEAHUy7ZADSOrI0ADLKVRUa9/bFB0/mg/PaAG96s0AXa4nnWo = X-Gm-Gg: ASbGncvK45EIXtBAoPnV9eZ034g7UOzLbW4eEaNMwjUpzxkpUM6r01fR/XXwh7djqvD 428OOSNGw4XKF55wt4EubgNFM1Tco6TFpW6E96tDobTpyaHIehdKF02WdMfv4nsvY8E9vY8M/8d FNSVlGT4M0bOwcvMh3pdcrMk9bbPUcUwlDittjX0MCcuc+Nm08PY8a19KjbK9Fq3KYrfDQgVuwn M913UWoQB5lKBTw3KcmJongu8/3UmPdXgq8+U9TnIyGoxU30VhYqwPVrlRyz5+IJzE9+oFJUrdr 4ObMW/vYrMU= X-Google-Smtp-Source: AGHT+IFUq2liH6RDEVKFsTu/lsSHLI6521ae9bXoFwnMbSg3iRqizUWS6nk5dAecT00uMqFooeKMlQ== X-Received: by 2002:a05:6e02:19c6:b0:3a7:6e97:9877 with SMTP id e9e14a558f8ab-3a811e3e7b3mr18548085ab.24.1733452613328; Thu, 05 Dec 2024 18:36:53 -0800 (PST) Received: from chromium.org (c-73-203-119-151.hsd1.co.comcast.net. [73.203.119.151]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4e2861f51bfsm575506173.112.2024.12.05.18.36.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Dec 2024 18:36:52 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Simon Glass , Bin Meng , Heinrich Schuchardt Subject: [PATCH v3 08/46] x86: Drop the unnecessary base_ptr argument to zboot_dump() Date: Thu, 5 Dec 2024 19:35:47 -0700 Message-Id: <20241206023626.2456858-9-sjg@chromium.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241206023626.2456858-1-sjg@chromium.org> References: <20241206023626.2456858-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.103.8 at phobos.denx.de X-Virus-Status: Clean This value is include the bootm_info, so drop the unnecessary parameter. Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- (no changes since v1) arch/x86/lib/zimage.c | 5 +++-- cmd/bootflow.c | 3 ++- cmd/x86/zboot.c | 8 +++----- include/bootm.h | 7 ++----- 4 files changed, 10 insertions(+), 13 deletions(-) diff --git a/arch/x86/lib/zimage.c b/arch/x86/lib/zimage.c index d74c404464c..4dfcde68060 100644 --- a/arch/x86/lib/zimage.c +++ b/arch/x86/lib/zimage.c @@ -555,12 +555,13 @@ static void show_loader(struct setup_header *hdr) printf("\n"); } -void zimage_dump(struct bootm_info *bmi, struct boot_params *base_ptr, - bool show_cmdline) +void zimage_dump(struct bootm_info *bmi, bool show_cmdline) { + struct boot_params *base_ptr; struct setup_header *hdr; int i; + base_ptr = bmi->base_ptr; printf("Setup located at %p:\n\n", base_ptr); print_num64("ACPI RSDP addr", base_ptr->acpi_rsdp_addr); diff --git a/cmd/bootflow.c b/cmd/bootflow.c index b3b78bebaed..a89c3bfd9c5 100644 --- a/cmd/bootflow.c +++ b/cmd/bootflow.c @@ -386,7 +386,8 @@ static int do_bootflow_info(struct cmd_tbl *cmdtp, int flag, int argc, bootm_init(&bmi); /* we don't know this at present */ bootm_x86_set(&bmi, bzimage_addr, 0); - zimage_dump(&bmi, bflow->x86_setup, false); + bootm_x86_set(&bmi, base_ptr, bflow->x86_setup); + zimage_dump(&bmi, false); return 0; } diff --git a/cmd/x86/zboot.c b/cmd/x86/zboot.c index 029ff4eb9fd..ee099ca041b 100644 --- a/cmd/x86/zboot.c +++ b/cmd/x86/zboot.c @@ -103,15 +103,13 @@ static int do_zboot_go(struct cmd_tbl *cmdtp, int flag, int argc, static int do_zboot_dump(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { - struct boot_params *base_ptr = bmi.base_ptr; - if (argc > 1) - base_ptr = (void *)hextoul(argv[1], NULL); - if (!base_ptr) { + bmi.base_ptr = (void *)hextoul(argv[1], NULL); + if (!bmi.base_ptr) { printf("No zboot setup_base\n"); return CMD_RET_FAILURE; } - zimage_dump(&bmi, base_ptr, true); + zimage_dump(&bmi, true); return 0; } diff --git a/include/bootm.h b/include/bootm.h index fe7f80b88a5..c471615b08c 100644 --- a/include/bootm.h +++ b/include/bootm.h @@ -342,13 +342,10 @@ const char *zimage_get_kernel_version(struct boot_params *params, * * This shows all available information in a zimage that has been loaded. * - * @bmi: Bootm information - * @base_ptr: Pointer to the boot parameters, typically at address - * DEFAULT_SETUP_BASE + * @bmi: Bootm information, with valid base_ptr * @show_cmdline: true to show the full command line */ -void zimage_dump(struct bootm_info *bmi, struct boot_params *base_ptr, - bool show_cmdline); +void zimage_dump(struct bootm_info *bmi, bool show_cmdline); /* * bootm_boot_start() - Boot an image at the given address From patchwork Fri Dec 6 02:35:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2019037 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=Na/XZfsy; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Y4FmN0nHhz1yRL for ; Fri, 6 Dec 2024 13:37:56 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 6818C89641; Fri, 6 Dec 2024 03:37:01 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="Na/XZfsy"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id B6A32895DE; Fri, 6 Dec 2024 03:37:00 +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=-5.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-io1-xd2e.google.com (mail-io1-xd2e.google.com [IPv6:2607:f8b0:4864:20::d2e]) (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 944F589645 for ; Fri, 6 Dec 2024 03:36:58 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-io1-xd2e.google.com with SMTP id ca18e2360f4ac-843e9db3e65so61409939f.1 for ; Thu, 05 Dec 2024 18:36:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1733452616; x=1734057416; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=fJSkpd111H9dx5eXhCnd/ejEAIAyryOgeVfjxtaJjmw=; b=Na/XZfsyVijpUVGPfhilVYJYX3LYcOUbWCupVREvWS3rTRJi2E6EtCch+hokMctJq7 dJVpdQqGTjsnsIeHcdJgD/Y8nbOBm7RmiMZqZ1g9PcIZ+VT+82JT8JBiKB0KUlEvuHZY Jez3ORU1cZTSuJvKZxiBfIOeqZ3aignAdOMQs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733452616; x=1734057416; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=fJSkpd111H9dx5eXhCnd/ejEAIAyryOgeVfjxtaJjmw=; b=wpf9poquWwOyCj3U+iYrq8JKlLqllhwPG7KLGa9VZOwIozIQ/49fYHtpTI1w6NxSVr R37I8CzSeLwzBFiKWDZI56c9sgs+zE0AalJClWOKsB9aQZB29l9Yajtg4AuuYSnLDtgB 8wdLIbml85Yrmk9u7WizTLm/+ALW/TctU3lIe5Z5b0bsqD7wWqWRACT37dybrLIDLUJ4 LawqFlkBruOws3/g5o1+4yZGFlhNyi12VtS35f8cn4vUjAsJdN8pTSbs+GM7J93IlvWf 8q0TsF95SdzqBCnR43boKTC+7FRK6Bl27DRuqZxEpS4J1mpGDbNO7CKzKAJNMkHfJNGy SNZQ== X-Gm-Message-State: AOJu0Ywf/u/OgxCAZJmPogakZfWFAbjENRvqhjHJIbI/XfxbfX6DC416 llfqcOynF7ulnLMnm4hmsCod81Zoj7jnF0dFZ+bpYjTC7aXAo7+BaH7RreLXfaQURGMChwMtmdw = X-Gm-Gg: ASbGncsEyEvKE0BDW9fiulA0mjSqfaWlATPUTP5PS3kvSl1dGYB6GZNhMVhF4Piyzuq 7/IzRzX8m8mwyZKC+2J+Yel8961WY9qV6B3pjC/jkHKNpUs/lbHadEruLBKuezIdhOjnOp7Xk65 xs3jNkt79MhL4G6Bp9ipr0n2oSpBUpqa8aTMBgfE3YVlvDs8+/jU3tVaI0R3eQZhmk7zc0yBTwn kh8d6LHLxxmvwxJ7zN276KMhwHyUfRcxsUexTBocQ1P4Pc0u7HTtUWi4axytkKMLBJPgfX5zhO1 JEYprxFdH5c= X-Google-Smtp-Source: AGHT+IHgBydP1q23uaYlu2q4xXQF4gyl/Fm6pB5mQ6qIjpib+8i3QtNqbL420Qk/L3VJuxbavPIu2w== X-Received: by 2002:a5d:948c:0:b0:841:ab27:acac with SMTP id ca18e2360f4ac-8447104d95bmr574088639f.2.1733452616305; Thu, 05 Dec 2024 18:36:56 -0800 (PST) Received: from chromium.org (c-73-203-119-151.hsd1.co.comcast.net. [73.203.119.151]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4e2861f51bfsm575506173.112.2024.12.05.18.36.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Dec 2024 18:36:54 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Simon Glass , Marek Vasut , Martyn Welch , Michael Trimarchi , Quentin Schulz Subject: [PATCH v3 09/46] boot: Use strlcpy() in label_boot() Date: Thu, 5 Dec 2024 19:35:48 -0700 Message-Id: <20241206023626.2456858-10-sjg@chromium.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241206023626.2456858-1-sjg@chromium.org> References: <20241206023626.2456858-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.103.8 at phobos.denx.de X-Virus-Status: Clean This function is recommended instead of strncpy() since it always terminates the string. Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- (no changes since v2) Changes in v2: - Split out strlcpy() change into new patch boot/pxe_utils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/boot/pxe_utils.c b/boot/pxe_utils.c index 82f217aaf86..e96935896a9 100644 --- a/boot/pxe_utils.c +++ b/boot/pxe_utils.c @@ -558,7 +558,7 @@ static int label_boot(struct pxe_context *ctx, struct pxe_label *label) } if (label->append) - strncpy(bootargs, label->append, sizeof(bootargs)); + strlcpy(bootargs, label->append, sizeof(bootargs)); strcat(bootargs, ip_str); strcat(bootargs, mac_str); From patchwork Fri Dec 6 02:35:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2019038 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=i8rqyVhN; dkim-atps=neutral Authentication-Results: legolas.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=patchwork.ozlabs.org) 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 ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Y4FmY4Z8Hz1yRL for ; Fri, 6 Dec 2024 13:38:05 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id BC38889620; Fri, 6 Dec 2024 03:37:04 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="i8rqyVhN"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 16CF3896F0; Fri, 6 Dec 2024 03:37:03 +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=-5.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-io1-xd2a.google.com (mail-io1-xd2a.google.com [IPv6:2607:f8b0:4864:20::d2a]) (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 87C7C8918C for ; Fri, 6 Dec 2024 03:37:00 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-io1-xd2a.google.com with SMTP id ca18e2360f4ac-841d8dec20aso47352539f.3 for ; Thu, 05 Dec 2024 18:37:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1733452619; x=1734057419; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=P4Q+9Gx2dZF7mM8FeUKiotIgp09hkVbxwm7NQoue2/I=; b=i8rqyVhNRRuzZbU4Sio2fu76MIY6sENAjOLsdvUiMPduSMuKb1GrscWAwMyuVxGsKt E4xp3Hzhn6TDVajzmsyKFWOyjGzGOhhDDf90gnLlMlHhdf2UrD9RBNWKKF2yMFNil7f9 cVFyNhDd+PLEexn+w6mWKasikdS+fGMCs3jvM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733452619; x=1734057419; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=P4Q+9Gx2dZF7mM8FeUKiotIgp09hkVbxwm7NQoue2/I=; b=fKlyEDs0XEfVJzbW8tNdCnFXZXHtgcIzpb+SY5uNuiae8AxE8yoJXRaWwgZ4/t/8wL QVVvxvlwElDrQ/KW8U9a6HZCFG626GlEm7IvBt35KUsR4QrKxks7OCNA4kcXMxsWjxNL XnSzoTLX6tNvZqGM5+Xt7fFdBMX0poyNA1ajNbYukYYSGLUUJ/7a0Z6/c8I/ZCtDMhOv 43E+PD4Rax4qKo1MqW68XZWT3k8+wFnLIMKNUKRK5KBy7kfa3PGJKQ9m1oDzvWUA+xol qh3g7raxmxgpnfanZXzTxCkVBjCQMWpNZKlXqUqm50a8QWozK/nwMKAFgIRwdvpziieV G9mA== X-Gm-Message-State: AOJu0Yw2jvKZRVCb8peOGJzQvQowsMpE+E+3s9qWrasRNTbajms/BfBW GW5rHMtRlNPzpbCasmaf0mX9tPFLk0ETjxxvOy5icyjRdIX1A2uZAt0XbSWeOo3qahzIo6RTc6k = X-Gm-Gg: ASbGncvqrBJSOIqR5cKJE9UFcClBDdKoca/AKjDOVDhacBDIIX7H584YkPKb/a0Qkx5 FCXH14OBLQSvi+u1D+aTYdZDb6C7jyTp3o9Zj5ygzgdIqfCXO/4d+v26ujxtyFU7s9hMCD1jbX0 b3NbIa09StjmBw87UDKWm+i3rmknUvQCBnSmsETk+79B1PrZn5By2pQ7wTyksN7js58GWQFV1C4 c3io/P07kIc3SoDWyxrGOu6be5eweXl+oGYTACnJENiuaUXWssaXCWbMASkJmD9IT7PZLeF9p0H X7QsTFPhyAM= X-Google-Smtp-Source: AGHT+IHjyDS+juilf8tE20JpTAowspuoPoyDDnhSRQ0djXDzEcjPjWYuWNdOMeDNeK9nC1qfoc1Vjw== X-Received: by 2002:a05:6602:2b01:b0:843:e86b:2467 with SMTP id ca18e2360f4ac-8447e1ff068mr224863239f.1.1733452618677; Thu, 05 Dec 2024 18:36:58 -0800 (PST) Received: from chromium.org (c-73-203-119-151.hsd1.co.comcast.net. [73.203.119.151]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4e2861f51bfsm575506173.112.2024.12.05.18.36.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Dec 2024 18:36:58 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Simon Glass , Quentin Schulz , Marek Vasut , Martyn Welch , Michael Trimarchi Subject: [PATCH v3 10/46] boot: Split pxe label_boot() into two parts Date: Thu, 5 Dec 2024 19:35:49 -0700 Message-Id: <20241206023626.2456858-11-sjg@chromium.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241206023626.2456858-1-sjg@chromium.org> References: <20241206023626.2456858-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.103.8 at phobos.denx.de X-Virus-Status: Clean This function is far too long. Split out the part which builds and runs the bootm/i/z commands into its own function. Add a function comment for the new label_run_boot() function. Signed-off-by: Simon Glass Reviewed-by: Quentin Schulz Signed-off-by: Simon Glass Reviewed-by: Quentin Schulz --- (no changes since v2) Changes in v2: - Move strlcpy() change into an earlier patch - Fix 'initaddr' typo' boot/pxe_utils.c | 284 ++++++++++++++++++++++++++--------------------- 1 file changed, 156 insertions(+), 128 deletions(-) diff --git a/boot/pxe_utils.c b/boot/pxe_utils.c index e96935896a9..fd1a09225e1 100644 --- a/boot/pxe_utils.c +++ b/boot/pxe_utils.c @@ -433,142 +433,29 @@ skip_overlay: #endif /** - * label_boot() - Boot according to the contents of a pxe_label - * - * If we can't boot for any reason, we return. A successful boot never - * returns. - * - * The kernel will be stored in the location given by the 'kernel_addr_r' - * environment variable. - * - * If the label specifies an initrd file, it will be stored in the location - * given by the 'ramdisk_addr_r' environment variable. - * - * If the label specifies an 'append' line, its contents will overwrite that - * of the 'bootargs' environment variable. + * label_run_boot() - Set up the FDT and call the appropriate bootm/z/i command * * @ctx: PXE context * @label: Label to process - * Returns does not return on success, otherwise returns 0 if a localboot - * label was processed, or 1 on error + * @kernel_addr: String containing kernel address (cannot be NULL) + * @initrd_addr_str: String containing initrd address (NULL if none) + * @initrd_filesize: String containing initrd size (only used if + * @initrd_addr_str) + * @initrd_str: initrd string to process (only used if @initrd_addr_str) + * Return: does not return on success, or returns 0 if the boot command + * returned, or -ve error value on error */ -static int label_boot(struct pxe_context *ctx, struct pxe_label *label) +static int label_run_boot(struct pxe_context *ctx, struct pxe_label *label, + char *kernel_addr, char *initrd_addr_str, + char *initrd_filesize, char *initrd_str) { char *bootm_argv[] = { "bootm", NULL, NULL, NULL, NULL }; char *zboot_argv[] = { "zboot", NULL, "0", NULL, NULL }; - char *kernel_addr = NULL; - char *initrd_addr_str = NULL; - char initrd_filesize[10]; - char initrd_str[28]; - char mac_str[29] = ""; - char ip_str[68] = ""; - char *fit_addr = NULL; + ulong kernel_addr_r; int bootm_argc = 2; int zboot_argc = 3; - int len = 0; - ulong kernel_addr_r; void *buf; - label_print(label); - - label->attempted = 1; - - if (label->localboot) { - if (label->localboot_val >= 0) - label_localboot(label); - return 0; - } - - if (!label->kernel) { - printf("No kernel given, skipping %s\n", - label->name); - return 1; - } - - if (get_relfile_envaddr(ctx, label->kernel, "kernel_addr_r", - (enum bootflow_img_t)IH_TYPE_KERNEL, NULL) - < 0) { - printf("Skipping %s for failure retrieving kernel\n", - label->name); - return 1; - } - - kernel_addr = env_get("kernel_addr_r"); - /* for FIT, append the configuration identifier */ - if (label->config) { - int len = strlen(kernel_addr) + strlen(label->config) + 1; - - fit_addr = malloc(len); - if (!fit_addr) { - printf("malloc fail (FIT address)\n"); - return 1; - } - snprintf(fit_addr, len, "%s%s", kernel_addr, label->config); - kernel_addr = fit_addr; - } - - /* For FIT, the label can be identical to kernel one */ - if (label->initrd && !strcmp(label->kernel_label, label->initrd)) { - initrd_addr_str = kernel_addr; - } else if (label->initrd) { - ulong size; - if (get_relfile_envaddr(ctx, label->initrd, "ramdisk_addr_r", - (enum bootflow_img_t)IH_TYPE_RAMDISK, - &size) < 0) { - printf("Skipping %s for failure retrieving initrd\n", - label->name); - goto cleanup; - } - strcpy(initrd_filesize, simple_xtoa(size)); - initrd_addr_str = env_get("ramdisk_addr_r"); - size = snprintf(initrd_str, sizeof(initrd_str), "%s:%lx", - initrd_addr_str, size); - if (size >= sizeof(initrd_str)) - goto cleanup; - } - - if (label->ipappend & 0x1) { - sprintf(ip_str, " ip=%s:%s:%s:%s", - env_get("ipaddr"), env_get("serverip"), - env_get("gatewayip"), env_get("netmask")); - } - - if (IS_ENABLED(CONFIG_CMD_NET)) { - if (label->ipappend & 0x2) { - int err; - - strcpy(mac_str, " BOOTIF="); - err = format_mac_pxe(mac_str + 8, sizeof(mac_str) - 8); - if (err < 0) - mac_str[0] = '\0'; - } - } - - if ((label->ipappend & 0x3) || label->append) { - char bootargs[CONFIG_SYS_CBSIZE] = ""; - char finalbootargs[CONFIG_SYS_CBSIZE]; - - if (strlen(label->append ?: "") + - strlen(ip_str) + strlen(mac_str) + 1 > sizeof(bootargs)) { - printf("bootarg overflow %zd+%zd+%zd+1 > %zd\n", - strlen(label->append ?: ""), - strlen(ip_str), strlen(mac_str), - sizeof(bootargs)); - goto cleanup; - } - - if (label->append) - strlcpy(bootargs, label->append, sizeof(bootargs)); - - strcat(bootargs, ip_str); - strcat(bootargs, mac_str); - - cli_simple_process_macros(bootargs, finalbootargs, - sizeof(finalbootargs)); - env_set("bootargs", finalbootargs); - printf("append: %s\n", finalbootargs); - } - /* * fdt usage is optional: * It handles the following scenarios. @@ -607,6 +494,7 @@ static int label_boot(struct pxe_context *ctx, struct pxe_label *label) } } else if (label->fdtdir) { char *f1, *f2, *f3, *f4, *slash; + int len; f1 = env_get("fdtfile"); if (f1) { @@ -649,7 +537,7 @@ static int label_boot(struct pxe_context *ctx, struct pxe_label *label) fdtfilefree = malloc(len); if (!fdtfilefree) { printf("malloc fail (FDT filename)\n"); - goto cleanup; + return -ENOMEM; } snprintf(fdtfilefree, len, "%s%s%s%s%s%s", @@ -669,7 +557,7 @@ static int label_boot(struct pxe_context *ctx, struct pxe_label *label) if (label->fdt) { printf("Skipping %s for failure retrieving FDT\n", label->name); - goto cleanup; + return -ENOENT; } if (label->fdtdir) { @@ -750,10 +638,150 @@ static int label_boot(struct pxe_context *ctx, struct pxe_label *label) unmap_sysmem(buf); + return 0; +} + +/** + * label_boot() - Boot according to the contents of a pxe_label + * + * If we can't boot for any reason, we return. A successful boot never + * returns. + * + * The kernel will be stored in the location given by the 'kernel_addr_r' + * environment variable. + * + * If the label specifies an initrd file, it will be stored in the location + * given by the 'ramdisk_addr_r' environment variable. + * + * If the label specifies an 'append' line, its contents will overwrite that + * of the 'bootargs' environment variable. + * + * @ctx: PXE context + * @label: Label to process + * Returns does not return on success, otherwise returns 0 if a localboot + * label was processed, or 1 on error + */ +static int label_boot(struct pxe_context *ctx, struct pxe_label *label) +{ + char *kernel_addr = NULL; + char *initrd_addr_str = NULL; + char initrd_filesize[10]; + char initrd_str[28]; + char mac_str[29] = ""; + char ip_str[68] = ""; + char *fit_addr = NULL; + + label_print(label); + + label->attempted = 1; + + if (label->localboot) { + if (label->localboot_val >= 0) + label_localboot(label); + return 0; + } + + if (!label->kernel) { + printf("No kernel given, skipping %s\n", + label->name); + return 1; + } + + if (get_relfile_envaddr(ctx, label->kernel, "kernel_addr_r", + (enum bootflow_img_t)IH_TYPE_KERNEL, NULL) + < 0) { + printf("Skipping %s for failure retrieving kernel\n", + label->name); + return 1; + } + + kernel_addr = env_get("kernel_addr_r"); + /* for FIT, append the configuration identifier */ + if (label->config) { + int len = strlen(kernel_addr) + strlen(label->config) + 1; + + fit_addr = malloc(len); + if (!fit_addr) { + printf("malloc fail (FIT address)\n"); + return 1; + } + snprintf(fit_addr, len, "%s%s", kernel_addr, label->config); + kernel_addr = fit_addr; + } + + /* For FIT, the label can be identical to kernel one */ + if (label->initrd && !strcmp(label->kernel_label, label->initrd)) { + initrd_addr_str = kernel_addr; + } else if (label->initrd) { + ulong size; + int ret; + + ret = get_relfile_envaddr(ctx, label->initrd, "ramdisk_addr_r", + (enum bootflow_img_t)IH_TYPE_RAMDISK, + &size); + if (ret < 0) { + printf("Skipping %s for failure retrieving initrd\n", + label->name); + goto cleanup; + } + strcpy(initrd_filesize, simple_xtoa(size)); + initrd_addr_str = env_get("ramdisk_addr_r"); + size = snprintf(initrd_str, sizeof(initrd_str), "%s:%lx", + initrd_addr_str, size); + if (size >= sizeof(initrd_str)) + goto cleanup; + } + + if (label->ipappend & 0x1) { + sprintf(ip_str, " ip=%s:%s:%s:%s", + env_get("ipaddr"), env_get("serverip"), + env_get("gatewayip"), env_get("netmask")); + } + + if (IS_ENABLED(CONFIG_CMD_NET)) { + if (label->ipappend & 0x2) { + int err; + + strcpy(mac_str, " BOOTIF="); + err = format_mac_pxe(mac_str + 8, sizeof(mac_str) - 8); + if (err < 0) + mac_str[0] = '\0'; + } + } + + if ((label->ipappend & 0x3) || label->append) { + char bootargs[CONFIG_SYS_CBSIZE] = ""; + char finalbootargs[CONFIG_SYS_CBSIZE]; + + if (strlen(label->append ?: "") + + strlen(ip_str) + strlen(mac_str) + 1 > sizeof(bootargs)) { + printf("bootarg overflow %zd+%zd+%zd+1 > %zd\n", + strlen(label->append ?: ""), + strlen(ip_str), strlen(mac_str), + sizeof(bootargs)); + goto cleanup; + } + + if (label->append) + strlcpy(bootargs, label->append, sizeof(bootargs)); + + strcat(bootargs, ip_str); + strcat(bootargs, mac_str); + + cli_simple_process_macros(bootargs, finalbootargs, + sizeof(finalbootargs)); + env_set("bootargs", finalbootargs); + printf("append: %s\n", finalbootargs); + } + + label_run_boot(ctx, label, kernel_addr, initrd_addr_str, + initrd_filesize, initrd_str); + /* ignore the error value since we are going to fail anyway */ + cleanup: free(fit_addr); - return 1; + return 1; /* returning is always failure */ } /** enum token_type - Tokens for the pxe file parser */ From patchwork Fri Dec 6 02:35:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2019040 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=CHgqYQQN; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Y4Fml08hdz1yRL for ; Fri, 6 Dec 2024 13:38:15 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 2411989619; Fri, 6 Dec 2024 03:37:06 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="CHgqYQQN"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 3FA0789690; Fri, 6 Dec 2024 03:37:05 +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=-5.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-io1-xd33.google.com (mail-io1-xd33.google.com [IPv6:2607:f8b0:4864:20::d33]) (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 8327689633 for ; Fri, 6 Dec 2024 03:37:02 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-io1-xd33.google.com with SMTP id ca18e2360f4ac-843df3c4390so50367039f.3 for ; Thu, 05 Dec 2024 18:37:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1733452620; x=1734057420; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=OSy+fxsRG0mtEIT0uW+SL5I6nQiQ4mlB3+Rx4El2O3M=; b=CHgqYQQNTwDNLUYWKe9ClpkVI8xmJVrymtj4PvtzYihsSC8zLUcQ123Z04e42BfSy9 hxNvkgTr2ccjHWkoYSSxHe+43NrgyrW6Sk8Dv/hkoBhxzWM1vAGUN76yvVmpSAr1RhhK /UbevbznLFLZZ2w8zpYQUK8M+LYuRhXBf3QXs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733452620; x=1734057420; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=OSy+fxsRG0mtEIT0uW+SL5I6nQiQ4mlB3+Rx4El2O3M=; b=uXEzfWFRvhkTj8VlxgnVVBR1jkvj1oGDuzWKttNqsORETPw6cLc8cNoPd2svlbiGAX DO30YmZf2CaV3RakkYyI1lw5BKaDk0mJ86Ilso/A1OqqGTluVlhS3PbegFS6bWiapFLM Xmknx5BEPdMIpWoZzuIclrxV4X/85kC9+jh2NlHj5Bt0Z0LXdqlGO0gS7iOszNSaGWh/ fGA5oKnrqwq16oAeTinxLybW/EoaWjZNoeebsaNoigrTzWyRA1Xlz07VOU9kzkol8H7x KuhCdQtMSugP930EorbL1GjdUws4404jndJoz1mSl08a4HVnnlBDRnHRCXs8xQEii8Ot wQ6A== X-Gm-Message-State: AOJu0YyOV1Tp0FuGdkpcRk5yX30Jl0x1UcHHQ7bTwi12MNxB87uKuFxo W3fcRMC2V4M2p/zevFjS8DAKqAxnJheX15gC9iwAtVl3uDD7f3bzLXShzGojJdUrytjgS8cf1Ww = X-Gm-Gg: ASbGnctUAUs+9yFpqnNXKzQKPOo43kb2tnnqO2inFN5N5deEncicqbHXz4Bj4K5R1SB Ad/QyjVL6sWOU7NvZhx//wyyyi6+E0j5X8gbGk/mv0IigOZZcf7VHKskqc9u6cWUwJAEsk/2bnc Ie4BfmB+cbM7A4Q/eBlvf0I1646a5+ufI4HQhmJ1IhEY/+U9x100l8FL+wiV4+3q+IMh21KyvVA mNpHDHzhojepjKWSfUAPBZOGIpVDftSEumxb79GvRDANLkxytEQc7q26x2+sAcCuSDeByfFicWk OxxP04ijveE= X-Google-Smtp-Source: AGHT+IGNLTaTHyGda/iP/7V1Z2vJEcfBk9jGy7s3JlqMyj8u3GINBrWQOysBiVidzcXwhpvFrh5eww== X-Received: by 2002:a05:6602:1610:b0:83a:d039:a721 with SMTP id ca18e2360f4ac-8447e24216emr188461839f.8.1733452620355; Thu, 05 Dec 2024 18:37:00 -0800 (PST) Received: from chromium.org (c-73-203-119-151.hsd1.co.comcast.net. [73.203.119.151]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4e2861f51bfsm575506173.112.2024.12.05.18.36.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Dec 2024 18:36:59 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Simon Glass , Quentin Schulz , Marek Vasut , Martyn Welch , Michael Trimarchi Subject: [PATCH v3 11/46] boot: Split pxe label_run_boot() into two parts Date: Thu, 5 Dec 2024 19:35:50 -0700 Message-Id: <20241206023626.2456858-12-sjg@chromium.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241206023626.2456858-1-sjg@chromium.org> References: <20241206023626.2456858-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.103.8 at phobos.denx.de X-Virus-Status: Clean This function is quite long. Split out the FDT processing into its own function. Add a function comment for the new label_process_fdt() function. Signed-off-by: Simon Glass Reviewed-by: Quentin Schulz Signed-off-by: Simon Glass Reviewed-by: Quentin Schulz --- (no changes since v2) Changes in v2: - Rebase on earlier change boot/pxe_utils.c | 100 ++++++++++++++++++++++++++++------------------- 1 file changed, 60 insertions(+), 40 deletions(-) diff --git a/boot/pxe_utils.c b/boot/pxe_utils.c index fd1a09225e1..a14b4eb54c2 100644 --- a/boot/pxe_utils.c +++ b/boot/pxe_utils.c @@ -432,51 +432,37 @@ skip_overlay: } #endif -/** - * label_run_boot() - Set up the FDT and call the appropriate bootm/z/i command +/* + * label_process_fdt() - Process FDT for the label * * @ctx: PXE context * @label: Label to process - * @kernel_addr: String containing kernel address (cannot be NULL) - * @initrd_addr_str: String containing initrd address (NULL if none) - * @initrd_filesize: String containing initrd size (only used if - * @initrd_addr_str) - * @initrd_str: initrd string to process (only used if @initrd_addr_str) - * Return: does not return on success, or returns 0 if the boot command - * returned, or -ve error value on error + * @kernel_addr: String containing kernel address + * @bootm_argv: bootm arguments to fill in (this only adjusts @bootm_argv[3]) + * Return: 0 if OK, -ENOMEM if out of memory, -ENOENT if FDT file could not be + * loaded + * + * fdt usage is optional: + * It handles the following scenarios. + * + * Scenario 1: If fdt_addr_r specified and "fdt" or "fdtdir" label is + * defined in pxe file, retrieve fdt blob from server. Pass fdt_addr_r to + * bootm, and adjust argc appropriately. + * + * If retrieve fails and no exact fdt blob is specified in pxe file with + * "fdt" label, try Scenario 2. + * + * Scenario 2: If there is an fdt_addr specified, pass it along to + * bootm, and adjust argc appropriately. + * + * Scenario 3: If there is an fdtcontroladdr specified, pass it along to + * bootm, and adjust argc appropriately, unless the image type is fitImage. + * + * Scenario 4: fdt blob is not available. */ -static int label_run_boot(struct pxe_context *ctx, struct pxe_label *label, - char *kernel_addr, char *initrd_addr_str, - char *initrd_filesize, char *initrd_str) +static int label_process_fdt(struct pxe_context *ctx, struct pxe_label *label, + char *kernel_addr, char *bootm_argv[]) { - char *bootm_argv[] = { "bootm", NULL, NULL, NULL, NULL }; - char *zboot_argv[] = { "zboot", NULL, "0", NULL, NULL }; - ulong kernel_addr_r; - int bootm_argc = 2; - int zboot_argc = 3; - void *buf; - - /* - * fdt usage is optional: - * It handles the following scenarios. - * - * Scenario 1: If fdt_addr_r specified and "fdt" or "fdtdir" label is - * defined in pxe file, retrieve fdt blob from server. Pass fdt_addr_r to - * bootm, and adjust argc appropriately. - * - * If retrieve fails and no exact fdt blob is specified in pxe file with - * "fdt" label, try Scenario 2. - * - * Scenario 2: If there is an fdt_addr specified, pass it along to - * bootm, and adjust argc appropriately. - * - * Scenario 3: If there is an fdtcontroladdr specified, pass it along to - * bootm, and adjust argc appropriately, unless the image type is fitImage. - * - * Scenario 4: fdt blob is not available. - */ - bootm_argv[3] = env_get("fdt_addr_r"); - /* For FIT, the label can be identical to kernel one */ if (label->fdt && !strcmp(label->kernel_label, label->fdt)) { bootm_argv[3] = kernel_addr; @@ -578,6 +564,40 @@ static int label_run_boot(struct pxe_context *ctx, struct pxe_label *label, } } + return 0; +} + +/** + * label_run_boot() - Set up the FDT and call the appropriate bootm/z/i command + * + * @ctx: PXE context + * @label: Label to process + * @kernel_addr: String containing kernel address (cannot be NULL) + * @initrd_addr_str: String containing initrd address (NULL if none) + * @initrd_filesize: String containing initrd size (only used if + * @initrd_addr_str) + * @initrd_str: initrd string to process (only used if @initrd_addr_str) + * Return: does not return on success, or returns 0 if the boot command + * returned, or -ve error value on error + */ +static int label_run_boot(struct pxe_context *ctx, struct pxe_label *label, + char *kernel_addr, char *initrd_addr_str, + char *initrd_filesize, char *initrd_str) +{ + char *bootm_argv[] = { "bootm", NULL, NULL, NULL, NULL }; + char *zboot_argv[] = { "zboot", NULL, "0", NULL, NULL }; + ulong kernel_addr_r; + int bootm_argc = 2; + int zboot_argc = 3; + void *buf; + int ret; + + bootm_argv[3] = env_get("fdt_addr_r"); + + ret = label_process_fdt(ctx, label, kernel_addr, bootm_argv); + if (ret) + return ret; + bootm_argv[1] = kernel_addr; zboot_argv[1] = kernel_addr; From patchwork Fri Dec 6 02:35:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2019041 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=jz/HMdVA; dkim-atps=neutral Authentication-Results: legolas.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=patchwork.ozlabs.org) 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 ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Y4Fmy0VCJz1yRL for ; Fri, 6 Dec 2024 13:38:26 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 729D98965E; Fri, 6 Dec 2024 03:37:08 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="jz/HMdVA"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 6D9B0896CC; Fri, 6 Dec 2024 03:37:07 +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=-5.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-il1-x134.google.com (mail-il1-x134.google.com [IPv6:2607:f8b0:4864:20::134]) (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 2A98C8965E for ; Fri, 6 Dec 2024 03:37:05 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-il1-x134.google.com with SMTP id e9e14a558f8ab-3a7a46ca756so5313435ab.0 for ; Thu, 05 Dec 2024 18:37:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1733452623; x=1734057423; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Ze9Dvt2bKqftKJfhqMb0dV2ed/94BZjckOFVhk80tm4=; b=jz/HMdVA3sM14Nttzy/l5GCVQAsI1+w4Lt0D72yYi2cKG3dVK61T8mxE9wYEVc2ImR Xh/dFd8tsp3HXMYc8fyozDeDsaKfyyRCP2bKLTtOghqH4oY8wlFyJc/sspQ5abfDudyW mUmWApgAqL2puxy15nI9SjK+msMAKr1GpIxz0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733452623; x=1734057423; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Ze9Dvt2bKqftKJfhqMb0dV2ed/94BZjckOFVhk80tm4=; b=mBx15zUwtuIiehR0TvxOA0Q1vWVOGfpSKyWagoMTKOXi+/799Y5RvxcGBnOCufOhE8 rUrniMHoYoZXt22JS1WEAaWpU0Zm4MMIGceo7D08Dvwc6WxSMUMMMytJxTAWHoseNCRv 0/tsfD+fMozaKS4WP5yUWmvryhQKsYbVuCL0IiFWBBbXYa4/nQXifacjzGE6eZYpRe+m FLcwso01LfSAmIEWJJlr7Vl1YZtkbmkvnAZZBAdTA2ayoW4GFa3XdmJgymvoU2Dy/sEK avyERgrvTFvSqHyg2v7HtMny3Vou74IgK+ZZeIMTTbjjmvECoKPBTHiw41l2RnnLyc76 A2cA== X-Gm-Message-State: AOJu0YzwYmVS++JtAnFJxCUwY+dL82gaeAS9Rox2LWqg08d/krGKiUL3 qO6pz2EFfk7lAishJ/eXrEZvKhPm3LBZaZE75LTcj00TODycF4HYAhYiCL5mlmSydAY4ksjU/Uc = X-Gm-Gg: ASbGncsaUbu+KpdCR2hSd1ikxf3gCRXV1vOuZvIi2MpPeSsGaHJoAbuiK0DylDCsag6 GKGNXplbA5rDAwDe8I6InbcQjIPL0jrqXlWnWJRMMOKYX+3xSFiqHd4JEsaScnopvEO8iCwxNq4 H3baXBGAkI8v9Ht3Dh/WeB6VCzYsXSbEpW5ifcjNiXAnAtSDjlt/j1oo9lH67mlIEN4GLPUc6Qg nPuPkLiVyrQi7vaDG/HuyTUj6Oz8Z0uir0jU8o2QWXPsTcvk/bmoeYeJ2o53d6zFBurxHYQ4Xj5 3ZJVHehbPCQ= X-Google-Smtp-Source: AGHT+IGHSf0x2NRnxjbV5y0UOJ6LoR42S/Q8J3O+ViVYkg9dFFJHRWFmHysMIRyKcBN0wElAidNJRw== X-Received: by 2002:a05:6e02:1a66:b0:3a7:7ee3:10a2 with SMTP id e9e14a558f8ab-3a811e27d9bmr23533645ab.19.1733452623381; Thu, 05 Dec 2024 18:37:03 -0800 (PST) Received: from chromium.org (c-73-203-119-151.hsd1.co.comcast.net. [73.203.119.151]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4e2861f51bfsm575506173.112.2024.12.05.18.37.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Dec 2024 18:37:02 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Simon Glass , Quentin Schulz , Marek Vasut , Martyn Welch , Michael Trimarchi Subject: [PATCH v3 12/46] boot: Pass just the FDT argument to label_process_fdt() Date: Thu, 5 Dec 2024 19:35:51 -0700 Message-Id: <20241206023626.2456858-13-sjg@chromium.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241206023626.2456858-1-sjg@chromium.org> References: <20241206023626.2456858-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.103.8 at phobos.denx.de X-Virus-Status: Clean Since this function only adjusts one element of the bootm command, pass just that. This will make it easier to refactor things to remove the bootm command. Signed-off-by: Simon Glass Reviewed-by: Quentin Schulz Signed-off-by: Simon Glass Reviewed-by: Quentin Schulz --- (no changes since v1) boot/pxe_utils.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/boot/pxe_utils.c b/boot/pxe_utils.c index a14b4eb54c2..2ada5c4aaac 100644 --- a/boot/pxe_utils.c +++ b/boot/pxe_utils.c @@ -438,7 +438,7 @@ skip_overlay: * @ctx: PXE context * @label: Label to process * @kernel_addr: String containing kernel address - * @bootm_argv: bootm arguments to fill in (this only adjusts @bootm_argv[3]) + * @fdt_argp: bootm argument to fill in, for FDT * Return: 0 if OK, -ENOMEM if out of memory, -ENOENT if FDT file could not be * loaded * @@ -461,13 +461,13 @@ skip_overlay: * Scenario 4: fdt blob is not available. */ static int label_process_fdt(struct pxe_context *ctx, struct pxe_label *label, - char *kernel_addr, char *bootm_argv[]) + char *kernel_addr, char **fdt_argp) { /* For FIT, the label can be identical to kernel one */ if (label->fdt && !strcmp(label->kernel_label, label->fdt)) { - bootm_argv[3] = kernel_addr; + *fdt_argp = kernel_addr; /* if fdt label is defined then get fdt from server */ - } else if (bootm_argv[3]) { + } else if (*fdt_argp) { char *fdtfile = NULL; char *fdtfilefree = NULL; @@ -538,7 +538,7 @@ static int label_process_fdt(struct pxe_context *ctx, struct pxe_label *label, free(fdtfilefree); if (err < 0) { - bootm_argv[3] = NULL; + *fdt_argp = NULL; if (label->fdt) { printf("Skipping %s for failure retrieving FDT\n", @@ -560,7 +560,7 @@ static int label_process_fdt(struct pxe_context *ctx, struct pxe_label *label, label_boot_fdtoverlay(ctx, label); #endif } else { - bootm_argv[3] = NULL; + *fdt_argp = NULL; } } @@ -594,7 +594,7 @@ static int label_run_boot(struct pxe_context *ctx, struct pxe_label *label, bootm_argv[3] = env_get("fdt_addr_r"); - ret = label_process_fdt(ctx, label, kernel_addr, bootm_argv); + ret = label_process_fdt(ctx, label, kernel_addr, &bootm_argv[3]); if (ret) return ret; From patchwork Fri Dec 6 02:35:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2019042 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=AEW7Ess3; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Y4Fn66JVFz1yRL for ; Fri, 6 Dec 2024 13:38:34 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id CE6098971E; Fri, 6 Dec 2024 03:37:10 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="AEW7Ess3"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 88AFE89622; Fri, 6 Dec 2024 03:37:09 +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=-5.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-il1-x129.google.com (mail-il1-x129.google.com [IPv6:2607:f8b0:4864:20::129]) (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 57CEA895DE for ; Fri, 6 Dec 2024 03:37:07 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-il1-x129.google.com with SMTP id e9e14a558f8ab-3a7deec316aso5579645ab.1 for ; Thu, 05 Dec 2024 18:37:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1733452625; x=1734057425; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=OEaE1fphclgQDqzpnHdWb6ml0j7J3NisLCZD8sOxWfU=; b=AEW7Ess30iL/SnjdVcHiEBQb8eA6P/D2MC0IfJt498aJCDB3PLJW0fbpyqScEXXIea WyVbYLKpfFAyynhPLfTc1D33gJQAeNAQtcF7iwbRIJZCrbTlRkCcsluYCLD/JhZDeZ4M zVofC2ChAjH/MiHiJ50xoHn94/A6nxrZRgyn4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733452625; x=1734057425; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=OEaE1fphclgQDqzpnHdWb6ml0j7J3NisLCZD8sOxWfU=; b=S2sEa7Y0aUO2/uVvhYPPH2LA4GK6MASvkNzIZIWMPtF6dMazmg943+rL0jZmlyzur3 UtIym6qLTNawIdii7JFwBK3ZZ3t9kohidNh1XXPhyV5gEWu8bAczVY6rJfYhsrNWEpQe 756SKijUXdMwzoVZpPNgcdPWmcr1ovkhcyIcTeILvyBySCBdxEVviZm+yzXKv035VuDc HNK2P4webnUbgbXNOT8Q2DCf+kmicOXw1N7CrZCsPzHagXS2LCaiBGLSxoetAx8BvJj8 9DkDJs5xN7gNWr2DzdDlChVYQ4gXyIiU5hiCqaemSaVZNY3MAlVrKxN+mRhuuWiU7ufm keVQ== X-Gm-Message-State: AOJu0Yz2oPt/h8pj8OBkimHIpol7maGgh1bjYSvPOptu0+HrL/T2CzaG /h8SSOaHERT15x2Ui2jYvrl9Jo8ZZgtKxEVX6tD1gTcjJ/c3Xj5PHD3Vk1RnOxdiZ5z27/MWV9Y = X-Gm-Gg: ASbGncuKzRJ5Onp5ISvym45s3gsVQYwjrwJpzKXpnVUlWVRY3S/HlOYyBh0nr5ObMf5 NyNBGeej5UCnPa5SxtPNsf1s5mnUlhM4LnV8M6UsSmagDgkVhFoqb5VZ8ojWb0ZLUR/0Cp5XGbK /gD1SXgaMsWXd+H97cTgcyitDpta7HPLI2Fk2qrl9MvSoNQiuVe11NHCNp+lTC9NuAd9Tz0BckW yezjAEUhLASe+PScAWfl4UcxC+n4LccEHos7egPS96HgA85XC7sO5aP/+msKldXq4RuoctlctN+ wf90fWh+XMA= X-Google-Smtp-Source: AGHT+IHfATTvoaIAxBSQ5gih5qElI9Be25LY7FmW4bBbuZQJBJHX+E25Gwvb2dXs8vyLjkOeed66Aw== X-Received: by 2002:a05:6e02:1c8f:b0:3a7:e528:6edd with SMTP id e9e14a558f8ab-3a811db7d25mr20105995ab.12.1733452625545; Thu, 05 Dec 2024 18:37:05 -0800 (PST) Received: from chromium.org (c-73-203-119-151.hsd1.co.comcast.net. [73.203.119.151]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4e2861f51bfsm575506173.112.2024.12.05.18.37.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Dec 2024 18:37:04 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Simon Glass , Quentin Schulz , Ilias Apalodimas , Mattijs Korpershoek , Sughosh Ganu Subject: [PATCH v3 13/46] bootm: Allow building bootm.c without CONFIG_SYS_BOOTM_LEN Date: Thu, 5 Dec 2024 19:35:52 -0700 Message-Id: <20241206023626.2456858-14-sjg@chromium.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241206023626.2456858-1-sjg@chromium.org> References: <20241206023626.2456858-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.103.8 at phobos.denx.de X-Virus-Status: Clean This code cannot be compiled by boards which don't have this option. Add an accessor in the header file to avoid another #ifdef Signed-off-by: Simon Glass Reviewed-by: Quentin Schulz Signed-off-by: Simon Glass Reviewed-by: Quentin Schulz --- (no changes since v1) boot/bootm.c | 8 ++++---- include/bootm.h | 8 ++++++++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/boot/bootm.c b/boot/bootm.c index 16a43d519a8..0a1040ef923 100644 --- a/boot/bootm.c +++ b/boot/bootm.c @@ -633,11 +633,11 @@ static int bootm_load_os(struct bootm_headers *images, int boot_progress) load_buf = map_sysmem(load, 0); image_buf = map_sysmem(os.image_start, image_len); err = image_decomp(os.comp, load, os.image_start, os.type, - load_buf, image_buf, image_len, - CONFIG_SYS_BOOTM_LEN, &load_end); + load_buf, image_buf, image_len, bootm_len(), + &load_end); if (err) { - err = handle_decomp_error(os.comp, load_end - load, - CONFIG_SYS_BOOTM_LEN, err); + err = handle_decomp_error(os.comp, load_end - load, bootm_len(), + err); bootstage_error(BOOTSTAGE_ID_DECOMP_IMAGE); return err; } diff --git a/include/bootm.h b/include/bootm.h index c471615b08c..d174f18ac18 100644 --- a/include/bootm.h +++ b/include/bootm.h @@ -89,6 +89,14 @@ struct bootm_info { #define bootm_x86_set(_bmi, _field, _val) #endif +static inline ulong bootm_len(void) +{ +#ifdef CONFIG_SYS_BOOTM_LEN + return CONFIG_SYS_BOOTM_LEN; +#endif + return 0; +} + /** * bootm_init() - Set up a bootm_info struct with useful defaults * From patchwork Fri Dec 6 02:35:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2019043 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=eiq/ZnVG; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Y4FnJ3gnHz1yRL for ; Fri, 6 Dec 2024 13:38:44 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 2D6FA89737; Fri, 6 Dec 2024 03:37:12 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="eiq/ZnVG"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id DCE2F89734; Fri, 6 Dec 2024 03:37:11 +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=-5.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-il1-x130.google.com (mail-il1-x130.google.com [IPv6:2607:f8b0:4864:20::130]) (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 A2B05895DE for ; Fri, 6 Dec 2024 03:37:09 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-il1-x130.google.com with SMTP id e9e14a558f8ab-3a7d7c1b190so5590465ab.3 for ; Thu, 05 Dec 2024 18:37:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1733452628; x=1734057428; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=b7F81TTQ7FsN/bKWTwSGEwIqM1VkNrGPAXNbGgHdyNg=; b=eiq/ZnVGTuRdvZhygtAz7x3RUEo3Cn+HzOl1e6m1rrizBOKHRJBIxHuYOcxw/22s0g 4H/PO5s7MEJv8u4Z7rkaw9sop5vqBh38+aRwO3iIU2BrvO8u/HHi2w8Y9x8kssT2Ls7l U33CBgv/Jw1/thPeAxa9OGJ8IDzFfQCP04rNo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733452628; x=1734057428; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=b7F81TTQ7FsN/bKWTwSGEwIqM1VkNrGPAXNbGgHdyNg=; b=EX6Ssn0T72VabephoJnp1u6UKY92ukH15fUk0n4ZqFcpo0WYXxSpVj/pT+lx/W7v8k GF8YUYr0cV3aKd06A5Tc2X5GpaehHJLmcUuQW4n0O3ymltfUYDgdgP22Clhk4/xJOiDy cm5ngy4s0qKrPVZDGIrsVxJSsEUrHlNU6Qwyt+4RYpoRnXXBiKULNW00nVxzL67tWB5n /h7hvQPNxlZsBTpw494DGarhVNJXaIGFIqppaIXd/qwl0xnBgUVc4wo4NM8+VFeAiyW/ vraYzE+lYoSH2jNkHmTCfRi2P+7hbS42riI3vcBJanItxHee9PQ+RcfK8DO/C62JkUXx yq+A== X-Gm-Message-State: AOJu0Yz9rNxJaL5lOYfBissZDrgQE2AXi6xepCvGLUPLHcGnX1pgV/w6 0NZxl9YDpcD1UvpSzz79CR1dkEVhebbA10noTs2+1cVZa24RwzvTljL4gF/Cc7mgQ+30Ro7/jUE = X-Gm-Gg: ASbGncvLCgXYfXBxmXWA4ydQtJ/CgIooBl4/v5ljPZYZ0uF594z4ri8Lt3N9ooBYtOH jUkjDfTSq3xLrg0V9KPAfDxGRNjWqu5S521cste6pjgN9CxrDuJL8lBtV72m777tZSpN2WSOQ6j eGbPxMLobybds/FCDdVgjVS4nUKPPcHDR13ZldRJrvbBjLm97zHVpRcUBmRHmfem6ObLKm/mzlA XQXGOkrzPXxBGumrmtSedV5eiZw1dd7zNlHtgnWnrTg54oI5s5mJz4ahs9p/ob6ym0J2N40Okzo cLB0yIDf6/M= X-Google-Smtp-Source: AGHT+IE99RtKPWkuOZ4i3MyojiX889LIJhDeSCQtSW8sL0yrTMm/IQHteLCtzmNo90ChNMKWLBkx4Q== X-Received: by 2002:a05:6e02:1c05:b0:3a7:1dcb:d44b with SMTP id e9e14a558f8ab-3a811db73d7mr15277815ab.11.1733452627874; Thu, 05 Dec 2024 18:37:07 -0800 (PST) Received: from chromium.org (c-73-203-119-151.hsd1.co.comcast.net. [73.203.119.151]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4e2861f51bfsm575506173.112.2024.12.05.18.37.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Dec 2024 18:37:06 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Simon Glass , Julien Masson , Marek Vasut , Mattijs Korpershoek , Michal Simek , Peter Korsgaard , Roman Stratiienko , Sughosh Ganu Subject: [PATCH v3 14/46] boot: Convert IMAGE_FORMAT into an enum Date: Thu, 5 Dec 2024 19:35:53 -0700 Message-Id: <20241206023626.2456858-15-sjg@chromium.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241206023626.2456858-1-sjg@chromium.org> References: <20241206023626.2456858-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.103.8 at phobos.denx.de X-Virus-Status: Clean Use an enum so it is clearer that these options are related. Update genimg_get_format(), tidy up the function comment and move it to the header file, since it is exported. Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- Changes in v3: - Add new patch to convert IMAGE_FORMAT into an enum boot/image-board.c | 18 +++--------------- include/image.h | 26 +++++++++++++++++++++----- 2 files changed, 24 insertions(+), 20 deletions(-) diff --git a/boot/image-board.c b/boot/image-board.c index b726bd6b303..c681972109e 100644 --- a/boot/image-board.c +++ b/boot/image-board.c @@ -234,21 +234,7 @@ ulong genimg_get_kernel_addr(char * const img_addr) &fit_uname_kernel); } -/** - * genimg_get_format - get image format type - * @img_addr: image start address - * - * genimg_get_format() checks whether provided address points to a valid - * legacy or FIT image. - * - * New uImage format and FDT blob are based on a libfdt. FDT blob - * may be passed directly or embedded in a FIT image. In both situations - * genimg_get_format() must be able to dectect libfdt header. - * - * returns: - * image format type or IMAGE_FORMAT_INVALID if no image is present - */ -int genimg_get_format(const void *img_addr) +enum image_fmt_t genimg_get_format(const void *img_addr) { if (CONFIG_IS_ENABLED(LEGACY_IMAGE_FORMAT)) { const struct legacy_img_hdr *hdr; @@ -434,6 +420,8 @@ static int select_ramdisk(struct bootm_headers *images, const char *select, u8 a done = true; } break; + case IMAGE_FORMAT_INVALID: + break; } if (!done) { diff --git a/include/image.h b/include/image.h index 9be5acd8158..e3fc4b83b1d 100644 --- a/include/image.h +++ b/include/image.h @@ -597,10 +597,12 @@ int boot_get_setup(struct bootm_headers *images, uint8_t arch, ulong *setup_star ulong *setup_len); /* Image format types, returned by _get_format() routine */ -#define IMAGE_FORMAT_INVALID 0x00 -#define IMAGE_FORMAT_LEGACY 0x01 /* legacy image_header based format */ -#define IMAGE_FORMAT_FIT 0x02 /* new, libfdt based format */ -#define IMAGE_FORMAT_ANDROID 0x03 /* Android boot image */ +enum image_fmt_t { + IMAGE_FORMAT_INVALID, + IMAGE_FORMAT_LEGACY, /* legacy image_header based format */ + IMAGE_FORMAT_FIT, /* new, libfdt based format */ + IMAGE_FORMAT_ANDROID, /* Android boot image */ +}; /** * genimg_get_kernel_addr_fit() - Parse FIT specifier @@ -629,7 +631,21 @@ ulong genimg_get_kernel_addr_fit(const char *const img_addr, const char **fit_uname_kernel); ulong genimg_get_kernel_addr(char * const img_addr); -int genimg_get_format(const void *img_addr); + +/** + * genimg_get_format - get image format type + * @img_addr: image start address + * Return: image format type or IMAGE_FORMAT_INVALID if no image is present + * + * genimg_get_format() checks whether provided address points to a valid + * legacy or FIT image. + * + * New uImage format and FDT blob are based on a libfdt. FDT blob + * may be passed directly or embedded in a FIT image. In both situations + * genimg_get_format() must be able to dectect libfdt header. + */ +enum image_fmt_t genimg_get_format(const void *img_addr); + int genimg_has_config(struct bootm_headers *images); /** From patchwork Fri Dec 6 02:35:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2019044 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=mt3gNPWN; dkim-atps=neutral Authentication-Results: legolas.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=patchwork.ozlabs.org) 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 ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Y4FnT4kJXz1yRL for ; Fri, 6 Dec 2024 13:38:53 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 8AA0B896D5; Fri, 6 Dec 2024 03:37:15 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="mt3gNPWN"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 609E78918C; Fri, 6 Dec 2024 03:37:14 +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=-5.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-il1-x12a.google.com (mail-il1-x12a.google.com [IPv6:2607:f8b0:4864:20::12a]) (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 1379289734 for ; Fri, 6 Dec 2024 03:37:12 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-il1-x12a.google.com with SMTP id e9e14a558f8ab-3a777c67c45so5889525ab.1 for ; Thu, 05 Dec 2024 18:37:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1733452630; x=1734057430; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=/nYuQKd/i6J8gzVoWw5MFu3/dgDGjbgus2wpZ1fWwLs=; b=mt3gNPWNUZnIserrMF4M32SXO8VZho7gP6x5i4ZT2X4fJc7Kie4K5H4ATqAtby02QQ svNx/C3755iHJZIwqhLe897jT0gGN0nBvGjXBuBEuCmcQdS6kfBP6AjkX1lPVUhK8Y8C FeJl5vAcaIVOmFeANLZagtjwz+g0ncbz6vnms= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733452630; x=1734057430; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/nYuQKd/i6J8gzVoWw5MFu3/dgDGjbgus2wpZ1fWwLs=; b=vkPBUXh4HzIsZZEg7Xx+NRcBO2o5z9Ba/9yLMigOYhkYloOmQvVUNVDnllaQJle0JJ PfYLYU5sSnOR8da3VkcQw5mxjOOSt0eRm7h6Rm7x7DYCd1KdRJWukmXkbvT0cHnaXRbK gzfgKX4sXUvudvQwy3aShxC7Ux+tO+lAFPqnnX0JffXsVFAsOyZZTIQwbxY72zmNnw3u rEfHuBlRJNWzs5srwK5B7F5alMDTNDcxbAKPaFvn3PhveGQAK2NvPExzDQkptGi5oB3v h/lMCIYoip+ooiTxRnMu7scf641C/VS612JaEDC7s7ImY8cftU0I506wAN5ShkMPftOr hI9Q== X-Gm-Message-State: AOJu0YxqiQsTqaajrhF76uXV4+Er06TtzscG4GeDr3iByJvTp0bu3Zi1 ExJoGNjjqggK88evYxt4NQXMiGMf7ooyLHCjCdEZh6qFuwu3hVVhlz+a/znopIcgp0pWqKaYWfU = X-Gm-Gg: ASbGnctkOgbE16BubAb0/sLBeVMYbn2ssZnLj9r7P18TaoccPtxfJXFSFBvdBhRcQPK 0341S54iioJwVLiYtDcJuBRj4mMDaH1OpI/WjQrODEh4x9J3/X4vzrdM9vIWXzCvBAw7yOGsbL1 ugTVuXBtKsfzUu0CbZN52Xjk0pmyyc28VXBhR9UcIRuY4e7U82wA6yl7UTNjfB+ZQTWUWiJX2Ux 5OkQH7BjwYIu0v0cAI3+OfWbceaOUILHVjVqqqbru/85HRPbQVT91sMkQ8ohLEvdbjVosw4DEme kN3vPeiuFkI= X-Google-Smtp-Source: AGHT+IFjezkKEvTtm4Tcrq+3CmDPOLy4qHqeu00bAfCd8fIiV/KbYmiGhNznchztexhS+auEJoPHcw== X-Received: by 2002:a05:6e02:10ce:b0:3a8:13d5:bd2c with SMTP id e9e14a558f8ab-3a813d5bd8emr8154075ab.2.1733452630178; Thu, 05 Dec 2024 18:37:10 -0800 (PST) Received: from chromium.org (c-73-203-119-151.hsd1.co.comcast.net. [73.203.119.151]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4e2861f51bfsm575506173.112.2024.12.05.18.37.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Dec 2024 18:37:08 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Simon Glass , Albert Aribaud , Heinrich Schuchardt , Julien Masson , Leo , Marek Vasut , Mattijs Korpershoek , Peter Korsgaard , Rick Chen , Roman Stratiienko , Sughosh Ganu Subject: [PATCH v3 15/46] boot: arm: riscv: sandbox: Add a format for the booti file Date: Thu, 5 Dec 2024 19:35:54 -0700 Message-Id: <20241206023626.2456858-16-sjg@chromium.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241206023626.2456858-1-sjg@chromium.org> References: <20241206023626.2456858-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.103.8 at phobos.denx.de X-Virus-Status: Clean Arm invented a new format for arm64 and something similar is also used with RISC-V. Add this to the list of supported formats and provide a way for the format to be detected on both architectures. Update the genimg_get_format() function to support this. Fix up switch() statements which don't currently mention this format. Booti does not support a ramdisk, so this can be ignored. Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- Changes in v3: - Add new patch to add a format for the booti file arch/arm/lib/image.c | 9 ++++++++- arch/riscv/lib/image.c | 9 ++++++++- arch/sandbox/lib/bootm.c | 5 +++++ boot/image-board.c | 5 +++++ include/image.h | 9 +++++++++ 5 files changed, 35 insertions(+), 2 deletions(-) diff --git a/arch/arm/lib/image.c b/arch/arm/lib/image.c index 1f672eee2c8..d78d704cb58 100644 --- a/arch/arm/lib/image.c +++ b/arch/arm/lib/image.c @@ -28,6 +28,13 @@ struct Image_header { uint32_t res5; }; +bool booti_is_valid(const void *img) +{ + const struct Image_header *ih = img; + + return ih->magic == le32_to_cpu(LINUX_ARM64_IMAGE_MAGIC); +} + int booti_setup(ulong image, ulong *relocated_addr, ulong *size, bool force_reloc) { @@ -39,7 +46,7 @@ int booti_setup(ulong image, ulong *relocated_addr, ulong *size, ih = (struct Image_header *)map_sysmem(image, 0); - if (ih->magic != le32_to_cpu(LINUX_ARM64_IMAGE_MAGIC)) { + if (!booti_is_valid(ih)) { puts("Bad Linux ARM64 Image magic!\n"); return 1; } diff --git a/arch/riscv/lib/image.c b/arch/riscv/lib/image.c index a82f48e9a50..859326cbac8 100644 --- a/arch/riscv/lib/image.c +++ b/arch/riscv/lib/image.c @@ -32,6 +32,13 @@ struct linux_image_h { uint32_t res4; /* reserved */ }; +bool booti_is_valid(const void *img) +{ + const struct linux_image_h *lhdr = img; + + return lhdr->magic == LINUX_RISCV_IMAGE_MAGIC; +} + int booti_setup(ulong image, ulong *relocated_addr, ulong *size, bool force_reloc) { @@ -39,7 +46,7 @@ int booti_setup(ulong image, ulong *relocated_addr, ulong *size, lhdr = (struct linux_image_h *)map_sysmem(image, 0); - if (lhdr->magic != LINUX_RISCV_IMAGE_MAGIC) { + if (!booti_is_valid(lhdr)) { puts("Bad Linux RISCV Image magic!\n"); return -EINVAL; } diff --git a/arch/sandbox/lib/bootm.c b/arch/sandbox/lib/bootm.c index 44ba8b52e13..8ed923750f4 100644 --- a/arch/sandbox/lib/bootm.c +++ b/arch/sandbox/lib/bootm.c @@ -89,3 +89,8 @@ int booti_setup(ulong image, ulong *relocated_addr, ulong *size, return 1; } + +bool booti_is_valid(const void *img) +{ + return false; +} diff --git a/boot/image-board.c b/boot/image-board.c index c681972109e..e096dc49eef 100644 --- a/boot/image-board.c +++ b/boot/image-board.c @@ -250,6 +250,9 @@ enum image_fmt_t genimg_get_format(const void *img_addr) if (IS_ENABLED(CONFIG_ANDROID_BOOT_IMAGE) && is_android_boot_image_header(img_addr)) return IMAGE_FORMAT_ANDROID; + if (IS_ENABLED(CONFIG_CMD_BOOTI) && + booti_is_valid(img_addr)) + return IMAGE_FORMAT_BOOTI; return IMAGE_FORMAT_INVALID; } @@ -420,6 +423,8 @@ static int select_ramdisk(struct bootm_headers *images, const char *select, u8 a done = true; } break; + case IMAGE_FORMAT_BOOTI: + break; case IMAGE_FORMAT_INVALID: break; } diff --git a/include/image.h b/include/image.h index e3fc4b83b1d..b2699ecff3d 100644 --- a/include/image.h +++ b/include/image.h @@ -602,6 +602,7 @@ enum image_fmt_t { IMAGE_FORMAT_LEGACY, /* legacy image_header based format */ IMAGE_FORMAT_FIT, /* new, libfdt based format */ IMAGE_FORMAT_ANDROID, /* Android boot image */ + IMAGE_FORMAT_BOOTI, /* Arm64/RISC-V boot image */ }; /** @@ -648,6 +649,14 @@ enum image_fmt_t genimg_get_format(const void *img_addr); int genimg_has_config(struct bootm_headers *images); +/** + * booti_is_valid() - Check if an image appears to be an Arm64 image + * + * @img: Pointer to image + * Return: true if the image has the Arm64 magic + */ +bool booti_is_valid(const void *img); + /** * boot_get_fpga() - Locate the FPGA image * From patchwork Fri Dec 6 02:35:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2019045 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=T5Rd9gBB; dkim-atps=neutral Authentication-Results: legolas.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=patchwork.ozlabs.org) 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 ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Y4Fng4Hzgz1yRL for ; Fri, 6 Dec 2024 13:39:03 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id E567F89633; Fri, 6 Dec 2024 03:37:18 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="T5Rd9gBB"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 5F8C089633; Fri, 6 Dec 2024 03:37:17 +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=-5.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-io1-xd2a.google.com (mail-io1-xd2a.google.com [IPv6:2607:f8b0:4864:20::d2a]) (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 17F1D8918C for ; Fri, 6 Dec 2024 03:37:15 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-io1-xd2a.google.com with SMTP id ca18e2360f4ac-841d8dec299so99955139f.3 for ; Thu, 05 Dec 2024 18:37:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1733452633; x=1734057433; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=VrmmRHWxXfjE5EdNZV8YHp4vl8W+tY0XBnPDSK1K+PI=; b=T5Rd9gBBJxNTNfw51JM0wJOfJJDRFTntw2h2Kf9F0KxtCYqKRXPX5u9MUX6IxqlP6X 4Rl2hcCo1B9tLVACL1rv7RaoRHubuRkK24tYc2UNSObEOk+OLHyZYO53p0xTfPMmp0bb 3FAcGk6wA8FrUpo33sZuEqG+33qFKPLDYQrDg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733452633; x=1734057433; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=VrmmRHWxXfjE5EdNZV8YHp4vl8W+tY0XBnPDSK1K+PI=; b=l5FcpvV1INNbHFQc0mipQyaDGdKgsT+xtPnfh+JZMqz60IO/HMm11e92h4806s9Nho cGbMA22YjZ0DxY9eKPvG8Itl6YKn1JB6FjFiEifkoobtk4Y1XHPwS+vm5+EJ/donkxAV 7YVRIBgVSAEEDTktAUhw2Xoby9NcfAMvTGsP47lqyb0mEeQEnBNBvn/Y43K2fWDplRTW s1FdMiu0h9yyMWM7pziLZsd5zNOuPd5j8fOZD5YtsQ0U4ao7yO3gXElDsxGwMaemPI4Y Ua46udw+feBKRxDP0UaNXboTv78g+m4Zpa35bPErXpQgop+OSXI62BXNrjqSc1kiEgcH jlNQ== X-Gm-Message-State: AOJu0Yx69xM6G4UJ1LZoFfUqtSK34kHhhPj/NFJNL/aq26E+YPvBkkeP oTu458wMZMYFKsosawh2bThUlsJ9fYOUUTuKUhnwfM4xrK9/djxB0XlrKVXcSEwsRZbQObkl3Ck = X-Gm-Gg: ASbGnctbCjbwLKyD9rewRjvkzCmOm6wT2+Eo2BWrxAJjpv8JZpdR+n/2fkFqFpKeZTP 8zYvE9k2t3M2jw6ekNHmBf1vFC4bJFaai7voS+TKwZ/aWZbTrwZqaVC5WMn8mQUbSltfJxfb4Vw ANmYhaNn+zHSdAqS1t3sfX8NBnebdhld1zcw/XbJHDLn8I0Ex1ahRXlIk6m5vUUrouGicdtbu+j CfioBxhtB5Y/0LN22k+iQSgsjremrT0aIqd0TXLd1kgxlTEBrtT1JwrzP2L+SSFM7EDX9AskYgW F2XIeMlf4Fs= X-Google-Smtp-Source: AGHT+IH9bszyiBoWMpt81o9x4idqvtN0s2WM8HRC2y25OItT02z01NLHb/OT4jFT7d5NvSAZEID7fQ== X-Received: by 2002:a05:6602:6011:b0:842:ff2d:c3d9 with SMTP id ca18e2360f4ac-8447e204c01mr214671539f.4.1733452633329; Thu, 05 Dec 2024 18:37:13 -0800 (PST) Received: from chromium.org (c-73-203-119-151.hsd1.co.comcast.net. [73.203.119.151]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4e2861f51bfsm575506173.112.2024.12.05.18.37.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Dec 2024 18:37:11 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Simon Glass , Ilias Apalodimas , Julien Masson , Mattijs Korpershoek , Sughosh Ganu Subject: [PATCH v3 16/46] boot: Support booti format in bootm Date: Thu, 5 Dec 2024 19:35:55 -0700 Message-Id: <20241206023626.2456858-17-sjg@chromium.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241206023626.2456858-1-sjg@chromium.org> References: <20241206023626.2456858-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.103.8 at phobos.denx.de X-Virus-Status: Clean At present the booti format is handled separately, in its own command. Provide a way to boot uncompressed booti images within the bootm code, so that eventually we can boot these images without CONFIG_CMDLINE Update bootm_init() to attach the images for all formats which use them. Add some debugging while we are here. Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- Changes in v3: - Add new patch to support booti format in bootm boot/bootm.c | 42 +++++++++++++++++++++++++++++++++++++++++- include/image.h | 2 +- 2 files changed, 42 insertions(+), 2 deletions(-) diff --git a/boot/bootm.c b/boot/bootm.c index 0a1040ef923..6fafa354732 100644 --- a/boot/bootm.c +++ b/boot/bootm.c @@ -227,6 +227,12 @@ static int boot_get_kernel(const char *addr_fit, struct bootm_headers *images, break; } #endif + case IMAGE_FORMAT_BOOTI: + if (IS_ENABLED(CONFIG_CMD_BOOTI)) { + *os_data = img_addr; + break; + } + fallthrough; default: bootstage_error(BOOTSTAGE_ID_CHECK_IMAGETYPE); return -EPROTOTYPE; @@ -286,6 +292,24 @@ static int bootm_pre_load(const char *addr_str) return ret; } +static int found_booti_os(enum image_comp_t comp) +{ + images.os.load = images.os.image_start; + images.os.type = IH_TYPE_KERNEL; + images.os.os = IH_OS_LINUX; + images.os.comp = comp; + if (IS_ENABLED(CONFIG_RISCV_SMODE)) + images.os.arch = IH_ARCH_RISCV; + else if (IS_ENABLED(CONFIG_ARM64)) + images.os.arch = IH_ARCH_ARM64; + + log_debug("load %lx start %lx len %lx ep %lx os %x comp %x\n", + images.os.load, images.os.image_start, images.os.image_len, + images.ep, images.os.os, images.os.comp); + + return 0; +} + /** * bootm_find_os(): Find the OS to boot * @@ -390,6 +414,14 @@ static int bootm_find_os(const char *cmd_name, const char *addr_fit) } break; #endif + case IMAGE_FORMAT_BOOTI: + if (IS_ENABLED(CONFIG_CMD_BOOTI)) { + if (found_booti_os(IH_COMP_NONE)) + return 1; + ep_found = true; + break; + } + fallthrough; default: puts("ERROR: unknown image format type!\n"); return 1; @@ -541,6 +573,7 @@ int bootm_find_images(ulong img_addr, const char *conf_ramdisk, static int bootm_find_other(ulong img_addr, const char *conf_ramdisk, const char *conf_fdt) { + log_debug("find_other type %x os %x\n", images.os.type, images.os.os); if ((images.os.type == IH_TYPE_KERNEL || images.os.type == IH_TYPE_KERNEL_NOLOAD || images.os.type == IH_TYPE_MULTI) && @@ -629,6 +662,8 @@ static int bootm_load_os(struct bootm_headers *images, int boot_progress) debug("Allocated %lx bytes at %lx for kernel (size %lx) decompression\n", req_size, load, image_len); } + log_debug("load_os load %lx image_start %lx image_len %lx\n", load, + image_start, image_len); load_buf = map_sysmem(load, 0); image_buf = map_sysmem(os.image_start, image_len); @@ -1109,6 +1144,10 @@ int boot_run(struct bootm_info *bmi, const char *cmd, int extra_states) states |= BOOTM_STATE_RAMDISK; states |= extra_states; + log_debug("cmd '%s' states %x addr_img '%s' conf_ramdisk '%s' conf_fdt '%s' images %p\n", + cmd, states, bmi->addr_img, bmi->conf_ramdisk, bmi->conf_fdt, + bmi->images); + return bootm_run_states(bmi, states); } @@ -1165,7 +1204,8 @@ void bootm_init(struct bootm_info *bmi) { memset(bmi, '\0', sizeof(struct bootm_info)); bmi->boot_progress = true; - if (IS_ENABLED(CONFIG_CMD_BOOTM)) + if (IS_ENABLED(CONFIG_CMD_BOOTM) || IS_ENABLED(CONFIG_CMD_BOOTZ) || + IS_ENABLED(CONFIG_CMD_BOOTI) || IS_ENABLED(CONFIG_PXE_UTILS)) bmi->images = &images; } diff --git a/include/image.h b/include/image.h index b2699ecff3d..6dd7373c7ba 100644 --- a/include/image.h +++ b/include/image.h @@ -243,7 +243,7 @@ enum image_type_t { * New IDs *MUST* be appended at the end of the list and *NEVER* * inserted for backward compatibility. */ -enum { +enum image_comp_t { IH_COMP_NONE = 0, /* No Compression Used */ IH_COMP_GZIP, /* gzip Compression Used */ IH_COMP_BZIP2, /* bzip2 Compression Used */ From patchwork Fri Dec 6 02:35:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2019046 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=Iyz+yef0; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Y4Fns3rVBz1yRL for ; Fri, 6 Dec 2024 13:39:13 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 4A7E089701; Fri, 6 Dec 2024 03:37:21 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="Iyz+yef0"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 5D2028973E; Fri, 6 Dec 2024 03:37:20 +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=-5.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-il1-x129.google.com (mail-il1-x129.google.com [IPv6:2607:f8b0:4864:20::129]) (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 136F18918C for ; Fri, 6 Dec 2024 03:37:18 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-il1-x129.google.com with SMTP id e9e14a558f8ab-3a7a46ca756so5314265ab.0 for ; Thu, 05 Dec 2024 18:37:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1733452636; x=1734057436; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=8rRTXL9GcLV1F1SIaLR2PzzjW2LkE254wbWhdTlU5K0=; b=Iyz+yef0esxn/M6irev1IOFsAKUy01GC0nldSEuFlCwppAto6uYTcvu+NqYYtH26MG FrMBUj9XLP4IYBNKlXsIXvWbI0MmVwrEXzR5xmizERx5bV+IIt3KCjLreqEGbgKCBf71 l8mqr5lcNqYcrg8ejLnWB/KSE6HL7ycEnSjMk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733452636; x=1734057436; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8rRTXL9GcLV1F1SIaLR2PzzjW2LkE254wbWhdTlU5K0=; b=Stx86DaSjVMY4zOW5nVXyZMyJvQmVT3wCmbWXHS7vTY2eqo7ArSaHNmzxc1+gTYxBh S8JsGKiMmSFkEDnHs9N0QPiX6zVhruNEdrEuDn/ykVDaOUA4QPOXCMG8ykoeEzKY1pta a2htfQSmLj5bPTDCBVAft+A+X3ukrYYUotPty1xbCi+nbC/syGUgA6Wz1bACrvN8ibE/ Ot7KJh4M/OQ1toVMyyDQlaIEZpfQnbAYjzIFw/AVnI0N4XoysSY7oyCftzSdPAxjxcb3 0lbsEHqyzrjT1o88r+EDCYpg4OWXsnhhxSC54amaqBOWByBUpMO6N6NT7kaJ/Rty0COW u+UQ== X-Gm-Message-State: AOJu0YwYGsjssjToLxeVdGQBn9hCWjEX98+IX8ns5roq4i5fDfwjB+FF tt+HJHV3Z8KRQEpi34zRRFtB5nJuEqtgCP2ZWeqxdihhmQ8EWSEi9zuCoWVWkDiVEOeVkd1v2AY = X-Gm-Gg: ASbGnct30skFSj5ndSkS2RmEvK77kk+FgpRFFEzCCeIXMIx4i1IowNGzvVWW6X0+TFO cY+fI39IOTrxXXsMnfI6HMiN/QPA/07pkL5BUzz1YbyfFhZ/kciXqzx896DESh2sdGvF5ZODn3q tT3JOR6N7vPLjGkSdyZvgX9lk5SNh/FdRstYJiBgmaJuAW2DDt5UpF8KwlPi9DT4YT7h9b0J8Wq k6wbvCJoS4dU4Q3ZeYuOOVUM9RZ/WWwKbrvr6nw+ID4WQdiiKZPZcYuwKscJj1yvVmfqxWizIyx HqjbNr2QStk= X-Google-Smtp-Source: AGHT+IGOU+ptQaqQRiqJjhPjliflOtuQNeU8Qa7g8nI9mUt5Yj0A3x/YGDrGg68n2tEFQjKL1mZELg== X-Received: by 2002:a05:6e02:12c2:b0:3a7:6d14:cc29 with SMTP id e9e14a558f8ab-3a811d776fbmr22406295ab.1.1733452636286; Thu, 05 Dec 2024 18:37:16 -0800 (PST) Received: from chromium.org (c-73-203-119-151.hsd1.co.comcast.net. [73.203.119.151]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4e2861f51bfsm575506173.112.2024.12.05.18.37.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Dec 2024 18:37:14 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Simon Glass , Ilias Apalodimas , Julien Masson , Marek Vasut , Mattijs Korpershoek , Peter Korsgaard , Roman Stratiienko , Sughosh Ganu Subject: [PATCH v3 17/46] boot: Support compressed booti images in bootm Date: Thu, 5 Dec 2024 19:35:56 -0700 Message-Id: <20241206023626.2456858-18-sjg@chromium.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241206023626.2456858-1-sjg@chromium.org> References: <20241206023626.2456858-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.103.8 at phobos.denx.de X-Virus-Status: Clean A compressed booti image relies on the compression-format's header at the start to indicate which compression algorithm is used. We don't support this elsewhere in U-Boot, so assume that a compressed file is always a booti file. Once it is compressed, a check is made to make sure that it actually is. Simplify the implementation by adding a new function which returns the booti image-type if compression is detected. Signed-off-by: Simon Glass --- Changes in v3: - Add new patch to support compressed booti images in bootm boot/bootm.c | 36 +++++++++++++++++++++++++++++------- boot/image-board.c | 13 ++++++++++++- include/image.h | 11 +++++++++++ 3 files changed, 52 insertions(+), 8 deletions(-) diff --git a/boot/bootm.c b/boot/bootm.c index 6fafa354732..7f0a74b9e24 100644 --- a/boot/bootm.c +++ b/boot/bootm.c @@ -146,7 +146,7 @@ static int boot_get_kernel(const char *addr_fit, struct bootm_headers *images, /* check image type, for FIT images get FIT kernel node */ *os_data = *os_len = 0; buf = map_sysmem(img_addr, 0); - switch (genimg_get_format(buf)) { + switch (genimg_get_format_comp(buf)) { #if CONFIG_IS_ENABLED(LEGACY_IMAGE_FORMAT) case IMAGE_FORMAT_LEGACY: printf("## Booting kernel from Legacy Image at %08lx ...\n", @@ -228,11 +228,8 @@ static int boot_get_kernel(const char *addr_fit, struct bootm_headers *images, } #endif case IMAGE_FORMAT_BOOTI: - if (IS_ENABLED(CONFIG_CMD_BOOTI)) { - *os_data = img_addr; - break; - } - fallthrough; + *os_data = img_addr; + break; default: bootstage_error(BOOTSTAGE_ID_CHECK_IMAGETYPE); return -EPROTOTYPE; @@ -306,6 +303,16 @@ static int found_booti_os(enum image_comp_t comp) log_debug("load %lx start %lx len %lx ep %lx os %x comp %x\n", images.os.load, images.os.image_start, images.os.image_len, images.ep, images.os.os, images.os.comp); + if (comp != IH_COMP_NONE) { + images.os.load = env_get_hex("kernel_comp_addr_r", 0); + images.os.image_len = env_get_ulong("kernel_comp_size", 16, 0); + if (!images.os.load || !images.os.image_len) { + puts("kernel_comp_addr_r or kernel_comp_size is not provided!\n"); + return -ENOTSUPP; + } + if (lmb_reserve(images.os.load, images.os.image_len) < 0) + return -EXDEV; + } return 0; } @@ -423,6 +430,19 @@ static int bootm_find_os(const char *cmd_name, const char *addr_fit) } fallthrough; default: + /* any compressed image is probably a booti image */ + if (IS_ENABLED(CONFIG_CMD_BOOTI)) { + int comp; + + comp = image_decomp_type(os_hdr, 2); + if (comp != IH_COMP_NONE) { + if (found_booti_os(comp)) + return 1; + ep_found = true; + } + break; + } + puts("ERROR: unknown image format type!\n"); return 1; } @@ -1165,7 +1185,9 @@ int bootz_run(struct bootm_info *bmi) int booti_run(struct bootm_info *bmi) { - return boot_run(bmi, "booti", 0); + return boot_run(bmi, "booti", BOOTM_STATE_START | BOOTM_STATE_FINDOS | + BOOTM_STATE_PRE_LOAD | BOOTM_STATE_FINDOTHER | + BOOTM_STATE_LOADOS); } int bootm_boot_start(ulong addr, const char *cmdline) diff --git a/boot/image-board.c b/boot/image-board.c index e096dc49eef..d018d790a49 100644 --- a/boot/image-board.c +++ b/boot/image-board.c @@ -257,6 +257,17 @@ enum image_fmt_t genimg_get_format(const void *img_addr) return IMAGE_FORMAT_INVALID; } +enum image_fmt_t genimg_get_format_comp(const void *img_addr) +{ + enum image_fmt_t fmt = genimg_get_format(img_addr); + + if (IS_ENABLED(CONFIG_CMD_BOOTI) && fmt == IMAGE_FORMAT_INVALID && + image_decomp_type(img_addr, 2) != IH_COMP_NONE) + fmt = IMAGE_FORMAT_BOOTI; + + return fmt; +} + /** * fit_has_config - check if there is a valid FIT configuration * @images: pointer to the bootm command headers structure @@ -353,7 +364,7 @@ static int select_ramdisk(struct bootm_headers *images, const char *select, u8 a * check image type, for FIT images get FIT node. */ buf = map_sysmem(rd_addr, 0); - switch (genimg_get_format(buf)) { + switch (genimg_get_format_comp(buf)) { case IMAGE_FORMAT_LEGACY: if (CONFIG_IS_ENABLED(LEGACY_IMAGE_FORMAT)) { const struct legacy_img_hdr *rd_hdr; diff --git a/include/image.h b/include/image.h index 6dd7373c7ba..de44dc09d07 100644 --- a/include/image.h +++ b/include/image.h @@ -647,6 +647,17 @@ ulong genimg_get_kernel_addr(char * const img_addr); */ enum image_fmt_t genimg_get_format(const void *img_addr); +/** + * genimg_get_format_comp() - Like genimg_get_format() but adds compressed booti + * + * If a compressed file is detected (with image_decomp_type()) and + * CONFIG_CMD_BOOTI is enabled, then this returns IMAGE_FORMAT_BOOTI + * + * @img_addr: image start address + * Return: image format type or IMAGE_FORMAT_INVALID if no image is present + */ +enum image_fmt_t genimg_get_format_comp(const void *img_addr); + int genimg_has_config(struct bootm_headers *images); /** From patchwork Fri Dec 6 02:35:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2019047 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=BgjMhJn4; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Y4Fp21bWGz1yRL for ; Fri, 6 Dec 2024 13:39:22 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 9FE1D89622; Fri, 6 Dec 2024 03:37:24 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="BgjMhJn4"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 3D70B895DE; Fri, 6 Dec 2024 03:37:23 +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=-5.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-il1-x12a.google.com (mail-il1-x12a.google.com [IPv6:2607:f8b0:4864:20::12a]) (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 E513A8918C for ; Fri, 6 Dec 2024 03:37:20 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-il1-x12a.google.com with SMTP id e9e14a558f8ab-3a81324bbdcso2359755ab.1 for ; Thu, 05 Dec 2024 18:37:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1733452639; x=1734057439; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Dk3ymu+0Or0zVIKukkowNqICfAbtE0w5QwF2dDVtBFs=; b=BgjMhJn4rOTqqOVUQTHYsz2pAgXmkntMiHe/0KkZAKAMaHlPp6MJPixWQmgTVjjKrc KmmcGYsQDO2/NtO3RoVfGHs4AGW4KxRj/88zJdaSkoab5TBho8qc3b6tV0wlTmWOLj0/ wd1iLeHjl2z7so12hFri5UaZhQrzGMZ1tLUtU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733452639; x=1734057439; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Dk3ymu+0Or0zVIKukkowNqICfAbtE0w5QwF2dDVtBFs=; b=q0iIqBn+rgQfGRLKFaLcvfubag5W+p+HvK+yI6kSZR7UaHCt2F8JowBcUy6vqdawVr jVPvJttgbECoaYyd/9dvWkfrx3/EQyZYHeSRzAm1fdXoUM7OhwMnc9oXGGAyCWw6vPHB a6G5OgMUUW/mLesCn9zwVWcftMQk6p3eJHfW/7LIdgzgzDXnSOUFhoWwPrM6iyEpXGa+ WLkRq8ZpXZr5mRS4rpKuaxCPGx2JOjrR0XFkOQvh1ukTrmXCWaFclkrWBmXA2aK72sM2 WJDGsQamXLwfaFdMNAIsPoGfjmcqtl1QKn1mSS9K5bv9omE4fb77yaOmIX6QEsgt9C5P XWlQ== X-Gm-Message-State: AOJu0YzICM6gdhx/MeYgb0KaDA1eFNlSc3vvdK4T5qWHwdw/76UA5nrs 6YbE6Ne49RVVh/BMrFpuZKV88E3qvnIdVRPXvb25tmOIqqmaAJvaIaUMxep+ZFXjouqmCoUUgIc = X-Gm-Gg: ASbGncu2SIuQAUT2aHdvjljlv2JFDtZTbv9aBhnDofYeoBGHtTNPJZ2FG2H6CEIn0pd x1voQIsOKZ9SHWwU+Imrt9RVo1Rd+NlkUS90RJTIsS0lXBeGF4Esodac+OzbCG5aZMflIssRnPd XA4w9gZ9jt2z6QGuqtNDnWwn1r0nhKwvVSA9hgE1QZLEg9ogdD1fGlvc2qX0RH7npNonpQEs6kg JAhN0S04rVuFRClu9yYjjm13EJ1JQJyuW2faZI4JcgqBYKOxC8tehFCIV810fG+7eyCAL5w7N4d 3MM5Ai8JFVo= X-Google-Smtp-Source: AGHT+IFaA+6byK8qj/o8ZtonH/JiADLrhoRLFWBRjdlxvMQPS/KcUwtBw0hJv/2qTZ0ld9n2dD85Bw== X-Received: by 2002:a05:6e02:198a:b0:3a7:6a98:3fdf with SMTP id e9e14a558f8ab-3a811daf831mr19521245ab.14.1733452639195; Thu, 05 Dec 2024 18:37:19 -0800 (PST) Received: from chromium.org (c-73-203-119-151.hsd1.co.comcast.net. [73.203.119.151]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4e2861f51bfsm575506173.112.2024.12.05.18.37.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Dec 2024 18:37:17 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Simon Glass , Quentin Schulz , AKASHI Takahiro , Heinrich Schuchardt , Marek Vasut , Martyn Welch , Mattijs Korpershoek , Michael Trimarchi Subject: [PATCH v3 18/46] boot: pxe: Use bootm_...() functions where possible Date: Thu, 5 Dec 2024 19:35:57 -0700 Message-Id: <20241206023626.2456858-19-sjg@chromium.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241206023626.2456858-1-sjg@chromium.org> References: <20241206023626.2456858-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.103.8 at phobos.denx.de X-Virus-Status: Clean Rather than building a command line for each operation, use the functions provided by the bootm API. Make sure that the bootm functions are available if pxe_utils is used. Since SYS_BOOTM_LEN is not present for the tools-only build, adjust the code to handle that. Signed-off-by: Simon Glass Reviewed-by: Quentin Schulz Signed-off-by: Simon Glass Reviewed-by: Quentin Schulz --- (no changes since v1) boot/Makefile | 2 +- boot/pxe_utils.c | 43 ++++++++++++++++++++----------------------- 2 files changed, 21 insertions(+), 24 deletions(-) diff --git a/boot/Makefile b/boot/Makefile index b03d628187b..ef9943bbfc1 100644 --- a/boot/Makefile +++ b/boot/Makefile @@ -10,7 +10,7 @@ obj-$(CONFIG_CMD_BOOTM) += bootm.o bootm_os.o obj-$(CONFIG_CMD_BOOTZ) += bootm.o bootm_os.o obj-$(CONFIG_CMD_BOOTI) += bootm.o bootm_os.o -obj-$(CONFIG_PXE_UTILS) += pxe_utils.o +obj-$(CONFIG_PXE_UTILS) += bootm.o pxe_utils.o endif diff --git a/boot/pxe_utils.c b/boot/pxe_utils.c index 2ada5c4aaac..bbb6ff203b6 100644 --- a/boot/pxe_utils.c +++ b/boot/pxe_utils.c @@ -7,6 +7,7 @@ #define LOG_CATEGORY LOGC_BOOT #include +#include #include #include #include @@ -461,7 +462,7 @@ skip_overlay: * Scenario 4: fdt blob is not available. */ static int label_process_fdt(struct pxe_context *ctx, struct pxe_label *label, - char *kernel_addr, char **fdt_argp) + char *kernel_addr, const char **fdt_argp) { /* For FIT, the label can be identical to kernel one */ if (label->fdt && !strcmp(label->kernel_label, label->fdt)) { @@ -584,72 +585,66 @@ static int label_run_boot(struct pxe_context *ctx, struct pxe_label *label, char *kernel_addr, char *initrd_addr_str, char *initrd_filesize, char *initrd_str) { - char *bootm_argv[] = { "bootm", NULL, NULL, NULL, NULL }; char *zboot_argv[] = { "zboot", NULL, "0", NULL, NULL }; + struct bootm_info bmi; ulong kernel_addr_r; - int bootm_argc = 2; int zboot_argc = 3; void *buf; int ret; - bootm_argv[3] = env_get("fdt_addr_r"); + bootm_init(&bmi); - ret = label_process_fdt(ctx, label, kernel_addr, &bootm_argv[3]); + bmi.conf_fdt = env_get("fdt_addr_r"); + + ret = label_process_fdt(ctx, label, kernel_addr, &bmi.conf_fdt); if (ret) return ret; - bootm_argv[1] = kernel_addr; + bmi.addr_img = kernel_addr; zboot_argv[1] = kernel_addr; if (initrd_addr_str) { - bootm_argv[2] = initrd_str; - bootm_argc = 3; + bmi.conf_ramdisk = initrd_str; zboot_argv[3] = initrd_addr_str; zboot_argv[4] = initrd_filesize; zboot_argc = 5; } - if (!bootm_argv[3]) { + if (!bmi.conf_fdt) { if (IS_ENABLED(CONFIG_SUPPORT_PASSING_ATAGS)) { if (strcmp("-", label->fdt)) - bootm_argv[3] = env_get("fdt_addr"); + bmi.conf_fdt = env_get("fdt_addr"); } else { - bootm_argv[3] = env_get("fdt_addr"); + bmi.conf_fdt = env_get("fdt_addr"); } } kernel_addr_r = genimg_get_kernel_addr(kernel_addr); buf = map_sysmem(kernel_addr_r, 0); - if (!bootm_argv[3] && genimg_get_format(buf) != IMAGE_FORMAT_FIT) { + if (!bmi.conf_fdt && genimg_get_format(buf) != IMAGE_FORMAT_FIT) { if (IS_ENABLED(CONFIG_SUPPORT_PASSING_ATAGS)) { if (strcmp("-", label->fdt)) - bootm_argv[3] = env_get("fdtcontroladdr"); + bmi.conf_fdt = env_get("fdtcontroladdr"); } else { - bootm_argv[3] = env_get("fdtcontroladdr"); + bmi.conf_fdt = env_get("fdtcontroladdr"); } } - if (bootm_argv[3]) { - if (!bootm_argv[2]) - bootm_argv[2] = "-"; - bootm_argc = 4; - } - /* Try bootm for legacy and FIT format image */ if (genimg_get_format(buf) != IMAGE_FORMAT_INVALID && IS_ENABLED(CONFIG_CMD_BOOTM)) { log_debug("using bootm\n"); - do_bootm(ctx->cmdtp, 0, bootm_argc, bootm_argv); + ret = bootm_run(&bmi); /* Try booting an AArch64 Linux kernel image */ } else if (IS_ENABLED(CONFIG_CMD_BOOTI)) { log_debug("using booti\n"); - do_booti(ctx->cmdtp, 0, bootm_argc, bootm_argv); + ret = booti_run(&bmi); /* Try booting a Image */ } else if (IS_ENABLED(CONFIG_CMD_BOOTZ)) { log_debug("using bootz\n"); - do_bootz(ctx->cmdtp, 0, bootm_argc, bootm_argv); + ret = bootz_run(&bmi); /* Try booting an x86_64 Linux kernel image */ } else if (IS_ENABLED(CONFIG_CMD_ZBOOT)) { log_debug("using zboot\n"); @@ -657,6 +652,8 @@ static int label_run_boot(struct pxe_context *ctx, struct pxe_label *label, } unmap_sysmem(buf); + if (ret) + return ret; return 0; } From patchwork Fri Dec 6 02:35:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2019048 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=YVS/f/4q; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Y4FpB6CTBz1yRL for ; Fri, 6 Dec 2024 13:39:30 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 0450489736; Fri, 6 Dec 2024 03:37:27 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="YVS/f/4q"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 2D5A589736; Fri, 6 Dec 2024 03:37:26 +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=-5.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-io1-xd36.google.com (mail-io1-xd36.google.com [IPv6:2607:f8b0:4864:20::d36]) (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 957768918C for ; Fri, 6 Dec 2024 03:37:23 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-io1-xd36.google.com with SMTP id ca18e2360f4ac-8418ecda199so55718539f.2 for ; Thu, 05 Dec 2024 18:37:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1733452641; x=1734057441; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=qsAWBSpRjw4R0AqyMrs39o+aPJEFcT8k17IMykfCQAw=; b=YVS/f/4qcsJElBUea7Pz0SByPLa9wD2PKp6mQ9K1XSXvNKEVHrr+IExuUYR1qvWEu5 Pke3g0KWC+37bNd2AXWC/jqlrM2bcKGEvBMwrHUZ/m10HuyA5HIxI2CLYdMZ/3DxUE6I kKJZSspjoPbBSDw/M+5zD0TFiUkrgMITmoeZE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733452641; x=1734057441; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=qsAWBSpRjw4R0AqyMrs39o+aPJEFcT8k17IMykfCQAw=; b=LreipSZjG7TWByPP4nZzA6mI/U1K2Uuhl7OOE41wlGH5jueuDdzN4UADLKXBKl6O+C BXw4C7o6jyKjKSICzjC+PBa/apn8KicOGKzEqGWFH7F06ZB1fSli+DiII3VlOXq9+xGn eIEvWPrgt4CxGT5j1Iv6SCrEydjg7Xe6DjtcooKiU5gsKQ9jibXFo+wqKK/edSlo7wEV v1GhlMaOZoyZKrqCIsI4Gev5ETtHpTkmZ46Gaiu+1IiuA0BiomEbQLurSSgBc/i5O4Y1 PmBdryUZzgmDav3yOHxE0jtC5UCZuIK90PXDHV66FAbbBg+SMlReo4TLkcVba3eVDC1o VxtA== X-Gm-Message-State: AOJu0YwfuyvOchFrxUOM1yla/6j8lQsydNfaX+V+CO73dE/1384ee1ao 7uRmAkBAmV+SzC1LuikEyeLa63hmLd2wR4sDreB6sx99tkxLjSeic/zdkuANmuiIuLCmIZKUyjU = X-Gm-Gg: ASbGncuRnnKL+sh6Zs9IUKTtDXb3ilohEtQC+h5IoOemWK0w0kg4xjyTVfB6hFIRJUU B3JYXMmmg2YWjTfOYoW32HcOHrYnks8QR8uQ+LG7j9uOAmsLnEBbjXDssREk+qtkQbBisDV3apV ugb1yjGmXFQD9/cPdzWmQGAOL7vrEsrx7TWOAd9/WpqtMaC876ABzMhSSQc3MwlJSvIktd47w92 WViB8da/ibjmiDmC5u4M9XofS4Vy8EaGB930r9zt1pEp5gErgg30+n3jqf2QRlDFfjJa+rmP8H3 fLvAJ3V/+Lg= X-Google-Smtp-Source: AGHT+IEH4KXU0S531k4axrt8z1v/d7vrOdPEJr5m2sHQJNP9lRQEN5KjdZaCQbfPiYg2++iytL5O3A== X-Received: by 2002:a05:6e02:1ca7:b0:3a7:e0a5:aa98 with SMTP id e9e14a558f8ab-3a811db2148mr18943145ab.13.1733452641487; Thu, 05 Dec 2024 18:37:21 -0800 (PST) Received: from chromium.org (c-73-203-119-151.hsd1.co.comcast.net. [73.203.119.151]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4e2861f51bfsm575506173.112.2024.12.05.18.37.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Dec 2024 18:37:19 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Simon Glass , Quentin Schulz , Marek Vasut , Martyn Welch , Michael Trimarchi Subject: [PATCH v3 19/46] pxe_utils: Simplify default fdt in label_run_boot() Date: Thu, 5 Dec 2024 19:35:58 -0700 Message-Id: <20241206023626.2456858-20-sjg@chromium.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241206023626.2456858-1-sjg@chromium.org> References: <20241206023626.2456858-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.103.8 at phobos.denx.de X-Virus-Status: Clean Tidy up this code a little to avoid two calls to env_get() for both fdt_addr and fdtcontroladdr Signed-off-by: Simon Glass Suggested-by: Quentin Schulz Signed-off-by: Simon Glass --- (no changes since v2) Changes in v2: - Add new patch to simplify the code reading fdtcontroladdr and fdt_addr boot/pxe_utils.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/boot/pxe_utils.c b/boot/pxe_utils.c index bbb6ff203b6..37306f37009 100644 --- a/boot/pxe_utils.c +++ b/boot/pxe_utils.c @@ -612,24 +612,18 @@ static int label_run_boot(struct pxe_context *ctx, struct pxe_label *label, } if (!bmi.conf_fdt) { - if (IS_ENABLED(CONFIG_SUPPORT_PASSING_ATAGS)) { - if (strcmp("-", label->fdt)) - bmi.conf_fdt = env_get("fdt_addr"); - } else { + if (!IS_ENABLED(CONFIG_SUPPORT_PASSING_ATAGS) || + strcmp("-", label->fdt)) bmi.conf_fdt = env_get("fdt_addr"); - } } kernel_addr_r = genimg_get_kernel_addr(kernel_addr); buf = map_sysmem(kernel_addr_r, 0); if (!bmi.conf_fdt && genimg_get_format(buf) != IMAGE_FORMAT_FIT) { - if (IS_ENABLED(CONFIG_SUPPORT_PASSING_ATAGS)) { - if (strcmp("-", label->fdt)) - bmi.conf_fdt = env_get("fdtcontroladdr"); - } else { + if (!IS_ENABLED(CONFIG_SUPPORT_PASSING_ATAGS) || + strcmp("-", label->fdt)) bmi.conf_fdt = env_get("fdtcontroladdr"); - } } /* Try bootm for legacy and FIT format image */ From patchwork Fri Dec 6 02:35:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2019049 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=FLRvTXEs; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Y4FpM4pZ5z1yRL for ; Fri, 6 Dec 2024 13:39:39 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 512808973F; Fri, 6 Dec 2024 03:37:30 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="FLRvTXEs"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 846538973E; Fri, 6 Dec 2024 03:37:28 +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=-5.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-io1-xd36.google.com (mail-io1-xd36.google.com [IPv6:2607:f8b0:4864:20::d36]) (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 5046C8918C for ; Fri, 6 Dec 2024 03:37:26 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-io1-xd36.google.com with SMTP id ca18e2360f4ac-841acc8151aso101401839f.1 for ; Thu, 05 Dec 2024 18:37:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1733452644; x=1734057444; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=1Jmy5A8G1dN4sDl+c/Au1MUDiB7/oS6Wa+0WizabxbI=; b=FLRvTXEsCQ4ttDFKjZyHseea0i58EQOITv7ICO+8Pikj7BGVvIIH18Sz3O0UqswlHJ K5s3QIKvkNke9egwe24PI3P1JejkWAe6xkqB3+J0cawpLemgD0wLBpnJqhyl8G0a/FGy Bvn51Tvq5wdvUU121rkQGfSAOG9oIPoKu2Mx8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733452644; x=1734057444; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1Jmy5A8G1dN4sDl+c/Au1MUDiB7/oS6Wa+0WizabxbI=; b=ZW1HfN60o7ECgFuQxdz0SCAMSqmv6+fQeO3q1gr6matMm0ScxhoHxN25V9P6/R4KAL WgUcKw+VDMFRiValc/48Ec+v5/GBhFgdBC6nFkhddf8US/C/iVW2Y233GBfbQb0znljc oXtLCenWGr0gsJRg3DEThZgAqjuIxJDJpBzXj/LNGnQUqYeIKyEgXADBFUVKxVD0kjfH 81xHJF/hCf3alIIqvlbjcvMKQHfm5tBU6z98EXGonrrHIDTKK/NpM9aDr6ebUBOO+5bO 84Shkxr/N+j2ieyvgYk56W6vQmphl8b4l0MPnIO53X24rdjSoo+RnvixvEIJqdp8/SYG FT4w== X-Gm-Message-State: AOJu0YyOxLGgctU0KfAWrlM1qgmq98VYYyD5DtHahBUeTfPtFZ5G7J82 w0QSS45WElToSeCCx79KSJ6MO4AX78pupu8mvdqTrhmbVmWHFoqPk27M0nPLFgn1aH5n79A90KI = X-Gm-Gg: ASbGnctrtwYRMRQ+T4wbcAvBqgoed4tK5Ub2YC6Fv2vELpFCkguFAg3Q+EbuYTPKJRT ph61la/fypXEK007ZZsmoiWZ9ctDkNt78uxd55gPqBY3Ho2mAkhY4/rs//gleIP2PoM3D25Lenp fMbW8efio2/AP05TUP8gWaPP9IoXowiXM7hzi8Cs/iyDkeRth8qo3NrAQiUPWGLPQAk7ByDvxC3 VpLOJWd3i9V1MDRgSfh+CVOdbJMSmxWFUH3edg4w+BKZB+bfEcbG4SOIGO4pjxqmaZFtoUFrxos mXJXgSBqmAk= X-Google-Smtp-Source: AGHT+IGbEpf6yy+hm9hdRcqPhrequ5Ts/38I5vEEth2hsX1m/qoyGL6ep5YNXzLY+CzeO/ij7ddFLw== X-Received: by 2002:a05:6602:6b10:b0:83e:418c:8a28 with SMTP id ca18e2360f4ac-8447e23adaemr224165039f.7.1733452644418; Thu, 05 Dec 2024 18:37:24 -0800 (PST) Received: from chromium.org (c-73-203-119-151.hsd1.co.comcast.net. [73.203.119.151]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4e2861f51bfsm575506173.112.2024.12.05.18.37.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Dec 2024 18:37:22 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Simon Glass , Bin Meng , Marek Vasut , Martyn Welch , Michael Trimarchi , Quentin Schulz Subject: [PATCH v3 20/46] boot: pxe: Refactor label_run_boot() to avoid cmdline Date: Thu, 5 Dec 2024 19:35:59 -0700 Message-Id: <20241206023626.2456858-21-sjg@chromium.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241206023626.2456858-1-sjg@chromium.org> References: <20241206023626.2456858-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.103.8 at phobos.denx.de X-Virus-Status: Clean Adjust the remaining call in this function to use the bootm API. This will allow PXE to work without the command line. Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- (no changes since v1) arch/x86/lib/zimage.c | 27 +++++++++++++++++++-------- boot/pxe_utils.c | 13 +++++-------- include/bootm.h | 9 +++++++++ 3 files changed, 33 insertions(+), 16 deletions(-) diff --git a/arch/x86/lib/zimage.c b/arch/x86/lib/zimage.c index 4dfcde68060..26d623711bc 100644 --- a/arch/x86/lib/zimage.c +++ b/arch/x86/lib/zimage.c @@ -433,27 +433,38 @@ int zboot_go(struct bootm_info *bmi) return ret; } -int zboot_run_args(ulong addr, ulong size, ulong initrd, ulong initrd_size, - ulong base, char *cmdline) +int zboot_run(struct bootm_info *bmi) { - struct bootm_info bmi; int ret; - bootm_init(&bmi); - zboot_start(&bmi, addr, size, initrd, initrd_size, base, cmdline); - ret = zboot_load(&bmi); + ret = zboot_load(bmi); if (ret) return log_msg_ret("ld", ret); - ret = zboot_setup(&bmi); + ret = zboot_setup(bmi); if (ret) return log_msg_ret("set", ret); - ret = zboot_go(&bmi); + ret = zboot_go(bmi); if (ret) return log_msg_ret("go", ret); return -EFAULT; } +int zboot_run_args(ulong addr, ulong size, ulong initrd, ulong initrd_size, + ulong base, char *cmdline) +{ + struct bootm_info bmi; + int ret; + + bootm_init(&bmi); + zboot_start(&bmi, addr, size, initrd, initrd_size, base, cmdline); + ret = zboot_run(&bmi); + if (ret) + return log_msg_ret("zra", ret); + + return 0; +} + static void print_num(const char *name, ulong value) { printf("%-20s: %lx\n", name, value); diff --git a/boot/pxe_utils.c b/boot/pxe_utils.c index 37306f37009..a91372407eb 100644 --- a/boot/pxe_utils.c +++ b/boot/pxe_utils.c @@ -585,10 +585,8 @@ static int label_run_boot(struct pxe_context *ctx, struct pxe_label *label, char *kernel_addr, char *initrd_addr_str, char *initrd_filesize, char *initrd_str) { - char *zboot_argv[] = { "zboot", NULL, "0", NULL, NULL }; struct bootm_info bmi; ulong kernel_addr_r; - int zboot_argc = 3; void *buf; int ret; @@ -601,14 +599,13 @@ static int label_run_boot(struct pxe_context *ctx, struct pxe_label *label, return ret; bmi.addr_img = kernel_addr; - zboot_argv[1] = kernel_addr; + bootm_x86_set(&bmi, bzimage_addr, hextoul(kernel_addr, NULL)); if (initrd_addr_str) { bmi.conf_ramdisk = initrd_str; - - zboot_argv[3] = initrd_addr_str; - zboot_argv[4] = initrd_filesize; - zboot_argc = 5; + bootm_x86_set(&bmi, initrd_addr, hextoul(kernel_addr, NULL)); + bootm_x86_set(&bmi, initrd_size, + hextoul(initrd_filesize, NULL)); } if (!bmi.conf_fdt) { @@ -642,7 +639,7 @@ static int label_run_boot(struct pxe_context *ctx, struct pxe_label *label, /* Try booting an x86_64 Linux kernel image */ } else if (IS_ENABLED(CONFIG_CMD_ZBOOT)) { log_debug("using zboot\n"); - do_zboot_parent(ctx->cmdtp, 0, zboot_argc, zboot_argv, NULL); + ret = zboot_run(&bmi); } unmap_sysmem(buf); diff --git a/include/bootm.h b/include/bootm.h index d174f18ac18..465577a66f5 100644 --- a/include/bootm.h +++ b/include/bootm.h @@ -315,6 +315,15 @@ int bootm_process_cmdline(char *buf, int maxlen, int flags); */ int bootm_process_cmdline_env(int flags); +/** + * zboot_run() - Run through the various steps to boot a zimage + * + * @bmi: Bootm information, with bzimage_size, initrd_addr, initrd_size and + * cmdline set up. If base_ptr is 0, then bzimage_addr must be set to the start + * of the bzImage. Otherwise base_ptr and load_address must be provided. + */ +int zboot_run(struct bootm_info *bmi); + /** * zboot_run_args() - Run through the various steps to boot a zimage * From patchwork Fri Dec 6 02:36:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2019050 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=Tw37Dl9r; dkim-atps=neutral Authentication-Results: legolas.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=patchwork.ozlabs.org) 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 ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Y4FpX55KFz1yRL for ; Fri, 6 Dec 2024 13:39:48 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id A1ED989734; Fri, 6 Dec 2024 03:37:32 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="Tw37Dl9r"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 4BA1F89729; Fri, 6 Dec 2024 03:37:31 +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=-5.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-il1-x12d.google.com (mail-il1-x12d.google.com [IPv6:2607:f8b0:4864:20::12d]) (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 136C18918C for ; Fri, 6 Dec 2024 03:37:29 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-il1-x12d.google.com with SMTP id e9e14a558f8ab-3a777958043so6529175ab.2 for ; Thu, 05 Dec 2024 18:37:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1733452647; x=1734057447; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=EnFaitV/n0GPg6YYhPB8/MET0vxlWv6+/wH9w65GJCY=; b=Tw37Dl9r1CbCXSqXw2PbEy+AqLDrxLVRJ2LkvGvqmCOZvHsVaQ8Ef+zTcbDMvEZUfP ridghOygH3lExVXIcoAoGEL0x5Z6gfEwdc/PBX9Vpmd0uIHVvIidBWGcpYFF1T3SXnx0 CGH+rkRliOcn3erd3oFkwkInGugeZyklHFohM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733452647; x=1734057447; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=EnFaitV/n0GPg6YYhPB8/MET0vxlWv6+/wH9w65GJCY=; b=QkERJv5p+XOf8/UDAVngyqFpWy5pKC2cVcGDbCQuxCHjkX5mLK7VG+uVZOllsG+hDE wRilXc9B/9qxMjybr/58md8P7y3CdkOituqWiDzQ7hYQyyQdIAw/IgCaN6YLWDfkUFbz S8fep23v6bwBibVWc9OYvLqS6/SKJNJNl0tkuyS0vpjvtSM6sVr2clmTYuyPe4duIFCW XxpwBYMwa3bicBhN9TUD8gNOmeujLkCzTFfNFDOYktHAYghoJuUpxag87KQWq4CNKGkp twG4pNYD9p8WZo0EELeaPKRq/NfWaahS51nw0uV6gD854V1xsMJOv/wk614cpzZB65wZ 4dwg== X-Gm-Message-State: AOJu0YzoZkL/GFIYr/bKwm/CnObx6gx5QsOG4MBDTrK3gIHrLBVyi+Ii VWupoGzz48hagPW1sAYiX6/BxdoWE56SZqxJ0ToQ9ORo/XSEr7j6mKzWBUOFYQnTHxmr56Q+DPA = X-Gm-Gg: ASbGncsvXOOKBaJcJi5StgPMd10FVkaewhvFflzGdk6Da8mU0yh6XgUVkeIz2TXv6Yu EEvA7ZimHypMgAZ4SHZDOOYP3OImkxyRQVDdgV2S4xVgg9cDXckomBiIdMwVdo0Tcwqm+fwoqGM jPo8UXn42PhTHRI/mByg9LdluSLYPC+yLU0bbA6YztBmn7yKg65zn6g7LbOO/ok8gBJcR9BWLII lr0gYr79jvIhtv6F78aM30uY9QsT7Nnvfbl2OSlEJhNKwD68GYPCJJwIuKjtZFRjtiRS07dZXzM liq3NO1kKxE= X-Google-Smtp-Source: AGHT+IGrVZuaMtEuyvSsleP4e7X+b6M8y3x5L4++QMAHysLWmC/XgFemWPSmWvnuY28cxwKXO6N6yg== X-Received: by 2002:a05:6e02:1c46:b0:3a7:fe8c:b014 with SMTP id e9e14a558f8ab-3a811e29199mr17494185ab.21.1733452647276; Thu, 05 Dec 2024 18:37:27 -0800 (PST) Received: from chromium.org (c-73-203-119-151.hsd1.co.comcast.net. [73.203.119.151]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4e2861f51bfsm575506173.112.2024.12.05.18.37.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Dec 2024 18:37:25 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Simon Glass , Adriano Cordova , Ilias Apalodimas , Jerome Forissier , Joe Hershberger , Marek Vasut Subject: [PATCH v3 21/46] net: Keep the bootstage functions together Date: Thu, 5 Dec 2024 19:36:00 -0700 Message-Id: <20241206023626.2456858-22-sjg@chromium.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241206023626.2456858-1-sjg@chromium.org> References: <20241206023626.2456858-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.103.8 at phobos.denx.de X-Virus-Status: Clean Move the bootstage_mark() function just before net_loop(), so that the IPv6 code is not in the way. Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- (no changes since v1) cmd/net.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/net.c b/cmd/net.c index 79525f73a51..deebd5b710f 100644 --- a/cmd/net.c +++ b/cmd/net.c @@ -413,8 +413,6 @@ static int netboot_common(enum proto_t proto, struct cmd_tbl *cmdtp, int argc, return CMD_RET_USAGE; } - bootstage_mark(BOOTSTAGE_ID_NET_START); - if (IS_ENABLED(CONFIG_IPV6) && !use_ip6) { char *s, *e; size_t len; @@ -428,6 +426,8 @@ static int netboot_common(enum proto_t proto, struct cmd_tbl *cmdtp, int argc, } } + bootstage_mark(BOOTSTAGE_ID_NET_START); + size = net_loop(proto); if (size < 0) { bootstage_error(BOOTSTAGE_ID_NET_NETLOOP_OK); From patchwork Fri Dec 6 02:36:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2019051 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=R58gKkpv; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Y4Fpl0ZZTz1yRL for ; Fri, 6 Dec 2024 13:39:59 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 19D7C895DE; Fri, 6 Dec 2024 03:37:35 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="R58gKkpv"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 3EDC1895DE; Fri, 6 Dec 2024 03:37:34 +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=-5.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-io1-xd2f.google.com (mail-io1-xd2f.google.com [IPv6:2607:f8b0:4864:20::d2f]) (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 0F5F28918C for ; Fri, 6 Dec 2024 03:37:32 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-io1-xd2f.google.com with SMTP id ca18e2360f4ac-841a9366b08so47542939f.1 for ; Thu, 05 Dec 2024 18:37:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1733452650; x=1734057450; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=6WGopKjGf+ZI5qRJVXEab18RrPazU4gYc+ZJYFhUg1g=; b=R58gKkpvCmlWiB6S1y6UOl9TzAwPk4At9L7j7uaOARCNSY+WQ87bAN9/A1IvPZNZeR gMrb0bgQ5/WmoOkFfTpIKur8dvqceURJJfhgpHQv2n9CVwCT7pReCtwB6nnDv4XrN2nX rli0RsBCbRk9y7Kw6JPFppFk8FXdJwijsMT5g= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733452650; x=1734057450; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=6WGopKjGf+ZI5qRJVXEab18RrPazU4gYc+ZJYFhUg1g=; b=aRhPTMsEp+EmwQRz5MySgjg9pamzkJPQ67GEYeUP8kAa4KiwRn0FHrmn/vvuKVPJpF knzwC8sD6FpOnY4N4gLSIfNPNF4PbiBKkBw4YMlRupD42ntuk4et9xw5YAMSuxxEl/6h jL4SkDtsa4kDet1mkZS5nv917Lm6n2TnwdnsVKLG96FlrkukjjxiLctg5TZjufJTWtQ8 qKqdUuEqa7LvbioZu8e65Q9kFoMqCLnJyTPS9l1jo0iR7dJLWIjyjnX/9LnFsz/B/k4V e7LieAR7ZI836f+4M06DVS5OPNp+eafOLrIxlf2EVEeNAU6WDMHZ820tTcVA/isuP+eB 8vHg== X-Gm-Message-State: AOJu0YwsZ1hKRI/1IoOr+V9Znfl5/Az/fP48wGJYpJPtsAcdX/XQKA3T U+IiV68U/JYNe87Bxz9Nax4DPJSITqWL4E85J4h+YtB9sRtrDqak4FxFxsCBbLoxOGLkZijpx6M = X-Gm-Gg: ASbGncvlQve6kEX2dXT8AfELb/iV4fiAeGK9xxqfJ9qhXMPlT1NlIOVXOmqWtFHeWQl UyXz+8LG5a8ZuTxE6nWVe0sX8S2RwkCxpk1CSwP388oNJV1ktsQEu/Fwj5NNafp+V+74OGC9AnT Folb9XHcw4IXrbPzdN6NH16K9l/fKT4xebzYCqt9H5yhL4N/Jz2VlkcNwqrCmUdNNwcFuOxLl6y O6AWnRiIu7dWNZ03PcyR6Y9y591hDgtxHFGEtVQM/Qsct1q8rHPtuqeFITC6tlEYjAoIuOF29Q4 Z337eIDaCcA= X-Google-Smtp-Source: AGHT+IGBphKGyOMgKv4yTHGrhLZ4EMntxsuXJ2ZvJolBPg6Q0YWwPp2w6CvJcu10zuU9lOGsGkb2aQ== X-Received: by 2002:a05:6602:3422:b0:841:a73b:a978 with SMTP id ca18e2360f4ac-8447e23ded3mr207461639f.7.1733452650322; Thu, 05 Dec 2024 18:37:30 -0800 (PST) Received: from chromium.org (c-73-203-119-151.hsd1.co.comcast.net. [73.203.119.151]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4e2861f51bfsm575506173.112.2024.12.05.18.37.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Dec 2024 18:37:28 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Simon Glass , Ilias Apalodimas , Adriano Cordova , Jerome Forissier , Joe Hershberger , Marek Vasut Subject: [PATCH v3 22/46] net: Tidy up the comments to parse_args() Date: Thu, 5 Dec 2024 19:36:01 -0700 Message-Id: <20241206023626.2456858-23-sjg@chromium.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241206023626.2456858-1-sjg@chromium.org> References: <20241206023626.2456858-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.103.8 at phobos.denx.de X-Virus-Status: Clean This function is a bit vague as to what it does. Expand the comment a little, to specify which args are provided and which variables are updated. Signed-off-by: Simon Glass Acked-by: Ilias Apalodimas Signed-off-by: Simon Glass Acked-by: Ilias Apalodimas --- (no changes since v1) cmd/net.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/cmd/net.c b/cmd/net.c index deebd5b710f..89a4d9b38d4 100644 --- a/cmd/net.c +++ b/cmd/net.c @@ -313,9 +313,18 @@ static int parse_addr_size(char * const argv[]) /** * parse_args() - parse command line arguments * + * Sets: + * + * - net_boot_file_name_explicit to true if a filename was specified + * - net_boot_file_name to that filename, if specified, else the value of the + * 'bootfile' environment variable + * - image_load_addr if a load address was provided + * - image_save_addr and image_save_size, if proto == TFTPPUT + * * @proto: command prototype - * @argc: number of arguments - * @argv: command line arguments + * @argc: number of arguments, include the command, which has already been + * parsed + * @argv: command line arguments, with argv[0] being the command * Return: 0 on success */ static int parse_args(enum proto_t proto, int argc, char *const argv[]) From patchwork Fri Dec 6 02:36:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2019052 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=Hd18a1nR; dkim-atps=neutral Authentication-Results: legolas.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=patchwork.ozlabs.org) 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 ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Y4Fpw3GBCz1yRK for ; Fri, 6 Dec 2024 13:40:08 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 77FC58951F; Fri, 6 Dec 2024 03:37:37 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="Hd18a1nR"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 39F6F89629; Fri, 6 Dec 2024 03:37:37 +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=-5.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-io1-xd35.google.com (mail-io1-xd35.google.com [IPv6:2607:f8b0:4864:20::d35]) (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 E706A8918C for ; Fri, 6 Dec 2024 03:37:34 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-io1-xd35.google.com with SMTP id ca18e2360f4ac-841a7ae8d8aso107755339f.1 for ; Thu, 05 Dec 2024 18:37:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1733452653; x=1734057453; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=e1Iq6mSs4INgAob9R3/1RMubhmT6VYYhyvbqf/5X+3w=; b=Hd18a1nRWQEX2yRkRdpbD3jWCg8mSVXFuO3fo7xv4xaZIEg1fTVq1wZfpXYD0lyNN0 gZvyv1Ob2mTGsbWTVcCr3Sfl5x7FUwk66j7MCQe5tjRO/VNxmIqqTvpVUtkyaj/aq9cV SAxk6J3qrIit5XGuWE/iNHqTm6oFfCaZ47pMM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733452653; x=1734057453; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=e1Iq6mSs4INgAob9R3/1RMubhmT6VYYhyvbqf/5X+3w=; b=pDtuasrsRvDUGbKkaGiRgtsCKaP4q9IpyIzt9tPp9lP/uV1I7w+fgwxCzrgwqcksBD fUWoOFBUzm62fIstMhW87Wo+DuXGwK/K+aDQsAxf5XniU3CYkAmiYWDjdJWPn8q1ghdD XBz+QyJSYvypNGUUN4UhjohyEMRFSMyDdY3bA4C0WmHkf9pZIqX1gI8XNzw7A9a582Mc SJN/RYrrqJjpcsmjW+GB8HhzH9gMfJMBUo1NHVys/Cj7t9xN6Ew/i0iMcLyQ64LXpDCl g4FMu8fiRNelGI4cOBoUQkpK603fP24fvIVC9qSwtam8hk3tPlPWJGBSIDPwgTinBqSL ScSA== X-Gm-Message-State: AOJu0Ywq8IarcUF88ako7faqNTGQGMjYD7pZvuCo/CqjkvgcXsh/dEbS HoOU1MSoKRxVrFWSABUkxg6zG5ZPyQhwTXCvcJs0MkjBPRLhSP3gO4V7VtJuTf4PhgvDQkA3Kc4 = X-Gm-Gg: ASbGncvIB8WyfwW5ctwMbq8kg4OTwFt5rG5Uyb582lfpRqILKMLp5pGcPSci1uWs8Za c5Y8V1k55OOckQuZ2xxonphXLc7f3EwOOAacA3q70+p6pDTUPpbQMFJLibQ6Oedic0SV06pTCWf ErzIh1RsqmGeDgYWw8nezmEApsn7XJTFsq+q5LbrS15Gs47MfW/DE+rQtY3Zj+4QjhwvOot+iPp R1uCijPzyuhp7RTqGL8CF3tydNJVJrC1IoqOpl+3mAmg/31URhVH2wCjUb/nLRSM20eu3VuLjAF xdkW0O2qfTI= X-Google-Smtp-Source: AGHT+IESNYJm0yE1C6xOMvI2cI/PknJB4V6ouLHUxvn3JNKb0sqyt6vFuUavy0dLahsWBSxeg5mESg== X-Received: by 2002:a05:6602:6c18:b0:83a:b188:7a4d with SMTP id ca18e2360f4ac-8447e0da473mr238819039f.0.1733452653176; Thu, 05 Dec 2024 18:37:33 -0800 (PST) Received: from chromium.org (c-73-203-119-151.hsd1.co.comcast.net. [73.203.119.151]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4e2861f51bfsm575506173.112.2024.12.05.18.37.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Dec 2024 18:37:31 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Simon Glass , Adriano Cordova , Ilias Apalodimas , Jerome Forissier , Joe Hershberger , Marek Vasut Subject: [PATCH v3 23/46] net: Simplify parse_args() Date: Thu, 5 Dec 2024 19:36:02 -0700 Message-Id: <20241206023626.2456858-24-sjg@chromium.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241206023626.2456858-1-sjg@chromium.org> References: <20241206023626.2456858-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.103.8 at phobos.denx.de X-Virus-Status: Clean This function repeats the same code in a few places, namely setting net_boot_file_name_explicit and copying of the filename to net_boot_file_name Move these two operations to the caller, with just the filename (or NULL) returned by parse_args() This makes things a little easier to follow. Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- (no changes since v1) cmd/net.c | 45 ++++++++++++++++++++------------------------- 1 file changed, 20 insertions(+), 25 deletions(-) diff --git a/cmd/net.c b/cmd/net.c index 89a4d9b38d4..cc7d14eb082 100644 --- a/cmd/net.c +++ b/cmd/net.c @@ -314,10 +314,6 @@ static int parse_addr_size(char * const argv[]) * parse_args() - parse command line arguments * * Sets: - * - * - net_boot_file_name_explicit to true if a filename was specified - * - net_boot_file_name to that filename, if specified, else the value of the - * 'bootfile' environment variable * - image_load_addr if a load address was provided * - image_save_addr and image_save_size, if proto == TFTPPUT * @@ -325,21 +321,20 @@ static int parse_addr_size(char * const argv[]) * @argc: number of arguments, include the command, which has already been * parsed * @argv: command line arguments, with argv[0] being the command + * @fnamep: set to the filename, if provided, else NULL * Return: 0 on success */ -static int parse_args(enum proto_t proto, int argc, char *const argv[]) +static int parse_args(enum proto_t proto, int argc, char *const argv[], + const char **fnamep) { ulong addr; char *end; + *fnamep = NULL; switch (argc) { case 1: if (IS_ENABLED(CONFIG_CMD_TFTPPUT) && proto == TFTPPUT) return 1; - - /* refresh bootfile name from env */ - copy_filename(net_boot_file_name, env_get("bootfile"), - sizeof(net_boot_file_name)); break; case 2: @@ -352,16 +347,10 @@ static int parse_args(enum proto_t proto, int argc, char *const argv[]) * mis-interpreted as a valid number. */ addr = hextoul(argv[1], &end); - if (end == (argv[1] + strlen(argv[1]))) { + if (end == (argv[1] + strlen(argv[1]))) image_load_addr = addr; - /* refresh bootfile name from env */ - copy_filename(net_boot_file_name, env_get("bootfile"), - sizeof(net_boot_file_name)); - } else { - net_boot_file_name_explicit = true; - copy_filename(net_boot_file_name, argv[1], - sizeof(net_boot_file_name)); - } + else + *fnamep = argv[1]; break; case 3: @@ -370,9 +359,7 @@ static int parse_args(enum proto_t proto, int argc, char *const argv[]) return 1; } else { image_load_addr = hextoul(argv[1], NULL); - net_boot_file_name_explicit = true; - copy_filename(net_boot_file_name, argv[2], - sizeof(net_boot_file_name)); + *fnamep = argv[2]; } break; @@ -380,20 +367,20 @@ static int parse_args(enum proto_t proto, int argc, char *const argv[]) case 4: if (parse_addr_size(argv)) return 1; - net_boot_file_name_explicit = true; - copy_filename(net_boot_file_name, argv[3], - sizeof(net_boot_file_name)); + *fnamep = argv[3]; break; #endif default: return 1; } + return 0; } static int netboot_common(enum proto_t proto, struct cmd_tbl *cmdtp, int argc, char *const argv[]) { + const char *fname; char *s; int rcode = 0; int size; @@ -417,11 +404,19 @@ static int netboot_common(enum proto_t proto, struct cmd_tbl *cmdtp, int argc, } } - if (parse_args(proto, argc, argv)) { + if (parse_args(proto, argc, argv, &fname)) { bootstage_error(BOOTSTAGE_ID_NET_START); return CMD_RET_USAGE; } + if (fname) { + net_boot_file_name_explicit = true; + } else { + net_boot_file_name_explicit = false; + fname = env_get("bootfile"); + } + copy_filename(net_boot_file_name, fname, sizeof(net_boot_file_name)); + if (IS_ENABLED(CONFIG_IPV6) && !use_ip6) { char *s, *e; size_t len; From patchwork Fri Dec 6 02:36:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2019053 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=aEKf4LDE; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Y4Fq54gS8z1yRK for ; Fri, 6 Dec 2024 13:40:17 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id CE51789754; Fri, 6 Dec 2024 03:37:40 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="aEKf4LDE"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 1571589752; Fri, 6 Dec 2024 03:37:40 +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=-5.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-il1-x12c.google.com (mail-il1-x12c.google.com [IPv6:2607:f8b0:4864:20::12c]) (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 D6E0489740 for ; Fri, 6 Dec 2024 03:37:37 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-il1-x12c.google.com with SMTP id e9e14a558f8ab-3a7d690479eso6944345ab.0 for ; Thu, 05 Dec 2024 18:37:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1733452656; x=1734057456; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=+310A69RNHaeLpwQcsGXHqFegngMu3nd8c1Ch+d3To4=; b=aEKf4LDESCnj6Q6PtpGf+hxMgEozkDlfoOhkjctuzLPWqvd5ifHarNcDhsZ+fk0IzD smVzBjvhuKSFqCzwaz6seKSP/nIb7Jr4rOP+OKVtJ1rdIRlBE+a8gLZeus+gr3HH48Lk sK7DBTy5BaAOKT918eQKQXp1GChvahwnR0A5U= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733452656; x=1734057456; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+310A69RNHaeLpwQcsGXHqFegngMu3nd8c1Ch+d3To4=; b=FDvsVR+N1J6UeofEBD6+8HkKhEdzAHnbDsRIe+/Jz8bMgzswfrqQlAgfAU5V7lUKwN acEm1iYZ43br/ynMkTwTcDdpnHEtjN4dZ4e54vo9NTfZMbMdRdsJaabF7icn1/R9To2R qoA8jaAUwTImJLuUQ9HCmqXwnmevZyM5Kyb4uBPDK73+hb7qYLQznwUb4D10949AAyX1 5ETormosKdPSvwdbqyb9v0Nse2AXxgWGDIr2BOZCB9ur7LX2GRiodCZvDmksW28X5aR8 ZdIH5eTIWyRyYK0RkTq4DEJzirmvhJrdY8yeNpawBsbgXBCqH8g9xKuiHWIkfLO3y9Um H31g== X-Gm-Message-State: AOJu0YxwZbOXLz8GM90SWcR0kTURJ+9qnwp/8aAIgjXGCcIwA88zMBxb mkjXkU/zDO2gISXarlNUdKtz3JdEohSH56RDVzP6AFqi7au/LSSfXEP0254Mhh0vp4fjYX2sc3M = X-Gm-Gg: ASbGncv+wBD4vsRFbFtruUJxAEZGxujvAFjUY3e4SLaCxwEPkUXAfAgCQaaiJYtJ7ok Wq+qqvY2TyPQMr8YjdusTvRYnQXhve4767F1mpKQ3tkaBL+0j3oXxW+N/n/Up4ECN4/hHNOYTf4 g1tIqCe3c4JTDDYJnbuv4wZY28AuatIl6cRSKAvUcmNb9u4cwyeOdSUvhou8eH4sPhfy7hdwjt3 1Lu9GFJnZnvBJi1pFlKvtV0RlvGp4HXHLAdBApKNnfBqCh1HYf+FghUdbN6PIcAjbHncd01l9wK Rs/AJN7cEOQ= X-Google-Smtp-Source: AGHT+IHWTRQtLYaqwYr/D6wg0fCfFFWw8jB39eCLVzgFuCGqaoy8ccowCgXwNvhVmLa9gaTEZa7Zcw== X-Received: by 2002:a05:6e02:12c2:b0:3a7:e047:733f with SMTP id e9e14a558f8ab-3a811c7a445mr22883055ab.1.1733452656151; Thu, 05 Dec 2024 18:37:36 -0800 (PST) Received: from chromium.org (c-73-203-119-151.hsd1.co.comcast.net. [73.203.119.151]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4e2861f51bfsm575506173.112.2024.12.05.18.37.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Dec 2024 18:37:34 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Simon Glass , Adriano Cordova , Ilias Apalodimas , Jerome Forissier , Joe Hershberger , Marek Vasut Subject: [PATCH v3 24/46] net: Return the load address from parse_args() Date: Thu, 5 Dec 2024 19:36:03 -0700 Message-Id: <20241206023626.2456858-25-sjg@chromium.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241206023626.2456858-1-sjg@chromium.org> References: <20241206023626.2456858-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.103.8 at phobos.denx.de X-Virus-Status: Clean Rather than updating the global, update the value of a parameter, so the action of the function is simpler. Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- (no changes since v1) cmd/net.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/cmd/net.c b/cmd/net.c index cc7d14eb082..d15d344cb54 100644 --- a/cmd/net.c +++ b/cmd/net.c @@ -314,7 +314,6 @@ static int parse_addr_size(char * const argv[]) * parse_args() - parse command line arguments * * Sets: - * - image_load_addr if a load address was provided * - image_save_addr and image_save_size, if proto == TFTPPUT * * @proto: command prototype @@ -322,10 +321,12 @@ static int parse_addr_size(char * const argv[]) * parsed * @argv: command line arguments, with argv[0] being the command * @fnamep: set to the filename, if provided, else NULL + * @addrp: returns the load address, if any is provided, else it is left + * unchanged * Return: 0 on success */ static int parse_args(enum proto_t proto, int argc, char *const argv[], - const char **fnamep) + const char **fnamep, ulong *addrp) { ulong addr; char *end; @@ -348,7 +349,7 @@ static int parse_args(enum proto_t proto, int argc, char *const argv[], */ addr = hextoul(argv[1], &end); if (end == (argv[1] + strlen(argv[1]))) - image_load_addr = addr; + *addrp = addr; else *fnamep = argv[1]; break; @@ -358,7 +359,7 @@ static int parse_args(enum proto_t proto, int argc, char *const argv[], if (parse_addr_size(argv)) return 1; } else { - image_load_addr = hextoul(argv[1], NULL); + *addrp = hextoul(argv[1], NULL); *fnamep = argv[2]; } break; @@ -404,7 +405,7 @@ static int netboot_common(enum proto_t proto, struct cmd_tbl *cmdtp, int argc, } } - if (parse_args(proto, argc, argv, &fname)) { + if (parse_args(proto, argc, argv, &fname, &image_load_addr)) { bootstage_error(BOOTSTAGE_ID_NET_START); return CMD_RET_USAGE; } From patchwork Fri Dec 6 02:36:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2019054 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=Kx0fKMUW; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Y4FqG1wjzz1yRK for ; Fri, 6 Dec 2024 13:40:26 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 2D2B489740; Fri, 6 Dec 2024 03:37:43 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="Kx0fKMUW"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 4619189749; Fri, 6 Dec 2024 03:37:42 +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=-5.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-io1-xd30.google.com (mail-io1-xd30.google.com [IPv6:2607:f8b0:4864:20::d30]) (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 0BFB38918C for ; Fri, 6 Dec 2024 03:37:40 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-io1-xd30.google.com with SMTP id ca18e2360f4ac-843e3b49501so49215139f.0 for ; Thu, 05 Dec 2024 18:37:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1733452658; x=1734057458; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=TASgF64mELNe+oUxBSLXMSx1uLGUSsbkbeCaOKlmuAo=; b=Kx0fKMUWyhZLKoNMUTHNhy+Xr7xhEdOYgHo3zcsl61TLWXiflomAii2467RoqLrV+q gI+L37NN0/dgrDP8em6WruoZwQ+OG8otGOPJKhUHxU9lrBFgZxT0WN2HBIUvC4uDlGE+ fworPfcojJ3Ami9czZemV1dGg3kipJdg+obBg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733452658; x=1734057458; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=TASgF64mELNe+oUxBSLXMSx1uLGUSsbkbeCaOKlmuAo=; b=s/ALUacQrOYqGga8fRW77Aa0iZjPpnmtTYBV1kHShxFL2lFJMKhowEXiTLYBhzIz/p Gy/u25Z/BG8fDiiqt3bF7ak7nzi9ypsX4HK2Vy4mgwcGbY2FoP2LVxVaiQuSAJpWdTaP KQNdgVeT8WB8nv2qEPli1S9BabBGQxWQi21U2TsYm5lSEApIGKnfmIArHPKpN09d/kuq IXyyfNBV0fUwl6dFwkklqxAySI9hhGB5PX7s2qVUrVRapbHm7Pr/klIkF2Zioi86sseN 9XtRRAI3rG9W0pdN8YV52kfDO6v63xHs66DVmSh2AjMpsDcpvbLmUmEaeKW5YqyVW5UK /wLQ== X-Gm-Message-State: AOJu0Yw7pyA7G06tpDTSoVhpQdRqNtO6wxYXyiXEACrh/Hu0jdfP/4qA Kg0NpyxVbhvBXHbBVRpClyBKdPjigyoFNZ3l4BJ1x9vUuJFYRkfwgPUyFbV5zqqEci2bIcuutAY = X-Gm-Gg: ASbGncvLzk9bla81Q8j+H2QS8QBsPc4fmKizePPk/8Vg97SNLO+BfyXLRYMQ5okXSV+ Mk31JgsB18j5UrOHYNrZxFsfXgtRfiQbxjmzcnRNRuuqW0Xav7FwDySheeX9Ss0PUingseWAeyq jnP3mXPvAWE0JapfXXVumVSBkTbm7/PxGjh1snpbLprhrlPTcsS83rXgz5LrbksDHGJoXaqQO0g OYnVC5etEWnYGWd6iQfRzBxzUA3A2PYmgvJ25eyt78Fz+YbF4BF9RALI9Q1edKb9Fz3SYnju7aG O0fxz7T3xqs= X-Google-Smtp-Source: AGHT+IHMxsJ1yjUpcXsGPott6WaN/8uI6TPUOVIfhkEhE8UqMF08e+Gg/KW8wQmc/O0+zo35JYakrw== X-Received: by 2002:a05:6602:48e:b0:843:e667:f198 with SMTP id ca18e2360f4ac-8447e20004emr248070239f.2.1733452658247; Thu, 05 Dec 2024 18:37:38 -0800 (PST) Received: from chromium.org (c-73-203-119-151.hsd1.co.comcast.net. [73.203.119.151]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4e2861f51bfsm575506173.112.2024.12.05.18.37.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Dec 2024 18:37:36 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Simon Glass , Adriano Cordova , Ilias Apalodimas , Jerome Forissier , Joe Hershberger , Marek Vasut Subject: [PATCH v3 25/46] net: Return the address and size from parse_addr_size() Date: Thu, 5 Dec 2024 19:36:04 -0700 Message-Id: <20241206023626.2456858-26-sjg@chromium.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241206023626.2456858-1-sjg@chromium.org> References: <20241206023626.2456858-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.103.8 at phobos.denx.de X-Virus-Status: Clean Rather than updating the global, update the value of some parameters, so the action of the function is simpler. Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- (no changes since v1) cmd/net.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/cmd/net.c b/cmd/net.c index d15d344cb54..cc968e9460f 100644 --- a/cmd/net.c +++ b/cmd/net.c @@ -297,13 +297,15 @@ static void netboot_update_env(void) /** * parse_addr_size() - parse address and size arguments for tftpput * - * @argv: command line arguments + * @argv: command line arguments (argv[1] and argv[2] must be valid) + * @addrp: returns the address, on success + * @sizep: returns the size, on success * Return: 0 on success */ -static int parse_addr_size(char * const argv[]) +static int parse_addr_size(char * const argv[], ulong *addrp, ulong *sizep) { - if (strict_strtoul(argv[1], 16, &image_save_addr) < 0 || - strict_strtoul(argv[2], 16, &image_save_size) < 0) { + if (strict_strtoul(argv[1], 16, addrp) < 0 || + strict_strtoul(argv[2], 16, sizep) < 0) { printf("Invalid address/size\n"); return CMD_RET_USAGE; } @@ -356,7 +358,8 @@ static int parse_args(enum proto_t proto, int argc, char *const argv[], case 3: if (IS_ENABLED(CONFIG_CMD_TFTPPUT) && proto == TFTPPUT) { - if (parse_addr_size(argv)) + if (parse_addr_size(argv, &image_save_addr, + &image_save_size)) return 1; } else { *addrp = hextoul(argv[1], NULL); @@ -366,7 +369,7 @@ static int parse_args(enum proto_t proto, int argc, char *const argv[], #ifdef CONFIG_CMD_TFTPPUT case 4: - if (parse_addr_size(argv)) + if (parse_addr_size(argv, &image_save_addr, &image_save_size)) return 1; *fnamep = argv[3]; break; From patchwork Fri Dec 6 02:36:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2019055 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=UPAxDJMI; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Y4FqR0XKFz1yRK for ; Fri, 6 Dec 2024 13:40:35 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 874E88962F; Fri, 6 Dec 2024 03:37:46 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="UPAxDJMI"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 6BA7189629; Fri, 6 Dec 2024 03:37:44 +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=-5.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-il1-x135.google.com (mail-il1-x135.google.com [IPv6:2607:f8b0:4864:20::135]) (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 31B7589748 for ; Fri, 6 Dec 2024 03:37:42 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-il1-x135.google.com with SMTP id e9e14a558f8ab-3a7d7c1b190so5591735ab.3 for ; Thu, 05 Dec 2024 18:37:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1733452660; x=1734057460; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Yv39WvHDrKZ7gT7q3Ct6k+vlbpMf/MblKm3sDcXH3hw=; b=UPAxDJMISNRoCV2NnVKysimPTCdpaqjUregpf1HUDRtN7zmFS84M0fy/RtKV48Irwl NrBbVafi14VK336nOZnX53m4jb9cROG32duPYJAwSImc0JkczyPNGKany4tiMDr6M1rB jLrStdo/SCvJZS6EepmVInoDjNZCLRvaod+/0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733452660; x=1734057460; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Yv39WvHDrKZ7gT7q3Ct6k+vlbpMf/MblKm3sDcXH3hw=; b=gd6JpF4kYeYwK7ldHqgFvEACnKsk28c7q7wV1ncldLVhtbG4Ir1BZ7R1WRg1LGDLHn JxwurEIOETO8wvcRODDWqcGg77P69xwzL4bc4tN10o6vOEiyjt/xHL9N3rEhx8RvuttC Rbp/4ns3begmtvxsDbMLOfpo5YTNxxVHhKptx+pn/l0o8LWJTYaxQkkhQp+0Hyy1VWZS UAq3RjWMeQFzTsXU07C+dRiXPEIKMlmqKm2T/rm4r2pLuAT9s1o5msOlWfkgrmxWNePD gaJkQrJSr5Kp5JMrZ6hhyFaFmr/ns5ZW0MZMJpkhI+7NHsmbMsLFRZBgo0Fmd7M/zkMj /0/A== X-Gm-Message-State: AOJu0Yzn2IzQr1taSvGvLqLFf/NFQvkwo0IBP+Bd4CakJfXiIqHBYhZv 7GCi9MT+xtdjxBO2W0ZIPdRVNr61K0Y44CGV5zc+IM2PBu/RHpfrpXA30UzWMQB4BVmm0KioDmk = X-Gm-Gg: ASbGncvemwkyiY7WjYk+ViVww3u5Iko8LoD7kxaoxnvtP06MW+Gqm8Byn11WH804qz6 PgUtH5tSmocLICqDfZ6f4ss38eTTbW0WnGy/WHffE7wgnQtFiEdawx7VimwMtAhU2MU2hBSblNk mEM1xY4RzzfdJuW8+PyTHQVVM5W7kKUDXJFmL6FKmINrNg6k87xdm5kn+4rNujFfYm7ZHuPw9sV Yj1RwboTgOHDO/VCGvsKCjQ2VH/Qh13yW6ICLmnNx/n7nBf5cCfBy14W6xv9l28CaS9Hqd9N2FZ qNNCGDwIJL4= X-Google-Smtp-Source: AGHT+IElMap1576eiwmZIBoIHf4/afTYyygSY0NnOq4czMmimli111r2nCD4Y5uLFKePZHF67mGHAg== X-Received: by 2002:a05:6e02:1544:b0:3a7:e0d1:e255 with SMTP id e9e14a558f8ab-3a811e4d2b4mr22386395ab.23.1733452660415; Thu, 05 Dec 2024 18:37:40 -0800 (PST) Received: from chromium.org (c-73-203-119-151.hsd1.co.comcast.net. [73.203.119.151]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4e2861f51bfsm575506173.112.2024.12.05.18.37.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Dec 2024 18:37:39 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Simon Glass , Adriano Cordova , Ilias Apalodimas , Jerome Forissier , Joe Hershberger , Marek Vasut Subject: [PATCH v3 26/46] net: Return the size from parse_args() Date: Thu, 5 Dec 2024 19:36:05 -0700 Message-Id: <20241206023626.2456858-27-sjg@chromium.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241206023626.2456858-1-sjg@chromium.org> References: <20241206023626.2456858-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.103.8 at phobos.denx.de X-Virus-Status: Clean Rather than setting global variables, return the size, if provided. For tftput, use the addr argument to store the save address, to avoid adding yet another parameter. Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- (no changes since v1) cmd/net.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/cmd/net.c b/cmd/net.c index cc968e9460f..572fa75a72f 100644 --- a/cmd/net.c +++ b/cmd/net.c @@ -323,12 +323,14 @@ static int parse_addr_size(char * const argv[], ulong *addrp, ulong *sizep) * parsed * @argv: command line arguments, with argv[0] being the command * @fnamep: set to the filename, if provided, else NULL - * @addrp: returns the load address, if any is provided, else it is left + * @addrp: returns the load/save address, if any is provided, else it is + * left unchanged + * @sizep: returns the save size, if any is provided, else it is left * unchanged * Return: 0 on success */ static int parse_args(enum proto_t proto, int argc, char *const argv[], - const char **fnamep, ulong *addrp) + const char **fnamep, ulong *addrp, ulong *sizep) { ulong addr; char *end; @@ -358,8 +360,7 @@ static int parse_args(enum proto_t proto, int argc, char *const argv[], case 3: if (IS_ENABLED(CONFIG_CMD_TFTPPUT) && proto == TFTPPUT) { - if (parse_addr_size(argv, &image_save_addr, - &image_save_size)) + if (parse_addr_size(argv, addrp, sizep)) return 1; } else { *addrp = hextoul(argv[1], NULL); @@ -369,7 +370,7 @@ static int parse_args(enum proto_t proto, int argc, char *const argv[], #ifdef CONFIG_CMD_TFTPPUT case 4: - if (parse_addr_size(argv, &image_save_addr, &image_save_size)) + if (parse_addr_size(argv, addrp, sizep)) return 1; *fnamep = argv[3]; break; @@ -385,6 +386,7 @@ static int netboot_common(enum proto_t proto, struct cmd_tbl *cmdtp, int argc, char *const argv[]) { const char *fname; + ulong addr; char *s; int rcode = 0; int size; @@ -392,10 +394,10 @@ static int netboot_common(enum proto_t proto, struct cmd_tbl *cmdtp, int argc, net_boot_file_name_explicit = false; *net_boot_file_name = '\0'; - /* pre-set image_load_addr */ + /* pre-set addr */ s = env_get("loadaddr"); if (s != NULL) - image_load_addr = hextoul(s, NULL); + addr = hextoul(s, NULL); if (IS_ENABLED(CONFIG_IPV6)) { use_ip6 = false; @@ -408,10 +410,14 @@ static int netboot_common(enum proto_t proto, struct cmd_tbl *cmdtp, int argc, } } - if (parse_args(proto, argc, argv, &fname, &image_load_addr)) { + if (parse_args(proto, argc, argv, &fname, &addr, &image_save_size)) { bootstage_error(BOOTSTAGE_ID_NET_START); return CMD_RET_USAGE; } + if (IS_ENABLED(CONFIG_CMD_TFTPPUT) && proto == TFTPPUT) + image_save_addr = addr; + else + image_load_addr = addr; if (fname) { net_boot_file_name_explicit = true; From patchwork Fri Dec 6 02:36:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2019056 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=AvHb6orD; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Y4Fqb6ydZz1yRK for ; Fri, 6 Dec 2024 13:40:43 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id EA07F89745; Fri, 6 Dec 2024 03:37:47 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="AvHb6orD"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 193C68974E; Fri, 6 Dec 2024 03:37:47 +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=-5.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-il1-x12d.google.com (mail-il1-x12d.google.com [IPv6:2607:f8b0:4864:20::12d]) (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 CFFBA8918C for ; Fri, 6 Dec 2024 03:37:44 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-il1-x12d.google.com with SMTP id e9e14a558f8ab-3a813899384so882645ab.1 for ; Thu, 05 Dec 2024 18:37:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1733452662; x=1734057462; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=1iSLRxEmx5EzvBCuLgq4Mu5ho7dzmKpouUz9dyWfVWU=; b=AvHb6orDnUdzBEs/oMe+LVQl5EIJU2ihgPji5wj62HdgBgfKg85TVyMtHPkzxTcmE0 Yp/kINqIDZmlIjyHRw1MbMsd2RhuXF751lRTAvUWK0hy3buR5styGsnTRNfuuIXS0Q1I 0kAZs2js8xDJZOM+u00RnUcTyxD38M0HavgrE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733452662; x=1734057462; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1iSLRxEmx5EzvBCuLgq4Mu5ho7dzmKpouUz9dyWfVWU=; b=rvGcdup89ECr4rI+zoJasIsxgZqaR+pkr+lEL01uLbsW7qli7GBn1wF73Gnxy0+IjU HJForZyS97Ve4DGYu7zJP8qHtZGvARNtlIp7b/Vdbx3i+famomuqqXKvOs77roJNWvGZ kT4vosjaJDR+iCcMRH3DXxEmQfvHzyJdJvHMudSs3NY2ThlZjTUVLJDOTUCrl2SUt0/o WQZtM68MkaGqMJFLsFbjpPlza9dx3EPIQfKwCDeQio+z96ZM89amhzDs27BeXE0xQo9j ZkB6CDcW+839JQj96OzPIOj/sN1dMz6hIGdHd2ztteksTg2eVIKiTtk+SsoltWBwfARA rQqg== X-Gm-Message-State: AOJu0YxE5Qpz+XE0/t80ZE86KrI5LSZVYaGtp7IdH/gmYL/mBwFMnY7i MhM2+vXZ3Ya5g8FQsDrejKt3VzIGLbEX+l9btMNkVqKR+HLv689RmCtgmQt+wAEW9Q2H5KQLJQM = X-Gm-Gg: ASbGnct7P2DOUqEUMyuUtGLLzpKJp1IynJjFbTwXqWcHQ4tMyjSjzlMvSl9NVcz3Nf8 ThrPFpuIOYP80sZWXBWNaMpf7KvDXc3GRuDrSxyCzh1OUHbSYpBywp6uGnhNQ0Qf9u9uz60tt2M XvrnOMGycqR8dirzUpNZaIKKGrW0P2VQIu4aaD/u0LmxEfNBE6cMrXU18ps7IGiK47lesURct8Q wuR5z2KTnFld0ChXTkQW5jlkrMrDG66kFVmcVlNWY53BpUxgRXHawrRm9J0sFcmSdIdUeYkg8Yg 5E1+Jh6rYhQ= X-Google-Smtp-Source: AGHT+IERgGYLMQX8DyiFu1LjTTZFIXe9qMDjtZkFNA/dDay1cCG4l0cb8q+AHwkLKKxS/+R8wYLI8g== X-Received: by 2002:a92:c242:0:b0:3a7:d84c:f2a0 with SMTP id e9e14a558f8ab-3a811dc3a1amr18855095ab.7.1733452662571; Thu, 05 Dec 2024 18:37:42 -0800 (PST) Received: from chromium.org (c-73-203-119-151.hsd1.co.comcast.net. [73.203.119.151]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4e2861f51bfsm575506173.112.2024.12.05.18.37.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Dec 2024 18:37:41 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Simon Glass , Adriano Cordova , Ilias Apalodimas , Jerome Forissier , Joe Hershberger , Marek Vasut Subject: [PATCH v3 27/46] net: Refactor part of netboot_common() into a function Date: Thu, 5 Dec 2024 19:36:06 -0700 Message-Id: <20241206023626.2456858-28-sjg@chromium.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241206023626.2456858-1-sjg@chromium.org> References: <20241206023626.2456858-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.103.8 at phobos.denx.de X-Virus-Status: Clean Move the core code for starting an netboot operation into a separate function, so that we can (with additional work) move towards calling it from outside the file. Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- (no changes since v1) cmd/net.c | 62 +++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 46 insertions(+), 16 deletions(-) diff --git a/cmd/net.c b/cmd/net.c index 572fa75a72f..f980448e0ef 100644 --- a/cmd/net.c +++ b/cmd/net.c @@ -382,11 +382,50 @@ static int parse_args(enum proto_t proto, int argc, char *const argv[], return 0; } +static int netboot_run_(enum proto_t proto, ulong addr, const char *fname, + ulong size, bool fname_explicit, bool ipv6) +{ + int ret; + + bootstage_mark(BOOTSTAGE_ID_NET_START); + + /* + * For now we use the global variables as that is the only way to + * control the network stack. At some point, perhaps, the state could be + * in a struct + */ + if (IS_ENABLED(CONFIG_CMD_TFTPPUT) && proto == TFTPPUT) + image_save_addr = addr; + else + image_load_addr = addr; + + net_boot_file_name_explicit = fname_explicit; + copy_filename(net_boot_file_name, fname, sizeof(net_boot_file_name)); + if (IS_ENABLED(CONFIG_IPV6)) + use_ip6 = ipv6; + if (IS_ENABLED(CONFIG_CMD_TFTPPUT) && proto == TFTPPUT) { + image_save_addr = addr; + image_save_size = size; + } else { + image_load_addr = addr; + } + + ret = net_loop(proto); + if (ret < 0) { + bootstage_error(BOOTSTAGE_ID_NET_NETLOOP_OK); + return ret; + } + bootstage_mark(BOOTSTAGE_ID_NET_NETLOOP_OK); + + return 0; +} + static int netboot_common(enum proto_t proto, struct cmd_tbl *cmdtp, int argc, char *const argv[]) { + ulong addr, save_size; + bool fname_explicit; const char *fname; - ulong addr; char *s; int rcode = 0; int size; @@ -410,22 +449,17 @@ static int netboot_common(enum proto_t proto, struct cmd_tbl *cmdtp, int argc, } } - if (parse_args(proto, argc, argv, &fname, &addr, &image_save_size)) { + if (parse_args(proto, argc, argv, &fname, &addr, &save_size)) { bootstage_error(BOOTSTAGE_ID_NET_START); return CMD_RET_USAGE; } - if (IS_ENABLED(CONFIG_CMD_TFTPPUT) && proto == TFTPPUT) - image_save_addr = addr; - else - image_load_addr = addr; if (fname) { - net_boot_file_name_explicit = true; + fname_explicit = true; } else { - net_boot_file_name_explicit = false; + fname_explicit = false; fname = env_get("bootfile"); } - copy_filename(net_boot_file_name, fname, sizeof(net_boot_file_name)); if (IS_ENABLED(CONFIG_IPV6) && !use_ip6) { char *s, *e; @@ -440,14 +474,10 @@ static int netboot_common(enum proto_t proto, struct cmd_tbl *cmdtp, int argc, } } - bootstage_mark(BOOTSTAGE_ID_NET_START); - - size = net_loop(proto); - if (size < 0) { - bootstage_error(BOOTSTAGE_ID_NET_NETLOOP_OK); + size = netboot_run_(proto, addr, fname, save_size, fname_explicit, + use_ip6); + if (size < 0) return CMD_RET_FAILURE; - } - bootstage_mark(BOOTSTAGE_ID_NET_NETLOOP_OK); /* net_loop ok, update environment */ netboot_update_env(); From patchwork Fri Dec 6 02:36:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2019057 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=Zq9Kc+UX; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Y4Fqm6Pqyz1yRK for ; Fri, 6 Dec 2024 13:40:52 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 54E4C89752; Fri, 6 Dec 2024 03:37:51 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="Zq9Kc+UX"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id F08E4896BB; Fri, 6 Dec 2024 03:37:49 +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=-5.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-io1-xd2e.google.com (mail-io1-xd2e.google.com [IPv6:2607:f8b0:4864:20::d2e]) (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 BECBF8918C for ; Fri, 6 Dec 2024 03:37:47 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-io1-xd2e.google.com with SMTP id ca18e2360f4ac-841a7ae8d8aso107762239f.1 for ; Thu, 05 Dec 2024 18:37:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1733452665; x=1734057465; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=95iUHcKaIvde41hMaQPreEKC3EfpLOe5YPuaL6m3KN8=; b=Zq9Kc+UXpHTf051Ez69+E1av+9ACNbLhcFux6YLnVxYPIBe3aD/0QlHsFchqSJZeFY 45hXcB6+MaOI0XsHuLPGk92tByvyJfsOvys3FdXnC9iUR8WhhZmmKUeXQimvcUaIMg6D p6wa57+jPH/Kmn9ScJAgPDXJ3uUZmw5nxmquM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733452665; x=1734057465; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=95iUHcKaIvde41hMaQPreEKC3EfpLOe5YPuaL6m3KN8=; b=EDLWAsyZEyIq/BdhnHHDD04YSjcHHe/jnNJjapzJVd4d5wkQble6FR3CM+OqAvfj6O 7jk342vdNrYLk5g8AapJcFAwcUJgDPAjccIYwVoc6KL4COO1if8HiRkipQQkO3cYTlqx 9rDRtBY8rikb2rvHSBQzP39bdRrTqwj7wK/fW7yRLfmHi07rKtPGQYLOdZJ4Ogr9lpXP p5rB59OV/ewWTawav8Bw5midxGGDdTippIsic6pAAdGTnxXv9AfITc5+E/6rUzFRkSYh b1e96DHjOinc5AtdE/YIpiyZlCUu9vy/vCIjZN8CfbZJVufqeaagE3ESnxexalNO6g/1 JT0w== X-Gm-Message-State: AOJu0YzmUs/G8iD4aWQSKy6gEIYLRxnpk/BZ4rjkJVRXy3dHCy918d/a PsL5hIhtXtcO/WXnAm2eXOLdXPUDwQOnVIbTrwT+ynVJVZVSlWCv60Vj699Rf5hm6qbhn9gmA/c = X-Gm-Gg: ASbGncs6kZgPra137VKL0xCYdpWZe3dayjqRQVbLrMR6zdPTQxSk94bCu6ZVR9LXGAI A80LkDifU1YardHKwrN3cDKYntfqxu6zhITeld7ZiwtbjB3GbViuFeD1pMhcmwytlypG1AJ0mKC GevldNj45UOYQXtcAoO8ZT/t85eYFbn4PhXAp16+3NB55bmgyHgLpqd8UyFVEwYLIvHgbtNvGNS YEVv4g+jFrBwNT3KJldL8lNHhtiqq2GBf9eQQUWtGytJhqsRBN+rcHWVU2M7Xvaez8TDUIY0yVj 8JSzQEIcd3o= X-Google-Smtp-Source: AGHT+IG6MIXUGvnTPH3czKn+liJDNMEfNyGL7vMVl8Qr/nIDTEFK7akfnOsUzxZQ/ey9YGbw+QwOwg== X-Received: by 2002:a05:6602:1509:b0:843:e11e:e7e1 with SMTP id ca18e2360f4ac-8447e2c393amr269206539f.14.1733452665655; Thu, 05 Dec 2024 18:37:45 -0800 (PST) Received: from chromium.org (c-73-203-119-151.hsd1.co.comcast.net. [73.203.119.151]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4e2861f51bfsm575506173.112.2024.12.05.18.37.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Dec 2024 18:37:44 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Simon Glass , Ilias Apalodimas , Adriano Cordova , Jerome Forissier , Joe Hershberger , Marek Vasut Subject: [PATCH v3 28/46] net: Drop #ifdef in parse_args() Date: Thu, 5 Dec 2024 19:36:07 -0700 Message-Id: <20241206023626.2456858-29-sjg@chromium.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241206023626.2456858-1-sjg@chromium.org> References: <20241206023626.2456858-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.103.8 at phobos.denx.de X-Virus-Status: Clean Use IS_ENABLED() to avoid an extra build path. Signed-off-by: Simon Glass Acked-by: Ilias Apalodimas Signed-off-by: Simon Glass Acked-by: Ilias Apalodimas --- (no changes since v1) cmd/net.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/cmd/net.c b/cmd/net.c index f980448e0ef..6d1c6374f76 100644 --- a/cmd/net.c +++ b/cmd/net.c @@ -368,13 +368,13 @@ static int parse_args(enum proto_t proto, int argc, char *const argv[], } break; -#ifdef CONFIG_CMD_TFTPPUT case 4: - if (parse_addr_size(argv, addrp, sizep)) - return 1; - *fnamep = argv[3]; - break; -#endif + if (IS_ENABLED(CONFIG_CMD_TFTPPUT)) { + if (parse_addr_size(argv, addrp, sizep)) + return 1; + *fnamep = argv[3]; + break; + } default: return 1; } From patchwork Fri Dec 6 02:36:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2019058 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=JNwPd9VZ; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Y4Fqy3GBkz1yRK for ; Fri, 6 Dec 2024 13:41:02 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id B2BBA89629; Fri, 6 Dec 2024 03:37:53 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="JNwPd9VZ"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id F36D48918C; Fri, 6 Dec 2024 03:37:52 +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=-5.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-il1-x12c.google.com (mail-il1-x12c.google.com [IPv6:2607:f8b0:4864:20::12c]) (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 81E5A89639 for ; Fri, 6 Dec 2024 03:37:50 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-il1-x12c.google.com with SMTP id e9e14a558f8ab-3a814831760so320205ab.1 for ; Thu, 05 Dec 2024 18:37:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1733452669; x=1734057469; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=tTkBwhrC1LPXtT0zrlJsSb3uQn27kt+msnO3TO925OI=; b=JNwPd9VZJdJzd6gxg0J8Ikxk/SwGRzbuB4zHmRcbe1ctpoUhqXEvsQcPFz7iRrkBEl 5E7L6XRLpo7Nvs39068HYivsJZz3Tnin2Dhpg0MxPkTckF4N0Kfs797OZdLRks2jQf8G bcDcx7lr0aMvoYkZ/WCz8dBFnCf1A440dOMzk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733452669; x=1734057469; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=tTkBwhrC1LPXtT0zrlJsSb3uQn27kt+msnO3TO925OI=; b=jDamwHyl5VqNQ24DQVFa1INAkN2FgOAFAOxLWmpGlvEef3/U8C923j046sHl7n6J6i mzBMq9Fist9CQ4AItSXGunQ3plmQELgcDLf5cfSLFGP6mGC904t3IqhFHQajQn1kxJCW edwCyLJz94T8tHmA/CVF9Wmm8xbG7nGPN3xgtpjj6CMcytSW9tP34Amtb2DETDMqwN9V POSlr2/gEnzWUahS8HEztncO9qyiG2U9BhKhje0hStpIRT3GVGTty3OiL+k2mYa+DtJ9 K7MQV80usTqrDUREpHMPteJSKjJwEslPGdSQkDGs65VeKg9ysnAhA3hn4MdJslJMZifU wlXg== X-Gm-Message-State: AOJu0YwKgca8qRq3a5FG7alzQwcZ6IbWDgCXYwn7NxoujyyCpe6oFH18 t7fYDl424xdsvoLWSny8go3UUE688npNaz1p/zPjm0yiKu7nDVYBad2oSNFdUm0t8YXkb4QveeM = X-Gm-Gg: ASbGnctbZAqp27B2WWV6QTiWOGSoi4ZRV/KJy+NhX/4dYeIZrdhFW5X4uSWj0KD9aH0 T9vemcbFHAB4MetQI2f6KlzU/jB9wO9BVAKkaZHeDRfl8tkzlEJ+VT47Tag2aB87TcUx5/RJn4p u08lt7ZRMe54GUYCE4jGc0unL5a/0Y5A+HVxesW1Qhrkle6QGvS0aZ8pE293IR/aWh7drQkqQ7S kQYzd2dAmLSfRJ10jkrTWhGwkGy0lLmavg+It7kFpCFwWCe68oR6WMgZwKW8D9tIoexRjz0D9YP 1Qr/OFY+5+I= X-Google-Smtp-Source: AGHT+IG4y0KFLyRyLTdX0LTVmydyCRNnGsCQ8Le1KNjs0flBPf3F/JQ27CNnJXt7FJCZeGbblOcQJg== X-Received: by 2002:a05:6e02:1b0e:b0:3a7:e732:471f with SMTP id e9e14a558f8ab-3a811d7731bmr22385085ab.1.1733452668761; Thu, 05 Dec 2024 18:37:48 -0800 (PST) Received: from chromium.org (c-73-203-119-151.hsd1.co.comcast.net. [73.203.119.151]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4e2861f51bfsm575506173.112.2024.12.05.18.37.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Dec 2024 18:37:47 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Simon Glass , Adriano Cordova , Christian Marangi , Heinrich Schuchardt , Ilias Apalodimas , Jerome Forissier , Joe Hershberger , Marek Vasut , Ramon Fried Subject: [PATCH v3 29/46] net: Provide a function to run network operations Date: Thu, 5 Dec 2024 19:36:08 -0700 Message-Id: <20241206023626.2456858-30-sjg@chromium.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241206023626.2456858-1-sjg@chromium.org> References: <20241206023626.2456858-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.103.8 at phobos.denx.de X-Virus-Status: Clean Add a new netboot_run() function which can be used for simple network operations, such as loading a file. Put the implementation in an internal function, used by the existing code. Place this function into the net/ code, so that it does not need the command line to be available. Document which network operations are supported, i.e. a limited subset, for now. For the one board which uses lwip, it is not quite clear how to avoid using the cmdline interface. This will need some discussion. Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- (no changes since v1) cmd/net.c | 40 +--------------------------------------- include/net-common.h | 30 ++++++++++++++++++++++++++++++ net/net.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 75 insertions(+), 39 deletions(-) diff --git a/cmd/net.c b/cmd/net.c index 6d1c6374f76..8f33c9f55d5 100644 --- a/cmd/net.c +++ b/cmd/net.c @@ -382,44 +382,6 @@ static int parse_args(enum proto_t proto, int argc, char *const argv[], return 0; } -static int netboot_run_(enum proto_t proto, ulong addr, const char *fname, - ulong size, bool fname_explicit, bool ipv6) -{ - int ret; - - bootstage_mark(BOOTSTAGE_ID_NET_START); - - /* - * For now we use the global variables as that is the only way to - * control the network stack. At some point, perhaps, the state could be - * in a struct - */ - if (IS_ENABLED(CONFIG_CMD_TFTPPUT) && proto == TFTPPUT) - image_save_addr = addr; - else - image_load_addr = addr; - - net_boot_file_name_explicit = fname_explicit; - copy_filename(net_boot_file_name, fname, sizeof(net_boot_file_name)); - if (IS_ENABLED(CONFIG_IPV6)) - use_ip6 = ipv6; - if (IS_ENABLED(CONFIG_CMD_TFTPPUT) && proto == TFTPPUT) { - image_save_addr = addr; - image_save_size = size; - } else { - image_load_addr = addr; - } - - ret = net_loop(proto); - if (ret < 0) { - bootstage_error(BOOTSTAGE_ID_NET_NETLOOP_OK); - return ret; - } - bootstage_mark(BOOTSTAGE_ID_NET_NETLOOP_OK); - - return 0; -} - static int netboot_common(enum proto_t proto, struct cmd_tbl *cmdtp, int argc, char *const argv[]) { @@ -475,7 +437,7 @@ static int netboot_common(enum proto_t proto, struct cmd_tbl *cmdtp, int argc, } size = netboot_run_(proto, addr, fname, save_size, fname_explicit, - use_ip6); + IS_ENABLED(CONFIG_IPV6) && use_ip6); if (size < 0) return CMD_RET_FAILURE; diff --git a/include/net-common.h b/include/net-common.h index c5e314b360d..12c50e2a41e 100644 --- a/include/net-common.h +++ b/include/net-common.h @@ -474,6 +474,36 @@ int net_init(void); enum proto_t; int net_loop(enum proto_t protocol); +/* internal function: do not use! */ +int netboot_run_(enum proto_t proto, ulong addr, const char *fname, ulong size, + bool fname_explicit, bool ipv6); + +/** + * netboot_run() - Run a network operation + * + * The following proto values are NOT supported: + * PING, since net_ping_ip cannot be set + * NETCONS, since its parameters cannot bet set + * RS, since first_call cannot be set, along with perhaps other things + * UDP, since udp_ops cannot be set + * DNS, since net_dns_resolve and net_dns_env_var cannot be set + * WGET, since DNS must be done first and that is not supported + * DHCP6, since the required parameters cannot be passed in + * + * To support one of these, either add the required arguments or perhaps a + * separate function and a struct to hold the information. + * + * @proto: Operation to run: TFTPGET, FASTBOOT_UDP, FASTBOOT_TCP, BOOTP, + * TFTPPUT, RARP, NFS, DHCP + * @addr: Load/save address + * @fname: Filename + * @size: Save size (not used for TFTPGET) + * @ipv6: true to use IPv6, false to use IPv4 + * Return 0 on success, else -ve error code + */ +int netboot_run(enum proto_t proto, ulong addr, const char *fname, ulong size, + bool ipv6); + /** * dhcp_run() - Run DHCP on the current ethernet device * diff --git a/net/net.c b/net/net.c index 93154f05c44..556ab347cc9 100644 --- a/net/net.c +++ b/net/net.c @@ -737,6 +737,50 @@ done: return ret; } +int netboot_run_(enum proto_t proto, ulong addr, const char *fname, ulong size, + bool fname_explicit, bool ipv6) +{ + int ret; + + bootstage_mark(BOOTSTAGE_ID_NET_START); + + /* + * For now we use the global variables as that is the only way to + * control the network stack. At some point, perhaps, the state could be + * in a struct + */ + if (IS_ENABLED(CONFIG_CMD_TFTPPUT) && proto == TFTPPUT) + image_save_addr = addr; + else + image_load_addr = addr; + + net_boot_file_name_explicit = fname_explicit; + copy_filename(net_boot_file_name, fname, sizeof(net_boot_file_name)); + if (IS_ENABLED(CONFIG_IPV6)) + use_ip6 = ipv6; + if (IS_ENABLED(CONFIG_CMD_TFTPPUT) && proto == TFTPPUT) { + image_save_addr = addr; + image_save_size = size; + } else { + image_load_addr = addr; + } + + ret = net_loop(proto); + if (ret < 0) { + bootstage_error(BOOTSTAGE_ID_NET_NETLOOP_OK); + return ret; + } + bootstage_mark(BOOTSTAGE_ID_NET_NETLOOP_OK); + + return 0; +} + +int netboot_run(enum proto_t proto, ulong addr, const char *fname, ulong size, + bool ipv6) +{ + return netboot_run_(proto, addr, fname, size, true, ipv6); +} + /**********************************************************************/ static void start_again_timeout_handler(void) From patchwork Fri Dec 6 02:36:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2019059 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=QnNMgtQM; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Y4Fr83Ht4z1yRK for ; Fri, 6 Dec 2024 13:41:12 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 199FF8975C; Fri, 6 Dec 2024 03:37:57 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="QnNMgtQM"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 0517F8918C; Fri, 6 Dec 2024 03:37:56 +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=-5.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-io1-xd2c.google.com (mail-io1-xd2c.google.com [IPv6:2607:f8b0:4864:20::d2c]) (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 C236E896BB for ; Fri, 6 Dec 2024 03:37:53 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-io1-xd2c.google.com with SMTP id ca18e2360f4ac-84183532291so108514239f.2 for ; Thu, 05 Dec 2024 18:37:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1733452671; x=1734057471; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=j3zXsbXJlPwih/+3PGs3kgtViG62jYklfxxJ4FA0jmQ=; b=QnNMgtQMUoQOtMCvDaUiZQTsz+TM61Yc7wfA2BM3Fsb+5ZroxBEqgtg1aGcE5WDGdP 0b3xKMsuHdbFCJx8nVrI/Zm/FCDoUAUW7fO5mG89vZoxGAh+D2YoCgtICafkmlyrkea8 sBz9wcBlFpxolNWjAmQsz+dDeXg/qH2jcyZsU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733452671; x=1734057471; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=j3zXsbXJlPwih/+3PGs3kgtViG62jYklfxxJ4FA0jmQ=; b=Yr3cf6P2cEUIa6Ll0iNAw+8XE8SbPtHQJKJh0GplK3D8T/b3QuaywyAQICtlDdJFQg x6uULToNT1HL47YRhvVBX5mjm1l8DleAJN0TR2QQwVW7xSeyR/UHlMCtpMGnDWKOIUpg uNa8uwGYHQGk4h/R5Gl0gfqXr4YccfSR2nyCiHWY0YuphTcVg7RMxB4PLQCTZ+WqJALj Mklif6wMRZtilVNZbNeJ4ouuDd+sCc9hF9NGOepWuQNHADfF73a3WjQAKY1XqO+HMEcO nlJaiF8dxImKX1+hQvsZPX572o30H/tAANntJxgccutWFqI1EtT1m5bC4qeIk1w8gpma rlwA== X-Gm-Message-State: AOJu0YwVOv/63Ivy1p3QXmXHjGHP+rzQ/AiA+qZpljAqfOXtN6yp3Ata pS80mW58qGqlf2oWdBNPSg4pvqktaVqnoe0To11r+zaf3RAC3hbvyAsK36rkm0JuXITgWD8OWHY = X-Gm-Gg: ASbGncsDteOI9tJLK/QC0El3j2zU4v59mecsZwZrFcJW61XiK1RwJ1z1IEj8SGoU+7F vNSmZPr+4j4MyBKn34ow9GfwG/pHjzkQoaV6NdSWX6Q91vFdrqbRTWGHNiKKj/sSJSDu764TBTM eqNETKyfmTMHZC9GK0MBSzWussoFb8V65XCfvgaNM7z9stXujsTF0IYDC+ZFUKux/rmVgCJjNsJ vLYjLwcLAhpGE6qEW9o0i0pi6alIg81i4XyJ/Yq6AVbRTR8UuEi/Ds7McjNNxT9ssFm8dPcg39x j6wgTro3s1w= X-Google-Smtp-Source: AGHT+IHdkZDa/f5Ds4R3YjhW1mCFBY3MlH4zyK9YzcZ0oM/yHyO3QVh4Hj31WykQ549EBoKTk3jMaQ== X-Received: by 2002:a05:6602:6011:b0:842:ff2d:c3d9 with SMTP id ca18e2360f4ac-8447e204c01mr214782639f.4.1733452671649; Thu, 05 Dec 2024 18:37:51 -0800 (PST) Received: from chromium.org (c-73-203-119-151.hsd1.co.comcast.net. [73.203.119.151]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4e2861f51bfsm575506173.112.2024.12.05.18.37.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Dec 2024 18:37:50 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Simon Glass , Heinrich Schuchardt , Ilias Apalodimas , Martyn Welch , Mattijs Korpershoek Subject: [PATCH v3 30/46] boot: Avoid using the cmdline in bootmeth_pxe and pxe cmd Date: Thu, 5 Dec 2024 19:36:09 -0700 Message-Id: <20241206023626.2456858-31-sjg@chromium.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241206023626.2456858-1-sjg@chromium.org> References: <20241206023626.2456858-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.103.8 at phobos.denx.de X-Virus-Status: Clean Use the new netboot_run() function to avoid building a command line, when running these network operations. For the one board which uses lwip, it is not quite clear how to avoid using the cmdline interface, so produce an error, for now. This can be figured out later. Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- (no changes since v1) boot/bootmeth_pxe.c | 16 ++++++---------- cmd/pxe.c | 21 +++++++-------------- 2 files changed, 13 insertions(+), 24 deletions(-) diff --git a/boot/bootmeth_pxe.c b/boot/bootmeth_pxe.c index b91e61bcbc4..c6a132b8de2 100644 --- a/boot/bootmeth_pxe.c +++ b/boot/bootmeth_pxe.c @@ -116,21 +116,17 @@ static int extlinux_pxe_read_file(struct udevice *dev, struct bootflow *bflow, const char *file_path, ulong addr, enum bootflow_img_t type, ulong *sizep) { - char *tftp_argv[] = {"tftp", NULL, NULL, NULL}; - struct pxe_context *ctx = dev_get_priv(dev); - char file_addr[17]; ulong size; int ret; - sprintf(file_addr, "%lx", addr); - tftp_argv[1] = file_addr; - tftp_argv[2] = (void *)file_path; - - if (do_tftpb(ctx->cmdtp, 0, 3, tftp_argv)) - return -ENOENT; - ret = pxe_get_file_size(&size); + if (IS_ENABLED(CONFIG_NET_LWIP)) + return -ENOTSUPP; + ret = netboot_run(TFTPGET, addr, file_path, 0, false); if (ret) return log_msg_ret("tftp", ret); + ret = pxe_get_file_size(&size); + if (ret) + return log_msg_ret("tft2", ret); if (size > *sizep) return log_msg_ret("spc", -ENOSPC); *sizep = size; diff --git a/cmd/pxe.c b/cmd/pxe.c index 37b8dea6ad6..c69b8130423 100644 --- a/cmd/pxe.c +++ b/cmd/pxe.c @@ -29,25 +29,18 @@ const char *pxe_default_paths[] = { static int do_get_tftp(struct pxe_context *ctx, const char *file_path, char *file_addr, enum bootflow_img_t type, ulong *sizep) { - char *tftp_argv[] = {"tftp", NULL, NULL, NULL}; int ret; - int num_args; - tftp_argv[1] = file_addr; - tftp_argv[2] = (void *)file_path; - if (ctx->use_ipv6) { - tftp_argv[3] = USE_IP6_CMD_PARAM; - num_args = 4; - } else { - num_args = 3; - } - - if (do_tftpb(ctx->cmdtp, 0, num_args, tftp_argv)) - return -ENOENT; + if (IS_ENABLED(CONFIG_NET_LWIP)) + return -ENOTSUPP; + ret = netboot_run(TFTPGET, hextoul(file_addr, NULL), file_path, 0, + ctx->use_ipv6); + if (ret) + return log_msg_ret("tfp", ret); ret = pxe_get_file_size(sizep); if (ret) - return log_msg_ret("tftp", ret); + return log_msg_ret("tf2", ret); ctx->pxe_file_size = *sizep; return 1; From patchwork Fri Dec 6 02:36:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2019060 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=YHsh5ucF; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Y4FrJ4MQ9z1yRK for ; Fri, 6 Dec 2024 13:41:20 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 7876F89771; Fri, 6 Dec 2024 03:37:59 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="YHsh5ucF"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 35EBC89639; Fri, 6 Dec 2024 03:37:58 +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=-5.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-io1-xd36.google.com (mail-io1-xd36.google.com [IPv6:2607:f8b0:4864:20::d36]) (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 D68AB89756 for ; Fri, 6 Dec 2024 03:37:55 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-io1-xd36.google.com with SMTP id ca18e2360f4ac-84198253281so100260239f.0 for ; Thu, 05 Dec 2024 18:37:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1733452673; x=1734057473; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=4QbQTnlorlo8HeLSxopeHPSZBzVoPlqaLk5bDAWwbqc=; b=YHsh5ucFG0KN+sLx7xACK5DgltLYPOW9caCYnfJgmz8pE6atQ1iY/xeHg9lkQlojR6 U8XJ/YAhHfKBNp9G6kDoaXeaxh62Gaf+W0NQhsugMRu1k1AipdpVvWRL6zHK54wfH/YT Rrp+VUTHgO+6mtXSwdevNz4FLhFWp3ZXtkM30= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733452673; x=1734057473; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=4QbQTnlorlo8HeLSxopeHPSZBzVoPlqaLk5bDAWwbqc=; b=j8tQHGGfjs86BnQ7E1qj+mysh87ae0aIG06Fw9W0i1bmPtcPu/FdXevmHMCzO2FXcL AVzpF8p+E1Y6Pastn6yw6NLOm9wPLcXZE0i4Kn6kl6BfcjbZffPtH1Pnx6ovILxn13l0 VQioMG2aPyQQugu281TqPQ/Ip4+9l0NAqmIuTqI7B4e8NiSlvvEwyEWaBCG1UotEiquS 3VNDuTqVpDcnekQMFe/CtS7O9wjOigbSJZJV3bljIuxdmmSP2T38ufoea1WqgRo1rr49 HYHWxvBSOwA8PAKqRlKonE6jksy6++ltyMyysLOyGDSpHNHurFETAua807vQ4/6NqkTP v3XQ== X-Gm-Message-State: AOJu0Yz2IWKzeEnZx9jvXEZuIfImRzz4rZF7DgMDGLQvy247/OBMGKKC 3cukeXVW2Icc6V9YClgNDYsI3dIUbplkSlEmC1RX+0bLW6ty1VknirYIvEv/Hnq3xKaNT71tMJQ = X-Gm-Gg: ASbGnct9icQXj+nv9VntMtl9eg4wCZguYm1fbCaqby3zRljVRCM8mn12aEafR+URyek 5u3kca/ukgL93vWORx9BYl5tG6IoFZTEFH+DtgRCFWC54FLqAZyjsUGDNE3jnRm1vc4AFZZleXO kmktkWamXG7B3yM0m8zDO1xz9SzATs4nlkkJzeO94nHU/8f8EKYP0mUgmPkPYWRglFr9KGbm19F ZXSlhUX4vPdbUkKoN/RSsGRpsAByhgkTWUAOdk0TgyUk6bXknAo+f73xzYyE9UJRbmXbOmmgbVn b9JIPAEycV4= X-Google-Smtp-Source: AGHT+IHoZkOS0gnDni07tJa9ec7SrFDGxcpxgJfKWrf7gmntnACC4PmdwPsnpyHZfqvH1UF7vN/ijg== X-Received: by 2002:a05:6602:15ca:b0:843:e9a6:fd1 with SMTP id ca18e2360f4ac-8447e1f99ffmr191865439f.1.1733452673443; Thu, 05 Dec 2024 18:37:53 -0800 (PST) Received: from chromium.org (c-73-203-119-151.hsd1.co.comcast.net. [73.203.119.151]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4e2861f51bfsm575506173.112.2024.12.05.18.37.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Dec 2024 18:37:52 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Simon Glass , Caleb Connolly , Heinrich Schuchardt , Ilias Apalodimas , Ion Agorria , Marek Vasut , Martyn Welch , Mattijs Korpershoek , Michael Trimarchi , Nam Cao , Quentin Schulz Subject: [PATCH v3 31/46] pxe: Drop the cmdline parameter Date: Thu, 5 Dec 2024 19:36:10 -0700 Message-Id: <20241206023626.2456858-32-sjg@chromium.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241206023626.2456858-1-sjg@chromium.org> References: <20241206023626.2456858-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.103.8 at phobos.denx.de X-Virus-Status: Clean Now that PXE can operate without the command line, drop the parameter throughout the code. Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- (no changes since v1) boot/bootmeth_extlinux.c | 5 ++--- boot/bootmeth_pxe.c | 4 +--- boot/pxe_utils.c | 8 +++----- cmd/pxe.c | 9 ++++----- cmd/sysboot.c | 4 ++-- include/extlinux.h | 1 - include/pxe_utils.h | 10 +++------- 7 files changed, 15 insertions(+), 26 deletions(-) diff --git a/boot/bootmeth_extlinux.c b/boot/bootmeth_extlinux.c index 17c6cebd2f4..4adcaf5654a 100644 --- a/boot/bootmeth_extlinux.c +++ b/boot/bootmeth_extlinux.c @@ -175,7 +175,6 @@ static int extlinux_read_bootflow(struct udevice *dev, struct bootflow *bflow) static int extlinux_boot(struct udevice *dev, struct bootflow *bflow) { - struct cmd_tbl cmdtp = {}; /* dummy */ struct pxe_context ctx; struct extlinux_info info; struct extlinux_plat *plat; @@ -188,8 +187,8 @@ static int extlinux_boot(struct udevice *dev, struct bootflow *bflow) plat = dev_get_plat(dev); - ret = pxe_setup_ctx(&ctx, &cmdtp, extlinux_getfile, &info, true, - bflow->fname, false, plat->use_fallback); + ret = pxe_setup_ctx(&ctx, extlinux_getfile, &info, true, bflow->fname, + false, plat->use_fallback); if (ret) return log_msg_ret("ctx", -EINVAL); diff --git a/boot/bootmeth_pxe.c b/boot/bootmeth_pxe.c index c6a132b8de2..59ebf1be83a 100644 --- a/boot/bootmeth_pxe.c +++ b/boot/bootmeth_pxe.c @@ -140,7 +140,6 @@ static int extlinux_pxe_read_file(struct udevice *dev, struct bootflow *bflow, static int extlinux_pxe_boot(struct udevice *dev, struct bootflow *bflow) { struct pxe_context *ctx = dev_get_priv(dev); - struct cmd_tbl cmdtp = {}; /* dummy */ struct extlinux_info info; ulong addr; int ret; @@ -148,8 +147,7 @@ static int extlinux_pxe_boot(struct udevice *dev, struct bootflow *bflow) addr = map_to_sysmem(bflow->buf); info.dev = dev; info.bflow = bflow; - info.cmdtp = &cmdtp; - ret = pxe_setup_ctx(ctx, &cmdtp, extlinux_pxe_getfile, &info, false, + ret = pxe_setup_ctx(ctx, extlinux_pxe_getfile, &info, false, bflow->subdir, false, false); if (ret) return log_msg_ret("ctx", -EINVAL); diff --git a/boot/pxe_utils.c b/boot/pxe_utils.c index a91372407eb..b4aa284b1ee 100644 --- a/boot/pxe_utils.c +++ b/boot/pxe_utils.c @@ -1630,16 +1630,14 @@ void handle_pxe_menu(struct pxe_context *ctx, struct pxe_menu *cfg) boot_unattempted_labels(ctx, cfg); } -int pxe_setup_ctx(struct pxe_context *ctx, struct cmd_tbl *cmdtp, - pxe_getfile_func getfile, void *userdata, - bool allow_abs_path, const char *bootfile, bool use_ipv6, - bool use_fallback) +int pxe_setup_ctx(struct pxe_context *ctx, pxe_getfile_func getfile, + void *userdata, bool allow_abs_path, const char *bootfile, + bool use_ipv6, bool use_fallback) { const char *last_slash; size_t path_len = 0; memset(ctx, '\0', sizeof(*ctx)); - ctx->cmdtp = cmdtp; ctx->getfile = getfile; ctx->userdata = userdata; ctx->allow_abs_path = allow_abs_path; diff --git a/cmd/pxe.c b/cmd/pxe.c index c69b8130423..530d5d9c35b 100644 --- a/cmd/pxe.c +++ b/cmd/pxe.c @@ -126,12 +126,11 @@ static int pxe_ipaddr_paths(struct pxe_context *ctx, unsigned long pxefile_addr_ int pxe_get(ulong pxefile_addr_r, char **bootdirp, ulong *sizep, bool use_ipv6) { - struct cmd_tbl cmdtp[] = {}; /* dummy */ struct pxe_context ctx; int i; - if (pxe_setup_ctx(&ctx, cmdtp, do_get_tftp, NULL, false, - env_get("bootfile"), use_ipv6, false)) + if (pxe_setup_ctx(&ctx, do_get_tftp, NULL, false, env_get("bootfile"), + use_ipv6, false)) return -ENOMEM; if (IS_ENABLED(CONFIG_BOOTP_PXE_DHCP_OPTION) && @@ -280,8 +279,8 @@ do_pxe_boot(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) return 1; } - if (pxe_setup_ctx(&ctx, cmdtp, do_get_tftp, NULL, false, - env_get("bootfile"), use_ipv6, false)) { + if (pxe_setup_ctx(&ctx, do_get_tftp, NULL, false, env_get("bootfile"), + use_ipv6, false)) { printf("Out of memory\n"); return CMD_RET_FAILURE; } diff --git a/cmd/sysboot.c b/cmd/sysboot.c index 93d4a400830..6e899f381ec 100644 --- a/cmd/sysboot.c +++ b/cmd/sysboot.c @@ -105,8 +105,8 @@ static int do_sysboot(struct cmd_tbl *cmdtp, int flag, int argc, return 1; } - if (pxe_setup_ctx(&ctx, cmdtp, sysboot_read_file, &info, true, - filename, false, false)) { + if (pxe_setup_ctx(&ctx, sysboot_read_file, &info, true, filename, false, + false)) { printf("Out of memory\n"); return CMD_RET_FAILURE; } diff --git a/include/extlinux.h b/include/extlinux.h index 721ba46371c..6747fe01dda 100644 --- a/include/extlinux.h +++ b/include/extlinux.h @@ -18,7 +18,6 @@ struct extlinux_info { struct udevice *dev; struct bootflow *bflow; - struct cmd_tbl *cmdtp; }; #endif diff --git a/include/pxe_utils.h b/include/pxe_utils.h index 0378f2889f7..fb057442d5d 100644 --- a/include/pxe_utils.h +++ b/include/pxe_utils.h @@ -100,7 +100,6 @@ typedef int (*pxe_getfile_func)(struct pxe_context *ctx, const char *file_path, /** * struct pxe_context - context information for PXE parsing * - * @cmdtp: Pointer to command table to use when calling other commands * @getfile: Function called by PXE to read a file * @userdata: Data the caller requires for @getfile * @allow_abs_path: true to allow absolute paths @@ -112,7 +111,6 @@ typedef int (*pxe_getfile_func)(struct pxe_context *ctx, const char *file_path, * "default" option as default */ struct pxe_context { - struct cmd_tbl *cmdtp; /** * getfile() - read a file * @@ -222,7 +220,6 @@ int format_mac_pxe(char *outbuf, size_t outbuf_len); * pxe_setup_ctx() - Setup a new PXE context * * @ctx: Context to set up - * @cmdtp: Command table entry which started this action * @getfile: Function to call to read a file * @userdata: Data the caller requires for @getfile - stored in ctx->userdata * @allow_abs_path: true to allow absolute paths @@ -237,10 +234,9 @@ int format_mac_pxe(char *outbuf, size_t outbuf_len); * Return: 0 if OK, -ENOMEM if out of memory, -E2BIG if bootfile is larger than * MAX_TFTP_PATH_LEN bytes */ -int pxe_setup_ctx(struct pxe_context *ctx, struct cmd_tbl *cmdtp, - pxe_getfile_func getfile, void *userdata, - bool allow_abs_path, const char *bootfile, bool use_ipv6, - bool use_fallback); +int pxe_setup_ctx(struct pxe_context *ctx, pxe_getfile_func getfile, + void *userdata, bool allow_abs_path, const char *bootfile, + bool use_ipv6, bool use_fallback); /** * pxe_destroy_ctx() - Destroy a PXE context From patchwork Fri Dec 6 02:36:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2019061 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=IKUZeAa6; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Y4FrT33wHz1yRK for ; Fri, 6 Dec 2024 13:41:29 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id CC0CB896C7; Fri, 6 Dec 2024 03:38:04 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="IKUZeAa6"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C3E7389772; Fri, 6 Dec 2024 03:38:03 +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=-5.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-io1-xd34.google.com (mail-io1-xd34.google.com [IPv6:2607:f8b0:4864:20::d34]) (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 3819A89753 for ; Fri, 6 Dec 2024 03:37:58 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-io1-xd34.google.com with SMTP id ca18e2360f4ac-843e9db3e65so61427139f.1 for ; Thu, 05 Dec 2024 18:37:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1733452676; x=1734057476; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=5t7xGm9UIfOBvXsTAl+woWHVdKLR0fJi5PGeinfYoeo=; b=IKUZeAa6Bkp30V4/5JkOuoWE8uMNeoVKJ7pP1Eiy7nmAy1g8UQ2xX3/5DoVo9kckrF /4mNe9AWJ7J7EVb/LJf4RQg5B2MYGegd2uGDZ35CoUVrMLQkI4yvtwAPLnM9LumRSTGj o36MLEnJaXtB0NDzAyasnVaRsXffc+uvcPetU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733452676; x=1734057476; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=5t7xGm9UIfOBvXsTAl+woWHVdKLR0fJi5PGeinfYoeo=; b=qHeJySz7JrJVI+aZdelE3RxMtvXk4lds2ZXZ7X4G+oianw1YxH/rmPoAmWOj2cG13x 1kPNzZn/gc335dur8GKd0mYwO1ETWgzR7H0D03rAOYhjKWyG9CXoZwo2R6LrpguHoj6c JWswGPSpcF6j41EsM7LKlAQcPGDmd8LAmwEHQYWMwjkt/eilkw2qpeXT/At/lvktjMVo GoWgTL3Fb2khd3Q2ADTj7UUZwLWaLGBSoheaofWy7qIDMSbznrICzcsy9T8qi7S8hQz9 /kuXGz1In6w8lQXQyRsebGNycT0UJTJem+zeA0NM8sYQeiOTlu7K3ABNJk+57bXpY9ZS THpg== X-Gm-Message-State: AOJu0YyZQA8jMmthhH7VvFPKws/rH0prCxN8PuKPw73Dzy3NbP8timab vng3m3eyLvz5xJpjr5yTQqK7afkC/y6PQ/GtIDnpTm4nbOOsPK/g13qZXBYqRIDNFbpH3TW3kfA = X-Gm-Gg: ASbGnct0Jh/LhWUNf89k2I32xd97mpGYWM060jCrgHnsxoiLoof/RBzGxy8094dHK02 UusSF6dacF2TaT2+7usa5dob/R0wW3H3isCVW3QxSZaVPOL8Ys4UxcEn0UlPuwElA9Z1ARs+rlc 4ji07g9O8zM7KUuArlNOZrv8mFipWgO3N4KbzmojG3tvcqmmd8uerRxrSgfLWAI3vyHroXiNF3i 6Pe6s/44dJUtUrGPpgw7+dUT3ExptoMzfQHAoKH2gORA9vklgqpNKNipxv841+DVmdtED0Agiip hrzeHXxy5m4= X-Google-Smtp-Source: AGHT+IEwguCQ5mmqxKh9KYqML6VaTpKl+6VPWvp6T7XoIojxt29os0VI7L+/3Or4dAbHEiwp/v6XXQ== X-Received: by 2002:a6b:6210:0:b0:844:2ef3:a95a with SMTP id ca18e2360f4ac-84471100818mr569269539f.7.1733452676433; Thu, 05 Dec 2024 18:37:56 -0800 (PST) Received: from chromium.org (c-73-203-119-151.hsd1.co.comcast.net. [73.203.119.151]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4e2861f51bfsm575506173.112.2024.12.05.18.37.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Dec 2024 18:37:55 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Simon Glass , Caleb Connolly , Heinrich Schuchardt , Ilias Apalodimas , Ion Agorria , Marek Vasut , Martyn Welch , Mattijs Korpershoek , Michael Trimarchi , Nam Cao , Quentin Schulz Subject: [PATCH v3 32/46] pxe: Record the bootflow in the PXE context Date: Thu, 5 Dec 2024 19:36:11 -0700 Message-Id: <20241206023626.2456858-33-sjg@chromium.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241206023626.2456858-1-sjg@chromium.org> References: <20241206023626.2456858-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.103.8 at phobos.denx.de X-Virus-Status: Clean At present the only option with PXE is to boot it and see what happens. Provide a bootflow, when available, so that PXE will eventually be able to add some useful information to it. Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- (no changes since v1) boot/bootmeth_extlinux.c | 2 +- boot/bootmeth_pxe.c | 2 +- boot/pxe_utils.c | 3 ++- cmd/pxe.c | 4 ++-- cmd/sysboot.c | 2 +- include/pxe_utils.h | 5 ++++- 6 files changed, 11 insertions(+), 7 deletions(-) diff --git a/boot/bootmeth_extlinux.c b/boot/bootmeth_extlinux.c index 4adcaf5654a..569f9d760bf 100644 --- a/boot/bootmeth_extlinux.c +++ b/boot/bootmeth_extlinux.c @@ -188,7 +188,7 @@ static int extlinux_boot(struct udevice *dev, struct bootflow *bflow) plat = dev_get_plat(dev); ret = pxe_setup_ctx(&ctx, extlinux_getfile, &info, true, bflow->fname, - false, plat->use_fallback); + false, plat->use_fallback, bflow); if (ret) return log_msg_ret("ctx", -EINVAL); diff --git a/boot/bootmeth_pxe.c b/boot/bootmeth_pxe.c index 59ebf1be83a..f2b9ffaae89 100644 --- a/boot/bootmeth_pxe.c +++ b/boot/bootmeth_pxe.c @@ -148,7 +148,7 @@ static int extlinux_pxe_boot(struct udevice *dev, struct bootflow *bflow) info.dev = dev; info.bflow = bflow; ret = pxe_setup_ctx(ctx, extlinux_pxe_getfile, &info, false, - bflow->subdir, false, false); + bflow->subdir, false, false, bflow); if (ret) return log_msg_ret("ctx", -EINVAL); diff --git a/boot/pxe_utils.c b/boot/pxe_utils.c index b4aa284b1ee..f7bbc1527af 100644 --- a/boot/pxe_utils.c +++ b/boot/pxe_utils.c @@ -1632,7 +1632,7 @@ void handle_pxe_menu(struct pxe_context *ctx, struct pxe_menu *cfg) int pxe_setup_ctx(struct pxe_context *ctx, pxe_getfile_func getfile, void *userdata, bool allow_abs_path, const char *bootfile, - bool use_ipv6, bool use_fallback) + bool use_ipv6, bool use_fallback, struct bootflow *bflow) { const char *last_slash; size_t path_len = 0; @@ -1643,6 +1643,7 @@ int pxe_setup_ctx(struct pxe_context *ctx, pxe_getfile_func getfile, ctx->allow_abs_path = allow_abs_path; ctx->use_ipv6 = use_ipv6; ctx->use_fallback = use_fallback; + ctx->bflow = bflow; /* figure out the boot directory, if there is one */ if (bootfile && strlen(bootfile) >= MAX_TFTP_PATH_LEN) diff --git a/cmd/pxe.c b/cmd/pxe.c index 530d5d9c35b..7728949d14b 100644 --- a/cmd/pxe.c +++ b/cmd/pxe.c @@ -130,7 +130,7 @@ int pxe_get(ulong pxefile_addr_r, char **bootdirp, ulong *sizep, bool use_ipv6) int i; if (pxe_setup_ctx(&ctx, do_get_tftp, NULL, false, env_get("bootfile"), - use_ipv6, false)) + use_ipv6, false, NULL)) return -ENOMEM; if (IS_ENABLED(CONFIG_BOOTP_PXE_DHCP_OPTION) && @@ -280,7 +280,7 @@ do_pxe_boot(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) } if (pxe_setup_ctx(&ctx, do_get_tftp, NULL, false, env_get("bootfile"), - use_ipv6, false)) { + use_ipv6, false, NULL)) { printf("Out of memory\n"); return CMD_RET_FAILURE; } diff --git a/cmd/sysboot.c b/cmd/sysboot.c index 6e899f381ec..384d5e15e3d 100644 --- a/cmd/sysboot.c +++ b/cmd/sysboot.c @@ -106,7 +106,7 @@ static int do_sysboot(struct cmd_tbl *cmdtp, int flag, int argc, } if (pxe_setup_ctx(&ctx, sysboot_read_file, &info, true, filename, false, - false)) { + false, NULL)) { printf("Out of memory\n"); return CMD_RET_FAILURE; } diff --git a/include/pxe_utils.h b/include/pxe_utils.h index fb057442d5d..e8e03430a81 100644 --- a/include/pxe_utils.h +++ b/include/pxe_utils.h @@ -109,6 +109,7 @@ typedef int (*pxe_getfile_func)(struct pxe_context *ctx, const char *file_path, * @use_ipv6: TRUE : use IPv6 addressing, FALSE : use IPv4 addressing * @use_fallback: TRUE : use "fallback" option as default, FALSE : use * "default" option as default + * @bflow: Bootflow being booted, or NULL if none */ struct pxe_context { /** @@ -129,6 +130,7 @@ struct pxe_context { ulong pxe_file_size; bool use_ipv6; bool use_fallback; + struct bootflow *bflow; }; /** @@ -231,12 +233,13 @@ int format_mac_pxe(char *outbuf, size_t outbuf_len); * other choice be selected * FALSE : Use "default" option should no other choice be * selected + * @bflow: Bootflow to update, NULL if none * Return: 0 if OK, -ENOMEM if out of memory, -E2BIG if bootfile is larger than * MAX_TFTP_PATH_LEN bytes */ int pxe_setup_ctx(struct pxe_context *ctx, pxe_getfile_func getfile, void *userdata, bool allow_abs_path, const char *bootfile, - bool use_ipv6, bool use_fallback); + bool use_ipv6, bool use_fallback, struct bootflow *bflow); /** * pxe_destroy_ctx() - Destroy a PXE context From patchwork Fri Dec 6 02:36:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2019062 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=lK6/r7ne; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Y4Frf0t34z1yRK for ; Fri, 6 Dec 2024 13:41:38 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 3398B89774; Fri, 6 Dec 2024 03:38:08 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="lK6/r7ne"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 225DD8975E; Fri, 6 Dec 2024 03:38:07 +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=-5.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-io1-xd2a.google.com (mail-io1-xd2a.google.com [IPv6:2607:f8b0:4864:20::d2a]) (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 0DBBE8975F for ; Fri, 6 Dec 2024 03:38:01 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-io1-xd2a.google.com with SMTP id ca18e2360f4ac-8418f849466so55617039f.1 for ; Thu, 05 Dec 2024 18:38:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1733452679; x=1734057479; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ZqrsMmPwPo46XJn92V2eHwp/JJbrP7PGh6pnbvICI1A=; b=lK6/r7neCATuwWtmzNRZdlEIMsSRDN5LAp/rOC+n40bGrn/YK9qAiR8xeU3h24ekB/ a/80h5Yh8Yz4OnAcALa3BVJ1yCPXDwyGZT1v32fa9x//JnVqb37D6k7glPkFcSC4stcq 8ThHH95ohiAAmw9ohQIjUQLkyRtPwKi3NqXcQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733452679; x=1734057479; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ZqrsMmPwPo46XJn92V2eHwp/JJbrP7PGh6pnbvICI1A=; b=u4I4ltGjhsNcyB7MudjqoYgfQkh5P7vmOXP+IqcW3Rf7vr29MPRxV+X4Yvkmn873lO Alu1ThhYECg1MzvLRSsGPRmRFRUxIeAcEJbB72PrtBuF4EBX9acUs+6+ZFn7dKO3cz3Y bsunI4fwT/BQA2cVdghTFTcWSH/ZpafkVT95USe7YrenbcQK1uDKppJR4RTeDxHz1mTn 0VccSi9X6ultvMXV7qqV0xhnFMjhxMYXH2N81ZD1oPMnDhD/+FdqK4tkP3Hoq2YTv8Hz NYwQQBFzi1KXZg5lJoqvZwVL/JRjVDvXLqOPaSYfs0jsF8cUtXPElz3Gjpi5SN8Vc74n bCaw== X-Gm-Message-State: AOJu0YwIgEM+bd7cBZz6dTj1GhpERc5/+heao5fpzPbkQsFqevdi4vr4 vWhlUT+oTDXoRw032vbtCrJ1y0bMQL5RGQcjva3jfcEZ84/pD0JwuRrme7OF2iBb85VvxTmkKEM = X-Gm-Gg: ASbGnct17qKCtRdqNAGGLlLtXIO6Wp/P2MV0CbbQBaqQ9b42M1VCPeQrI1NFBa4p6zM /zYs+9qyhtO/HAjPlNPQhfTDM7lYIdgSAOhhrMIZNDCD7d19IQF7WDbcbuzq24qgRDuHc7vNfcZ U+TNvDaoERwGpwgmxIiFsypwlIQP53Ol1JB/WvajYQ6qgN1+cb81GVo8X+e+hVuQC84dorUnd9F czcelbUZxGYi+4YsGipt5HBhBgdffINTs/Vxw8xUpLhA8EXSIQrQadR318wpMppbmoZHxT/chCK C2YyqkO4oIo= X-Google-Smtp-Source: AGHT+IGMiae/08z5le6251noICsxR9tvxmzrFoKPLN7iwzDO+PFvWT9xXvRq0IdM50ZnLCzl2T6v9A== X-Received: by 2002:a05:6602:2b09:b0:841:a9d3:3b30 with SMTP id ca18e2360f4ac-8447e200cdfmr220917439f.1.1733452679302; Thu, 05 Dec 2024 18:37:59 -0800 (PST) Received: from chromium.org (c-73-203-119-151.hsd1.co.comcast.net. [73.203.119.151]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4e2861f51bfsm575506173.112.2024.12.05.18.37.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Dec 2024 18:37:57 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Simon Glass , Marek Vasut , Martyn Welch , Michael Trimarchi , Quentin Schulz Subject: [PATCH v3 33/46] pxe: Allow skipping the boot Date: Thu, 5 Dec 2024 19:36:12 -0700 Message-Id: <20241206023626.2456858-34-sjg@chromium.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241206023626.2456858-1-sjg@chromium.org> References: <20241206023626.2456858-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.103.8 at phobos.denx.de X-Virus-Status: Clean Provide a way to skip booting the OS and just return. This will allow bootstd to read out useful information. Add debugging to help figure out the flow. Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- (no changes since v1) boot/pxe_utils.c | 12 ++++++++++-- include/pxe_utils.h | 4 +++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/boot/pxe_utils.c b/boot/pxe_utils.c index f7bbc1527af..3531ab1c71a 100644 --- a/boot/pxe_utils.c +++ b/boot/pxe_utils.c @@ -782,6 +782,9 @@ static int label_boot(struct pxe_context *ctx, struct pxe_label *label) printf("append: %s\n", finalbootargs); } + if (ctx->no_boot) + return 0; + label_run_boot(ctx, label, kernel_addr, initrd_addr_str, initrd_filesize, initrd_str); /* ignore the error value since we are going to fail anyway */ @@ -1566,11 +1569,15 @@ static void boot_unattempted_labels(struct pxe_context *ctx, struct list_head *pos; struct pxe_label *label; + log_debug("Booting unattempted labels\n"); list_for_each(pos, &cfg->labels) { label = list_entry(pos, struct pxe_label, list); - if (!label->attempted) - label_boot(ctx, label); + if (!label->attempted) { + log_debug("attempt: %s\n", label->name); + if (!label_boot(ctx, label)) + return; + } } } @@ -1621,6 +1628,7 @@ void handle_pxe_menu(struct pxe_context *ctx, struct pxe_menu *cfg) if (err == 1) { err = label_boot(ctx, choice); + log_debug("label_boot() returns %d\n", err); if (!err) return; } else if (err != -ENOENT) { diff --git a/include/pxe_utils.h b/include/pxe_utils.h index e8e03430a81..beadd221475 100644 --- a/include/pxe_utils.h +++ b/include/pxe_utils.h @@ -109,7 +109,8 @@ typedef int (*pxe_getfile_func)(struct pxe_context *ctx, const char *file_path, * @use_ipv6: TRUE : use IPv6 addressing, FALSE : use IPv4 addressing * @use_fallback: TRUE : use "fallback" option as default, FALSE : use * "default" option as default - * @bflow: Bootflow being booted, or NULL if none + * @no_boot: Stop show of actually booting and just return + * @bflow: Bootflow being booted, or NULL if none (must be valid if @no_boot) */ struct pxe_context { /** @@ -130,6 +131,7 @@ struct pxe_context { ulong pxe_file_size; bool use_ipv6; bool use_fallback; + bool no_boot; struct bootflow *bflow; }; From patchwork Fri Dec 6 02:36:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2019063 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=Mb5gDGkG; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Y4Frq2Qb8z1yRK for ; Fri, 6 Dec 2024 13:41:47 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 7B1E98975E; Fri, 6 Dec 2024 03:38:10 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="Mb5gDGkG"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id E32EC89774; Fri, 6 Dec 2024 03:38:07 +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=-5.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-il1-x134.google.com (mail-il1-x134.google.com [IPv6:2607:f8b0:4864:20::134]) (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 42D1C89639 for ; Fri, 6 Dec 2024 03:38:04 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-il1-x134.google.com with SMTP id e9e14a558f8ab-3a77c066a15so6014525ab.3 for ; Thu, 05 Dec 2024 18:38:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1733452682; x=1734057482; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=h0iBc9rZUrZFtdY+XumUVUYCijopZZSx4HIM2bazzRo=; b=Mb5gDGkGoUJzPb8CeqF25dgZjOOlVqBgqz3gvyoomQd7c2jYkU8MM5WCXFDePjh25H S+zY12CFv8VSiqiIDXSTvpvUqm91DbnVSKVF47HK7HJShyEVzZ7P1IhWu01dhNPFcrb8 0SLDp34RF62bxZCDgBqE6AaQyEnxQ7UfqaikE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733452682; x=1734057482; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=h0iBc9rZUrZFtdY+XumUVUYCijopZZSx4HIM2bazzRo=; b=rjeJRGo2I5isWvEfh1m2AIN0TmPjMSK6ZJzAuVLicwkPxw5OTgTdeDqjcCOnE+5zJG yrl8g/QX3kHxCUPrzc7oZcjennZh3X/Ek9mMpNoFT3sZwVVYafq8p2LS8UAspPo132f9 BNPBC09MKUsVGRM9E1+Sg021mUVbeYbTjR9a/LeExR83W827WtbvnDWD3s6NLn0QdJRe OoUfRbtnoYluq/qpMpQSwYLTPAY5ACtCt08KAsLsSQ/cYy29DPSr2284Ir8BfH5sRXXg q3T4FoL9IxWLVXGZcqU60BwK2EVBvN4MMuu2Rua3DsY2IRw4EPvV4KBppRAJh8AbVpka OJ4Q== X-Gm-Message-State: AOJu0YxuYCa7i1J98MgVMlxMnwDcp+gXL4INJOdSfElFnU15kgSpjbGD aRRJ6bRbEJ9wOac4blYWO5Kj3ZofizxNsrPKkIlFVFDgcbAzF5z+eehKQDOswxhPBX1x2cYstxA = X-Gm-Gg: ASbGncsN/eLdbqzZzty353O8JiEFCeg26nF3vO6qUyIPSXjYyYtGJx3d/K9fLocqvJt kPdDa6Wj5JzJ8NSCJlAc9ime7fI2iFqnML2iznA4s9EEervycC8PBcep9DdBNqvnvTC7QdO/Ur9 kpLFNL5VFuRDLCsqrLRCgy6zrrt8BvacCs0sZFs5f3XN6k0Yt8QHMHy2DIExrFw5zedG1m9Zx0u T+ViRbz7He2gwBGaAQoUwC71POU/DJ79Y9wBihN1e3+i6tuFP7LEvahBBDgkgA38GjZ6qa2iAXv /AcJJ1kV6dI= X-Google-Smtp-Source: AGHT+IHt2tV74KQX4wkbFdNUWaopDuzv5Kl8wwy/Ec2Kf5DCZHyRhiPHYjOg2e2RQkLFtD6QbeBMcQ== X-Received: by 2002:a92:c24b:0:b0:3a7:e83c:2d07 with SMTP id e9e14a558f8ab-3a811da31c3mr19771735ab.14.1733452682143; Thu, 05 Dec 2024 18:38:02 -0800 (PST) Received: from chromium.org (c-73-203-119-151.hsd1.co.comcast.net. [73.203.119.151]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4e2861f51bfsm575506173.112.2024.12.05.18.37.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Dec 2024 18:38:00 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Simon Glass , Andrew Goodbody Subject: [PATCH v3 34/46] test: Update bootm test to restore silent_console Date: Thu, 5 Dec 2024 19:36:13 -0700 Message-Id: <20241206023626.2456858-35-sjg@chromium.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241206023626.2456858-1-sjg@chromium.org> References: <20241206023626.2456858-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.103.8 at phobos.denx.de X-Virus-Status: Clean Unset this environment variable at the end of bootm_test_silent() et al to avoid affecting subsequent tests. Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- (no changes since v1) test/boot/bootm.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test/boot/bootm.c b/test/boot/bootm.c index 9455f44884c..0dd8bc2979f 100644 --- a/test/boot/bootm.c +++ b/test/boot/bootm.c @@ -122,6 +122,9 @@ static int bootm_test_silent(struct unit_test_state *uts) ut_assertok(bootm_process_cmdline(buf, BUF_SIZE, BOOTM_CL_SILENT)); ut_asserteq_str("console=ttynull something", buf); + /* restore settings */ + env_set("silent_linux", NULL); + return 0; } BOOTM_TEST(bootm_test_silent, 0); @@ -229,6 +232,8 @@ static int bootm_test_subst_var(struct unit_test_state *uts) ut_assertok(bootm_process_cmdline_env(BOOTM_CL_SILENT)); ut_asserteq_str("some${var}thing console=ttynull", env_get("bootargs")); + env_set("silent_linux", NULL); + return 0; } BOOTM_TEST(bootm_test_subst_var, 0); @@ -246,6 +251,8 @@ static int bootm_test_subst_both(struct unit_test_state *uts) ut_assertok(bootm_process_cmdline_env(BOOTM_CL_ALL)); ut_asserteq_str("some1234567890thing console=ttynull", env_get("bootargs")); + env_set("silent_linux", NULL); + return 0; } BOOTM_TEST(bootm_test_subst_both, 0); From patchwork Fri Dec 6 02:36:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2019064 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=fcTqljIK; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Y4Frz5gbVz1yRK for ; Fri, 6 Dec 2024 13:41:55 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id CFC678976E; Fri, 6 Dec 2024 03:38:10 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="fcTqljIK"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 1133A89761; Fri, 6 Dec 2024 03:38: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=-5.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-io1-xd2a.google.com (mail-io1-xd2a.google.com [IPv6:2607:f8b0:4864:20::d2a]) (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 D2E508975E for ; Fri, 6 Dec 2024 03:38:07 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-io1-xd2a.google.com with SMTP id ca18e2360f4ac-8418a2f596fso47720039f.1 for ; Thu, 05 Dec 2024 18:38:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1733452686; x=1734057486; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=0MOGQ2zyftS1Xz2K5qYTDlxJ85b4+CYNa3WpB8IuHTM=; b=fcTqljIKt1tahwhdJiLZ17iBaDde2w4vvelq+JKfZwmMFCL61xkxUHuLR0u4ezk7cq 96hDkAnitXpiEZC+0x5O7bhhM+0UUWvOUO5SByN66HRU/WVx+bPrkWJe9w/9cQpKq2W7 pTrA2iUIRjvtOa2F5Jpao/cQfZGNF2lot2NcI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733452686; x=1734057486; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0MOGQ2zyftS1Xz2K5qYTDlxJ85b4+CYNa3WpB8IuHTM=; b=JVzZfM0MZmvNU0Swpg4lJ9cjhlwdPCIMVoMzixjB+s1Dpu2EWO/D19Dp+f/0A1ZXNh HpVHVubesA1YiW6sPQRXoZkk60DW2Zdgzkl6XkWF6eenHzsnEsZW8m2EfCOcfNM/+mUw Fg0m8zLn9o0kJTn6L39cGPIPoWvH8weEvuKbqW9SpUQVS98UfVTbNs5YBu7zksoESKiE TYneAVOpKP9tAu/ELnVvuMkORuKkfFGaMRkJH1DUDw+EJ20DCuzn/uuRdiTDiGt75kEj qckamTVbW/wMUsUXL+wWMyaOVxR+GltZ96cXjnDhGs04d03n8ZB2lJFW/+U/9zlwIYTV dIuA== X-Gm-Message-State: AOJu0Yz7TYweRMrlXWDOGtRoQYRBiWtSQ1es7GWKNi8rPFFxrL+sAYMd kNe6jxXUbTss+ngv7gvpg6nJtQsNUO2CJNd+WlyWLYS3pH8Uihd0HstwT3VqPAddK/KhJf1wcvE = X-Gm-Gg: ASbGncuGGz8DGOMqkDsTFDWk21ZK04AzY4od2IROkI/Wt8fosNMAHkJWmQRiR2QJFNp PMOyV3maLXE5RQQX2XXfiV9j95jaYud8e0kHXCc6DhP1DISTFOOyCH7ae5AYdb9pdVipOuMgl1P SFJwZEoFXysNaDOMjErQL0sXzTymxvFSHkI7IBKZWtf5t68Mq1WIbT+fEmfXtCdildeh+HVRnTi kDPN5iRLPwc/vUto6lEMVkUUj3o8Fae8OEohAL3UB/jKMTHaXXp3es0z1vnD0N78rdL1aF1doNf gQu5UeWa5DU= X-Google-Smtp-Source: AGHT+IENxOdKhFOTM5EZg1dvM47gNKePTuL9xGjYBRb49fH6WqlbEqDAo01Wje3i9Vi2ojiDxDgjUw== X-Received: by 2002:a05:6602:2c07:b0:83a:ab63:20b with SMTP id ca18e2360f4ac-8447e220e9dmr230148339f.4.1733452684574; Thu, 05 Dec 2024 18:38:04 -0800 (PST) Received: from chromium.org (c-73-203-119-151.hsd1.co.comcast.net. [73.203.119.151]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4e2861f51bfsm575506173.112.2024.12.05.18.38.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Dec 2024 18:38:02 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Simon Glass , Heinrich Schuchardt , Ion Agorria , Martyn Welch , Mattijs Korpershoek , Nam Cao Subject: [PATCH v3 35/46] bootmeth_extlinux: Move extlinux_info into plat Date: Thu, 5 Dec 2024 19:36:14 -0700 Message-Id: <20241206023626.2456858-36-sjg@chromium.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241206023626.2456858-1-sjg@chromium.org> References: <20241206023626.2456858-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.103.8 at phobos.denx.de X-Virus-Status: Clean Move this struct into the plat data so that we can use it multiple times during the boot process. This struct is missing a comment, so add one. Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- (no changes since v1) boot/bootmeth_extlinux.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/boot/bootmeth_extlinux.c b/boot/bootmeth_extlinux.c index 569f9d760bf..e2050af8203 100644 --- a/boot/bootmeth_extlinux.c +++ b/boot/bootmeth_extlinux.c @@ -22,8 +22,15 @@ #include #include +/** + * struct extlinux_plat - locate state for this bootmeth + * + * @use_fallback: true to boot with the fallback option + * @info: Info passed to the extlinux_getfile() function + */ struct extlinux_plat { bool use_fallback; + struct extlinux_info info; }; enum extlinux_option_type { @@ -175,20 +182,18 @@ static int extlinux_read_bootflow(struct udevice *dev, struct bootflow *bflow) static int extlinux_boot(struct udevice *dev, struct bootflow *bflow) { + struct extlinux_plat *plat = dev_get_plat(dev); struct pxe_context ctx; - struct extlinux_info info; - struct extlinux_plat *plat; ulong addr; int ret; addr = map_to_sysmem(bflow->buf); - info.dev = dev; - info.bflow = bflow; - plat = dev_get_plat(dev); + plat->info.dev = dev; + plat->info.bflow = bflow; - ret = pxe_setup_ctx(&ctx, extlinux_getfile, &info, true, bflow->fname, - false, plat->use_fallback, bflow); + ret = pxe_setup_ctx(&ctx, extlinux_getfile, &plat->info, true, + bflow->fname, false, plat->use_fallback, bflow); if (ret) return log_msg_ret("ctx", -EINVAL); From patchwork Fri Dec 6 02:36:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2019065 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=iiqj2lvc; dkim-atps=neutral Authentication-Results: legolas.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=patchwork.ozlabs.org) 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 ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Y4FsG1T4pz1yRK for ; Fri, 6 Dec 2024 13:42:10 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C24868975F; Fri, 6 Dec 2024 03:38:12 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="iiqj2lvc"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 7DC5C8977D; Fri, 6 Dec 2024 03:38:11 +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=-5.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-il1-x129.google.com (mail-il1-x129.google.com [IPv6:2607:f8b0:4864:20::129]) (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 4D6A68918C for ; Fri, 6 Dec 2024 03:38:09 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-il1-x129.google.com with SMTP id e9e14a558f8ab-3a77bd62fdeso5475885ab.2 for ; Thu, 05 Dec 2024 18:38:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1733452687; x=1734057487; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=/FjgX98zQ9LiIHYFJUf6V1snK6MplD46fQlGJcvlOq8=; b=iiqj2lvcMKYsfquMvXPLCAmkknS3EZuRkQxtD3fv/db5PdWqv0nsTsiIue2pjL4sOf +ZT8sSLZB2P2CNvlXqHHDgWf6lJNoit2gAbSZb+Ze8iXfCFoQBCzNeiN7P1VdIpjTF6C kBZAqtP4F3ZVeM4FKXavf4fzMF0wsYknmsAfU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733452687; x=1734057487; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/FjgX98zQ9LiIHYFJUf6V1snK6MplD46fQlGJcvlOq8=; b=dzp46vobQSkHTCJhs+RVHEL7CoaVCPLku04JKiCZNJ2iEWsM5a9+/jGGupl6MD1HDv GZMxi/33zflDzve1OViXr81W84Vb53PE03/96ZVk0fGU7dTXl+bJjIBI3bFgD+qKKIPR 3aXlYfGD8D/wwWCNQxtT/Lz/3XgF5zv8u7tnUnnZhQwMrQ/941QfoiSKL2X4PaJuN5ri okMrY5B4ARJzFraC8bUai6BdJfrBqjObPVhHrPEzZ6JaGNmz5hTu7rYBqbJpGQUSlpXh 8NfBnCMHp+WPNSN8xkb9vm/TLKHK2BKbYd72GtW6jhzlLF+kgG8hytKtWfha/D8ZLs7J XGeg== X-Gm-Message-State: AOJu0YysPbKpKgRu8xd+Pw+wRAnoog1ES3S4+B5SsVZbQZ0lUWqC4GwG Miu+qncfIRajO0mBWSuRTJsOZFujmyQPdNLXti6qGLTg3r+JYzzUXEmzTlKQcPaj5h1mZdoIzeY = X-Gm-Gg: ASbGncvmPhsqOMXjSR0WFOe3qWBkt/xyPptrqBL9ydBEmwEj+aE2in2Gj/V4gNtkmA8 JvW+peBBoTDX4Bxv0orZ4OfoUFgK6tXcJg+1FY8qUIZYclCahYFECIb6XbUq2zy+4ZWrw9u0adP 3DRdtzY9+uGH/swK+Lkd6b6PuBG9ceMseJcr7ndYpZzU4qpEBS8iM2BujDiqo3Y0SPDHvUz6f9g PRschfeT1jqYBtgWUxomaSzfxQA95lwiHXpdF/nArd8N7no79Nd0c5F4qX0ZIDEDn0yIqMc42JP BifHeabdApQ= X-Google-Smtp-Source: AGHT+IHT40k1wic3BcMI8txUfrBu23q0LJLmsP7JslpJVZH8Uv98+SEOuFPBNvsTThAkTeoTrLNOLg== X-Received: by 2002:a05:6602:341a:b0:83a:db84:41a8 with SMTP id ca18e2360f4ac-8447e35343bmr167948439f.10.1733452687574; Thu, 05 Dec 2024 18:38:07 -0800 (PST) Received: from chromium.org (c-73-203-119-151.hsd1.co.comcast.net. [73.203.119.151]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4e2861f51bfsm575506173.112.2024.12.05.18.38.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Dec 2024 18:38:06 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Simon Glass , Ion Agorria , Martyn Welch , Mattijs Korpershoek , Nam Cao Subject: [PATCH v3 36/46] bootmeth_extlinux: Move pxe_context into plat Date: Thu, 5 Dec 2024 19:36:15 -0700 Message-Id: <20241206023626.2456858-37-sjg@chromium.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241206023626.2456858-1-sjg@chromium.org> References: <20241206023626.2456858-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.103.8 at phobos.denx.de X-Virus-Status: Clean Move this struct into the plat data so that we can use it multiple times during the boot process. Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- (no changes since v1) boot/bootmeth_extlinux.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/boot/bootmeth_extlinux.c b/boot/bootmeth_extlinux.c index e2050af8203..144f5a11425 100644 --- a/boot/bootmeth_extlinux.c +++ b/boot/bootmeth_extlinux.c @@ -27,9 +27,11 @@ * * @use_fallback: true to boot with the fallback option * @info: Info passed to the extlinux_getfile() function + * @ctx: holds the PXE context, if it should be saved */ struct extlinux_plat { bool use_fallback; + struct pxe_context ctx; struct extlinux_info info; }; @@ -183,7 +185,6 @@ static int extlinux_read_bootflow(struct udevice *dev, struct bootflow *bflow) static int extlinux_boot(struct udevice *dev, struct bootflow *bflow) { struct extlinux_plat *plat = dev_get_plat(dev); - struct pxe_context ctx; ulong addr; int ret; @@ -192,12 +193,12 @@ static int extlinux_boot(struct udevice *dev, struct bootflow *bflow) plat->info.dev = dev; plat->info.bflow = bflow; - ret = pxe_setup_ctx(&ctx, extlinux_getfile, &plat->info, true, + ret = pxe_setup_ctx(&plat->ctx, extlinux_getfile, &plat->info, true, bflow->fname, false, plat->use_fallback, bflow); if (ret) return log_msg_ret("ctx", -EINVAL); - ret = pxe_process(&ctx, addr, false); + ret = pxe_process(&plat->ctx, addr, false); if (ret) return log_msg_ret("bread", -EINVAL); From patchwork Fri Dec 6 02:36:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2019066 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=DjC0UOr3; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Y4FsR0rDzz1yRK for ; Fri, 6 Dec 2024 13:42:19 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 1DB428975D; Fri, 6 Dec 2024 03:38:16 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="DjC0UOr3"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id D5E828964B; Fri, 6 Dec 2024 03:38:14 +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=-5.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-io1-xd29.google.com (mail-io1-xd29.google.com [IPv6:2607:f8b0:4864:20::d29]) (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 7280289639 for ; Fri, 6 Dec 2024 03:38:12 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-io1-xd29.google.com with SMTP id ca18e2360f4ac-843e9db3e65so61432239f.1 for ; Thu, 05 Dec 2024 18:38:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1733452690; x=1734057490; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=CCYenFilXTU1jQRStzq9TfQZeMRckJYoTJ9XjbpV5Bw=; b=DjC0UOr35OJEknWqfM9PnQIeVxPnyzbMolpFNjl79WAENLrUnVH2HsRRcUTb/q9OFS 7bMVtPwKP6s3P1ROzYT1knSy4XA4uapuO4w+qN3Qqq7D0oadTGt+Hg3InIzDRVE6tbkz uzqs6S1azraVe38ACDv6pWipGjrUwfUQrwIpQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733452690; x=1734057490; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=CCYenFilXTU1jQRStzq9TfQZeMRckJYoTJ9XjbpV5Bw=; b=Y4V59hd3x208Gyp0P6wOESKSZkXQgwHnYnKOFe76z+7eqefXhADAluXseV12WtNm0h x3ByzhWsfVFYPekpNhOX2pQbe4YD8oMroIi9tqvrZTDBTnZw4tBp0sLiMv9bArKPZS8w SXQEYuEz2kwRzOZiAEaQLN9jMj26rAcH87nTMdINat3KGJNCQ/xlUl9NOfkSSJ++RYOz iXWZ33+ocvhU2MbuHg2c6rjnJIEhzbrbhrXuBBwHapo30ysC2jGaFsGrpxU/1/f5jlTf E//JGWl/orzG+tYL1cH2XQhjIQbfobuP7eiod/z6l6KmClnN4u8dEPUbvbZwYFcklEdF PKVw== X-Gm-Message-State: AOJu0YzNOnF0tg4qLlQJXfuAWtzPBC01MwqFhbTgZsYw4Y5o5BXldDDI yPDB/crfh5DDnOkdn4/jU2ZVr716m4rKdUiz0Ggihtk6MNyF7tt2MrgheBgT3BVzgc86UOdG2SI = X-Gm-Gg: ASbGnctoN41Ou5Z47SoY4vN8kzj6qIwkApEVOnx4ULseWbX2nZuzj01EfeCymovVWfh JqgLXH+mtBb1eiK9UM8oHellYWA+ZNo7bAjhfp0sveeOIT/ZFKEIuxNXAkXITWK9TWkiKfgXGLt D0Vd+60ipGmdUjEd6Ptn81QOl7QHsy6TZ5GB1619PoMweExZGz9UGjE4+iWHHBt3LDmYM0S6zhl 7vTwph4n74Grz+sAgSVHK2CzZKrIZfbkZjrCMvLmlNLAA7DAwqXpkXcvLQIG0an3uHKixW6zGot d4m26FpNLIY= X-Google-Smtp-Source: AGHT+IGJRr1mwsRa/YtivwYxapikPQ1yamRJIF0hSeSwmazIbhv7fP/lpmfwUynEc+FeaDcE9/wjoA== X-Received: by 2002:a5d:8c8a:0:b0:841:9225:1f56 with SMTP id ca18e2360f4ac-844710c586dmr531526539f.3.1733452690650; Thu, 05 Dec 2024 18:38:10 -0800 (PST) Received: from chromium.org (c-73-203-119-151.hsd1.co.comcast.net. [73.203.119.151]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4e2861f51bfsm575506173.112.2024.12.05.18.38.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Dec 2024 18:38:09 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Simon Glass , AKASHI Takahiro , Guillaume La Roque , Heinrich Schuchardt , Ion Agorria , Julien Masson , Marek Vasut , Martyn Welch , Mattijs Korpershoek , Nam Cao , Quentin Schulz , Svyatoslav Ryhel Subject: [PATCH v3 37/46] bootmeth: Refactor to put options in a common file Date: Thu, 5 Dec 2024 19:36:16 -0700 Message-Id: <20241206023626.2456858-38-sjg@chromium.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241206023626.2456858-1-sjg@chromium.org> References: <20241206023626.2456858-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.103.8 at phobos.denx.de X-Virus-Status: Clean The fallback feature is implemented for extlinux but not for PXE. Move the code into common files so we can keep both pieces in sync. Tidy up the comment for set_property() while we are here, fixing the return value and some missing hyphens. Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- (no changes since v1) boot/Makefile | 4 +-- boot/bootmeth_extlinux.c | 74 -------------------------------------- boot/ext_pxe_common.c | 76 ++++++++++++++++++++++++++++++++++++++++ include/bootmeth.h | 8 ++--- include/extlinux.h | 29 +++++++++++++++ 5 files changed, 111 insertions(+), 80 deletions(-) create mode 100644 boot/ext_pxe_common.c diff --git a/boot/Makefile b/boot/Makefile index ef9943bbfc1..9446c6b82a9 100644 --- a/boot/Makefile +++ b/boot/Makefile @@ -27,8 +27,8 @@ obj-$(CONFIG_$(PHASE_)BOOTSTD) += bootstd-uclass.o obj-$(CONFIG_$(PHASE_)BOOTSTD_MENU) += bootflow_menu.o obj-$(CONFIG_$(PHASE_)BOOTSTD_PROG) += prog_boot.o -obj-$(CONFIG_$(PHASE_)BOOTMETH_EXTLINUX) += bootmeth_extlinux.o -obj-$(CONFIG_$(PHASE_)BOOTMETH_EXTLINUX_PXE) += bootmeth_pxe.o +obj-$(CONFIG_$(PHASE_)BOOTMETH_EXTLINUX) += ext_pxe_common.o bootmeth_extlinux.o +obj-$(CONFIG_$(PHASE_)BOOTMETH_EXTLINUX_PXE) += ext_pxe_common.o bootmeth_pxe.o obj-$(CONFIG_$(PHASE_)BOOTMETH_EFILOADER) += bootmeth_efi.o obj-$(CONFIG_$(PHASE_)BOOTMETH_CROS) += bootm.o bootm_os.o bootmeth_cros.o obj-$(CONFIG_$(PHASE_)BOOTMETH_FEL) += bootmeth_fel.o diff --git a/boot/bootmeth_extlinux.c b/boot/bootmeth_extlinux.c index 144f5a11425..d0a32eb8b68 100644 --- a/boot/bootmeth_extlinux.c +++ b/boot/bootmeth_extlinux.c @@ -22,48 +22,6 @@ #include #include -/** - * struct extlinux_plat - locate state for this bootmeth - * - * @use_fallback: true to boot with the fallback option - * @info: Info passed to the extlinux_getfile() function - * @ctx: holds the PXE context, if it should be saved - */ -struct extlinux_plat { - bool use_fallback; - struct pxe_context ctx; - struct extlinux_info info; -}; - -enum extlinux_option_type { - EO_FALLBACK, - EO_INVALID -}; - -struct extlinux_option { - char *name; - enum extlinux_option_type option; -}; - -static const struct extlinux_option options[] = { - {"fallback", EO_FALLBACK}, - {NULL, EO_INVALID} -}; - -static enum extlinux_option_type get_option(const char *option) -{ - int i = 0; - - while (options[i].name) { - if (!strcmp(options[i].name, option)) - return options[i].option; - - i++; - } - - return EO_INVALID; -}; - static int extlinux_get_state_desc(struct udevice *dev, char *buf, int maxsize) { if (IS_ENABLED(CONFIG_SANDBOX)) { @@ -205,38 +163,6 @@ static int extlinux_boot(struct udevice *dev, struct bootflow *bflow) return 0; } -static int extlinux_set_property(struct udevice *dev, const char *property, const char *value) -{ - struct extlinux_plat *plat; - static enum extlinux_option_type option; - - plat = dev_get_plat(dev); - - option = get_option(property); - if (option == EO_INVALID) { - printf("Invalid option\n"); - return -EINVAL; - } - - switch (option) { - case EO_FALLBACK: - if (!strcmp(value, "1")) { - plat->use_fallback = true; - } else if (!strcmp(value, "0")) { - plat->use_fallback = false; - } else { - printf("Unexpected value '%s'\n", value); - return -EINVAL; - } - break; - default: - printf("Unrecognised property '%s'\n", property); - return -EINVAL; - } - - return 0; -} - static int extlinux_bootmeth_bind(struct udevice *dev) { struct bootmeth_uc_plat *plat = dev_get_uclass_plat(dev); diff --git a/boot/ext_pxe_common.c b/boot/ext_pxe_common.c new file mode 100644 index 00000000000..e42865b84f5 --- /dev/null +++ b/boot/ext_pxe_common.c @@ -0,0 +1,76 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Common functions for extlinux and PXE + * + * Copyright 2024 Collabora + * Written by Martyn Welch + */ + +#define LOG_CATEGORY UCLASS_BOOTSTD + +#include +#include +#include +#include + +enum extlinux_option_type { + EO_FALLBACK, + EO_INVALID +}; + +struct extlinux_option { + char *name; + enum extlinux_option_type option; +}; + +static const struct extlinux_option options[] = { + {"fallback", EO_FALLBACK}, + {NULL, EO_INVALID} +}; + +static enum extlinux_option_type extlinux_get_option(const char *option) +{ + int i = 0; + + while (options[i].name) { + if (!strcmp(options[i].name, option)) + return options[i].option; + + i++; + } + + return EO_INVALID; +}; + +int extlinux_set_property(struct udevice *dev, const char *property, + const char *value) +{ + struct extlinux_plat *plat; + static enum extlinux_option_type option; + + plat = dev_get_plat(dev); + + option = extlinux_get_option(property); + if (option == EO_INVALID) { + printf("Invalid option\n"); + return -EINVAL; + } + + switch (option) { + case EO_FALLBACK: + if (!strcmp(value, "1")) { + plat->use_fallback = true; + } else if (!strcmp(value, "0")) { + plat->use_fallback = false; + } else { + printf("Unexpected value '%s'\n", value); + return -EINVAL; + } + break; + default: + printf("Unrecognised property '%s'\n", property); + return -EINVAL; + } + + return 0; +} diff --git a/include/bootmeth.h b/include/bootmeth.h index 26de593a9a4..03301c90580 100644 --- a/include/bootmeth.h +++ b/include/bootmeth.h @@ -151,15 +151,15 @@ struct bootmeth_ops { /** * set_property() - set the bootmeth property * - * This allows the setting of boot method specific properties to enable - * automated finer grain control of the boot process + * This allows the setting of bootmeth-specific properties to enable + * automated finer-grained control of the boot process * * @name: String containing the name of the relevant boot method * @property: String containing the name of the property to set * @value: String containing the value to be set for the specified * property - * Return: 0 if OK, -ENODEV if an unknown bootmeth or property is - * provided, -ENOENT if there are no bootmeth devices + * Return: 0 if OK, -EINVAL if an unknown property or invalid value is + * provided */ int (*set_property)(struct udevice *dev, const char *property, const char *value); diff --git a/include/extlinux.h b/include/extlinux.h index 6747fe01dda..f97164954cc 100644 --- a/include/extlinux.h +++ b/include/extlinux.h @@ -7,6 +7,8 @@ #ifndef __extlinux_h #define __extlinux_h +#include + #define EXTLINUX_FNAME "extlinux/extlinux.conf" /** @@ -20,4 +22,31 @@ struct extlinux_info { struct bootflow *bflow; }; +/** + * struct extlinux_plat - locate state for this bootmeth + * + * @use_falllback: true to boot with the fallback option + * @ctx: holds the PXE context, if it should be saved + * @info: information used for the getfile() method + */ +struct extlinux_plat { + bool use_fallback; + struct pxe_context ctx; + struct extlinux_info info; +}; + +/** + * extlinux_set_property() - set an extlinux property + * + * This allows the setting of bootmeth-specific properties to enable + * automated finer-grained control of the boot process + * + * @name: String containing the name of the relevant boot method + * @property: String containing the name of the property to set + * @value: String containing the value to be set for the specified property + * Return: 0 if OK, -EINVAL if an unknown property or invalid value is provided + */ +int extlinux_set_property(struct udevice *dev, const char *property, + const char *value); + #endif From patchwork Fri Dec 6 02:36:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2019067 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=UbkFRUIM; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Y4Fsb1fdLz1yRK for ; Fri, 6 Dec 2024 13:42:27 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 79BBF89783; Fri, 6 Dec 2024 03:38:18 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="UbkFRUIM"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 211C089791; Fri, 6 Dec 2024 03:38:18 +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=-5.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-io1-xd35.google.com (mail-io1-xd35.google.com [IPv6:2607:f8b0:4864:20::d35]) (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 E937389756 for ; Fri, 6 Dec 2024 03:38:15 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-io1-xd35.google.com with SMTP id ca18e2360f4ac-841a9366b08so47558739f.1 for ; Thu, 05 Dec 2024 18:38:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1733452693; x=1734057493; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=KlzJGU4+LZ7F0oEmRxjQ2/0xIF3Ehh/AF5D318jSqeg=; b=UbkFRUIM/DIjfuEu/lhpovmkz7V6Xj/ElaCANyf/387AfQNodGovhZrTfGO6WbuZAb Io7HTsAOcPS/kgE54W7qIsh5/O7Ywm9gqH+pjWHKaIVR5uNlvWB0EsFt0diHL60ywa8G F99ujmtjVjxh6x0+31waDDSFnk1NYypgF1kAk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733452693; x=1734057493; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=KlzJGU4+LZ7F0oEmRxjQ2/0xIF3Ehh/AF5D318jSqeg=; b=ExyOXxlDsKdXwkITu5LZYYyNkZP9Jvl16NH3lweRVM1KCRjsP3YLh2LdA5skLreBJs B7TrnPPzUIa3r+5lS5U9pbnEoiIn0HxX1CdK+ig8/9e5Vv0YoMEJsly738EfZM0vNbuQ j7j9IOO4hatabBIMs383xK8YLZEPFy1LwnkoEPdePmXrup+FOa0Re1Zzb/y7DAB6Jyxy S7t/ooPARLG4tFZwWbxs1iS/HS1NJCEv03EK+nxDlozDOA+kwMJaFrJrPtqTuCiEddfy CdD+XGnz6eT+Mzga0mPLNajp/aj8tmA6+tPNuazlMm10wqNqE+uJ19mL/qE1+jdpkdnV 7yMA== X-Gm-Message-State: AOJu0YyTOCBD9ofnYHy8VpCgmHMfDsLil+xQ3VV7kNK7sPPDhZtNyzrd BgzmcDx4vudR5Xe13mvCDKBp9t+E24SsmVd3Glyk1lUKZ15eXhbvw1QyattcszsKvPxYxMgCZVo = X-Gm-Gg: ASbGncuV+4FrrWA2BVZSJCHsQeNsO3/DVYvyvizB6gxmNpEmg/XgKcCsxlfFy0kiR4P 5/5OPEAT0R3F9JLDvLkMjCSuA9XwSjHhMAH2X7KqZI42DrUDCDr29fbArfiqIGKZR65KfU5s0/J 0bpuaMSb/xjnhJAdfBxHfwX3rKWJK7dmUMLZuowJwopAXizOwWxdCpT3qpFMsD0hUkzXmokrpe/ gzAtLP2tzHAy37kp5ycxrmZb2bT8neVIeaU2Ph8A41oduVUWz2hlJ/K5vUW2vd3c/Qi9lpYSxHO DE8zzER/wqw= X-Google-Smtp-Source: AGHT+IHRqxPOTzIJ7sX2F5ECUyFIOBNsPl/6abChURGtsTs2WCiAFoPZ1ORdNBwn51kOr7RaWVnAgA== X-Received: by 2002:a05:6e02:160a:b0:3a3:b45b:fb92 with SMTP id e9e14a558f8ab-3a811e47e7bmr19858675ab.23.1733452693671; Thu, 05 Dec 2024 18:38:13 -0800 (PST) Received: from chromium.org (c-73-203-119-151.hsd1.co.comcast.net. [73.203.119.151]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4e2861f51bfsm575506173.112.2024.12.05.18.38.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Dec 2024 18:38:12 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Simon Glass , Heinrich Schuchardt , Ilias Apalodimas , Martyn Welch , Mattijs Korpershoek Subject: [PATCH v3 38/46] bootmeth_pxe: Implement the fallback option Date: Thu, 5 Dec 2024 19:36:17 -0700 Message-Id: <20241206023626.2456858-39-sjg@chromium.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241206023626.2456858-1-sjg@chromium.org> References: <20241206023626.2456858-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.103.8 at phobos.denx.de X-Virus-Status: Clean Provide this feature in PXE, so that it matches extlinux. Use plat data for this, just like extlinux. Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- (no changes since v1) boot/bootmeth_pxe.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/boot/bootmeth_pxe.c b/boot/bootmeth_pxe.c index f2b9ffaae89..6b3cb3c4b91 100644 --- a/boot/bootmeth_pxe.c +++ b/boot/bootmeth_pxe.c @@ -139,16 +139,16 @@ static int extlinux_pxe_read_file(struct udevice *dev, struct bootflow *bflow, static int extlinux_pxe_boot(struct udevice *dev, struct bootflow *bflow) { + struct extlinux_plat *plat = dev_get_plat(dev); struct pxe_context *ctx = dev_get_priv(dev); - struct extlinux_info info; ulong addr; int ret; addr = map_to_sysmem(bflow->buf); - info.dev = dev; - info.bflow = bflow; - ret = pxe_setup_ctx(ctx, extlinux_pxe_getfile, &info, false, - bflow->subdir, false, false, bflow); + plat->info.dev = dev; + plat->info.bflow = bflow; + ret = pxe_setup_ctx(ctx, extlinux_pxe_getfile, &plat->info, false, + bflow->subdir, false, plat->use_fallback, bflow); if (ret) return log_msg_ret("ctx", -EINVAL); @@ -174,6 +174,7 @@ static struct bootmeth_ops extlinux_bootmeth_pxe_ops = { .read_bootflow = extlinux_pxe_read_bootflow, .read_file = extlinux_pxe_read_file, .boot = extlinux_pxe_boot, + .set_property = extlinux_set_property, }; static const struct udevice_id extlinux_bootmeth_pxe_ids[] = { @@ -188,4 +189,5 @@ U_BOOT_DRIVER(bootmeth_zpxe) = { .ops = &extlinux_bootmeth_pxe_ops, .bind = extlinux_bootmeth_pxe_bind, .priv_auto = sizeof(struct pxe_context), + .plat_auto = sizeof(struct extlinux_plat) }; From patchwork Fri Dec 6 02:36:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2019068 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=QQaYlhyp; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Y4Fsl2fM9z1yRK for ; Fri, 6 Dec 2024 13:42:35 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id BAA6F89756; Fri, 6 Dec 2024 03:38:20 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="QQaYlhyp"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 5DB2189776; Fri, 6 Dec 2024 03:38:20 +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=-5.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-il1-x12d.google.com (mail-il1-x12d.google.com [IPv6:2607:f8b0:4864:20::12d]) (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 8259589761 for ; Fri, 6 Dec 2024 03:38:17 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-il1-x12d.google.com with SMTP id e9e14a558f8ab-3a814831760so320655ab.1 for ; Thu, 05 Dec 2024 18:38:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1733452696; x=1734057496; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=UoWeoek1tAJaSsy88HsYiS60U4m3iWD9z9iWtihJc0A=; b=QQaYlhypn/mh3jW3OHiN0OcZp9wcMnCUi8nVqRV9/Fng4kmSuIRPmaBMMHTGsOV+ff lMS59CA4Y56WC6RS1t5DBswijEgiG53cX28YvPbQeeOhl9y6JMnnkvh0BK6+yiTEh8JP 4a0CYr0y/tEji8DbY7huMku/AU0G9TgH3BILM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733452696; x=1734057496; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=UoWeoek1tAJaSsy88HsYiS60U4m3iWD9z9iWtihJc0A=; b=pa0TGXfeZPNW1E/6lsr/wkPaWR7vha7AiZgQJj6USuGpkZlwjwEdvALg9pFoGbpH2X qKqvtS6mNbg1U8TatQh+PcwWXDexEMPpeNQ1SZbxPcQefX7Y9qzfU9S4LLmBELmgrsky +ynMFGUAH5ObW59K2AfEruMBqXxHDQOsd38svHCEe7Zf1Tr5JhSt6UEJ0a9G8oqOSkdd iGPLaU44MppD9EUMe+rkSWHxWX8wYBNgbQXFlJk0C6JdID99u6fl+IWaIQ+h8Md3c1MV 0fx7wPq7doO7M59N4lVhqOpAOS3t5HSzwvxD3/aZ0vu8fJ3IteYwRGzNzTcmWpwUDS0f kNlQ== X-Gm-Message-State: AOJu0YwAHYN4Eq4Ar/lrF8VxkrynRf5NBSi+fUWjIQn0oQtzUHJarlrU ZJVR2NSrgD2+9OwoVGxkGpupZi0NYODMkvirE2g7epftkEssU19u6d19k/iODPLaU8A6s8zU+Ok = X-Gm-Gg: ASbGncuAfKBIfzmq/WCStNc0i3NXcnOzAp0Slzd6swEBiS3R8BboICmUEQTLVt8E1H7 QJEgwp7V8WJ/aN8B+BeQkKagWONKFLd5NL0xjop9wlpXFb0mzV/z7SSid6gR1yqJdnM0WlTlL+C gaH5ONukJN9A2cGINdQBst9cDc0zeXlfejiFyJFe21++LKHIUh0/QH0cHUqMk2NLETfB/Ngl4e0 TQ8y30eKlcFE+8Vvnkor+3s4xjgONSa7/JIL/Ls8VMIe6lElXWe6cB2N74bk2g1lLNQmLMNP1qW GUCudeFtqx4= X-Google-Smtp-Source: AGHT+IHwvZqmoTgPNWG4XtMQVUuX57hZBg6CagLizi5RevXSrEt3sT2pahOEd6cvOkOY3SG9HpYI7Q== X-Received: by 2002:a05:6e02:19c8:b0:3a7:e592:55cd with SMTP id e9e14a558f8ab-3a811dcca00mr22398465ab.14.1733452695760; Thu, 05 Dec 2024 18:38:15 -0800 (PST) Received: from chromium.org (c-73-203-119-151.hsd1.co.comcast.net. [73.203.119.151]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4e2861f51bfsm575506173.112.2024.12.05.18.38.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Dec 2024 18:38:15 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Simon Glass , Heinrich Schuchardt , Ilias Apalodimas , Martyn Welch , Mattijs Korpershoek Subject: [PATCH v3 39/46] bootmeth_pxe: Drop the driver-private data Date: Thu, 5 Dec 2024 19:36:18 -0700 Message-Id: <20241206023626.2456858-40-sjg@chromium.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241206023626.2456858-1-sjg@chromium.org> References: <20241206023626.2456858-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.103.8 at phobos.denx.de X-Virus-Status: Clean Since this driver's plat-data already contains a PXE context, use that. Drop the priv-data. Use the extlinux_info which is in there, as well. Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- (no changes since v1) boot/bootmeth_pxe.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/boot/bootmeth_pxe.c b/boot/bootmeth_pxe.c index 6b3cb3c4b91..a9608edcef9 100644 --- a/boot/bootmeth_pxe.c +++ b/boot/bootmeth_pxe.c @@ -140,7 +140,7 @@ static int extlinux_pxe_read_file(struct udevice *dev, struct bootflow *bflow, static int extlinux_pxe_boot(struct udevice *dev, struct bootflow *bflow) { struct extlinux_plat *plat = dev_get_plat(dev); - struct pxe_context *ctx = dev_get_priv(dev); + struct pxe_context *ctx = &plat->ctx; ulong addr; int ret; @@ -188,6 +188,5 @@ U_BOOT_DRIVER(bootmeth_zpxe) = { .of_match = extlinux_bootmeth_pxe_ids, .ops = &extlinux_bootmeth_pxe_ops, .bind = extlinux_bootmeth_pxe_bind, - .priv_auto = sizeof(struct pxe_context), .plat_auto = sizeof(struct extlinux_plat) }; From patchwork Fri Dec 6 02:36:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2019069 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=amFIcYEH; dkim-atps=neutral Authentication-Results: legolas.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=patchwork.ozlabs.org) 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 ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Y4Fsv3fTdz1yRK for ; Fri, 6 Dec 2024 13:42:43 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 7231F8964B; Fri, 6 Dec 2024 03:38:24 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="amFIcYEH"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C891C8964B; Fri, 6 Dec 2024 03:38:22 +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=-5.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-il1-x136.google.com (mail-il1-x136.google.com [IPv6:2607:f8b0:4864:20::136]) (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 7E80789639 for ; Fri, 6 Dec 2024 03:38:20 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-il1-x136.google.com with SMTP id e9e14a558f8ab-3a789d422bcso10162265ab.1 for ; Thu, 05 Dec 2024 18:38:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1733452699; x=1734057499; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=zNoisvhlYym/phkHYZv/QNwyx/c4NzECymAONd28A60=; b=amFIcYEHdZjfcV55ZPJz3lBmt60ZPVz9whc8WJeWF/QTp3QhWCqquX82YQ0u1fqosI t1WcgDdYHb/Y9NeQzNc3jmlHxKtH7AhVnU03jBEPh5DjJz7vdbRlXkwYfFDaq22TVVot MVdNc2mpdXF4hdbbvE7iGtoqh3wIhoGmY6CKQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733452699; x=1734057499; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=zNoisvhlYym/phkHYZv/QNwyx/c4NzECymAONd28A60=; b=hnuDgtUDGtkiayJAdgAeDF0Em4FgUIJc7JF/VLudt41sVytoo2/U3Wy26LKzZK0/Sl q6xIj4tWmI1VTThthkO0ergPye9kQCKisM2VEOkD/vAl50E45nPZ7xpzOxRXwL07+Df3 g1T5fIMlhBxf2QTwvUKKiPJZ1S8IggPhf10axsshl7EQGO9A9SCoHfgLG4COUPmtB0iR lzSaI+k6FSPzXkHli80ZWbK8mFI7z83UNVFjwfBwnIs+OTtYNCoObzESZktdTy3g0/aq ySXgvVnH2UXEb3biCFqsCbBkytYyLs1lma2gKTRO6ChWVmIJwbbCt5lqVL/mF8HlKWZx rrkA== X-Gm-Message-State: AOJu0Yzgwa1NL1ox522di2lQsuuxwpuqKd9skvQIFZubIrE75P79vQGU +HwygM/lwQohh+cBGfwtgSE/0HHrqqqgD37FM0nkkFSwbiof3lESt2fYhf39G2ykJlDquKmwpRs = X-Gm-Gg: ASbGncsv1xxHCnsgAmTIy9LRddCLmBWiuMiDqUQjHbc2PeIB8AFze1AZIgKyZvel0fg 1uJhjvi/fweKq12eS//LAbgdkuC28SJVNvmh7GBdd6EEma9TpqCpB5f96n0PHXcXyb+pbDAgQyW hD3AwFMnWHyEIn5HFJVWR0IQzhvCNqW93vzunBA0N9+Fzl6s7tNYIjisLbRBIXsGecdc1W3JrKo lNZe3d8zFxVKO3pUpoty8AyKiRaQC1aNQ6OWxA6zOgOYgCtM7Rs7XSbQ04VxrBwm+V9GbLLR0xE sG7R+wc1SDg= X-Google-Smtp-Source: AGHT+IGWKTyVlT0MvofYAR8vehgC4Jmm5SrS5/DiDLBGq2ESHkYwjRfDBXg4gWR5i16f1kQrBO0Ieg== X-Received: by 2002:a05:6e02:1c0f:b0:3a7:3760:7314 with SMTP id e9e14a558f8ab-3a811e29869mr22491665ab.20.1733452698776; Thu, 05 Dec 2024 18:38:18 -0800 (PST) Received: from chromium.org (c-73-203-119-151.hsd1.co.comcast.net. [73.203.119.151]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4e2861f51bfsm575506173.112.2024.12.05.18.38.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Dec 2024 18:38:17 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Simon Glass , Heinrich Schuchardt , Ilias Apalodimas , Ion Agorria , Martyn Welch , Mattijs Korpershoek , Nam Cao Subject: [PATCH v3 40/46] bootmeth_extlinux: Move boot code into common file Date: Thu, 5 Dec 2024 19:36:19 -0700 Message-Id: <20241206023626.2456858-41-sjg@chromium.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241206023626.2456858-1-sjg@chromium.org> References: <20241206023626.2456858-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.103.8 at phobos.denx.de X-Virus-Status: Clean The extlinux and PXE code for booting is almost the same. Move it into the common file so it is easier to keep it in sync. Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- Changes in v3: - Pass through the bootfile since extlinux and PXE are different boot/bootmeth_extlinux.c | 24 +++--------------------- boot/bootmeth_pxe.c | 20 ++------------------ boot/ext_pxe_common.c | 25 +++++++++++++++++++++++++ include/extlinux.h | 15 +++++++++++++++ 4 files changed, 45 insertions(+), 39 deletions(-) diff --git a/boot/bootmeth_extlinux.c b/boot/bootmeth_extlinux.c index d0a32eb8b68..e7277ccdaa9 100644 --- a/boot/bootmeth_extlinux.c +++ b/boot/bootmeth_extlinux.c @@ -140,27 +140,9 @@ static int extlinux_read_bootflow(struct udevice *dev, struct bootflow *bflow) return 0; } -static int extlinux_boot(struct udevice *dev, struct bootflow *bflow) +static int extlinux_local_boot(struct udevice *dev, struct bootflow *bflow) { - struct extlinux_plat *plat = dev_get_plat(dev); - ulong addr; - int ret; - - addr = map_to_sysmem(bflow->buf); - - plat->info.dev = dev; - plat->info.bflow = bflow; - - ret = pxe_setup_ctx(&plat->ctx, extlinux_getfile, &plat->info, true, - bflow->fname, false, plat->use_fallback, bflow); - if (ret) - return log_msg_ret("ctx", -EINVAL); - - ret = pxe_process(&plat->ctx, addr, false); - if (ret) - return log_msg_ret("bread", -EINVAL); - - return 0; + return extlinux_boot(dev, bflow, extlinux_getfile, true, bflow->fname); } static int extlinux_bootmeth_bind(struct udevice *dev) @@ -178,7 +160,7 @@ static struct bootmeth_ops extlinux_bootmeth_ops = { .check = extlinux_check, .read_bootflow = extlinux_read_bootflow, .read_file = bootmeth_common_read_file, - .boot = extlinux_boot, + .boot = extlinux_local_boot, .set_property = extlinux_set_property, }; diff --git a/boot/bootmeth_pxe.c b/boot/bootmeth_pxe.c index a9608edcef9..5f3d595628c 100644 --- a/boot/bootmeth_pxe.c +++ b/boot/bootmeth_pxe.c @@ -139,24 +139,8 @@ static int extlinux_pxe_read_file(struct udevice *dev, struct bootflow *bflow, static int extlinux_pxe_boot(struct udevice *dev, struct bootflow *bflow) { - struct extlinux_plat *plat = dev_get_plat(dev); - struct pxe_context *ctx = &plat->ctx; - ulong addr; - int ret; - - addr = map_to_sysmem(bflow->buf); - plat->info.dev = dev; - plat->info.bflow = bflow; - ret = pxe_setup_ctx(ctx, extlinux_pxe_getfile, &plat->info, false, - bflow->subdir, false, plat->use_fallback, bflow); - if (ret) - return log_msg_ret("ctx", -EINVAL); - - ret = pxe_process(ctx, addr, false); - if (ret) - return log_msg_ret("bread", -EINVAL); - - return 0; + return extlinux_boot(dev, bflow, extlinux_pxe_getfile, false, + bflow->subdir); } static int extlinux_bootmeth_pxe_bind(struct udevice *dev) diff --git a/boot/ext_pxe_common.c b/boot/ext_pxe_common.c index e42865b84f5..0d808048289 100644 --- a/boot/ext_pxe_common.c +++ b/boot/ext_pxe_common.c @@ -74,3 +74,28 @@ int extlinux_set_property(struct udevice *dev, const char *property, return 0; } + +int extlinux_boot(struct udevice *dev, struct bootflow *bflow, + pxe_getfile_func getfile, bool allow_abs_path, + const char *bootfile) +{ + struct extlinux_plat *plat = dev_get_plat(dev); + ulong addr; + int ret; + + addr = map_to_sysmem(bflow->buf); + + plat->info.dev = dev; + plat->info.bflow = bflow; + + ret = pxe_setup_ctx(&plat->ctx, getfile, &plat->info, allow_abs_path, + bootfile, false, plat->use_fallback, bflow); + if (ret) + return log_msg_ret("ctx", -EINVAL); + + ret = pxe_process(&plat->ctx, addr, false); + if (ret) + return log_msg_ret("bread", -EINVAL); + + return 0; +} diff --git a/include/extlinux.h b/include/extlinux.h index f97164954cc..5baa2440b53 100644 --- a/include/extlinux.h +++ b/include/extlinux.h @@ -49,4 +49,19 @@ struct extlinux_plat { int extlinux_set_property(struct udevice *dev, const char *property, const char *value); +/** + * extlinux_boot() - Boot a bootflow + * + * @dev: bootmeth device + * @bflow: Bootflow to boot + * @getfile: Function to use to read files + * @allow_abs_path: true to allow absolute paths + * @bootfile: Bootfile whose directory loaded files are relative to, NULL if + * none + * Return: 0 if OK, -ve error code on failure + */ +int extlinux_boot(struct udevice *dev, struct bootflow *bflow, + pxe_getfile_func getfile, bool allow_abs_path, + const char *bootfile); + #endif From patchwork Fri Dec 6 02:36:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2019070 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=lylkJOkh; dkim-atps=neutral Authentication-Results: legolas.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=patchwork.ozlabs.org) 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 ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Y4Ft40DGXz1yRK for ; Fri, 6 Dec 2024 13:42:52 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C54708978C; Fri, 6 Dec 2024 03:38:27 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="lylkJOkh"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id D7D0E89639; Fri, 6 Dec 2024 03:38:26 +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=-5.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-il1-x12a.google.com (mail-il1-x12a.google.com [IPv6:2607:f8b0:4864:20::12a]) (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 7B70B89753 for ; Fri, 6 Dec 2024 03:38:24 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-il1-x12a.google.com with SMTP id e9e14a558f8ab-3a77c066a15so6015515ab.3 for ; Thu, 05 Dec 2024 18:38:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1733452702; x=1734057502; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=aMR03ciOncqkvtcejI0AIuBObAhV4KL1rA4xH5j3ORY=; b=lylkJOkhB/Y4NQjJOUy/GdtdUbRbodkc5h2XHhA+pRI2NnAqxUAF5b47Konsp0yW1v D6JRDGeCQGfxCh7A3MwmXTyA7OriWk+hTzAqsfbYxKS4utY5MOk+5+I3GH5OXQzqj4l1 /e3lMBYifkJT3NyOtBPZdHlsFrdqCsmfbUNBA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733452702; x=1734057502; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=aMR03ciOncqkvtcejI0AIuBObAhV4KL1rA4xH5j3ORY=; b=OvAPeqa26PeDMnPLUYiwuTE7u6bBd4HftIzvElm6F8d1Ml2200YHliQEQCIwbsc4qF WdPThbx94ixWpnLroTcwiRTGKr+mURvHOJqinqfqH4zGRgF/WbFlUw9LnoLL/L89GFUH ky4VRzw3hBMLNRgengmAoLzDNJdhBiWRSoeFujvxafTDs5WjERq8V6eetyXYtfOZ9DM4 EyZsos0i1fytoxyGsCO4hz5Dl4Ak6uzyYCEbr/3legi2fCvQKG9C+R/3RWNLSIdegX5q 5fimsyDZqP3q7ioazrdsiE1QK5ieYyRautfjPtAqIkZaYZAWYjtjzFQoSQ6/kfBsMLdV pvLg== X-Gm-Message-State: AOJu0YwOp1y0lQnqpQXFHZad5z5ZFq94Rp1r90+bHhRDPtevIOyyk5CG SApMD3gC61e4SntKyLlJsu7ALp373RrmMtuOlCQ6do686s/hzo3YatgBBzGTOQPov+ksTKwg3G8 = X-Gm-Gg: ASbGnct7zL/EL1DxWQKrllFR/Qnjn+BwsgIvBFtwGojMQPYujiciqNDqDPHgwkFVVCG ON6uCvfxaX4eO9DmUnYaE3ps4SrAKhduQqhYLdKDJmkIoCBVYvVC3lrat28GkRqdcg/ixIcVqub 4/jBJOPWdD9asE3dXsZ0w1pDNivIrqm5U+ohGteqPi4jG6m0Dhbx1/4SkGDVEN0J3PdXGJneeTc DL7H3JLMX1A7GzM8Pnd1Yi3MlGh2s4R9IV9SqOTGPEThu/ai+V5/euujFnBX682zxRVZ7dtqfoF mCHNxijeQTs= X-Google-Smtp-Source: AGHT+IE/Ne6pAWaBmHQbYPzBDBBpTDM+JRDDRQ0ZL50nUPpMnhQhDCnL/0/qRtIp8GLRnu/uPZQfug== X-Received: by 2002:a05:6602:2d81:b0:835:4d27:edf6 with SMTP id ca18e2360f4ac-8447e238b26mr185357539f.7.1733452701881; Thu, 05 Dec 2024 18:38:21 -0800 (PST) Received: from chromium.org (c-73-203-119-151.hsd1.co.comcast.net. [73.203.119.151]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4e2861f51bfsm575506173.112.2024.12.05.18.38.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Dec 2024 18:38:20 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Simon Glass , AKASHI Takahiro , Guillaume La Roque , Heinrich Schuchardt , Ilias Apalodimas , Ion Agorria , Martyn Welch , Mattijs Korpershoek , Nam Cao , Quentin Schulz Subject: [PATCH v3 41/46] bootstd: Update extlinux and pxe to allow boot interruption Date: Thu, 5 Dec 2024 19:36:20 -0700 Message-Id: <20241206023626.2456858-42-sjg@chromium.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241206023626.2456858-1-sjg@chromium.org> References: <20241206023626.2456858-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.103.8 at phobos.denx.de X-Virus-Status: Clean It is useful to be able to inspect things before the OS is actually booted, perhaps to check that all is well or to adjust the kernel command-line. Implement the 'read_all()' method to allow this. Provide a simple test to check that the images are found. For now it is not possible to actually continue the uninterrupted boot, without re-reading all the images. Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- Changes in v3: - Pass through the bootfile since extlinux and PXE are different boot/bootmeth_extlinux.c | 11 ++++++++++ boot/bootmeth_pxe.c | 11 ++++++++++ boot/ext_pxe_common.c | 29 ++++++++++++++++++++++++--- include/extlinux.h | 15 ++++++++++++++ test/boot/bootflow.c | 43 ++++++++++++++++++++++++++++++++++++++++ 5 files changed, 106 insertions(+), 3 deletions(-) diff --git a/boot/bootmeth_extlinux.c b/boot/bootmeth_extlinux.c index e7277ccdaa9..bd9026d448b 100644 --- a/boot/bootmeth_extlinux.c +++ b/boot/bootmeth_extlinux.c @@ -145,6 +145,14 @@ static int extlinux_local_boot(struct udevice *dev, struct bootflow *bflow) return extlinux_boot(dev, bflow, extlinux_getfile, true, bflow->fname); } +#if CONFIG_IS_ENABLED(BOOTSTD_FULL) +static int extlinux_local_read_all(struct udevice *dev, struct bootflow *bflow) +{ + return extlinux_read_all(dev, bflow, extlinux_getfile, true, + bflow->fname); +} +#endif + static int extlinux_bootmeth_bind(struct udevice *dev) { struct bootmeth_uc_plat *plat = dev_get_uclass_plat(dev); @@ -162,6 +170,9 @@ static struct bootmeth_ops extlinux_bootmeth_ops = { .read_file = bootmeth_common_read_file, .boot = extlinux_local_boot, .set_property = extlinux_set_property, +#if CONFIG_IS_ENABLED(BOOTSTD_FULL) + .read_all = extlinux_local_read_all, +#endif }; static const struct udevice_id extlinux_bootmeth_ids[] = { diff --git a/boot/bootmeth_pxe.c b/boot/bootmeth_pxe.c index 5f3d595628c..4b5b88bae52 100644 --- a/boot/bootmeth_pxe.c +++ b/boot/bootmeth_pxe.c @@ -143,6 +143,14 @@ static int extlinux_pxe_boot(struct udevice *dev, struct bootflow *bflow) bflow->subdir); } +#if CONFIG_IS_ENABLED(BOOTSTD_FULL) +static int extlinux_pxe_read_all(struct udevice *dev, struct bootflow *bflow) +{ + return extlinux_read_all(dev, bflow, extlinux_pxe_getfile, false, + bflow->subdir); +} +#endif + static int extlinux_bootmeth_pxe_bind(struct udevice *dev) { struct bootmeth_uc_plat *plat = dev_get_uclass_plat(dev); @@ -159,6 +167,9 @@ static struct bootmeth_ops extlinux_bootmeth_pxe_ops = { .read_file = extlinux_pxe_read_file, .boot = extlinux_pxe_boot, .set_property = extlinux_set_property, +#if CONFIG_IS_ENABLED(BOOTSTD_FULL) + .read_all = extlinux_pxe_read_all, +#endif }; static const struct udevice_id extlinux_bootmeth_pxe_ids[] = { diff --git a/boot/ext_pxe_common.c b/boot/ext_pxe_common.c index 0d808048289..6e999af5fca 100644 --- a/boot/ext_pxe_common.c +++ b/boot/ext_pxe_common.c @@ -75,9 +75,9 @@ int extlinux_set_property(struct udevice *dev, const char *property, return 0; } -int extlinux_boot(struct udevice *dev, struct bootflow *bflow, - pxe_getfile_func getfile, bool allow_abs_path, - const char *bootfile) +static int extlinux_process(struct udevice *dev, struct bootflow *bflow, + pxe_getfile_func getfile, bool allow_abs_path, + const char *bootfile, bool no_boot) { struct extlinux_plat *plat = dev_get_plat(dev); ulong addr; @@ -92,6 +92,7 @@ int extlinux_boot(struct udevice *dev, struct bootflow *bflow, bootfile, false, plat->use_fallback, bflow); if (ret) return log_msg_ret("ctx", -EINVAL); + plat->ctx.no_boot = no_boot; ret = pxe_process(&plat->ctx, addr, false); if (ret) @@ -99,3 +100,25 @@ int extlinux_boot(struct udevice *dev, struct bootflow *bflow, return 0; } + +int extlinux_boot(struct udevice *dev, struct bootflow *bflow, + pxe_getfile_func getfile, bool allow_abs_path, + const char *bootfile) +{ + return extlinux_process(dev, bflow, getfile, allow_abs_path, bootfile, + false); +} + +int extlinux_read_all(struct udevice *dev, struct bootflow *bflow, + pxe_getfile_func getfile, bool allow_abs_path, + const char *bootfile) +{ + int ret; + + ret = extlinux_process(dev, bflow, getfile, allow_abs_path, bootfile, + true); + if (ret) + return log_msg_ret("era", -EINVAL); + + return 0; +} diff --git a/include/extlinux.h b/include/extlinux.h index 5baa2440b53..f64597ebdef 100644 --- a/include/extlinux.h +++ b/include/extlinux.h @@ -64,4 +64,19 @@ int extlinux_boot(struct udevice *dev, struct bootflow *bflow, pxe_getfile_func getfile, bool allow_abs_path, const char *bootfile); +/** + * extlinux_read_all() - read all files for a bootflow + * + * @dev: Bootmethod device to boot + * @bflow: Bootflow to read + * @getfile: Function to use to read files + * @allow_abs_path: true to allow absolute paths + * @bootfile: Bootfile whose directory loaded files are relative to, NULL if + * none + * Return: 0 if OK, -EIO on I/O error, other -ve on other error + */ +int extlinux_read_all(struct udevice *dev, struct bootflow *bflow, + pxe_getfile_func getfile, bool allow_abs_path, + const char *bootfile); + #endif diff --git a/test/boot/bootflow.c b/test/boot/bootflow.c index f7d12765928..ef8c0c1bbaa 100644 --- a/test/boot/bootflow.c +++ b/test/boot/bootflow.c @@ -1433,3 +1433,46 @@ static int bootstd_adhoc(struct unit_test_state *uts) return 0; } BOOTSTD_TEST(bootstd_adhoc, UTF_CONSOLE); + +/* Check scanning extlinux, adjusting cmdline and booting */ +static int bootflow_scan_extlinux(struct unit_test_state *uts) +{ + const struct bootflow_img *img; + struct bootstd_priv *std; + struct bootflow *bflow; + + ut_assertok(run_command("bootflow scan", 0)); + ut_assert_console_end(); + ut_assertok(bootstd_get_priv(&std)); + + ut_asserteq(1, std->bootflows.count); + + bflow = alist_getw(&std->bootflows, 0, struct bootflow); + std->cur_bootflow = bflow; + + /* read all the images, but don't actually boot */ + ut_assertok(inject_response(uts)); + ut_assertok(bootflow_read_all(bflow)); + + /* check that the command line is now present */ + ut_asserteq_str( + "ro root=UUID=9732b35b-4cd5-458b-9b91-80f7047e0b8a rhgb quiet LANG=en_US.UTF-8 cma=192MB cma=256MB", + bflow->cmdline); + + ut_asserteq(3, bflow->images.count); + + /* check each image */ + img = alist_get(&bflow->images, 0, struct bootflow_img); + ut_asserteq_strn("# extlinux.conf", map_sysmem(img->addr, 0)); + + img = alist_get(&bflow->images, 1, struct bootflow_img); + ut_asserteq(IH_TYPE_KERNEL, img->type); + ut_asserteq(0x1000000, img->addr); /* kernel_addr_r */ + + img = alist_get(&bflow->images, 2, struct bootflow_img); + ut_asserteq(IH_TYPE_RAMDISK, img->type); + ut_asserteq(0x2000000, img->addr); /* ramdisk_addr_r */ + + return 0; +} +BOOTSTD_TEST(bootflow_scan_extlinux, UTF_DM | UTF_SCAN_FDT | UTF_CONSOLE); From patchwork Fri Dec 6 02:36:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2019071 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=jxN7l45y; dkim-atps=neutral Authentication-Results: legolas.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=patchwork.ozlabs.org) 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 ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Y4FtC70kyz1yRK for ; Fri, 6 Dec 2024 13:42:59 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 38E7B89753; Fri, 6 Dec 2024 03:38:30 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="jxN7l45y"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id DD2628979B; Fri, 6 Dec 2024 03:38:28 +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=-5.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-il1-x12c.google.com (mail-il1-x12c.google.com [IPv6:2607:f8b0:4864:20::12c]) (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 78C4889761 for ; Fri, 6 Dec 2024 03:38:26 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-il1-x12c.google.com with SMTP id e9e14a558f8ab-3a79911ac70so6210315ab.1 for ; Thu, 05 Dec 2024 18:38:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1733452704; x=1734057504; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=2vYAECU28AEurSs1P/vzovd1fibvOs8JYUmQjJ2pZRg=; b=jxN7l45yEqjm4UX8XjX6BlZfXp8c0+IKytlZ3cFNhAkzXtbVHalEJmuFIvZsMRt2ev wZCY++NVG8XVqXdasaoNdLfuuN/WPSSibuRVohOGuHGXyP2uANUiAHkhnKdRxjSQ/+tD MwqN4+dT/qdSiKQz7R5EvMQ4uRItr4OC+LwIc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733452704; x=1734057504; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2vYAECU28AEurSs1P/vzovd1fibvOs8JYUmQjJ2pZRg=; b=qrbAqoHJO3IxP9atLbSa9lAKlybwXuU1+oS1U5SD4m39MamoyTIKpU41CfvgKcgLTn epKOcMsR1mVeitmFwSBEtlaVixBvM8aCf892VqIrsCWF16v8jHbVywO1yvFbMv/0ToGe JKEI4pDP5CBKXtevklxsIoXKG5T8LW2EyoTZ1cqPzBUX+4JAnj3kiqm5PLAb9fxppbnd GH4kRCtW90sUxrgGvtpXzLOsC8eQIdt/H+uqfUF9CUC2jtJUEz6DBY/oTyQB+h4M0hRJ 4cfs1xubAaaoS1Otts9bQ+n6HGQZAVuWXPLMv8Mf36jx4ZauBUgXACqgFilg6xrtouiU pCZg== X-Gm-Message-State: AOJu0YzjU32OjjVg9Ctvy/v3WjYuDrJFqECZHC5neBWDD84ao2orXPhJ AHM9jmiMbRH5YAOwNrM/MoNXwFisQ1uiTNGZRmBu++wjqCLfii9wvddXOkYeXCCEAw1OywYQxDg = X-Gm-Gg: ASbGnctAWGDnEwqE41tJ53j4Bf+3d1O431ZcVlmI3eBWgUJicfE8u5lI3uQChoCDum1 ytA4ckw9CvhQ9wovW7I99TzwDijr2Jd1qBOa44C6BxghtmTrgar6A3nailPUO4UQpXFxxA6PePi slieSufeNT18pJYpr8eJryMMv7KH5Dp/UXJ4ecfcvVydQBGht7T3ouwsOduvCdirHJmG+WokYeP 8N6WdxMLudY4Qh6x/2Sk4cgnNdWqk0hkMVDdppJsiZjIVgd2d+7TFjI1EDvPL2h3AmiWSMrk5vU yTNjVYdm+IM= X-Google-Smtp-Source: AGHT+IGgiqcb02kXy/IMs7o+M3s2AlumGvfvGAno2UTmB2yzEhH5crgL8/tqTFETSUJlSzy+sx+a8Q== X-Received: by 2002:a05:6e02:1ca7:b0:3a7:6e34:9219 with SMTP id e9e14a558f8ab-3a811db26admr20042975ab.14.1733452704342; Thu, 05 Dec 2024 18:38:24 -0800 (PST) Received: from chromium.org (c-73-203-119-151.hsd1.co.comcast.net. [73.203.119.151]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4e2861f51bfsm575506173.112.2024.12.05.18.38.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Dec 2024 18:38:22 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Simon Glass , AKASHI Takahiro , Guillaume La Roque , Heinrich Schuchardt , Ilias Apalodimas , Marek Vasut , Martyn Welch , Mattijs Korpershoek , Michael Trimarchi , Quentin Schulz Subject: [PATCH v3 42/46] pxe: Collect the FDT in the bootflow Date: Thu, 5 Dec 2024 19:36:21 -0700 Message-Id: <20241206023626.2456858-43-sjg@chromium.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241206023626.2456858-1-sjg@chromium.org> References: <20241206023626.2456858-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.103.8 at phobos.denx.de X-Virus-Status: Clean Move processing of the FDT so that it happens before booting. Add a test to check that the FDT is now visible. Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- (no changes since v1) boot/pxe_utils.c | 22 +++++++++++++--------- test/boot/bootflow.c | 6 +++++- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/boot/pxe_utils.c b/boot/pxe_utils.c index 3531ab1c71a..053fdcbb6e7 100644 --- a/boot/pxe_utils.c +++ b/boot/pxe_utils.c @@ -578,26 +578,23 @@ static int label_process_fdt(struct pxe_context *ctx, struct pxe_label *label, * @initrd_filesize: String containing initrd size (only used if * @initrd_addr_str) * @initrd_str: initrd string to process (only used if @initrd_addr_str) + * @conf_fdt: string containing the FDT address * Return: does not return on success, or returns 0 if the boot command * returned, or -ve error value on error */ static int label_run_boot(struct pxe_context *ctx, struct pxe_label *label, char *kernel_addr, char *initrd_addr_str, - char *initrd_filesize, char *initrd_str) + char *initrd_filesize, char *initrd_str, + const char *conf_fdt) { struct bootm_info bmi; ulong kernel_addr_r; + int ret = 0; void *buf; - int ret; bootm_init(&bmi); - bmi.conf_fdt = env_get("fdt_addr_r"); - - ret = label_process_fdt(ctx, label, kernel_addr, &bmi.conf_fdt); - if (ret) - return ret; - + bmi.conf_fdt = conf_fdt; bmi.addr_img = kernel_addr; bootm_x86_set(&bmi, bzimage_addr, hextoul(kernel_addr, NULL)); @@ -678,6 +675,8 @@ static int label_boot(struct pxe_context *ctx, struct pxe_label *label) char mac_str[29] = ""; char ip_str[68] = ""; char *fit_addr = NULL; + const char *conf_fdt; + int ret; label_print(label); @@ -782,11 +781,16 @@ static int label_boot(struct pxe_context *ctx, struct pxe_label *label) printf("append: %s\n", finalbootargs); } + conf_fdt = env_get("fdt_addr_r"); + ret = label_process_fdt(ctx, label, kernel_addr, &conf_fdt); + if (ret) + return ret; + if (ctx->no_boot) return 0; label_run_boot(ctx, label, kernel_addr, initrd_addr_str, - initrd_filesize, initrd_str); + initrd_filesize, initrd_str, conf_fdt); /* ignore the error value since we are going to fail anyway */ cleanup: diff --git a/test/boot/bootflow.c b/test/boot/bootflow.c index ef8c0c1bbaa..640a7cdb7c9 100644 --- a/test/boot/bootflow.c +++ b/test/boot/bootflow.c @@ -1459,7 +1459,7 @@ static int bootflow_scan_extlinux(struct unit_test_state *uts) "ro root=UUID=9732b35b-4cd5-458b-9b91-80f7047e0b8a rhgb quiet LANG=en_US.UTF-8 cma=192MB cma=256MB", bflow->cmdline); - ut_asserteq(3, bflow->images.count); + ut_asserteq(4, bflow->images.count); /* check each image */ img = alist_get(&bflow->images, 0, struct bootflow_img); @@ -1473,6 +1473,10 @@ static int bootflow_scan_extlinux(struct unit_test_state *uts) ut_asserteq(IH_TYPE_RAMDISK, img->type); ut_asserteq(0x2000000, img->addr); /* ramdisk_addr_r */ + img = alist_get(&bflow->images, 3, struct bootflow_img); + ut_asserteq(IH_TYPE_FLATDT, img->type); + ut_asserteq(0xc00000, img->addr); /* fdt_addr_r */ + return 0; } BOOTSTD_TEST(bootflow_scan_extlinux, UTF_DM | UTF_SCAN_FDT | UTF_CONSOLE); From patchwork Fri Dec 6 02:36:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2019072 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=MhWeolxf; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Y4FtN2Xrpz1yRV for ; Fri, 6 Dec 2024 13:43:08 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 9C9F489787; Fri, 6 Dec 2024 03:38:33 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="MhWeolxf"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 9DAEE8965B; Fri, 6 Dec 2024 03:38:31 +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=-5.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-il1-x131.google.com (mail-il1-x131.google.com [IPv6:2607:f8b0:4864:20::131]) (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 E01A089787 for ; Fri, 6 Dec 2024 03:38:28 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-il1-x131.google.com with SMTP id e9e14a558f8ab-3a813899384so883895ab.1 for ; Thu, 05 Dec 2024 18:38:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1733452707; x=1734057507; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=99yWmNGac7HvS5PIqaO4WTa+FuVX6TAIYsUh1NTygfc=; b=MhWeolxfM9Qb4VYBo+ukije+85wWqdCzz5uV6c1UT5/Ge8yI9rNlznO3Yh1eqNxdTt Lmq0rusb12bwLol6vtI38YJVNz+5AAeOt9fs7ul4jUBGp2qoVUSO3y4Ht4T3V32fs3ld 636FBPBPDDYPRp2r96mXWGsZfSxzYgLy4sR6w= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733452707; x=1734057507; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=99yWmNGac7HvS5PIqaO4WTa+FuVX6TAIYsUh1NTygfc=; b=qr/ydFfuCvxYJg1fMwo4SKmLQUxE6DmoYDsYjTqedKJbwfrSPGiYqoAmDpUhdOIzFP UMc1Q9SN1srhcsLiuH2HfR0g1m2cCsjN03JbGAqRQy6jNvWFI+5g2SWTjDUmgjEhtJ75 U0GbAqwZ348OMRKMGig9SFJ8ULMqTwYFtZq737cUUvbSq6CZvoyV2j88hC2sUOWY4Ivg 6QsoxW5+hFqWDIJDpWlgMVrYUnuZYbCeuogKmB0WtHrbJXPQLMvIrmEgql5ZYNvX4dYe ezzxnS7AzuGRrf0a23oGHNza3Ws0njUvLwxt4YTZ8WSeqVFO2lqFFHF/Sn7aBbQhDaTm JMyQ== X-Gm-Message-State: AOJu0YzIV7oNpDW2JdTtqTOuf3SJolM3IPqtHhAjwnZjhENo9HC2gJU4 geTyiE7Ssaez/DxlnrpgmH8QEz6bmxVFS2cU0b7727PZRQVuirtTqPQhiOdvyYrThxRe/1b95bI = X-Gm-Gg: ASbGncvLQeT72HQuL4TM2VVusBjWu0xuJ3dj6idtmUulQdt3q6LfAetagSxQOueqUJP kJcQO2FK8yGw0mHtjEgVjgZpkMBj8ENtv8jH6b0mFL0/AgAbmjkqerK1ukj4PJuVpuFPZu5s1E5 cYbRdMBn+NT817JCViLM07Ud/AvyN486zvD0ors2R5tag9XZUgFPNgyXFHVvIQVElZRMx/oP1iQ lSdxSzi6giyfWqYZXeyRHnyQOJ8yWuYLOTETup+yoGiFKC8lmf4TH/zeDrAgMwTdQVmIk3JBQbr O1UVluNiDNI= X-Google-Smtp-Source: AGHT+IEOeAceoSR7O91lqBNhOydv/EJucbvtxvwD2+Gqtf81ddm4PbL4PYxnKmHDYmnl5Pcb1WP/4g== X-Received: by 2002:a05:6e02:168a:b0:3a7:8d8e:e760 with SMTP id e9e14a558f8ab-3a811dab4dfmr18193305ab.4.1733452706771; Thu, 05 Dec 2024 18:38:26 -0800 (PST) Received: from chromium.org (c-73-203-119-151.hsd1.co.comcast.net. [73.203.119.151]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4e2861f51bfsm575506173.112.2024.12.05.18.38.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Dec 2024 18:38:25 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Simon Glass , Marek Vasut , Martyn Welch , Michael Trimarchi , Quentin Schulz Subject: [PATCH v3 43/46] pxe: Deal with a missing FDT in the bootflow Date: Thu, 5 Dec 2024 19:36:22 -0700 Message-Id: <20241206023626.2456858-44-sjg@chromium.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241206023626.2456858-1-sjg@chromium.org> References: <20241206023626.2456858-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.103.8 at phobos.denx.de X-Virus-Status: Clean Move processing of a missing FDT so that it happens before booting, so we can see the result in the bootflow. Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- (no changes since v1) boot/pxe_utils.c | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/boot/pxe_utils.c b/boot/pxe_utils.c index 053fdcbb6e7..1468a8e8498 100644 --- a/boot/pxe_utils.c +++ b/boot/pxe_utils.c @@ -605,21 +605,9 @@ static int label_run_boot(struct pxe_context *ctx, struct pxe_label *label, hextoul(initrd_filesize, NULL)); } - if (!bmi.conf_fdt) { - if (!IS_ENABLED(CONFIG_SUPPORT_PASSING_ATAGS) || - strcmp("-", label->fdt)) - bmi.conf_fdt = env_get("fdt_addr"); - } - kernel_addr_r = genimg_get_kernel_addr(kernel_addr); buf = map_sysmem(kernel_addr_r, 0); - if (!bmi.conf_fdt && genimg_get_format(buf) != IMAGE_FORMAT_FIT) { - if (!IS_ENABLED(CONFIG_SUPPORT_PASSING_ATAGS) || - strcmp("-", label->fdt)) - bmi.conf_fdt = env_get("fdtcontroladdr"); - } - /* Try bootm for legacy and FIT format image */ if (genimg_get_format(buf) != IMAGE_FORMAT_INVALID && IS_ENABLED(CONFIG_CMD_BOOTM)) { @@ -786,6 +774,28 @@ static int label_boot(struct pxe_context *ctx, struct pxe_label *label) if (ret) return ret; + if (!conf_fdt) { + if (!IS_ENABLED(CONFIG_SUPPORT_PASSING_ATAGS) || + strcmp("-", label->fdt)) + conf_fdt = env_get("fdt_addr"); + } + + if (!conf_fdt) { + ulong kernel_addr_r; + void *buf; + + kernel_addr_r = genimg_get_kernel_addr(kernel_addr); + buf = map_sysmem(kernel_addr_r, 0); + if (genimg_get_format(buf) != IMAGE_FORMAT_FIT) { + if (!IS_ENABLED(CONFIG_SUPPORT_PASSING_ATAGS) || + strcmp("-", label->fdt)) + conf_fdt = env_get("fdtcontroladdr"); + } + unmap_sysmem(buf); + } + if (ctx->bflow) + ctx->bflow->fdt_addr = hextoul(conf_fdt, NULL); + if (ctx->no_boot) return 0; From patchwork Fri Dec 6 02:36:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2019073 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=jkoNyjaO; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Y4FtX2Qqqz1yRK for ; Fri, 6 Dec 2024 13:43:16 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id EDF458978E; Fri, 6 Dec 2024 03:38:34 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="jkoNyjaO"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id A3C2589788; Fri, 6 Dec 2024 03:38:33 +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=-5.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-io1-xd2e.google.com (mail-io1-xd2e.google.com [IPv6:2607:f8b0:4864:20::d2e]) (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 795A8896BA for ; Fri, 6 Dec 2024 03:38:31 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-io1-xd2e.google.com with SMTP id ca18e2360f4ac-8442ec2adc7so55091139f.2 for ; Thu, 05 Dec 2024 18:38:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1733452709; x=1734057509; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=oOn2u10S5kwmBvbMJ6aNx/m5KTqTAk6amUxoKRLpCG4=; b=jkoNyjaOB00J0xE1zTFN5H3ody4q6tK6AGs+vBoLNwbzQzLX0vni5yVRMEt3rwCw/C cWckoG7cfPZ9MoNSNW9wUNEzIMBNJjLsZ/Vz7ETAcczUx/6Q9fcqSxZHIyxP00FEGcBC demUZOmZnXcwDLFWloGFAWKyH2xHrI+xO/JDM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733452709; x=1734057509; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=oOn2u10S5kwmBvbMJ6aNx/m5KTqTAk6amUxoKRLpCG4=; b=SfiaEfYLCZb3voeuAp1fz0U+4sKXbpKQltd9Oc45e9wmi5kYlnJuWiQDt56NKsL9qE CPULtl6CvFPwJDCY53uQtk++9Eqcy7eN7cleVeWU5XzEk1k0CrkSWsGdy+6EIYBT0yu2 7wkYBra433behLQkh+dB8KrFqjWKkuF3zmUAHw0I055PMB24vLBjdFssviuEww09HMNe 4UtqPhxcdLJfJXSnpGx5y9CM5bgwPVf6qaK0eJgNjGesYXu9UvIxhVpzLX1pdpRpbfpg OEMfV8VC5urHeuTu3CFW7LqhgEIiV0WDxICxsGL7YexerPD+p/bHs8kIQjw2yKZcBYBg iGmQ== X-Gm-Message-State: AOJu0YzITfVR8tRWSGmDENBOPBCHf8xGDLkh0ANAgtkZ3qnx8TV4WsxO p1ZLt8S18e4BMRlqKx5sWYYxkLFuu0sS32A25ahUmOVlTV5dJl6eDxa61NHAwH4nZY8B9gHzkMw = X-Gm-Gg: ASbGncuOZzcC+Tt5/N738e7T3nbfeeT88Db4QWGFWQ1/prDi9TIfyVeCs56fNoY15ka AraoPNd9FrMe5RqwWzlEqmlV9XjKhqXnKAB5hLB6tAcoJvlRSJ4CKJdrAhB8pAJKb2VMdtCwcqP huW23kFtrPm24XD8iIYpbzvxJ/qHz23h6dO6TmUEe8P6N1nJyJp5B7jpIguSrgDoJM++vHWjBOs bbi+exMhiM3gLpZymqqEonlYPks2rtgyp9jiZvJiCl1SVrpEgdN7VmEr3dTesvJr55cJprUt5gy VAk5qIsA/88= X-Google-Smtp-Source: AGHT+IGdvpOa1ls93PFw6WWkTpnHmP4pPwrMl3QXlpPHv7OlS+WRMqY6+Uf0zJvcPmV5WCGtQlPYXA== X-Received: by 2002:a05:6602:6c1c:b0:843:e9c1:930b with SMTP id ca18e2360f4ac-8447e2d9f29mr216065839f.14.1733452709686; Thu, 05 Dec 2024 18:38:29 -0800 (PST) Received: from chromium.org (c-73-203-119-151.hsd1.co.comcast.net. [73.203.119.151]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4e2861f51bfsm575506173.112.2024.12.05.18.38.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Dec 2024 18:38:28 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Simon Glass , Marek Vasut , Martyn Welch , Michael Trimarchi , Quentin Schulz Subject: [PATCH v3 44/46] boot: Detect booti format properly in pxe_utils Date: Thu, 5 Dec 2024 19:36:23 -0700 Message-Id: <20241206023626.2456858-45-sjg@chromium.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241206023626.2456858-1-sjg@chromium.org> References: <20241206023626.2456858-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.103.8 at phobos.denx.de X-Virus-Status: Clean Rather than assuming that a file can be booted with bootm, check that the format is correct first. Do the same for booti. Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- Changes in v3: - Add new patch to detect booti format properly in pxe_utils boot/pxe_utils.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/boot/pxe_utils.c b/boot/pxe_utils.c index 1468a8e8498..71347b19119 100644 --- a/boot/pxe_utils.c +++ b/boot/pxe_utils.c @@ -591,6 +591,7 @@ static int label_run_boot(struct pxe_context *ctx, struct pxe_label *label, ulong kernel_addr_r; int ret = 0; void *buf; + enum image_fmt_t fmt; bootm_init(&bmi); @@ -608,13 +609,18 @@ static int label_run_boot(struct pxe_context *ctx, struct pxe_label *label, kernel_addr_r = genimg_get_kernel_addr(kernel_addr); buf = map_sysmem(kernel_addr_r, 0); - /* Try bootm for legacy and FIT format image */ - if (genimg_get_format(buf) != IMAGE_FORMAT_INVALID && - IS_ENABLED(CONFIG_CMD_BOOTM)) { + /* + * Try bootm for legacy and FIT format image, assume booti if + * compressed + */ + fmt = genimg_get_format_comp(buf); + + if (IS_ENABLED(CONFIG_CMD_BOOTM) && (fmt == IMAGE_FORMAT_FIT || + fmt == IMAGE_FORMAT_LEGACY)) { log_debug("using bootm\n"); ret = bootm_run(&bmi); /* Try booting an AArch64 Linux kernel image */ - } else if (IS_ENABLED(CONFIG_CMD_BOOTI)) { + } else if (IS_ENABLED(CONFIG_CMD_BOOTI) && fmt == IMAGE_FORMAT_BOOTI) { log_debug("using booti\n"); ret = booti_run(&bmi); /* Try booting a Image */ From patchwork Fri Dec 6 02:36:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2019074 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=e6+S0un1; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Y4Fth5XVBz1yRK for ; Fri, 6 Dec 2024 13:43:24 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 41D988979B; Fri, 6 Dec 2024 03:38:38 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="e6+S0un1"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 677F98978D; Fri, 6 Dec 2024 03:38:37 +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=-5.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-il1-x12f.google.com (mail-il1-x12f.google.com [IPv6:2607:f8b0:4864:20::12f]) (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 1627D89794 for ; Fri, 6 Dec 2024 03:38:35 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-il1-x12f.google.com with SMTP id e9e14a558f8ab-3a7a46ca756so5316935ab.0 for ; Thu, 05 Dec 2024 18:38:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1733452713; x=1734057513; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=U+0MII1wQkO+/NRRSb/EhLD0lRD5dPjuS+jMfskJkjA=; b=e6+S0un1Ej6zSuY0uGcb6Rv/JA0ZchrR0f9H5QgGA2QEjTbY5vSZpHRUnE47xlrMAX B9OZdqQBYOxFMB1AxNqCKdFSszqygjPF025TwFuvTR/6Mp/h7v8rgCmph5lSY34oy8qP W5vsIe0qgsBxtFP9jo4eIoOPSd6B5shZL1POo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733452713; x=1734057513; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=U+0MII1wQkO+/NRRSb/EhLD0lRD5dPjuS+jMfskJkjA=; b=Ymm0f8T5wCWLf6/TZ6dlAuh83FZUVQHsOga5w9VLUS+zCuHvqBcjvhyrMOthaRuxr6 sEklVu1f5LKEZJ4Brv0xxhih3r4WIt5EJ0xzeFnw+I8SIDCkZP+fuGgPrejblOoRJZ9V fAqt5OslmmVmdAiVSl/sTsMn5b/EIG1B5TA+EYutwJg2z7v3qW2Bv5uzAB/nKTfV6qXo WgW1/FALRyx9tpqo4yTBvM2Q/lTFuoZetwR5m8bBI2LpynmtwXoBeCwh9xIU4fQJiEWg jIOwD1lFN15uulA//Cj3UilT9bREUM4UeQoFOUmINMrR3c2DK3idN7V+frpHHqI7w7Zi XLag== X-Gm-Message-State: AOJu0YzD6KI+4snzfKxFBmjGwJf2iFqeT5G7cQAQUatqoyU6qWmyxo28 TcLQmDyrp/pX8UidSB7gwomRLfTgzyLVYvuD3+dtyV1kpm8m2IZkf7YePG5wJM+EDFFbAzcfoGM = X-Gm-Gg: ASbGncuH6D3JRp4qyNFDULn1xTYs6YwIF7IFjQZkUV6IraXu9s6BX99a9i944Ej8ox7 hzQujBd1YtQ6Av9RToAGAImdMmxQl4BWlSgvZQ4a8AhTGPl7nEtrtZ7r9Tf1PK1y0UGZVwkJ/BF HIW+Orxod52FMj66N7OGiENb2SEPCuQ225eMEH7miM7Y+6csMHb6Rq9G+OYAnIExIO6JdFqoWaQ hIHBwxBvtoY9RxkcVfC10KHx8vOiPPRVZMasdyPHwCJgqwjj3zBghKduP7BwIKC+k+fzY1cyfA+ fvY0Suk1/LA= X-Google-Smtp-Source: AGHT+IEf3wkbvZZl7w8UrC4FD528Gnp60C9Itj9W7Hd0P3+KNfD+AuhPJItFkWSV7vY9UE88G3xPXA== X-Received: by 2002:a05:6e02:1c8f:b0:3a7:e528:6edd with SMTP id e9e14a558f8ab-3a811db7d25mr20137395ab.12.1733452712677; Thu, 05 Dec 2024 18:38:32 -0800 (PST) Received: from chromium.org (c-73-203-119-151.hsd1.co.comcast.net. [73.203.119.151]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4e2861f51bfsm575506173.112.2024.12.05.18.38.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Dec 2024 18:38:31 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Simon Glass , Marek Vasut , Martyn Welch , Michael Trimarchi , Quentin Schulz Subject: [PATCH v3 45/46] pxe_utils: Refactor to separate reading from booting Date: Thu, 5 Dec 2024 19:36:24 -0700 Message-Id: <20241206023626.2456858-46-sjg@chromium.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241206023626.2456858-1-sjg@chromium.org> References: <20241206023626.2456858-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.103.8 at phobos.denx.de X-Virus-Status: Clean It is useful to be able to select a bootflow and read its images, without actually doing the boot. This allows adjusting the bootargs, for example. Provide support for this in the pxe_utils module, by adding a 'probe' method which selects a label and saves its settings, so it can be booted later, if desired. Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- (no changes since v1) boot/pxe_utils.c | 72 +++++++++++++++++++++++++++++++++++++++++---- include/pxe_utils.h | 41 ++++++++++++++++++++++++++ 2 files changed, 108 insertions(+), 5 deletions(-) diff --git a/boot/pxe_utils.c b/boot/pxe_utils.c index 71347b19119..3a4caa9329a 100644 --- a/boot/pxe_utils.c +++ b/boot/pxe_utils.c @@ -802,8 +802,31 @@ static int label_boot(struct pxe_context *ctx, struct pxe_label *label) if (ctx->bflow) ctx->bflow->fdt_addr = hextoul(conf_fdt, NULL); - if (ctx->no_boot) + if (IS_ENABLED(CONFIG_BOOTSTD_FULL) && ctx->no_boot) { + ctx->label = label; + ctx->kernel_addr = strdup(kernel_addr); + if (initrd_addr_str) { + ctx->initrd_addr_str = strdup(initrd_addr_str); + ctx->initrd_filesize = strdup(initrd_filesize); + ctx->initrd_str = strdup(initrd_str); + } + ctx->conf_fdt = strdup(conf_fdt); + log_debug("Saving label '%s':\n", label->name); + log_debug("- kernel_addr '%s' conf_fdt '%s'\n", + ctx->kernel_addr, ctx->conf_fdt); + if (initrd_addr_str) { + log_debug("- initrd addr '%s' filesize '%s' str '%s'\n", + ctx->initrd_addr_str, ctx->initrd_filesize, + ctx->initrd_str); + } + if (!ctx->kernel_addr || !ctx->conf_fdt || + (initrd_addr_str && (!ctx->initrd_addr_str || + !ctx->initrd_filesize || !ctx->initrd_str))) { + printf("malloc fail (saving label)\n"); + return 1; + } return 0; + } label_run_boot(ctx, label, kernel_addr, initrd_addr_str, initrd_filesize, initrd_str, conf_fdt); @@ -1695,18 +1718,29 @@ void pxe_destroy_ctx(struct pxe_context *ctx) free(ctx->bootdir); } -int pxe_process(struct pxe_context *ctx, ulong pxefile_addr_r, bool prompt) +struct pxe_menu *pxe_prepare(struct pxe_context *ctx, ulong pxefile_addr_r, + bool prompt) { struct pxe_menu *cfg; cfg = parse_pxefile(ctx, pxefile_addr_r); if (!cfg) { printf("Error parsing config file\n"); - return 1; + return NULL; } - if (prompt) - cfg->prompt = 1; + cfg->prompt = prompt; + + return cfg; +} + +int pxe_process(struct pxe_context *ctx, ulong pxefile_addr_r, bool prompt) +{ + struct pxe_menu *cfg; + + cfg = pxe_prepare(ctx, pxefile_addr_r, prompt); + if (!cfg) + return 1; handle_pxe_menu(ctx, cfg); @@ -1714,3 +1748,31 @@ int pxe_process(struct pxe_context *ctx, ulong pxefile_addr_r, bool prompt) return 0; } + +int pxe_probe(struct pxe_context *ctx, ulong pxefile_addr_r, bool prompt) +{ + ctx->cfg = pxe_prepare(ctx, pxefile_addr_r, prompt); + if (!ctx->cfg) + return -EINVAL; + ctx->no_boot = true; + + handle_pxe_menu(ctx, ctx->cfg); + + return 0; +} + +int pxe_do_boot(struct pxe_context *ctx) +{ + int ret; + + if (!ctx->label) + return log_msg_ret("pxb", -ENOENT); + + ret = label_run_boot(ctx, ctx->label, ctx->kernel_addr, + ctx->initrd_addr_str, ctx->initrd_filesize, + ctx->initrd_str, ctx->conf_fdt); + if (ret) + return log_msg_ret("lrb", ret); + + return 0; +} diff --git a/include/pxe_utils.h b/include/pxe_utils.h index beadd221475..6425e349d19 100644 --- a/include/pxe_utils.h +++ b/include/pxe_utils.h @@ -111,6 +111,16 @@ typedef int (*pxe_getfile_func)(struct pxe_context *ctx, const char *file_path, * "default" option as default * @no_boot: Stop show of actually booting and just return * @bflow: Bootflow being booted, or NULL if none (must be valid if @no_boot) + * @cfg: PXE menu (NULL if not yet probed) + * + * The following are only used when probing for a label + * @label: Label to process + * @kernel_addr: String containing kernel address (cannot be NULL) + * @initrd_addr_str: String containing initaddr address (NULL if none) + * @initrd_filesize: String containing initrd size (only used if + * @initrd_addr_str) + * @initrd_str: initrd string to process (only used if @initrd_addr_str) + * @conf_fdt: string containing the FDT address */ struct pxe_context { /** @@ -133,6 +143,15 @@ struct pxe_context { bool use_fallback; bool no_boot; struct bootflow *bflow; + struct pxe_menu *cfg; + + /* information on the selected label to boot */ + struct pxe_label *label; + char *kernel_addr; + char *initrd_addr_str; + char *initrd_filesize; + char *initrd_str; + char *conf_fdt; }; /** @@ -283,4 +302,26 @@ int pxe_get_file_size(ulong *sizep); */ int pxe_get(ulong pxefile_addr_r, char **bootdirp, ulong *sizep, bool use_ipv6); +/** + * pxe_probe() - Process a PXE file to find the label to boot + * + * This fills in the label, etc. fields in @ctx, assuming it funds something to + * boot. Then pxe_do_boot() can be called to boot it. + * + * @ctx: PXE context created with pxe_setup_ctx() + * @pxefile_addr_r: Address to load file + * @prompt: Force a prompt for the user + * Return: 0 if OK, -ve on error + */ +int pxe_probe(struct pxe_context *ctx, ulong pxefile_addr_r, bool prompt); + +/** + * pxe_do_boot() - Boot the selected label + * + * This boots the label discovered by pxe_probe() + * + * Return: Does not return, on success, otherwise returns a -ve error code + */ +int pxe_do_boot(struct pxe_context *ctx); + #endif /* __PXE_UTILS_H */ From patchwork Fri Dec 6 02:36:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2019075 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=YORAUkpg; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Y4Ftr71rSz1yRK for ; Fri, 6 Dec 2024 13:43:32 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 980958965B; Fri, 6 Dec 2024 03:38:41 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="YORAUkpg"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id A6A7989620; Fri, 6 Dec 2024 03:38:39 +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=-5.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-il1-x12b.google.com (mail-il1-x12b.google.com [IPv6:2607:f8b0:4864:20::12b]) (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 5F04F89788 for ; Fri, 6 Dec 2024 03:38:37 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-il1-x12b.google.com with SMTP id e9e14a558f8ab-3a77980fe3aso5854415ab.0 for ; Thu, 05 Dec 2024 18:38:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1733452715; x=1734057515; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=FnFdJ6ShazJSrJJt2fufZmBS22KiAPCd/h+jVYrP+oc=; b=YORAUkpgQxZCcbB8Aj8c4z/x37MrvOrk5rwO00h7hnj7sReO1Utli+gBdVd3dYJXuf 4qw7SeFEWiFQIA2l/G9/ibfovzXdvLh7ER742hSVX0QSOzPuaZ22UJg3BS55wJxQRGsc kbRWk4Io1GE+u99H6HJNDeCBvQPznTXL5x+3M= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733452715; x=1734057515; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=FnFdJ6ShazJSrJJt2fufZmBS22KiAPCd/h+jVYrP+oc=; b=S1XVPQB8hSydkHKzFNSLJQrgaaSf/HkeHP59J6Ls0xFKpdUlp+os8A8sa98Ov+KXLm py+CDDFkhZBHXUo9N6OBnl/0SnAnf02q4c16FadJwWfWwB5pV9lmAmBwo+qCpYBlwpBo 6/TONrEMLS7Vv6JRgAWWozL9VuBl92HVp5zEAJZdD0ocXAf3b5j4ysjEQJtxOYOscwMv w26ldgerC4m/o+XgEQH86fNVaZPgoEXxi6ZwYyfnLmUPj8xLuPc1a5LBOKW7URj9lJYR tfijNm5FO9qOXJK6F9+8vUUKIlmlFrIcNVJ6hpBqdWB9s7HzisTLiT32waH5NDmye5tR EDbg== X-Gm-Message-State: AOJu0Yz6hpca3aP1WsZKOBNNq18dcP0q+eMbRiGCEltpdyTmtBB9IWej vd+ekLSsAYYJFPiq9O+bNbn5/5KBTmU5vxAnmHrNAkb1yG0rfEPBRy68usP8jr0i6S4zej398R8 = X-Gm-Gg: ASbGncu75wU95bfW76cFk898HOTicz4Jv9oMQOkYea56viGGCMYUqP51zX3HPflN973 MAllrZSZrfsgn45O2WBKYQaftLeXgmHXnmYx2xSBHRXRPO4DduyFo0A1uq17bJiM5xs995kL8Yy b9VEO+BSlwJgUlE28PcG3PWtUR+0lNP99ROgk70wJvsgaKB5MVAMu9H5ug7ARdzKyKTnzLHPsrX fIXSNgWR9GdhBMi8K/Hr0zuLg/mopF7ps8WZDsHjNP11q7f99/55KwMeERl9dA2KU/wrii+B0Cj tFLQLZcGA2E= X-Google-Smtp-Source: AGHT+IH9jfQ/O5DTu87kO8Nq1rmEghn/ZrQjklJZ3sDAL0ePMYtE8QuFXafBzN+0tqukGflToeSy4Q== X-Received: by 2002:a05:6e02:10ce:b0:3a8:13d5:bd2c with SMTP id e9e14a558f8ab-3a813d5bd8emr8178725ab.2.1733452715557; Thu, 05 Dec 2024 18:38:35 -0800 (PST) Received: from chromium.org (c-73-203-119-151.hsd1.co.comcast.net. [73.203.119.151]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4e2861f51bfsm575506173.112.2024.12.05.18.38.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Dec 2024 18:38:34 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Simon Glass , AKASHI Takahiro , Guillaume La Roque , Heinrich Schuchardt , Mattijs Korpershoek Subject: [PATCH v3 46/46] bootmeth_extlinux: Refactor extlinux to split boot Date: Thu, 5 Dec 2024 19:36:25 -0700 Message-Id: <20241206023626.2456858-47-sjg@chromium.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241206023626.2456858-1-sjg@chromium.org> References: <20241206023626.2456858-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.103.8 at phobos.denx.de X-Virus-Status: Clean Add a new extlinux_setup() function which sets things up so that the bootflow can either be booted, or just probed. Provide a readall() method so that images can be read into memory, without booting the OS. Adjust the boot() method so that it can boot, after any changes have been made by the user. Update the test to change the bootargs and check that they are booted with the changes intact. Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- Changes in v3: - Pass through the bootfile since extlinux and PXE are different boot/ext_pxe_common.c | 53 +++++++++++++++++++++++++++---------------- test/boot/bootflow.c | 24 ++++++++++++++++++++ 2 files changed, 58 insertions(+), 19 deletions(-) diff --git a/boot/ext_pxe_common.c b/boot/ext_pxe_common.c index 6e999af5fca..2037099708a 100644 --- a/boot/ext_pxe_common.c +++ b/boot/ext_pxe_common.c @@ -75,28 +75,20 @@ int extlinux_set_property(struct udevice *dev, const char *property, return 0; } -static int extlinux_process(struct udevice *dev, struct bootflow *bflow, - pxe_getfile_func getfile, bool allow_abs_path, - const char *bootfile, bool no_boot) +static int extlinux_setup(struct udevice *dev, struct bootflow *bflow, + pxe_getfile_func getfile, bool allow_abs_path, + const char *bootfile, struct pxe_context *ctx) { struct extlinux_plat *plat = dev_get_plat(dev); - ulong addr; int ret; - addr = map_to_sysmem(bflow->buf); - plat->info.dev = dev; plat->info.bflow = bflow; - ret = pxe_setup_ctx(&plat->ctx, getfile, &plat->info, allow_abs_path, - bootfile, false, plat->use_fallback, bflow); - if (ret) - return log_msg_ret("ctx", -EINVAL); - plat->ctx.no_boot = no_boot; - - ret = pxe_process(&plat->ctx, addr, false); + ret = pxe_setup_ctx(ctx, getfile, &plat->info, allow_abs_path, bootfile, + false, plat->use_fallback, bflow); if (ret) - return log_msg_ret("bread", -EINVAL); + return log_msg_ret("ctx", ret); return 0; } @@ -105,20 +97,43 @@ int extlinux_boot(struct udevice *dev, struct bootflow *bflow, pxe_getfile_func getfile, bool allow_abs_path, const char *bootfile) { - return extlinux_process(dev, bflow, getfile, allow_abs_path, bootfile, - false); + struct extlinux_plat *plat = dev_get_plat(dev); + ulong addr; + int ret; + + /* if we have already selected a label, just boot it */ + if (plat->ctx.label) { + ret = pxe_do_boot(&plat->ctx); + } else { + ret = extlinux_setup(dev, bflow, getfile, allow_abs_path, + bootfile, &plat->ctx); + if (ret) + return log_msg_ret("elb", ret); + addr = map_to_sysmem(bflow->buf); + ret = pxe_process(&plat->ctx, addr, false); + } + if (ret) + return log_msg_ret("elb", -EFAULT); + + return 0; } int extlinux_read_all(struct udevice *dev, struct bootflow *bflow, pxe_getfile_func getfile, bool allow_abs_path, const char *bootfile) { + struct extlinux_plat *plat = dev_get_plat(dev); + ulong addr; int ret; - ret = extlinux_process(dev, bflow, getfile, allow_abs_path, bootfile, - true); + ret = extlinux_setup(dev, bflow, getfile, allow_abs_path, bootfile, + &plat->ctx); + if (ret) + return log_msg_ret("era", ret); + addr = map_to_sysmem(bflow->buf); + ret = pxe_probe(&plat->ctx, addr, false); if (ret) - return log_msg_ret("era", -EINVAL); + return log_msg_ret("elb", -EFAULT); return 0; } diff --git a/test/boot/bootflow.c b/test/boot/bootflow.c index 640a7cdb7c9..35580cee90c 100644 --- a/test/boot/bootflow.c +++ b/test/boot/bootflow.c @@ -21,6 +21,7 @@ #endif #include #include +#include #include #include #include "bootstd_common.h" @@ -1440,6 +1441,9 @@ static int bootflow_scan_extlinux(struct unit_test_state *uts) const struct bootflow_img *img; struct bootstd_priv *std; struct bootflow *bflow; + const char *cline; + const void *fdt; + int node; ut_assertok(run_command("bootflow scan", 0)); ut_assert_console_end(); @@ -1477,6 +1481,26 @@ static int bootflow_scan_extlinux(struct unit_test_state *uts) ut_asserteq(IH_TYPE_FLATDT, img->type); ut_asserteq(0xc00000, img->addr); /* fdt_addr_r */ + /* adjust the command line */ + ut_assertok(run_command("bootflow cmdline set root /dev/mmc2", 0)); + + ut_asserteq(-EFAULT, bootflow_boot(bflow)); + ut_assert_skip_to_line("sandbox: continuing, as we cannot run Linux"); + ut_assert_console_end(); + + /* check that the images were not loaded again */ + ut_asserteq(4, bflow->images.count); + + /* check the cmdline in the booted FDT */ + fdt = working_fdt; + node = fdt_subnode_offset(fdt, 0, "chosen"); + ut_assert(node > 0); + cline = fdt_getprop(fdt, node, "bootargs", 0); + ut_assertnonnull(cline); + ut_asserteq_str( + "ro root=/dev/mmc2 rhgb quiet LANG=en_US.UTF-8 cma=192MB cma=256MB", + bflow->cmdline); + return 0; } BOOTSTD_TEST(bootflow_scan_extlinux, UTF_DM | UTF_SCAN_FDT | UTF_CONSOLE);