2018-05-06 21:58:06 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
2014-06-12 13:24:46 +00:00
|
|
|
/*
|
|
|
|
* (C) Copyright 2000-2009
|
|
|
|
* Wolfgang Denk, DENX Software Engineering, wd@denx.de.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
|
|
|
#include <bootm.h>
|
2020-05-10 17:40:00 +00:00
|
|
|
#include <bootstage.h>
|
2019-11-14 19:57:37 +00:00
|
|
|
#include <cpu_func.h>
|
2019-12-24 16:05:39 +00:00
|
|
|
#include <efi_loader.h>
|
2019-08-01 15:46:46 +00:00
|
|
|
#include <env.h>
|
2014-06-12 13:24:46 +00:00
|
|
|
#include <fdt_support.h>
|
2020-05-10 17:40:01 +00:00
|
|
|
#include <image.h>
|
|
|
|
#include <lmb.h>
|
2020-05-10 17:40:05 +00:00
|
|
|
#include <log.h>
|
2020-10-31 03:38:53 +00:00
|
|
|
#include <asm/global_data.h>
|
2018-03-04 16:20:11 +00:00
|
|
|
#include <linux/libfdt.h>
|
2014-06-12 13:24:46 +00:00
|
|
|
#include <malloc.h>
|
2019-12-24 16:05:39 +00:00
|
|
|
#include <mapmem.h>
|
2014-06-12 13:24:46 +00:00
|
|
|
#include <vxworks.h>
|
2018-03-13 16:50:36 +00:00
|
|
|
#include <tee/optee.h>
|
2014-06-12 13:24:46 +00:00
|
|
|
|
|
|
|
DECLARE_GLOBAL_DATA_PTR;
|
|
|
|
|
2023-12-16 03:14:13 +00:00
|
|
|
static int do_bootm_standalone(int flag, struct bootm_info *bmi)
|
2014-06-12 13:24:46 +00:00
|
|
|
{
|
2023-12-16 03:14:13 +00:00
|
|
|
struct bootm_headers *images = bmi->images;
|
2014-06-12 13:24:46 +00:00
|
|
|
int (*appl)(int, char *const[]);
|
|
|
|
|
2021-10-22 03:08:52 +00:00
|
|
|
if (!env_get_autostart()) {
|
2017-08-03 18:22:10 +00:00
|
|
|
env_set_hex("filesize", images->os.image_len);
|
2014-06-12 13:24:46 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
appl = (int (*)(int, char * const []))images->ep;
|
2023-12-16 03:14:13 +00:00
|
|
|
appl(bmi->argc, bmi->argv);
|
2014-06-12 13:24:46 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*******************************************************************/
|
|
|
|
/* OS booting routines */
|
|
|
|
/*******************************************************************/
|
|
|
|
|
|
|
|
#if defined(CONFIG_BOOTM_NETBSD) || defined(CONFIG_BOOTM_PLAN9)
|
2020-05-10 17:40:03 +00:00
|
|
|
static void copy_args(char *dest, int argc, char *const argv[], char delim)
|
2014-06-12 13:24:46 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < argc; i++) {
|
|
|
|
if (i > 0)
|
|
|
|
*dest++ = delim;
|
|
|
|
strcpy(dest, argv[i]);
|
|
|
|
dest += strlen(argv[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2021-09-26 01:43:32 +00:00
|
|
|
static void __maybe_unused fit_unsupported_reset(const char *msg)
|
|
|
|
{
|
|
|
|
if (CONFIG_IS_ENABLED(FIT_VERBOSE)) {
|
|
|
|
printf("! FIT images not supported for '%s' - must reset board to recover!\n",
|
|
|
|
msg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-06-12 13:24:46 +00:00
|
|
|
#ifdef CONFIG_BOOTM_NETBSD
|
2023-12-16 03:14:13 +00:00
|
|
|
static int do_bootm_netbsd(int flag, struct bootm_info *bmi)
|
2014-06-12 13:24:46 +00:00
|
|
|
{
|
2023-12-16 03:14:13 +00:00
|
|
|
struct bootm_headers *images = bmi->images;
|
2022-09-07 02:26:52 +00:00
|
|
|
void (*loader)(struct bd_info *bd, struct legacy_img_hdr *hdr,
|
|
|
|
char *console, char *cmdline);
|
|
|
|
struct legacy_img_hdr *os_hdr, *hdr;
|
2014-06-12 13:24:46 +00:00
|
|
|
ulong kernel_data, kernel_len;
|
|
|
|
char *cmdline;
|
|
|
|
|
|
|
|
if (flag != BOOTM_STATE_OS_GO)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
#if defined(CONFIG_FIT)
|
|
|
|
if (!images->legacy_hdr_valid) {
|
|
|
|
fit_unsupported_reset("NetBSD");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
hdr = images->legacy_hdr_os;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Booting a (NetBSD) kernel image
|
|
|
|
*
|
|
|
|
* This process is pretty similar to a standalone application:
|
|
|
|
* The (first part of an multi-) image must be a stage-2 loader,
|
|
|
|
* which in turn is responsible for loading & invoking the actual
|
|
|
|
* kernel. The only differences are the parameters being passed:
|
|
|
|
* besides the board info strucure, the loader expects a command
|
|
|
|
* line, the name of the console device, and (optionally) the
|
|
|
|
* address of the original image header.
|
|
|
|
*/
|
|
|
|
os_hdr = NULL;
|
|
|
|
if (image_check_type(&images->legacy_hdr_os_copy, IH_TYPE_MULTI)) {
|
|
|
|
image_multi_getimg(hdr, 1, &kernel_data, &kernel_len);
|
|
|
|
if (kernel_len)
|
|
|
|
os_hdr = hdr;
|
|
|
|
}
|
|
|
|
|
2023-12-16 03:14:13 +00:00
|
|
|
if (bmi->argc > 0) {
|
2014-06-12 13:24:46 +00:00
|
|
|
ulong len;
|
|
|
|
int i;
|
|
|
|
|
2023-12-16 03:14:13 +00:00
|
|
|
for (i = 0, len = 0; i < bmi->argc; i += 1)
|
|
|
|
len += strlen(bmi->argv[i]) + 1;
|
2014-06-12 13:24:46 +00:00
|
|
|
cmdline = malloc(len);
|
2023-12-16 03:14:13 +00:00
|
|
|
copy_args(cmdline, bmi->argc, bmi->argv, ' ');
|
2014-06-12 13:24:46 +00:00
|
|
|
} else {
|
2017-08-03 18:22:12 +00:00
|
|
|
cmdline = env_get("bootargs");
|
2014-06-12 13:24:46 +00:00
|
|
|
if (cmdline == NULL)
|
|
|
|
cmdline = "";
|
|
|
|
}
|
|
|
|
|
2022-09-07 02:26:52 +00:00
|
|
|
loader = (void (*)(struct bd_info *, struct legacy_img_hdr *, char *, char *))images->ep;
|
2014-06-12 13:24:46 +00:00
|
|
|
|
|
|
|
printf("## Transferring control to NetBSD stage-2 loader (at address %08lx) ...\n",
|
|
|
|
(ulong)loader);
|
|
|
|
|
|
|
|
bootstage_mark(BOOTSTAGE_ID_RUN_OS);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* NetBSD Stage-2 Loader Parameters:
|
|
|
|
* arg[0]: pointer to board info data
|
|
|
|
* arg[1]: image load address
|
|
|
|
* arg[2]: char pointer to the console device to use
|
|
|
|
* arg[3]: char pointer to the boot arguments
|
|
|
|
*/
|
2017-06-07 15:33:09 +00:00
|
|
|
(*loader)(gd->bd, os_hdr, "", cmdline);
|
2014-06-12 13:24:46 +00:00
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
#endif /* CONFIG_BOOTM_NETBSD*/
|
|
|
|
|
|
|
|
#ifdef CONFIG_BOOTM_RTEMS
|
2023-12-16 03:14:13 +00:00
|
|
|
static int do_bootm_rtems(int flag, struct bootm_info *bmi)
|
2014-06-12 13:24:46 +00:00
|
|
|
{
|
2023-12-16 03:14:13 +00:00
|
|
|
struct bootm_headers *images = bmi->images;
|
2020-06-26 06:13:33 +00:00
|
|
|
void (*entry_point)(struct bd_info *);
|
2014-06-12 13:24:46 +00:00
|
|
|
|
|
|
|
if (flag != BOOTM_STATE_OS_GO)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
#if defined(CONFIG_FIT)
|
|
|
|
if (!images->legacy_hdr_valid) {
|
|
|
|
fit_unsupported_reset("RTEMS");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2020-06-26 06:13:33 +00:00
|
|
|
entry_point = (void (*)(struct bd_info *))images->ep;
|
2014-06-12 13:24:46 +00:00
|
|
|
|
|
|
|
printf("## Transferring control to RTEMS (at address %08lx) ...\n",
|
|
|
|
(ulong)entry_point);
|
|
|
|
|
|
|
|
bootstage_mark(BOOTSTAGE_ID_RUN_OS);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* RTEMS Parameters:
|
|
|
|
* r3: ptr to board info data
|
|
|
|
*/
|
|
|
|
(*entry_point)(gd->bd);
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
#endif /* CONFIG_BOOTM_RTEMS */
|
|
|
|
|
|
|
|
#if defined(CONFIG_BOOTM_OSE)
|
2023-12-16 03:14:13 +00:00
|
|
|
static int do_bootm_ose(int flag, struct bootm_info *bmi)
|
2014-06-12 13:24:46 +00:00
|
|
|
{
|
2023-12-16 03:14:13 +00:00
|
|
|
struct bootm_headers *images = bmi->images;
|
2014-06-12 13:24:46 +00:00
|
|
|
void (*entry_point)(void);
|
|
|
|
|
|
|
|
if (flag != BOOTM_STATE_OS_GO)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
#if defined(CONFIG_FIT)
|
|
|
|
if (!images->legacy_hdr_valid) {
|
|
|
|
fit_unsupported_reset("OSE");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
entry_point = (void (*)(void))images->ep;
|
|
|
|
|
|
|
|
printf("## Transferring control to OSE (at address %08lx) ...\n",
|
|
|
|
(ulong)entry_point);
|
|
|
|
|
|
|
|
bootstage_mark(BOOTSTAGE_ID_RUN_OS);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* OSE Parameters:
|
|
|
|
* None
|
|
|
|
*/
|
|
|
|
(*entry_point)();
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
#endif /* CONFIG_BOOTM_OSE */
|
|
|
|
|
|
|
|
#if defined(CONFIG_BOOTM_PLAN9)
|
2023-12-16 03:14:13 +00:00
|
|
|
static int do_bootm_plan9(int flag, struct bootm_info *bmi)
|
2014-06-12 13:24:46 +00:00
|
|
|
{
|
2023-12-16 03:14:13 +00:00
|
|
|
struct bootm_headers *images = bmi->images;
|
2014-06-12 13:24:46 +00:00
|
|
|
void (*entry_point)(void);
|
|
|
|
char *s;
|
|
|
|
|
|
|
|
if (flag != BOOTM_STATE_OS_GO)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
#if defined(CONFIG_FIT)
|
|
|
|
if (!images->legacy_hdr_valid) {
|
|
|
|
fit_unsupported_reset("Plan 9");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* See README.plan9 */
|
2017-08-03 18:22:12 +00:00
|
|
|
s = env_get("confaddr");
|
2014-06-12 13:24:46 +00:00
|
|
|
if (s != NULL) {
|
2021-07-24 15:03:29 +00:00
|
|
|
char *confaddr = (char *)hextoul(s, NULL);
|
2014-06-12 13:24:46 +00:00
|
|
|
|
2023-12-16 03:14:13 +00:00
|
|
|
if (bmi->argc) {
|
|
|
|
copy_args(confaddr, bmi->argc, bmi->argv, '\n');
|
2014-06-12 13:24:46 +00:00
|
|
|
} else {
|
2017-08-03 18:22:12 +00:00
|
|
|
s = env_get("bootargs");
|
2014-06-12 13:24:46 +00:00
|
|
|
if (s != NULL)
|
|
|
|
strcpy(confaddr, s);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
entry_point = (void (*)(void))images->ep;
|
|
|
|
|
|
|
|
printf("## Transferring control to Plan 9 (at address %08lx) ...\n",
|
|
|
|
(ulong)entry_point);
|
|
|
|
|
|
|
|
bootstage_mark(BOOTSTAGE_ID_RUN_OS);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Plan 9 Parameters:
|
|
|
|
* None
|
|
|
|
*/
|
|
|
|
(*entry_point)();
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
#endif /* CONFIG_BOOTM_PLAN9 */
|
|
|
|
|
|
|
|
#if defined(CONFIG_BOOTM_VXWORKS) && \
|
|
|
|
(defined(CONFIG_PPC) || defined(CONFIG_ARM))
|
|
|
|
|
2022-09-07 02:26:50 +00:00
|
|
|
static void do_bootvx_fdt(struct bootm_headers *images)
|
2014-06-12 13:24:46 +00:00
|
|
|
{
|
|
|
|
#if defined(CONFIG_OF_LIBFDT)
|
|
|
|
int ret;
|
|
|
|
char *bootline;
|
|
|
|
ulong of_size = images->ft_len;
|
|
|
|
char **of_flat_tree = &images->ft_addr;
|
|
|
|
struct lmb *lmb = &images->lmb;
|
|
|
|
|
|
|
|
if (*of_flat_tree) {
|
|
|
|
boot_fdt_add_mem_rsv_regions(lmb, *of_flat_tree);
|
|
|
|
|
|
|
|
ret = boot_relocate_fdt(lmb, of_flat_tree, &of_size);
|
|
|
|
if (ret)
|
|
|
|
return;
|
|
|
|
|
2017-08-25 12:27:37 +00:00
|
|
|
/* Update ethernet nodes */
|
|
|
|
fdt_fixup_ethernet(*of_flat_tree);
|
|
|
|
|
2014-06-12 13:24:46 +00:00
|
|
|
ret = fdt_add_subnode(*of_flat_tree, 0, "chosen");
|
|
|
|
if ((ret >= 0 || ret == -FDT_ERR_EXISTS)) {
|
2017-08-03 18:22:12 +00:00
|
|
|
bootline = env_get("bootargs");
|
2014-06-12 13:24:46 +00:00
|
|
|
if (bootline) {
|
|
|
|
ret = fdt_find_and_setprop(*of_flat_tree,
|
|
|
|
"/chosen", "bootargs",
|
|
|
|
bootline,
|
|
|
|
strlen(bootline) + 1, 1);
|
|
|
|
if (ret < 0) {
|
|
|
|
printf("## ERROR: %s : %s\n", __func__,
|
|
|
|
fdt_strerror(ret));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
printf("## ERROR: %s : %s\n", __func__,
|
|
|
|
fdt_strerror(ret));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
boot_prep_vxworks(images);
|
|
|
|
|
|
|
|
bootstage_mark(BOOTSTAGE_ID_RUN_OS);
|
|
|
|
|
|
|
|
#if defined(CONFIG_OF_LIBFDT)
|
|
|
|
printf("## Starting vxWorks at 0x%08lx, device tree at 0x%08lx ...\n",
|
|
|
|
(ulong)images->ep, (ulong)*of_flat_tree);
|
|
|
|
#else
|
|
|
|
printf("## Starting vxWorks at 0x%08lx\n", (ulong)images->ep);
|
|
|
|
#endif
|
2022-09-05 09:31:21 +00:00
|
|
|
flush();
|
2014-06-12 13:24:46 +00:00
|
|
|
|
|
|
|
boot_jump_vxworks(images);
|
|
|
|
|
|
|
|
puts("## vxWorks terminated\n");
|
|
|
|
}
|
|
|
|
|
2023-12-16 03:14:13 +00:00
|
|
|
static int do_bootm_vxworks_legacy(int flag, struct bootm_info *bmi)
|
2014-06-12 13:24:46 +00:00
|
|
|
{
|
2023-12-16 03:14:13 +00:00
|
|
|
struct bootm_headers *images = bmi->images;
|
|
|
|
|
2014-06-12 13:24:46 +00:00
|
|
|
if (flag != BOOTM_STATE_OS_GO)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
do_bootvx_fdt(images);
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
2019-11-15 08:21:17 +00:00
|
|
|
|
2023-12-16 03:14:13 +00:00
|
|
|
int do_bootm_vxworks(int flag, struct bootm_info *bmi)
|
2019-11-15 08:21:17 +00:00
|
|
|
{
|
|
|
|
char *bootargs;
|
|
|
|
int pos;
|
|
|
|
unsigned long vxflags;
|
|
|
|
bool std_dtb = false;
|
|
|
|
|
|
|
|
/* get bootargs env */
|
|
|
|
bootargs = env_get("bootargs");
|
|
|
|
|
|
|
|
if (bootargs != NULL) {
|
|
|
|
for (pos = 0; pos < strlen(bootargs); pos++) {
|
|
|
|
/* find f=0xnumber flag */
|
|
|
|
if ((bootargs[pos] == '=') && (pos >= 1) &&
|
|
|
|
(bootargs[pos - 1] == 'f')) {
|
2021-07-24 15:03:29 +00:00
|
|
|
vxflags = hextoul(&bootargs[pos + 1], NULL);
|
2019-11-15 08:21:17 +00:00
|
|
|
if (vxflags & VXWORKS_SYSFLG_STD_DTB)
|
|
|
|
std_dtb = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (std_dtb) {
|
|
|
|
if (flag & BOOTM_STATE_OS_PREP)
|
|
|
|
printf(" Using standard DTB\n");
|
2023-12-16 03:14:13 +00:00
|
|
|
return do_bootm_linux(flag, bmi);
|
2019-11-15 08:21:17 +00:00
|
|
|
} else {
|
|
|
|
if (flag & BOOTM_STATE_OS_PREP)
|
|
|
|
printf(" !!! WARNING !!! Using legacy DTB\n");
|
2023-12-16 03:14:13 +00:00
|
|
|
return do_bootm_vxworks_legacy(flag, bmi);
|
2019-11-15 08:21:17 +00:00
|
|
|
}
|
|
|
|
}
|
2014-06-12 13:24:46 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(CONFIG_CMD_ELF)
|
2023-12-16 03:14:13 +00:00
|
|
|
static int do_bootm_qnxelf(int flag, struct bootm_info *bmi)
|
2014-06-12 13:24:46 +00:00
|
|
|
{
|
2023-12-16 03:14:13 +00:00
|
|
|
struct bootm_headers *images = bmi->images;
|
2014-06-12 13:24:46 +00:00
|
|
|
char *local_args[2];
|
|
|
|
char str[16];
|
2017-01-19 09:23:56 +00:00
|
|
|
int dcache;
|
2014-06-12 13:24:46 +00:00
|
|
|
|
|
|
|
if (flag != BOOTM_STATE_OS_GO)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
#if defined(CONFIG_FIT)
|
|
|
|
if (!images->legacy_hdr_valid) {
|
|
|
|
fit_unsupported_reset("QNX");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
sprintf(str, "%lx", images->ep); /* write entry-point into string */
|
2023-12-16 03:14:13 +00:00
|
|
|
local_args[0] = bmi->argv[0];
|
2014-06-12 13:24:46 +00:00
|
|
|
local_args[1] = str; /* and provide it via the arguments */
|
2017-01-19 09:23:56 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* QNX images require the data cache is disabled.
|
|
|
|
*/
|
|
|
|
dcache = dcache_status();
|
|
|
|
if (dcache)
|
|
|
|
dcache_disable();
|
|
|
|
|
2014-06-12 13:24:46 +00:00
|
|
|
do_bootelf(NULL, 0, 2, local_args);
|
|
|
|
|
2017-01-19 09:23:56 +00:00
|
|
|
if (dcache)
|
|
|
|
dcache_enable();
|
|
|
|
|
2014-06-12 13:24:46 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef CONFIG_INTEGRITY
|
2023-12-16 03:14:13 +00:00
|
|
|
static int do_bootm_integrity(int flag, struct bootm_info *bmi)
|
2014-06-12 13:24:46 +00:00
|
|
|
{
|
2023-12-16 03:14:13 +00:00
|
|
|
struct bootm_headers *images = bmi->images;
|
2014-06-12 13:24:46 +00:00
|
|
|
void (*entry_point)(void);
|
|
|
|
|
|
|
|
if (flag != BOOTM_STATE_OS_GO)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
#if defined(CONFIG_FIT)
|
|
|
|
if (!images->legacy_hdr_valid) {
|
|
|
|
fit_unsupported_reset("INTEGRITY");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
entry_point = (void (*)(void))images->ep;
|
|
|
|
|
|
|
|
printf("## Transferring control to INTEGRITY (at address %08lx) ...\n",
|
|
|
|
(ulong)entry_point);
|
|
|
|
|
|
|
|
bootstage_mark(BOOTSTAGE_ID_RUN_OS);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* INTEGRITY Parameters:
|
|
|
|
* None
|
|
|
|
*/
|
|
|
|
(*entry_point)();
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2014-12-16 13:07:21 +00:00
|
|
|
#ifdef CONFIG_BOOTM_OPENRTOS
|
2023-12-16 03:14:13 +00:00
|
|
|
static int do_bootm_openrtos(int flag, struct bootm_info *bmi)
|
2014-12-16 13:07:21 +00:00
|
|
|
{
|
2023-12-16 03:14:13 +00:00
|
|
|
struct bootm_headers *images = bmi->images;
|
2014-12-16 13:07:21 +00:00
|
|
|
void (*entry_point)(void);
|
|
|
|
|
|
|
|
if (flag != BOOTM_STATE_OS_GO)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
entry_point = (void (*)(void))images->ep;
|
|
|
|
|
|
|
|
printf("## Transferring control to OpenRTOS (at address %08lx) ...\n",
|
|
|
|
(ulong)entry_point);
|
|
|
|
|
|
|
|
bootstage_mark(BOOTSTAGE_ID_RUN_OS);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* OpenRTOS Parameters:
|
|
|
|
* None
|
|
|
|
*/
|
|
|
|
(*entry_point)();
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2018-03-13 16:50:36 +00:00
|
|
|
#ifdef CONFIG_BOOTM_OPTEE
|
2023-12-16 03:14:13 +00:00
|
|
|
static int do_bootm_tee(int flag, struct bootm_info *bmi)
|
2018-03-13 16:50:36 +00:00
|
|
|
{
|
2023-12-16 03:14:13 +00:00
|
|
|
struct bootm_headers *images = bmi->images;
|
2018-03-13 16:50:36 +00:00
|
|
|
int ret;
|
|
|
|
|
|
|
|
/* Validate OPTEE header */
|
|
|
|
ret = optee_verify_bootm_image(images->os.image_start,
|
|
|
|
images->os.load,
|
|
|
|
images->os.image_len);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
/* From here we can run the regular linux boot path */
|
2023-12-16 03:14:13 +00:00
|
|
|
return do_bootm_linux(flag, bmi);
|
2018-03-13 16:50:36 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2019-12-24 16:05:39 +00:00
|
|
|
#ifdef CONFIG_BOOTM_EFI
|
2023-12-16 03:14:13 +00:00
|
|
|
static int do_bootm_efi(int flag, struct bootm_info *bmi)
|
2019-12-24 16:05:39 +00:00
|
|
|
{
|
2023-12-16 03:14:13 +00:00
|
|
|
struct bootm_headers *images = bmi->images;
|
2023-11-21 01:29:46 +00:00
|
|
|
int ret;
|
2019-12-24 16:05:39 +00:00
|
|
|
void *image_buf;
|
|
|
|
|
|
|
|
if (flag != BOOTM_STATE_OS_GO)
|
|
|
|
return 0;
|
|
|
|
|
2023-11-21 01:29:46 +00:00
|
|
|
/* We expect to return */
|
|
|
|
images->os.type = IH_TYPE_STANDALONE;
|
2019-12-24 16:05:39 +00:00
|
|
|
|
2023-11-21 01:29:46 +00:00
|
|
|
image_buf = map_sysmem(images->ep, images->os.image_len);
|
2019-12-24 16:05:39 +00:00
|
|
|
|
|
|
|
/* Run EFI image */
|
|
|
|
printf("## Transferring control to EFI (at address %08lx) ...\n",
|
|
|
|
images->ep);
|
|
|
|
bootstage_mark(BOOTSTAGE_ID_RUN_OS);
|
|
|
|
|
2023-11-21 01:29:46 +00:00
|
|
|
ret = efi_binary_run(image_buf, images->os.image_len,
|
|
|
|
images->ft_len
|
|
|
|
? images->ft_addr : EFI_FDT_USE_INTERNAL);
|
2020-07-18 08:54:26 +00:00
|
|
|
|
2023-11-21 01:29:46 +00:00
|
|
|
return ret;
|
2019-12-24 16:05:39 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2014-06-12 13:24:46 +00:00
|
|
|
static boot_os_fn *boot_os[] = {
|
|
|
|
[IH_OS_U_BOOT] = do_bootm_standalone,
|
|
|
|
#ifdef CONFIG_BOOTM_LINUX
|
|
|
|
[IH_OS_LINUX] = do_bootm_linux,
|
|
|
|
#endif
|
|
|
|
#ifdef CONFIG_BOOTM_NETBSD
|
|
|
|
[IH_OS_NETBSD] = do_bootm_netbsd,
|
|
|
|
#endif
|
|
|
|
#ifdef CONFIG_BOOTM_RTEMS
|
|
|
|
[IH_OS_RTEMS] = do_bootm_rtems,
|
|
|
|
#endif
|
|
|
|
#if defined(CONFIG_BOOTM_OSE)
|
|
|
|
[IH_OS_OSE] = do_bootm_ose,
|
|
|
|
#endif
|
|
|
|
#if defined(CONFIG_BOOTM_PLAN9)
|
|
|
|
[IH_OS_PLAN9] = do_bootm_plan9,
|
|
|
|
#endif
|
|
|
|
#if defined(CONFIG_BOOTM_VXWORKS) && \
|
2018-12-21 15:13:41 +00:00
|
|
|
(defined(CONFIG_PPC) || defined(CONFIG_ARM) || defined(CONFIG_RISCV))
|
2014-06-12 13:24:46 +00:00
|
|
|
[IH_OS_VXWORKS] = do_bootm_vxworks,
|
|
|
|
#endif
|
|
|
|
#if defined(CONFIG_CMD_ELF)
|
|
|
|
[IH_OS_QNX] = do_bootm_qnxelf,
|
|
|
|
#endif
|
|
|
|
#ifdef CONFIG_INTEGRITY
|
|
|
|
[IH_OS_INTEGRITY] = do_bootm_integrity,
|
|
|
|
#endif
|
2014-12-16 13:07:21 +00:00
|
|
|
#ifdef CONFIG_BOOTM_OPENRTOS
|
|
|
|
[IH_OS_OPENRTOS] = do_bootm_openrtos,
|
|
|
|
#endif
|
2018-03-13 16:50:36 +00:00
|
|
|
#ifdef CONFIG_BOOTM_OPTEE
|
|
|
|
[IH_OS_TEE] = do_bootm_tee,
|
|
|
|
#endif
|
2019-12-24 16:05:39 +00:00
|
|
|
#ifdef CONFIG_BOOTM_EFI
|
|
|
|
[IH_OS_EFI] = do_bootm_efi,
|
|
|
|
#endif
|
2014-06-12 13:24:46 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Allow for arch specific config before we boot */
|
2014-07-10 21:06:25 +00:00
|
|
|
__weak void arch_preboot_os(void)
|
2014-06-12 13:24:46 +00:00
|
|
|
{
|
|
|
|
/* please define platform specific arch_preboot_os() */
|
|
|
|
}
|
|
|
|
|
2018-10-04 19:16:31 +00:00
|
|
|
/* Allow for board specific config before we boot */
|
|
|
|
__weak void board_preboot_os(void)
|
|
|
|
{
|
|
|
|
/* please define board specific board_preboot_os() */
|
|
|
|
}
|
|
|
|
|
2023-12-16 03:14:20 +00:00
|
|
|
int boot_selected_os(int state, struct bootm_info *bmi, boot_os_fn *boot_fn)
|
2014-06-12 13:24:46 +00:00
|
|
|
{
|
|
|
|
arch_preboot_os();
|
2018-10-04 19:16:31 +00:00
|
|
|
board_preboot_os();
|
2023-12-16 03:14:13 +00:00
|
|
|
|
2023-12-16 03:14:20 +00:00
|
|
|
boot_fn(state, bmi);
|
2014-06-12 13:24:46 +00:00
|
|
|
|
|
|
|
/* Stand-alone may return when 'autostart' is 'no' */
|
2023-12-16 03:14:20 +00:00
|
|
|
if (bmi->images->os.type == IH_TYPE_STANDALONE ||
|
2016-07-03 15:40:35 +00:00
|
|
|
IS_ENABLED(CONFIG_SANDBOX) ||
|
2014-06-12 13:24:46 +00:00
|
|
|
state == BOOTM_STATE_OS_FAKE_GO) /* We expect to return */
|
|
|
|
return 0;
|
|
|
|
bootstage_error(BOOTSTAGE_ID_BOOT_OS_RETURNED);
|
2016-05-08 06:52:21 +00:00
|
|
|
debug("\n## Control returned to monitor - resetting...\n");
|
|
|
|
|
2014-06-12 13:24:46 +00:00
|
|
|
return BOOTM_ERR_RESET;
|
|
|
|
}
|
|
|
|
|
|
|
|
boot_os_fn *bootm_os_get_boot_func(int os)
|
|
|
|
{
|
|
|
|
return boot_os[os];
|
|
|
|
}
|