History log of /u-boot/include/bootm.h
Revision Date Author Comments
(<<< Hide modified files)
(Show modified files >>>)
# cdd20e3f 18-Apr-2024 Tom Rini <trini@konsulko.com>

Revert "Merge patch series "pxe: Allow extlinux booting without CMDLINE enabled""

As reported by Jonas Karlman this series breaks booting on some AArch64
platforms with common use cases. For now the best path forward is to
revert the series.

This reverts commit 777c28460947371ada40868dc994dfe8537d7115, reversing
changes made to ab3453e7b12daef47b9e91da2a2a3d48615dc6fc.

Link: https://lore.kernel.org/u-boot/50dfa3d6-a1ca-4492-a3fc-8d8c56b40b43@kwiboo.se/
Signed-off-by: Tom Rini <trini@konsulko.com>

# 777c2846 10-Apr-2024 Tom Rini <trini@konsulko.com>

Merge patch series "pxe: Allow extlinux booting without CMDLINE enabled"

Simon Glass <sjg@chromium.org> says:

This series is the culmanation of the current line of refactoring
series. It adjusts pxe to call the booting functionality directly
rather than going through the command-line interface.

With this is is possible to boot using the extlinux bootmeth without
the command line enabled.

It also updates fastboot to do a similar thing.


# 26736347 14-Dec-2023 Simon Glass <sjg@chromium.org>

bootm: Make cmdline optional with bootm_boot_start()

Allow the default command line to be used when booting the OS. This is
needed by fastboot.

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

# ab3453e7 10-Apr-2024 Tom Rini <trini@konsulko.com>

Merge patch series "Complete decoupling of zboot logic from commands"

Simon Glass <sjg@chromium.org> says:

This series refactors the zboot code to allow it to be used with
CONFIG_COMMAND disabled.

A new zboot_run() function is used to boot a zimage.


# 8d24535e 03-Dec-2023 Simon Glass <sjg@chromium.org>

x86: zboot: Tidy up the comment for zboot_run()

The current use case (ChromeOS) is the uncommon case. Document how this
function is more normally used, where base is 0 and cmdline is NULL

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

# d2c485a0 03-Dec-2023 Simon Glass <sjg@chromium.org>

x86: zboot: Rename zboot_start() to zboot_run()

The term 'start' is used withint bootm and zboot to indicate the first
phase of booting an image.

Since zboot_start() does the whole boot, rename it to zboot_run() to
align with bootm_run() etc.

Fix a log message while we are here.

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

# d37086a9 15-Dec-2023 Simon Glass <sjg@chromium.org>

bootm: Create a new boot_run() function to handle booting

Create a common function used by the three existing bootz/i/m_run()
functions, to reduce duplicated code.

Signed-off-by: Simon Glass <sjg@chromium.org>
Suggested-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Tom Rini <trini@konsulko.com>

# e7683c36 15-Dec-2023 Simon Glass <sjg@chromium.org>

bootm: Create a function to run through the booti states

In a few places, the booti command is used to handle a boot. We want
these to be done without needing CONFIG_CMDLINE, so add a new
booti_run() function to handle this.

So far this is not used.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@konsulko.com>

# 3405c9b6 15-Dec-2023 Simon Glass <sjg@chromium.org>

bootm: Create a function to run through the bootz states

In a few places, the bootz command is used to handle a boot. We want
these to be done without needing CONFIG_CMDLINE, so add a new
bootz_run() function to handle this.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@konsulko.com>

# e1a24c02 15-Dec-2023 Simon Glass <sjg@chromium.org>

bootm: Create a function to run through the bootm states

In quite a few places, the bootm command is used to handle a boot. We
want these to be done without needing CONFIG_CMDLINE, so add a new
bootm_run() function to handle this.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@konsulko.com>

# 725ddf1f 15-Dec-2023 Simon Glass <sjg@chromium.org>

bootm: Tidy up boot_selected_os()

Use struct bootm_info with this function, to avoiding needing to
create a new one.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@konsulko.com>

# b5d397f4 15-Dec-2023 Simon Glass <sjg@chromium.org>

bootm: Rename do_bootm_states() to bootm_run_states()

Rename the function to bootm_run_states() to better indicate ts
purpose. The 'do_' prefix is used to indicate a command processor,
which this is now not.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@konsulko.com>

# a6c49161 15-Dec-2023 Simon Glass <sjg@chromium.org>

bootm: Drop arguments from do_bootm_states()

Use the bootm_info struct to hold the information required by bootm.

Now that none of the functions called from do_bootm_states() needs an
argv[] list, change the arguments of do_bootm_states() as well. Take
care to use the same value for boot_progress even though it is a little
inconsistent.

For booti make sure it only uses argv[] and argc at the top of the
function, so we can eventually refactor to remove these parameters.

With bootm, some OSes need access to the arguments provided to the
command, so set these up in the bootm_info struct, for bootm only.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@konsulko.com>

# e370e3df 15-Dec-2023 Simon Glass <sjg@chromium.org>

bootm: Move do_bootm_states() comment to header file

This is an exported function, so move the function comment to the
bootm.h header file.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
Reviewed-by: Tom Rini <trini@konsulko.com>

# c2211ff6 15-Dec-2023 Simon Glass <sjg@chromium.org>

bootm: Add more fields to bootm_info

Add fields for the three bootm parameters and other things needed for
booting. Also add a helper to set up the struct correctly.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@konsulko.com>

# a48336e5 15-Dec-2023 Simon Glass <sjg@chromium.org>

bootm: Adjust arguments of boot_os_fn

Adjust boot_os_fn to use struct bootm_info instead of the separate
argc, argv and image parameters. Update the handlers accordingly. Few
of the functions make use of the arguments, so this improves code size
slightly.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@konsulko.com>

# c4921625 15-Dec-2023 Simon Glass <sjg@chromium.org>

bootm: Create a struct for argument information

Some OS functions require the arguments to the 'bootm' command. This is
inconvenient for two reasons.

Firstly, there may not be any actual command, if CMDLINE is not enabled
and programmatic boot is being used.

Secondly, most functions don't require the arguments, so it is
inefficient to pass them when not needed. For example it increases code
size.

Create a new struct which holds the arguments, which can be used if
needed.

Add the images pointer as well, since this is commonly needed.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@konsulko.com>

# 3ac85bdc 18-Nov-2023 Simon Glass <sjg@chromium.org>

bootm: Adjust the parameters of bootm_find_images()

Rather than passing it all the command-line args, pass in the pieces
that it needs. These are the image address, the ramdisk address/name
and the FDT address/name.

Ultimately this will allow usage of this function without being called
from the command line.

Move the function comment to the header file and tidy it a little.

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

# dec166d6 24-Oct-2023 Eddie James <eajames@linux.ibm.com>

bootm: Support boot measurement

Add a configuration option to measure the boot through the bootm
function. Add the measurement state to the booti and bootz paths
as well.

Signed-off-by: Eddie James <eajames@linux.ibm.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Ilias: Added some info on Kconfig explaining this is when booting !EFI
Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>

# daffb0be 30-Jul-2023 Simon Glass <sjg@chromium.org>

bootstd: cros: Add ARM support

Support booting ChromiumOS on ARM devices using FIT. Add an entry into the
boot implementation which does not require a command line. This can be
expanded over time as the bootm code is refactored.

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

# cbb607d2 30-Jul-2023 Simon Glass <sjg@chromium.org>

bootstd: Allow display of the x86 setup information

Provide an option to dump this information if available.

Move the funciion prototype to the common x86 header. Allow the command
line to be left out since 'bootflow info' show this itself and it is
not in the correct place in memory until the kernel is actually booted.

Fix a badly aligned heading while we are here.

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

# 1a081092 30-Jul-2023 Simon Glass <sjg@chromium.org>

bootstd: Move common zimage functions to bootm.h

We want to avoid using #ifdefs around header files and in the code. It
makes sense to collect the various functions used for loading images into
a single header which can be included by all architectures. The best place
for this is the arch-neutral bootm.h header, so use that.

Move some zimage functions into this bootm.h header.

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

# d9d7c20b 06-Sep-2022 Simon Glass <sjg@chromium.org>

treewide: Drop bootm_headers_t typedef

This is not needed and we should avoid typedefs. Use the struct instead.

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>

# 7e713067 26-Oct-2021 Thomas Huth <thuth@redhat.com>

Remove LYNX KDI remainders

The last board that used to set CONFIG_LYNXKDI has been removed in
commit 242836a893ae ("powerpc: ppc4xx: remove pcs440ep support"),
doc/README.lynxkdi only talks about a MPC8260 board being supported,
and the mpc8260 support has been removed four years ago in commit
2eb48ff7a210d ("powerpc, 8260: remove support for mpc8260") already,
and common/lynxkdi.c only consists of an "#error" statement these
days, so it seems like the LYNX KDI code is dead code nowadays.
Let's remove it now.

Signed-off-by: Thomas Huth <thuth@redhat.com>

# 51bb3384 05-Nov-2020 Simon Glass <sjg@chromium.org>

bootm: Support string substitution in bootargs

In some cases it is necessary to pass parameters to Linux so that it will
boot correctly. For example, the rootdev parameter is often used to
specify the root device. However the root device may change depending on
whence U-Boot loads the kernel. At present it is necessary to build up
the command line by adding device strings to it one by one.

It is often more convenient to provide a template for bootargs, with
U-Boot doing the substitution from other environment variables.

Add a way to substitute strings in the bootargs variable. This allows
things like "rootdev=${rootdev}" to be used in bootargs, with the
${rootdev} substitution providing the UUID of the root device.

For example, to substitute the GUID of the kernel partition:

setenv bootargs "console=/dev/ttyS0 rootdev=${uuid}/PARTNROFF=1
kern_guid=${uuid}"
part uuid mmc 2:2 uuid
bootm

This is particularly useful when the command line from another place. For
example, Chrome OS stores the command line next to the kernel itself. It
depends on the kernel version being used as well as the hardware features,
so it is extremely difficult to devise a U-Boot script that works on all
boards and kernel versions. With this feature, the command line can be
read from disk and used directly, with a few substitutions set up.

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

# 4448fe8e 05-Nov-2020 Simon Glass <sjg@chromium.org>

bootm: Allow updating the bootargs in a buffer

At present we only support updating the 'bootargs' environment
variable. Add another function to update a buffer instead. This will
allow zimage to use this feature.

Also add a lot more tests to cover various cases.

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

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

bootm: Update bootm_process_cmdline_env() to use flags

At present only one transformation is supported: making the Linux console
silent. To prepare for adding more, convert the boolean parameter into a
flag value.

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

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

bootm: Add a bool parameter to bootm_process_cmdline_env()

This function will soon do more than just handle the 'silent linux'
feature. As a first step, update it to take a boolean parameter,
indicating whether or not the processing is required.

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

# 4dcb8154 05-Nov-2020 Simon Glass <sjg@chromium.org>

bootm: Rename fixup_silent_linux()

We want to add more processing to this function. Before doing so, rename
it to bootm_process_cmdline_env(), which is more generic.

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

# 4ae42643 05-Nov-2020 Simon Glass <sjg@chromium.org>

bootm: Update fixup_silent_linux() to return an error

At present this function fails silently on error. Update it to produce
an error code. Report this error to the user and abort the boot, since it
likely will prevent a successful start.

No tests are added at this stage, since additional refactoring is taking
place in subsequent patches.

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

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

bootm: Add tests for fixup_silent_linux()

This function currently has no tests. Export it so that we can implement
a simple test on sandbox. Use IS_ENABLED() to remove the unused code,
instead #ifdef.

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

# 73fdb955 14-Sep-2020 Heinrich Schuchardt <xypron.glpk@gmx.de>

bootm: add {arch,board}_preboot_os() to bootm.h

Functions that are used in multiple C modules should be defined in an
include.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Michael Walle <michael@walle.cc>

# fbde7589 12-Jun-2020 Tero Kristo <t-kristo@ti.com>

common: bootm: add checks to verify if ramdisk / fdtimage overlaps OS image

These cases are typically fatal and are difficult to debug for random
users. Add checks for detecting overlapping images and abort if overlap
is detected.

Signed-off-by: Tero Kristo <t-kristo@ti.com>

# 09140113 10-May-2020 Simon Glass <sjg@chromium.org>

command: Remove the cmd_tbl_t typedef

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 <sjg@chromium.org>

# 2090854c 24-Jul-2019 Julius Werner <jwerner@chromium.org>

common: Move bootm_decomp_image() to image.c (as image_decomp())

Upcoming patches want to add decompression to use cases that are no
longer directly related to booting. It makes sense to retain a single
decompression routine, but it should no longer be in bootm.c (which is
not compiled for all configurations). This patch moves
bootm_decomp_image() to image.c and renames it to image_decomp() in
preparation of those upcoming patches.

Signed-off-by: Julius Werner <jwerner@chromium.org>
Reviewed-by: Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com>
[trini: Fix warning around handle_decomp_error being unused]
Signed-off-by: Tom Rini <trini@konsulko.com>

# 93e07880 03-May-2019 Fabrice Fontaine <fontaine.fabrice@gmail.com>

Make FIT support really optional

Due to some mistakes in the source code, it was not possible to really
turn FIT support off. This commit fixes the problem by means of the
following changes:

- Enclose "bootm_host_load_image" and "bootm_host_load_images" between
checks for CONFIG_FIT_SIGNATURE, in common/bootm.c.

- Enclose the declaration of "bootm_host_load_images" between checks for
CONFIG_FIT_SIGNATURE, in common/bootm.h.

- Condition the compilation and linking of fit_common.o fit_image.o
image-host.o common/image-fit.o to CONFIG_FIT=y, in tools/Makefile.

