2018-05-06 21:58:06 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
2016-07-04 17:57:51 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2016 Google, Inc
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
|
|
|
#include <dm.h>
|
|
|
|
#include <os.h>
|
2016-07-04 17:57:55 +00:00
|
|
|
#include <spl.h>
|
2016-07-04 17:57:51 +00:00
|
|
|
#include <asm/spl.h>
|
|
|
|
#include <asm/state.h>
|
|
|
|
|
|
|
|
DECLARE_GLOBAL_DATA_PTR;
|
|
|
|
|
2019-05-18 17:59:46 +00:00
|
|
|
/* SPL / TPL init function */
|
2016-07-04 17:57:51 +00:00
|
|
|
void board_init_f(ulong flag)
|
|
|
|
{
|
|
|
|
struct sandbox_state *state = state_get_current();
|
|
|
|
|
|
|
|
gd->arch.ram_buf = state->ram_buf;
|
|
|
|
gd->ram_size = state->ram_size;
|
|
|
|
}
|
|
|
|
|
|
|
|
u32 spl_boot_device(void)
|
|
|
|
{
|
|
|
|
return BOOT_DEVICE_BOARD;
|
|
|
|
}
|
|
|
|
|
2016-09-25 00:20:13 +00:00
|
|
|
static int spl_board_load_image(struct spl_image_info *spl_image,
|
|
|
|
struct spl_boot_device *bootdev)
|
2016-07-04 17:57:51 +00:00
|
|
|
{
|
|
|
|
char fname[256];
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret = os_find_u_boot(fname, sizeof(fname));
|
2016-11-30 22:30:56 +00:00
|
|
|
if (ret) {
|
|
|
|
printf("(%s not found, error %d)\n", fname, ret);
|
2016-07-04 17:57:51 +00:00
|
|
|
return ret;
|
2016-11-30 22:30:56 +00:00
|
|
|
}
|
2016-07-04 17:57:51 +00:00
|
|
|
|
2018-11-16 01:44:08 +00:00
|
|
|
/* Set up spl_image to boot from jump_to_image_no_args() */
|
|
|
|
spl_image->arg = strdup(fname);
|
|
|
|
if (!spl_image->arg)
|
|
|
|
return log_msg_ret("Setup exec filename", -ENOMEM);
|
|
|
|
|
|
|
|
return 0;
|
2016-07-04 17:57:51 +00:00
|
|
|
}
|
2019-05-18 17:59:45 +00:00
|
|
|
SPL_LOAD_IMAGE_METHOD("sandbox", 9, BOOT_DEVICE_BOARD, spl_board_load_image);
|
2016-07-04 17:57:55 +00:00
|
|
|
|
|
|
|
void spl_board_init(void)
|
|
|
|
{
|
2018-11-16 01:44:01 +00:00
|
|
|
struct sandbox_state *state = state_get_current();
|
|
|
|
struct udevice *dev;
|
|
|
|
|
2016-07-04 17:57:55 +00:00
|
|
|
preloader_console_init();
|
2018-11-16 01:44:01 +00:00
|
|
|
if (state->show_of_platdata) {
|
|
|
|
/*
|
|
|
|
* Scan all the devices so that we can output their platform
|
|
|
|
* data. See sandbox_spl_probe().
|
|
|
|
*/
|
|
|
|
printf("Scanning misc devices\n");
|
|
|
|
for (uclass_first_device(UCLASS_MISC, &dev);
|
|
|
|
dev;
|
|
|
|
uclass_next_device(&dev))
|
|
|
|
;
|
|
|
|
}
|
2016-07-04 17:57:55 +00:00
|
|
|
}
|
2018-11-16 01:44:08 +00:00
|
|
|
|
|
|
|
void __noreturn jump_to_image_no_args(struct spl_image_info *spl_image)
|
|
|
|
{
|
|
|
|
const char *fname = spl_image->arg;
|
|
|
|
|
2018-11-24 04:29:25 +00:00
|
|
|
if (fname) {
|
|
|
|
os_fd_restore();
|
|
|
|
os_spl_to_uboot(fname);
|
|
|
|
} else {
|
|
|
|
printf("No filename provided for U-Boot\n");
|
|
|
|
}
|
2018-11-16 01:44:08 +00:00
|
|
|
hang();
|
|
|
|
}
|
2019-09-25 14:11:18 +00:00
|
|
|
|
|
|
|
int handoff_arch_save(struct spl_handoff *ho)
|
|
|
|
{
|
|
|
|
ho->arch.magic = TEST_HANDOFF_MAGIC;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|