diff mbox series

[v3,30/46] boot: Avoid using the cmdline in bootmeth_pxe and pxe cmd

Message ID 20241206023626.2456858-31-sjg@chromium.org
State Changes Requested
Delegated to: Tom Rini
Headers show
Series pxe: Support read_all() for extlinux and PXE | expand

Commit Message

Simon Glass Dec. 6, 2024, 2:36 a.m. UTC
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 <sjg@chromium.org>
---

(no changes since v1)

 boot/bootmeth_pxe.c | 16 ++++++----------
 cmd/pxe.c           | 21 +++++++--------------
 2 files changed, 13 insertions(+), 24 deletions(-)

Comments

Simon Glass Dec. 20, 2024, 4:05 a.m. UTC | #1
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 <sjg@chromium.org>
---

(no changes since v1)

 boot/bootmeth_pxe.c | 16 ++++++----------
 cmd/pxe.c           | 21 +++++++--------------
 2 files changed, 13 insertions(+), 24 deletions(-)

Applied to sjg/master, thanks!
diff mbox series

Patch

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;