History log of /u-boot/include/cli.h
Revision Date Author Comments
(<<< Hide modified files)
(Show modified files >>>)
# 39ee3216 01-Oct-2023 Simon Glass <sjg@chromium.org>

cli: Add a function to set up a new cread

Create a init function so that it is easy to use command-line reading.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 3b487bf5 01-Oct-2023 Simon Glass <sjg@chromium.org>

cli: Allow command completion to be disabled

When inputting text outside the command line we don't want to use tab
for command completion. Add an option to control this.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 8fc041fe 01-Oct-2023 Simon Glass <sjg@chromium.org>

cli: Allow history to be disabled

When inputting text outside the command line we don't want history to be
accessible. Add an option to control this.

Signed-off-by: Simon Glass <sjg@chromium.org>

# e5509ce8 01-Oct-2023 Simon Glass <sjg@chromium.org>

cli: Create a function to process characters

Move most of the inner loop from cread_line() into a new function. This
will allow using it from other code.

This involves adding a few more members to the state struct.

Signed-off-by: Simon Glass <sjg@chromium.org>

# be5c2edd 01-Oct-2023 Simon Glass <sjg@chromium.org>

cli: Convert cread_line() to use a struct for the main vars

We want to reuse the editing code elsewhere. As a first step, move the
common variables into a struct. This will allow us to eventually put the
contents of the inner loop in a function, so it can be called from
elsewhere.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 33eb0b9e 01-Oct-2023 Simon Glass <sjg@chromium.org>

cli: Add a command to show cmdline history

There is a function for this but it is never used. Showing the history is
a useful feature, so add a new 'history' command.

Signed-off-by: Simon Glass <sjg@chromium.org>

# be0169f0 27-Mar-2023 Simon Glass <sjg@chromium.org>

cli: Correct handling of invalid escape sequences in cread_line()

The second call to cli_ch_process() is in the wrong place, meaning that
the one of the characters of an invalid escape sequence is swallowed
instead of being returned.

Fix the bug and add a test to cover this.

This behaviour matches that of the code before cli_getch() was
introduced. This was verified on the commit before b08e9d4b66 i.e.:

7d850f85aad ("sandbox: Enable mmc command and legacy images")

Signed-off-by: Simon Glass <sjg@chromium.org>
Reported-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 32bab0ea 06-Jan-2023 Simon Glass <sjg@chromium.org>

menu: Make use of CLI character processing

Avoid duplicating some of the escape-sequence processing here and use the
CLI function instead.

Signed-off-by: Simon Glass <sjg@chromium.org>

# b08e9d4b 06-Jan-2023 Simon Glass <sjg@chromium.org>

cli: Move readline character-processing to a state machine

The current cread_line() function is very long. It handles the escape
processing inline. The menu command does similar processing but at the
character level, so there is some duplication.

Split the character processing into a new function cli_ch_process() which
processes individual characters and returns the resulting input character,
taking account of escape sequences. It requires the caller to set up and
maintain its state.

Update cread_line() to use this new function.

The only intended functional change is that an invalid escape sequence
does not add invalid/control characters into the input buffer, but instead
discards these.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 185f812c 19-Jan-2022 Heinrich Schuchardt <xypron.glpk@gmx.de>

doc: replace @return by Return:

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 <heinrich.schuchardt@canonical.com>

# 1a62d64c 05-Nov-2020 Simon Glass <sjg@chromium.org>

cli: Support macro processing with a fixed-size buffer

At present cli_simple_process_macros() requires that the caller provide
an output buffer that is exactly CONFIG_SYS_CBSIZE bytes in length. This
makes sense since it is designed to be used from the command line. But we
also want to use it for bootargs substitution.

Update the function to allow the caller to specify the buffer size. Also
return an error if the buffer is exhausted. The caller can ignore that if
preferred.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 83d290c5 06-May-2018 Tom Rini <trini@konsulko.com>

SPDX: Convert all of our single license tags to Linux Kernel style

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 <trini@konsulko.com>

