at91: Correct CONFIG_AUTOBOOT_PROMPT definition for pm9263

This is not currently used, since autoboot is not enabled for this
board, but the string is missing a parameter. Add it.

Signed-off-by: Simon Glass <sjg@chromium.org>
Acked-by: Andreas Bießmann <andreas.devel@googlemail.com>
net: Add prototype for update_tftp

This function should be declared in net.h.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Joe Hershberger <joe.hershberger@ni.com>
main: Separate out the two abortboot() functions

There are two implementations of abortboot(). Turn these into two separate
functions, and create a single abortboot() which calls either one or the
other.

Also it seems that nothing uses abortboot() outside main, so make it static.

At this point there is no further use of CONFIG_MENU in main.c.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Joe Hershberger <joe.hershberger@ni.com>
main: Move boot_delay code into its own function

Move this code into its own function, since it clutters up main_loop().

Signed-off-by: Simon Glass <sjg@chromium.org>
main: Use get/setenv_ulong()

These functions are now available, so use them to avoid extra code here.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Joe Hershberger <joe.hershberger@ni.com>
main: Fix typos and checkpatch warnings in command line reading

There are a few over-long lines and other checkpatch problems in this area
of the code. Prepare the ground for the next patch by tidying these up.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Joe Hershberger <joe.hershberger@ni.com>
main: Correct header order

The headers are a bit out of order, so fix them.

Signed-off-by: Simon Glass <sjg@chromium.org>
main: Add debug_parser() to avoid #ifdefs

Define a simple debug condition at the top of the file, to avoid using
lots of #ifdefs later on.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Joe Hershberger <joe.hershberger@ni.com>
main: Add debug_bootkeys to avoid #ifdefs

Define a simple debug condition at the top of the file, to avoid using
lots of #ifdefs later on.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Joe Hershberger <joe.hershberger@ni.com>
bootstage: Introduce sub-IDs for use with image loading

Loading a ramdisk, kernel or FDT goes through similar stages. Create
a block of IDs for each task, and define a consistent numbering within
the block. This will allow use of common code for image loading.

Signed-off-by: Simon Glass <sjg@chromium.org>
mkimage: Add map_sysmem() and IH_ARCH_DEFAULT to simplfy building

These are not actually used in mkimage itself, but the image code (which
is common with mkimage) does use them. To avoid #ifdefs in the image code
just for mkimage, define dummy version of these here. The compiler will
eliminate the dead code anyway.

A better way to handle this might be to split out more things from common.h
so that mkimage can include them. At present any file that mkimage uses
has to be very careful what headers it includes.

Signed-off-by: Simon Glass <sjg@chromium.org>
image: Introduce fit_image_load() to load images from FITs

At present code to load an image from a FIT is duplicated in the three
places where it is needed (kernel, fdt, ramdisk).

The differences between these different code copies is fairly minor.
Create a new function in the fit code which can handle any of the
requirements of those cases.

Signed-off-by: Simon Glass <sjg@chromium.org>
image: Use fit_image_load() to load ramdisk

Use the new common code to load a ramdisk. The functionality should not
change.

Signed-off-by: Simon Glass <sjg@chromium.org>
image: Use fit_image_load() to load FDT

Use the new common code to load a flat device tree. Also fix up a few casts
so that this code works with sandbox. Other than that the functionality
should not change.

Signed-off-by: Simon Glass <sjg@chromium.org>
sandbox: Adjust bootm command to work with sandbox

Use map_sysmem() when converting from addresses to pointers, so that
bootm can be used with sandbox.

Signed-off-by: Simon Glass <sjg@chromium.org>
image: Use fit_image_load() to load kernel

Use the new common code to load a kernel. The functionality should not
change.

Signed-off-by: Simon Glass <sjg@chromium.org>
sandbox: image: Adjust FIT image printing to work with sandbox

Use map_sysmem() to convert from address to pointer, so that sandbox can
print FIT information without crashing.

Signed-off-by: Simon Glass <sjg@chromium.org>
bootstage: Remove unused entries related to kernel/ramdisk/fdt load

Now that the code for loading these three images from a FIT is common, we
don't need individual boostage IDs for each of them.

Note: there are some minor changes in the bootstage numbering, particuarly
for kernel loading. I don't believe this matters.

Signed-off-by: Simon Glass <sjg@chromium.org>
sandbox: image: Create a test for loading FIT images

The image code is fairly complex with various different options. It would
be useful to have comprehensive tests for this.

As a start, create a script which tries out loading a kernel/ramdisk/fdt
from a FIT and checks that the images appear in the right place in memory.

This uses sandbox which now supports bootm and related features.

Signed-off-by: Simon Glass <sjg@chromium.org>
disk: Fix possible out-of-bounds access in part_efi.c

Make sure to never access beyond bounds of either EFI partition name
or DOS partition name. This situation is happening:

part.h:     disk_partition_t->name is 32-byte long
part_efi.h: gpt_entry->partition_name is 36-bytes long

The loop in part_efi.c copies over 36 bytes and thus accesses beyond
the disk_partition_t->name .

Fix this by picking the shortest of source and destination arrays and
make sure the destination array is cleared so the trailing bytes are
zeroed-out and don't cause issues with string manipulation.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Tom Rini <trini@ti.com>
Cc: Simon Glass <sjg@chromium.org>