1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (c) 2016 Google, Inc
13 #include <asm/global_data.h>
15 #include <asm/state.h>
18 DECLARE_GLOBAL_DATA_PTR;
20 int sandbox_find_next_phase(char *fname, int maxlen, bool use_img)
22 const char *cur_prefix, *next_prefix;
25 cur_prefix = spl_phase_prefix(spl_phase());
26 next_prefix = spl_phase_prefix(spl_next_phase());
27 ret = os_find_u_boot(fname, maxlen, use_img, cur_prefix, next_prefix);
29 return log_msg_ret("find", ret);
34 /* SPL / TPL init function */
35 void board_init_f(ulong flag)
37 struct sandbox_state *state = state_get_current();
39 gd->arch.ram_buf = state->ram_buf;
40 gd->ram_size = state->ram_size;
43 u32 spl_boot_device(void)
45 return BOOT_DEVICE_BOARD;
48 static int spl_board_load_image(struct spl_image_info *spl_image,
49 struct spl_boot_device *bootdev)
54 ret = sandbox_find_next_phase(fname, sizeof(fname), false);
56 printf("(%s not found, error %d)\n", fname, ret);
61 * Set up spl_image to boot from jump_to_image_no_args(). Allocate this
62 * outsdide the RAM buffer (i.e. don't use strdup()).
64 spl_image->arg = os_malloc(strlen(fname) + 1);
66 return log_msg_ret("exec", -ENOMEM);
67 strcpy(spl_image->arg, fname);
71 SPL_LOAD_IMAGE_METHOD("sandbox", 9, BOOT_DEVICE_BOARD, spl_board_load_image);
73 void spl_board_init(void)
75 struct sandbox_state *state = state_get_current();
77 preloader_console_init();
79 if (state->run_unittests) {
80 struct unit_test *tests = UNIT_TEST_ALL_START();
81 const int count = UNIT_TEST_ALL_COUNT();
84 ret = ut_run_list("spl", NULL, tests, count,
85 state->select_unittests);
86 /* continue execution into U-Boot */
90 void __noreturn jump_to_image_no_args(struct spl_image_info *spl_image)
92 const char *fname = spl_image->arg;
96 os_spl_to_uboot(fname);
98 printf("No filename provided for U-Boot\n");
103 int handoff_arch_save(struct spl_handoff *ho)
105 ho->arch.magic = TEST_HANDOFF_MAGIC;