ARC: bootm: Refactor GO and PREP subcommands implementation

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>
This commit is contained in:
Eugeniy Paltsev 2018-03-23 15:35:03 +03:00 committed by Alexey Brodkin
parent 6b85b26e4b
commit f665c14f04
3 changed files with 52 additions and 22 deletions

View File

@ -46,35 +46,47 @@ static int cleanup_before_linux(void)
return 0; return 0;
} }
__weak int board_prep_linux(bootm_headers_t *images) { return 0; }
/* Subcommand: PREP */ /* 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)) int ret;
hang();
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) {} /* Generic implementation for single core CPU */
__weak void smp_kick_all_cpus(void) {} __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 */ /* Subcommand: GO */
static void boot_jump_linux(bootm_headers_t *images, int flag) 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; unsigned int r0, r2;
int fake = (flag & BOOTM_STATE_OS_FAKE_GO); 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", debug("## Transferring control to Linux (at address %08lx)...\n",
(ulong) kernel_entry); kernel_entry);
bootstage_mark(BOOTSTAGE_ID_RUN_OS); bootstage_mark(BOOTSTAGE_ID_RUN_OS);
printf("\nStarting kernel ...%s\n\n", fake ? printf("\nStarting kernel ...%s\n\n", fake ?
"(fake run for tracing)" : ""); "(fake run for tracing)" : "");
bootstage_mark_name(BOOTSTAGE_ID_BOOTM_HANDOFF, "start_kernel"); bootstage_mark_name(BOOTSTAGE_ID_BOOTM_HANDOFF, "start_kernel");
cleanup_before_linux();
if (IMAGE_ENABLE_OF_LIBFDT && images->ft_len) { if (IMAGE_ENABLE_OF_LIBFDT && images->ft_len) {
r0 = 2; r0 = 2;
r2 = (unsigned int)images->ft_addr; 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"); r2 = (unsigned int)env_get("bootargs");
} }
if (!fake) { cleanup_before_linux();
smp_set_core_boot_addr((unsigned long)kernel_entry, -1);
smp_kick_all_cpus(); if (!fake)
kernel_entry(r0, 0, r2); board_jump_and_run(kernel_entry, r0, 0, r2);
}
} }
int do_bootm_linux(int flag, int argc, char *argv[], bootm_headers_t *images) 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)) if ((flag & BOOTM_STATE_OS_BD_T) || (flag & BOOTM_STATE_OS_CMDLINE))
return -1; return -1;
if (flag & BOOTM_STATE_OS_PREP) { if (flag & BOOTM_STATE_OS_PREP)
boot_prep_linux(images); return boot_prep_linux(images);
return 0;
}
if (flag & (BOOTM_STATE_OS_GO | BOOTM_STATE_OS_FAKE_GO)) { if (flag & (BOOTM_STATE_OS_GO | BOOTM_STATE_OS_FAKE_GO)) {
boot_jump_linux(images, flag); boot_jump_linux(images, flag);
return 0; return 0;
} }
boot_prep_linux(images); return -1;
boot_jump_linux(images, flag);
return 0;
} }

View File

@ -47,6 +47,18 @@ int board_early_init_f(void)
} }
#ifdef CONFIG_ISA_ARCV2 #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 #define RESET_VECTOR_ADDR 0x0
void smp_set_core_boot_addr(unsigned long addr, int corenr) void smp_set_core_boot_addr(unsigned long addr, int corenr)

View File

@ -58,6 +58,17 @@ int board_mmc_init(bd_t *bis)
return 0; 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 #define RESET_VECTOR_ADDR 0x0
void smp_set_core_boot_addr(unsigned long addr, int corenr) void smp_set_core_boot_addr(unsigned long addr, int corenr)