From e13df08a2685345f12ae1ec1d99ea3f599d58360 Mon Sep 17 00:00:00 2001 From: Rasmus Villemoes Date: Thu, 27 Feb 2020 13:56:10 +0000 Subject: env: remove callback.o for an SPL build env.h says this about about callback declarations (U_BOOT_ENV_CALLBACK): * For SPL these are silently dropped to reduce code size, since environment * callbacks are not supported with SPL. So env_callback_init() does a lot of work to not find anything in the guaranteed empty env_clbk list. Drop callback.o entirely from the link and stub out the only public function defined in callback.o. This cuts about 600 bytes from the SPL on my ppc build. Signed-off-by: Rasmus Villemoes Reviewed-by: Simon Glass --- include/env_callback.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'include') diff --git a/include/env_callback.h b/include/env_callback.h index 74da20eec30..05e9516a0f4 100644 --- a/include/env_callback.h +++ b/include/env_callback.h @@ -72,6 +72,12 @@ "serial#:serialno," \ CONFIG_ENV_CALLBACK_LIST_STATIC +#ifndef CONFIG_SPL_BUILD void env_callback_init(struct env_entry *var_entry); +#else +static inline void env_callback_init(struct env_entry *var_entry) +{ +} +#endif #endif /* __ENV_CALLBACK_H__ */ -- cgit v1.3.1 From 080019b86c997a9b7e13bc7b8f476fbf9a0e5f3c Mon Sep 17 00:00:00 2001 From: Rasmus Villemoes Date: Thu, 27 Feb 2020 13:56:12 +0000 Subject: make env_entry::callback conditional on !CONFIG_SPL_BUILD The callback member of struct env_entry is always NULL for an SPL build. Removing it thus saves a bit of run-time memory in the SPL (when CONFIG_SPL_ENV_SUPPORT=y) since struct env_entry is embedded in struct env_entry_node - i.e. about 2KB for the normal case of 512+change hash table entries. Two small fixups are needed for this, all other references to the callback member are already under !CONFIG_SPL_BUILD: Don't initialize .callback in set_flags() - hsearch_r doesn't use that value anyway. And make env_callback_init() initialize ->callback to NULL for a new entry instead of relying on an unused or deleted entry having NULL in ->callback. Signed-off-by: Rasmus Villemoes Reviewed-by: Simon Glass --- env/callback.c | 2 ++ env/flags.c | 1 - include/search.h | 2 ++ lib/hashtable.c | 1 - 4 files changed, 4 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/env/callback.c b/env/callback.c index f0904cfdc53..4054b9ef58b 100644 --- a/env/callback.c +++ b/env/callback.c @@ -55,6 +55,8 @@ void env_callback_init(struct env_entry *var_entry) first_call = 0; } + var_entry->callback = NULL; + /* look in the ".callbacks" var for a reference to this variable */ if (callback_list != NULL) ret = env_attr_lookup(callback_list, var_name, callback_name); diff --git a/env/flags.c b/env/flags.c index 418d6cc7425..b88fe7ba9c8 100644 --- a/env/flags.c +++ b/env/flags.c @@ -457,7 +457,6 @@ static int set_flags(const char *name, const char *value, void *priv) e.key = name; e.data = NULL; - e.callback = NULL; hsearch_r(e, ENV_FIND, &ep, &env_htab, 0); /* does the env variable actually exist? */ diff --git a/include/search.h b/include/search.h index 0469a852e07..8f87dc72ce7 100644 --- a/include/search.h +++ b/include/search.h @@ -29,8 +29,10 @@ enum env_action { struct env_entry { const char *key; char *data; +#ifndef CONFIG_SPL_BUILD int (*callback)(const char *name, const char *value, enum env_op op, int flags); +#endif int flags; }; diff --git a/lib/hashtable.c b/lib/hashtable.c index c4e1e2bd45f..f82f2463cf2 100644 --- a/lib/hashtable.c +++ b/lib/hashtable.c @@ -450,7 +450,6 @@ static void _hdelete(const char *key, struct hsearch_data *htab, debug("hdelete: DELETING key \"%s\"\n", key); free((void *)ep->key); free(ep->data); - ep->callback = NULL; ep->flags = 0; htab->table[idx].used = USED_DELETED; -- cgit v1.3.1 From 82b2f41357199c9fd06da80f8dd21e0576d08efe Mon Sep 17 00:00:00 2001 From: Rasmus Villemoes Date: Wed, 19 Feb 2020 09:47:40 +0000 Subject: env_internal.h: add alternative ENV_SAVE_PTR macro The current definition of the env_save_ptr does not take SPL_SAVEENV into account. Moreover, the way it is implemented means that drivers need to guard the definitions of their _save methods with ifdefs to avoid "defined but unused" warnings in case CMD_SAVEENV=n. The ifdeffery can be avoided by using a "something ? x : NULL" construction instead and still have the compiler elide the _save method when it is not referenced. Unfortunately we can't just switch the existing env_save_ptr macro, since that would give a lot of build errors unless all the ifdeffery is removed at the same time. Conversely, removing that ifdeffery first would merely lead to the "defined but unused" warnings temporarily, but for some storage drivers it requires a bit more work than just removing their private CMD_SAVEENV logic. So introduce an alternative to env_save_ptr, which for lack of a better name is simply uppercased, allowing one to update storage drivers piecemeal to both reduce their ifdeffery and honour CONFIG_SPL_SAVEENV. Signed-off-by: Rasmus Villemoes --- include/env_internal.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include') diff --git a/include/env_internal.h b/include/env_internal.h index 90a4df8a727..e89fbdb1b75 100644 --- a/include/env_internal.h +++ b/include/env_internal.h @@ -207,6 +207,8 @@ struct env_driver { #define env_save_ptr(x) NULL #endif +#define ENV_SAVE_PTR(x) (CONFIG_IS_ENABLED(SAVEENV) ? (x) : NULL) + extern struct hsearch_data env_htab; #endif /* DO_DEPS_ONLY */ -- cgit v1.3.1 From c738adb8dbbf28a34f8574239a241e85d46f3877 Mon Sep 17 00:00:00 2001 From: Kever Yang Date: Mon, 30 Mar 2020 11:56:17 +0800 Subject: tool: Move ALIGN_MASK to header as common MACRO The ALIGN code is need by many files who need handle structure or image align, so move the macro to imagetool.h file. Signed-off-by: Kever Yang Reviewed-by: Punit Agrawal Reviewed-by: Tom Rini --- include/imx8image.h | 1 - tools/ifwitool.c | 4 +--- tools/imagetool.h | 3 +++ tools/imx8mimage.c | 2 -- tools/mksunxiboot.c | 4 +--- 5 files changed, 5 insertions(+), 9 deletions(-) (limited to 'include') diff --git a/include/imx8image.h b/include/imx8image.h index 68ec9f5fcd2..00c614ab6cc 100644 --- a/include/imx8image.h +++ b/include/imx8image.h @@ -11,7 +11,6 @@ #include #include #include "imagetool.h" -#include "linux/kernel.h" #define __packed __attribute__((packed)) diff --git a/tools/ifwitool.c b/tools/ifwitool.c index 543e9d4e702..b2b06cc9219 100644 --- a/tools/ifwitool.c +++ b/tools/ifwitool.c @@ -8,15 +8,13 @@ #include #include #include +#include "imagetool.h" #include "os_support.h" #ifndef __packed #define __packed __attribute__((packed)) #endif #define KiB 1024 -#define ALIGN(x, a) __ALIGN_MASK((x), (typeof(x))(a) - 1) -#define __ALIGN_MASK(x, mask) (((x) + (mask)) & ~(mask)) -#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) /* * min()/max()/clamp() macros that also do diff --git a/tools/imagetool.h b/tools/imagetool.h index e1c778b0dff..81e5cd0c5cc 100644 --- a/tools/imagetool.h +++ b/tools/imagetool.h @@ -25,6 +25,9 @@ #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) +#define __ALIGN_MASK(x, mask) (((x) + (mask)) & ~(mask)) +#define ALIGN(x, a) __ALIGN_MASK((x), (typeof(x))(a) - 1) + #define IH_ARCH_DEFAULT IH_ARCH_INVALID /* Information about a file that needs to be placed into the FIT */ diff --git a/tools/imx8mimage.c b/tools/imx8mimage.c index 2b0d946a7d7..7defb13962f 100644 --- a/tools/imx8mimage.c +++ b/tools/imx8mimage.c @@ -32,8 +32,6 @@ static uint32_t rom_version = ROM_V1; #define HDMI_FW_SIZE 0x17000 /* Use Last 0x1000 for IVT and CSF */ #define ALIGN_SIZE 0x1000 -#define ALIGN(x,a) __ALIGN_MASK((x), (__typeof__(x))(a) - 1, a) -#define __ALIGN_MASK(x,mask,mask2) (((x) + (mask)) / (mask2) * (mask2)) static uint32_t get_cfg_value(char *token, char *name, int linenr) { diff --git a/tools/mksunxiboot.c b/tools/mksunxiboot.c index 1c8701e75ed..a18c9d98bc7 100644 --- a/tools/mksunxiboot.c +++ b/tools/mksunxiboot.c @@ -14,6 +14,7 @@ #include #include #include +#include "imagetool.h" #include "../arch/arm/include/asm/arch-sunxi/spl.h" #define STAMP_VALUE 0x5F0A6C39 @@ -44,9 +45,6 @@ int gen_check_sum(struct boot_file_head *head_p) return 0; } -#define ALIGN(x, a) __ALIGN_MASK((x), (typeof(x))(a)-1) -#define __ALIGN_MASK(x, mask) (((x)+(mask))&~(mask)) - #define SUNXI_SRAM_SIZE 0x8000 /* SoC with smaller size are limited before */ #define SRAM_LOAD_MAX_SIZE (SUNXI_SRAM_SIZE - sizeof(struct boot_file_head)) -- cgit v1.3.1 From 10d887ddfa4f94aa94cf7a6d3dd4f28a339a2f13 Mon Sep 17 00:00:00 2001 From: Kever Yang Date: Mon, 30 Mar 2020 11:56:23 +0800 Subject: libfdt: Make fdtdec_get_child_count() available for HOST The tool need to use fdtdec_get_child_count(), make it available for HOST_CC. Signed-off-by: Kever Yang Reviewed-by: Punit Agrawal Reviewed-by: Simon Glass --- include/fdt_support.h | 9 +++++++++ lib/fdtdec.c | 11 ----------- lib/fdtdec_common.c | 11 +++++++++++ 3 files changed, 20 insertions(+), 11 deletions(-) (limited to 'include') diff --git a/include/fdt_support.h b/include/fdt_support.h index ba14acd7f62..2eff311fa4f 100644 --- a/include/fdt_support.h +++ b/include/fdt_support.h @@ -343,6 +343,15 @@ int fdt_get_cells_len(const void *blob, char *nr_cells_name); #ifdef USE_HOSTCC int fdtdec_get_int(const void *blob, int node, const char *prop_name, int default_val); + +/* + * Count child nodes of one parent node. + * + * @param blob FDT blob + * @param node parent node + * @return number of child node; 0 if there is not child node + */ +int fdtdec_get_child_count(const void *blob, int node); #endif #ifdef CONFIG_FMAN_ENET int fdt_update_ethernet_dt(void *blob); diff --git a/lib/fdtdec.c b/lib/fdtdec.c index 460f0d250b4..0a3b8607822 100644 --- a/lib/fdtdec.c +++ b/lib/fdtdec.c @@ -810,17 +810,6 @@ int fdtdec_parse_phandle_with_args(const void *blob, int src_node, return rc; } -int fdtdec_get_child_count(const void *blob, int node) -{ - int subnode; - int num = 0; - - fdt_for_each_subnode(subnode, blob, node) - num++; - - return num; -} - int fdtdec_get_byte_array(const void *blob, int node, const char *prop_name, u8 *array, int count) { diff --git a/lib/fdtdec_common.c b/lib/fdtdec_common.c index 088e9e9063a..5775992ef33 100644 --- a/lib/fdtdec_common.c +++ b/lib/fdtdec_common.c @@ -53,3 +53,14 @@ unsigned int fdtdec_get_uint(const void *blob, int node, const char *prop_name, debug("(not found)\n"); return default_val; } + +int fdtdec_get_child_count(const void *blob, int node) +{ + int subnode; + int num = 0; + + fdt_for_each_subnode(subnode, blob, node) + num++; + + return num; +} -- cgit v1.3.1 From ec8eef5e71e4d876324aa81b3c394822d8ef1eb6 Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Fri, 3 Apr 2020 19:58:24 -0700 Subject: fvp: Add support for loading Android boot images via semihosting FVP now loads an Android boot image named boot.img if available, otherwise it falls back to the existing code path. Signed-off-by: Peter Collingbourne Reviewed-by: Ryan Harkin Reviewed-by: Linus Walleij --- configs/vexpress_aemv8a_semi_defconfig | 2 ++ include/configs/vexpress_aemv8a.h | 30 ++++++++++++++++++++---------- 2 files changed, 22 insertions(+), 10 deletions(-) (limited to 'include') diff --git a/configs/vexpress_aemv8a_semi_defconfig b/configs/vexpress_aemv8a_semi_defconfig index f31baab197f..b52c761dee1 100644 --- a/configs/vexpress_aemv8a_semi_defconfig +++ b/configs/vexpress_aemv8a_semi_defconfig @@ -14,6 +14,8 @@ CONFIG_BOOTARGS="console=ttyAMA0 earlycon=pl011,0x1c090000 debug user_debug=31 l # CONFIG_DISPLAY_CPUINFO is not set # CONFIG_DISPLAY_BOARDINFO is not set CONFIG_SYS_PROMPT="VExpress64# " +CONFIG_ANDROID_BOOT_IMAGE=y +CONFIG_CMD_ABOOTIMG=y # CONFIG_CMD_CONSOLE is not set # CONFIG_CMD_XIMG is not set # CONFIG_CMD_EDITENV is not set diff --git a/include/configs/vexpress_aemv8a.h b/include/configs/vexpress_aemv8a.h index 9a9cec414c8..4f3a792f496 100644 --- a/include/configs/vexpress_aemv8a.h +++ b/include/configs/vexpress_aemv8a.h @@ -177,16 +177,26 @@ "initrd_addr=0x88000000\0" \ "fdtfile=devtree.dtb\0" \ "fdt_addr=0x83000000\0" \ - "fdt_high=0xffffffffffffffff\0" \ - "initrd_high=0xffffffffffffffff\0" - -#define CONFIG_BOOTCOMMAND "smhload ${kernel_name} ${kernel_addr}; " \ - "smhload ${fdtfile} ${fdt_addr}; " \ - "smhload ${initrd_name} ${initrd_addr} "\ - "initrd_end; " \ - "fdt addr ${fdt_addr}; fdt resize; " \ - "fdt chosen ${initrd_addr} ${initrd_end}; " \ - "booti $kernel_addr - $fdt_addr" + "boot_name=boot.img\0" \ + "boot_addr=0x8007f800\0" + +#define CONFIG_BOOTCOMMAND "if smhload ${boot_name} ${boot_addr}; then " \ + " set bootargs; " \ + " abootimg addr ${boot_addr}; " \ + " abootimg get dtb --index=0 fdt_addr; " \ + " bootm ${boot_addr} ${boot_addr} " \ + " ${fdt_addr}; " \ + "else; " \ + " set fdt_high 0xffffffffffffffff; " \ + " set initrd_high 0xffffffffffffffff; " \ + " smhload ${kernel_name} ${kernel_addr}; " \ + " smhload ${fdtfile} ${fdt_addr}; " \ + " smhload ${initrd_name} ${initrd_addr} "\ + " initrd_end; " \ + " fdt addr ${fdt_addr}; fdt resize; " \ + " fdt chosen ${initrd_addr} ${initrd_end}; " \ + " booti $kernel_addr - $fdt_addr; " \ + "fi" #endif -- cgit v1.3.1