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>
This commit is contained in:
Simon Glass 2023-07-30 11:16:49 -06:00
parent 5a8589ebd6
commit de30aa9a2f
2 changed files with 201 additions and 2 deletions

View file

@ -21,6 +21,7 @@
#include <asm/zimage.h>
#endif
#include <linux/sizes.h>
#include "bootmeth_cros.h"
enum {
PROBE_SIZE = SZ_4K, /* initial bytes read from partition */
@ -82,7 +83,8 @@ static int copy_cmdline(const char *from, const char *uuid, char **bufp)
/**
* scan_part() - Scan a kernel partition to see if has a ChromeOS header
*
* This reads the first PROBE_SIZE of a partition, loookng for CHROMEOS
* This reads the first PROBE_SIZE of a partition, loookng for
* VB2_KEYBLOCK_MAGIC
*
* @blk: Block device to scan
* @partnum: Partition number to scan
@ -114,7 +116,7 @@ static int scan_part(struct udevice *blk, int partnum,
return log_msg_ret("inf", -EIO);
}
if (memcmp("CHROMEOS", hdr, 8)) {
if (memcmp(VB2_KEYBLOCK_MAGIC, hdr->magic, VB2_KEYBLOCK_MAGIC_SIZE)) {
free(hdr);
return -ENOENT;
}