]> git.sur5r.net Git - u-boot/commitdiff
ARC: bootm: Refactor GO and PREP subcommands implementation
authorEugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
Fri, 23 Mar 2018 12:35:03 +0000 (15:35 +0300)
committerAlexey Brodkin <abrodkin@synopsys.com>
Fri, 23 Mar 2018 12:57:51 +0000 (15:57 +0300)
Refactor GO and PREP subcommands implementation for a simpler
override in the boards platform code.

Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com>
arch/arc/lib/bootm.c
board/synopsys/axs10x/axs10x.c
board/synopsys/hsdk/hsdk.c

index f1ab344773744a4c5f4b47fb6e15589171f8ccff..4f04aad34a7a01bef308f8f6a81efa6ca2c356d1 100644 (file)
@@ -46,35 +46,47 @@ static int cleanup_before_linux(void)
        return 0;
 }
 
+__weak int board_prep_linux(bootm_headers_t *images) { return 0; }
+
 /* Subcommand: PREP */
-static void boot_prep_linux(bootm_headers_t *images)
+static int boot_prep_linux(bootm_headers_t *images)
 {
-       if (image_setup_linux(images))
-               hang();
+       int ret;
+
+       ret = image_setup_linux(images);
+       if (ret)
+               return ret;
+
+       return board_prep_linux(images);
 }
 
-__weak void smp_set_core_boot_addr(unsigned long addr, int corenr) {}
-__weak void smp_kick_all_cpus(void) {}
+/* Generic implementation for single core CPU */
+__weak void board_jump_and_run(ulong entry, int zero, int arch, uint params)
+{
+       void (*kernel_entry)(int zero, int arch, uint params);
+
+       kernel_entry = (void (*)(int, int, uint))entry;
+
+       kernel_entry(zero, arch, params);
+}
 
 /* Subcommand: GO */
 static void boot_jump_linux(bootm_headers_t *images, int flag)
 {
-       void (*kernel_entry)(int zero, int arch, uint params);
+       ulong kernel_entry;
        unsigned int r0, r2;
        int fake = (flag & BOOTM_STATE_OS_FAKE_GO);
 
-       kernel_entry = (void (*)(int, int, uint))images->ep;
+       kernel_entry = images->ep;
 
        debug("## Transferring control to Linux (at address %08lx)...\n",
-             (ulong) kernel_entry);
+             kernel_entry);
        bootstage_mark(BOOTSTAGE_ID_RUN_OS);
 
        printf("\nStarting kernel ...%s\n\n", fake ?
               "(fake run for tracing)" : "");
        bootstage_mark_name(BOOTSTAGE_ID_BOOTM_HANDOFF, "start_kernel");
 
-       cleanup_before_linux();
-
        if (IMAGE_ENABLE_OF_LIBFDT && images->ft_len) {
                r0 = 2;
                r2 = (unsigned int)images->ft_addr;
@@ -83,11 +95,10 @@ static void boot_jump_linux(bootm_headers_t *images, int flag)
                r2 = (unsigned int)env_get("bootargs");
        }
 
-       if (!fake) {
-               smp_set_core_boot_addr((unsigned long)kernel_entry, -1);
-               smp_kick_all_cpus();
-               kernel_entry(r0, 0, r2);
-       }
+       cleanup_before_linux();
+
+       if (!fake)
+               board_jump_and_run(kernel_entry, r0, 0, r2);
 }
 
 int do_bootm_linux(int flag, int argc, char *argv[], bootm_headers_t *images)
@@ -96,17 +107,13 @@ int do_bootm_linux(int flag, int argc, char *argv[], bootm_headers_t *images)
        if ((flag & BOOTM_STATE_OS_BD_T) || (flag & BOOTM_STATE_OS_CMDLINE))
                return -1;
 
-       if (flag & BOOTM_STATE_OS_PREP) {
-               boot_prep_linux(images);
-               return 0;
-       }
+       if (flag & BOOTM_STATE_OS_PREP)
+               return boot_prep_linux(images);
 
        if (flag & (BOOTM_STATE_OS_GO | BOOTM_STATE_OS_FAKE_GO)) {
                boot_jump_linux(images, flag);
                return 0;
        }
 
-       boot_prep_linux(images);
-       boot_jump_linux(images, flag);
-       return 0;
+       return -1;
 }
index e6b69da3da7fb41c8a851d89f8ed6588bf5f5d90..18f7666b1582c18ca5fca37f5b333e4003e02f80 100644 (file)
@@ -47,6 +47,18 @@ int board_early_init_f(void)
 }
 
 #ifdef CONFIG_ISA_ARCV2
+
+void board_jump_and_run(ulong entry, int zero, int arch, uint params)
+{
+       void (*kernel_entry)(int zero, int arch, uint params);
+
+       kernel_entry = (void (*)(int, int, uint))entry;
+
+       smp_set_core_boot_addr(entry, -1);
+       smp_kick_all_cpus();
+       kernel_entry(zero, arch, params);
+}
+
 #define RESET_VECTOR_ADDR      0x0
 
 void smp_set_core_boot_addr(unsigned long addr, int corenr)
index 7641978a7b13d7b5bd17cccca06b640499c8b49e..5b3a063b69059ceb5ed6580178eb7f02a1249873 100644 (file)
@@ -58,6 +58,17 @@ int board_mmc_init(bd_t *bis)
        return 0;
 }
 
+void board_jump_and_run(ulong entry, int zero, int arch, uint params)
+{
+       void (*kernel_entry)(int zero, int arch, uint params);
+
+       kernel_entry = (void (*)(int, int, uint))entry;
+
+       smp_set_core_boot_addr(entry, -1);
+       smp_kick_all_cpus();
+       kernel_entry(zero, arch, params);
+}
+
 #define RESET_VECTOR_ADDR      0x0
 
 void smp_set_core_boot_addr(unsigned long addr, int corenr)