Simon Glass | a7e2d4d | 2016-07-04 11:57:51 -0600 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2016 Google, Inc |
| 3 | * SPDX-License-Identifier: GPL-2.0+ |
| 4 | */ |
| 5 | |
| 6 | #include <common.h> |
| 7 | #include <dm.h> |
| 8 | #include <os.h> |
Simon Glass | 4e9c131 | 2016-07-04 11:57:55 -0600 | [diff] [blame] | 9 | #include <spl.h> |
Simon Glass | a7e2d4d | 2016-07-04 11:57:51 -0600 | [diff] [blame] | 10 | #include <asm/spl.h> |
| 11 | #include <asm/state.h> |
| 12 | |
| 13 | DECLARE_GLOBAL_DATA_PTR; |
| 14 | |
| 15 | void board_init_f(ulong flag) |
| 16 | { |
| 17 | struct sandbox_state *state = state_get_current(); |
| 18 | |
| 19 | gd->arch.ram_buf = state->ram_buf; |
| 20 | gd->ram_size = state->ram_size; |
| 21 | } |
| 22 | |
| 23 | u32 spl_boot_device(void) |
| 24 | { |
| 25 | return BOOT_DEVICE_BOARD; |
| 26 | } |
| 27 | |
Simon Glass | ee30679 | 2016-09-24 18:20:13 -0600 | [diff] [blame] | 28 | static int spl_board_load_image(struct spl_image_info *spl_image, |
| 29 | struct spl_boot_device *bootdev) |
Simon Glass | a7e2d4d | 2016-07-04 11:57:51 -0600 | [diff] [blame] | 30 | { |
| 31 | char fname[256]; |
| 32 | int ret; |
| 33 | |
| 34 | ret = os_find_u_boot(fname, sizeof(fname)); |
Simon Glass | e8845d2 | 2016-11-30 15:30:56 -0700 | [diff] [blame] | 35 | if (ret) { |
| 36 | printf("(%s not found, error %d)\n", fname, ret); |
Simon Glass | a7e2d4d | 2016-07-04 11:57:51 -0600 | [diff] [blame] | 37 | return ret; |
Simon Glass | e8845d2 | 2016-11-30 15:30:56 -0700 | [diff] [blame] | 38 | } |
Simon Glass | a7e2d4d | 2016-07-04 11:57:51 -0600 | [diff] [blame] | 39 | |
| 40 | /* Hopefully this will not return */ |
| 41 | return os_spl_to_uboot(fname); |
| 42 | } |
Simon Glass | 4fc1f25 | 2016-11-30 15:30:50 -0700 | [diff] [blame] | 43 | SPL_LOAD_IMAGE_METHOD("sandbox", 0, BOOT_DEVICE_BOARD, spl_board_load_image); |
Simon Glass | 4e9c131 | 2016-07-04 11:57:55 -0600 | [diff] [blame] | 44 | |
| 45 | void spl_board_init(void) |
| 46 | { |
Simon Glass | 4e9c131 | 2016-07-04 11:57:55 -0600 | [diff] [blame] | 47 | preloader_console_init(); |
Simon Glass | 4e9c131 | 2016-07-04 11:57:55 -0600 | [diff] [blame] | 48 | } |