2018-05-06 21:58:06 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
2014-02-04 08:56:15 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2013-2014 Synopsys, Inc. All rights reserved.
|
|
|
|
*/
|
|
|
|
|
2020-05-10 17:40:00 +00:00
|
|
|
#include <common.h>
|
|
|
|
#include <bootstage.h>
|
2020-05-10 17:40:03 +00:00
|
|
|
#include <env.h>
|
2020-05-10 17:40:01 +00:00
|
|
|
#include <image.h>
|
2019-11-14 19:57:42 +00:00
|
|
|
#include <irq_func.h>
|
2020-05-10 17:40:05 +00:00
|
|
|
#include <log.h>
|
2018-03-21 12:59:02 +00:00
|
|
|
#include <asm/cache.h>
|
2020-10-31 03:38:53 +00:00
|
|
|
#include <asm/global_data.h>
|
2014-02-04 08:56:15 +00:00
|
|
|
|
|
|
|
DECLARE_GLOBAL_DATA_PTR;
|
|
|
|
|
|
|
|
static int cleanup_before_linux(void)
|
|
|
|
{
|
|
|
|
disable_interrupts();
|
2018-03-21 12:59:02 +00:00
|
|
|
sync_n_cleanup_cache_all();
|
2014-02-04 08:56:15 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2022-09-07 02:26:50 +00:00
|
|
|
__weak int board_prep_linux(struct bootm_headers *images) { return 0; }
|
2018-03-23 12:35:03 +00:00
|
|
|
|
2014-02-04 08:56:15 +00:00
|
|
|
/* Subcommand: PREP */
|
2022-09-07 02:26:50 +00:00
|
|
|
static int boot_prep_linux(struct bootm_headers *images)
|
2014-02-04 08:56:15 +00:00
|
|
|
{
|
2018-03-23 12:35:03 +00:00
|
|
|
int ret;
|
|
|
|
|
2022-07-07 08:45:37 +00:00
|
|
|
if (CONFIG_IS_ENABLED(LMB)) {
|
|
|
|
ret = image_setup_linux(images);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
}
|
2018-03-23 12:35:03 +00:00
|
|
|
|
|
|
|
return board_prep_linux(images);
|
2014-02-04 08:56:15 +00:00
|
|
|
}
|
|
|
|
|
2018-03-23 12:35:03 +00:00
|
|
|
/* 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);
|
|
|
|
}
|
2015-04-13 10:37:05 +00:00
|
|
|
|
2014-02-04 08:56:15 +00:00
|
|
|
/* Subcommand: GO */
|
2022-09-07 02:26:50 +00:00
|
|
|
static void boot_jump_linux(struct bootm_headers *images, int flag)
|
2014-02-04 08:56:15 +00:00
|
|
|
{
|
2018-03-23 12:35:03 +00:00
|
|
|
ulong kernel_entry;
|
2014-02-04 08:56:15 +00:00
|
|
|
unsigned int r0, r2;
|
|
|
|
int fake = (flag & BOOTM_STATE_OS_FAKE_GO);
|
|
|
|
|
2018-03-23 12:35:03 +00:00
|
|
|
kernel_entry = images->ep;
|
2014-02-04 08:56:15 +00:00
|
|
|
|
|
|
|
debug("## Transferring control to Linux (at address %08lx)...\n",
|
2018-03-23 12:35:03 +00:00
|
|
|
kernel_entry);
|
2014-02-04 08:56:15 +00:00
|
|
|
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");
|
|
|
|
|
2021-09-26 01:43:21 +00:00
|
|
|
if (CONFIG_IS_ENABLED(OF_LIBFDT) && images->ft_len) {
|
2014-02-04 08:56:15 +00:00
|
|
|
r0 = 2;
|
|
|
|
r2 = (unsigned int)images->ft_addr;
|
|
|
|
} else {
|
|
|
|
r0 = 1;
|
2017-08-03 18:22:12 +00:00
|
|
|
r2 = (unsigned int)env_get("bootargs");
|
2014-02-04 08:56:15 +00:00
|
|
|
}
|
|
|
|
|
2018-03-23 12:35:03 +00:00
|
|
|
cleanup_before_linux();
|
|
|
|
|
|
|
|
if (!fake)
|
|
|
|
board_jump_and_run(kernel_entry, r0, 0, r2);
|
2014-02-04 08:56:15 +00:00
|
|
|
}
|
|
|
|
|
2022-09-07 02:26:50 +00:00
|
|
|
int do_bootm_linux(int flag, int argc, char *argv[], struct bootm_headers *images)
|
2014-02-04 08:56:15 +00:00
|
|
|
{
|
|
|
|
/* No need for those on ARC */
|
|
|
|
if ((flag & BOOTM_STATE_OS_BD_T) || (flag & BOOTM_STATE_OS_CMDLINE))
|
|
|
|
return -1;
|
|
|
|
|
2018-03-23 12:35:03 +00:00
|
|
|
if (flag & BOOTM_STATE_OS_PREP)
|
|
|
|
return boot_prep_linux(images);
|
2014-02-04 08:56:15 +00:00
|
|
|
|
|
|
|
if (flag & (BOOTM_STATE_OS_GO | BOOTM_STATE_OS_FAKE_GO)) {
|
|
|
|
boot_jump_linux(images, flag);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-03-23 12:35:03 +00:00
|
|
|
return -1;
|
2014-02-04 08:56:15 +00:00
|
|
|
}
|