diff options
author | Simon Glass | 2023-07-30 11:16:58 -0600 |
---|---|---|
committer | Simon Glass | 2023-08-10 18:34:54 -0600 |
commit | 074503c40a14f0e35b69bb3f06bb255b6881ca4e (patch) | |
tree | f82130830434baf51b7dfa5cf09bfe6064cd4299 /boot | |
parent | f861b1ee70aafff68a9a1ecbffb0bc79b71d13eb (diff) |
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>
Diffstat (limited to 'boot')
-rw-r--r-- | boot/bootmeth_cros.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/boot/bootmeth_cros.c b/boot/bootmeth_cros.c index 82cbdcf2c93..8728cd18e3c 100644 --- a/boot/bootmeth_cros.c +++ b/boot/bootmeth_cros.c @@ -294,6 +294,45 @@ static int cros_read_info(struct bootflow *bflow, const char *uuid, return 0; } +static int cros_read_kernel(struct bootflow *bflow) +{ + struct blk_desc *desc = dev_get_uclass_plat(bflow->blk); + struct cros_priv *priv = bflow->bootmeth_priv; + ulong base, setup; + ulong num_blks; + void *buf; + int ret; + + bflow->size = priv->body_size; + + buf = memalign(SZ_1K, priv->body_size); + if (!buf) + return log_msg_ret("buf", -ENOMEM); + + /* Check that the header is not smaller than permitted */ + if (priv->body_offset < PROBE_SIZE) + return log_msg_ret("san", EFAULT); + + /* Read kernel body */ + num_blks = priv->body_size >> desc->log2blksz; + log_debug("Reading body to %lx, blk=%s, size=%lx, blocks=%lx\n", + (ulong)map_to_sysmem(buf), bflow->blk->name, priv->body_size, + num_blks); + ret = blk_read(bflow->blk, + priv->part_start + (priv->body_offset >> desc->log2blksz), + num_blks, buf); + if (ret != num_blks) + return log_msg_ret("inf", -EIO); + base = map_to_sysmem(buf) + priv->bootloader_address - + priv->body_load_address; + setup = base + X86_SETUP_OFFSET; + + bflow->buf = buf; + bflow->x86_setup = map_sysmem(setup, 0); + + return 0; +} + static int cros_read_bootflow(struct udevice *dev, struct bootflow *bflow) { struct blk_desc *desc = dev_get_uclass_plat(bflow->blk); |