At present the setup block is always obtained from the image
automatically. In some cases it can be useful to use a setup block
obtained elsewhere, e.g. if the image has already been unpacked. Add an
argument to support this and update the logic to use it if provided.

Signed-off-by: Simon Glass <s...@chromium.org>
Reviewed-by: Wolfgang Wallner <wolfgang.wall...@br-automation.com>
Reviewed-by: Bin Meng <bmeng...@gmail.com>
---

(no changes since v2)

Changes in v2:
- Add a comment explaining the logic for a specified setup-base address
- Adjust maxargs in this patch

 arch/x86/lib/zimage.c | 41 ++++++++++++++++++++++++++++++++++-------
 1 file changed, 34 insertions(+), 7 deletions(-)

diff --git a/arch/x86/lib/zimage.c b/arch/x86/lib/zimage.c
index 11f1c60d53d..368b7d0c3f3 100644
--- a/arch/x86/lib/zimage.c
+++ b/arch/x86/lib/zimage.c
@@ -366,6 +366,22 @@ static int do_zboot_start(struct cmd_tbl *cmdtp, int flag, 
int argc,
                state.initrd_addr = simple_strtoul(argv[3], NULL, 16);
        if (argc >= 5)
                state.initrd_size = simple_strtoul(argv[4], NULL, 16);
+       if (argc >= 6) {
+               /*
+                * When the base_ptr is passed in, we assume that the image is
+                * already loaded at the address given by argv[1] and therefore
+                * the original bzImage is somewhere else, or not accessible.
+                * In any case, we don't need access to the bzImage since all
+                * the processing is assumed to be done.
+                *
+                * So set the base_ptr to the given address, use this arg as the
+                * load address and set bzimage_addr to 0 so we know that it
+                * cannot be proceesed (or processed again).
+                */
+               state.base_ptr = (void *)simple_strtoul(argv[5], NULL, 16);
+               state.load_address = state.bzimage_addr;
+               state.bzimage_addr = 0;
+       }
 
        return 0;
 }
@@ -375,11 +391,20 @@ static int do_zboot_load(struct cmd_tbl *cmdtp, int flag, 
int argc,
 {
        struct boot_params *base_ptr;
 
-       base_ptr = load_zimage((void *)state.bzimage_addr, state.bzimage_size,
-                              &state.load_address);
-       if (!base_ptr) {
-               puts("## Kernel loading failed ...\n");
-               return CMD_RET_FAILURE;
+       if (state.base_ptr) {
+               struct boot_params *from = (struct boot_params *)state.base_ptr;
+
+               base_ptr = (struct boot_params *)DEFAULT_SETUP_BASE;
+               printf("Building boot_params at 0x%8.8lx\n", (ulong)base_ptr);
+               memset(base_ptr, '\0', sizeof(*base_ptr));
+               base_ptr->hdr = from->hdr;
+       } else {
+               base_ptr = load_zimage((void *)state.bzimage_addr, 
state.bzimage_size,
+                                      &state.load_address);
+               if (!base_ptr) {
+                       puts("## Kernel loading failed ...\n");
+                       return CMD_RET_FAILURE;
+               }
        }
        state.base_ptr = base_ptr;
        if (env_set_hex("zbootbase", (ulong)base_ptr) ||
@@ -486,8 +511,8 @@ int do_zboot_parent(struct cmd_tbl *cmdtp, int flag, int 
argc,
 }
 
 U_BOOT_CMDREP_COMPLETE(
-       zboot, 6, do_zboot_parent, "Boot bzImage",
-       "[addr] [size] [initrd addr] [initrd size]\n"
+       zboot, 7, do_zboot_parent, "Boot bzImage",
+       "[addr] [size] [initrd addr] [initrd size] [setup]\n"
        "      addr -        The optional starting address of the bzimage.\n"
        "                    If not set it defaults to the environment\n"
        "                    variable \"fileaddr\".\n"
@@ -495,6 +520,8 @@ U_BOOT_CMDREP_COMPLETE(
        "                    zero.\n"
        "      initrd addr - The address of the initrd image to use, if any.\n"
        "      initrd size - The size of the initrd image to use, if any.\n"
+       "      setup -       The address of the kernel setup region, if this\n"
+       "                    is not at addr\n"
        "\n"
        "Sub-commands to do part of the zboot sequence:\n"
        "\tstart [addr [arg ...]] - specify arguments\n"
-- 
2.28.0.526.ge36021eeef-goog

Reply via email to