Fix linux-system-semi.axf build failure from clean

We were failing to build linux-system-semi.axf in a clean tree
because even if SEMIHOSTING was defined we still had a spurious
INPUT(boot.o), which is harmless if boot.o exists but fails
if it does not.

In fact the INPUT() commands for the .o files are unnecessary
because ld will pull in the correct .o files because the SECTIONS
command has a non-wildcard reference to them. So just drop the
unneeded INPUT() commands rather than adding more ifdefs.
(The INPUT() commands for the binary blobs are still required.)

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Boot kernel in hyp mode.

Leave the old monitor stub there for the moment, so we can boot current
Christoffer kernels.

Includes fixes by Dave Martin to make it actually work :)

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
model.lds.S: Move initrd address up to allow for large kernels

Move the start address of the initrd up to kernel start + 0xd00000,
so that we can handle large kernels (eg Android) without them
overlapping with the initrd. 0xd00000 is the offset QEMU uses in
its internal ARM bootloader so should be sufficient.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
boot-wrapper: tidy the Makefile to help with packaging.

Add and modify Makefile rules so that it can be used in a Debian
package.  Add an explicit 'distclean' target.  Add a 'semi' target
that only builds the semihosting binary.  Add stub commands to 'all'
and 'semi' so the call doesn't fall through to the default kernel
rule.  Update 'clean' to also clean the semihosting files.

Signed-off-by: Michael Hope <michael.hope@linaro.org>
Signed-off-by: Rusty Russell <rusty.russell@linaro.org>
Makefile: Use .PHONY target, not dummy commands; tidy clean list

There's no need to use a dummy 'true' command to suppress the
default 'try kernel makefile' target for targets with no actual
rules -- you can just list as in .PHONY instead.

Tidy the list of files to remove on clean to remove a duplicate
and use $(KERNEL) instead of uImage.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
bootwrapper: Import libfdt flattened device tree library

Import the sources of the libfdt flattened device tree library,
as a prerequisite for adding fdt support to the bootwrapper.
This commit just pulls in the upstream sources; it does not
cause them to be built.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
bootwrapper: Import C semihosting code

Import the reimplementation in C of the semihosting support
written by Dave Martin for the ARM big.LITTLE bootwrapper.
The main benefit of this switchover (apart from only having
one implementation rather than two) is the fdt support it
includes.

This commit only imports the sources, it doesn't compile them.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
bootwrapper: Switch to C semihosting code

Switch over to the C semihosting code, removing the old assembly
implementation. This allows us to simplify the build process
somewhat: boot.S is now compiled only once, rather than once for
semihosting and once without.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
bootwrapper: Add README

Add a short README file describing what the bootwrapper is
and how to run it.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
semi_loader.c: make --dtb actually work rather than be ignored

Fix a bug that meant that the --dtb option was silently ignored.
(The equivalent to this fix has already been applied in the
big.LITTLE bootwrapper which we borrow this file from, so this
brings us back into sync.)

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
semi_loader: Handle dtbs with 64 bit addresses

ARM board device tree blobs have moved to specifying addresses and
sizes as 64 bit values (2 cells) rather than 32 bit (1 cell); update
bootwrapper so it can handle these rather than stopping with an error.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Acked-by: Dave Martin <dave.martin@linaro.org>
semi_loader: Ignore u-boot image header in initrd if exist

Add support for loading initrd images in u-boot image format. The
image header is checked against u-boot image header magic. In
case of a match, the initrd is treated as starting after the u-boot
image header.

Signed-off-by: Guodong Xu <guodong.xu@linaro.org>
Acked-by: Dave Martin <dave.martin@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
bootwrapper: Use local definition of string.h

The semihosting and FDT code makes use of libc style string
functions implemented in our string.c, however it relies on the system
providing the string.h header file.

This causes problems on toolchains that don't provide these headers,
like Android toolchains, and it also means that we include declaration
for functions which aren't implemented in the bootwrapper.

Resolve this by providing our own string.h which declares only
the functions we implement and add the base directory to the
include path so this header is found.

Signed-off-by: Jon Medhurst <tixy@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>