From: Simon Glass <sjg@chromium.org>
To: U-Boot Mailing List <u-boot@lists.denx.de>
Cc: Matthew Garrett <mgarrett@aurora.tech>,
Simon Glass <sjg@chromium.org>,
Emil Kronborg <emil.kronborg@protonmail.com>,
Francis Laniel <francis.laniel@amarulasolutions.com>,
Heinrich Schuchardt <xypron.glpk@gmx.de>,
Hou Zhiqiang <Zhiqiang.Hou@nxp.com>,
Ilias Apalodimas <ilias.apalodimas@linaro.org>,
Jerome Forissier <jerome.forissier@linaro.org>,
Maxim Moskalets <maximmosk4@gmail.com>,
Rasmus Villemoes <rasmus.villemoes@prevas.dk>,
Sebastian Reichel <sebastian.reichel@collabora.com>,
Tom Rini <trini@konsulko.com>
Subject: [PATCH 7/8] doc: test: Add docs and test for addr_find
Date: Mon, 9 Dec 2024 09:28:00 -0700 [thread overview]
Message-ID: <20241209162801.288363-8-sjg@chromium.org> (raw)
In-Reply-To: <20241209162801.288363-1-sjg@chromium.org>
Add documentation and a test for this command.
Drop the use of config.h while we are here.
Signed-off-by: Simon Glass <sjg@chromium.org>
---
cmd/addr_find.c | 1 -
doc/usage/cmd/addr_find.rst | 63 +++++++++++++++++++++++++++++++++++++
doc/usage/index.rst | 1 +
test/cmd/Makefile | 1 +
test/cmd/addr_find.c | 27 ++++++++++++++++
5 files changed, 92 insertions(+), 1 deletion(-)
create mode 100644 doc/usage/cmd/addr_find.rst
create mode 100644 test/cmd/addr_find.c
diff --git a/cmd/addr_find.c b/cmd/addr_find.c
index 2c20b959031..601b8b2566b 100644
--- a/cmd/addr_find.c
+++ b/cmd/addr_find.c
@@ -5,7 +5,6 @@
*/
#include <blk.h>
-#include <config.h>
#include <command.h>
#include <env.h>
#include <fs.h>
diff --git a/doc/usage/cmd/addr_find.rst b/doc/usage/cmd/addr_find.rst
new file mode 100644
index 00000000000..0d16ffd236b
--- /dev/null
+++ b/doc/usage/cmd/addr_find.rst
@@ -0,0 +1,63 @@
+.. SPDX-License-Identifier: GPL-2.0+:
+
+.. index::
+ single: addr_find (command)
+
+addr_find command
+=================
+
+Synopsis
+--------
+
+::
+
+ addr_find <interface> [<dev[:part]> [<filename>]]
+
+Description
+-----------
+
+The addr_find command is used to find a consecutive region of memory
+sufficiently large to hold a file, ensuring that the memory is not currently in
+use for another file, etc.
+
+If successful, 'loadaddr' is set to the located address.
+
+The number of transferred bytes is saved in the environment variable filesize.
+The load address is saved in the environment variable fileaddr.
+
+interface
+ interface for accessing the block device (mmc, sata, scsi, usb, ....)
+
+dev
+ device number
+
+part
+ partition number, defaults to 0 (whole device)
+
+filename
+ path to file, defaults to environment variable 'bootfile'
+
+Example
+-------
+
+This shows obtaining an address suitable for a file on an mmc disk::
+
+ => ls mmc 1
+ extlinux/
+ 97135227 initramfs-5.3.7-301.fc31.armv7hl.img
+ dtb-5.3.7-301.fc31.armv7hl/
+ 12531628 vmlinuz-5.3.7-301.fc31.armv7hl
+
+ 2 file(s), 2 dir(s)
+
+ => addr_find mmc 1 vmlinuz-5.3.7-301.fc31.armv7hl
+ => print loadaddr
+ loadaddr=7c00000
+ =>
+
+
+Return value
+------------
+
+The return value $? is set to 0 (true) if the command succeeds. If no suitable
+address could be found, the return value $? is set to 1 (false).
diff --git a/doc/usage/index.rst b/doc/usage/index.rst
index 64fb91bc5a6..9cbc9a2c9f9 100644
--- a/doc/usage/index.rst
+++ b/doc/usage/index.rst
@@ -24,6 +24,7 @@ Shell commands
:maxdepth: 1
cmd/acpi
+ cmd/addr_find
cmd/addrmap
cmd/armffa
cmd/askenv
diff --git a/test/cmd/Makefile b/test/cmd/Makefile
index dfc49af7bf3..912579e0c6b 100644
--- a/test/cmd/Makefile
+++ b/test/cmd/Makefile
@@ -14,6 +14,7 @@ obj-$(CONFIG_CMD_PAUSE) += test_pause.o
endif
obj-y += exit.o mem.o
obj-$(CONFIG_X86) += cpuid.o msr.o
+obj-$(CONFIG_CMD_ADDR_FIND) += addr_find.o
obj-$(CONFIG_CMD_ADDRMAP) += addrmap.o
obj-$(CONFIG_CMD_BDI) += bdinfo.o
obj-$(CONFIG_COREBOOT_SYSINFO) += coreboot.o
diff --git a/test/cmd/addr_find.c b/test/cmd/addr_find.c
new file mode 100644
index 00000000000..ce087759d9e
--- /dev/null
+++ b/test/cmd/addr_find.c
@@ -0,0 +1,27 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Test for 'part_find' command
+ *
+ * Copyright 2024 Google LLC
+ * Written by Simon Glass <sjg@chromium.org>
+ */
+
+#include <dm/device-internal.h>
+#include <dm/lists.h>
+#include <dm/ofnode.h>
+#include <dm/test.h>
+#include <test/cmd.h>
+#include <test/ut.h>
+
+/* Test 'addr_find' command */
+static int cmd_test_addr_find(struct unit_test_state *uts)
+{
+ ut_assertok(env_set("loadaddr", NULL));
+ ut_assertok(run_command("addr_find mmc 1:1 vmlinuz-5.3.7-301.fc31.armv7hl", 0));
+ ut_assert_console_end();
+
+ ut_assertnonnull(env_get("loadaddr"));
+
+ return 0;
+}
+CMD_TEST(cmd_test_addr_find, UTF_CONSOLE | UTF_DM | UTF_SCAN_FDT);
--
2.34.1
next prev parent reply other threads:[~2024-12-09 16:29 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-09 16:27 [PATCH 0/8] efi: Add docs and tests and a few tweaks Simon Glass
2024-12-09 16:27 ` [PATCH 1/8] fdtdec: Correct devicetree symbol for EFI app Simon Glass
2024-12-09 16:27 ` [PATCH 2/8] part_find: Enable for sandbox and correct radix and calls Simon Glass
2024-12-09 16:27 ` [PATCH 3/8] doc: test: Add docs and test for part_find Simon Glass
2024-12-10 8:15 ` Heinrich Schuchardt
2024-12-10 16:16 ` Simon Glass
2024-12-10 17:08 ` Tom Rini
2024-12-16 0:29 ` Simon Glass
2024-12-16 8:05 ` Heinrich Schuchardt
2024-12-09 16:27 ` [PATCH 4/8] efi: Drop config.h Simon Glass
2024-12-09 16:27 ` [PATCH 5/8] cmd: Refactor part_find() into separate functions Simon Glass
2024-12-09 16:27 ` [PATCH 6/8] addr_find: Use a simple lmb allocation Simon Glass
2024-12-09 16:28 ` Simon Glass [this message]
2024-12-09 16:28 ` [PATCH 8/8] efi: Avoid a memory leak in efi_bind_block() on error path Simon Glass
2024-12-10 8:10 ` Heinrich Schuchardt
2024-12-16 15:15 ` Simon Glass
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241209162801.288363-8-sjg@chromium.org \
--to=sjg@chromium.org \
--cc=Zhiqiang.Hou@nxp.com \
--cc=emil.kronborg@protonmail.com \
--cc=francis.laniel@amarulasolutions.com \
--cc=ilias.apalodimas@linaro.org \
--cc=jerome.forissier@linaro.org \
--cc=maximmosk4@gmail.com \
--cc=mgarrett@aurora.tech \
--cc=rasmus.villemoes@prevas.dk \
--cc=sebastian.reichel@collabora.com \
--cc=trini@konsulko.com \
--cc=u-boot@lists.denx.de \
--cc=xypron.glpk@gmx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox