doc: test: Add docs and test for addr_find
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>
This commit is contained in:
@@ -5,7 +5,6 @@
|
||||
*/
|
||||
|
||||
#include <blk.h>
|
||||
#include <config.h>
|
||||
#include <command.h>
|
||||
#include <env.h>
|
||||
#include <fs_legacy.h>
|
||||
|
||||
63
doc/usage/cmd/addr_find.rst
Normal file
63
doc/usage/cmd/addr_find.rst
Normal file
@@ -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).
|
||||
@@ -26,6 +26,7 @@ Shell commands
|
||||
:maxdepth: 1
|
||||
|
||||
cmd/acpi
|
||||
cmd/addr_find
|
||||
cmd/addrmap
|
||||
cmd/armffa
|
||||
cmd/askenv
|
||||
|
||||
@@ -12,6 +12,7 @@ obj-$(CONFIG_CMD_PAUSE) += test_pause.o
|
||||
endif
|
||||
obj-y += exit.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_CMD_CHID) += chid.o
|
||||
|
||||
27
test/cmd/addr_find.c
Normal file
27
test/cmd/addr_find.c
Normal file
@@ -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);
|
||||
Reference in New Issue
Block a user