summaryrefslogtreecommitdiff
path: root/include/command.h
AgeCommit message (Collapse)Author
2025-05-29include/command.h: Drop <env.h>Tom Rini
Now that all of the cases of code that relied on <command.h> to provide <env.h> (or one of the headers that it includes, and so forth) have been fixed, we can drop the include from here. Signed-off-by: Tom Rini <[email protected]>
2024-01-16cmd/command.c: constify "arg" argument of cmd_get_data_size()Rasmus Villemoes
This function obviously does not and must not modify "arg". Change the prototype to allow passing an argument of type "const char*" without requiring a cast. Signed-off-by: Rasmus Villemoes <[email protected]>
2023-12-13command: Introduce functions to obtain command argumentsSimon Glass
Add some functions which provide an argument to a command, or NULL if the argument does not exist. Use the same numbering as argv[] since it seems less confusing than the previous idea. Signed-off-by: Simon Glass <[email protected]> Suggested-by: Tom Rini <[email protected]>
2023-12-13treewide: Tidy up semicolon after command macrosSimon Glass
The U_BOOT_CMD_COMPLETE() macro has a semicolon at the end, perhaps inadvertently. Some code has taken advantage of this. Tidy this up by dropping the semicolon from the macro and adding it to macro invocations as required. Signed-off-by: Simon Glass <[email protected]> Reviewed-by: Tom Rini <[email protected]> Reviewed-by: Ilias Apalodimas <[email protected]>
2023-10-16command.h: Add a U_BOOT_LONGHELP macroTom Rini
In order to be able to discard unused long help texts without further linker lists, add a macro for defining the long help messages which uses __maybe_unused. This allows us to discard them as unreferenced as part of the link. Signed-off-by: Tom Rini <[email protected]> Reviewed-by: Simon Glass <[email protected]>
2023-10-11cli: Drop #ifdefs for CONFIG_AUTO_COMPLETE in cli_readlineSimon Glass
Use a static inline and adjust the logic to avoid the need for #ifdefs in cli_readline_into_buffer() Signed-off-by: Simon Glass <[email protected]>
2023-10-06command: Include a required header in command.hSimon Glass
This uses ARRAY_SIZE() but does not include the header file which declares it. Fix this, so that command.h can be included without common.h Signed-off-by: Simon Glass <[email protected]> Reviewed-by: Mattijs Korpershoek <[email protected]>
2023-09-14command: Remove unused NEEDS_MANUAL_RELOC code bitsMarek Vasut
The last user of the NEEDS_MANUAL_RELOC has been removed in commit 26af162ac8f8 ("arch: m68k: Implement relocation") Remove now unused NEEDS_MANUAL_RELOC code. Signed-off-by: Marek Vasut <[email protected]>
2023-03-30cli: run_commandf(): small fixupsEvgeny Bachinin
* vsnprintf() can truncate cmd, hence it makes no sense to launch such command (it's broken). Moreover, it's better to signalize to the caller about such case (for facilitating debugging or bug hunting). * Fix kernel-doc warnings: include/command.h:264: info: Scanning doc for run_commandf include/command.h:268: warning: contents before sections include/command.h:271: warning: No description found for return value of 'run_commandf' * Add printf-like format attribute to validate at compile-time the format string against parameters's type. * Fix compilation error in case of -Wall, -Werror, -Wextra: error: variable ā€˜i’ set but not used [-Werror=unused-but-set-variable] * Drop extra ret variable. Signed-off-by: Evgeny Bachinin <[email protected]> Reviewed-by: Simon Glass <[email protected]>
2023-03-03command: Don't allow commands in SPLSimon Glass
At present we compile commands into U-Boot SPL even though they cannot be used. This wastes space. Adjust the condition to avoid this. Signed-off-by: Simon Glass <[email protected]>
2023-01-20global: Finish CONFIG -> CFG migrationTom Rini
At this point, the remaining places where we have a symbol that is defined as CONFIG_... are in fairly odd locations. While as much dead code has been removed as possible, some of these locations are simply less obvious at first. In other cases, this code is used, but was defined in such a way as to have been missed by earlier checks. Perform a rename of all such remaining symbols to be CFG_... rather than CONFIG_... Signed-off-by: Tom Rini <[email protected]> Reviewed-by: Simon Glass <[email protected]>
2023-01-16image: Move common image code to image_board and commandSimon Glass
We should use the cmd/ directory for commands rather than for common code used elsewhere in U-Boot. Move the common 'source' code into image-board.c to achieve this. The image_source_script() function needs to call run_command_list() so seems to belong better in the command library. Move and rename it. Signed-off-by: Simon Glass <[email protected]>
2022-08-11Merge tag 'dm-pull-9aug22-take2' of ↵Tom Rini
https://source.denx.de/u-boot/custodians/u-boot-dm dtoc fixes with pylint, tests
2022-08-10boot: allow bootmeth-distro without CONFIG_NETJohn Keeping
Remove the dependency on CMD_PXE from BOOTMETH_DISTRO by introducing a new hidden kconfig symbol to control whether pxe_utils is compiled, allowing bootstd's distro method to be compiled without needing networking support enabled. Signed-off-by: John Keeping <[email protected]> Reviewed-by: Tom Rini <[email protected]> Reviewed-by: Simon Glass <[email protected]> Correct build errors when CMD_BOOTM is not enabled: Signed-off-by: Simon Glass <[email protected]>
2022-08-10cmd: inconsistent return type of command_process()Heinrich Schuchardt
The declarations in the header and in the implementation must match. Reported-by: Sergei Antonov <[email protected]> Signed-off-by: Heinrich Schuchardt <[email protected]> Reviewed-by: Simon Glass <[email protected]>
2022-07-26fdt: Start a test for the fdt commandSimon Glass
Add a basic test of the 'fdt addr' command, to kick things off. This includes a new convenience function to run a command from a printf() string. Signed-off-by: Simon Glass <[email protected]>
2022-01-19doc: replace @return by Return:Heinrich Schuchardt
Sphinx expects Return: and not @return to indicate a return value. find . -name '*.c' -exec \ sed -i 's/^\(\s\)\*\(\s*\)@return\(\s\)/\1*\2Return:\3/' {} \; find . -name '*.h' -exec \ sed -i 's/^\(\s\)\*\(\s*\)@return\(\s\)/\1*\2Return:\3/' {} \; Signed-off-by: Heinrich Schuchardt <[email protected]>
2021-11-28command: Use a constant pointer for the helpSimon Glass
This text should never change during execution, so it makes sense to use a const char * so that it can be declared as const in the code. Update struct cmd_tbl with a const char * pointer for 'help'. We cannot make usage const because of the bmode command, used on mx53ppd for example. Signed-off-by: Simon Glass <[email protected]> Reviewed-by: Jagan Teki <[email protected]> Reviewed-by: Heinrich Schuchardt <[email protected]>
2021-03-27command: Fix operation of !CONFIG_CMDLINESimon Glass
The U_BOOT_CMDREP_COMPLETE() macro produces a build error if CONFIG_CMDLINE is not enabled. Fix this by updating the macro to provide the 'repeatable' arugment in this case. Signed-off-by: Simon Glass <[email protected]>
2021-02-03cmd: pxe_utils: sysboot: Add zboot support to boot x86 Linux kernel imageKory Maincent
Add "zboot" command to the list of supported boot in the label_boot function. Signed-off-by: Kory Maincent <[email protected]> Reviewed-by: Simon Glass <[email protected]> Reviewed-by: Bin Meng <[email protected]> [bmeng: add component tags in the summary] Signed-off-by: Bin Meng <[email protected]>
2021-02-03command.h: Remove extern from the headerKory Maincent
Remove the extern of the header because they are useless. Signed-off-by: Kory Maincent <[email protected]> Reviewed-by: Bin Meng <[email protected]> Reviewed-by: Simon Glass <[email protected]> [bmeng: minor edit on the commit message] Signed-off-by: Bin Meng <[email protected]>
2020-12-01setexpr: Add some tests for buffer overflow and backrefSimon Glass
Add tests to check for buffer overflow using simple replacement as well as back references. At present these don't fully pass. Signed-off-by: Simon Glass <[email protected]>
2020-12-01command: Add constants for cmd_get_data_size string / errorSimon Glass
At present these values are open-coded in a few places. Add constants so the meaning is clear. Also add a comment to cmd_get_data_size() Signed-off-by: Simon Glass <[email protected]>
2020-05-18command: Remove the cmd_tbl_t typedefSimon Glass
We should not use typedefs in U-Boot. They cannot be used as forward declarations which means that header files must include the full header to access them. Drop the typedef and rename the struct to remove the _s suffix which is now not useful. This requires quite a few header-file additions. Signed-off-by: Simon Glass <[email protected]>
2019-12-02common: Move command functions out of common.hSimon Glass
Move these functions into the command.h header file which is a better fit. Signed-off-by: Simon Glass <[email protected]> Reviewed-by: Tom Rini <[email protected]>
2019-08-11env: Move env_set() to env.hSimon Glass
Move env_set() over to the new header file. Acked-by: Joe Hershberger <[email protected]> Signed-off-by: Simon Glass <[email protected]>
2019-06-14cmd: define CMD_DATA_SIZE when CONFIG_CMD_SETEXPR is selectedBartosz Golaszewski
The setexpr shell command calls cmd_get_data_size() which is only built when CMD_DATA_SIZE is defined. We need to define CMD_DATA_SIZE if CONFIG_CMD_SETEXPR is selected or the build will fail if no other command selecting this option is enabled. Signed-off-by: Bartosz Golaszewski <[email protected]>
2019-03-22cmd: set CONFIG_SYS_HELP_CMD_WIDTH = 10Heinrich Schuchardt
CONFIG_SYS_HELP_CMD_WIDTH is used to format the output of help without any arguments. CONFIG_SYS_HELP_CMD_WIDTH = 8 is too narrow to fit all our commands. Signed-off-by: Heinrich Schuchardt <[email protected]>
2019-02-25cmd: env: add "-e" option for handling UEFI variablesAKASHI Takahiro
"env [print|set] -e" allows for handling uefi variables without knowing details about mapping to corresponding u-boot variables. Signed-off-by: AKASHI Takahiro <[email protected]> Reviewed-by: Heinrich Schuchardt <[email protected]>
2019-01-15command: commands: Add macros to declare commands with subcmdsBoris Brezillon
Most cmd/xxx.c source files expose several commands through a single entry point. Some of them are doing the sub-command parsing manually in their do_<cmd>() function, others are declaring a table of sub-commands and then use find_cmd_tbl() to delegate the request to the sub command handler. In either case, the amount of code to do that is not negligible and repetitive, not to mention that almost no commands are implementing the auto-completion hook, which means most u-boot commands lack auto-completion. Provide several macros to easily define commands exposing sub-commands. Signed-off-by: Boris Brezillon <[email protected]> Reviewed-by: Tom Rini <[email protected]>
2019-01-15common: command: Rework the 'cmd is repeatable' logicBoris Brezillon
The repeatable property is currently attached to the main command and sub-commands have no way to change the repeatable value (the ->repeatable field in sub-command entries is ignored). Replace the ->repeatable field by an extended ->cmd() hook (called ->cmd_rep()) which takes a new int pointer to store the repeatable cap of the command being executed. With this trick, we can let sub-commands decide whether they are repeatable or not. We also patch mmc and dtimg who are testing the ->repeatable field directly (they now use cmd_is_repeatable() instead), and fix the help entry manually since it doesn't use the U_BOOT_CMD() macro. Signed-off-by: Boris Brezillon <[email protected]> Reviewed-by: Tom Rini <[email protected]>
2019-01-15common: command: Expose a generic helper to auto-complete sub commandsBoris Brezillon
Some commands have a table of sub-commands. With minor adjustments, complete_cmdv() is able to provide auto-completion for sub-commands (it's just about passing the table of commands instead of taking the global one). We rename this function into complete_subcmd() and implement complete_cmdv() as a wrapper around complete_subcmdv(). Signed-off-by: Boris Brezillon <[email protected]> Reviewed-by: Tom Rini <[email protected]>
2018-10-19common: command: fix typoHeinrich Schuchardt
%s/CMD_RET_SUCCESX/CMD_RET_SUCCESS/g Signed-off-by: Heinrich Schuchardt <[email protected]>
2018-07-19common: command: Handle USAGE failure separatelyMichal Simek
command_ret_t enum contains 3 return values but only two are handled now. Extend cmd_process_error() and handle CMD_RET_USAGE separately. These commands are affected by this change. cmd/demo.c cmd/efi.c cmd/gpio.c cmd/qfw.c cmd/x86/fsp.c test/dm/cmd_dm.c And scripts shouldn't be affected because return value is not 0. But every command implementation can choose what it is correct to pass. I would expect that RET_USAGE is called when parameters are not correctly passed (have incorrect value, missing parameters) and RET_FAILURE when correct parameters are passed but command fails. Signed-off-by: Michal Simek <[email protected]> Reviewed-by: Simon Glass <[email protected]>
2018-05-07SPDX: Convert all of our single license tags to Linux Kernel styleTom Rini
When U-Boot started using SPDX tags we were among the early adopters and there weren't a lot of other examples to borrow from. So we picked the area of the file that usually had a full license text and replaced it with an appropriate SPDX-License-Identifier: entry. Since then, the Linux Kernel has adopted SPDX tags and they place it as the very first line in a file (except where shebangs are used, then it's second line) and with slightly different comment styles than us. In part due to community overlap, in part due to better tag visibility and in part for other minor reasons, switch over to that style. This commit changes all instances where we have a single declared license in the tag as both the before and after are identical in tag contents. There's also a few places where I found we did not have a tag and have introduced one. Signed-off-by: Tom Rini <[email protected]>
2018-03-23arm64: zynqmp: Add support to load an app at EL1Nitin Jain
This patch is adding support to switch to EL1 while loading an EL1 application with u-boot running at EL above EL1 in aarch64 mode. Signed-off-by: Nitin Jain <[email protected]> Signed-off-by: Siva Durga Prasad Paladugu <[email protected]> Signed-off-by: Michal Simek <[email protected]>
2017-08-11Kconfig: Drop CONFIG_CMD_PORTIO and associated commandSimon Glass
This command is not used by any board. It also looks quite similar to the 'iod' and 'iow' commands which use the correct I/O macros. Drop it. Signed-off-by: Simon Glass <[email protected]> Reviewed-by: Bin Meng <[email protected]> Reviewed-by: Philipp Tomsich <[email protected]>
2016-04-01Drop command-processing code when CONFIG_CMDLINE is disabledSimon Glass
Command parsing and processing code is not needed when the command line is disabled. Remove this code in that case. Signed-off-by: Simon Glass <[email protected]> Reviewed-by: Tom Rini <[email protected]>
2016-03-22Allow command code to compile to nothingSimon Glass
When CONFIG_CMDLINE is disabled we need to remove all the command-line code. Most can be removed by dropping the appropriate linker lists from the images, but sub-commands must be dealt with specially. A simple mechanism is used to avoid 'unused static function' errors. Signed-off-by: Simon Glass <[email protected]> Reviewed-by: Tom Rini <[email protected]>
2016-01-13cmd_boot: Add a poweroff commandMichael van Slingerland
Add a 'poweroff' command to boot commands, this only gets enabled if the board Kconfig does a "select CMD_POWEROFF". Signed-off-by: Michael van Slingerland <[email protected]> [[email protected]: Make the cmd conditional on a CMD_POWEROFF Kconfig] Signed-off-by: Hans de Goede <[email protected]>
2015-12-07CONFIG_NEEDS_MANUAL_RELOC: Fix warnings when not setTom Rini
Now that we may compile (but not link) code calling fixup_cmdtable when this is not set, we need to always have the declaration available. We should also make sure that anyone calling the function includes <command.h> as that's where the function declaration is. Signed-off-by: Tom Rini <[email protected]>
2015-07-27pxe: add AArch64 image supportStephen Warren
The sysboot and pxe commands currently support either U-Boot formats or raw zImages. Add support for the AArch64 Linux port's native image format too. As with zImage support, there is no auto-detection of the native image format. Rather, if the image is auto-detected as a U-Boot format, U-Boot will try to interpret it as such. Otherwise, U-Boot will fall back to a raw/native image format, if one is enabled. My belief is that CONFIG_CMD_BOOTZ won't ever be enabled for any AArch64 port, hence there's never a need to differentiate between CONFIG_CMD_ _BOOTI and _BOOTZ at run-time; compile-time will do. Even if this isn't true, we want to prefer _BOOTI over _BOOTZ when defined, since _BOOTI is definitely the native format for AArch64. Change-Id: I83c5cc7566032afd72516de46f4e5eb7a780284a Signed-off-by: Stephen Warren <[email protected]> Signed-off-by: Tom Warren <[email protected]>
2014-10-27cli: hush: Adjust 'run' command to run each line of the env varSimon Glass
The run command treats each argument an an environment variable. It gets the value of each variable and executes it as a command. If an environment variable contains a newline and the hush cli is used, it is supposed to execute each line one after the other. Normally a newline signals to hush to exit - this is used in normal command line entry - after a command is entered we want to return to allow the user to enter the next one. But environment variables obviously need to execute to completion. Add a special case for the execution of environment variables which continues when a newline is seen, and add a few tests to check this behaviour. Note: it's not impossible that this may cause regressions in other areas. I can't think of a case but with any change of behaviour with limited test coverage there is always a risk. From what I can tell this behaviour has been around since at least U-Boot 2011.03, although this pre-dates sandbox and I have not tested it on real hardware. Reported-by: Wolfgang Denk <[email protected]> Signed-off-by: Simon Glass <[email protected]>
2014-06-19Avoid including config.h in command.hSimon Glass
This is not necessary and prevents using this header when building tools. Signed-off-by: Simon Glass <[email protected]>
2014-03-04Add cmd_process_error() to report and process errorsSimon Glass
U-Boot now uses errors defined in include/errno.h which are negative integers. Commands which fail need to report the error and return 1 to indicate failure. Add this functionality in cmd_process_error(). For now this merely reports the error number. It would be possible also to produce a helpful error message by storing the error strings in U-Boot. Signed-off-by: Simon Glass <[email protected]>
2013-07-24Add GPL-2.0+ SPDX-License-Identifier to source filesWolfgang Denk
Signed-off-by: Wolfgang Denk <[email protected]> [trini: Fixup common/cmd_io.c] Signed-off-by: Tom Rini <[email protected]>
2013-06-24bootz: un-staticize do_bootzRob Herring
Make do_bootz available for other functions like do_bootm is. Signed-off-by: Rob Herring <[email protected]>
2013-03-12Refactor linker-generated arraysAlbert ARIBAUD
Refactor linker-generated array code so that symbols which were previously linker-generated are now compiler- generated. This causes relocation records of type R_ARM_ABS32 to become R_ARM_RELATIVE, which makes code which uses LGA able to run before relocation as well as after. Note: this affects more than ARM targets, as linker- lists span possibly all target architectures, notably PowerPC. Conflicts: arch/arm/cpu/arm926ejs/mxs/u-boot-spl.lds arch/arm/cpu/arm926ejs/spear/u-boot-spl.lds arch/arm/cpu/armv7/omap-common/u-boot-spl.lds board/ait/cam_enc_4xx/u-boot-spl.lds board/davinci/da8xxevm/u-boot-spl-da850evm.lds board/davinci/da8xxevm/u-boot-spl-hawk.lds board/vpac270/u-boot-spl.lds Signed-off-by: Albert ARIBAUD <[email protected]>
2013-02-04cmd_time: merge run_command_and_time_it with cmd_processRichard Genoud
As far as every arch has a get_timer function, run_command_and_time_it code can now disappear. Signed-off-by: Richard Genoud <[email protected]> Acked-By: Che-Liang Chiou <[email protected]> [trini: s/ulong/unsigned long/ in command.h portion] Signed-off-by: Tom Rini <[email protected]>
2012-12-11Add console command to access io space registersVadim Bendebury
Provide u-boot console functions to access IO space registers. A no thrills implementation, accessing one register at a time. For example: boot > iod 80 0080: 00000094 boot > iod.w 80 0080: 0094 boot > iod.b 80 0080: 94 boot > iow.b 0x80 12 boot > iod 0x80 0080: 00000012 Signed-off-by: Vadim Bendebury <[email protected]> Signed-off-by: Simon Glass <[email protected]>