diff options
Diffstat (limited to 'common')
-rw-r--r-- | common/Kconfig | 7 | ||||
-rw-r--r-- | common/Makefile | 6 | ||||
-rw-r--r-- | common/board_r.c | 9 | ||||
-rw-r--r-- | common/menu.c | 44 | ||||
-rw-r--r-- | common/spl/Kconfig | 7 | ||||
-rw-r--r-- | common/spl/spl.c | 16 | ||||
-rw-r--r-- | common/spl/spl_fat.c | 1 | ||||
-rw-r--r-- | common/spl/spl_fit.c | 53 | ||||
-rw-r--r-- | common/usb.c | 1 |
9 files changed, 117 insertions, 27 deletions
diff --git a/common/Kconfig b/common/Kconfig index be517b80eb5..17539079f90 100644 --- a/common/Kconfig +++ b/common/Kconfig @@ -727,6 +727,13 @@ config BOARD_EARLY_INIT_R relocation. With this option, U-Boot calls board_early_init_r() in the post-relocation init sequence. +config BOARD_INIT + bool "Call board-specific init board_init() during init-calls" + default y if ARM || RISCV || SANDBOX + help + Some boards need an board_init() function called during the initcall + phase of startup. + config BOARD_POSTCLK_INIT bool "Call board_postclk_init" help diff --git a/common/Makefile b/common/Makefile index 35991562a12..d62ea34599e 100644 --- a/common/Makefile +++ b/common/Makefile @@ -19,6 +19,12 @@ obj-y += version.o # # boards obj-y += board_f.o obj-y += board_r.o +ifdef CONFIG_$(PHASE_)SYS_THUMB_BUILD +ifneq ($(CONFIG_SYS_ARM_ARCH),7) +CFLAGS_REMOVE_board_f.o := $(LTO_CFLAGS) +CFLAGS_REMOVE_board_r.o := $(LTO_CFLAGS) +endif +endif obj-$(CONFIG_DISPLAY_BOARDINFO) += board_info.o obj-$(CONFIG_DISPLAY_BOARDINFO_LATE) += board_info.o diff --git a/common/board_r.c b/common/board_r.c index 41c8dec8d49..143d51d0633 100644 --- a/common/board_r.c +++ b/common/board_r.c @@ -36,7 +36,6 @@ #include <env.h> #include <env_internal.h> #include <fdtdec.h> -#include <ide.h> #include <init.h> #include <initcall.h> #include <kgdb.h> @@ -145,7 +144,7 @@ static int initr_reloc_global_data(void) */ fixup_cpu(); #endif -#ifdef CONFIG_SYS_RELOC_GD_ENV_ADDR +#ifdef CONFIG_ENV_RELOC_GD_ENV_ADDR /* * Relocate the early env_addr pointer unless we know it is not inside * the binary. Some systems need this and for the rest, it doesn't hurt. @@ -443,9 +442,6 @@ static int should_load_env(void) if (IS_ENABLED(CONFIG_OF_CONTROL)) return ofnode_conf_read_int("load-environment", 1); - if (IS_ENABLED(CONFIG_DELAY_ENVIRONMENT)) - return 0; - return 1; } @@ -649,8 +645,7 @@ static void initcall_run_r(void) #if CONFIG_IS_ENABLED(ADDR_MAP) INITCALL(init_addr_map); #endif -#if CONFIG_IS_ENABLED(ARM) || CONFIG_IS_ENABLED(RISCV) || \ - CONFIG_IS_ENABLED(SANDBOX) +#if CONFIG_IS_ENABLED(BOARD_INIT) INITCALL(board_init); /* Setup chipselects */ #endif /* diff --git a/common/menu.c b/common/menu.c index 5a2126aa01a..ae5afa14766 100644 --- a/common/menu.c +++ b/common/menu.c @@ -8,6 +8,7 @@ #include <cli.h> #include <malloc.h> #include <errno.h> +#include <linux/ctype.h> #include <linux/delay.h> #include <linux/list.h> #include <watchdog.h> @@ -436,6 +437,29 @@ int menu_destroy(struct menu *m) return 1; } +static int bootmenu_conv_shortcut_key(struct bootmenu_data *menu, int ichar) +{ + int shortcut_key; + + ichar = tolower(ichar); + switch (ichar) { + /* a-z for bootmenu entry > 9 */ + case 'a' ... 'z': + shortcut_key = ichar - 'a' + 9; + break; + /* 1-9 for bootmenu entry <= 9 */ + case '1' ... '9': + shortcut_key = ichar - '1'; + break; + /* Reserve 0 for last option (aka Exit) */ + case '0': + default: + return -1; + } + + return shortcut_key; +} + enum bootmenu_key bootmenu_autoboot_loop(struct bootmenu_data *menu, struct cli_ch_state *cch) { @@ -443,12 +467,12 @@ enum bootmenu_key bootmenu_autoboot_loop(struct bootmenu_data *menu, int i, c; while (menu->delay > 0) { + int ichar; + if (ansi) printf(ANSI_CURSOR_POSITION, menu->count + 5, 3); printf("Hit any key to stop autoboot: %d ", menu->delay); for (i = 0; i < 100; ++i) { - int ichar; - if (!tstc()) { schedule(); mdelay(10); @@ -470,6 +494,11 @@ enum bootmenu_key bootmenu_autoboot_loop(struct bootmenu_data *menu, case 0x3: /* ^C */ key = BKEY_QUIT; break; + case 'A' ... 'Z': + case 'a' ... 'z': + case '0' ... '9': + key = BKEY_SHORTCUT; + break; default: key = BKEY_NONE; break; @@ -477,6 +506,9 @@ enum bootmenu_key bootmenu_autoboot_loop(struct bootmenu_data *menu, break; } + if (key == BKEY_SHORTCUT) + cch->shortcut_key = bootmenu_conv_shortcut_key(menu, ichar); + if (menu->delay < 0) break; @@ -524,6 +556,11 @@ enum bootmenu_key bootmenu_conv_key(int ichar) case ' ': key = BKEY_SPACE; break; + case 'A' ... 'Z': + case 'a' ... 'z': + case '0' ... '9': + key = BKEY_SHORTCUT; + break; default: key = BKEY_NONE; break; @@ -554,5 +591,8 @@ enum bootmenu_key bootmenu_loop(struct bootmenu_data *menu, key = bootmenu_conv_key(c); + if (key == BKEY_SHORTCUT) + cch->shortcut_key = bootmenu_conv_shortcut_key(menu, c); + return key; } diff --git a/common/spl/Kconfig b/common/spl/Kconfig index 77cf04d38ed..9a17ccb2d3d 100644 --- a/common/spl/Kconfig +++ b/common/spl/Kconfig @@ -80,7 +80,7 @@ config SPL_MAX_SIZE default 0x1b000 if AM33XX && !TI_SECURE_DEVICE default 0xec00 if OMAP34XX default 0x10000 if ARCH_MX6 && !MX6_OCRAM_256KB - default 0xbfa0 if MACH_SUN50I_H616 + default 0xbfa0 if MACH_SUN50I_H616 || MACH_SUN50I_A133 default 0x7000 if RCAR_GEN3 default 0x5fa0 if SUNXI_SRAM_ADDRESS = 0x0 default 0x7fa0 if ARCH_SUNXI @@ -423,7 +423,7 @@ config SPL_STACK default 0x91ffb8 if ARCH_MX6 && !MX6_OCRAM_256KB default 0x118000 if MACH_SUN50I_H6 default 0x52a00 if MACH_SUN50I_H616 - default 0x40000 if MACH_SUN8I_R528 + default 0x40000 if MACH_SUN8I_R528 || MACH_SUN50I_A133 default 0x54000 if MACH_SUN50I || MACH_SUN50I_H5 default 0x18000 if MACH_SUN9I default 0x8000 if ARCH_SUNXI @@ -488,7 +488,7 @@ config SPL_CUSTOM_SYS_MALLOC_ADDR config SPL_SYS_MALLOC_SIZE hex "Size of the SPL malloc pool" depends on SPL_SYS_MALLOC - default 0x180000 if BIOSEMU && RISCV + default 0x800000 if RISCV default 0x100000 config SPL_READ_ONLY @@ -1138,6 +1138,7 @@ config SPL_DM_SPI_FLASH config SPL_NET bool "Support networking" depends on !NET_LWIP + select SPL_USE_TINY_PRINTF_POINTER_SUPPORT if SPL_USE_TINY_PRINTF help Enable support for network devices (such as Ethernet) in SPL. This permits SPL to load U-Boot over a network link rather than diff --git a/common/spl/spl.c b/common/spl/spl.c index 76fd56dfe4b..d8e26605d20 100644 --- a/common/spl/spl.c +++ b/common/spl/spl.c @@ -392,7 +392,7 @@ int spl_load(struct spl_image_info *spl_image, } #endif -__weak void __noreturn jump_to_image_no_args(struct spl_image_info *spl_image) +__weak void __noreturn jump_to_image(struct spl_image_info *spl_image) { typedef void __noreturn (*image_entry_noargs_t)(void); @@ -689,7 +689,7 @@ void board_init_r(gd_t *dummy1, ulong dummy2) BOOT_DEVICE_NONE, BOOT_DEVICE_NONE, }; - spl_jump_to_image_t jump_to_image = &jump_to_image_no_args; + spl_jump_to_image_t jumper = &jump_to_image; struct spl_image_info spl_image; int ret, os; @@ -783,20 +783,20 @@ void board_init_r(gd_t *dummy1, ulong dummy2) } else if (CONFIG_IS_ENABLED(ATF) && os == IH_OS_ARM_TRUSTED_FIRMWARE) { debug("Jumping to U-Boot via ARM Trusted Firmware\n"); spl_fixup_fdt(spl_image_fdt_addr(&spl_image)); - jump_to_image = &spl_invoke_atf; + jumper = &spl_invoke_atf; } else if (CONFIG_IS_ENABLED(OPTEE_IMAGE) && os == IH_OS_TEE) { debug("Jumping to U-Boot via OP-TEE\n"); spl_board_prepare_for_optee(spl_image_fdt_addr(&spl_image)); - jump_to_image = &jump_to_image_optee; + jumper = &jump_to_image_optee; } else if (CONFIG_IS_ENABLED(OPENSBI) && os == IH_OS_OPENSBI) { debug("Jumping to U-Boot via RISC-V OpenSBI\n"); - jump_to_image = &spl_invoke_opensbi; + jumper = &spl_invoke_opensbi; } else if (CONFIG_IS_ENABLED(OS_BOOT) && os == IH_OS_LINUX) { debug("Jumping to Linux\n"); if (IS_ENABLED(CONFIG_SPL_OS_BOOT)) spl_fixup_fdt((void *)SPL_PAYLOAD_ARGS_ADDR); spl_board_prepare_for_linux(); - jump_to_image = &jump_to_image_linux; + jumper = &jump_to_image_linux; } else { debug("Unsupported OS image.. Jumping nevertheless..\n"); } @@ -848,7 +848,7 @@ void board_init_r(gd_t *dummy1, ulong dummy2) if (CONFIG_IS_ENABLED(RELOC_LOADER)) { int ret; - ret = spl_reloc_jump(&spl_image, jump_to_image); + ret = spl_reloc_jump(&spl_image, jumper); if (ret) { if (xpl_phase() == PHASE_VPL) printf("jump failed %d\n", ret); @@ -856,7 +856,7 @@ void board_init_r(gd_t *dummy1, ulong dummy2) } } - jump_to_image(&spl_image); + jumper(&spl_image); } /* diff --git a/common/spl/spl_fat.c b/common/spl/spl_fat.c index f426a068ff9..8b7cafa7291 100644 --- a/common/spl/spl_fat.c +++ b/common/spl/spl_fat.c @@ -16,6 +16,7 @@ #include <errno.h> #include <image.h> #include <linux/libfdt.h> +#include <asm/cache.h> static int fat_registered; diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c index 86506d6905c..b3824af475f 100644 --- a/common/spl/spl_fit.c +++ b/common/spl/spl_fit.c @@ -86,11 +86,12 @@ static int spl_fit_get_image_name(const struct spl_fit_info *ctx, str = name; for (i = 0; i < index; i++) { - str = strchr(str, '\0') + 1; - if (!str || (str - name >= len)) { + str = memchr(str, '\0', name + len - str); + if (!str) { found = false; break; } + str++; } if (!found && CONFIG_IS_ENABLED(SYSINFO) && !sysinfo_get(&sysinfo)) { @@ -199,7 +200,7 @@ static int get_aligned_image_size(struct spl_load_info *info, int data_size, * the image gets loaded to the address pointed to by the * load_addr member in this struct, if load_addr is not 0 * - * Return: 0 on success, -EPERM if this image is not the correct phase + * Return: 0 on success, -EBADSLT if this image is not the correct phase * (for CONFIG_BOOTMETH_VBE_SIMPLE_FW), or another negative error number on * other error. */ @@ -235,7 +236,7 @@ static int load_simple_fit(struct spl_load_info *info, ulong fit_offset, return ret; } else { log_debug("- phase mismatch, skipping this image\n"); - return -EPERM; + return -EBADSLT; } } @@ -474,7 +475,7 @@ static int spl_fit_append_fdt(struct spl_image_info *spl_image, image_info.load_addr = (ulong)tmpbuffer; ret = load_simple_fit(info, offset, ctx, node, &image_info); - if (ret == -EPERM) + if (ret == -EBADSLT) continue; else if (ret < 0) break; @@ -702,13 +703,51 @@ static int spl_simple_fit_read(struct spl_fit_info *ctx, */ size = get_aligned_image_size(info, size, 0); buf = board_spl_fit_buffer_addr(size, size, 1); + if (!buf) { + /* + * We assume that none of the board will ever use 0x0 as a + * valid load address. Theoretically some board could use it, + * but this is extremely unlikely. + */ + return -EIO; + } count = info->read(info, offset, size, buf); + if (!count) { + /* + * FIT could not be read. This means we should free the + * memory allocated by board_spl_fit_buffer_addr(). + * Unfortunately, we don't know what memory allocation + * mechanism was used: + * - For the SPL_SYS_MALLOC_SIMPLE case nothing could + * be done. The memory just could not be freed. + * - For statically allocated memory buffer we can try + * to reuse previously allocated memory (example: + * board_spl_fit_buffer_addr() function from the + * file test/image/spl_load.c). + * - For normall malloc() -- memory leak can't be easily + * avoided. To somehow reduce memory consumption the + * next calls of board_spl_fit_buffer_addr() could + * reallocate previously allocated buffer and use + * them again. This is somethat similar to the approach + * used for statically allocated buffer. + * + * Please note: + * - FIT images with data placed outside of the FIT + * structure will cause small memory leak (several + * kilobytes), + * - FIT images with data placed inside to the FIT + * structure may cause huge memory leak (up to + * several megabytes). Do NOT use such images! + */ + return -EIO; + } + ctx->fit = buf; debug("fit read offset %lx, size=%lu, dst=%p, count=%lu\n", offset, size, buf, count); - return (count == 0) ? -EIO : 0; + return 0; } static int spl_simple_fit_parse(struct spl_fit_info *ctx) @@ -834,7 +873,7 @@ int spl_load_simple_fit(struct spl_image_info *spl_image, image_info.load_addr = 0; ret = load_simple_fit(info, offset, &ctx, node, &image_info); - if (ret < 0 && ret != -EPERM) { + if (ret < 0 && ret != -EBADSLT) { printf("%s: can't load image loadables index %d (ret = %d)\n", __func__, index, ret); return ret; diff --git a/common/usb.c b/common/usb.c index 7a8435296c6..6a4ad346f4b 100644 --- a/common/usb.c +++ b/common/usb.c @@ -28,6 +28,7 @@ #include <command.h> #include <dm.h> #include <dm/device_compat.h> +#include <env.h> #include <log.h> #include <malloc.h> #include <memalign.h> |