From 2289629f27f743003254d0a31ae9ed6175d1dd63 Mon Sep 17 00:00:00 2001 From: Hannu Lounento Date: Mon, 18 Oct 2021 08:49:03 +0300 Subject: image.h: make image_sign_info.fit point to const The data blob apparently does not need to be modified through the fit field of the image_sign_info struct so make it point to const to avoid the need to cast away constness in functions that assign a pointer to const data to the field. fit_image_setup_verify already had to cast away constness as it assigned a const void * argument to the field. The cast can now be removed. Signed-off-by: Hannu Lounento Reviewed-by: Simon Glass --- include/image.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/image.h b/include/image.h index 34d13ada84b..fd662e74b41 100644 --- a/include/image.h +++ b/include/image.h @@ -1159,7 +1159,7 @@ struct image_sign_info { const char *keydir; /* Directory conaining keys */ const char *keyname; /* Name of key to use */ const char *keyfile; /* Filename of private or public key */ - void *fit; /* Pointer to FIT blob */ + const void *fit; /* Pointer to FIT blob */ int node_offset; /* Offset of signature node */ const char *name; /* Algorithm name */ struct checksum_algo *checksum; /* Checksum algorithm information */ -- cgit v1.3.1 From c5cbbe35fd7b3d05273f4d3f273c9e613bd38d7d Mon Sep 17 00:00:00 2001 From: Marek Behún Date: Fri, 22 Oct 2021 15:47:24 +0200 Subject: env: Always use char for default_environment MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sometimes we use uchar and sometimes char for the default environment array. By always using char, we can get rid of some explicit casts. Signed-off-by: Marek Behún Reviewed-by: Simon Glass --- board/Marvell/mvebu_armada-37xx/board.c | 2 +- env/common.c | 6 +++--- include/env_default.h | 4 ++-- include/env_internal.h | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) (limited to 'include') diff --git a/board/Marvell/mvebu_armada-37xx/board.c b/board/Marvell/mvebu_armada-37xx/board.c index 2de9c2ac173..d7b6ecafbfa 100644 --- a/board/Marvell/mvebu_armada-37xx/board.c +++ b/board/Marvell/mvebu_armada-37xx/board.c @@ -87,7 +87,7 @@ int board_init(void) #ifdef CONFIG_BOARD_LATE_INIT int board_late_init(void) { - char *ptr = (char *)&default_environment[0]; + char *ptr = &default_environment[0]; struct udevice *dev; struct mmc *mmc_dev; bool ddr4, emmc; diff --git a/env/common.c b/env/common.c index db213b77483..664d2e688ed 100644 --- a/env/common.c +++ b/env/common.c @@ -162,7 +162,7 @@ int env_get_f(const char *name, char *buf, unsigned len) name_len = strlen(name); if (gd->env_valid == ENV_INVALID) - env = (const char *)default_environment; + env = default_environment; else env = (const char *)gd->env_addr; @@ -264,7 +264,7 @@ void env_set_default(const char *s, int flags) } flags |= H_DEFAULT; - if (himport_r(&env_htab, (char *)default_environment, + if (himport_r(&env_htab, default_environment, sizeof(default_environment), '\0', flags, 0, 0, NULL) == 0) pr_err("## Error: Environment import failed: errno = %d\n", @@ -283,7 +283,7 @@ int env_set_default_vars(int nvars, char * const vars[], int flags) * (and use \0 as a separator) */ flags |= H_NOCLEAR | H_DEFAULT; - return himport_r(&env_htab, (const char *)default_environment, + return himport_r(&env_htab, default_environment, sizeof(default_environment), '\0', flags, 0, nvars, vars); } diff --git a/include/env_default.h b/include/env_default.h index 66e203eb6e4..a6724719eca 100644 --- a/include/env_default.h +++ b/include/env_default.h @@ -20,9 +20,9 @@ env_t embedded_environment __UBOOT_ENV_SECTION__(environment) = { #elif defined(DEFAULT_ENV_INSTANCE_STATIC) static char default_environment[] = { #elif defined(DEFAULT_ENV_IS_RW) -uchar default_environment[] = { +char default_environment[] = { #else -const uchar default_environment[] = { +const char default_environment[] = { #endif #ifndef CONFIG_USE_DEFAULT_ENV_FILE #ifdef CONFIG_ENV_CALLBACK_LIST_DEFAULT diff --git a/include/env_internal.h b/include/env_internal.h index b7bddcb00d8..f74927cd641 100644 --- a/include/env_internal.h +++ b/include/env_internal.h @@ -112,9 +112,9 @@ extern env_t embedded_environment; #endif /* ENV_IS_EMBEDDED */ #ifdef DEFAULT_ENV_IS_RW -extern unsigned char default_environment[]; +extern char default_environment[]; #else -extern const unsigned char default_environment[]; +extern const char default_environment[]; #endif #ifndef DO_DEPS_ONLY -- cgit v1.3.1 From 37f3758a250d4c590ffac671f100d9b5ec73b417 Mon Sep 17 00:00:00 2001 From: Marek Behún Date: Fri, 22 Oct 2021 15:47:25 +0200 Subject: env: Use static_assert() to check if default_environment is too large MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Check sizeof(default_environment) against ENV_SIZE in a static_assert() instead of runtime. Only check if !USE_HOSTCC (for in fw_env tool ENV_SIZE expands to a variable, and cannot be checked statically) nad !DEFAULT_ENV_INSTANCE_EMBEDDED, for in that case the default_environment variable is not set. Signed-off-by: Marek Behún Reviewed-by: Simon Glass --- env/common.c | 5 ----- include/env_default.h | 6 ++++++ 2 files changed, 6 insertions(+), 5 deletions(-) (limited to 'include') diff --git a/env/common.c b/env/common.c index 664d2e688ed..99729ca002c 100644 --- a/env/common.c +++ b/env/common.c @@ -247,11 +247,6 @@ char *env_get_default(const char *name) void env_set_default(const char *s, int flags) { - if (sizeof(default_environment) > ENV_SIZE) { - puts("*** Error - default environment is too large\n\n"); - return; - } - if (s) { if ((flags & H_INTERACTIVE) == 0) { printf("*** Warning - %s, " diff --git a/include/env_default.h b/include/env_default.h index a6724719eca..23430dc70d7 100644 --- a/include/env_default.h +++ b/include/env_default.h @@ -121,3 +121,9 @@ const char default_environment[] = { } #endif }; + +#if !defined(USE_HOSTCC) && !defined(DEFAULT_ENV_INSTANCE_EMBEDDED) +#include +static_assert(sizeof(default_environment) <= ENV_SIZE, + "Default environment is too large"); +#endif -- cgit v1.3.1 From b55881ddb455af31b64038cf3b67f781909971cc Mon Sep 17 00:00:00 2001 From: Marek Vasut Date: Sat, 23 Oct 2021 03:06:03 +0200 Subject: bootstage: Add SPL support Allow usage of the bootstage facilities in SPL. Signed-off-by: Marek Vasut Cc: Simon Glass Reviewed-by: Simon Glass --- arch/x86/cpu/cpu.c | 2 +- board/siemens/iot2050/board.c | 2 +- common/Kconfig.boot | 9 +++++++++ common/init/board_init.c | 2 +- common/spl/spl.c | 2 +- include/bootstage.h | 2 +- 6 files changed, 14 insertions(+), 5 deletions(-) (limited to 'include') diff --git a/arch/x86/cpu/cpu.c b/arch/x86/cpu/cpu.c index 01dece5769c..86f53e78d24 100644 --- a/arch/x86/cpu/cpu.c +++ b/arch/x86/cpu/cpu.c @@ -178,7 +178,7 @@ int default_print_cpuinfo(void) return 0; } -#if CONFIG_IS_ENABLED(BOOTSTAGE) +#if CONFIG_IS_ENABLED(SHOW_BOOT_PROGRESS) void show_boot_progress(int val) { outb(val, POST_PORT); diff --git a/board/siemens/iot2050/board.c b/board/siemens/iot2050/board.c index b2110978ae0..16ae2ffc174 100644 --- a/board/siemens/iot2050/board.c +++ b/board/siemens/iot2050/board.c @@ -250,7 +250,7 @@ void spl_board_init(void) { } -#if CONFIG_IS_ENABLED(LED) && CONFIG_IS_ENABLED(BOOTSTAGE) +#if CONFIG_IS_ENABLED(LED) && CONFIG_IS_ENABLED(SHOW_BOOT_PROGRESS) /* * Indicate any error or (accidental?) entering of CLI via the red status LED. */ diff --git a/common/Kconfig.boot b/common/Kconfig.boot index c948d58094c..a8d4be23a97 100644 --- a/common/Kconfig.boot +++ b/common/Kconfig.boot @@ -703,6 +703,15 @@ config SHOW_BOOT_PROGRESS -150 common/cmd_nand.c Incorrect FIT image format 151 common/cmd_nand.c FIT image format OK +config SPL_SHOW_BOOT_PROGRESS + bool "Show boot progress in a board-specific manner" + depends on SPL + help + Defining this option allows to add some board-specific code (calling + a user-provided function show_boot_progress(int) that enables you to + show the system's boot progress on some display (for example, some + LEDs) on your board. For details see SHOW_BOOT_PROGRESS. + endmenu menu "Boot media" diff --git a/common/init/board_init.c b/common/init/board_init.c index 0965b96fa3a..eab5ee13953 100644 --- a/common/init/board_init.c +++ b/common/init/board_init.c @@ -166,7 +166,7 @@ void board_init_f_init_reserve(ulong base) board_init_f_init_stack_protection(); } -#if CONFIG_IS_ENABLED(BOOTSTAGE) +#if CONFIG_IS_ENABLED(SHOW_BOOT_PROGRESS) /* * Board-specific Platform code can reimplement show_boot_progress () if needed */ diff --git a/common/spl/spl.c b/common/spl/spl.c index 0c08da06e8f..99cde6609cf 100644 --- a/common/spl/spl.c +++ b/common/spl/spl.c @@ -61,7 +61,7 @@ binman_sym_declare(ulong, spl, size); /* Define board data structure */ static struct bd_info bdata __attribute__ ((section(".data"))); -#if CONFIG_IS_ENABLED(BOOTSTAGE) +#if CONFIG_IS_ENABLED(SHOW_BOOT_PROGRESS) /* * Board-specific Platform code can reimplement show_boot_progress () if needed */ diff --git a/include/bootstage.h b/include/bootstage.h index f837a387c8c..8d1989ac0e5 100644 --- a/include/bootstage.h +++ b/include/bootstage.h @@ -220,7 +220,7 @@ enum bootstage_id { */ ulong timer_get_boot_us(void); -#if defined(USE_HOSTCC) || !CONFIG_IS_ENABLED(BOOTSTAGE) +#if defined(USE_HOSTCC) || !CONFIG_IS_ENABLED(SHOW_BOOT_PROGRESS) #define show_boot_progress(val) do {} while (0) #else /** -- cgit v1.3.1