# 0f925822 11-Aug-2015 Masahiro Yamada <masahiroy@kernel.org>

of: clean up OF_CONTROL ifdef conditionals

We have flipped CONFIG_SPL_DISABLE_OF_CONTROL. We have cleansing
devices, $(SPL_) and CONFIG_IS_ENABLED(), so we are ready to clear
away the ugly logic in include/fdtdec.h:

#ifdef CONFIG_OF_CONTROL
# if defined(CONFIG_SPL_BUILD) && !defined(SPL_OF_CONTROL)
# define OF_CONTROL 0
# else
# define OF_CONTROL 1
# endif
#else
# define OF_CONTROL 0
#endif

Now CONFIG_IS_ENABLED(OF_CONTROL) is the substitute. It refers to
CONFIG_OF_CONTROL for U-boot proper and CONFIG_SPL_OF_CONTROL for
SPL.

Also, we no longer have to cancel CONFIG_OF_CONTROL in
include/config_uncmd_spl.h and scripts/Makefile.spl.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Reviewed-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Acked-by: Linus Walleij <linus.walleij@linaro.org>

# a06be2d0 06-Aug-2014 Hans de Goede <hdegoede@redhat.com>

cli: Export cli_simple_process_macros for use outside of cli_simple

Signed-off-by: Hans de Goede <hdegoede@redhat.com>

# affb2156 10-Apr-2014 Simon Glass <sjg@chromium.org>

main: Make the execution path a little clearer in main.c

bootdelay_process() never returns in some circumstances, whichs makes the
control flow confusing. Change it so that the decision about how to execute
the boot command is made in the main_loop() code, so it is easier to follow.
Move CLI stuff to cli.c.

Signed-off-by: Simon Glass <sjg@chromium.org>

# c1bb2cd0 10-Apr-2014 Simon Glass <sjg@chromium.org>

main: Hide the hush/simple details inside cli.c