Signed-off-by: Carlos Santos <casantos@datacom.ind.br>
[fabio: adapt for 2016.07]
Signed-off-by: Fabio Estevam <festevam@gmail.com>
[Ricardo: fix conditional compilation and linking of the files mentioned above
for 2016.07]
Signed-off-by: Ricardo Martincoski <ricardo.martincoski@gmail.com>
[Jörg: adapt for 2019.01]
Signed-off-by: Jörg Krause <joerg.krause@embedded.rocks>
[Retrieved from:
https://git.buildroot.net/buildroot/tree/package/uboot-tools/0003-Make-FIT-support-really-optional.patch]
Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>

# f6c6df7e 08-Jan-2019 Heinrich Schuchardt <xypron.glpk@gmx.de>

efi_loader: refactor switch to non-secure mode

Refactor the switch from supervisor to hypervisor to a new function called
at the beginning of do_bootefi().

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Alexander Graf <agraf@suse.de>

# f2a53c76 21-Dec-2018 Bin Meng <bmeng.cn@gmail.com>

bootm: vxworks: Make do_bootm_vxworks() non-static

For future extension to other architectures, make do_bootm_vxworks()
a non-static function.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>

# 896019b1 16-May-2018 Simon Glass <sjg@chromium.org>

Add a comment for board_quiesce_devices()

This exported function should have a comment describing what it does. Also
it should really be removed in favour of device_remove(), which handles
this sort of thing now. Add a comment with a TODO.

Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Alexander Graf <agraf@suse.de>

# 329da485 16-May-2018 Simon Glass <sjg@chromium.org>

Define board_quiesce_devices() in a shared location

This undocumented function relies on arch-specific code to declare a nop
weak version. Add the weak function in common code instead to avoid having
to duplicate the same function in each arch.

Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Alexander Graf <agraf@suse.de>

# 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>

# d52e8575 21-May-2015 Karl Apsite <Karl.Apsite@dornerworks.com>

Combine bootm_find_<thing> functions together

bootm_find_ramdisk_fdt() renamed to bootm_find_images() for readability.

The function bootm_find_ramdisk_fdt() appears to be a simple wrapper for
bootm_find_ramdisk(), bootm_find_fdt(), and now bootm_find_loadables().
I didn't see any other callers entering a bootm_find<thing>, so removing
the wrapper, and condensing these together hopefully makes the code a
little simpler.

Signed-off-by: Karl Apsite <Karl.Apsite@dornerworks.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 081cc197 02-Dec-2014 Simon Glass <sjg@chromium.org>

bootm: Export bootm_decomp_image()

Export this function for testing. Also add a parameter so that values other
than CONFIG_SYS_BOOTM_LEN can be used for the maximum uncompressed size.

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

# f1bd871a 08-Oct-2014 Jeroen Hofstee <jeroen@myspectrum.nl>

bootm: add prototype for arch_preboot_os

Signed-off-by: Jeroen Hofstee <jeroen@myspectrum.nl>

# d2b2ffe3 14-Aug-2014 Tom Rini <trini@konsulko.com>

cmd_bootm.c: Add 'booti' for ARM64 Linux kernel Images

The default format for arm64 Linux kernels is the "Image" format,
described in Documentation/arm64/booting.txt. This, along with an
optional gzip compression on top is all that is generated by default.
The Image format has a magic number within the header for verification,
a text_offset where the Image must be run from, an image_size that
includes the BSS and reserved fields.

This does not support automatic detection of a gzip compressed image.

Signed-off-by: Tom Rini <trini@ti.com>

# ce1400f6 12-Jun-2014 Simon Glass <sjg@chromium.org>

Enhance fit_check_sign to check all images

At present this tool only checks the configuration signing. Have it also
look at each of the images in the configuration and confirm that they
verify.

Signed-off-by: Simon Glass <sjg@chromium.org>
Acked-by: Heiko Schocher <hs@denx.de> (v1)

# b6396403 12-Jun-2014 Simon Glass <sjg@chromium.org>

bootm: Split out code from cmd_bootm.c

This file has code in three different categories:
- Command processing
- OS-specific boot code
- Locating images and setting up to boot

Only the first category really belongs in a file called cmd_bootm.c.

Leave the command processing code where it is. Split out the OS-specific
boot code into bootm_os.c. Split out the other code into bootm.c

Header files and extern declarations are tidied but otherwise no code
changes are made, to make it easier to review.

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

# 777c2846 10-Apr-2024 Tom Rini <trini@konsulko.com>

Merge patch series "pxe: Allow extlinux booting without CMDLINE enabled"

Simon Glass <sjg@chromium.org> says:

This series is the culmanation of the current line of refactoring
series. It adjusts pxe to call the booting functionality directly
rather than going through the command-line interface.

With this is is possible to boot using the extlinux bootmeth without
the command line enabled.

It also updates fastboot to do a similar thing.


# 26736347 14-Dec-2023 Simon Glass <sjg@chromium.org>

bootm: Make cmdline optional with bootm_boot_start()

Allow the default command line to be used when booting the OS. This is
needed by fastboot.

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

# ab3453e7 10-Apr-2024 Tom Rini <trini@konsulko.com>

Merge patch series "Complete decoupling of zboot logic from commands"

Simon Glass <sjg@chromium.org> says:

This series refactors the zboot code to allow it to be used with
CONFIG_COMMAND disabled.

A new zboot_run() function is used to boot a zimage.


# 8d24535e 03-Dec-2023 Simon Glass <sjg@chromium.org>

x86: zboot: Tidy up the comment for zboot_run()

The current use case (ChromeOS) is the uncommon case. Document how this
function is more normally used, where base is 0 and cmdline is NULL

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

# d2c485a0 03-Dec-2023 Simon Glass <sjg@chromium.org>

x86: zboot: Rename zboot_start() to zboot_run()

The term 'start' is used withint bootm and zboot to indicate the first
phase of booting an image.

Since zboot_start() does the whole boot, rename it to zboot_run() to
align with bootm_run() etc.

Fix a log message while we are here.

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

# d37086a9 15-Dec-2023 Simon Glass <sjg@chromium.org>

bootm: Create a new boot_run() function to handle booting

Create a common function used by the three existing bootz/i/m_run()
functions, to reduce duplicated code.

Signed-off-by: Simon Glass <sjg@chromium.org>
Suggested-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Tom Rini <trini@konsulko.com>

# e7683c36 15-Dec-2023 Simon Glass <sjg@chromium.org>

bootm: Create a function to run through the booti states

In a few places, the booti command is used to handle a boot. We want
these to be done without needing CONFIG_CMDLINE, so add a new
booti_run() function to handle this.

So far this is not used.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@konsulko.com>

# 3405c9b6 15-Dec-2023 Simon Glass <sjg@chromium.org>

bootm: Create a function to run through the bootz states

In a few places, the bootz command is used to handle a boot. We want
these to be done without needing CONFIG_CMDLINE, so add a new
bootz_run() function to handle this.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@konsulko.com>

# e1a24c02 15-Dec-2023 Simon Glass <sjg@chromium.org>

bootm: Create a function to run through the bootm states

In quite a few places, the bootm command is used to handle a boot. We
want these to be done without needing CONFIG_CMDLINE, so add a new
bootm_run() function to handle this.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@konsulko.com>

# 725ddf1f 15-Dec-2023 Simon Glass <sjg@chromium.org>

bootm: Tidy up boot_selected_os()

Use struct bootm_info with this function, to avoiding needing to
create a new one.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@konsulko.com>

# b5d397f4 15-Dec-2023 Simon Glass <sjg@chromium.org>

bootm: Rename do_bootm_states() to bootm_run_states()

Rename the function to bootm_run_states() to better indicate ts
purpose. The 'do_' prefix is used to indicate a command processor,
which this is now not.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@konsulko.com>

# a6c49161 15-Dec-2023 Simon Glass <sjg@chromium.org>

bootm: Drop arguments from do_bootm_states()

Use the bootm_info struct to hold the information required by bootm.

Now that none of the functions called from do_bootm_states() needs an
argv[] list, change the arguments of do_bootm_states() as well. Take
care to use the same value for boot_progress even though it is a little
inconsistent.

For booti make sure it only uses argv[] and argc at the top of the
function, so we can eventually refactor to remove these parameters.

With bootm, some OSes need access to the arguments provided to the
command, so set these up in the bootm_info struct, for bootm only.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@konsulko.com>

# e370e3df 15-Dec-2023 Simon Glass <sjg@chromium.org>

bootm: Move do_bootm_states() comment to header file

This is an exported function, so move the function comment to the
bootm.h header file.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
Reviewed-by: Tom Rini <trini@konsulko.com>

# c2211ff6 15-Dec-2023 Simon Glass <sjg@chromium.org>

bootm: Add more fields to bootm_info

Add fields for the three bootm parameters and other things needed for
booting. Also add a helper to set up the struct correctly.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@konsulko.com>

# a48336e5 15-Dec-2023 Simon Glass <sjg@chromium.org>

bootm: Adjust arguments of boot_os_fn

Adjust boot_os_fn to use struct bootm_info instead of the separate
argc, argv and image parameters. Update the handlers accordingly. Few
of the functions make use of the arguments, so this improves code size
slightly.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@konsulko.com>

# c4921625 15-Dec-2023 Simon Glass <sjg@chromium.org>

bootm: Create a struct for argument information

Some OS functions require the arguments to the 'bootm' command. This is
inconvenient for two reasons.

Firstly, there may not be any actual command, if CMDLINE is not enabled
and programmatic boot is being used.

Secondly, most functions don't require the arguments, so it is
inefficient to pass them when not needed. For example it increases code
size.

Create a new struct which holds the arguments, which can be used if
needed.

Add the images pointer as well, since this is commonly needed.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@konsulko.com>

# 3ac85bdc 18-Nov-2023 Simon Glass <sjg@chromium.org>

bootm: Adjust the parameters of bootm_find_images()

Rather than passing it all the command-line args, pass in the pieces
that it needs. These are the image address, the ramdisk address/name
and the FDT address/name.

Ultimately this will allow usage of this function without being called
from the command line.

Move the function comment to the header file and tidy it a little.

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

# dec166d6 24-Oct-2023 Eddie James <eajames@linux.ibm.com>

bootm: Support boot measurement

Add a configuration option to measure the boot through the bootm
function. Add the measurement state to the booti and bootz paths
as well.

Signed-off-by: Eddie James <eajames@linux.ibm.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Ilias: Added some info on Kconfig explaining this is when booting !EFI
Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>

# daffb0be 30-Jul-2023 Simon Glass <sjg@chromium.org>

bootstd: cros: Add ARM support

Support booting ChromiumOS on ARM devices using FIT. Add an entry into the
boot implementation which does not require a command line. This can be
expanded over time as the bootm code is refactored.

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

# cbb607d2 30-Jul-2023 Simon Glass <sjg@chromium.org>

bootstd: Allow display of the x86 setup information

Provide an option to dump this information if available.

Move the funciion prototype to the common x86 header. Allow the command
line to be left out since 'bootflow info' show this itself and it is
not in the correct place in memory until the kernel is actually booted.

Fix a badly aligned heading while we are here.

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

# 1a081092 30-Jul-2023 Simon Glass <sjg@chromium.org>

bootstd: Move common zimage functions to bootm.h

We want to avoid using #ifdefs around header files and in the code. It
makes sense to collect the various functions used for loading images into
a single header which can be included by all architectures. The best place
for this is the arch-neutral bootm.h header, so use that.

Move some zimage functions into this bootm.h header.

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

# d9d7c20b 06-Sep-2022 Simon Glass <sjg@chromium.org>

treewide: Drop bootm_headers_t typedef

This is not needed and we should avoid typedefs. Use the struct instead.

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>

# 7e713067 26-Oct-2021 Thomas Huth <thuth@redhat.com>

Remove LYNX KDI remainders

The last board that used to set CONFIG_LYNXKDI has been removed in
commit 242836a893ae ("powerpc: ppc4xx: remove pcs440ep support"),
doc/README.lynxkdi only talks about a MPC8260 board being supported,
and the mpc8260 support has been removed four years ago in commit
2eb48ff7a210d ("powerpc, 8260: remove support for mpc8260") already,
and common/lynxkdi.c only consists of an "#error" statement these
days, so it seems like the LYNX KDI code is dead code nowadays.
Let's remove it now.

Signed-off-by: Thomas Huth <thuth@redhat.com>

# 51bb3384 05-Nov-2020 Simon Glass <sjg@chromium.org>

bootm: Support string substitution in bootargs

In some cases it is necessary to pass parameters to Linux so that it will
boot correctly. For example, the rootdev parameter is often used to
specify the root device. However the root device may change depending on
whence U-Boot loads the kernel. At present it is necessary to build up
the command line by adding device strings to it one by one.

It is often more convenient to provide a template for bootargs, with
U-Boot doing the substitution from other environment variables.

Add a way to substitute strings in the bootargs variable. This allows
things like "rootdev=${rootdev}" to be used in bootargs, with the
${rootdev} substitution providing the UUID of the root device.

For example, to substitute the GUID of the kernel partition:

setenv bootargs "console=/dev/ttyS0 rootdev=${uuid}/PARTNROFF=1
kern_guid=${uuid}"
part uuid mmc 2:2 uuid
bootm

This is particularly useful when the command line from another place. For
example, Chrome OS stores the command line next to the kernel itself. It
depends on the kernel version being used as well as the hardware features,
so it is extremely difficult to devise a U-Boot script that works on all
boards and kernel versions. With this feature, the command line can be
read from disk and used directly, with a few substitutions set up.

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

# 4448fe8e 05-Nov-2020 Simon Glass <sjg@chromium.org>

bootm: Allow updating the bootargs in a buffer

At present we only support updating the 'bootargs' environment
variable. Add another function to update a buffer instead. This will
allow zimage to use this feature.

Also add a lot more tests to cover various cases.

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

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

bootm: Update bootm_process_cmdline_env() to use flags

At present only one transformation is supported: making the Linux console
silent. To prepare for adding more, convert the boolean parameter into a
flag value.

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

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

bootm: Add a bool parameter to bootm_process_cmdline_env()

This function will soon do more than just handle the 'silent linux'
feature. As a first step, update it to take a boolean parameter,
indicating whether or not the processing is required.

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

# 4dcb8154 05-Nov-2020 Simon Glass <sjg@chromium.org>

bootm: Rename fixup_silent_linux()

We want to add more processing to this function. Before doing so, rename
it to bootm_process_cmdline_env(), which is more generic.

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

# 4ae42643 05-Nov-2020 Simon Glass <sjg@chromium.org>

bootm: Update fixup_silent_linux() to return an error

At present this function fails silently on error. Update it to produce
an error code. Report this error to the user and abort the boot, since it
likely will prevent a successful start.

No tests are added at this stage, since additional refactoring is taking
place in subsequent patches.

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

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

bootm: Add tests for fixup_silent_linux()

This function currently has no tests. Export it so that we can implement
a simple test on sandbox. Use IS_ENABLED() to remove the unused code,
instead #ifdef.

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

# 73fdb955 14-Sep-2020 Heinrich Schuchardt <xypron.glpk@gmx.de>

bootm: add {arch,board}_preboot_os() to bootm.h

Functions that are used in multiple C modules should be defined in an
include.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Michael Walle <michael@walle.cc>

# fbde7589 12-Jun-2020 Tero Kristo <t-kristo@ti.com>

common: bootm: add checks to verify if ramdisk / fdtimage overlaps OS image

These cases are typically fatal and are difficult to debug for random
users. Add checks for detecting overlapping images and abort if overlap
is detected.

Signed-off-by: Tero Kristo <t-kristo@ti.com>

# 09140113 10-May-2020 Simon Glass <sjg@chromium.org>

command: Remove the cmd_tbl_t typedef

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 <sjg@chromium.org>

# 2090854c 24-Jul-2019 Julius Werner <jwerner@chromium.org>

common: Move bootm_decomp_image() to image.c (as image_decomp())

Upcoming patches want to add decompression to use cases that are no
longer directly related to booting. It makes sense to retain a single
decompression routine, but it should no longer be in bootm.c (which is
not compiled for all configurations). This patch moves
bootm_decomp_image() to image.c and renames it to image_decomp() in
preparation of those upcoming patches.

Signed-off-by: Julius Werner <jwerner@chromium.org>
Reviewed-by: Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com>
[trini: Fix warning around handle_decomp_error being unused]
Signed-off-by: Tom Rini <trini@konsulko.com>

# 93e07880 03-May-2019 Fabrice Fontaine <fontaine.fabrice@gmail.com>

Make FIT support really optional

Due to some mistakes in the source code, it was not possible to really
turn FIT support off. This commit fixes the problem by means of the
following changes:

- Enclose "bootm_host_load_image" and "bootm_host_load_images" between
checks for CONFIG_FIT_SIGNATURE, in common/bootm.c.

- Enclose the declaration of "bootm_host_load_images" between checks for
CONFIG_FIT_SIGNATURE, in common/bootm.h.

- Condition the compilation and linking of fit_common.o fit_image.o
image-host.o common/image-fit.o to CONFIG_FIT=y, in tools/Makefile.

Signed-off-by: Carlos Santos <casantos@datacom.ind.br>
[fabio: adapt for 2016.07]
Signed-off-by: Fabio Estevam <festevam@gmail.com>
[Ricardo: fix conditional compilation and linking of the files mentioned above
for 2016.07]
Signed-off-by: Ricardo Martincoski <ricardo.martincoski@gmail.com>
[Jörg: adapt for 2019.01]
Signed-off-by: Jörg Krause <joerg.krause@embedded.rocks>
[Retrieved from:
https://git.buildroot.net/buildroot/tree/package/uboot-tools/0003-Make-FIT-support-really-optional.patch]
Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>

# f6c6df7e 08-Jan-2019 Heinrich Schuchardt <xypron.glpk@gmx.de>

efi_loader: refactor switch to non-secure mode

Refactor the switch from supervisor to hypervisor to a new function called
at the beginning of do_bootefi().

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Alexander Graf <agraf@suse.de>

# f2a53c76 21-Dec-2018 Bin Meng <bmeng.cn@gmail.com>

bootm: vxworks: Make do_bootm_vxworks() non-static

For future extension to other architectures, make do_bootm_vxworks()
a non-static function.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>

# 896019b1 16-May-2018 Simon Glass <sjg@chromium.org>

Add a comment for board_quiesce_devices()

This exported function should have a comment describing what it does. Also
it should really be removed in favour of device_remove(), which handles
this sort of thing now. Add a comment with a TODO.

Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Alexander Graf <agraf@suse.de>

# 329da485 16-May-2018 Simon Glass <sjg@chromium.org>

Define board_quiesce_devices() in a shared location

This undocumented function relies on arch-specific code to declare a nop
weak version. Add the weak function in common code instead to avoid having
to duplicate the same function in each arch.

Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Alexander Graf <agraf@suse.de>

# 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>

# d52e8575 21-May-2015 Karl Apsite <Karl.Apsite@dornerworks.com>

Combine bootm_find_<thing> functions together

bootm_find_ramdisk_fdt() renamed to bootm_find_images() for readability.

The function bootm_find_ramdisk_fdt() appears to be a simple wrapper for
bootm_find_ramdisk(), bootm_find_fdt(), and now bootm_find_loadables().
I didn't see any other callers entering a bootm_find<thing>, so removing
the wrapper, and condensing these together hopefully makes the code a
little simpler.

Signed-off-by: Karl Apsite <Karl.Apsite@dornerworks.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 081cc197 02-Dec-2014 Simon Glass <sjg@chromium.org>

bootm: Export bootm_decomp_image()

Export this function for testing. Also add a parameter so that values other
than CONFIG_SYS_BOOTM_LEN can be used for the maximum uncompressed size.

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

# f1bd871a 08-Oct-2014 Jeroen Hofstee <jeroen@myspectrum.nl>

bootm: add prototype for arch_preboot_os

Signed-off-by: Jeroen Hofstee <jeroen@myspectrum.nl>

# d2b2ffe3 14-Aug-2014 Tom Rini <trini@konsulko.com>

cmd_bootm.c: Add 'booti' for ARM64 Linux kernel Images

The default format for arm64 Linux kernels is the "Image" format,
described in Documentation/arm64/booting.txt. This, along with an
optional gzip compression on top is all that is generated by default.
The Image format has a magic number within the header for verification,
a text_offset where the Image must be run from, an image_size that
includes the BSS and reserved fields.

This does not support automatic detection of a gzip compressed image.

Signed-off-by: Tom Rini <trini@ti.com>

# ce1400f6 12-Jun-2014 Simon Glass <sjg@chromium.org>

Enhance fit_check_sign to check all images

At present this tool only checks the configuration signing. Have it also
look at each of the images in the configuration and confirm that they
verify.

Signed-off-by: Simon Glass <sjg@chromium.org>
Acked-by: Heiko Schocher <hs@denx.de> (v1)

# b6396403 12-Jun-2014 Simon Glass <sjg@chromium.org>

bootm: Split out code from cmd_bootm.c

This file has code in three different categories:
- Command processing
- OS-specific boot code
- Locating images and setting up to boot

Only the first category really belongs in a file called cmd_bootm.c.

Leave the command processing code where it is. Split out the OS-specific
boot code into bootm_os.c. Split out the other code into bootm.c

Header files and extern declarations are tidied but otherwise no code
changes are made, to make it easier to review.

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

# d37086a9 15-Dec-2023 Simon Glass <sjg@chromium.org>

bootm: Create a new boot_run() function to handle booting

Create a common function used by the three existing bootz/i/m_run()
functions, to reduce duplicated code.

Signed-off-by: Simon Glass <sjg@chromium.org>
Suggested-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Tom Rini <trini@konsulko.com>

# e7683c36 15-Dec-2023 Simon Glass <sjg@chromium.org>

bootm: Create a function to run through the booti states

In a few places, the booti command is used to handle a boot. We want
these to be done without needing CONFIG_CMDLINE, so add a new
booti_run() function to handle this.

So far this is not used.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@konsulko.com>

# 3405c9b6 15-Dec-2023 Simon Glass <sjg@chromium.org>

bootm: Create a function to run through the bootz states

In a few places, the bootz command is used to handle a boot. We want
these to be done without needing CONFIG_CMDLINE, so add a new
bootz_run() function to handle this.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@konsulko.com>

# e1a24c02 15-Dec-2023 Simon Glass <sjg@chromium.org>

bootm: Create a function to run through the bootm states

In quite a few places, the bootm command is used to handle a boot. We
want these to be done without needing CONFIG_CMDLINE, so add a new
bootm_run() function to handle this.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@konsulko.com>

# 725ddf1f 15-Dec-2023 Simon Glass <sjg@chromium.org>

bootm: Tidy up boot_selected_os()

Use struct bootm_info with this function, to avoiding needing to
create a new one.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@konsulko.com>

# b5d397f4 15-Dec-2023 Simon Glass <sjg@chromium.org>

bootm: Rename do_bootm_states() to bootm_run_states()

Rename the function to bootm_run_states() to better indicate ts
purpose. The 'do_' prefix is used to indicate a command processor,
which this is now not.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@konsulko.com>

# a6c49161 15-Dec-2023 Simon Glass <sjg@chromium.org>

bootm: Drop arguments from do_bootm_states()

Use the bootm_info struct to hold the information required by bootm.

Now that none of the functions called from do_bootm_states() needs an
argv[] list, change the arguments of do_bootm_states() as well. Take
care to use the same value for boot_progress even though it is a little
inconsistent.

For booti make sure it only uses argv[] and argc at the top of the
function, so we can eventually refactor to remove these parameters.

With bootm, some OSes need access to the arguments provided to the
command, so set these up in the bootm_info struct, for bootm only.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@konsulko.com>

# e370e3df 15-Dec-2023 Simon Glass <sjg@chromium.org>

bootm: Move do_bootm_states() comment to header file

This is an exported function, so move the function comment to the
bootm.h header file.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
Reviewed-by: Tom Rini <trini@konsulko.com>

# c2211ff6 15-Dec-2023 Simon Glass <sjg@chromium.org>

bootm: Add more fields to bootm_info

Add fields for the three bootm parameters and other things needed for
booting. Also add a helper to set up the struct correctly.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@konsulko.com>

# a48336e5 15-Dec-2023 Simon Glass <sjg@chromium.org>

bootm: Adjust arguments of boot_os_fn

Adjust boot_os_fn to use struct bootm_info instead of the separate
argc, argv and image parameters. Update the handlers accordingly. Few
of the functions make use of the arguments, so this improves code size
slightly.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@konsulko.com>

# c4921625 15-Dec-2023 Simon Glass <sjg@chromium.org>

bootm: Create a struct for argument information

Some OS functions require the arguments to the 'bootm' command. This is
inconvenient for two reasons.

Firstly, there may not be any actual command, if CMDLINE is not enabled
and programmatic boot is being used.

Secondly, most functions don't require the arguments, so it is
inefficient to pass them when not needed. For example it increases code
size.

Create a new struct which holds the arguments, which can be used if
needed.

Add the images pointer as well, since this is commonly needed.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@konsulko.com>

# 3ac85bdc 18-Nov-2023 Simon Glass <sjg@chromium.org>

bootm: Adjust the parameters of bootm_find_images()

Rather than passing it all the command-line args, pass in the pieces
that it needs. These are the image address, the ramdisk address/name
and the FDT address/name.

Ultimately this will allow usage of this function without being called
from the command line.

Move the function comment to the header file and tidy it a little.

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

# dec166d6 24-Oct-2023 Eddie James <eajames@linux.ibm.com>

bootm: Support boot measurement

Add a configuration option to measure the boot through the bootm
function. Add the measurement state to the booti and bootz paths
as well.

Signed-off-by: Eddie James <eajames@linux.ibm.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Ilias: Added some info on Kconfig explaining this is when booting !EFI
Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>

# daffb0be 30-Jul-2023 Simon Glass <sjg@chromium.org>

bootstd: cros: Add ARM support

Support booting ChromiumOS on ARM devices using FIT. Add an entry into the
boot implementation which does not require a command line. This can be
expanded over time as the bootm code is refactored.

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

# cbb607d2 30-Jul-2023 Simon Glass <sjg@chromium.org>

bootstd: Allow display of the x86 setup information

Provide an option to dump this information if available.

Move the funciion prototype to the common x86 header. Allow the command
line to be left out since 'bootflow info' show this itself and it is
not in the correct place in memory until the kernel is actually booted.

Fix a badly aligned heading while we are here.

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

# 1a081092 30-Jul-2023 Simon Glass <sjg@chromium.org>

bootstd: Move common zimage functions to bootm.h

We want to avoid using #ifdefs around header files and in the code. It
makes sense to collect the various functions used for loading images into
a single header which can be included by all architectures. The best place
for this is the arch-neutral bootm.h header, so use that.

Move some zimage functions into this bootm.h header.

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

# d9d7c20b 06-Sep-2022 Simon Glass <sjg@chromium.org>

treewide: Drop bootm_headers_t typedef

This is not needed and we should avoid typedefs. Use the struct instead.

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>

# 7e713067 26-Oct-2021 Thomas Huth <thuth@redhat.com>

Remove LYNX KDI remainders

The last board that used to set CONFIG_LYNXKDI has been removed in
commit 242836a893ae ("powerpc: ppc4xx: remove pcs440ep support"),
doc/README.lynxkdi only talks about a MPC8260 board being supported,
and the mpc8260 support has been removed four years ago in commit
2eb48ff7a210d ("powerpc, 8260: remove support for mpc8260") already,
and common/lynxkdi.c only consists of an "#error" statement these
days, so it seems like the LYNX KDI code is dead code nowadays.
Let's remove it now.

Signed-off-by: Thomas Huth <thuth@redhat.com>

# 51bb3384 05-Nov-2020 Simon Glass <sjg@chromium.org>

bootm: Support string substitution in bootargs

In some cases it is necessary to pass parameters to Linux so that it will
boot correctly. For example, the rootdev parameter is often used to
specify the root device. However the root device may change depending on
whence U-Boot loads the kernel. At present it is necessary to build up
the command line by adding device strings to it one by one.

It is often more convenient to provide a template for bootargs, with
U-Boot doing the substitution from other environment variables.

Add a way to substitute strings in the bootargs variable. This allows
things like "rootdev=${rootdev}" to be used in bootargs, with the
${rootdev} substitution providing the UUID of the root device.

For example, to substitute the GUID of the kernel partition:

setenv bootargs "console=/dev/ttyS0 rootdev=${uuid}/PARTNROFF=1
kern_guid=${uuid}"
part uuid mmc 2:2 uuid
bootm

This is particularly useful when the command line from another place. For
example, Chrome OS stores the command line next to the kernel itself. It
depends on the kernel version being used as well as the hardware features,
so it is extremely difficult to devise a U-Boot script that works on all
boards and kernel versions. With this feature, the command line can be
read from disk and used directly, with a few substitutions set up.

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

# 4448fe8e 05-Nov-2020 Simon Glass <sjg@chromium.org>

bootm: Allow updating the bootargs in a buffer

At present we only support updating the 'bootargs' environment
variable. Add another function to update a buffer instead. This will
allow zimage to use this feature.

Also add a lot more tests to cover various cases.

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

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

bootm: Update bootm_process_cmdline_env() to use flags

At present only one transformation is supported: making the Linux console
silent. To prepare for adding more, convert the boolean parameter into a
flag value.

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

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

bootm: Add a bool parameter to bootm_process_cmdline_env()

This function will soon do more than just handle the 'silent linux'
feature. As a first step, update it to take a boolean parameter,
indicating whether or not the processing is required.

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

# 4dcb8154 05-Nov-2020 Simon Glass <sjg@chromium.org>

bootm: Rename fixup_silent_linux()

We want to add more processing to this function. Before doing so, rename
it to bootm_process_cmdline_env(), which is more generic.

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

# 4ae42643 05-Nov-2020 Simon Glass <sjg@chromium.org>

bootm: Update fixup_silent_linux() to return an error

At present this function fails silently on error. Update it to produce
an error code. Report this error to the user and abort the boot, since it
likely will prevent a successful start.

No tests are added at this stage, since additional refactoring is taking
place in subsequent patches.

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

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

bootm: Add tests for fixup_silent_linux()

This function currently has no tests. Export it so that we can implement
a simple test on sandbox. Use IS_ENABLED() to remove the unused code,
instead #ifdef.

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

# 73fdb955 14-Sep-2020 Heinrich Schuchardt <xypron.glpk@gmx.de>

bootm: add {arch,board}_preboot_os() to bootm.h

Functions that are used in multiple C modules should be defined in an
include.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Michael Walle <michael@walle.cc>

# fbde7589 12-Jun-2020 Tero Kristo <t-kristo@ti.com>

common: bootm: add checks to verify if ramdisk / fdtimage overlaps OS image

These cases are typically fatal and are difficult to debug for random
users. Add checks for detecting overlapping images and abort if overlap
is detected.

Signed-off-by: Tero Kristo <t-kristo@ti.com>

# 09140113 10-May-2020 Simon Glass <sjg@chromium.org>

command: Remove the cmd_tbl_t typedef

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 <sjg@chromium.org>

# 2090854c 24-Jul-2019 Julius Werner <jwerner@chromium.org>

common: Move bootm_decomp_image() to image.c (as image_decomp())

Upcoming patches want to add decompression to use cases that are no
longer directly related to booting. It makes sense to retain a single
decompression routine, but it should no longer be in bootm.c (which is
not compiled for all configurations). This patch moves
bootm_decomp_image() to image.c and renames it to image_decomp() in
preparation of those upcoming patches.

Signed-off-by: Julius Werner <jwerner@chromium.org>
Reviewed-by: Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com>
[trini: Fix warning around handle_decomp_error being unused]
Signed-off-by: Tom Rini <trini@konsulko.com>

# 93e07880 03-May-2019 Fabrice Fontaine <fontaine.fabrice@gmail.com>

Make FIT support really optional

Due to some mistakes in the source code, it was not possible to really
turn FIT support off. This commit fixes the problem by means of the
following changes:

- Enclose "bootm_host_load_image" and "bootm_host_load_images" between
checks for CONFIG_FIT_SIGNATURE, in common/bootm.c.

- Enclose the declaration of "bootm_host_load_images" between checks for
CONFIG_FIT_SIGNATURE, in common/bootm.h.

- Condition the compilation and linking of fit_common.o fit_image.o
image-host.o common/image-fit.o to CONFIG_FIT=y, in tools/Makefile.

Signed-off-by: Carlos Santos <casantos@datacom.ind.br>
[fabio: adapt for 2016.07]
Signed-off-by: Fabio Estevam <festevam@gmail.com>
[Ricardo: fix conditional compilation and linking of the files mentioned above
for 2016.07]
Signed-off-by: Ricardo Martincoski <ricardo.martincoski@gmail.com>
[Jörg: adapt for 2019.01]
Signed-off-by: Jörg Krause <joerg.krause@embedded.rocks>
[Retrieved from:
https://git.buildroot.net/buildroot/tree/package/uboot-tools/0003-Make-FIT-support-really-optional.patch]
Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>

# f6c6df7e 08-Jan-2019 Heinrich Schuchardt <xypron.glpk@gmx.de>

efi_loader: refactor switch to non-secure mode

Refactor the switch from supervisor to hypervisor to a new function called
at the beginning of do_bootefi().

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Alexander Graf <agraf@suse.de>

# f2a53c76 21-Dec-2018 Bin Meng <bmeng.cn@gmail.com>

bootm: vxworks: Make do_bootm_vxworks() non-static

For future extension to other architectures, make do_bootm_vxworks()
a non-static function.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>

# 896019b1 16-May-2018 Simon Glass <sjg@chromium.org>

Add a comment for board_quiesce_devices()

This exported function should have a comment describing what it does. Also
it should really be removed in favour of device_remove(), which handles
this sort of thing now. Add a comment with a TODO.

Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Alexander Graf <agraf@suse.de>

# 329da485 16-May-2018 Simon Glass <sjg@chromium.org>

Define board_quiesce_devices() in a shared location

This undocumented function relies on arch-specific code to declare a nop
weak version. Add the weak function in common code instead to avoid having
to duplicate the same function in each arch.

Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Alexander Graf <agraf@suse.de>

# 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>

# d52e8575 21-May-2015 Karl Apsite <Karl.Apsite@dornerworks.com>

Combine bootm_find_<thing> functions together

bootm_find_ramdisk_fdt() renamed to bootm_find_images() for readability.

The function bootm_find_ramdisk_fdt() appears to be a simple wrapper for
bootm_find_ramdisk(), bootm_find_fdt(), and now bootm_find_loadables().
I didn't see any other callers entering a bootm_find<thing>, so removing
the wrapper, and condensing these together hopefully makes the code a
little simpler.

Signed-off-by: Karl Apsite <Karl.Apsite@dornerworks.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 081cc197 02-Dec-2014 Simon Glass <sjg@chromium.org>

bootm: Export bootm_decomp_image()

Export this function for testing. Also add a parameter so that values other
than CONFIG_SYS_BOOTM_LEN can be used for the maximum uncompressed size.

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

# f1bd871a 08-Oct-2014 Jeroen Hofstee <jeroen@myspectrum.nl>

bootm: add prototype for arch_preboot_os

Signed-off-by: Jeroen Hofstee <jeroen@myspectrum.nl>

# d2b2ffe3 14-Aug-2014 Tom Rini <trini@konsulko.com>

cmd_bootm.c: Add 'booti' for ARM64 Linux kernel Images

The default format for arm64 Linux kernels is the "Image" format,
described in Documentation/arm64/booting.txt. This, along with an
optional gzip compression on top is all that is generated by default.
The Image format has a magic number within the header for verification,
a text_offset where the Image must be run from, an image_size that
includes the BSS and reserved fields.

This does not support automatic detection of a gzip compressed image.

Signed-off-by: Tom Rini <trini@ti.com>

# ce1400f6 12-Jun-2014 Simon Glass <sjg@chromium.org>

Enhance fit_check_sign to check all images

At present this tool only checks the configuration signing. Have it also
look at each of the images in the configuration and confirm that they
verify.

Signed-off-by: Simon Glass <sjg@chromium.org>
Acked-by: Heiko Schocher <hs@denx.de> (v1)

# b6396403 12-Jun-2014 Simon Glass <sjg@chromium.org>

bootm: Split out code from cmd_bootm.c

This file has code in three different categories:
- Command processing
- OS-specific boot code
- Locating images and setting up to boot

Only the first category really belongs in a file called cmd_bootm.c.

Leave the command processing code where it is. Split out the OS-specific
boot code into bootm_os.c. Split out the other code into bootm.c

Header files and extern declarations are tidied but otherwise no code
changes are made, to make it easier to review.

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

# dec166d6 24-Oct-2023 Eddie James <eajames@linux.ibm.com>

bootm: Support boot measurement

Add a configuration option to measure the boot through the bootm
function. Add the measurement state to the booti and bootz paths
as well.

Signed-off-by: Eddie James <eajames@linux.ibm.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Ilias: Added some info on Kconfig explaining this is when booting !EFI
Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>

# daffb0be 30-Jul-2023 Simon Glass <sjg@chromium.org>

bootstd: cros: Add ARM support

Support booting ChromiumOS on ARM devices using FIT. Add an entry into the
boot implementation which does not require a command line. This can be
expanded over time as the bootm code is refactored.

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

# cbb607d2 30-Jul-2023 Simon Glass <sjg@chromium.org>

bootstd: Allow display of the x86 setup information

Provide an option to dump this information if available.

Move the funciion prototype to the common x86 header. Allow the command
line to be left out since 'bootflow info' show this itself and it is
not in the correct place in memory until the kernel is actually booted.

Fix a badly aligned heading while we are here.

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

# 1a081092 30-Jul-2023 Simon Glass <sjg@chromium.org>

bootstd: Move common zimage functions to bootm.h

We want to avoid using #ifdefs around header files and in the code. It
makes sense to collect the various functions used for loading images into
a single header which can be included by all architectures. The best place
for this is the arch-neutral bootm.h header, so use that.

Move some zimage functions into this bootm.h header.

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

# d9d7c20b 06-Sep-2022 Simon Glass <sjg@chromium.org>

treewide: Drop bootm_headers_t typedef

This is not needed and we should avoid typedefs. Use the struct instead.

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>

# 7e713067 26-Oct-2021 Thomas Huth <thuth@redhat.com>

Remove LYNX KDI remainders

The last board that used to set CONFIG_LYNXKDI has been removed in
commit 242836a893ae ("powerpc: ppc4xx: remove pcs440ep support"),
doc/README.lynxkdi only talks about a MPC8260 board being supported,
and the mpc8260 support has been removed four years ago in commit
2eb48ff7a210d ("powerpc, 8260: remove support for mpc8260") already,
and common/lynxkdi.c only consists of an "#error" statement these
days, so it seems like the LYNX KDI code is dead code nowadays.
Let's remove it now.

Signed-off-by: Thomas Huth <thuth@redhat.com>

# 51bb3384 05-Nov-2020 Simon Glass <sjg@chromium.org>

bootm: Support string substitution in bootargs

In some cases it is necessary to pass parameters to Linux so that it will
boot correctly. For example, the rootdev parameter is often used to
specify the root device. However the root device may change depending on
whence U-Boot loads the kernel. At present it is necessary to build up
the command line by adding device strings to it one by one.

It is often more convenient to provide a template for bootargs, with
U-Boot doing the substitution from other environment variables.

Add a way to substitute strings in the bootargs variable. This allows
things like "rootdev=${rootdev}" to be used in bootargs, with the
${rootdev} substitution providing the UUID of the root device.

For example, to substitute the GUID of the kernel partition:

setenv bootargs "console=/dev/ttyS0 rootdev=${uuid}/PARTNROFF=1
kern_guid=${uuid}"
part uuid mmc 2:2 uuid
bootm

This is particularly useful when the command line from another place. For
example, Chrome OS stores the command line next to the kernel itself. It
depends on the kernel version being used as well as the hardware features,
so it is extremely difficult to devise a U-Boot script that works on all
boards and kernel versions. With this feature, the command line can be
read from disk and used directly, with a few substitutions set up.

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

# 4448fe8e 05-Nov-2020 Simon Glass <sjg@chromium.org>

bootm: Allow updating the bootargs in a buffer

At present we only support updating the 'bootargs' environment
variable. Add another function to update a buffer instead. This will
allow zimage to use this feature.

Also add a lot more tests to cover various cases.

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

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

bootm: Update bootm_process_cmdline_env() to use flags

At present only one transformation is supported: making the Linux console
silent. To prepare for adding more, convert the boolean parameter into a
flag value.

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

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

bootm: Add a bool parameter to bootm_process_cmdline_env()

This function will soon do more than just handle the 'silent linux'
feature. As a first step, update it to take a boolean parameter,
indicating whether or not the processing is required.

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

# 4dcb8154 05-Nov-2020 Simon Glass <sjg@chromium.org>

bootm: Rename fixup_silent_linux()

We want to add more processing to this function. Before doing so, rename
it to bootm_process_cmdline_env(), which is more generic.

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

# 4ae42643 05-Nov-2020 Simon Glass <sjg@chromium.org>

bootm: Update fixup_silent_linux() to return an error

At present this function fails silently on error. Update it to produce
an error code. Report this error to the user and abort the boot, since it
likely will prevent a successful start.

No tests are added at this stage, since additional refactoring is taking
place in subsequent patches.

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

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

bootm: Add tests for fixup_silent_linux()

This function currently has no tests. Export it so that we can implement
a simple test on sandbox. Use IS_ENABLED() to remove the unused code,
instead #ifdef.

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

# 73fdb955 14-Sep-2020 Heinrich Schuchardt <xypron.glpk@gmx.de>

bootm: add {arch,board}_preboot_os() to bootm.h

Functions that are used in multiple C modules should be defined in an
include.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Michael Walle <michael@walle.cc>

# fbde7589 12-Jun-2020 Tero Kristo <t-kristo@ti.com>

common: bootm: add checks to verify if ramdisk / fdtimage overlaps OS image

These cases are typically fatal and are difficult to debug for random
users. Add checks for detecting overlapping images and abort if overlap
is detected.

Signed-off-by: Tero Kristo <t-kristo@ti.com>

# 09140113 10-May-2020 Simon Glass <sjg@chromium.org>

command: Remove the cmd_tbl_t typedef

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 <sjg@chromium.org>

# 2090854c 24-Jul-2019 Julius Werner <jwerner@chromium.org>

common: Move bootm_decomp_image() to image.c (as image_decomp())

Upcoming patches want to add decompression to use cases that are no
longer directly related to booting. It makes sense to retain a single
decompression routine, but it should no longer be in bootm.c (which is
not compiled for all configurations). This patch moves
bootm_decomp_image() to image.c and renames it to image_decomp() in
preparation of those upcoming patches.

Signed-off-by: Julius Werner <jwerner@chromium.org>
Reviewed-by: Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com>
[trini: Fix warning around handle_decomp_error being unused]
Signed-off-by: Tom Rini <trini@konsulko.com>

# 93e07880 03-May-2019 Fabrice Fontaine <fontaine.fabrice@gmail.com>

Make FIT support really optional

Due to some mistakes in the source code, it was not possible to really
turn FIT support off. This commit fixes the problem by means of the
following changes:

- Enclose "bootm_host_load_image" and "bootm_host_load_images" between
checks for CONFIG_FIT_SIGNATURE, in common/bootm.c.

- Enclose the declaration of "bootm_host_load_images" between checks for
CONFIG_FIT_SIGNATURE, in common/bootm.h.

- Condition the compilation and linking of fit_common.o fit_image.o
image-host.o common/image-fit.o to CONFIG_FIT=y, in tools/Makefile.

Signed-off-by: Carlos Santos <casantos@datacom.ind.br>
[fabio: adapt for 2016.07]
Signed-off-by: Fabio Estevam <festevam@gmail.com>
[Ricardo: fix conditional compilation and linking of the files mentioned above
for 2016.07]
Signed-off-by: Ricardo Martincoski <ricardo.martincoski@gmail.com>
[Jörg: adapt for 2019.01]
Signed-off-by: Jörg Krause <joerg.krause@embedded.rocks>
[Retrieved from:
https://git.buildroot.net/buildroot/tree/package/uboot-tools/0003-Make-FIT-support-really-optional.patch]
Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>

# f6c6df7e 08-Jan-2019 Heinrich Schuchardt <xypron.glpk@gmx.de>

efi_loader: refactor switch to non-secure mode

Refactor the switch from supervisor to hypervisor to a new function called
at the beginning of do_bootefi().

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Alexander Graf <agraf@suse.de>

# f2a53c76 21-Dec-2018 Bin Meng <bmeng.cn@gmail.com>

bootm: vxworks: Make do_bootm_vxworks() non-static

For future extension to other architectures, make do_bootm_vxworks()
a non-static function.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>

# 896019b1 16-May-2018 Simon Glass <sjg@chromium.org>

Add a comment for board_quiesce_devices()

This exported function should have a comment describing what it does. Also
it should really be removed in favour of device_remove(), which handles
this sort of thing now. Add a comment with a TODO.

Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Alexander Graf <agraf@suse.de>

# 329da485 16-May-2018 Simon Glass <sjg@chromium.org>

Define board_quiesce_devices() in a shared location

This undocumented function relies on arch-specific code to declare a nop
weak version. Add the weak function in common code instead to avoid having
to duplicate the same function in each arch.

Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Alexander Graf <agraf@suse.de>

# 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>

# d52e8575 21-May-2015 Karl Apsite <Karl.Apsite@dornerworks.com>

Combine bootm_find_<thing> functions together

bootm_find_ramdisk_fdt() renamed to bootm_find_images() for readability.

The function bootm_find_ramdisk_fdt() appears to be a simple wrapper for
bootm_find_ramdisk(), bootm_find_fdt(), and now bootm_find_loadables().
I didn't see any other callers entering a bootm_find<thing>, so removing
the wrapper, and condensing these together hopefully makes the code a
little simpler.

Signed-off-by: Karl Apsite <Karl.Apsite@dornerworks.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 081cc197 02-Dec-2014 Simon Glass <sjg@chromium.org>

bootm: Export bootm_decomp_image()

Export this function for testing. Also add a parameter so that values other
than CONFIG_SYS_BOOTM_LEN can be used for the maximum uncompressed size.

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

# f1bd871a 08-Oct-2014 Jeroen Hofstee <jeroen@myspectrum.nl>

bootm: add prototype for arch_preboot_os

Signed-off-by: Jeroen Hofstee <jeroen@myspectrum.nl>

# d2b2ffe3 14-Aug-2014 Tom Rini <trini@konsulko.com>

cmd_bootm.c: Add 'booti' for ARM64 Linux kernel Images

The default format for arm64 Linux kernels is the "Image" format,
described in Documentation/arm64/booting.txt. This, along with an
optional gzip compression on top is all that is generated by default.
The Image format has a magic number within the header for verification,
a text_offset where the Image must be run from, an image_size that
includes the BSS and reserved fields.

This does not support automatic detection of a gzip compressed image.

Signed-off-by: Tom Rini <trini@ti.com>

# ce1400f6 12-Jun-2014 Simon Glass <sjg@chromium.org>

Enhance fit_check_sign to check all images

At present this tool only checks the configuration signing. Have it also
look at each of the images in the configuration and confirm that they
verify.

Signed-off-by: Simon Glass <sjg@chromium.org>
Acked-by: Heiko Schocher <hs@denx.de> (v1)

# b6396403 12-Jun-2014 Simon Glass <sjg@chromium.org>

bootm: Split out code from cmd_bootm.c

This file has code in three different categories:
- Command processing
- OS-specific boot code
- Locating images and setting up to boot

Only the first category really belongs in a file called cmd_bootm.c.

Leave the command processing code where it is. Split out the OS-specific
boot code into bootm_os.c. Split out the other code into bootm.c

Header files and extern declarations are tidied but otherwise no code
changes are made, to make it easier to review.

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

# daffb0be 30-Jul-2023 Simon Glass <sjg@chromium.org>

bootstd: cros: Add ARM support

Support booting ChromiumOS on ARM devices using FIT. Add an entry into the
boot implementation which does not require a command line. This can be
expanded over time as the bootm code is refactored.

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

# cbb607d2 30-Jul-2023 Simon Glass <sjg@chromium.org>

bootstd: Allow display of the x86 setup information

Provide an option to dump this information if available.

Move the funciion prototype to the common x86 header. Allow the command
line to be left out since 'bootflow info' show this itself and it is
not in the correct place in memory until the kernel is actually booted.

Fix a badly aligned heading while we are here.

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

# 1a081092 30-Jul-2023 Simon Glass <sjg@chromium.org>

bootstd: Move common zimage functions to bootm.h

We want to avoid using #ifdefs around header files and in the code. It
makes sense to collect the various functions used for loading images into
a single header which can be included by all architectures. The best place
for this is the arch-neutral bootm.h header, so use that.

Move some zimage functions into this bootm.h header.

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

# d9d7c20b 06-Sep-2022 Simon Glass <sjg@chromium.org>

treewide: Drop bootm_headers_t typedef

This is not needed and we should avoid typedefs. Use the struct instead.

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>

# 7e713067 26-Oct-2021 Thomas Huth <thuth@redhat.com>

Remove LYNX KDI remainders

The last board that used to set CONFIG_LYNXKDI has been removed in
commit 242836a893ae ("powerpc: ppc4xx: remove pcs440ep support"),
doc/README.lynxkdi only talks about a MPC8260 board being supported,
and the mpc8260 support has been removed four years ago in commit
2eb48ff7a210d ("powerpc, 8260: remove support for mpc8260") already,
and common/lynxkdi.c only consists of an "#error" statement these
days, so it seems like the LYNX KDI code is dead code nowadays.
Let's remove it now.

Signed-off-by: Thomas Huth <thuth@redhat.com>

# 51bb3384 05-Nov-2020 Simon Glass <sjg@chromium.org>

bootm: Support string substitution in bootargs

In some cases it is necessary to pass parameters to Linux so that it will
boot correctly. For example, the rootdev parameter is often used to
specify the root device. However the root device may change depending on
whence U-Boot loads the kernel. At present it is necessary to build up
the command line by adding device strings to it one by one.

It is often more convenient to provide a template for bootargs, with
U-Boot doing the substitution from other environment variables.

Add a way to substitute strings in the bootargs variable. This allows
things like "rootdev=${rootdev}" to be used in bootargs, with the
${rootdev} substitution providing the UUID of the root device.

For example, to substitute the GUID of the kernel partition:

setenv bootargs "console=/dev/ttyS0 rootdev=${uuid}/PARTNROFF=1
kern_guid=${uuid}"
part uuid mmc 2:2 uuid
bootm

This is particularly useful when the command line from another place. For
example, Chrome OS stores the command line next to the kernel itself. It
depends on the kernel version being used as well as the hardware features,
so it is extremely difficult to devise a U-Boot script that works on all
boards and kernel versions. With this feature, the command line can be
read from disk and used directly, with a few substitutions set up.

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

# 4448fe8e 05-Nov-2020 Simon Glass <sjg@chromium.org>

bootm: Allow updating the bootargs in a buffer

At present we only support updating the 'bootargs' environment
variable. Add another function to update a buffer instead. This will
allow zimage to use this feature.

Also add a lot more tests to cover various cases.

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

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

bootm: Update bootm_process_cmdline_env() to use flags

At present only one transformation is supported: making the Linux console
silent. To prepare for adding more, convert the boolean parameter into a
flag value.

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

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

bootm: Add a bool parameter to bootm_process_cmdline_env()

This function will soon do more than just handle the 'silent linux'
feature. As a first step, update it to take a boolean parameter,
indicating whether or not the processing is required.

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

# 4dcb8154 05-Nov-2020 Simon Glass <sjg@chromium.org>

bootm: Rename fixup_silent_linux()

We want to add more processing to this function. Before doing so, rename
it to bootm_process_cmdline_env(), which is more generic.

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

# 4ae42643 05-Nov-2020 Simon Glass <sjg@chromium.org>

bootm: Update fixup_silent_linux() to return an error

At present this function fails silently on error. Update it to produce
an error code. Report this error to the user and abort the boot, since it
likely will prevent a successful start.

No tests are added at this stage, since additional refactoring is taking
place in subsequent patches.

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

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

bootm: Add tests for fixup_silent_linux()

This function currently has no tests. Export it so that we can implement
a simple test on sandbox. Use IS_ENABLED() to remove the unused code,
instead #ifdef.

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

# 73fdb955 14-Sep-2020 Heinrich Schuchardt <xypron.glpk@gmx.de>

bootm: add {arch,board}_preboot_os() to bootm.h

Functions that are used in multiple C modules should be defined in an
include.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Michael Walle <michael@walle.cc>

# fbde7589 12-Jun-2020 Tero Kristo <t-kristo@ti.com>

common: bootm: add checks to verify if ramdisk / fdtimage overlaps OS image

These cases are typically fatal and are difficult to debug for random
users. Add checks for detecting overlapping images and abort if overlap
is detected.

Signed-off-by: Tero Kristo <t-kristo@ti.com>

# 09140113 10-May-2020 Simon Glass <sjg@chromium.org>

command: Remove the cmd_tbl_t typedef

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 <sjg@chromium.org>

# 2090854c 24-Jul-2019 Julius Werner <jwerner@chromium.org>

common: Move bootm_decomp_image() to image.c (as image_decomp())

Upcoming patches want to add decompression to use cases that are no
longer directly related to booting. It makes sense to retain a single
decompression routine, but it should no longer be in bootm.c (which is
not compiled for all configurations). This patch moves
bootm_decomp_image() to image.c and renames it to image_decomp() in
preparation of those upcoming patches.

Signed-off-by: Julius Werner <jwerner@chromium.org>
Reviewed-by: Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com>
[trini: Fix warning around handle_decomp_error being unused]
Signed-off-by: Tom Rini <trini@konsulko.com>

# 93e07880 03-May-2019 Fabrice Fontaine <fontaine.fabrice@gmail.com>

Make FIT support really optional

Due to some mistakes in the source code, it was not possible to really
turn FIT support off. This commit fixes the problem by means of the
following changes:

- Enclose "bootm_host_load_image" and "bootm_host_load_images" between
checks for CONFIG_FIT_SIGNATURE, in common/bootm.c.

- Enclose the declaration of "bootm_host_load_images" between checks for
CONFIG_FIT_SIGNATURE, in common/bootm.h.

- Condition the compilation and linking of fit_common.o fit_image.o
image-host.o common/image-fit.o to CONFIG_FIT=y, in tools/Makefile.

Signed-off-by: Carlos Santos <casantos@datacom.ind.br>
[fabio: adapt for 2016.07]
Signed-off-by: Fabio Estevam <festevam@gmail.com>
[Ricardo: fix conditional compilation and linking of the files mentioned above
for 2016.07]
Signed-off-by: Ricardo Martincoski <ricardo.martincoski@gmail.com>
[Jörg: adapt for 2019.01]
Signed-off-by: Jörg Krause <joerg.krause@embedded.rocks>
[Retrieved from:
https://git.buildroot.net/buildroot/tree/package/uboot-tools/0003-Make-FIT-support-really-optional.patch]
Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>

# f6c6df7e 08-Jan-2019 Heinrich Schuchardt <xypron.glpk@gmx.de>

efi_loader: refactor switch to non-secure mode

Refactor the switch from supervisor to hypervisor to a new function called
at the beginning of do_bootefi().

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Alexander Graf <agraf@suse.de>

# f2a53c76 21-Dec-2018 Bin Meng <bmeng.cn@gmail.com>

bootm: vxworks: Make do_bootm_vxworks() non-static

For future extension to other architectures, make do_bootm_vxworks()
a non-static function.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>

# 896019b1 16-May-2018 Simon Glass <sjg@chromium.org>

Add a comment for board_quiesce_devices()

This exported function should have a comment describing what it does. Also
it should really be removed in favour of device_remove(), which handles
this sort of thing now. Add a comment with a TODO.

Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Alexander Graf <agraf@suse.de>

# 329da485 16-May-2018 Simon Glass <sjg@chromium.org>

Define board_quiesce_devices() in a shared location

This undocumented function relies on arch-specific code to declare a nop
weak version. Add the weak function in common code instead to avoid having
to duplicate the same function in each arch.

Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Alexander Graf <agraf@suse.de>

# 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>

# d52e8575 21-May-2015 Karl Apsite <Karl.Apsite@dornerworks.com>

Combine bootm_find_<thing> functions together

bootm_find_ramdisk_fdt() renamed to bootm_find_images() for readability.

The function bootm_find_ramdisk_fdt() appears to be a simple wrapper for
bootm_find_ramdisk(), bootm_find_fdt(), and now bootm_find_loadables().
I didn't see any other callers entering a bootm_find<thing>, so removing
the wrapper, and condensing these together hopefully makes the code a
little simpler.

Signed-off-by: Karl Apsite <Karl.Apsite@dornerworks.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 081cc197 02-Dec-2014 Simon Glass <sjg@chromium.org>

bootm: Export bootm_decomp_image()

Export this function for testing. Also add a parameter so that values other
than CONFIG_SYS_BOOTM_LEN can be used for the maximum uncompressed size.

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

# f1bd871a 08-Oct-2014 Jeroen Hofstee <jeroen@myspectrum.nl>

bootm: add prototype for arch_preboot_os

Signed-off-by: Jeroen Hofstee <jeroen@myspectrum.nl>

# d2b2ffe3 14-Aug-2014 Tom Rini <trini@konsulko.com>

cmd_bootm.c: Add 'booti' for ARM64 Linux kernel Images

The default format for arm64 Linux kernels is the "Image" format,
described in Documentation/arm64/booting.txt. This, along with an
optional gzip compression on top is all that is generated by default.
The Image format has a magic number within the header for verification,
a text_offset where the Image must be run from, an image_size that
includes the BSS and reserved fields.

This does not support automatic detection of a gzip compressed image.

Signed-off-by: Tom Rini <trini@ti.com>

# ce1400f6 12-Jun-2014 Simon Glass <sjg@chromium.org>

Enhance fit_check_sign to check all images

At present this tool only checks the configuration signing. Have it also
look at each of the images in the configuration and confirm that they
verify.

Signed-off-by: Simon Glass <sjg@chromium.org>
Acked-by: Heiko Schocher <hs@denx.de> (v1)

# b6396403 12-Jun-2014 Simon Glass <sjg@chromium.org>

bootm: Split out code from cmd_bootm.c

This file has code in three different categories:
- Command processing
- OS-specific boot code
- Locating images and setting up to boot

Only the first category really belongs in a file called cmd_bootm.c.

Leave the command processing code where it is. Split out the OS-specific
boot code into bootm_os.c. Split out the other code into bootm.c

Header files and extern declarations are tidied but otherwise no code
changes are made, to make it easier to review.

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

# d9d7c20b 06-Sep-2022 Simon Glass <sjg@chromium.org>

treewide: Drop bootm_headers_t typedef

This is not needed and we should avoid typedefs. Use the struct instead.

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>

# 7e713067 26-Oct-2021 Thomas Huth <thuth@redhat.com>

Remove LYNX KDI remainders

The last board that used to set CONFIG_LYNXKDI has been removed in
commit 242836a893ae ("powerpc: ppc4xx: remove pcs440ep support"),
doc/README.lynxkdi only talks about a MPC8260 board being supported,
and the mpc8260 support has been removed four years ago in commit
2eb48ff7a210d ("powerpc, 8260: remove support for mpc8260") already,
and common/lynxkdi.c only consists of an "#error" statement these
days, so it seems like the LYNX KDI code is dead code nowadays.
Let's remove it now.

Signed-off-by: Thomas Huth <thuth@redhat.com>

# 51bb3384 05-Nov-2020 Simon Glass <sjg@chromium.org>

bootm: Support string substitution in bootargs

In some cases it is necessary to pass parameters to Linux so that it will
boot correctly. For example, the rootdev parameter is often used to
specify the root device. However the root device may change depending on
whence U-Boot loads the kernel. At present it is necessary to build up
the command line by adding device strings to it one by one.

It is often more convenient to provide a template for bootargs, with
U-Boot doing the substitution from other environment variables.

Add a way to substitute strings in the bootargs variable. This allows
things like "rootdev=${rootdev}" to be used in bootargs, with the
${rootdev} substitution providing the UUID of the root device.

For example, to substitute the GUID of the kernel partition:

setenv bootargs "console=/dev/ttyS0 rootdev=${uuid}/PARTNROFF=1
kern_guid=${uuid}"
part uuid mmc 2:2 uuid
bootm

This is particularly useful when the command line from another place. For
example, Chrome OS stores the command line next to the kernel itself. It
depends on the kernel version being used as well as the hardware features,
so it is extremely difficult to devise a U-Boot script that works on all
boards and kernel versions. With this feature, the command line can be
read from disk and used directly, with a few substitutions set up.

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

# 4448fe8e 05-Nov-2020 Simon Glass <sjg@chromium.org>

bootm: Allow updating the bootargs in a buffer

At present we only support updating the 'bootargs' environment
variable. Add another function to update a buffer instead. This will
allow zimage to use this feature.

Also add a lot more tests to cover various cases.

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

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

bootm: Update bootm_process_cmdline_env() to use flags

At present only one transformation is supported: making the Linux console
silent. To prepare for adding more, convert the boolean parameter into a
flag value.

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

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

bootm: Add a bool parameter to bootm_process_cmdline_env()

This function will soon do more than just handle the 'silent linux'
feature. As a first step, update it to take a boolean parameter,
indicating whether or not the processing is required.

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

# 4dcb8154 05-Nov-2020 Simon Glass <sjg@chromium.org>

bootm: Rename fixup_silent_linux()

We want to add more processing to this function. Before doing so, rename
it to bootm_process_cmdline_env(), which is more generic.

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

# 4ae42643 05-Nov-2020 Simon Glass <sjg@chromium.org>

bootm: Update fixup_silent_linux() to return an error

At present this function fails silently on error. Update it to produce
an error code. Report this error to the user and abort the boot, since it
likely will prevent a successful start.

No tests are added at this stage, since additional refactoring is taking
place in subsequent patches.

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

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

bootm: Add tests for fixup_silent_linux()

This function currently has no tests. Export it so that we can implement
a simple test on sandbox. Use IS_ENABLED() to remove the unused code,
instead #ifdef.

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

# 73fdb955 14-Sep-2020 Heinrich Schuchardt <xypron.glpk@gmx.de>

bootm: add {arch,board}_preboot_os() to bootm.h

Functions that are used in multiple C modules should be defined in an
include.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Michael Walle <michael@walle.cc>

# fbde7589 12-Jun-2020 Tero Kristo <t-kristo@ti.com>

common: bootm: add checks to verify if ramdisk / fdtimage overlaps OS image

These cases are typically fatal and are difficult to debug for random
users. Add checks for detecting overlapping images and abort if overlap
is detected.

Signed-off-by: Tero Kristo <t-kristo@ti.com>

# 09140113 10-May-2020 Simon Glass <sjg@chromium.org>

command: Remove the cmd_tbl_t typedef

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 <sjg@chromium.org>

# 2090854c 24-Jul-2019 Julius Werner <jwerner@chromium.org>

common: Move bootm_decomp_image() to image.c (as image_decomp())

Upcoming patches want to add decompression to use cases that are no
longer directly related to booting. It makes sense to retain a single
decompression routine, but it should no longer be in bootm.c (which is
not compiled for all configurations). This patch moves
bootm_decomp_image() to image.c and renames it to image_decomp() in
preparation of those upcoming patches.

Signed-off-by: Julius Werner <jwerner@chromium.org>
Reviewed-by: Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com>
[trini: Fix warning around handle_decomp_error being unused]
Signed-off-by: Tom Rini <trini@konsulko.com>

# 93e07880 03-May-2019 Fabrice Fontaine <fontaine.fabrice@gmail.com>

Make FIT support really optional

Due to some mistakes in the source code, it was not possible to really
turn FIT support off. This commit fixes the problem by means of the
following changes:

- Enclose "bootm_host_load_image" and "bootm_host_load_images" between
checks for CONFIG_FIT_SIGNATURE, in common/bootm.c.

- Enclose the declaration of "bootm_host_load_images" between checks for
CONFIG_FIT_SIGNATURE, in common/bootm.h.

- Condition the compilation and linking of fit_common.o fit_image.o
image-host.o common/image-fit.o to CONFIG_FIT=y, in tools/Makefile.

Signed-off-by: Carlos Santos <casantos@datacom.ind.br>
[fabio: adapt for 2016.07]
Signed-off-by: Fabio Estevam <festevam@gmail.com>
[Ricardo: fix conditional compilation and linking of the files mentioned above
for 2016.07]
Signed-off-by: Ricardo Martincoski <ricardo.martincoski@gmail.com>
[Jörg: adapt for 2019.01]
Signed-off-by: Jörg Krause <joerg.krause@embedded.rocks>
[Retrieved from:
https://git.buildroot.net/buildroot/tree/package/uboot-tools/0003-Make-FIT-support-really-optional.patch]
Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>

# f6c6df7e 08-Jan-2019 Heinrich Schuchardt <xypron.glpk@gmx.de>

efi_loader: refactor switch to non-secure mode

Refactor the switch from supervisor to hypervisor to a new function called
at the beginning of do_bootefi().

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Alexander Graf <agraf@suse.de>

# f2a53c76 21-Dec-2018 Bin Meng <bmeng.cn@gmail.com>

bootm: vxworks: Make do_bootm_vxworks() non-static

For future extension to other architectures, make do_bootm_vxworks()
a non-static function.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>

# 896019b1 16-May-2018 Simon Glass <sjg@chromium.org>

Add a comment for board_quiesce_devices()

This exported function should have a comment describing what it does. Also
it should really be removed in favour of device_remove(), which handles
this sort of thing now. Add a comment with a TODO.

Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Alexander Graf <agraf@suse.de>

# 329da485 16-May-2018 Simon Glass <sjg@chromium.org>

Define board_quiesce_devices() in a shared location

This undocumented function relies on arch-specific code to declare a nop
weak version. Add the weak function in common code instead to avoid having
to duplicate the same function in each arch.

Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Alexander Graf <agraf@suse.de>

# 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>

# d52e8575 21-May-2015 Karl Apsite <Karl.Apsite@dornerworks.com>

Combine bootm_find_<thing> functions together

bootm_find_ramdisk_fdt() renamed to bootm_find_images() for readability.

The function bootm_find_ramdisk_fdt() appears to be a simple wrapper for
bootm_find_ramdisk(), bootm_find_fdt(), and now bootm_find_loadables().
I didn't see any other callers entering a bootm_find<thing>, so removing
the wrapper, and condensing these together hopefully makes the code a
little simpler.

Signed-off-by: Karl Apsite <Karl.Apsite@dornerworks.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 081cc197 02-Dec-2014 Simon Glass <sjg@chromium.org>

bootm: Export bootm_decomp_image()

Export this function for testing. Also add a parameter so that values other
than CONFIG_SYS_BOOTM_LEN can be used for the maximum uncompressed size.

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

# f1bd871a 08-Oct-2014 Jeroen Hofstee <jeroen@myspectrum.nl>

bootm: add prototype for arch_preboot_os

Signed-off-by: Jeroen Hofstee <jeroen@myspectrum.nl>

# d2b2ffe3 14-Aug-2014 Tom Rini <trini@konsulko.com>

cmd_bootm.c: Add 'booti' for ARM64 Linux kernel Images

The default format for arm64 Linux kernels is the "Image" format,
described in Documentation/arm64/booting.txt. This, along with an
optional gzip compression on top is all that is generated by default.
The Image format has a magic number within the header for verification,
a text_offset where the Image must be run from, an image_size that
includes the BSS and reserved fields.

This does not support automatic detection of a gzip compressed image.

Signed-off-by: Tom Rini <trini@ti.com>

# ce1400f6 12-Jun-2014 Simon Glass <sjg@chromium.org>

Enhance fit_check_sign to check all images

At present this tool only checks the configuration signing. Have it also
look at each of the images in the configuration and confirm that they
verify.

Signed-off-by: Simon Glass <sjg@chromium.org>
Acked-by: Heiko Schocher <hs@denx.de> (v1)

# b6396403 12-Jun-2014 Simon Glass <sjg@chromium.org>

bootm: Split out code from cmd_bootm.c

This file has code in three different categories:
- Command processing
- OS-specific boot code
- Locating images and setting up to boot

Only the first category really belongs in a file called cmd_bootm.c.

Leave the command processing code where it is. Split out the OS-specific
boot code into bootm_os.c. Split out the other code into bootm.c

Header files and extern declarations are tidied but otherwise no code
changes are made, to make it easier to review.

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>

# 7e713067 26-Oct-2021 Thomas Huth <thuth@redhat.com>

Remove LYNX KDI remainders

The last board that used to set CONFIG_LYNXKDI has been removed in
commit 242836a893ae ("powerpc: ppc4xx: remove pcs440ep support"),
doc/README.lynxkdi only talks about a MPC8260 board being supported,
and the mpc8260 support has been removed four years ago in commit
2eb48ff7a210d ("powerpc, 8260: remove support for mpc8260") already,
and common/lynxkdi.c only consists of an "#error" statement these
days, so it seems like the LYNX KDI code is dead code nowadays.
Let's remove it now.

Signed-off-by: Thomas Huth <thuth@redhat.com>

# 51bb3384 05-Nov-2020 Simon Glass <sjg@chromium.org>

bootm: Support string substitution in bootargs

In some cases it is necessary to pass parameters to Linux so that it will
boot correctly. For example, the rootdev parameter is often used to
specify the root device. However the root device may change depending on
whence U-Boot loads the kernel. At present it is necessary to build up
the command line by adding device strings to it one by one.

It is often more convenient to provide a template for bootargs, with
U-Boot doing the substitution from other environment variables.

Add a way to substitute strings in the bootargs variable. This allows
things like "rootdev=${rootdev}" to be used in bootargs, with the
${rootdev} substitution providing the UUID of the root device.

For example, to substitute the GUID of the kernel partition:

setenv bootargs "console=/dev/ttyS0 rootdev=${uuid}/PARTNROFF=1
kern_guid=${uuid}"
part uuid mmc 2:2 uuid
bootm

This is particularly useful when the command line from another place. For
example, Chrome OS stores the command line next to the kernel itself. It
depends on the kernel version being used as well as the hardware features,
so it is extremely difficult to devise a U-Boot script that works on all
boards and kernel versions. With this feature, the command line can be
read from disk and used directly, with a few substitutions set up.

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

# 4448fe8e 05-Nov-2020 Simon Glass <sjg@chromium.org>

bootm: Allow updating the bootargs in a buffer

At present we only support updating the 'bootargs' environment
variable. Add another function to update a buffer instead. This will
allow zimage to use this feature.

Also add a lot more tests to cover various cases.

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

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

bootm: Update bootm_process_cmdline_env() to use flags

At present only one transformation is supported: making the Linux console
silent. To prepare for adding more, convert the boolean parameter into a
flag value.

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

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

bootm: Add a bool parameter to bootm_process_cmdline_env()

This function will soon do more than just handle the 'silent linux'
feature. As a first step, update it to take a boolean parameter,
indicating whether or not the processing is required.

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

# 4dcb8154 05-Nov-2020 Simon Glass <sjg@chromium.org>

bootm: Rename fixup_silent_linux()

We want to add more processing to this function. Before doing so, rename
it to bootm_process_cmdline_env(), which is more generic.

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

# 4ae42643 05-Nov-2020 Simon Glass <sjg@chromium.org>

bootm: Update fixup_silent_linux() to return an error

At present this function fails silently on error. Update it to produce
an error code. Report this error to the user and abort the boot, since it
likely will prevent a successful start.

No tests are added at this stage, since additional refactoring is taking
place in subsequent patches.

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

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

bootm: Add tests for fixup_silent_linux()

This function currently has no tests. Export it so that we can implement
a simple test on sandbox. Use IS_ENABLED() to remove the unused code,
instead #ifdef.

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

# 73fdb955 14-Sep-2020 Heinrich Schuchardt <xypron.glpk@gmx.de>

bootm: add {arch,board}_preboot_os() to bootm.h

Functions that are used in multiple C modules should be defined in an
include.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Michael Walle <michael@walle.cc>

# fbde7589 12-Jun-2020 Tero Kristo <t-kristo@ti.com>

common: bootm: add checks to verify if ramdisk / fdtimage overlaps OS image

These cases are typically fatal and are difficult to debug for random
users. Add checks for detecting overlapping images and abort if overlap
is detected.

Signed-off-by: Tero Kristo <t-kristo@ti.com>

# 09140113 10-May-2020 Simon Glass <sjg@chromium.org>

command: Remove the cmd_tbl_t typedef

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 <sjg@chromium.org>

# 2090854c 24-Jul-2019 Julius Werner <jwerner@chromium.org>

common: Move bootm_decomp_image() to image.c (as image_decomp())

Upcoming patches want to add decompression to use cases that are no
longer directly related to booting. It makes sense to retain a single
decompression routine, but it should no longer be in bootm.c (which is
not compiled for all configurations). This patch moves
bootm_decomp_image() to image.c and renames it to image_decomp() in
preparation of those upcoming patches.

Signed-off-by: Julius Werner <jwerner@chromium.org>
Reviewed-by: Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com>
[trini: Fix warning around handle_decomp_error being unused]
Signed-off-by: Tom Rini <trini@konsulko.com>

# 93e07880 03-May-2019 Fabrice Fontaine <fontaine.fabrice@gmail.com>

Make FIT support really optional

Due to some mistakes in the source code, it was not possible to really
turn FIT support off. This commit fixes the problem by means of the
following changes:

- Enclose "bootm_host_load_image" and "bootm_host_load_images" between
checks for CONFIG_FIT_SIGNATURE, in common/bootm.c.

- Enclose the declaration of "bootm_host_load_images" between checks for
CONFIG_FIT_SIGNATURE, in common/bootm.h.

- Condition the compilation and linking of fit_common.o fit_image.o
image-host.o common/image-fit.o to CONFIG_FIT=y, in tools/Makefile.

Signed-off-by: Carlos Santos <casantos@datacom.ind.br>
[fabio: adapt for 2016.07]
Signed-off-by: Fabio Estevam <festevam@gmail.com>
[Ricardo: fix conditional compilation and linking of the files mentioned above
for 2016.07]
Signed-off-by: Ricardo Martincoski <ricardo.martincoski@gmail.com>
[Jörg: adapt for 2019.01]
Signed-off-by: Jörg Krause <joerg.krause@embedded.rocks>
[Retrieved from:
https://git.buildroot.net/buildroot/tree/package/uboot-tools/0003-Make-FIT-support-really-optional.patch]
Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>

# f6c6df7e 08-Jan-2019 Heinrich Schuchardt <xypron.glpk@gmx.de>

efi_loader: refactor switch to non-secure mode

Refactor the switch from supervisor to hypervisor to a new function called
at the beginning of do_bootefi().

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Alexander Graf <agraf@suse.de>

# f2a53c76 21-Dec-2018 Bin Meng <bmeng.cn@gmail.com>

bootm: vxworks: Make do_bootm_vxworks() non-static

For future extension to other architectures, make do_bootm_vxworks()
a non-static function.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>

# 896019b1 16-May-2018 Simon Glass <sjg@chromium.org>

Add a comment for board_quiesce_devices()

This exported function should have a comment describing what it does. Also
it should really be removed in favour of device_remove(), which handles
this sort of thing now. Add a comment with a TODO.

Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Alexander Graf <agraf@suse.de>

# 329da485 16-May-2018 Simon Glass <sjg@chromium.org>

Define board_quiesce_devices() in a shared location

This undocumented function relies on arch-specific code to declare a nop
weak version. Add the weak function in common code instead to avoid having
to duplicate the same function in each arch.

Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Alexander Graf <agraf@suse.de>

# 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>

# d52e8575 21-May-2015 Karl Apsite <Karl.Apsite@dornerworks.com>

Combine bootm_find_<thing> functions together

bootm_find_ramdisk_fdt() renamed to bootm_find_images() for readability.

The function bootm_find_ramdisk_fdt() appears to be a simple wrapper for
bootm_find_ramdisk(), bootm_find_fdt(), and now bootm_find_loadables().
I didn't see any other callers entering a bootm_find<thing>, so removing
the wrapper, and condensing these together hopefully makes the code a
little simpler.

Signed-off-by: Karl Apsite <Karl.Apsite@dornerworks.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 081cc197 02-Dec-2014 Simon Glass <sjg@chromium.org>

bootm: Export bootm_decomp_image()

Export this function for testing. Also add a parameter so that values other
than CONFIG_SYS_BOOTM_LEN can be used for the maximum uncompressed size.

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

# f1bd871a 08-Oct-2014 Jeroen Hofstee <jeroen@myspectrum.nl>

bootm: add prototype for arch_preboot_os

Signed-off-by: Jeroen Hofstee <jeroen@myspectrum.nl>

# d2b2ffe3 14-Aug-2014 Tom Rini <trini@ti.com>

cmd_bootm.c: Add 'booti' for ARM64 Linux kernel Images

The default format for arm64 Linux kernels is the "Image" format,
described in Documentation/arm64/booting.txt. This, along with an
optional gzip compression on top is all that is generated by default.
The Image format has a magic number within the header for verification,
a text_offset where the Image must be run from, an image_size that
includes the BSS and reserved fields.

This does not support automatic detection of a gzip compressed image.

Signed-off-by: Tom Rini <trini@ti.com>

# ce1400f6 12-Jun-2014 Simon Glass <sjg@chromium.org>

Enhance fit_check_sign to check all images

At present this tool only checks the configuration signing. Have it also
look at each of the images in the configuration and confirm that they
verify.

Signed-off-by: Simon Glass <sjg@chromium.org>
Acked-by: Heiko Schocher <hs@denx.de> (v1)

# b6396403 12-Jun-2014 Simon Glass <sjg@chromium.org>

bootm: Split out code from cmd_bootm.c

This file has code in three different categories:
- Command processing
- OS-specific boot code
- Locating images and setting up to boot

Only the first category really belongs in a file called cmd_bootm.c.

Leave the command processing code where it is. Split out the OS-specific
boot code into bootm_os.c. Split out the other code into bootm.c

Header files and extern declarations are tidied but otherwise no code
changes are made, to make it easier to review.

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

# 7e713067 26-Oct-2021 Thomas Huth <thuth@redhat.com>

Remove LYNX KDI remainders

The last board that used to set CONFIG_LYNXKDI has been removed in
commit 242836a893ae ("powerpc: ppc4xx: remove pcs440ep support"),
doc/README.lynxkdi only talks about a MPC8260 board being supported,
and the mpc8260 support has been removed four years ago in commit
2eb48ff7a210d ("powerpc, 8260: remove support for mpc8260") already,
and common/lynxkdi.c only consists of an "#error" statement these
days, so it seems like the LYNX KDI code is dead code nowadays.
Let's remove it now.

Signed-off-by: Thomas Huth <thuth@redhat.com>

# 51bb3384 05-Nov-2020 Simon Glass <sjg@chromium.org>

bootm: Support string substitution in bootargs

In some cases it is necessary to pass parameters to Linux so that it will
boot correctly. For example, the rootdev parameter is often used to
specify the root device. However the root device may change depending on
whence U-Boot loads the kernel. At present it is necessary to build up
the command line by adding device strings to it one by one.

It is often more convenient to provide a template for bootargs, with
U-Boot doing the substitution from other environment variables.

Add a way to substitute strings in the bootargs variable. This allows
things like "rootdev=${rootdev}" to be used in bootargs, with the
${rootdev} substitution providing the UUID of the root device.

For example, to substitute the GUID of the kernel partition:

setenv bootargs "console=/dev/ttyS0 rootdev=${uuid}/PARTNROFF=1
kern_guid=${uuid}"
part uuid mmc 2:2 uuid
bootm

This is particularly useful when the command line from another place. For
example, Chrome OS stores the command line next to the kernel itself. It
depends on the kernel version being used as well as the hardware features,
so it is extremely difficult to devise a U-Boot script that works on all
boards and kernel versions. With this feature, the command line can be
read from disk and used directly, with a few substitutions set up.

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

# 4448fe8e 05-Nov-2020 Simon Glass <sjg@chromium.org>

bootm: Allow updating the bootargs in a buffer

At present we only support updating the 'bootargs' environment
variable. Add another function to update a buffer instead. This will
allow zimage to use this feature.

Also add a lot more tests to cover various cases.

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

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

bootm: Update bootm_process_cmdline_env() to use flags

At present only one transformation is supported: making the Linux console
silent. To prepare for adding more, convert the boolean parameter into a
flag value.

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

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

bootm: Add a bool parameter to bootm_process_cmdline_env()

This function will soon do more than just handle the 'silent linux'
feature. As a first step, update it to take a boolean parameter,
indicating whether or not the processing is required.

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

# 4dcb8154 05-Nov-2020 Simon Glass <sjg@chromium.org>

bootm: Rename fixup_silent_linux()

We want to add more processing to this function. Before doing so, rename
it to bootm_process_cmdline_env(), which is more generic.

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

# 4ae42643 05-Nov-2020 Simon Glass <sjg@chromium.org>

bootm: Update fixup_silent_linux() to return an error

At present this function fails silently on error. Update it to produce
an error code. Report this error to the user and abort the boot, since it
likely will prevent a successful start.

No tests are added at this stage, since additional refactoring is taking
place in subsequent patches.

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

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

bootm: Add tests for fixup_silent_linux()

This function currently has no tests. Export it so that we can implement
a simple test on sandbox. Use IS_ENABLED() to remove the unused code,
instead #ifdef.

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

# 73fdb955 14-Sep-2020 Heinrich Schuchardt <xypron.glpk@gmx.de>

bootm: add {arch,board}_preboot_os() to bootm.h

Functions that are used in multiple C modules should be defined in an
include.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Michael Walle <michael@walle.cc>

# fbde7589 12-Jun-2020 Tero Kristo <t-kristo@ti.com>

common: bootm: add checks to verify if ramdisk / fdtimage overlaps OS image

These cases are typically fatal and are difficult to debug for random
users. Add checks for detecting overlapping images and abort if overlap
is detected.

Signed-off-by: Tero Kristo <t-kristo@ti.com>

# 09140113 10-May-2020 Simon Glass <sjg@chromium.org>

command: Remove the cmd_tbl_t typedef

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 <sjg@chromium.org>

# 2090854c 24-Jul-2019 Julius Werner <jwerner@chromium.org>

common: Move bootm_decomp_image() to image.c (as image_decomp())

Upcoming patches want to add decompression to use cases that are no
longer directly related to booting. It makes sense to retain a single
decompression routine, but it should no longer be in bootm.c (which is
not compiled for all configurations). This patch moves
bootm_decomp_image() to image.c and renames it to image_decomp() in
preparation of those upcoming patches.

Signed-off-by: Julius Werner <jwerner@chromium.org>
Reviewed-by: Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com>
[trini: Fix warning around handle_decomp_error being unused]
Signed-off-by: Tom Rini <trini@konsulko.com>

# 93e07880 03-May-2019 Fabrice Fontaine <fontaine.fabrice@gmail.com>

Make FIT support really optional

Due to some mistakes in the source code, it was not possible to really
turn FIT support off. This commit fixes the problem by means of the
following changes:

- Enclose "bootm_host_load_image" and "bootm_host_load_images" between
checks for CONFIG_FIT_SIGNATURE, in common/bootm.c.

- Enclose the declaration of "bootm_host_load_images" between checks for
CONFIG_FIT_SIGNATURE, in common/bootm.h.

- Condition the compilation and linking of fit_common.o fit_image.o
image-host.o common/image-fit.o to CONFIG_FIT=y, in tools/Makefile.

Signed-off-by: Carlos Santos <casantos@datacom.ind.br>
[fabio: adapt for 2016.07]
Signed-off-by: Fabio Estevam <festevam@gmail.com>
[Ricardo: fix conditional compilation and linking of the files mentioned above
for 2016.07]
Signed-off-by: Ricardo Martincoski <ricardo.martincoski@gmail.com>
[Jörg: adapt for 2019.01]
Signed-off-by: Jörg Krause <joerg.krause@embedded.rocks>
[Retrieved from:
https://git.buildroot.net/buildroot/tree/package/uboot-tools/0003-Make-FIT-support-really-optional.patch]
Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>

# f6c6df7e 08-Jan-2019 Heinrich Schuchardt <xypron.glpk@gmx.de>

efi_loader: refactor switch to non-secure mode

Refactor the switch from supervisor to hypervisor to a new function called
at the beginning of do_bootefi().

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Alexander Graf <agraf@suse.de>

# f2a53c76 21-Dec-2018 Bin Meng <bmeng.cn@gmail.com>

bootm: vxworks: Make do_bootm_vxworks() non-static

For future extension to other architectures, make do_bootm_vxworks()
a non-static function.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>

# 896019b1 16-May-2018 Simon Glass <sjg@chromium.org>

Add a comment for board_quiesce_devices()

This exported function should have a comment describing what it does. Also
it should really be removed in favour of device_remove(), which handles
this sort of thing now. Add a comment with a TODO.

Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Alexander Graf <agraf@suse.de>

# 329da485 16-May-2018 Simon Glass <sjg@chromium.org>

Define board_quiesce_devices() in a shared location

This undocumented function relies on arch-specific code to declare a nop
weak version. Add the weak function in common code instead to avoid having
to duplicate the same function in each arch.

Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Alexander Graf <agraf@suse.de>

# 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>

# d52e8575 21-May-2015 Karl Apsite <Karl.Apsite@dornerworks.com>

Combine bootm_find_<thing> functions together

bootm_find_ramdisk_fdt() renamed to bootm_find_images() for readability.

The function bootm_find_ramdisk_fdt() appears to be a simple wrapper for
bootm_find_ramdisk(), bootm_find_fdt(), and now bootm_find_loadables().
I didn't see any other callers entering a bootm_find<thing>, so removing
the wrapper, and condensing these together hopefully makes the code a
little simpler.

Signed-off-by: Karl Apsite <Karl.Apsite@dornerworks.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 081cc197 02-Dec-2014 Simon Glass <sjg@chromium.org>

bootm: Export bootm_decomp_image()

Export this function for testing. Also add a parameter so that values other
than CONFIG_SYS_BOOTM_LEN can be used for the maximum uncompressed size.

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

# f1bd871a 08-Oct-2014 Jeroen Hofstee <jeroen@myspectrum.nl>

bootm: add prototype for arch_preboot_os

Signed-off-by: Jeroen Hofstee <jeroen@myspectrum.nl>

# d2b2ffe3 14-Aug-2014 Tom Rini <trini@ti.com>

cmd_bootm.c: Add 'booti' for ARM64 Linux kernel Images

The default format for arm64 Linux kernels is the "Image" format,
described in Documentation/arm64/booting.txt. This, along with an
optional gzip compression on top is all that is generated by default.
The Image format has a magic number within the header for verification,
a text_offset where the Image must be run from, an image_size that
includes the BSS and reserved fields.

This does not support automatic detection of a gzip compressed image.

Signed-off-by: Tom Rini <trini@ti.com>

# ce1400f6 12-Jun-2014 Simon Glass <sjg@chromium.org>

Enhance fit_check_sign to check all images

At present this tool only checks the configuration signing. Have it also
look at each of the images in the configuration and confirm that they
verify.

Signed-off-by: Simon Glass <sjg@chromium.org>
Acked-by: Heiko Schocher <hs@denx.de> (v1)

# b6396403 12-Jun-2014 Simon Glass <sjg@chromium.org>

bootm: Split out code from cmd_bootm.c

This file has code in three different categories:
- Command processing
- OS-specific boot code
- Locating images and setting up to boot

Only the first category really belongs in a file called cmd_bootm.c.

Leave the command processing code where it is. Split out the OS-specific
boot code into bootm_os.c. Split out the other code into bootm.c

Header files and extern declarations are tidied but otherwise no code
changes are made, to make it easier to review.

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

# 51bb3384 05-Nov-2020 Simon Glass <sjg@chromium.org>

bootm: Support string substitution in bootargs

In some cases it is necessary to pass parameters to Linux so that it will
boot correctly. For example, the rootdev parameter is often used to
specify the root device. However the root device may change depending on
whence U-Boot loads the kernel. At present it is necessary to build up
the command line by adding device strings to it one by one.

It is often more convenient to provide a template for bootargs, with
U-Boot doing the substitution from other environment variables.

Add a way to substitute strings in the bootargs variable. This allows
things like "rootdev=${rootdev}" to be used in bootargs, with the
${rootdev} substitution providing the UUID of the root device.

For example, to substitute the GUID of the kernel partition:

setenv bootargs "console=/dev/ttyS0 rootdev=${uuid}/PARTNROFF=1
kern_guid=${uuid}"
part uuid mmc 2:2 uuid
bootm

This is particularly useful when the command line from another place. For
example, Chrome OS stores the command line next to the kernel itself. It
depends on the kernel version being used as well as the hardware features,
so it is extremely difficult to devise a U-Boot script that works on all
boards and kernel versions. With this feature, the command line can be
read from disk and used directly, with a few substitutions set up.

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

# 4448fe8e 05-Nov-2020 Simon Glass <sjg@chromium.org>

bootm: Allow updating the bootargs in a buffer

At present we only support updating the 'bootargs' environment
variable. Add another function to update a buffer instead. This will
allow zimage to use this feature.

Also add a lot more tests to cover various cases.

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

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

bootm: Update bootm_process_cmdline_env() to use flags

At present only one transformation is supported: making the Linux console
silent. To prepare for adding more, convert the boolean parameter into a
flag value.

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

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

bootm: Add a bool parameter to bootm_process_cmdline_env()

This function will soon do more than just handle the 'silent linux'
feature. As a first step, update it to take a boolean parameter,
indicating whether or not the processing is required.

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

# 4dcb8154 05-Nov-2020 Simon Glass <sjg@chromium.org>

bootm: Rename fixup_silent_linux()

We want to add more processing to this function. Before doing so, rename
it to bootm_process_cmdline_env(), which is more generic.

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

# 4ae42643 05-Nov-2020 Simon Glass <sjg@chromium.org>

bootm: Update fixup_silent_linux() to return an error

At present this function fails silently on error. Update it to produce
an error code. Report this error to the user and abort the boot, since it
likely will prevent a successful start.

No tests are added at this stage, since additional refactoring is taking
place in subsequent patches.

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

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

bootm: Add tests for fixup_silent_linux()

This function currently has no tests. Export it so that we can implement
a simple test on sandbox. Use IS_ENABLED() to remove the unused code,
instead #ifdef.

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

# 73fdb955 14-Sep-2020 Heinrich Schuchardt <xypron.glpk@gmx.de>

bootm: add {arch,board}_preboot_os() to bootm.h

Functions that are used in multiple C modules should be defined in an
include.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Michael Walle <michael@walle.cc>

# fbde7589 12-Jun-2020 Tero Kristo <t-kristo@ti.com>

common: bootm: add checks to verify if ramdisk / fdtimage overlaps OS image

These cases are typically fatal and are difficult to debug for random
users. Add checks for detecting overlapping images and abort if overlap
is detected.

Signed-off-by: Tero Kristo <t-kristo@ti.com>

# 09140113 10-May-2020 Simon Glass <sjg@chromium.org>

command: Remove the cmd_tbl_t typedef

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 <sjg@chromium.org>

# 2090854c 24-Jul-2019 Julius Werner <jwerner@chromium.org>

common: Move bootm_decomp_image() to image.c (as image_decomp())

Upcoming patches want to add decompression to use cases that are no
longer directly related to booting. It makes sense to retain a single
decompression routine, but it should no longer be in bootm.c (which is
not compiled for all configurations). This patch moves
bootm_decomp_image() to image.c and renames it to image_decomp() in
preparation of those upcoming patches.

Signed-off-by: Julius Werner <jwerner@chromium.org>
Reviewed-by: Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com>
[trini: Fix warning around handle_decomp_error being unused]
Signed-off-by: Tom Rini <trini@konsulko.com>

# 93e07880 03-May-2019 Fabrice Fontaine <fontaine.fabrice@gmail.com>

Make FIT support really optional

Due to some mistakes in the source code, it was not possible to really
turn FIT support off. This commit fixes the problem by means of the
following changes:

- Enclose "bootm_host_load_image" and "bootm_host_load_images" between
checks for CONFIG_FIT_SIGNATURE, in common/bootm.c.

- Enclose the declaration of "bootm_host_load_images" between checks for
CONFIG_FIT_SIGNATURE, in common/bootm.h.

- Condition the compilation and linking of fit_common.o fit_image.o
image-host.o common/image-fit.o to CONFIG_FIT=y, in tools/Makefile.

Signed-off-by: Carlos Santos <casantos@datacom.ind.br>
[fabio: adapt for 2016.07]
Signed-off-by: Fabio Estevam <festevam@gmail.com>
[Ricardo: fix conditional compilation and linking of the files mentioned above
for 2016.07]
Signed-off-by: Ricardo Martincoski <ricardo.martincoski@gmail.com>
[Jörg: adapt for 2019.01]
Signed-off-by: Jörg Krause <joerg.krause@embedded.rocks>
[Retrieved from:
https://git.buildroot.net/buildroot/tree/package/uboot-tools/0003-Make-FIT-support-really-optional.patch]
Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>

# f6c6df7e 08-Jan-2019 Heinrich Schuchardt <xypron.glpk@gmx.de>

efi_loader: refactor switch to non-secure mode

Refactor the switch from supervisor to hypervisor to a new function called
at the beginning of do_bootefi().

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Alexander Graf <agraf@suse.de>

# f2a53c76 21-Dec-2018 Bin Meng <bmeng.cn@gmail.com>

bootm: vxworks: Make do_bootm_vxworks() non-static

For future extension to other architectures, make do_bootm_vxworks()
a non-static function.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>

# 896019b1 16-May-2018 Simon Glass <sjg@chromium.org>

Add a comment for board_quiesce_devices()

This exported function should have a comment describing what it does. Also
it should really be removed in favour of device_remove(), which handles
this sort of thing now. Add a comment with a TODO.

Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Alexander Graf <agraf@suse.de>

# 329da485 16-May-2018 Simon Glass <sjg@chromium.org>

Define board_quiesce_devices() in a shared location

This undocumented function relies on arch-specific code to declare a nop
weak version. Add the weak function in common code instead to avoid having
to duplicate the same function in each arch.

Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Alexander Graf <agraf@suse.de>

# 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>

# d52e8575 21-May-2015 Karl Apsite <Karl.Apsite@dornerworks.com>

Combine bootm_find_<thing> functions together

bootm_find_ramdisk_fdt() renamed to bootm_find_images() for readability.

The function bootm_find_ramdisk_fdt() appears to be a simple wrapper for
bootm_find_ramdisk(), bootm_find_fdt(), and now bootm_find_loadables().
I didn't see any other callers entering a bootm_find<thing>, so removing
the wrapper, and condensing these together hopefully makes the code a
little simpler.

Signed-off-by: Karl Apsite <Karl.Apsite@dornerworks.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 081cc197 02-Dec-2014 Simon Glass <sjg@chromium.org>

bootm: Export bootm_decomp_image()

Export this function for testing. Also add a parameter so that values other
than CONFIG_SYS_BOOTM_LEN can be used for the maximum uncompressed size.

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

# f1bd871a 08-Oct-2014 Jeroen Hofstee <jeroen@myspectrum.nl>

bootm: add prototype for arch_preboot_os

Signed-off-by: Jeroen Hofstee <jeroen@myspectrum.nl>

# d2b2ffe3 14-Aug-2014 Tom Rini <trini@ti.com>

cmd_bootm.c: Add 'booti' for ARM64 Linux kernel Images

The default format for arm64 Linux kernels is the "Image" format,
described in Documentation/arm64/booting.txt. This, along with an
optional gzip compression on top is all that is generated by default.
The Image format has a magic number within the header for verification,
a text_offset where the Image must be run from, an image_size that
includes the BSS and reserved fields.

This does not support automatic detection of a gzip compressed image.

Signed-off-by: Tom Rini <trini@ti.com>

# ce1400f6 12-Jun-2014 Simon Glass <sjg@chromium.org>

Enhance fit_check_sign to check all images

At present this tool only checks the configuration signing. Have it also
look at each of the images in the configuration and confirm that they
verify.

Signed-off-by: Simon Glass <sjg@chromium.org>
Acked-by: Heiko Schocher <hs@denx.de> (v1)

# b6396403 12-Jun-2014 Simon Glass <sjg@chromium.org>

bootm: Split out code from cmd_bootm.c

This file has code in three different categories:
- Command processing
- OS-specific boot code
- Locating images and setting up to boot

Only the first category really belongs in a file called cmd_bootm.c.

Leave the command processing code where it is. Split out the OS-specific
boot code into bootm_os.c. Split out the other code into bootm.c

Header files and extern declarations are tidied but otherwise no code
changes are made, to make it easier to review.

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

# 73fdb955 14-Sep-2020 Heinrich Schuchardt <xypron.glpk@gmx.de>

bootm: add {arch,board}_preboot_os() to bootm.h

Functions that are used in multiple C modules should be defined in an
include.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Michael Walle <michael@walle.cc>

# fbde7589 12-Jun-2020 Tero Kristo <t-kristo@ti.com>

common: bootm: add checks to verify if ramdisk / fdtimage overlaps OS image

These cases are typically fatal and are difficult to debug for random
users. Add checks for detecting overlapping images and abort if overlap
is detected.

Signed-off-by: Tero Kristo <t-kristo@ti.com>

# 09140113 10-May-2020 Simon Glass <sjg@chromium.org>

command: Remove the cmd_tbl_t typedef

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 <sjg@chromium.org>

# 2090854c 24-Jul-2019 Julius Werner <jwerner@chromium.org>

common: Move bootm_decomp_image() to image.c (as image_decomp())

Upcoming patches want to add decompression to use cases that are no
longer directly related to booting. It makes sense to retain a single
decompression routine, but it should no longer be in bootm.c (which is
not compiled for all configurations). This patch moves
bootm_decomp_image() to image.c and renames it to image_decomp() in
preparation of those upcoming patches.

Signed-off-by: Julius Werner <jwerner@chromium.org>
Reviewed-by: Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com>
[trini: Fix warning around handle_decomp_error being unused]
Signed-off-by: Tom Rini <trini@konsulko.com>

# 93e07880 03-May-2019 Fabrice Fontaine <fontaine.fabrice@gmail.com>

Make FIT support really optional

Due to some mistakes in the source code, it was not possible to really
turn FIT support off. This commit fixes the problem by means of the
following changes:

- Enclose "bootm_host_load_image" and "bootm_host_load_images" between
checks for CONFIG_FIT_SIGNATURE, in common/bootm.c.

- Enclose the declaration of "bootm_host_load_images" between checks for
CONFIG_FIT_SIGNATURE, in common/bootm.h.

- Condition the compilation and linking of fit_common.o fit_image.o
image-host.o common/image-fit.o to CONFIG_FIT=y, in tools/Makefile.

Signed-off-by: Carlos Santos <casantos@datacom.ind.br>
[fabio: adapt for 2016.07]
Signed-off-by: Fabio Estevam <festevam@gmail.com>
[Ricardo: fix conditional compilation and linking of the files mentioned above
for 2016.07]
Signed-off-by: Ricardo Martincoski <ricardo.martincoski@gmail.com>
[Jörg: adapt for 2019.01]
Signed-off-by: Jörg Krause <joerg.krause@embedded.rocks>
[Retrieved from:
https://git.buildroot.net/buildroot/tree/package/uboot-tools/0003-Make-FIT-support-really-optional.patch]
Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>

# f6c6df7e 08-Jan-2019 Heinrich Schuchardt <xypron.glpk@gmx.de>

efi_loader: refactor switch to non-secure mode

Refactor the switch from supervisor to hypervisor to a new function called
at the beginning of do_bootefi().

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Alexander Graf <agraf@suse.de>

# f2a53c76 21-Dec-2018 Bin Meng <bmeng.cn@gmail.com>

bootm: vxworks: Make do_bootm_vxworks() non-static

For future extension to other architectures, make do_bootm_vxworks()
a non-static function.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>

# 896019b1 16-May-2018 Simon Glass <sjg@chromium.org>

Add a comment for board_quiesce_devices()

This exported function should have a comment describing what it does. Also
it should really be removed in favour of device_remove(), which handles
this sort of thing now. Add a comment with a TODO.

Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Alexander Graf <agraf@suse.de>

# 329da485 16-May-2018 Simon Glass <sjg@chromium.org>

Define board_quiesce_devices() in a shared location

This undocumented function relies on arch-specific code to declare a nop
weak version. Add the weak function in common code instead to avoid having
to duplicate the same function in each arch.

Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Alexander Graf <agraf@suse.de>

# 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>

# d52e8575 21-May-2015 Karl Apsite <Karl.Apsite@dornerworks.com>

Combine bootm_find_<thing> functions together

bootm_find_ramdisk_fdt() renamed to bootm_find_images() for readability.

The function bootm_find_ramdisk_fdt() appears to be a simple wrapper for
bootm_find_ramdisk(), bootm_find_fdt(), and now bootm_find_loadables().
I didn't see any other callers entering a bootm_find<thing>, so removing
the wrapper, and condensing these together hopefully makes the code a
little simpler.

Signed-off-by: Karl Apsite <Karl.Apsite@dornerworks.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 081cc197 02-Dec-2014 Simon Glass <sjg@chromium.org>

bootm: Export bootm_decomp_image()

Export this function for testing. Also add a parameter so that values other
than CONFIG_SYS_BOOTM_LEN can be used for the maximum uncompressed size.

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

# f1bd871a 08-Oct-2014 Jeroen Hofstee <jeroen@myspectrum.nl>

bootm: add prototype for arch_preboot_os

Signed-off-by: Jeroen Hofstee <jeroen@myspectrum.nl>

# d2b2ffe3 14-Aug-2014 Tom Rini <trini@ti.com>

cmd_bootm.c: Add 'booti' for ARM64 Linux kernel Images

The default format for arm64 Linux kernels is the "Image" format,
described in Documentation/arm64/booting.txt. This, along with an
optional gzip compression on top is all that is generated by default.
The Image format has a magic number within the header for verification,
a text_offset where the Image must be run from, an image_size that
includes the BSS and reserved fields.

This does not support automatic detection of a gzip compressed image.

Signed-off-by: Tom Rini <trini@ti.com>

# ce1400f6 12-Jun-2014 Simon Glass <sjg@chromium.org>

Enhance fit_check_sign to check all images

At present this tool only checks the configuration signing. Have it also
look at each of the images in the configuration and confirm that they
verify.

Signed-off-by: Simon Glass <sjg@chromium.org>
Acked-by: Heiko Schocher <hs@denx.de> (v1)

# b6396403 12-Jun-2014 Simon Glass <sjg@chromium.org>

bootm: Split out code from cmd_bootm.c

This file has code in three different categories:
- Command processing
- OS-specific boot code
- Locating images and setting up to boot

Only the first category really belongs in a file called cmd_bootm.c.

Leave the command processing code where it is. Split out the OS-specific
boot code into bootm_os.c. Split out the other code into bootm.c

Header files and extern declarations are tidied but otherwise no code
changes are made, to make it easier to review.

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

# fbde7589 12-Jun-2020 Tero Kristo <t-kristo@ti.com>

common: bootm: add checks to verify if ramdisk / fdtimage overlaps OS image

These cases are typically fatal and are difficult to debug for random
users. Add checks for detecting overlapping images and abort if overlap
is detected.

Signed-off-by: Tero Kristo <t-kristo@ti.com>

# 09140113 10-May-2020 Simon Glass <sjg@chromium.org>

command: Remove the cmd_tbl_t typedef

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 <sjg@chromium.org>

# 2090854c 24-Jul-2019 Julius Werner <jwerner@chromium.org>

common: Move bootm_decomp_image() to image.c (as image_decomp())

Upcoming patches want to add decompression to use cases that are no
longer directly related to booting. It makes sense to retain a single
decompression routine, but it should no longer be in bootm.c (which is
not compiled for all configurations). This patch moves
bootm_decomp_image() to image.c and renames it to image_decomp() in
preparation of those upcoming patches.

Signed-off-by: Julius Werner <jwerner@chromium.org>
Reviewed-by: Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com>
[trini: Fix warning around handle_decomp_error being unused]
Signed-off-by: Tom Rini <trini@konsulko.com>

# 93e07880 03-May-2019 Fabrice Fontaine <fontaine.fabrice@gmail.com>

Make FIT support really optional

Due to some mistakes in the source code, it was not possible to really
turn FIT support off. This commit fixes the problem by means of the
following changes:

- Enclose "bootm_host_load_image" and "bootm_host_load_images" between
checks for CONFIG_FIT_SIGNATURE, in common/bootm.c.

- Enclose the declaration of "bootm_host_load_images" between checks for
CONFIG_FIT_SIGNATURE, in common/bootm.h.

- Condition the compilation and linking of fit_common.o fit_image.o
image-host.o common/image-fit.o to CONFIG_FIT=y, in tools/Makefile.

Signed-off-by: Carlos Santos <casantos@datacom.ind.br>
[fabio: adapt for 2016.07]
Signed-off-by: Fabio Estevam <festevam@gmail.com>
[Ricardo: fix conditional compilation and linking of the files mentioned above
for 2016.07]
Signed-off-by: Ricardo Martincoski <ricardo.martincoski@gmail.com>
[Jörg: adapt for 2019.01]
Signed-off-by: Jörg Krause <joerg.krause@embedded.rocks>
[Retrieved from:
https://git.buildroot.net/buildroot/tree/package/uboot-tools/0003-Make-FIT-support-really-optional.patch]
Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>

# f6c6df7e 08-Jan-2019 Heinrich Schuchardt <xypron.glpk@gmx.de>

efi_loader: refactor switch to non-secure mode

Refactor the switch from supervisor to hypervisor to a new function called
at the beginning of do_bootefi().

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Alexander Graf <agraf@suse.de>

# f2a53c76 21-Dec-2018 Bin Meng <bmeng.cn@gmail.com>

bootm: vxworks: Make do_bootm_vxworks() non-static

For future extension to other architectures, make do_bootm_vxworks()
a non-static function.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>

# 896019b1 16-May-2018 Simon Glass <sjg@chromium.org>

Add a comment for board_quiesce_devices()

This exported function should have a comment describing what it does. Also
it should really be removed in favour of device_remove(), which handles
this sort of thing now. Add a comment with a TODO.

Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Alexander Graf <agraf@suse.de>

# 329da485 16-May-2018 Simon Glass <sjg@chromium.org>

Define board_quiesce_devices() in a shared location

This undocumented function relies on arch-specific code to declare a nop
weak version. Add the weak function in common code instead to avoid having
to duplicate the same function in each arch.

Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Alexander Graf <agraf@suse.de>

# 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>

# d52e8575 21-May-2015 Karl Apsite <Karl.Apsite@dornerworks.com>

Combine bootm_find_<thing> functions together

bootm_find_ramdisk_fdt() renamed to bootm_find_images() for readability.

The function bootm_find_ramdisk_fdt() appears to be a simple wrapper for
bootm_find_ramdisk(), bootm_find_fdt(), and now bootm_find_loadables().
I didn't see any other callers entering a bootm_find<thing>, so removing
the wrapper, and condensing these together hopefully makes the code a
little simpler.

Signed-off-by: Karl Apsite <Karl.Apsite@dornerworks.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 081cc197 02-Dec-2014 Simon Glass <sjg@chromium.org>

bootm: Export bootm_decomp_image()

Export this function for testing. Also add a parameter so that values other
than CONFIG_SYS_BOOTM_LEN can be used for the maximum uncompressed size.

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

# f1bd871a 08-Oct-2014 Jeroen Hofstee <jeroen@myspectrum.nl>

bootm: add prototype for arch_preboot_os

Signed-off-by: Jeroen Hofstee <jeroen@myspectrum.nl>

# d2b2ffe3 14-Aug-2014 Tom Rini <trini@ti.com>

cmd_bootm.c: Add 'booti' for ARM64 Linux kernel Images

The default format for arm64 Linux kernels is the "Image" format,
described in Documentation/arm64/booting.txt. This, along with an
optional gzip compression on top is all that is generated by default.
The Image format has a magic number within the header for verification,
a text_offset where the Image must be run from, an image_size that
includes the BSS and reserved fields.

This does not support automatic detection of a gzip compressed image.

Signed-off-by: Tom Rini <trini@ti.com>

# ce1400f6 12-Jun-2014 Simon Glass <sjg@chromium.org>

Enhance fit_check_sign to check all images

At present this tool only checks the configuration signing. Have it also
look at each of the images in the configuration and confirm that they
verify.

Signed-off-by: Simon Glass <sjg@chromium.org>
Acked-by: Heiko Schocher <hs@denx.de> (v1)

# b6396403 12-Jun-2014 Simon Glass <sjg@chromium.org>

bootm: Split out code from cmd_bootm.c

This file has code in three different categories:
- Command processing
- OS-specific boot code
- Locating images and setting up to boot

Only the first category really belongs in a file called cmd_bootm.c.

Leave the command processing code where it is. Split out the OS-specific
boot code into bootm_os.c. Split out the other code into bootm.c

Header files and extern declarations are tidied but otherwise no code
changes are made, to make it easier to review.

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

# 09140113 10-May-2020 Simon Glass <sjg@chromium.org>

command: Remove the cmd_tbl_t typedef

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 <sjg@chromium.org>

# 2090854c 24-Jul-2019 Julius Werner <jwerner@chromium.org>

common: Move bootm_decomp_image() to image.c (as image_decomp())

Upcoming patches want to add decompression to use cases that are no
longer directly related to booting. It makes sense to retain a single
decompression routine, but it should no longer be in bootm.c (which is
not compiled for all configurations). This patch moves
bootm_decomp_image() to image.c and renames it to image_decomp() in
preparation of those upcoming patches.

Signed-off-by: Julius Werner <jwerner@chromium.org>
Reviewed-by: Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com>
[trini: Fix warning around handle_decomp_error being unused]
Signed-off-by: Tom Rini <trini@konsulko.com>

# 93e07880 03-May-2019 Fabrice Fontaine <fontaine.fabrice@gmail.com>

Make FIT support really optional

Due to some mistakes in the source code, it was not possible to really
turn FIT support off. This commit fixes the problem by means of the
following changes:

- Enclose "bootm_host_load_image" and "bootm_host_load_images" between
checks for CONFIG_FIT_SIGNATURE, in common/bootm.c.

- Enclose the declaration of "bootm_host_load_images" between checks for
CONFIG_FIT_SIGNATURE, in common/bootm.h.

- Condition the compilation and linking of fit_common.o fit_image.o
image-host.o common/image-fit.o to CONFIG_FIT=y, in tools/Makefile.

Signed-off-by: Carlos Santos <casantos@datacom.ind.br>
[fabio: adapt for 2016.07]
Signed-off-by: Fabio Estevam <festevam@gmail.com>
[Ricardo: fix conditional compilation and linking of the files mentioned above
for 2016.07]
Signed-off-by: Ricardo Martincoski <ricardo.martincoski@gmail.com>
[Jörg: adapt for 2019.01]
Signed-off-by: Jörg Krause <joerg.krause@embedded.rocks>
[Retrieved from:
https://git.buildroot.net/buildroot/tree/package/uboot-tools/0003-Make-FIT-support-really-optional.patch]
Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>

# f6c6df7e 08-Jan-2019 Heinrich Schuchardt <xypron.glpk@gmx.de>

efi_loader: refactor switch to non-secure mode

Refactor the switch from supervisor to hypervisor to a new function called
at the beginning of do_bootefi().

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Alexander Graf <agraf@suse.de>

# f2a53c76 21-Dec-2018 Bin Meng <bmeng.cn@gmail.com>

bootm: vxworks: Make do_bootm_vxworks() non-static

For future extension to other architectures, make do_bootm_vxworks()
a non-static function.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>

# 896019b1 16-May-2018 Simon Glass <sjg@chromium.org>

Add a comment for board_quiesce_devices()

This exported function should have a comment describing what it does. Also
it should really be removed in favour of device_remove(), which handles
this sort of thing now. Add a comment with a TODO.

Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Alexander Graf <agraf@suse.de>

# 329da485 16-May-2018 Simon Glass <sjg@chromium.org>

Define board_quiesce_devices() in a shared location

This undocumented function relies on arch-specific code to declare a nop
weak version. Add the weak function in common code instead to avoid having
to duplicate the same function in each arch.

Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Alexander Graf <agraf@suse.de>

# 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>

# d52e8575 21-May-2015 Karl Apsite <Karl.Apsite@dornerworks.com>

Combine bootm_find_<thing> functions together

bootm_find_ramdisk_fdt() renamed to bootm_find_images() for readability.

The function bootm_find_ramdisk_fdt() appears to be a simple wrapper for
bootm_find_ramdisk(), bootm_find_fdt(), and now bootm_find_loadables().
I didn't see any other callers entering a bootm_find<thing>, so removing
the wrapper, and condensing these together hopefully makes the code a
little simpler.

Signed-off-by: Karl Apsite <Karl.Apsite@dornerworks.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 081cc197 02-Dec-2014 Simon Glass <sjg@chromium.org>

bootm: Export bootm_decomp_image()

Export this function for testing. Also add a parameter so that values other
than CONFIG_SYS_BOOTM_LEN can be used for the maximum uncompressed size.

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

# f1bd871a 08-Oct-2014 Jeroen Hofstee <jeroen@myspectrum.nl>

bootm: add prototype for arch_preboot_os

Signed-off-by: Jeroen Hofstee <jeroen@myspectrum.nl>

# d2b2ffe3 14-Aug-2014 Tom Rini <trini@ti.com>

cmd_bootm.c: Add 'booti' for ARM64 Linux kernel Images

The default format for arm64 Linux kernels is the "Image" format,
described in Documentation/arm64/booting.txt. This, along with an
optional gzip compression on top is all that is generated by default.
The Image format has a magic number within the header for verification,
a text_offset where the Image must be run from, an image_size that
includes the BSS and reserved fields.

This does not support automatic detection of a gzip compressed image.

Signed-off-by: Tom Rini <trini@ti.com>

# ce1400f6 12-Jun-2014 Simon Glass <sjg@chromium.org>

Enhance fit_check_sign to check all images

At present this tool only checks the configuration signing. Have it also
look at each of the images in the configuration and confirm that they
verify.

Signed-off-by: Simon Glass <sjg@chromium.org>
Acked-by: Heiko Schocher <hs@denx.de> (v1)

# b6396403 12-Jun-2014 Simon Glass <sjg@chromium.org>

bootm: Split out code from cmd_bootm.c

This file has code in three different categories:
- Command processing
- OS-specific boot code
- Locating images and setting up to boot

Only the first category really belongs in a file called cmd_bootm.c.

Leave the command processing code where it is. Split out the OS-specific
boot code into bootm_os.c. Split out the other code into bootm.c

Header files and extern declarations are tidied but otherwise no code
changes are made, to make it easier to review.

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

# 2090854c 24-Jul-2019 Julius Werner <jwerner@chromium.org>

common: Move bootm_decomp_image() to image.c (as image_decomp())

Upcoming patches want to add decompression to use cases that are no
longer directly related to booting. It makes sense to retain a single
decompression routine, but it should no longer be in bootm.c (which is
not compiled for all configurations). This patch moves
bootm_decomp_image() to image.c and renames it to image_decomp() in
preparation of those upcoming patches.

Signed-off-by: Julius Werner <jwerner@chromium.org>
Reviewed-by: Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com>
[trini: Fix warning around handle_decomp_error being unused]
Signed-off-by: Tom Rini <trini@konsulko.com>

# 93e07880 03-May-2019 Fabrice Fontaine <fontaine.fabrice@gmail.com>

Make FIT support really optional

Due to some mistakes in the source code, it was not possible to really
turn FIT support off. This commit fixes the problem by means of the
following changes:

- Enclose "bootm_host_load_image" and "bootm_host_load_images" between
checks for CONFIG_FIT_SIGNATURE, in common/bootm.c.

- Enclose the declaration of "bootm_host_load_images" between checks for
CONFIG_FIT_SIGNATURE, in common/bootm.h.

- Condition the compilation and linking of fit_common.o fit_image.o
image-host.o common/image-fit.o to CONFIG_FIT=y, in tools/Makefile.

Signed-off-by: Carlos Santos <casantos@datacom.ind.br>
[fabio: adapt for 2016.07]
Signed-off-by: Fabio Estevam <festevam@gmail.com>
[Ricardo: fix conditional compilation and linking of the files mentioned above
for 2016.07]
Signed-off-by: Ricardo Martincoski <ricardo.martincoski@gmail.com>
[Jörg: adapt for 2019.01]
Signed-off-by: Jörg Krause <joerg.krause@embedded.rocks>
[Retrieved from:
https://git.buildroot.net/buildroot/tree/package/uboot-tools/0003-Make-FIT-support-really-optional.patch]
Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>

# f6c6df7e 08-Jan-2019 Heinrich Schuchardt <xypron.glpk@gmx.de>

efi_loader: refactor switch to non-secure mode

Refactor the switch from supervisor to hypervisor to a new function called
at the beginning of do_bootefi().

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Alexander Graf <agraf@suse.de>

# f2a53c76 21-Dec-2018 Bin Meng <bmeng.cn@gmail.com>

bootm: vxworks: Make do_bootm_vxworks() non-static

For future extension to other architectures, make do_bootm_vxworks()
a non-static function.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>

# 896019b1 16-May-2018 Simon Glass <sjg@chromium.org>

Add a comment for board_quiesce_devices()

This exported function should have a comment describing what it does. Also
it should really be removed in favour of device_remove(), which handles
this sort of thing now. Add a comment with a TODO.

Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Alexander Graf <agraf@suse.de>

# 329da485 16-May-2018 Simon Glass <sjg@chromium.org>

Define board_quiesce_devices() in a shared location

This undocumented function relies on arch-specific code to declare a nop
weak version. Add the weak function in common code instead to avoid having
to duplicate the same function in each arch.

Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Alexander Graf <agraf@suse.de>

# 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>

# d52e8575 21-May-2015 Karl Apsite <Karl.Apsite@dornerworks.com>

Combine bootm_find_<thing> functions together

bootm_find_ramdisk_fdt() renamed to bootm_find_images() for readability.

The function bootm_find_ramdisk_fdt() appears to be a simple wrapper for
bootm_find_ramdisk(), bootm_find_fdt(), and now bootm_find_loadables().
I didn't see any other callers entering a bootm_find<thing>, so removing
the wrapper, and condensing these together hopefully makes the code a
little simpler.

Signed-off-by: Karl Apsite <Karl.Apsite@dornerworks.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 081cc197 02-Dec-2014 Simon Glass <sjg@chromium.org>

bootm: Export bootm_decomp_image()

Export this function for testing. Also add a parameter so that values other
than CONFIG_SYS_BOOTM_LEN can be used for the maximum uncompressed size.

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

# f1bd871a 08-Oct-2014 Jeroen Hofstee <jeroen@myspectrum.nl>

bootm: add prototype for arch_preboot_os

Signed-off-by: Jeroen Hofstee <jeroen@myspectrum.nl>

# d2b2ffe3 14-Aug-2014 Tom Rini <trini@ti.com>

cmd_bootm.c: Add 'booti' for ARM64 Linux kernel Images

The default format for arm64 Linux kernels is the "Image" format,
described in Documentation/arm64/booting.txt. This, along with an
optional gzip compression on top is all that is generated by default.
The Image format has a magic number within the header for verification,
a text_offset where the Image must be run from, an image_size that
includes the BSS and reserved fields.

This does not support automatic detection of a gzip compressed image.

Signed-off-by: Tom Rini <trini@ti.com>

# ce1400f6 12-Jun-2014 Simon Glass <sjg@chromium.org>

Enhance fit_check_sign to check all images

At present this tool only checks the configuration signing. Have it also
look at each of the images in the configuration and confirm that they
verify.

Signed-off-by: Simon Glass <sjg@chromium.org>
Acked-by: Heiko Schocher <hs@denx.de> (v1)

# b6396403 12-Jun-2014 Simon Glass <sjg@chromium.org>

bootm: Split out code from cmd_bootm.c

This file has code in three different categories:
- Command processing
- OS-specific boot code
- Locating images and setting up to boot

Only the first category really belongs in a file called cmd_bootm.c.

Leave the command processing code where it is. Split out the OS-specific
boot code into bootm_os.c. Split out the other code into bootm.c

Header files and extern declarations are tidied but otherwise no code
changes are made, to make it easier to review.

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

# 896019b1 16-May-2018 Simon Glass <sjg@chromium.org>

Add a comment for board_quiesce_devices()

This exported function should have a comment describing what it does. Also
it should really be removed in favour of device_remove(), which handles
this sort of thing now. Add a comment with a TODO.

Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Alexander Graf <agraf@suse.de>


# 329da485 16-May-2018 Simon Glass <sjg@chromium.org>

Define board_quiesce_devices() in a shared location

This undocumented function relies on arch-specific code to declare a nop
weak version. Add the weak function in common code instead to avoid having
to duplicate the same function in each arch.

Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Alexander Graf <agraf@suse.de>


# 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>


# d52e8575 21-May-2015 Karl Apsite <Karl.Apsite@dornerworks.com>

Combine bootm_find_<thing> functions together

bootm_find_ramdisk_fdt() renamed to bootm_find_images() for readability.

The function bootm_find_ramdisk_fdt() appears to be a simple wrapper for
bootm_find_ramdisk(), bootm_find_fdt(), and now bootm_find_loadables().
I didn't see any other callers entering a bootm_find<thing>, so removing
the wrapper, and condensing these together hopefully makes the code a
little simpler.

Signed-off-by: Karl Apsite <Karl.Apsite@dornerworks.com>
Reviewed-by: Simon Glass <sjg@chromium.org>


# 081cc197 02-Dec-2014 Simon Glass <sjg@chromium.org>

bootm: Export bootm_decomp_image()

Export this function for testing. Also add a parameter so that values other
than CONFIG_SYS_BOOTM_LEN can be used for the maximum uncompressed size.

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


# f1bd871a 08-Oct-2014 Jeroen Hofstee <jeroen@myspectrum.nl>

bootm: add prototype for arch_preboot_os

Signed-off-by: Jeroen Hofstee <jeroen@myspectrum.nl>


# d2b2ffe3 14-Aug-2014 Tom Rini <trini@ti.com>

cmd_bootm.c: Add 'booti' for ARM64 Linux kernel Images

The default format for arm64 Linux kernels is the "Image" format,
described in Documentation/arm64/booting.txt. This, along with an
optional gzip compression on top is all that is generated by default.
The Image format has a magic number within the header for verification,
a text_offset where the Image must be run from, an image_size that
includes the BSS and reserved fields.

This does not support automatic detection of a gzip compressed image.

Signed-off-by: Tom Rini <trini@ti.com>


# ce1400f6 12-Jun-2014 Simon Glass <sjg@chromium.org>

Enhance fit_check_sign to check all images

At present this tool only checks the configuration signing. Have it also
look at each of the images in the configuration and confirm that they
verify.

Signed-off-by: Simon Glass <sjg@chromium.org>
Acked-by: Heiko Schocher <hs@denx.de> (v1)


# b6396403 12-Jun-2014 Simon Glass <sjg@chromium.org>

bootm: Split out code from cmd_bootm.c

This file has code in three different categories:
- Command processing
- OS-specific boot code
- Locating images and setting up to boot

Only the first category really belongs in a file called cmd_bootm.c.

Leave the command processing code where it is. Split out the OS-specific
boot code into bootm_os.c. Split out the other code into bootm.c

Header files and extern declarations are tidied but otherwise no code
changes are made, to make it easier to review.

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