Skip to content
Snippets Groups Projects
Commit f665c14f authored by Eugeniy Paltsev's avatar Eugeniy Paltsev Committed by Alexey Brodkin
Browse files

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: default avatarEugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
Signed-off-by: default avatarAlexey Brodkin <abrodkin@synopsys.com>
parent 6b85b26e
No related branches found
No related tags found
No related merge requests found
...@@ -46,35 +46,47 @@ static int cleanup_before_linux(void) ...@@ -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) ...@@ -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) ...@@ -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;
} }
...@@ -47,6 +47,18 @@ int board_early_init_f(void) ...@@ -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)
......
...@@ -58,6 +58,17 @@ int board_mmc_init(bd_t *bis) ...@@ -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)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment