Commit Graph

18 Commits

Author SHA1 Message Date
Simon Glass
d2c485a032 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>
2024-04-10 13:49:16 -06:00
Simon Glass
a831d11378 bootstd: cros: Correct condition for read method
This has a typo which makes the method inoperable. Correct it so that
'bootflow read' works correctly for ChromeOS.

Signed-off-by: Simon Glass <sjg@chromium.org>
2023-11-01 12:26:44 -04:00
Simon Glass
71f634b822 bootstd: cros: Allow detection of any kernel partition
The existing ChromiumOS bootmeth only supports reading a single kernel
partition, either 2 or 4. In fact there are normally two options
available.

Use the GUID to detect kernel partitions, with the BOOTMETHF_ANY_PART
flag, so that bootstd does not require a valid filesystem before calling
the bootmeth.

Tidy up and improve the logging while we are here.

Signed-off-by: Simon Glass <sjg@chromium.org>
Suggested-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
[trini: Add missing select of PARTITION_TYPE_GUID]
Signed-off-by: Tom Rini <trini@konsulko.com>
2023-08-26 10:07:32 -04:00
Simon Glass
daffb0be2c 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>
2023-08-11 07:33:40 -06:00
Simon Glass
c279224ea6 bootstd: Add a command to read all files for a bootflow
Some bootflows (such as EFI and ChromiumOS) delay reading the kernel until
it is needed to boot. This saves time when scanning and avoids needing to
allocate memory for something that may never be used.

To permit reading of these files, add a new 'bootflow read' command.

Signed-off-by: Simon Glass <sjg@chromium.org>
2023-08-11 07:33:38 -06:00
Simon Glass
598dea978d bootstd: cros: Split up reading info and kernel
Use the two new functions to separate reading of the ChromiumOS info from
the partition from actually reading the kernel and booting it.

Signed-off-by: Simon Glass <sjg@chromium.org>
2023-08-10 18:34:54 -06:00
Simon Glass
074503c40a bootstd: cros: Add a function to read a kernel
The code to read the ChromiumOS information from the partition is
currently all in one function.

Create a new function which reads the kernel, assuming that the metadata
has been parsed.

For now this function is not used. Future work will plumb it in.

Signed-off-by: Simon Glass <sjg@chromium.org>
2023-08-10 18:34:54 -06:00
Simon Glass
f861b1ee70 bootstd: cros: Add a function to read info from partition
The code to read the ChromiumOS information from the partition is
currently all in one function. It reads the entire kernel, which is
unnecessary unless it is to be booted.

Create a new function which reads just the minimum required data from the
disk, then obtains what it needs from there.

For now this function is not used. Future work will plumb it in.

Signed-off-by: Simon Glass <sjg@chromium.org>
2023-08-10 18:34:54 -06:00
Simon Glass
1d4bbdf3e4 bootstd: cros: Add private info for ChromiumOS
Create a new private structure to hold information gleaned from the disk.
This will allow separation between reading of the bootflow information and
(later) reading the whole kernel.

Signed-off-by: Simon Glass <sjg@chromium.org>
2023-08-10 18:34:54 -06:00
Simon Glass
b7ed5386a4 bootstd: cros: Add docs for the kernel layout
Provide brief documentation about the ChromiumOS kernel layout.

Signed-off-by: Simon Glass <sjg@chromium.org>
2023-08-10 18:34:54 -06:00
Simon Glass
1a0810924a 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>
2023-08-10 18:34:54 -06:00
Simon Glass
c5dca50bbb bootstd: cros: Simplify setup and cmdline expressions
Create a common base from which the other parts are offset and make all
of the offsets related to that. This makes the code a little easier to
read.

Use X86_ prefixes for the two values which are x86-specific.

Drop OFFSET_BASE since it is available in a header field.

Drop the unnecessary 'start' variable too.

Signed-off-by: Simon Glass <sjg@chromium.org>
2023-08-10 18:34:54 -06:00
Simon Glass
3257835e56 bootstd: cros: Decode some kernel preamble fields
Decode the kernel start and size using the structures provided. This
accesses the same data, just in a cleaner way.

Add some logging for some of the fields in the kernel preamble.

Signed-off-by: Simon Glass <sjg@chromium.org>
2023-08-10 18:34:54 -06:00
Simon Glass
4cfe4510f1 bootstd: cros: Support a kernel on either partition
ChromiumOS allows a kernel to be on either partition 2 or 4. Add support
for scanning both and using the first one we find with a suitable
signature.

Record the partition which is used.

Signed-off-by: Simon Glass <sjg@chromium.org>
2023-08-10 18:34:54 -06:00
Simon Glass
de30aa9a2f bootstd: cros: Bring in some ChromiumOS structures
Add a header file with structures for booting ChromiumOS, taken from the
vboot tree. Using these makes it easier to understand the code.

Note that the code style has not been updated for U-Boot, with use of
uint64_t,  __attribute__((packed)) and one comment-style nit. This should
make it easier to keep the code in sync. It was taken from commit:

   5b8596ce ("2sha256_arm: Fix data abort issue")

Update the CHROMEOS string to use the defined values.

Signed-off-by: Simon Glass <sjg@chromium.org>
2023-08-10 18:34:54 -06:00
Simon Glass
5a8589ebd6 bootstd: cros: Move partition reading into a function
Move the code which reads a partition into its own function. Add a
constant for the number of bytes to 'probe' at the start of the partition.

Signed-off-by: Simon Glass <sjg@chromium.org>
2023-08-10 18:34:54 -06:00
Simon Glass
defa33ad29 bootstd: cros: Correct reporting of I/O errors
Return -EIO when the read failed, rather than the number of blocks read.

Signed-off-by: Simon Glass <sjg@chromium.org>
2023-08-10 18:34:54 -06:00
Simon Glass
c88d67d021 bootstd: Add a simple bootmeth for ChromiumOS
It is possible to boot x86-based ChromeOS machines by parsing a table and
locating the kernel and command line. Add a bootmeth for this.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
2023-07-17 13:38:35 +08:00