Move these details from main (which doesn't care which parser is used) to
cli.c where they belong.

Signed-off-by: Simon Glass <sjg@chromium.org>

# b26440f1 10-Apr-2014 Simon Glass <sjg@chromium.org>

Rename bootretry functions and remove #ifdefs

Add a bootretry_ prefix to these two functions, and remove the need for
the #ifdef around everything (it moves to the Makefile).

Signed-off-by: Simon Glass <sjg@chromium.org>

# e1bf824d 10-Apr-2014 Simon Glass <sjg@chromium.org>

Add cli_ prefix to readline functions

This makes it clear where the code resides.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 6493ccc7 10-Apr-2014 Simon Glass <sjg@chromium.org>

Split out simple parser and readline into separate files

It doesn't make sense to have the simple parser and the readline code
all in main. Split them out into separate files.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 18d66533 10-Apr-2014 Simon Glass <sjg@chromium.org>

move CLI prototypes to cli.h and add comments

Move the CLI prototypes from common.h to cli.h as part of an effort to
reduce the size of common.h.

Signed-off-by: Simon Glass <sjg@chromium.org>

# be0169f0 27-Mar-2023 Simon Glass <sjg@chromium.org>

cli: Correct handling of invalid escape sequences in cread_line()

The second call to cli_ch_process() is in the wrong place, meaning that
the one of the characters of an invalid escape sequence is swallowed
instead of being returned.

Fix the bug and add a test to cover this.

This behaviour matches that of the code before cli_getch() was
introduced. This was verified on the commit before b08e9d4b66 i.e.:

7d850f85aad ("sandbox: Enable mmc command and legacy images")

Signed-off-by: Simon Glass <sjg@chromium.org>
Reported-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 32bab0ea 06-Jan-2023 Simon Glass <sjg@chromium.org>

menu: Make use of CLI character processing

Avoid duplicating some of the escape-sequence processing here and use the
CLI function instead.

Signed-off-by: Simon Glass <sjg@chromium.org>

# b08e9d4b 06-Jan-2023 Simon Glass <sjg@chromium.org>

cli: Move readline character-processing to a state machine

The current cread_line() function is very long. It handles the escape
processing inline. The menu command does similar processing but at the
character level, so there is some duplication.

Split the character processing into a new function cli_ch_process() which
processes individual characters and returns the resulting input character,
taking account of escape sequences. It requires the caller to set up and
maintain its state.

Update cread_line() to use this new function.

The only intended functional change is that an invalid escape sequence
does not add invalid/control characters into the input buffer, but instead
discards these.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 185f812c 19-Jan-2022 Heinrich Schuchardt <xypron.glpk@gmx.de>

doc: replace @return by Return:

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 <heinrich.schuchardt@canonical.com>

# 1a62d64c 05-Nov-2020 Simon Glass <sjg@chromium.org>

cli: Support macro processing with a fixed-size buffer

At present cli_simple_process_macros() requires that the caller provide
an output buffer that is exactly CONFIG_SYS_CBSIZE bytes in length. This
makes sense since it is designed to be used from the command line. But we
also want to use it for bootargs substitution.

Update the function to allow the caller to specify the buffer size. Also
return an error if the buffer is exhausted. The caller can ignore that if
preferred.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 83d290c5 06-May-2018 Tom Rini <trini@konsulko.com>

SPDX: Convert all of our single license tags to Linux Kernel style

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 <trini@konsulko.com>

# 0f925822 11-Aug-2015 Masahiro Yamada <yamada.masahiro@socionext.com>

of: clean up OF_CONTROL ifdef conditionals

We have flipped CONFIG_SPL_DISABLE_OF_CONTROL. We have cleansing
devices, $(SPL_) and CONFIG_IS_ENABLED(), so we are ready to clear
away the ugly logic in include/fdtdec.h:

#ifdef CONFIG_OF_CONTROL
# if defined(CONFIG_SPL_BUILD) && !defined(SPL_OF_CONTROL)
# define OF_CONTROL 0
# else
# define OF_CONTROL 1
# endif
#else
# define OF_CONTROL 0
#endif

Now CONFIG_IS_ENABLED(OF_CONTROL) is the substitute. It refers to
CONFIG_OF_CONTROL for U-boot proper and CONFIG_SPL_OF_CONTROL for
SPL.

Also, we no longer have to cancel CONFIG_OF_CONTROL in
include/config_uncmd_spl.h and scripts/Makefile.spl.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Reviewed-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Acked-by: Linus Walleij <linus.walleij@linaro.org>

# a06be2d0 06-Aug-2014 Hans de Goede <hdegoede@redhat.com>

cli: Export cli_simple_process_macros for use outside of cli_simple

Signed-off-by: Hans de Goede <hdegoede@redhat.com>

# affb2156 10-Apr-2014 Simon Glass <sjg@chromium.org>

main: Make the execution path a little clearer in main.c

bootdelay_process() never returns in some circumstances, whichs makes the
control flow confusing. Change it so that the decision about how to execute
the boot command is made in the main_loop() code, so it is easier to follow.
Move CLI stuff to cli.c.

Signed-off-by: Simon Glass <sjg@chromium.org>

# c1bb2cd0 10-Apr-2014 Simon Glass <sjg@chromium.org>

main: Hide the hush/simple details inside cli.c

Move these details from main (which doesn't care which parser is used) to
cli.c where they belong.

Signed-off-by: Simon Glass <sjg@chromium.org>

# b26440f1 10-Apr-2014 Simon Glass <sjg@chromium.org>

Rename bootretry functions and remove #ifdefs

Add a bootretry_ prefix to these two functions, and remove the need for
the #ifdef around everything (it moves to the Makefile).

Signed-off-by: Simon Glass <sjg@chromium.org>

# e1bf824d 10-Apr-2014 Simon Glass <sjg@chromium.org>

Add cli_ prefix to readline functions

This makes it clear where the code resides.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 6493ccc7 10-Apr-2014 Simon Glass <sjg@chromium.org>

Split out simple parser and readline into separate files

It doesn't make sense to have the simple parser and the readline code
all in main. Split them out into separate files.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 18d66533 10-Apr-2014 Simon Glass <sjg@chromium.org>

move CLI prototypes to cli.h and add comments

Move the CLI prototypes from common.h to cli.h as part of an effort to
reduce the size of common.h.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 32bab0ea 06-Jan-2023 Simon Glass <sjg@chromium.org>

menu: Make use of CLI character processing

Avoid duplicating some of the escape-sequence processing here and use the
CLI function instead.

Signed-off-by: Simon Glass <sjg@chromium.org>

# b08e9d4b 06-Jan-2023 Simon Glass <sjg@chromium.org>

cli: Move readline character-processing to a state machine

The current cread_line() function is very long. It handles the escape
processing inline. The menu command does similar processing but at the
character level, so there is some duplication.

Split the character processing into a new function cli_ch_process() which
processes individual characters and returns the resulting input character,
taking account of escape sequences. It requires the caller to set up and
maintain its state.

Update cread_line() to use this new function.

The only intended functional change is that an invalid escape sequence
does not add invalid/control characters into the input buffer, but instead
discards these.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 185f812c 19-Jan-2022 Heinrich Schuchardt <xypron.glpk@gmx.de>

doc: replace @return by Return:

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 <heinrich.schuchardt@canonical.com>

# 1a62d64c 05-Nov-2020 Simon Glass <sjg@chromium.org>

cli: Support macro processing with a fixed-size buffer

At present cli_simple_process_macros() requires that the caller provide
an output buffer that is exactly CONFIG_SYS_CBSIZE bytes in length. This
makes sense since it is designed to be used from the command line. But we
also want to use it for bootargs substitution.

Update the function to allow the caller to specify the buffer size. Also
return an error if the buffer is exhausted. The caller can ignore that if
preferred.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 83d290c5 06-May-2018 Tom Rini <trini@konsulko.com>

SPDX: Convert all of our single license tags to Linux Kernel style

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 <trini@konsulko.com>

# 0f925822 11-Aug-2015 Masahiro Yamada <yamada.masahiro@socionext.com>

of: clean up OF_CONTROL ifdef conditionals

We have flipped CONFIG_SPL_DISABLE_OF_CONTROL. We have cleansing
devices, $(SPL_) and CONFIG_IS_ENABLED(), so we are ready to clear
away the ugly logic in include/fdtdec.h:

#ifdef CONFIG_OF_CONTROL
# if defined(CONFIG_SPL_BUILD) && !defined(SPL_OF_CONTROL)
# define OF_CONTROL 0
# else
# define OF_CONTROL 1
# endif
#else
# define OF_CONTROL 0
#endif

Now CONFIG_IS_ENABLED(OF_CONTROL) is the substitute. It refers to
CONFIG_OF_CONTROL for U-boot proper and CONFIG_SPL_OF_CONTROL for
SPL.

Also, we no longer have to cancel CONFIG_OF_CONTROL in
include/config_uncmd_spl.h and scripts/Makefile.spl.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Reviewed-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Acked-by: Linus Walleij <linus.walleij@linaro.org>

# a06be2d0 06-Aug-2014 Hans de Goede <hdegoede@redhat.com>

cli: Export cli_simple_process_macros for use outside of cli_simple

Signed-off-by: Hans de Goede <hdegoede@redhat.com>

# affb2156 10-Apr-2014 Simon Glass <sjg@chromium.org>

main: Make the execution path a little clearer in main.c

bootdelay_process() never returns in some circumstances, whichs makes the
control flow confusing. Change it so that the decision about how to execute
the boot command is made in the main_loop() code, so it is easier to follow.
Move CLI stuff to cli.c.

Signed-off-by: Simon Glass <sjg@chromium.org>

# c1bb2cd0 10-Apr-2014 Simon Glass <sjg@chromium.org>

main: Hide the hush/simple details inside cli.c

Move these details from main (which doesn't care which parser is used) to
cli.c where they belong.

Signed-off-by: Simon Glass <sjg@chromium.org>

# b26440f1 10-Apr-2014 Simon Glass <sjg@chromium.org>

Rename bootretry functions and remove #ifdefs

Add a bootretry_ prefix to these two functions, and remove the need for
the #ifdef around everything (it moves to the Makefile).

Signed-off-by: Simon Glass <sjg@chromium.org>

# e1bf824d 10-Apr-2014 Simon Glass <sjg@chromium.org>

Add cli_ prefix to readline functions

This makes it clear where the code resides.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 6493ccc7 10-Apr-2014 Simon Glass <sjg@chromium.org>

Split out simple parser and readline into separate files

It doesn't make sense to have the simple parser and the readline code
all in main. Split them out into separate files.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 18d66533 10-Apr-2014 Simon Glass <sjg@chromium.org>

move CLI prototypes to cli.h and add comments

Move the CLI prototypes from common.h to cli.h as part of an effort to
reduce the size of common.h.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 185f812c 19-Jan-2022 Heinrich Schuchardt <xypron.glpk@gmx.de>

doc: replace @return by Return:

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 <heinrich.schuchardt@canonical.com>

# 1a62d64c 05-Nov-2020 Simon Glass <sjg@chromium.org>

cli: Support macro processing with a fixed-size buffer

At present cli_simple_process_macros() requires that the caller provide
an output buffer that is exactly CONFIG_SYS_CBSIZE bytes in length. This
makes sense since it is designed to be used from the command line. But we
also want to use it for bootargs substitution.

Update the function to allow the caller to specify the buffer size. Also
return an error if the buffer is exhausted. The caller can ignore that if
preferred.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 83d290c5 06-May-2018 Tom Rini <trini@konsulko.com>

SPDX: Convert all of our single license tags to Linux Kernel style

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 <trini@konsulko.com>

# 0f925822 11-Aug-2015 Masahiro Yamada <yamada.masahiro@socionext.com>

of: clean up OF_CONTROL ifdef conditionals

We have flipped CONFIG_SPL_DISABLE_OF_CONTROL. We have cleansing
devices, $(SPL_) and CONFIG_IS_ENABLED(), so we are ready to clear
away the ugly logic in include/fdtdec.h:

#ifdef CONFIG_OF_CONTROL
# if defined(CONFIG_SPL_BUILD) && !defined(SPL_OF_CONTROL)
# define OF_CONTROL 0
# else
# define OF_CONTROL 1
# endif
#else
# define OF_CONTROL 0
#endif

Now CONFIG_IS_ENABLED(OF_CONTROL) is the substitute. It refers to
CONFIG_OF_CONTROL for U-boot proper and CONFIG_SPL_OF_CONTROL for
SPL.

Also, we no longer have to cancel CONFIG_OF_CONTROL in
include/config_uncmd_spl.h and scripts/Makefile.spl.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Reviewed-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Acked-by: Linus Walleij <linus.walleij@linaro.org>

# a06be2d0 06-Aug-2014 Hans de Goede <hdegoede@redhat.com>

cli: Export cli_simple_process_macros for use outside of cli_simple

Signed-off-by: Hans de Goede <hdegoede@redhat.com>

# affb2156 10-Apr-2014 Simon Glass <sjg@chromium.org>

main: Make the execution path a little clearer in main.c

bootdelay_process() never returns in some circumstances, whichs makes the
control flow confusing. Change it so that the decision about how to execute
the boot command is made in the main_loop() code, so it is easier to follow.
Move CLI stuff to cli.c.

Signed-off-by: Simon Glass <sjg@chromium.org>

# c1bb2cd0 10-Apr-2014 Simon Glass <sjg@chromium.org>

main: Hide the hush/simple details inside cli.c

Move these details from main (which doesn't care which parser is used) to
cli.c where they belong.

Signed-off-by: Simon Glass <sjg@chromium.org>

# b26440f1 10-Apr-2014 Simon Glass <sjg@chromium.org>

Rename bootretry functions and remove #ifdefs

Add a bootretry_ prefix to these two functions, and remove the need for
the #ifdef around everything (it moves to the Makefile).

Signed-off-by: Simon Glass <sjg@chromium.org>

# e1bf824d 10-Apr-2014 Simon Glass <sjg@chromium.org>

Add cli_ prefix to readline functions

This makes it clear where the code resides.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 6493ccc7 10-Apr-2014 Simon Glass <sjg@chromium.org>

Split out simple parser and readline into separate files

It doesn't make sense to have the simple parser and the readline code
all in main. Split them out into separate files.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 18d66533 10-Apr-2014 Simon Glass <sjg@chromium.org>

move CLI prototypes to cli.h and add comments

Move the CLI prototypes from common.h to cli.h as part of an effort to
reduce the size of common.h.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 1a62d64c 05-Nov-2020 Simon Glass <sjg@chromium.org>

cli: Support macro processing with a fixed-size buffer

At present cli_simple_process_macros() requires that the caller provide
an output buffer that is exactly CONFIG_SYS_CBSIZE bytes in length. This
makes sense since it is designed to be used from the command line. But we
also want to use it for bootargs substitution.

Update the function to allow the caller to specify the buffer size. Also
return an error if the buffer is exhausted. The caller can ignore that if
preferred.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 83d290c5 06-May-2018 Tom Rini <trini@konsulko.com>

SPDX: Convert all of our single license tags to Linux Kernel style

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 <trini@konsulko.com>

# 0f925822 11-Aug-2015 Masahiro Yamada <yamada.masahiro@socionext.com>

of: clean up OF_CONTROL ifdef conditionals

We have flipped CONFIG_SPL_DISABLE_OF_CONTROL. We have cleansing
devices, $(SPL_) and CONFIG_IS_ENABLED(), so we are ready to clear
away the ugly logic in include/fdtdec.h:

#ifdef CONFIG_OF_CONTROL
# if defined(CONFIG_SPL_BUILD) && !defined(SPL_OF_CONTROL)
# define OF_CONTROL 0
# else
# define OF_CONTROL 1
# endif
#else
# define OF_CONTROL 0
#endif

Now CONFIG_IS_ENABLED(OF_CONTROL) is the substitute. It refers to
CONFIG_OF_CONTROL for U-boot proper and CONFIG_SPL_OF_CONTROL for
SPL.

Also, we no longer have to cancel CONFIG_OF_CONTROL in
include/config_uncmd_spl.h and scripts/Makefile.spl.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Reviewed-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Acked-by: Linus Walleij <linus.walleij@linaro.org>

# a06be2d0 06-Aug-2014 Hans de Goede <hdegoede@redhat.com>

cli: Export cli_simple_process_macros for use outside of cli_simple

Signed-off-by: Hans de Goede <hdegoede@redhat.com>

# affb2156 10-Apr-2014 Simon Glass <sjg@chromium.org>

main: Make the execution path a little clearer in main.c

bootdelay_process() never returns in some circumstances, whichs makes the
control flow confusing. Change it so that the decision about how to execute
the boot command is made in the main_loop() code, so it is easier to follow.
Move CLI stuff to cli.c.

Signed-off-by: Simon Glass <sjg@chromium.org>

# c1bb2cd0 10-Apr-2014 Simon Glass <sjg@chromium.org>

main: Hide the hush/simple details inside cli.c

Move these details from main (which doesn't care which parser is used) to
cli.c where they belong.

Signed-off-by: Simon Glass <sjg@chromium.org>

# b26440f1 10-Apr-2014 Simon Glass <sjg@chromium.org>

Rename bootretry functions and remove #ifdefs

Add a bootretry_ prefix to these two functions, and remove the need for
the #ifdef around everything (it moves to the Makefile).

Signed-off-by: Simon Glass <sjg@chromium.org>

# e1bf824d 10-Apr-2014 Simon Glass <sjg@chromium.org>

Add cli_ prefix to readline functions

This makes it clear where the code resides.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 6493ccc7 10-Apr-2014 Simon Glass <sjg@chromium.org>

Split out simple parser and readline into separate files

It doesn't make sense to have the simple parser and the readline code
all in main. Split them out into separate files.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 18d66533 10-Apr-2014 Simon Glass <sjg@chromium.org>

move CLI prototypes to cli.h and add comments

Move the CLI prototypes from common.h to cli.h as part of an effort to
reduce the size of common.h.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 83d290c5 06-May-2018 Tom Rini <trini@konsulko.com>

SPDX: Convert all of our single license tags to Linux Kernel style

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 <trini@konsulko.com>


# 0f925822 11-Aug-2015 Masahiro Yamada <yamada.masahiro@socionext.com>

of: clean up OF_CONTROL ifdef conditionals

We have flipped CONFIG_SPL_DISABLE_OF_CONTROL. We have cleansing
devices, $(SPL_) and CONFIG_IS_ENABLED(), so we are ready to clear
away the ugly logic in include/fdtdec.h:

#ifdef CONFIG_OF_CONTROL
# if defined(CONFIG_SPL_BUILD) && !defined(SPL_OF_CONTROL)
# define OF_CONTROL 0
# else
# define OF_CONTROL 1
# endif
#else
# define OF_CONTROL 0
#endif

Now CONFIG_IS_ENABLED(OF_CONTROL) is the substitute. It refers to
CONFIG_OF_CONTROL for U-boot proper and CONFIG_SPL_OF_CONTROL for
SPL.

Also, we no longer have to cancel CONFIG_OF_CONTROL in
include/config_uncmd_spl.h and scripts/Makefile.spl.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Reviewed-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Acked-by: Linus Walleij <linus.walleij@linaro.org>


# a06be2d0 06-Aug-2014 Hans de Goede <hdegoede@redhat.com>

cli: Export cli_simple_process_macros for use outside of cli_simple

Signed-off-by: Hans de Goede <hdegoede@redhat.com>


# affb2156 10-Apr-2014 Simon Glass <sjg@chromium.org>

main: Make the execution path a little clearer in main.c

bootdelay_process() never returns in some circumstances, whichs makes the
control flow confusing. Change it so that the decision about how to execute
the boot command is made in the main_loop() code, so it is easier to follow.
Move CLI stuff to cli.c.

Signed-off-by: Simon Glass <sjg@chromium.org>


# c1bb2cd0 10-Apr-2014 Simon Glass <sjg@chromium.org>

main: Hide the hush/simple details inside cli.c

Move these details from main (which doesn't care which parser is used) to
cli.c where they belong.

Signed-off-by: Simon Glass <sjg@chromium.org>


# b26440f1 10-Apr-2014 Simon Glass <sjg@chromium.org>

Rename bootretry functions and remove #ifdefs

Add a bootretry_ prefix to these two functions, and remove the need for
the #ifdef around everything (it moves to the Makefile).

Signed-off-by: Simon Glass <sjg@chromium.org>


# e1bf824d 10-Apr-2014 Simon Glass <sjg@chromium.org>

Add cli_ prefix to readline functions

This makes it clear where the code resides.

Signed-off-by: Simon Glass <sjg@chromium.org>


# 6493ccc7 10-Apr-2014 Simon Glass <sjg@chromium.org>

Split out simple parser and readline into separate files

It doesn't make sense to have the simple parser and the readline code
all in main. Split them out into separate files.

Signed-off-by: Simon Glass <sjg@chromium.org>


# 18d66533 10-Apr-2014 Simon Glass <sjg@chromium.org>

move CLI prototypes to cli.h and add comments

Move the CLI prototypes from common.h to cli.h as part of an effort to
reduce the size of common.h.

Signed-off-by: Simon Glass <sjg@chromium.org>