1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (c) 2016 Google, Inc
14 #include <asm/global_data.h>
16 #include <asm/state.h>
19 DECLARE_GLOBAL_DATA_PTR;
21 int sandbox_find_next_phase(char *fname, int maxlen, bool use_img)
23 const char *cur_prefix, *next_prefix;
26 cur_prefix = spl_phase_prefix(spl_phase());
27 next_prefix = spl_phase_prefix(spl_next_phase());
28 ret = os_find_u_boot(fname, maxlen, use_img, cur_prefix, next_prefix);
30 return log_msg_ret("find", ret);
35 /* SPL / TPL init function */
36 void board_init_f(ulong flag)
38 struct sandbox_state *state = state_get_current();
40 gd->arch.ram_buf = state->ram_buf;
41 gd->ram_size = state->ram_size;
44 u32 spl_boot_device(void)
46 return BOOT_DEVICE_BOARD;
49 static int spl_board_load_image(struct spl_image_info *spl_image,
50 struct spl_boot_device *bootdev)
55 ret = sandbox_find_next_phase(fname, sizeof(fname), false);
57 printf("(%s not found, error %d)\n", fname, ret);
62 * Set up spl_image to boot from jump_to_image_no_args(). Allocate this
63 * outsdide the RAM buffer (i.e. don't use strdup()).
65 spl_image->arg = os_malloc(strlen(fname) + 1);
67 return log_msg_ret("exec", -ENOMEM);
68 strcpy(spl_image->arg, fname);
72 SPL_LOAD_IMAGE_METHOD("sandbox", 9, BOOT_DEVICE_BOARD, spl_board_load_image);
74 void spl_board_init(void)
76 struct sandbox_state *state = state_get_current();
78 preloader_console_init();
80 if (state->run_unittests) {
81 struct unit_test *tests = UNIT_TEST_ALL_START();
82 const int count = UNIT_TEST_ALL_COUNT();
85 ret = ut_run_list("spl", NULL, tests, count,
86 state->select_unittests);
87 /* continue execution into U-Boot */
91 void __noreturn jump_to_image_no_args(struct spl_image_info *spl_image)
93 const char *fname = spl_image->arg;
97 os_spl_to_uboot(fname);
99 printf("No filename provided for U-Boot\n");
104 int handoff_arch_save(struct spl_handoff *ho)
106 ho->arch.magic = TEST_HANDOFF_MAGIC;