[PATCH 06/16] bootstd: cros: Simplify setup and cmdline expressions
Simon Glass
sjg at chromium.org
Sun Jul 30 19:16:52 CEST 2023
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 at chromium.org>
---
boot/bootmeth_cros.c | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/boot/bootmeth_cros.c b/boot/bootmeth_cros.c
index 2a745621e30e..05284713f67b 100644
--- a/boot/bootmeth_cros.c
+++ b/boot/bootmeth_cros.c
@@ -27,9 +27,9 @@
enum {
PROBE_SIZE = SZ_4K, /* initial bytes read from partition */
- SETUP_OFFSET = 0x1000, /* bytes before base */
- CMDLINE_OFFSET = 0x2000, /* bytes before base */
- OFFSET_BASE = 0x100000, /* assumed kernel load-address */
+ X86_SETUP_OFFSET = -0x1000, /* setup offset relative to base */
+ CMDLINE_OFFSET = -0x2000, /* cmdline offset relative to base */
+ X86_KERNEL_OFFSET = 0x4000, /* kernel offset relative to base */
};
static int cros_check(struct udevice *dev, struct bootflow_iter *iter)
@@ -126,7 +126,7 @@ static int scan_part(struct udevice *blk, int partnum,
static int cros_read_bootflow(struct udevice *dev, struct bootflow *bflow)
{
struct blk_desc *desc = dev_get_uclass_plat(bflow->blk);
- ulong base, start, setup, cmdline, num_blks, kern_base;
+ ulong base, setup, cmdline, num_blks, kern_base;
const struct vb2_kernel_preamble *preamble;
ulong body_offset, body_size;
struct disk_partition info;
@@ -160,7 +160,6 @@ static int cros_read_bootflow(struct udevice *dev, struct bootflow *bflow)
preamble->header_version_major,
preamble->header_version_minor);
- start = (ulong)preamble->bootloader_address;
log_debug(" - load_address %lx, bl_addr %lx, bl_size %lx\n",
(ulong)preamble->body_load_address,
(ulong)preamble->bootloader_address,
@@ -189,12 +188,13 @@ static int cros_read_bootflow(struct udevice *dev, struct bootflow *bflow)
num_blks, buf);
if (ret != num_blks)
return log_msg_ret("inf", -EIO);
- base = map_to_sysmem(buf);
+ base = map_to_sysmem(buf) + preamble->bootloader_address -
+ preamble->body_load_address;
- setup = base + start - OFFSET_BASE - SETUP_OFFSET;
- cmdline = base + start - OFFSET_BASE - CMDLINE_OFFSET;
- kern_base = base + start - OFFSET_BASE + SZ_16K;
- log_debug("base %lx setup %lx, cmdline %lx, kern_base %lx\n", base,
+ setup = base + X86_SETUP_OFFSET;
+ cmdline = base + CMDLINE_OFFSET;
+ kern_base = base + X86_KERNEL_OFFSET;
+ log_debug("base %lx setup %lx cmdline %lx kern_base %lx\n", base,
setup, cmdline, kern_base);
#ifdef CONFIG_X86
--
2.41.0.487.g6d72f3e995-goog
More information about the U-Boot
mailing list