dm: core: Support multiple device trees in ofnode
Subsystems (23)
cover dm: core: Support multiple device trees in ofnode
At present the ofnode interface is somewhat limited, in that it cannot access the device tree provided by the OS, only the one used by U-Boot itself (assuming these are separate). This prevents using ofnode functions to handle device tree fixups, i.e. ft_board_setup() and the like.
The ofnode interface was introduced to allow a consistent API to access the device tree, whether a flat tree or a live tree (OF_LIVE) is in use.
With the flat tree, adding nodes and properties at the start of the tree (as often happens when writing to the /chosen node) requires copying a lot of data for each operation. With live tree, such operations are quite a bit faster, since there is no memory copying required. This has to be weighed against the required memory allocation with OF_LIVE, as well as the cost of unflattening and flattening the device tree which U-Boot is running.
This series enables support for access to multiple device trees with the ofnode interface. This is already available to some extent with OF_LIVE, but some of the ofnode functions need changes to allow the tree to be specified.
The mechanism works by using the top 1-4 bits of the device tree offset. The sign bit is not affected, since negative values must be supported.
With this implemented, it becomes possible to use the ofnode interface to do device tree fixups. The only current user is the EVT_FT_FIXUP event.
This has two main benefits:
- ofnode can now be used everywhere, in preference to the libfdt calls
- live tree can eventually be used everywhere, with potential speed improvements when larger number of fixups are used
This series is only a step along the way. Firstly, while it is possible to access the 'fix-up' tree using OF_LIVE, most of the fixup functions use flat tree directly, rather than the ofnode interface. These need to be updated. Also the tree must be flattened again before it is passed to the OS. This is not currently implemented.
With OFNODE_MULTI_TREE disabled this has almost no effect on code size:
around 4 bytes if EVENT is enabled, 0 if not. With the feature enabled, the increase is around 500 bytes, e.g. on venice2:
buildman -b ofn venice2 -sS --step 0
Summary of 2 commits for 1 boards (1 thread, 64 jobs per thread) 01: image: Drop some other #ifdefs in image-board.c
arm: w+ venice2
23: dm: core: Add the ofnode multi-tree implementation 24: wip
arm: (for 1/1 boards) all +580.0 text +580.0
This size increase is not too bad, considering the extra functionality, but is too large to enable everywhere. So for now this features needs to be opt-in only, based on EVENT.
Simon Glass (21):
image: Fix BOOTM_STATE values
treewide: Drop bootm_headers_t typedef
treewide: Drop image_info_t typedef
treewide: Drop image_header_t typedef
event: Fix a typo in the EVENT help
dm: core: Pass a root node to of_find_node_by_phandle()
event: Pass the images to EVT_FT_FIXUP
dm: core: Allow adding ofnode subnodes
dm: core: Support writing a property to an empty node
dm: core: Drop the const from ofnode
test: Make a copy of the device tree before running a test
test: Detect a change in the device tree
test: Drop the UT_TESTF_LIVE_OR_FLAT flag
dm: core: Provide a way to reset the device tree
dm: core: Add an ofnode function to obtain the flat tree
dm: core: Add ofnode functions to obtain an oftree
dm: core: Add a way to look up a phandle in an oftree
dm: core: Allow obtaining a node offset in the same tree
dm: core: Add definitions for multiple ofnode trees
dm: core: Reduce code size with dev_of_offset()
dm: core: Add the ofnode multi-tree implementation
arch/arc/lib/bootm.c | 8 +- arch/arm/lib/bootm.c | 13 +- arch/arm/mach-aspeed/ast2600/spl.c | 4 +- arch/arm/mach-imx/hab.c | 2 +- arch/arm/mach-imx/spl_imx_romapi.c | 6 +- arch/arm/mach-k3/common.c | 2 +- arch/arm/mach-k3/sysfw-loader.c | 6 +- arch/arm/mach-keystone/cmd_mon.c | 6 +- arch/arm/mach-socfpga/board.c | 2 +- arch/arm/mach-sunxi/spl_spi_sunxi.c | 4 +- arch/m68k/lib/bootm.c | 2 +- arch/microblaze/lib/bootm.c | 6 +- arch/mips/lib/bootm.c | 16 +- arch/mips/mach-jz47xx/jz4780/jz4780.c | 6 +- arch/mips/mach-mtmips/mt7621/spl/spl.c | 4 +- arch/mips/mach-mtmips/mt7621/tpl/tpl.c | 4 +- arch/nios2/lib/bootm.c | 2 +- arch/powerpc/lib/bootm.c | 16 +- arch/riscv/lib/bootm.c | 8 +- arch/sandbox/lib/bootm.c | 2 +- arch/sh/lib/bootm.c | 2 +- arch/x86/lib/bootm.c | 8 +- arch/xtensa/lib/bootm.c | 2 +- board/synopsys/hsdk/hsdk.c | 2 +- board/ti/ks2_evm/board.c | 4 +- boot/boot_fit.c | 4 +- boot/bootm.c | 26 +-- boot/bootm_os.c | 35 ++-- boot/image-android.c | 6 +- boot/image-board.c | 26 +-- boot/image-fdt.c | 13 +- boot/image-fit.c | 16 +- boot/image.c | 14 +- cmd/bootefi.c | 2 +- cmd/booti.c | 2 +- cmd/bootm.c | 4 +- cmd/bootz.c | 2 +- cmd/disk.c | 4 +- cmd/fpga.c | 2 +- cmd/nand.c | 4 +- cmd/source.c | 2 +- cmd/ximg.c | 4 +- common/Kconfig | 2 +- common/board_r.c | 2 + common/spl/spl.c | 10 +- common/spl/spl_ext.c | 4 +- common/spl/spl_fat.c | 6 +- common/spl/spl_legacy.c | 8 +- common/spl/spl_mmc.c | 4 +- common/spl/spl_nand.c | 4 +- common/spl/spl_net.c | 2 +- common/spl/spl_nor.c | 8 +- common/spl/spl_onenand.c | 2 +- common/spl/spl_ram.c | 8 +- common/spl/spl_sata.c | 2 +- common/spl/spl_semihosting.c | 4 +- common/spl/spl_spi.c | 6 +- common/spl/spl_ubi.c | 4 +- common/spl/spl_xip.c | 2 +- common/spl/spl_ymodem.c | 14 +- common/splash_source.c | 6 +- doc/develop/driver-model/livetree.rst | 30 ++- doc/uImage.FIT/source_file_format.txt | 2 +- drivers/core/Kconfig | 24 +++ drivers/core/fdtaddr.c | 18 +- drivers/core/of_access.c | 65 +++++- drivers/core/ofnode.c | 263 ++++++++++++++++++++----- drivers/fpga/socfpga_arria10.c | 4 +- drivers/usb/gadget/f_sdp.c | 2 +- include/asm-generic/global_data.h | 4 + include/bootm.h | 6 +- include/configs/uniphier.h | 2 +- include/dm/device.h | 6 +- include/dm/of_access.h | 16 +- include/dm/ofnode.h | 159 +++++++++++++-- include/dm/ofnode_decl.h | 31 ++- include/event.h | 2 + include/image.h | 118 +++++------ include/spl.h | 8 +- include/tee/optee.h | 4 +- include/test/test.h | 8 +- lib/efi_loader/efi_dt_fixup.c | 2 +- lib/fdtdec.c | 5 +- test/dm/ofnode.c | 30 ++- test/image/spl_load.c | 4 +- test/test-main.c | 89 ++++++++- tools/binman/ftest.py | 4 +- tools/default_image.c | 31 ++- tools/fit_image.c | 4 +- tools/imx8mimage.c | 8 +- tools/mkimage.c | 2 +- tools/mtk_image.c | 10 +- 92 files changed, 951 insertions(+), 411 deletions(-)
Signature · 1 line
2.37.2.672.g94769d06f0-goog
PATCH 1/21 image: Fix BOOTM_STATE values
Tidy up the code style for these.
---
include/image.h | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-)
include/image.h +12 -12
@@ -341,18 +341,18 @@ typedef struct bootm_headers {int verify;/* env_get("verify")[0] != 'n' */ -#define BOOTM_STATE_START (0x00000001) -#define BOOTM_STATE_FINDOS (0x00000002) -#define BOOTM_STATE_FINDOTHER (0x00000004) -#define BOOTM_STATE_LOADOS (0x00000008) -#define BOOTM_STATE_RAMDISK (0x00000010) -#define BOOTM_STATE_FDT (0x00000020) -#define BOOTM_STATE_OS_CMDLINE (0x00000040) -#define BOOTM_STATE_OS_BD_T (0x00000080) -#define BOOTM_STATE_OS_PREP (0x00000100) -#define BOOTM_STATE_OS_FAKE_GO (0x00000200)/* 'Almost' run the OS */ -#define BOOTM_STATE_OS_GO (0x00000400) -#define BOOTM_STATE_PRE_LOAD 0x00000800 +#define BOOTM_STATE_START 0x00000001 +#define BOOTM_STATE_FINDOS 0x00000002 +#define BOOTM_STATE_FINDOTHER 0x00000004 +#define BOOTM_STATE_LOADOS 0x00000008 +#define BOOTM_STATE_RAMDISK 0x00000010 +#define BOOTM_STATE_FDT 0x00000020 +#define BOOTM_STATE_OS_CMDLINE 0x00000040 +#define BOOTM_STATE_OS_BD_T 0x00000080 +#define BOOTM_STATE_OS_PREP 0x00000100 +#define BOOTM_STATE_OS_FAKE_GO 0x00000200/* 'Almost' run the OS */ +#define BOOTM_STATE_OS_GO 0x00000400 +#define BOOTM_STATE_PRE_LOAD 0x00000800int state;#if defined(CONFIG_LMB ) && !defined(USE_HOSTCC )
Signature · 1 line
2.37.2.672.g94769d06f0-goog
PATCH 2/21 treewide: Drop bootm_headers_t typedef
In reply to Simon GlassThis is not needed and we should avoid typedefs. Use the struct instead.
---
arch/arc/lib/bootm.c | 8 ++++---- arch/arm/lib/bootm.c | 13 +++++++------ arch/arm/mach-k3/common.c | 2 +- arch/arm/mach-socfpga/board.c | 2 +- arch/m68k/lib/bootm.c | 2 +- arch/microblaze/lib/bootm.c | 6 +++--- arch/mips/lib/bootm.c | 16 ++++++++-------- arch/nios2/lib/bootm.c | 2 +- arch/powerpc/lib/bootm.c | 16 ++++++++-------- arch/riscv/lib/bootm.c | 8 ++++---- arch/sandbox/lib/bootm.c | 2 +- arch/sh/lib/bootm.c | 2 +- arch/x86/lib/bootm.c | 6 +++--- arch/xtensa/lib/bootm.c | 2 +- board/synopsys/hsdk/hsdk.c | 2 +- boot/bootm.c | 16 ++++++++-------- boot/bootm_os.c | 28 +++++++++++++-------------- boot/image-board.c | 14 +++++++------- boot/image-fdt.c | 6 +++--- boot/image-fit.c | 16 ++++++++-------- cmd/bootefi.c | 2 +- cmd/booti.c | 2 +- cmd/bootz.c | 2 +- common/spl/spl.c | 2 +- include/bootm.h | 6 +++--- include/image.h | 36 +++++++++++++++++------------------ lib/efi_loader/efi_dt_fixup.c | 2 +- 27 files changed, 111 insertions(+), 110 deletions(-)
arch/arc/lib/bootm.c +4 -4
@@ -22,10 +22,10 @@ static int cleanup_before_linux(void)return 0 ; } -__weak int board_prep_linux (bootm_headers_t *images) {return 0 ; } +__weak int board_prep_linux (struct bootm_headers *images) {return 0 ; }/* Subcommand: PREP */ -static int boot_prep_linux (bootm_headers_t *images) +static int boot_prep_linux (struct bootm_headers *images) {int ret;
@@ -49,7 +49,7 @@ __weak void board_jump_and_run(ulong entry, int zero, int arch, uint params) }/* Subcommand: GO */ -static void boot_jump_linux (bootm_headers_t *images,int flag) +static void boot_jump_linux (struct bootm_headers *images,int flag) {ulong kernel_entry;unsigned int r0, r2;
@@ -79,7 +79,7 @@ static void boot_jump_linux(bootm_headers_t *images, int flag)board_jump_and_run (kernel_entry, r0,0 , r2); } -int do_bootm_linux (int flag,int argc,char *argv[],bootm_headers_t *images) +int do_bootm_linux (int flag,int argc,char *argv[],struct bootm_headers *images) {/* No need for those on ARC */ if ((flag &BOOTM_STATE_OS_BD_T ) || (flag &BOOTM_STATE_OS_CMDLINE ))
arch/arm/lib/bootm.c +7 -6
@@ -192,10 +192,10 @@ static void do_nonsec_virt_switch(void) }#endif -__weak void board_prep_linux (bootm_headers_t *images) { } +__weak void board_prep_linux (struct bootm_headers *images) { }/* Subcommand: PREP */ -static void boot_prep_linux (bootm_headers_t *images) +static void boot_prep_linux (struct bootm_headers *images) {char *commandline =env_get ("bootargs" );
@@ -288,7 +288,7 @@ static void switch_to_el1(void)#endif /* Subcommand: GO */ -static void boot_jump_linux (bootm_headers_t *images,int flag) +static void boot_jump_linux (struct bootm_headers *images,int flag) {#ifdef CONFIG_ARM64 void (*kernel_entry)(void *fdt_addr, void *res0, void *res1,
@@ -379,7 +379,7 @@ static void boot_jump_linux(bootm_headers_t *images, int flag)* they are called if subcommand is equal 0. */ int do_bootm_linux (int flag,int argc,char *const argv[], -bootm_headers_t *images) +struct bootm_headers *images) {/* No need for those on ARM */ if (flag &BOOTM_STATE_OS_BD_T || flag &BOOTM_STATE_OS_CMDLINE )
@@ -401,7 +401,7 @@ int do_bootm_linux(int flag, int argc, char *const argv[], }#if defined(CONFIG_BOOTM_VXWORKS ) -void boot_prep_vxworks (bootm_headers_t *images) +void boot_prep_vxworks (struct bootm_headers *images) {#if defined(CONFIG_OF_LIBFDT )int off;
@@ -416,7 +416,8 @@ void boot_prep_vxworks(bootm_headers_t *images)#endif cleanup_before_linux (); } -void boot_jump_vxworks (bootm_headers_t *images) + +void boot_jump_vxworks (struct bootm_headers *images) {#if defined(CONFIG_ARM64 ) && defined(CONFIG_ARMV8_PSCI )armv8_setup_psci ();
arch/arm/mach-k3/common.c +1 -1
@@ -493,7 +493,7 @@ bool soc_is_j7200(void) }#ifdef CONFIG_ARM64 -void board_prep_linux (bootm_headers_t *images) +void board_prep_linux (struct bootm_headers *images) {debug ("Linux kernel Image start = 0x%lx end = 0x%lx\n" , images->os.start, images->os.end);
arch/arm/mach-socfpga/board.c +1 -1
@@ -114,7 +114,7 @@ void board_fit_image_post_process(const void *fit, int node, void **p_image,#endif #if !IS_ENABLED (CONFIG_SPL_BUILD ) &&IS_ENABLED (CONFIG_FIT ) -void board_prep_linux (bootm_headers_t *images) +void board_prep_linux (struct bootm_headers *images) {if (!images->fit_uname_cfg) { if (IS_ENABLED(CONFIG_SOCFPGA_SECURE_VAB_AUTH) &&
arch/m68k/lib/bootm.c +1 -1
@@ -36,7 +36,7 @@ void arch_lmb_reserve(struct lmb *lmb) }int do_bootm_linux (int flag,int argc,char *const argv[], -bootm_headers_t *images) +struct bootm_headers *images) {int ret;struct bd_info *kbd;
arch/microblaze/lib/bootm.c +3 -3
@@ -37,7 +37,7 @@ void arch_lmb_reserve(struct lmb *lmb)arch_lmb_reserve_generic (lmb,get_sp (), gd->ram_top,4096 ); } -static void boot_jump_linux (bootm_headers_t *images,int flag) +static void boot_jump_linux (struct bootm_headers *images,int flag) {void (*thekernel)(char *cmdline,ulong rd,ulong dt);ulong dt = (ulong )images->ft_addr;
@@ -71,7 +71,7 @@ static void boot_jump_linux(bootm_headers_t *images, int flag) } } -static void boot_prep_linux (bootm_headers_t *images) +static void boot_prep_linux (struct bootm_headers *images) {if (CONFIG_IS_ENABLED (OF_LIBFDT ) &&CONFIG_IS_ENABLED (LMB ) && images->ft_len) {debug ("using: FDT\n" );
@@ -83,7 +83,7 @@ static void boot_prep_linux(bootm_headers_t *images) }int do_bootm_linux (int flag,int argc,char *const argv[], -bootm_headers_t *images) +struct bootm_headers *images) { images->cmdline_start = (ulong )env_get ("bootargs" );
arch/mips/lib/bootm.c +8 -8
@@ -71,7 +71,7 @@ static void linux_cmdline_dump(void)debug (" arg %03d: %s\n" , i, linux_argv[i]); } -static void linux_cmdline_legacy (bootm_headers_t *images) +static void linux_cmdline_legacy (struct bootm_headers *images) {const char *bootargs, *next, *quote;
@@ -111,7 +111,7 @@ static void linux_cmdline_legacy(bootm_headers_t *images) } } -static void linux_cmdline_append (bootm_headers_t *images) +static void linux_cmdline_append (struct bootm_headers *images) {char buf[24 ];ulong mem, rd_start, rd_size;
@@ -164,7 +164,7 @@ static void linux_env_set(const char *env_name, const char *env_val) } } -static void linux_env_legacy (bootm_headers_t *images) +static void linux_env_legacy (struct bootm_headers *images) {char env_buf[12 ];const char *cp;
@@ -213,7 +213,7 @@ static void linux_env_legacy(bootm_headers_t *images) } } -static int boot_reloc_fdt (bootm_headers_t *images) +static int boot_reloc_fdt (struct bootm_headers *images) {/* * In case of legacy uImage's, relocation of FDT is already done
@@ -243,7 +243,7 @@ int arch_fixup_fdt(void *blob) }#endif -static int boot_setup_fdt (bootm_headers_t *images) +static int boot_setup_fdt (struct bootm_headers *images) { images->initrd_start =virt_to_phys ((void *)images->initrd_start); images->initrd_end =virt_to_phys ((void *)images->initrd_end);
@@ -251,7 +251,7 @@ static int boot_setup_fdt(bootm_headers_t *images) &images->lmb); } -static void boot_prep_linux (bootm_headers_t *images) +static void boot_prep_linux (struct bootm_headers *images) {if (CONFIG_IS_ENABLED (MIPS_BOOT_FDT ) && images->ft_len) {boot_reloc_fdt (images);
@@ -271,7 +271,7 @@ static void boot_prep_linux(bootm_headers_t *images) } } -static void boot_jump_linux (bootm_headers_t *images) +static void boot_jump_linux (struct bootm_headers *images) {typedef void __noreturn (*kernel_entry_t )(int ,ulong ,ulong ,ulong );kernel_entry_t kernel = (kernel_entry_t ) images->ep;
@@ -302,7 +302,7 @@ static void boot_jump_linux(bootm_headers_t *images) }int do_bootm_linux (int flag,int argc,char *const argv[], -bootm_headers_t *images) +struct bootm_headers *images) {/* No need for those on MIPS */ if (flag &BOOTM_STATE_OS_BD_T )
arch/nios2/lib/bootm.c +1 -1
@@ -17,7 +17,7 @@ DECLARE_GLOBAL_DATA_PTR;#define NIOS_MAGIC 0x534f494e/* enable command line and initrd passing */ int do_bootm_linux (int flag,int argc,char *const argv[], -bootm_headers_t *images) +struct bootm_headers *images) {void (*kernel)(int ,int ,int ,char *) = (void *)images->ep;char *commandline =env_get ("bootargs" );
arch/powerpc/lib/bootm.c +8 -8
@@ -45,7 +45,7 @@ static void set_clocks_in_mhz (struct bd_info *kbd);#define CONFIG_SYS_LINUX_LOWMEM_MAX_SIZE (768*1024*1024)#endif -static void boot_jump_linux (bootm_headers_t *images) +static void boot_jump_linux (struct bootm_headers *images) {void (*kernel)(struct bd_info *,ulong r4,ulong r5,ulong r6,ulong r7,ulong r8,ulong r9);
@@ -151,7 +151,7 @@ void arch_lmb_reserve(struct lmb *lmb)return ; } -static void boot_prep_linux (bootm_headers_t *images) +static void boot_prep_linux (struct bootm_headers *images) {#ifdef CONFIG_MP /*
@@ -163,7 +163,7 @@ static void boot_prep_linux(bootm_headers_t *images)#endif } -static int boot_cmdline_linux (bootm_headers_t *images) +static int boot_cmdline_linux (struct bootm_headers *images) {ulong of_size = images->ft_len;struct lmb *lmb = &images->lmb;
@@ -184,7 +184,7 @@ static int boot_cmdline_linux(bootm_headers_t *images)return ret; } -static int boot_bd_t_linux (bootm_headers_t *images) +static int boot_bd_t_linux (struct bootm_headers *images) {ulong of_size = images->ft_len;struct lmb *lmb = &images->lmb;
@@ -205,7 +205,7 @@ static int boot_bd_t_linux(bootm_headers_t *images)return ret; } -static int boot_body_linux (bootm_headers_t *images) +static int boot_body_linux (struct bootm_headers *images) {int ret;
@@ -224,7 +224,7 @@ static int boot_body_linux(bootm_headers_t *images) } noinline int do_bootm_linux(int flag, int argc, char *const argv[], -bootm_headers_t *images) +struct bootm_headers *images) {int ret;
@@ -273,7 +273,7 @@ static void set_clocks_in_mhz (struct bd_info *kbd) }#if defined(CONFIG_BOOTM_VXWORKS ) -void boot_prep_vxworks (bootm_headers_t *images) +void boot_prep_vxworks (struct bootm_headers *images) {#if defined(CONFIG_OF_LIBFDT )int off;
@@ -305,7 +305,7 @@ void boot_prep_vxworks(bootm_headers_t *images)#endif } -void boot_jump_vxworks (bootm_headers_t *images) +void boot_jump_vxworks (struct bootm_headers *images) {/* PowerPC VxWorks boot interface conforms to the ePAPR standard * general purpuse registers:
arch/riscv/lib/bootm.c +4 -4
@@ -62,7 +62,7 @@ static void announce_and_cleanup(int fake)cleanup_before_linux (); } -static void boot_prep_linux (bootm_headers_t *images) +static void boot_prep_linux (struct bootm_headers *images) {if (CONFIG_IS_ENABLED (OF_LIBFDT ) &&CONFIG_IS_ENABLED (LMB ) && images->ft_len) {debug ("using: FDT\n" );
@@ -76,7 +76,7 @@ static void boot_prep_linux(bootm_headers_t *images) } } -static void boot_jump_linux (bootm_headers_t *images,int flag) +static void boot_jump_linux (struct bootm_headers *images,int flag) {void (*kernel)(ulong hart,void *dtb);int fake = (flag &BOOTM_STATE_OS_FAKE_GO );
@@ -107,7 +107,7 @@ static void boot_jump_linux(bootm_headers_t *images, int flag) }int do_bootm_linux (int flag,int argc,char *const argv[], -bootm_headers_t *images) +struct bootm_headers *images) {/* No need for those on RISC-V */ if (flag &BOOTM_STATE_OS_BD_T || flag &BOOTM_STATE_OS_CMDLINE )
@@ -129,7 +129,7 @@ int do_bootm_linux(int flag, int argc, char *const argv[], }int do_bootm_vxworks (int flag,int argc,char *const argv[], -bootm_headers_t *images) +struct bootm_headers *images) {return do_bootm_linux (flag, argc, argv, images); }
arch/sandbox/lib/bootm.c +1 -1
@@ -50,7 +50,7 @@ int bootz_setup(ulong image, ulong *start, ulong *end)return ret; } -int do_bootm_linux (int flag,int argc,char *argv[],bootm_headers_t *images) +int do_bootm_linux (int flag,int argc,char *argv[],struct bootm_headers *images) {if (flag & (BOOTM_STATE_OS_GO |BOOTM_STATE_OS_FAKE_GO )) {bootstage_mark (BOOTSTAGE_ID_RUN_OS );
arch/sh/lib/bootm.c +1 -1
@@ -40,7 +40,7 @@ static unsigned long sh_check_cmd_arg(char *cmdline, char *key, int base) }int do_bootm_linux (int flag,int argc,char *const argv[], -bootm_headers_t *images) +struct bootm_headers *images) {/* Linux kernel load address */ void (*kernel) (void ) = (void (*)(void ))images->ep;
arch/x86/lib/bootm.c +3 -3
@@ -69,7 +69,7 @@ int arch_fixup_memory_node(void *blob)#endif /* Subcommand: PREP */ -static int boot_prep_linux (bootm_headers_t *images) +static int boot_prep_linux (struct bootm_headers *images) {char *cmd_line_dest =NULL ;image_header_t *hdr;
@@ -201,7 +201,7 @@ int boot_linux_kernel(ulong setup_base, ulong load_address, bool image_64bit) }/* Subcommand: GO */ -static int boot_jump_linux (bootm_headers_t *images) +static int boot_jump_linux (struct bootm_headers *images) {debug ("## Transferring control to Linux (at address %08lx, kernel %08lx) ...\n" , images->ep, images->os.load);
@@ -211,7 +211,7 @@ static int boot_jump_linux(bootm_headers_t *images) }int do_bootm_linux (int flag,int argc,char *const argv[], -bootm_headers_t *images) +struct bootm_headers *images) {/* No need for those on x86 */ if (flag &BOOTM_STATE_OS_BD_T || flag &BOOTM_STATE_OS_CMDLINE )
arch/xtensa/lib/bootm.c +1 -1
@@ -134,7 +134,7 @@ static struct bp_tag *setup_fdt_tag(struct bp_tag *params, void *fdt_start)* Boot Linux. */ -int do_bootm_linux (int flag,int argc,char *argv[],bootm_headers_t *images) +int do_bootm_linux (int flag,int argc,char *argv[],struct bootm_headers *images) {struct bp_tag *params, *params_start;ulong initrd_start, initrd_end;
board/synopsys/hsdk/hsdk.c +1 -1
@@ -844,7 +844,7 @@ static int hsdk_go_run(u32 cpu_start_reg)return 0 ; } -int board_prep_linux (bootm_headers_t *images) +int board_prep_linux (struct bootm_headers *images) {int ret, ofst;char mask[15 ];
boot/bootm.c +8 -8
@@ -41,10 +41,10 @@DECLARE_GLOBAL_DATA_PTR ; -bootm_headers_t images;/* pointers to os/initrd/fdt images */ +struct bootm_headers images;/* pointers to os/initrd/fdt images */ static const void *boot_get_kernel (struct cmd_tbl *cmdtp,int flag,int argc, -char *const argv[],bootm_headers_t *images, +char *const argv[],struct bootm_headers *images,ulong *os_data,ulong *os_len);__weak void board_quiesce_devices (void )
@@ -52,7 +52,7 @@ __weak void board_quiesce_devices(void) }#ifdef CONFIG_LMB -static void boot_start_lmb (bootm_headers_t *images) +static void boot_start_lmb (struct bootm_headers *images) {ulong mem_start;phys_size_t mem_size;
@@ -65,7 +65,7 @@ static void boot_start_lmb(bootm_headers_t *images) }#else #define lmb_reserve (lmb, base, size) -static inline void boot_start_lmb (bootm_headers_t *images) { } +static inline void boot_start_lmb (struct bootm_headers *images) { }#endif static int bootm_start(struct cmd_tbl *cmdtp, int flag, int argc,
@@ -397,7 +397,7 @@ static int handle_decomp_error(int comp_type, size_t uncomp_size,#endif #ifndef USE_HOSTCC -static int bootm_load_os (bootm_headers_t *images,int boot_progress) +static int bootm_load_os (struct bootm_headers *images,int boot_progress) {image_info_t os = images->os;ulong load = os.load;
@@ -688,7 +688,7 @@ int bootm_process_cmdline_env(int flags)* unless the image type is standalone. */ int do_bootm_states (struct cmd_tbl *cmdtp,int flag,int argc, -char *const argv[],int states,bootm_headers_t *images, +char *const argv[],int states,struct bootm_headers *images,int boot_progress) {boot_os_fn *boot_fn;
@@ -878,7 +878,7 @@ static image_header_t *image_get_kernel(ulong img_addr, int verify)* address and length, otherwise NULL */ static const void *boot_get_kernel (struct cmd_tbl *cmdtp,int flag,int argc, -char *const argv[],bootm_headers_t *images, +char *const argv[],struct bootm_headers *images,ulong *os_data,ulong *os_len) {#if CONFIG_IS_ENABLED (LEGACY_IMAGE_FORMAT )
@@ -1002,7 +1002,7 @@ static int bootm_host_load_image(const void *fit, int req_image_type, {const char *fit_uname_config =NULL ;ulong data, len; -bootm_headers_t images; +struct bootm_headers images;int noffset;ulong load_end, buf_size;uint8_t image_type;
boot/bootm_os.c +14 -14
@@ -24,7 +24,7 @@DECLARE_GLOBAL_DATA_PTR ;static int do_bootm_standalone (int flag,int argc,char *const argv[], -bootm_headers_t *images) +struct bootm_headers *images) {int (*appl)(int ,char *const []);
@@ -65,7 +65,7 @@ static void __maybe_unused fit_unsupported_reset(const char *msg)#ifdef CONFIG_BOOTM_NETBSD static int do_bootm_netbsd (int flag,int argc,char *const argv[], -bootm_headers_t *images) +struct bootm_headers *images) {void (*loader)(struct bd_info *,image_header_t *,char *,char *);image_header_t *os_hdr, *hdr;
@@ -137,7 +137,7 @@ static int do_bootm_netbsd(int flag, int argc, char *const argv[],#ifdef CONFIG_BOOTM_RTEMS static int do_bootm_rtems (int flag,int argc,char *const argv[], -bootm_headers_t *images) +struct bootm_headers *images) {void (*entry_point)(struct bd_info *);
@@ -170,7 +170,7 @@ static int do_bootm_rtems(int flag, int argc, char *const argv[],#if defined(CONFIG_BOOTM_OSE )static int do_bootm_ose (int flag,int argc,char *const argv[], -bootm_headers_t *images) +struct bootm_headers *images) {void (*entry_point)(void );
@@ -203,7 +203,7 @@ static int do_bootm_ose(int flag, int argc, char *const argv[],#if defined(CONFIG_BOOTM_PLAN9 )static int do_bootm_plan9 (int flag,int argc,char *const argv[], -bootm_headers_t *images) +struct bootm_headers *images) {void (*entry_point)(void );char *s;
@@ -252,7 +252,7 @@ static int do_bootm_plan9(int flag, int argc, char *const argv[],#if defined(CONFIG_BOOTM_VXWORKS ) && \ (defined(CONFIG_PPC ) || defined(CONFIG_ARM )) -static void do_bootvx_fdt (bootm_headers_t *images) +static void do_bootvx_fdt (struct bootm_headers *images) {#if defined(CONFIG_OF_LIBFDT )int ret;
@@ -310,7 +310,7 @@ static void do_bootvx_fdt(bootm_headers_t *images) }static int do_bootm_vxworks_legacy (int flag,int argc,char *const argv[], -bootm_headers_t *images) +struct bootm_headers *images) {if (flag !=BOOTM_STATE_OS_GO )return 0 ;
@@ -328,7 +328,7 @@ static int do_bootm_vxworks_legacy(int flag, int argc, char *const argv[], }int do_bootm_vxworks (int flag,int argc,char *const argv[], -bootm_headers_t *images) +struct bootm_headers *images) {char *bootargs;int pos;
@@ -364,7 +364,7 @@ int do_bootm_vxworks(int flag, int argc, char *const argv[],#if defined(CONFIG_CMD_ELF )static int do_bootm_qnxelf (int flag,int argc,char *const argv[], -bootm_headers_t *images) +struct bootm_headers *images) {char *local_args[2 ];char str[16 ];
@@ -402,7 +402,7 @@ static int do_bootm_qnxelf(int flag, int argc, char *const argv[],#ifdef CONFIG_INTEGRITY static int do_bootm_integrity (int flag,int argc,char *const argv[], -bootm_headers_t *images) +struct bootm_headers *images) {void (*entry_point)(void );
@@ -435,7 +435,7 @@ static int do_bootm_integrity(int flag, int argc, char *const argv[],#ifdef CONFIG_BOOTM_OPENRTOS static int do_bootm_openrtos (int flag,int argc,char *const argv[], -bootm_headers_t *images) +struct bootm_headers *images) {void (*entry_point)(void );
@@ -461,7 +461,7 @@ static int do_bootm_openrtos(int flag, int argc, char *const argv[],#ifdef CONFIG_BOOTM_OPTEE static int do_bootm_tee (int flag,int argc,char *const argv[], -bootm_headers_t *images) +struct bootm_headers *images) {int ret;
@@ -489,7 +489,7 @@ static int do_bootm_tee(int flag, int argc, char *const argv[],#ifdef CONFIG_BOOTM_EFI static int do_bootm_efi (int flag,int argc,char *const argv[], -bootm_headers_t *images) +struct bootm_headers *images) {int ret;efi_status_t efi_ret;
@@ -588,7 +588,7 @@ __weak void board_preboot_os(void) }int boot_selected_os (int argc,char *const argv[],int state, -bootm_headers_t *images,boot_os_fn *boot_fn) +struct bootm_headers *images,boot_os_fn *boot_fn) {arch_preboot_os ();board_preboot_os ();
boot/image-board.c +7 -7
@@ -301,7 +301,7 @@ int genimg_get_format(const void *img_addr)* 0, no FIT support or no configuration found * 1, configuration found */ -int genimg_has_config (bootm_headers_t *images) +int genimg_has_config (struct bootm_headers *images) {if (CONFIG_IS_ENABLED (FIT ) && images->fit_uname_cfg)return 1 ;
@@ -320,7 +320,7 @@ int genimg_has_config(bootm_headers_t *images)* Return: 0 if OK, -ENOPKG if no ramdisk (but an error should not be reported), * other -ve value on other error */ -static int select_ramdisk (bootm_headers_t *images,const char *select,u8 arch, +static int select_ramdisk (struct bootm_headers *images,const char *select,u8 arch,ulong *rd_datap,ulong *rd_lenp) {const char *fit_uname_config;
@@ -482,7 +482,7 @@ static int select_ramdisk(bootm_headers_t *images, const char *select, u8 arch,* 1, if ramdisk image is found but corrupted, or invalid * rd_start and rd_end are set to 0 if no ramdisk exists */ -int boot_get_ramdisk (int argc,char *const argv[],bootm_headers_t *images, +int boot_get_ramdisk (int argc,char *const argv[],struct bootm_headers *images,u8 arch,ulong *rd_start,ulong *rd_end) {ulong rd_data, rd_len;
@@ -646,7 +646,7 @@ error:return -1 ; } -int boot_get_setup (bootm_headers_t *images,u8 arch, +int boot_get_setup (struct bootm_headers *images,u8 arch,ulong *setup_start,ulong *setup_len) {if (!CONFIG_IS_ENABLED (FIT ))
@@ -655,7 +655,7 @@ int boot_get_setup(bootm_headers_t *images, u8 arch,return boot_get_setup_fit (images, arch, setup_start, setup_len); } -int boot_get_fpga (int argc,char *const argv[],bootm_headers_t *images, +int boot_get_fpga (int argc,char *const argv[],struct bootm_headers *images,u8 arch,const ulong *ld_start,ulong *const ld_len) {ulong tmp_img_addr, img_data, img_len;
@@ -758,7 +758,7 @@ static void fit_loadable_process(u8 img_type, fit_loadable_handler->handler (img_data, img_len); } -int boot_get_loadable (int argc,char *const argv[],bootm_headers_t *images, +int boot_get_loadable (int argc,char *const argv[],struct bootm_headers *images,u8 arch,const ulong *ld_start,ulong *const ld_len) {/*
@@ -919,7 +919,7 @@ int boot_get_kbd(struct lmb *lmb, struct bd_info **kbd)return 0 ; } -int image_setup_linux (bootm_headers_t *images) +int image_setup_linux (struct bootm_headers *images) {ulong of_size = images->ft_len;char **of_flat_tree = &images->ft_addr;
boot/image-fdt.c +3 -3
@@ -291,7 +291,7 @@ error:* other -ve value on other error */ -static int select_fdt (bootm_headers_t *images,const char *select,u8 arch, +static int select_fdt (struct bootm_headers *images,const char *select,u8 arch,ulong *fdt_addrp) {const char *buf;
@@ -470,7 +470,7 @@ static int select_fdt(bootm_headers_t *images, const char *select, u8 arch,* of_flat_tree and of_size are set to 0 if no fdt exists */ int boot_get_fdt (int flag,int argc,char *const argv[],uint8_t arch, -bootm_headers_t *images,char **of_flat_tree,ulong *of_size) +struct bootm_headers *images,char **of_flat_tree,ulong *of_size) {ulong img_addr;ulong fdt_addr;
@@ -602,7 +602,7 @@ __weak int arch_fixup_fdt(void *blob)return 0 ; } -int image_setup_libfdt (bootm_headers_t *images,void *blob, +int image_setup_libfdt (struct bootm_headers *images,void *blob,int of_size,struct lmb *lmb) {ulong *initrd_start = &images->initrd_start;
boot/image-fit.c +8 -8
@@ -1933,8 +1933,8 @@ static int fit_image_select(const void *fit, int rd_noffset, int verify)return 0 ; } -int fit_get_node_from_config (bootm_headers_t *images,const char *prop_name, -ulong addr) +int fit_get_node_from_config (struct bootm_headers *images, +const char *prop_name,ulong addr) {int cfg_noffset;void *fit_hdr;
@@ -1995,7 +1995,7 @@ static const char *fit_get_image_type_property(int type)return "unknown" ; } -int fit_image_load (bootm_headers_t *images,ulong addr, +int fit_image_load (struct bootm_headers *images,ulong addr,const char **fit_unamep,const char **fit_uname_configp,int arch,int image_type,int bootstage_id,enum fit_load_op load_op,ulong *datap,ulong *lenp)
@@ -2253,8 +2253,8 @@ int fit_image_load(bootm_headers_t *images, ulong addr,return noffset; } -int boot_get_setup_fit (bootm_headers_t *images,uint8_t arch, -ulong *setup_start,ulong *setup_len) +int boot_get_setup_fit (struct bootm_headers *images,uint8_t arch, +ulong *setup_start,ulong *setup_len) {int noffset;ulong addr;
@@ -2274,9 +2274,9 @@ int boot_get_setup_fit(bootm_headers_t *images, uint8_t arch, }#ifndef USE_HOSTCC -int boot_get_fdt_fit (bootm_headers_t *images,ulong addr, -const char **fit_unamep,const char **fit_uname_configp, -int arch,ulong *datap,ulong *lenp) +int boot_get_fdt_fit (struct bootm_headers *images,ulong addr, +const char **fit_unamep,const char **fit_uname_configp, +int arch,ulong *datap,ulong *lenp) {int fdt_noffset, cfg_noffset, count;const void *fit;
cmd/bootefi.c +1 -1
@@ -281,7 +281,7 @@ efi_status_t efi_install_fdt(void *fdt) return EFI_SUCCESS; }#else -bootm_headers_t img = {0 }; +struct bootm_headers img = {0 };efi_status_t ret;if (fdt ==EFI_FDT_USE_INTERNAL ) {
cmd/booti.c +1 -1
@@ -21,7 +21,7 @@ DECLARE_GLOBAL_DATA_PTR;* Image booting support */ static int booti_start (struct cmd_tbl *cmdtp,int flag,int argc, -char *const argv[],bootm_headers_t *images) +char *const argv[],struct bootm_headers *images) {int ret;ulong ld;
cmd/bootz.c +1 -1
@@ -25,7 +25,7 @@ int __weak bootz_setup(ulong image, ulong *start, ulong *end)* zImage booting support */ static int bootz_start (struct cmd_tbl *cmdtp,int flag,int argc, -char *const argv[],bootm_headers_t *images) +char *const argv[],struct bootm_headers *images) {int ret;ulong zi_start, zi_end;
common/spl/spl.c +1 -1
@@ -255,7 +255,7 @@ void spl_set_header_raw_uboot(struct spl_image_info *spl_image)static int spl_load_fit_image (struct spl_image_info *spl_image,const struct image_header *header) { -bootm_headers_t images; +struct bootm_headers images;const char *fit_uname_config =NULL ;uintptr_t fdt_hack;const char *uname;
include/bootm.h +3 -3
@@ -33,7 +33,7 @@ struct cmd_tbl;* not return. */ typedef int boot_os_fn (int flag,int argc,char *const argv[], -bootm_headers_t *images); +struct bootm_headers *images);extern boot_os_fn do_bootm_linux;extern boot_os_fn do_bootm_vxworks;
@@ -47,7 +47,7 @@ int bootm_host_load_images(const void *fit, int cfg_noffset);#endif int boot_selected_os (int argc,char *const argv[],int state, -bootm_headers_t *images,boot_os_fn *boot_fn); +struct bootm_headers *images,boot_os_fn *boot_fn);ulong bootm_disable_interrupts (void );
@@ -56,7 +56,7 @@ int bootm_find_images(int flag, int argc, char *const argv[], ulong start, ulong size);int do_bootm_states (struct cmd_tbl *cmdtp,int flag,int argc, -char *const argv[],int states,bootm_headers_t *images, +char *const argv[],int states,struct bootm_headers *images,int boot_progress);void arch_preboot_os (void );
include/image.h +18 -18
@@ -290,7 +290,7 @@ typedef struct image_info {* Legacy and FIT format headers used by do_bootm() and do_bootm_<os>() * routines. */ -typedef struct bootm_headers { +struct bootm_headers {/* * Legacy os image header, if it is a multi component image * then boot_get_ramdisk() and get_fdt() will attempt to get
@@ -358,7 +358,7 @@ typedef struct bootm_headers {#if defined(CONFIG_LMB ) && !defined(USE_HOSTCC )struct lmb lmb;/* for memory mgmt */ #endif -} bootm_headers_t; +};#ifdef CONFIG_LMB #define images_lmb (_images) (&(_images)->lmb)
@@ -366,7 +366,7 @@ typedef struct bootm_headers {#define images_lmb (_images) NULL#endif -extern bootm_headers_t images; +extern struct bootm_headers images;/* * Some systems (for example LWMON) have very short watchdog periods;
@@ -530,7 +530,7 @@ enum fit_load_op { FIT_LOAD_REQUIRED, /* Must be provided */ }; -int boot_get_setup (bootm_headers_t *images,uint8_t arch,ulong *setup_start, +int boot_get_setup (struct bootm_headers *images,uint8_t arch,ulong *setup_start,ulong *setup_len);/* Image format types, returned by _get_format() routine */
@@ -544,11 +544,11 @@ ulong genimg_get_kernel_addr_fit(char * const img_addr, const char **fit_uname_kernel);ulong genimg_get_kernel_addr (char *const img_addr);int genimg_get_format (const void *img_addr); -int genimg_has_config (bootm_headers_t *images); +int genimg_has_config (struct bootm_headers *images); -int boot_get_fpga (int argc,char *const argv[],bootm_headers_t *images, +int boot_get_fpga (int argc,char *const argv[],struct bootm_headers *images,uint8_t arch,const ulong *ld_start,ulong *const ld_len); -int boot_get_ramdisk (int argc,char *const argv[],bootm_headers_t *images, +int boot_get_ramdisk (int argc,char *const argv[],struct bootm_headers *images,uint8_t arch,ulong *rd_start,ulong *rd_end);/**
@@ -572,10 +572,10 @@ int boot_get_ramdisk(int argc, char *const argv[], bootm_headers_t *images,* 0, if only valid images or no images are found * error code, if an error occurs during fit_image_load */ -int boot_get_loadable (int argc,char *const argv[],bootm_headers_t *images, +int boot_get_loadable (int argc,char *const argv[],struct bootm_headers *images,uint8_t arch,const ulong *ld_start,ulong *const ld_len); -int boot_get_setup_fit (bootm_headers_t *images,uint8_t arch, +int boot_get_setup_fit (struct bootm_headers *images,uint8_t arch,ulong *setup_start,ulong *setup_len);/**
@@ -599,9 +599,9 @@ int boot_get_setup_fit(bootm_headers_t *images, uint8_t arch,* * Return: node offset of base image, or -ve error code on error */ -int boot_get_fdt_fit (bootm_headers_t *images,ulong addr, -const char **fit_unamep,const char **fit_uname_configp, -int arch,ulong *datap,ulong *lenp); +int boot_get_fdt_fit (struct bootm_headers *images,ulong addr, +const char **fit_unamep,const char **fit_uname_configp, +int arch,ulong *datap,ulong *lenp);/** * fit_image_load() - load an image from a FIT
@@ -633,7 +633,7 @@ int boot_get_fdt_fit(bootm_headers_t *images, ulong addr,* @param lenp Returns length of loaded image * Return: node offset of image, or -ve error code on error */ -int fit_image_load (bootm_headers_t *images,ulong addr, +int fit_image_load (struct bootm_headers *images,ulong addr,const char **fit_unamep,const char **fit_uname_configp,int arch,int image_type,int bootstage_id,enum fit_load_op load_op,ulong *datap,ulong *lenp);
@@ -677,11 +677,11 @@ int image_source_script(ulong addr, const char *fit_uname);* @param prop_name Property name to look up (FIT_..._PROP) * @param addr Address of FIT in memory */ -int fit_get_node_from_config (bootm_headers_t *images,const char *prop_name, -ulong addr); +int fit_get_node_from_config (struct bootm_headers *images, +const char *prop_name,ulong addr);int boot_get_fdt (int flag,int argc,char *const argv[],uint8_t arch, -bootm_headers_t *images, +struct bootm_headers *images,char **of_flat_tree,ulong *of_size);void boot_fdt_add_mem_rsv_regions (struct lmb *lmb,void *fdt_blob);int boot_relocate_fdt (struct lmb *lmb,char **of_flat_tree,ulong *of_size);
@@ -871,7 +871,7 @@ int image_decomp(int comp, ulong load, ulong image_start, int type,* @lmb: Points to logical memory block structure * Return: 0 if ok, <0 on failure */ -int image_setup_libfdt (bootm_headers_t *images,void *blob, +int image_setup_libfdt (struct bootm_headers *images,void *blob,int of_size,struct lmb *lmb);/**
@@ -883,7 +883,7 @@ int image_setup_libfdt(bootm_headers_t *images, void *blob,* @param images Images information * Return: 0 if ok, <0 on failure */ -int image_setup_linux (bootm_headers_t *images); +int image_setup_linux (struct bootm_headers *images);/** * bootz_setup() - Extract stat and size of a Linux xImage
lib/efi_loader/efi_dt_fixup.c +1 -1
@@ -145,7 +145,7 @@ efi_dt_fixup(struct efi_dt_fixup_protocol *this, void *dtb,efi_status_t ret;size_t required_size;size_t total_size; -bootm_headers_t img = {0 }; +struct bootm_headers img = {0 };EFI_ENTRY ("%p, %p, %p, %d" , this, dtb, buffer_size, flags);
Signature · 1 line
2.37.2.672.g94769d06f0-goog
PATCH 3/21 treewide: Drop image_info_t typedef
In reply to Simon GlassThis is not needed and we should avoid typedefs. Use the struct instead.
---
boot/bootm.c | 2 +- include/image.h | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-)
boot/bootm.c +1 -1
@@ -399,7 +399,7 @@ static int handle_decomp_error(int comp_type, size_t uncomp_size,#ifndef USE_HOSTCC static int bootm_load_os (struct bootm_headers *images,int boot_progress) { -image_info_t os = images->os; +struct image_info os = images->os;ulong load = os.load;ulong load_end;ulong blob_start = os.start;
include/image.h +3 -3
@@ -278,13 +278,13 @@ typedef struct image_header {uint8_t ih_name[IH_NMLEN ];/* Image Name */ } image_header_t; -typedef struct image_info { +struct image_info {ulong start, end;/* start/end of blob */ ulong image_start, image_len;/* start of image within blob, len of image */ ulong load;/* load addr for the image */ uint8_t comp, type, os;/* compression, type of image, os type */ uint8_t arch;/* CPU architecture */ -}image_info_t ; +};/* * Legacy and FIT format headers used by do_bootm() and do_bootm_<os>()
@@ -324,7 +324,7 @@ struct bootm_headers {int fit_noffset_setup;/* x86 setup subimage node offset */ #ifndef USE_HOSTCC -image_info_t os;/* os image info */ +struct image_info os;/* os image info */ ulong ep;/* entry point of OS */ ulong rd_start, rd_end;/* ramdisk start/end */
Signature · 1 line
2.37.2.672.g94769d06f0-goog
PATCH 4/21 treewide: Drop image_header_t typedef
In reply to Simon GlassThis is not needed and we should avoid typedefs. Use the struct instead and rename it to indicate that it really is a legacy struct.
---
arch/arm/mach-aspeed/ast2600/spl.c | 4 +- arch/arm/mach-imx/hab.c | 2 +- arch/arm/mach-imx/spl_imx_romapi.c | 6 +-- arch/arm/mach-k3/sysfw-loader.c | 6 +-- arch/arm/mach-keystone/cmd_mon.c | 6 +-- arch/arm/mach-sunxi/spl_spi_sunxi.c | 4 +- arch/mips/mach-jz47xx/jz4780/jz4780.c | 6 +-- arch/mips/mach-mtmips/mt7621/spl/spl.c | 4 +- arch/mips/mach-mtmips/mt7621/tpl/tpl.c | 4 +- arch/x86/lib/bootm.c | 2 +- board/ti/ks2_evm/board.c | 4 +- boot/boot_fit.c | 4 +- boot/bootm.c | 8 ++-- boot/bootm_os.c | 7 ++-- boot/image-android.c | 6 +-- boot/image-board.c | 12 +++--- boot/image-fdt.c | 6 +-- boot/image.c | 14 +++---- cmd/bootm.c | 4 +- cmd/disk.c | 4 +- cmd/fpga.c | 2 +- cmd/nand.c | 4 +- cmd/source.c | 2 +- cmd/ximg.c | 4 +- common/spl/spl.c | 8 ++-- common/spl/spl_ext.c | 4 +- common/spl/spl_fat.c | 6 +-- common/spl/spl_legacy.c | 8 ++-- common/spl/spl_mmc.c | 4 +- common/spl/spl_nand.c | 4 +- common/spl/spl_net.c | 2 +- common/spl/spl_nor.c | 8 ++-- common/spl/spl_onenand.c | 2 +- common/spl/spl_ram.c | 8 ++-- common/spl/spl_sata.c | 2 +- common/spl/spl_semihosting.c | 4 +- common/spl/spl_spi.c | 6 +-- common/spl/spl_ubi.c | 4 +- common/spl/spl_xip.c | 2 +- common/spl/spl_ymodem.c | 14 +++---- common/splash_source.c | 6 +-- doc/uImage.FIT/source_file_format.txt | 2 +- drivers/fpga/socfpga_arria10.c | 4 +- drivers/usb/gadget/f_sdp.c | 2 +- include/configs/uniphier.h | 2 +- include/image.h | 52 ++++++++++++++------------ include/spl.h | 8 ++-- include/tee/optee.h | 4 +- test/image/spl_load.c | 4 +- tools/binman/ftest.py | 4 +- tools/default_image.c | 31 ++++++++------- tools/fit_image.c | 4 +- tools/imx8mimage.c | 8 ++-- tools/mkimage.c | 2 +- tools/mtk_image.c | 10 ++--- 55 files changed, 179 insertions(+), 175 deletions(-)
arch/arm/mach-aspeed/ast2600/spl.c +2 -2
@@ -56,9 +56,9 @@ out:return BOOT_DEVICE_RAM ; } -struct image_header *spl_get_load_buffer (ssize_t offset,size_t size) +struct legacy_img_hdr *spl_get_load_buffer (ssize_t offset,size_t size) { -return (struct image_header *)(CONFIG_SYS_LOAD_ADDR ); +return (struct legacy_img_hdr *)(CONFIG_SYS_LOAD_ADDR ); }#ifdef CONFIG_SPL_OS_BOOT
arch/arm/mach-imx/hab.c +1 -1
@@ -589,7 +589,7 @@ static ulong get_image_ivt_offset(ulong img_addr)switch (genimg_get_format (buf)) {#if CONFIG_IS_ENABLED (LEGACY_IMAGE_FORMAT )case IMAGE_FORMAT_LEGACY : -return (image_get_image_size ((image_header_t *)img_addr) +return (image_get_image_size ((struct legacy_img_hdr *)img_addr) +0x1000 -1 ) & ~(0x1000 -1 );#endif #if CONFIG_IS_ENABLED (FIT )
arch/arm/mach-imx/spl_imx_romapi.c +3 -3
@@ -72,7 +72,7 @@ static int spl_romapi_load_image_seekable(struct spl_image_info *spl_image,int ret;u32 offset;u32 pagesize, size; -struct image_header *header; +struct legacy_img_hdr *header;u32 image_offset; ret =rom_api_query_boot_infor (QUERY_IVT_OFF , &offset);
@@ -84,14 +84,14 @@ static int spl_romapi_load_image_seekable(struct spl_image_info *spl_image,return -1 ; } - header = (struct image_header *)(CONFIG_SPL_IMX_ROMAPI_LOADADDR ); + header = (struct legacy_img_hdr *)(CONFIG_SPL_IMX_ROMAPI_LOADADDR );printf ("image offset 0x%x, pagesize 0x%x, ivt offset 0x%x\n" , image_offset, pagesize, offset); offset =spl_romapi_get_uboot_base (image_offset, rom_bt_dev); - size =ALIGN (sizeof (struct image_header ), pagesize); + size =ALIGN (sizeof (struct legacy_img_hdr ), pagesize); ret =rom_api_download_image ((u8 *)header, offset, size);if (ret !=ROM_API_OKAY ) {
arch/arm/mach-k3/sysfw-loader.c +3 -3
@@ -88,10 +88,10 @@ static void *sysfw_load_address;* Populate SPL hook to override the default load address used by the SPL * loader function with a custom address for SYSFW loading. */ -struct image_header *spl_get_load_buffer (ssize_t offset,size_t size) +struct legacy_img_hdr *spl_get_load_buffer (ssize_t offset,size_t size) {if (sysfw_loaded) -return (struct image_header *)(CONFIG_SYS_TEXT_BASE + offset); +return (struct legacy_img_hdr *)(CONFIG_SYS_TEXT_BASE + offset);else if (sysfw_load_address)return sysfw_load_address;else
@@ -490,7 +490,7 @@ void k3_sysfw_loader(bool rom_loaded_sysfw, sysfw_loaded = true;/* Ensure the SYSFW image is in FIT format */ -if (image_get_magic ((const image_header_t *)sysfw_load_address) != +if (image_get_magic ((const struct legacy_img_hdr *)sysfw_load_address) !=FDT_MAGIC )panic ("SYSFW image not in FIT format!\n" );
arch/arm/mach-keystone/cmd_mon.c +3 -3
@@ -17,7 +17,7 @@ static int do_mon_install(struct cmd_tbl *cmdtp, int flag, int argc, {u32 addr, dpsc_base =0x1E80000 , freq, load_addr, size;int rcode =0 ; -struct image_header *header; +struct legacy_img_hdr *header;u32 ecrypt_bm_addr =0 ;if (argc <2 )
@@ -27,7 +27,7 @@ static int do_mon_install(struct cmd_tbl *cmdtp, int flag, int argc, addr =hextoul (argv[1 ],NULL ); - header = (struct image_header *)addr; + header = (struct legacy_img_hdr *)addr;if (image_get_magic (header) !=IH_MAGIC ) {printf ("## Please update monitor image\n" );
@@ -36,7 +36,7 @@ static int do_mon_install(struct cmd_tbl *cmdtp, int flag, int argc, load_addr =image_get_load (header); size =image_get_data_size (header); -memcpy ((void *)load_addr, (void *)(addr +sizeof (struct image_header )), +memcpy ((void *)load_addr, (void *)(addr +sizeof (struct legacy_img_hdr )), size);if (argc >=3 )
arch/arm/mach-sunxi/spl_spi_sunxi.c +2 -2
@@ -335,10 +335,10 @@ static int spl_spi_load_image(struct spl_image_info *spl_image, struct spl_boot_device *bootdev) {int ret =0 ; -struct image_header *header; - header = (struct image_header *)(CONFIG_SYS_TEXT_BASE ); +struct legacy_img_hdr *header;uint32_t load_offset =sunxi_get_spl_size (); + header = (struct legacy_img_hdr *)CONFIG_SYS_TEXT_BASE ; load_offset =max_t (uint32_t, load_offset,CONFIG_SYS_SPI_U_BOOT_OFFS );spi0_init ();
arch/mips/mach-jz47xx/jz4780/jz4780.c +3 -3
@@ -30,7 +30,7 @@ void board_init_f(ulong dummy)typedef void __noreturn (*image_entry_noargs_t )(void );struct mmc *mmc;unsigned long count; -struct image_header *header; +struct legacy_img_hdr *header;int ret;/* Set global data pointer */
@@ -58,8 +58,8 @@ void board_init_f(ulong dummy)if (ret)hang (); - header = (struct image_header *)(CONFIG_SYS_TEXT_BASE - -sizeof (struct image_header )); + header = (struct legacy_img_hdr *)(CONFIG_SYS_TEXT_BASE - +sizeof (struct legacy_img_hdr )); count = blk_dread(mmc_get_blk_desc(mmc), CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR,
arch/mips/mach-mtmips/mt7621/spl/spl.c +2 -2
@@ -64,7 +64,7 @@ void board_boot_order(u32 *spl_boot_list)unsigned long spl_nor_get_uboot_base (void ) {const struct tpl_info *tpli; -const image_header_t *hdr; +const struct legacy_img_hdr *hdr;u32 addr; addr =FLASH_MMAP_BASE +TPL_INFO_OFFSET ;
@@ -72,7 +72,7 @@ unsigned long spl_nor_get_uboot_base(void)if (tpli->magic ==TPL_INFO_MAGIC ) { addr =FLASH_MMAP_BASE + tpli->size; - hdr = (const image_header_t *)KSEG1ADDR (addr); + hdr = (const struct legacy_img_hdr *)KSEG1ADDR (addr);if (image_get_magic (hdr) ==IH_MAGIC ) { addr +=sizeof (*hdr) +image_get_size (hdr);
arch/mips/mach-mtmips/mt7621/tpl/tpl.c +2 -2
@@ -116,7 +116,7 @@ static void mt7621_cache_init(void)void __noreturn tpl_main (void ) { -const image_header_t *hdr = (const image_header_t *)__image_copy_end; +const struct legacy_img_hdr *hdr = (const struct legacy_img_hdr *)__image_copy_end;image_entry_noargs_t image_entry;u32 loadaddr, size;uintptr_t data;
@@ -132,7 +132,7 @@ void __noreturn tpl_main(void) image_entry = (image_entry_noargs_t )image_get_ep (hdr);/* Load TPL image to L2 cache */ - data = (uintptr_t )__image_copy_end +sizeof (struct image_header ); + data = (uintptr_t )__image_copy_end +sizeof (struct legacy_img_hdr );fill_lock_l2cache (data, loadaddr, size);/* Jump to SPL */
arch/x86/lib/bootm.c +1 -1
@@ -72,7 +72,7 @@ int arch_fixup_memory_node(void *blob)static int boot_prep_linux (struct bootm_headers *images) {char *cmd_line_dest =NULL ; -image_header_t *hdr; +struct legacy_img_hdr *hdr;int is_zimage =0 ;void *data =NULL ;size_t len;
board/ti/ks2_evm/board.c +2 -2
@@ -64,9 +64,9 @@ int dram_init(void)return 0 ; } -struct image_header *spl_get_load_buffer (ssize_t offset,size_t size) +struct legacy_img_hdr *spl_get_load_buffer (ssize_t offset,size_t size) { -return (struct image_header *)(CONFIG_SYS_TEXT_BASE ); +return (struct legacy_img_hdr *)(CONFIG_SYS_TEXT_BASE ); }int board_init (void )
boot/boot_fit.c +2 -2
@@ -57,14 +57,14 @@ static int fdt_offset(const void *fit)void *locate_dtb_in_fit (const void *fit) { -struct image_header *header; +struct legacy_img_hdr *header;int size;int ret; size =fdt_totalsize (fit); size = (size +3 ) & ~3 ; - header = (struct image_header *)fit; + header = (struct legacy_img_hdr *)fit;if (image_get_magic (header) !=FDT_MAGIC ) {debug ("No FIT image appended to U-boot\n" );
boot/bootm.c +4 -4
@@ -825,9 +825,9 @@ err:* pointer to a legacy image header if valid image was found * otherwise return NULL */ -static image_header_t *image_get_kernel (ulong img_addr,int verify) +static struct legacy_img_hdr *image_get_kernel (ulong img_addr,int verify) { -image_header_t *hdr = (image_header_t *)img_addr; +struct legacy_img_hdr *hdr = (struct legacy_img_hdr *)img_addr;if (!image_check_magic (hdr)) {puts ("Bad Magic Number\n" );
@@ -882,7 +882,7 @@ static const void *boot_get_kernel(struct cmd_tbl *cmdtp, int flag, int argc, ulong *os_data, ulong *os_len) {#if CONFIG_IS_ENABLED (LEGACY_IMAGE_FORMAT ) -image_header_t *hdr; +struct legacy_img_hdr *hdr;#endif ulong img_addr;const void *buf;
@@ -940,7 +940,7 @@ static const void *boot_get_kernel(struct cmd_tbl *cmdtp, int flag, int argc,* kernel decompression. */ memmove (&images->legacy_hdr_os_copy, hdr, -sizeof (image_header_t)); +sizeof (struct legacy_img_hdr ));/* save pointer to image header */ images->legacy_hdr_os = hdr;
boot/bootm_os.c +4 -3
@@ -67,8 +67,9 @@ static void __maybe_unused fit_unsupported_reset(const char *msg)static int do_bootm_netbsd (int flag,int argc,char *const argv[],struct bootm_headers *images) { -void (*loader)(struct bd_info *,image_header_t *,char *,char *); -image_header_t *os_hdr, *hdr; +void (*loader)(struct bd_info *bd,struct legacy_img_hdr *hdr, +char *console,char *cmdline); +struct legacy_img_hdr *os_hdr, *hdr;ulong kernel_data, kernel_len;char *cmdline;
@@ -115,7 +116,7 @@ static int do_bootm_netbsd(int flag, int argc, char *const argv[], cmdline ="" ; } - loader = (void (*)(struct bd_info *,image_header_t *,char *,char *))images->ep; + loader = (void (*)(struct bd_info *,struct legacy_img_hdr *,char *,char *))images->ep;printf ("## Transferring control to NetBSD stage-2 loader (at address %08lx) ...\n" , (ulong )loader);
boot/image-android.c +3 -3
@@ -63,7 +63,7 @@ int android_image_get_kernel(const struct andr_img_hdr *hdr, int verify, ulong *os_data, ulong *os_len) {u32 kernel_addr =android_image_get_kernel_addr (hdr); -const struct image_header *ihdr = (const struct image_header *) +const struct legacy_img_hdr *ihdr = (const struct legacy_img_hdr *) ((uintptr_t )hdr + hdr->page_size);/*
@@ -159,8 +159,8 @@ ulong android_image_get_kcomp(const struct andr_img_hdr *hdr) {const void *p = (void *)((uintptr_t )hdr + hdr->page_size); -if (image_get_magic ((image_header_t *)p) ==IH_MAGIC ) -return image_get_comp ((image_header_t *)p); +if (image_get_magic ((struct legacy_img_hdr *)p) ==IH_MAGIC ) +return image_get_comp ((struct legacy_img_hdr *)p);else if (get_unaligned_le32 (p) ==LZ4F_MAGIC )return IH_COMP_LZ4 ;else
boot/image-board.c +6 -6
@@ -40,10 +40,10 @@ DECLARE_GLOBAL_DATA_PTR;* pointer to a ramdisk image header, if image was found and valid * otherwise, return NULL */ -static const image_header_t *image_get_ramdisk (ulong rd_addr,u8 arch, -int verify) +static const struct legacy_img_hdr *image_get_ramdisk (ulong rd_addr,u8 arch, +int verify) { -const image_header_t *rd_hdr = (const image_header_t *)rd_addr; +const struct legacy_img_hdr *rd_hdr = (const struct legacy_img_hdr *)rd_addr;if (!image_check_magic (rd_hdr)) {puts ("Bad Magic Number\n" );
@@ -273,9 +273,9 @@ ulong genimg_get_kernel_addr(char * const img_addr)int genimg_get_format (const void *img_addr) {if (CONFIG_IS_ENABLED (LEGACY_IMAGE_FORMAT )) { -const image_header_t *hdr; +const struct legacy_img_hdr *hdr; - hdr = (const image_header_t *)img_addr; + hdr = (const struct legacy_img_hdr *)img_addr;if (image_check_magic (hdr))return IMAGE_FORMAT_LEGACY ; }
@@ -389,7 +389,7 @@ static int select_ramdisk(struct bootm_headers *images, const char *select, u8 aswitch (genimg_get_format (buf)) {case IMAGE_FORMAT_LEGACY :if (CONFIG_IS_ENABLED (LEGACY_IMAGE_FORMAT )) { -const image_header_t *rd_hdr; +const struct legacy_img_hdr *rd_hdr;printf ("## Loading init Ramdisk from Legacy Image at %08lx ...\n" , rd_addr);
boot/image-fdt.c +3 -3
@@ -37,9 +37,9 @@ static void fdt_error(const char *msg) }#if CONFIG_IS_ENABLED (LEGACY_IMAGE_FORMAT ) -static const image_header_t *image_get_fdt (ulong fdt_addr) +static const struct legacy_img_hdr *image_get_fdt (ulong fdt_addr) { -const image_header_t *fdt_hdr =map_sysmem (fdt_addr,0 ); +const struct legacy_img_hdr *fdt_hdr =map_sysmem (fdt_addr,0 );image_print_contents (fdt_hdr);
@@ -358,7 +358,7 @@ static int select_fdt(struct bootm_headers *images, const char *select, u8 arch,switch (genimg_get_format (buf)) {#if CONFIG_IS_ENABLED (LEGACY_IMAGE_FORMAT )case IMAGE_FORMAT_LEGACY : { -const image_header_t *fdt_hdr; +const struct legacy_img_hdr *fdt_hdr;ulong load, load_end;ulong image_start, image_data, image_end;
boot/image.c +7 -7
@@ -220,11 +220,11 @@ static const struct table_info table_info[IH_COUNT] = {/*****************************************************************************/ /* Legacy format routines */ /*****************************************************************************/ -int image_check_hcrc (const image_header_t *hdr) +int image_check_hcrc (const struct legacy_img_hdr *hdr) {ulong hcrc;ulong len =image_get_header_size (); -image_header_t header; +struct legacy_img_hdr header;/* Copy header so we can blank CRC field for re-calculation */ memmove (&header, (char *)hdr,image_get_header_size ());
@@ -235,7 +235,7 @@ int image_check_hcrc(const image_header_t *hdr)return (hcrc ==image_get_hcrc (hdr)); } -int image_check_dcrc (const image_header_t *hdr) +int image_check_dcrc (const struct legacy_img_hdr *hdr) {ulong data =image_get_data (hdr);ulong len =image_get_data_size (hdr);
@@ -257,7 +257,7 @@ int image_check_dcrc(const image_header_t *hdr)* returns: * number of components */ -ulong image_multi_count (const image_header_t *hdr) +ulong image_multi_count (const struct legacy_img_hdr *hdr) {ulong i, count =0 ;uint32_t *size;
@@ -290,7 +290,7 @@ ulong image_multi_count(const image_header_t *hdr)* data address and size of the component, if idx is valid * 0 in data and len, if idx is out of range */ -void image_multi_getimg (const image_header_t *hdr,ulong idx, +void image_multi_getimg (const struct legacy_img_hdr *hdr,ulong idx,ulong *data,ulong *len) {int i;
@@ -326,7 +326,7 @@ void image_multi_getimg(const image_header_t *hdr, ulong idx, } } -static void image_print_type (const image_header_t *hdr) +static void image_print_type (const struct legacy_img_hdr *hdr) {const char __maybe_unused *os, *arch, *type, *comp;
@@ -352,7 +352,7 @@ static void image_print_type(const image_header_t *hdr)*/ void image_print_contents (const void *ptr) { -const image_header_t *hdr = (const image_header_t *)ptr; +const struct legacy_img_hdr *hdr = (const struct legacy_img_hdr *)ptr;const char __maybe_unused *p; p =IMAGE_INDENT_STRING ;
cmd/bootm.c +2 -2
@@ -511,7 +511,7 @@ static int do_imls_nand(void)continue ;for (off =0 ; off < mtd->size; off += mtd->erasesize) { -const image_header_t *header; +const struct legacy_img_hdr *header;int ret;if (nand_block_isbad (mtd, off))
@@ -529,7 +529,7 @@ static int do_imls_nand(void)switch (genimg_get_format (buffer)) {#if defined(CONFIG_LEGACY_IMAGE_FORMAT )case IMAGE_FORMAT_LEGACY : - header = (const image_header_t *)buffer; + header = (const struct legacy_img_hdr *)buffer; len =image_get_image_size (header);nand_imls_legacyimage (mtd, nand_dev, off, len);
cmd/disk.c +2 -2
@@ -20,7 +20,7 @@ int common_diskboot(struct cmd_tbl *cmdtp, const char *intf, int argc,ulong cnt;struct disk_partition info;#if defined(CONFIG_LEGACY_IMAGE_FORMAT ) -image_header_t *hdr; +struct legacy_img_hdr *hdr;#endif struct blk_desc *dev_desc;
@@ -68,7 +68,7 @@ int common_diskboot(struct cmd_tbl *cmdtp, const char *intf, int argc,switch (genimg_get_format ((void *) addr)) {#if defined(CONFIG_LEGACY_IMAGE_FORMAT )case IMAGE_FORMAT_LEGACY : - hdr = (image_header_t *) addr; + hdr = (struct legacy_img_hdr *)addr;bootstage_mark (BOOTSTAGE_ID_IDE_FORMAT );
cmd/fpga.c +1 -1
@@ -288,7 +288,7 @@ static int do_fpga_loadmk(struct cmd_tbl *cmdtp, int flag, int argc,#if defined(CONFIG_LEGACY_IMAGE_FORMAT )case IMAGE_FORMAT_LEGACY : { -image_header_t *hdr = (image_header_t *)fpga_data; +struct legacy_img_hdr *hdr = (struct legacy_img_hdr *)fpga_data;ulong data;u8 comp;
cmd/nand.c +2 -2
@@ -975,7 +975,7 @@ static int nand_load_image(struct cmd_tbl *cmdtp, struct mtd_info *mtd,char *s;size_t cnt;#if defined(CONFIG_LEGACY_IMAGE_FORMAT ) -image_header_t *hdr; +struct legacy_img_hdr *hdr;#endif #if defined(CONFIG_FIT )const void *fit_hdr =NULL ;
@@ -1004,7 +1004,7 @@ static int nand_load_image(struct cmd_tbl *cmdtp, struct mtd_info *mtd,switch (genimg_get_format ((void *)addr)) {#if defined(CONFIG_LEGACY_IMAGE_FORMAT )case IMAGE_FORMAT_LEGACY : - hdr = (image_header_t *)addr; + hdr = (struct legacy_img_hdr *)addr;bootstage_mark (BOOTSTAGE_ID_NAND_TYPE );image_print_contents (hdr);
cmd/source.c +1 -1
@@ -46,7 +46,7 @@ int image_source_script(ulong addr, const char *fit_uname) {ulong len;#if defined(CONFIG_LEGACY_IMAGE_FORMAT ) -const image_header_t *hdr; +const struct legacy_img_hdr *hdr;#endif u32 *data;int verify;
cmd/ximg.c +2 -2
@@ -42,7 +42,7 @@ do_imgextract(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])int part =0 ;#if defined(CONFIG_LEGACY_IMAGE_FORMAT )ulong count; -image_header_t *hdr =NULL ; +struct legacy_img_hdr *hdr =NULL ;#endif #if defined(CONFIG_FIT )const char *uname =NULL ;
@@ -78,7 +78,7 @@ do_imgextract(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])printf ("## Copying part %d from legacy image " "at %08lx ...\n" , part, addr); - hdr = (image_header_t *)addr; + hdr = (struct legacy_img_hdr *)addr;if (!image_check_magic (hdr)) {printf ("Bad Magic Number\n" );return 1 ;
common/spl/spl.c +4 -4
@@ -222,7 +222,7 @@ __weak void spl_board_prepare_for_boot(void)/* Nothing to do! */ } -__weak struct image_header *spl_get_load_buffer (ssize_t offset,size_t size) +__weak struct legacy_img_hdr *spl_get_load_buffer (ssize_t offset,size_t size) {return map_sysmem (CONFIG_SYS_TEXT_BASE + offset,0 ); }
@@ -253,7 +253,7 @@ void spl_set_header_raw_uboot(struct spl_image_info *spl_image)#if CONFIG_IS_ENABLED (LOAD_FIT_FULL )/* Parse and load full fitImage in SPL */ static int spl_load_fit_image (struct spl_image_info *spl_image, -const struct image_header *header) +const struct legacy_img_hdr *header) {struct bootm_headers images;const char *fit_uname_config =NULL ;
@@ -354,7 +354,7 @@ __weak int spl_parse_board_header(struct spl_image_info *spl_image, }__weak int spl_parse_legacy_header (struct spl_image_info *spl_image, -const struct image_header *header) +const struct legacy_img_hdr *header) {/* LEGACY image not supported */ debug ("Legacy boot image support not enabled, proceeding to other boot methods\n" );
@@ -363,7 +363,7 @@ __weak int spl_parse_legacy_header(struct spl_image_info *spl_image,int spl_parse_image_header (struct spl_image_info *spl_image,const struct spl_boot_device *bootdev, -const struct image_header *header) +const struct legacy_img_hdr *header) {#if CONFIG_IS_ENABLED (LOAD_FIT_FULL )int ret =spl_load_fit_image (spl_image, header);
common/spl/spl_ext.c +2 -2
@@ -15,7 +15,7 @@ int spl_load_image_ext(struct spl_image_info *spl_image, const char *filename) {s32 err; -struct image_header *header; +struct legacy_img_hdr *header;loff_t filelen, actlen;struct disk_partition part_info = {};
@@ -41,7 +41,7 @@ int spl_load_image_ext(struct spl_image_info *spl_image,puts ("spl: ext4fs_open failed\n" ); goto end; } - err =ext4fs_read ((char *)header,0 ,sizeof (struct image_header ), &actlen); + err =ext4fs_read ((char *)header,0 ,sizeof (struct legacy_img_hdr ), &actlen);if (err <0 ) {puts ("spl: ext4fs_read failed\n" ); goto end;
common/spl/spl_fat.c +3 -3
@@ -60,7 +60,7 @@ int spl_load_image_fat(struct spl_image_info *spl_image, const char *filename) {int err; -struct image_header *header; +struct legacy_img_hdr *header; err =spl_register_fat_device (block_dev, partition);if (err)
@@ -68,7 +68,7 @@ int spl_load_image_fat(struct spl_image_info *spl_image, header =spl_get_load_buffer (-sizeof (*header),sizeof (*header)); - err =file_fat_read (filename, header,sizeof (struct image_header )); + err =file_fat_read (filename, header,sizeof (struct legacy_img_hdr ));if (err <=0 ) goto end;
@@ -78,7 +78,7 @@ int spl_load_image_fat(struct spl_image_info *spl_image,if (err <=0 ) goto end; err =spl_parse_image_header (spl_image, bootdev, - (struct image_header *)CONFIG_SYS_LOAD_ADDR ); + (struct legacy_img_hdr *)CONFIG_SYS_LOAD_ADDR );if (err == -EAGAIN )return err;if (err ==0 )
common/spl/spl_legacy.c +4 -4
@@ -16,9 +16,9 @@#define LZMA_LEN (1 << 20)int spl_parse_legacy_header (struct spl_image_info *spl_image, -const struct image_header *header) +const struct legacy_img_hdr *header) { -u32 header_size =sizeof (struct image_header ); +u32 header_size =sizeof (struct legacy_img_hdr );/* check uImage header CRC */ if (IS_ENABLED(CONFIG_SPL_LEGACY_IMAGE_CRC_CHECK) &&
@@ -67,7 +67,7 @@ int spl_parse_legacy_header(struct spl_image_info *spl_image,* following switch/case statement in spl_load_legacy_img() away due to * Dead Code Elimination. */ -static inline int spl_image_get_comp (const struct image_header *hdr) +static inline int spl_image_get_comp (const struct legacy_img_hdr *hdr) {if (IS_ENABLED (CONFIG_SPL_LZMA ))return image_get_comp (hdr);
@@ -81,7 +81,7 @@ int spl_load_legacy_img(struct spl_image_info *spl_image, {__maybe_unused SizeT lzma_len;__maybe_unused void *src; -struct image_header hdr; +struct legacy_img_hdr hdr;ulong dataptr;int ret;
common/spl/spl_mmc.c +2 -2
@@ -20,7 +20,7 @@static int mmc_load_legacy (struct spl_image_info *spl_image,struct spl_boot_device *bootdev,struct mmc *mmc, -ulong sector,struct image_header *header) +ulong sector,struct legacy_img_hdr *header) {u32 image_offset_sectors;u32 image_size_sectors;
@@ -83,7 +83,7 @@ int mmc_load_image_raw_sector(struct spl_image_info *spl_image, struct mmc *mmc, unsigned long sector) {unsigned long count; -struct image_header *header; +struct legacy_img_hdr *header;struct blk_desc *bd =mmc_get_blk_desc (mmc);int ret =0 ;
common/spl/spl_nand.c +2 -2
@@ -78,7 +78,7 @@ struct mtd_info * __weak nand_get_mtd(void)static int spl_nand_load_element (struct spl_image_info *spl_image,struct spl_boot_device *bootdev, -int offset,struct image_header *header) +int offset,struct legacy_img_hdr *header) {struct mtd_info *mtd =nand_get_mtd ();int bl_len = mtd ? mtd->writesize :1 ;
@@ -133,7 +133,7 @@ static int spl_nand_load_image(struct spl_image_info *spl_image, struct spl_boot_device *bootdev) {int err; -struct image_header *header; +struct legacy_img_hdr *header; int *src __attribute__((unused)); int *dst __attribute__((unused));
common/spl/spl_net.c +1 -1
@@ -28,7 +28,7 @@ static ulong spl_net_load_read(struct spl_load_info *load, ulong sector,static int spl_net_load_image (struct spl_image_info *spl_image,struct spl_boot_device *bootdev) { -struct image_header *header = (struct image_header *)image_load_addr; +struct legacy_img_hdr *header = (struct legacy_img_hdr *)image_load_addr;int rv;env_init ();
common/spl/spl_nor.c +4 -4
@@ -26,7 +26,7 @@ unsigned long __weak spl_nor_get_uboot_base(void)static int spl_nor_load_image (struct spl_image_info *spl_image,struct spl_boot_device *bootdev) { -__maybe_unused const struct image_header *header; +__maybe_unused const struct legacy_img_hdr *header;__maybe_unused struct spl_load_info load;/*
@@ -41,7 +41,7 @@ static int spl_nor_load_image(struct spl_image_info *spl_image,* Load Linux from its location in NOR flash to its defined * location in SDRAM */ - header = (const struct image_header *)CONFIG_SYS_OS_BASE ; + header = (const struct legacy_img_hdr *)CONFIG_SYS_OS_BASE ;#ifdef CONFIG_SPL_LOAD_FIT if (image_get_magic (header) ==FDT_MAGIC ) {int ret;
@@ -72,7 +72,7 @@ static int spl_nor_load_image(struct spl_image_info *spl_image,memcpy ((void *)spl_image->load_addr, (void *)(CONFIG_SYS_OS_BASE + -sizeof (struct image_header )), +sizeof (struct legacy_img_hdr )), spl_image->size);#ifdef CONFIG_SYS_SPL_ARGS_ADDR spl_image->arg = (void *)CONFIG_SYS_SPL_ARGS_ADDR ;
@@ -92,7 +92,7 @@ static int spl_nor_load_image(struct spl_image_info *spl_image,* defined location in SDRAM */ #ifdef CONFIG_SPL_LOAD_FIT - header = (const struct image_header *)spl_nor_get_uboot_base (); + header = (const struct legacy_img_hdr *)spl_nor_get_uboot_base ();if (image_get_magic (header) ==FDT_MAGIC ) {debug ("Found FIT format U-Boot\n" ); load.bl_len =1 ;
common/spl/spl_onenand.c +1 -1
@@ -18,7 +18,7 @@static int spl_onenand_load_image (struct spl_image_info *spl_image,struct spl_boot_device *bootdev) { -struct image_header *header; +struct legacy_img_hdr *header;int ret;debug ("spl: onenand\n" );
common/spl/spl_ram.c +4 -4
@@ -41,9 +41,9 @@ static ulong spl_ram_load_read(struct spl_load_info *load, ulong sector,static int spl_ram_load_image (struct spl_image_info *spl_image,struct spl_boot_device *bootdev) { -struct image_header *header; +struct legacy_img_hdr *header; - header = (struct image_header *)CONFIG_SPL_LOAD_FIT_ADDRESS ; + header = (struct legacy_img_hdr *)CONFIG_SPL_LOAD_FIT_ADDRESS ;if (CONFIG_IS_ENABLED (IMAGE_PRE_LOAD )) {unsigned long addr = (unsigned long )header;
@@ -53,7 +53,7 @@ static int spl_ram_load_image(struct spl_image_info *spl_image,return ret; addr += image_load_offset; - header = (struct image_header *)addr; + header = (struct legacy_img_hdr *)addr; }#if CONFIG_IS_ENABLED (DFU )
@@ -87,7 +87,7 @@ static int spl_ram_load_image(struct spl_image_info *spl_image, u_boot_pos = (ulong )spl_get_load_buffer (-sizeof (*header),sizeof (*header)); } - header = (struct image_header *)map_sysmem (u_boot_pos,0 ); + header = (struct legacy_img_hdr *)map_sysmem (u_boot_pos,0 );spl_parse_image_header (spl_image, bootdev, header); }
common/spl/spl_sata.c +1 -1
@@ -30,7 +30,7 @@ static int spl_sata_load_image_raw(struct spl_image_info *spl_image,struct spl_boot_device *bootdev, struct blk_desc *stor_dev, unsigned long sector) { - struct image_header *header; + struct legacy_img_hdr *header;unsigned long count;u32 image_size_sectors;u32 image_offset_sectors;
common/spl/spl_semihosting.c +2 -2
@@ -27,7 +27,7 @@ static int spl_smh_load_image(struct spl_image_info *spl_image,const char *filename =CONFIG_SPL_FS_LOAD_PAYLOAD_NAME ;int ret;long fd, len; -struct image_header *header = +struct legacy_img_hdr *header =spl_get_load_buffer (-sizeof (*header),sizeof (*header)); fd =smh_open (filename,MODE_READ |MODE_BINARY );
@@ -43,7 +43,7 @@ static int spl_smh_load_image(struct spl_image_info *spl_image, } len = ret; - ret =smh_read_full (fd, header,sizeof (struct image_header )); + ret =smh_read_full (fd, header,sizeof (struct legacy_img_hdr ));if (ret) {log_debug ("could not read image header: %d\n" , ret); goto out;
common/spl/spl_spi.c +3 -3
@@ -26,7 +26,7 @@static int spi_load_image_os (struct spl_image_info *spl_image,struct spl_boot_device *bootdev,struct spi_flash *flash, -struct image_header *header) +struct legacy_img_hdr *header) {int err;
@@ -92,7 +92,7 @@ static int spl_spi_load_image(struct spl_image_info *spl_image,int err =0 ;unsigned int payload_offs;struct spi_flash *flash; -struct image_header *header; +struct legacy_img_hdr *header;unsigned int sf_bus =spl_spi_boot_bus ();unsigned int sf_cs =spl_spi_boot_cs ();
@@ -139,7 +139,7 @@ static int spl_spi_load_image(struct spl_image_info *spl_image,if (err)return err; err =spl_parse_image_header (spl_image, bootdev, - (struct image_header *)CONFIG_SYS_LOAD_ADDR ); + (struct legacy_img_hdr *)CONFIG_SYS_LOAD_ADDR ); }else if (IS_ENABLED (CONFIG_SPL_LOAD_FIT ) &&image_get_magic (header) ==FDT_MAGIC ) {struct spl_load_info load;
common/spl/spl_ubi.c +2 -2
@@ -15,7 +15,7 @@int spl_ubi_load_image (struct spl_image_info *spl_image,struct spl_boot_device *bootdev) { -struct image_header *header; +struct legacy_img_hdr *header;struct ubispl_info info;struct ubispl_load volumes[2 ];int ret =1 ;
@@ -54,7 +54,7 @@ int spl_ubi_load_image(struct spl_image_info *spl_image, ret =ubispl_load_volumes (&info, volumes,2 );if (!ret) { - header = (struct image_header *)volumes[0 ].load_addr; + header = (struct legacy_img_hdr *)volumes[0 ].load_addr;spl_parse_image_header (spl_image, bootdev, header);puts ("Linux loaded.\n" ); goto out;
common/spl/spl_xip.c +1 -1
@@ -25,6 +25,6 @@ static int spl_xip(struct spl_image_info *spl_image, }#endif return (spl_parse_image_header (spl_image, bootdev, - (const struct image_header *)CONFIG_SYS_UBOOT_BASE )); + (const struct legacy_img_hdr *)CONFIG_SYS_UBOOT_BASE )); }SPL_LOAD_IMAGE_METHOD ("XIP" ,0 ,BOOT_DEVICE_XIP , spl_xip);
common/spl/spl_ymodem.c +7 -7
@@ -96,7 +96,7 @@ int spl_ymodem_load_image(struct spl_image_info *spl_image,int ret;connection_info_t info;char buf[BUF_SIZE ]; -struct image_header *ih =NULL ; +struct legacy_img_hdr *ih =NULL ;ulong addr =0 ; info.mode = xyzModem_ymodem;
@@ -111,9 +111,9 @@ int spl_ymodem_load_image(struct spl_image_info *spl_image, goto end_stream;if (IS_ENABLED (CONFIG_SPL_LOAD_FIT_FULL ) && -image_get_magic ((struct image_header *)buf) ==FDT_MAGIC ) { +image_get_magic ((struct legacy_img_hdr *)buf) ==FDT_MAGIC ) { addr =CONFIG_SYS_LOAD_ADDR ; - ih = (struct image_header *)addr; + ih = (struct legacy_img_hdr *)addr;memcpy ((void *)addr, buf, res); size += res;
@@ -129,7 +129,7 @@ int spl_ymodem_load_image(struct spl_image_info *spl_image,if (ret)return ret; }else if (IS_ENABLED (CONFIG_SPL_LOAD_FIT ) && -image_get_magic ((struct image_header *)buf) ==FDT_MAGIC ) { +image_get_magic ((struct legacy_img_hdr *)buf) ==FDT_MAGIC ) {struct spl_load_info load;struct ymodem_fit_info info;
@@ -147,7 +147,7 @@ int spl_ymodem_load_image(struct spl_image_info *spl_image,while ((res =xyzModem_stream_read (buf,BUF_SIZE , &err)) >0 ) size += res; }else { - ih = (struct image_header *)buf; + ih = (struct legacy_img_hdr *)buf; ret =spl_parse_image_header (spl_image, bootdev, ih);if (ret) goto end_stream;
@@ -158,7 +158,7 @@ int spl_ymodem_load_image(struct spl_image_info *spl_image,#endif addr = spl_image->load_addr;memcpy ((void *)addr, buf, res); - ih = (struct image_header *)addr; + ih = (struct legacy_img_hdr *)addr; size += res; addr += res;
@@ -177,7 +177,7 @@ end_stream:#ifdef CONFIG_SPL_GZIP if (!(IS_ENABLED (CONFIG_SPL_LOAD_FIT ) && -image_get_magic ((struct image_header *)buf) ==FDT_MAGIC ) && +image_get_magic ((struct legacy_img_hdr *)buf) ==FDT_MAGIC ) && (ih->ih_comp ==IH_COMP_GZIP )) { if (gunzip((void *)(spl_image->load_addr + sizeof(*ih)), CONFIG_SYS_BOOTM_LEN,
common/splash_source.c +3 -3
@@ -327,17 +327,17 @@ static int splash_load_fit(struct splash_location *location, u32 bmp_load_addr)int external_splash_addr;int external_splash_size;bool is_splash_external = false; -struct image_header *img_header; +struct legacy_img_hdr *img_header;const u32 *fit_header;u32 fit_size; -const size_t header_size =sizeof (struct image_header ); +const size_t header_size =sizeof (struct legacy_img_hdr );/* Read in image header */ res =splash_storage_read_raw (location, bmp_load_addr, header_size);if (res <0 )return res; - img_header = (struct image_header *)bmp_load_addr; + img_header = (struct legacy_img_hdr *)bmp_load_addr;if (image_get_magic (img_header) !=FDT_MAGIC ) {printf ("Could not find FDT magic\n" );return -EINVAL ;
doc/uImage.FIT/source_file_format.txt +1 -1
@@ -23,7 +23,7 @@ in the system memory and passed to bootm as a arguments. Some of them may be missing: FDT is not present for legacy platforms, ramdisk is always optional. Additionally, old uImage format has been extended to support multi sub-images but the support is limited by simple format of the legacy uImage structure. -Single binary header 'struct image_header' is not flexible enough to cover all +Single binary header 'struct legacy_img_hdr' is not flexible enough to cover all possible scenarios. All those factors combined clearly show that there is a need for new, more
drivers/fpga/socfpga_arria10.c +2 -2
@@ -555,14 +555,14 @@ static int first_loading_rbf_to_buffer(struct udevice *dev,/* Load image header into buffer */ ret =request_firmware_into_buf (dev, fpga_loadfs->fpga_fsinfo->filename, - buffer_p,sizeof (struct image_header ), + buffer_p,sizeof (struct legacy_img_hdr ),0 );if (ret <0 ) {debug ("FPGA: Failed to read image header from flash.\n" );return -ENOENT ; } -if (image_get_magic ((struct image_header *)buffer_p) !=FDT_MAGIC ) { +if (image_get_magic ((struct legacy_img_hdr *)buffer_p) !=FDT_MAGIC ) {debug ("FPGA: No FDT magic was found.\n" );return -EBADF ; }
drivers/usb/gadget/f_sdp.c +1 -1
@@ -835,7 +835,7 @@ static int sdp_handle_in_ep(struct spl_image_info *spl_image,printf ("Found header at 0x%08x\n" , sdp_func->jmp_address); -image_header_t *header = +struct legacy_img_hdr *header =sdp_ptr (sdp_func->jmp_address);#ifdef CONFIG_SPL_LOAD_FIT if (image_get_magic (header) ==FDT_MAGIC ) {
include/configs/uniphier.h +1 -1
@@ -169,7 +169,7 @@/* only for SPL */ -/* subtract sizeof(struct image_header) */ +/* subtract sizeof(struct legacy_img_hdr) */ #define CONFIG_SYS_UBOOT_BASE (0x130000 - 0x40)#endif /* __CONFIG_UNIPHIER_H__ */
include/image.h +28 -24
156 lines not on this page · raw message
include/spl.h +4 -4
@@ -17,7 +17,7 @@#include <mmc.h> struct blk_desc ; -struct image_header ; +struct legacy_img_hdr ;/* Value in r0 indicates we booted from U-Boot */ #define UBOOT_NOT_LOADED_FROM_SPL 0x13578642
@@ -29,7 +29,7 @@ struct image_header;#define MMCSD_MODE_EMMCBOOT 3struct blk_desc ; -struct image_header ; +struct legacy_img_hdr ;struct spl_boot_device ;/*
@@ -476,7 +476,7 @@ void spl_set_header_raw_uboot(struct spl_image_info *spl_image);*/ int spl_parse_image_header (struct spl_image_info *spl_image,const struct spl_boot_device *bootdev, -const struct image_header *header); +const struct legacy_img_hdr *header);void spl_board_prepare_for_linux (void );
@@ -865,7 +865,7 @@ void spl_perform_fixups(struct spl_image_info *spl_image);* Returns memory area which can be populated by partial image data, * ie. uImage or fitImage header. */ -struct image_header *spl_get_load_buffer (ssize_t offset,size_t size); +struct legacy_img_hdr *spl_get_load_buffer (ssize_t offset,size_t size);void spl_save_restore_data (void );#endif
include/tee/optee.h +2 -2
@@ -30,7 +30,7 @@ struct optee_header { };static inline uint32_t -optee_image_get_entry_point (const struct image_header *hdr) +optee_image_get_entry_point (const struct legacy_img_hdr *hdr) {struct optee_header *optee_hdr = (struct optee_header *)(hdr +1 );
@@ -38,7 +38,7 @@ optee_image_get_entry_point(const struct image_header *hdr) }static inline uint32_t -optee_image_get_load_addr (const struct image_header *hdr) +optee_image_get_load_addr (const struct legacy_img_hdr *hdr) {return optee_image_get_entry_point (hdr) -sizeof (struct optee_header ); }
test/image/spl_load.c +2 -2
@@ -49,7 +49,7 @@ int board_fit_config_name_match(const char *name)return 0 ; } -struct image_header *spl_get_load_buffer (ssize_t offset,size_t size) +struct legacy_img_hdr *spl_get_load_buffer (ssize_t offset,size_t size) {return map_sysmem (0x100000 ,0 ); }
@@ -57,7 +57,7 @@ struct image_header *spl_get_load_buffer(ssize_t offset, size_t size)static int spl_test_load (struct unit_test_state *uts) {struct spl_image_info image; -struct image_header *header; +struct legacy_img_hdr *header;struct text_ctx text_ctx;struct spl_load_info load;char fname[256 ];
tools/binman/ftest.py +2 -2
@@ -5761,7 +5761,7 @@ fdt fdtmap Extract the devicetree blob from the fdtmap # Check that the data appears in the file somewhere self.assertIn(U_BOOT_SPL_DATA, data) - # Get struct image_header -> ih_name + # Get struct legacy_img_hdr -> ih_name name = data[0x20:0x40] # Build the filename that we expect to be placed in there, by virtue of
@@ -5778,7 +5778,7 @@ fdt fdtmap Extract the devicetree blob from the fdtmap # Check that the data appears in the file somewhere self.assertIn(U_BOOT_SPL_DATA, data) - # Get struct image_header -> ih_name + # Get struct legacy_img_hdr -> ih_name name = data[0x20:0x40] # Build the filename that we expect to be placed in there, by virtue of
tools/default_image.c +15 -16
@@ -22,7 +22,7 @@#include <u-boot/crc.h> #include <imximage.h> -static image_header_t header; +static struct legacy_img_hdr header;static int image_check_image_types (uint8_t type) {
@@ -46,15 +46,15 @@ static int image_verify_header(unsigned char *ptr, int image_size,uint32_t len;const unsigned char *data;uint32_t checksum; -image_header_t header; -image_header_t *hdr = &header; +struct legacy_img_hdr header; +struct legacy_img_hdr *hdr = &header;/* * create copy of header so that we can blank out the * checksum field for checking - this can't be done * on the PROT_READ mapped data. */ -memcpy (hdr, ptr,sizeof (image_header_t)); +memcpy (hdr, ptr,sizeof (struct legacy_img_hdr ));if (be32_to_cpu (hdr->ih_magic) !=IH_MAGIC ) { debug("%s: Bad Magic Number: \"%s\" is no valid image\n",
@@ -63,7 +63,7 @@ static int image_verify_header(unsigned char *ptr, int image_size, } data = (const unsigned char *)hdr; - len =sizeof (image_header_t); + len =sizeof (struct legacy_img_hdr ); checksum =be32_to_cpu (hdr->ih_hcrc); hdr->ih_hcrc =cpu_to_be32 (0 );/* clear for re-calculation */
@@ -74,8 +74,8 @@ static int image_verify_header(unsigned char *ptr, int image_size,return -FDT_ERR_BADSTATE ; } - data = (const unsigned char *)ptr +sizeof (image_header_t); - len = image_size -sizeof (image_header_t) ; + data = (const unsigned char *)ptr +sizeof (struct legacy_img_hdr ); + len = image_size -sizeof (struct legacy_img_hdr ); checksum =be32_to_cpu (hdr->ih_dcrc);if (crc32 (0 , data, len) != checksum) {
@@ -94,13 +94,12 @@ static void image_set_header(void *ptr, struct stat *sbuf, int ifd,uint32_t imagesize;uint32_t ep;uint32_t addr; - -image_header_t * hdr = (image_header_t *)ptr; +struct legacy_img_hdr *hdr = (struct legacy_img_hdr *)ptr; checksum =crc32 (0 , (const unsigned char *)(ptr + -sizeof (image_header_t)), - sbuf->st_size -sizeof (image_header_t)); +sizeof (struct legacy_img_hdr )), + sbuf->st_size -sizeof (struct legacy_img_hdr )); time =imagetool_get_source_date (params->cmdname, sbuf->st_mtime); ep = params->ep;
@@ -108,11 +107,11 @@ static void image_set_header(void *ptr, struct stat *sbuf, int ifd,if (params->type ==IH_TYPE_FIRMWARE_IVT )/* Add size of CSF minus IVT */ - imagesize = sbuf->st_size -sizeof (image_header_t) + imagesize = sbuf->st_size -sizeof (struct legacy_img_hdr ) +0x2060 -sizeof (flash_header_v2_t);else - imagesize = sbuf->st_size -sizeof (image_header_t); + imagesize = sbuf->st_size -sizeof (struct legacy_img_hdr );if (params->os ==IH_OS_TEE ) { addr =optee_image_get_load_addr (hdr);
@@ -134,14 +133,14 @@ static void image_set_header(void *ptr, struct stat *sbuf, int ifd,image_set_name (hdr, params->imagename); checksum =crc32 (0 , (const unsigned char *)hdr, -sizeof (image_header_t)); +sizeof (struct legacy_img_hdr ));image_set_hcrc (hdr, checksum); }static int image_extract_subimage (void *ptr,struct image_tool_params *params) { -const image_header_t *hdr = (const image_header_t *)ptr; +const struct legacy_img_hdr *hdr = (const struct legacy_img_hdr *)ptr;ulong file_data;ulong file_len;
@@ -175,7 +174,7 @@ static int image_extract_subimage(void *ptr, struct image_tool_params *params) U_BOOT_IMAGE_TYPE( defimage, "Default Image support", - sizeof(image_header_t), + sizeof(struct legacy_img_hdr), (void *)&header, image_check_params, image_verify_header,
tools/fit_image.c +2 -2
@@ -22,7 +22,7 @@#include <version.h> #include <u-boot/crc.h> -static image_header_t header; +static struct legacy_img_hdr header;static int fit_add_file_data (struct image_tool_params *params,size_t size_inc,const char *tmpfile)
@@ -915,7 +915,7 @@ static int fit_check_params(struct image_tool_params *params) U_BOOT_IMAGE_TYPE( fitimage, "FIT Image support", - sizeof(image_header_t), + sizeof(struct legacy_img_hdr), (void *)&header, fit_check_params, fit_verify_header,
tools/imx8mimage.c +4 -4
@@ -318,7 +318,7 @@ err_mmap:static int generate_ivt_for_fit (int fd,int fit_offset,uint32_t ep,uint32_t *fit_load_addr) { -image_header_t image_header; +struct legacy_img_hdr image_header;int ret;uint32_t fit_size, load_addr;
@@ -330,8 +330,8 @@ static int generate_ivt_for_fit(int fd, int fit_offset, uint32_t ep,exit (EXIT_FAILURE ); } -if (read (fd, (char *)&image_header,sizeof (image_header_t)) != -sizeof (image_header_t)) { +if (read (fd, (char *)&image_header,sizeof (struct legacy_img_hdr )) != +sizeof (struct legacy_img_hdr )) {fprintf (stderr,"generate_ivt_for_fit read failed: %s\n" ,strerror (errno));exit (EXIT_FAILURE );
@@ -600,7 +600,7 @@ void build_image(int ofd)close (sld_fd); file_off = sld_header_off; - file_off += sbuf.st_size +sizeof (image_header_t); + file_off += sbuf.st_size +sizeof (struct legacy_img_hdr ); } }
tools/mkimage.c +1 -1
@@ -845,7 +845,7 @@ copy_file (int ifd, const char *datafile, int pad)if (params.xflag) {unsigned char *p =NULL ;/* -* XIP: do not append the image_header_t at the +* XIP: do not append the struct legacy_img_hdr at the * beginning of the file, but consume the space * reserved for it. */
tools/mtk_image.c +5 -5
@@ -647,10 +647,10 @@ static uint32_t crc32be_cal(const void *data, size_t length)static int mtk_image_verify_mt7621_header (const uint8_t *ptr,int print) { -const image_header_t *hdr = (const image_header_t *)ptr; +const struct legacy_img_hdr *hdr = (const struct legacy_img_hdr *)ptr;struct mt7621_nand_header *nhdr;uint32_t spl_size, crcval; -image_header_t header; +struct legacy_img_hdr header;int ret; spl_size =image_get_size (hdr);
@@ -710,7 +710,7 @@ static int mtk_image_verify_mt7621_header(const uint8_t *ptr, int print)static int mtk_image_verify_header (unsigned char *ptr,int image_size,struct image_tool_params *params) { -image_header_t *hdr = (image_header_t *)ptr; +struct legacy_img_hdr *hdr = (struct legacy_img_hdr *)ptr;union lk_hdr *lk = (union lk_hdr *)ptr;/* nothing to verify for LK image header */
@@ -732,7 +732,7 @@ static int mtk_image_verify_header(unsigned char *ptr, int image_size,static void mtk_image_print_header (const void *ptr) { -image_header_t *hdr = (image_header_t *)ptr; +struct legacy_img_hdr *hdr = (struct legacy_img_hdr *)ptr;union lk_hdr *lk = (union lk_hdr *)ptr;if (le32_to_cpu (lk->magic) ==LK_PART_MAGIC ) {
@@ -914,7 +914,7 @@ static void mtk_image_set_nand_header(void *ptr, off_t filesize,static void mtk_image_set_mt7621_header (void *ptr,off_t filesize,uint32_t loadaddr) { -image_header_t *hdr = (image_header_t *)ptr; +struct legacy_img_hdr *hdr = (struct legacy_img_hdr *)ptr;struct mt7621_stage1_header *shdr;struct mt7621_nand_header *nhdr;uint32_t datasize, crcval;
Signature · 1 line
2.37.2.672.g94769d06f0-goog
PATCH 5/21 event: Fix a typo in the EVENT help
In reply to Simon GlassFix the help message.
---
common/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
common/Kconfig +1 -1
@@ -551,7 +551,7 @@ config EVENT help This enables sending and processing of events, to allow interested parties to be alerted when something happens. This is an attempt to - step the flow of weak functions, hooks, functions in board_f.c + stem the flow of weak functions, hooks, functions in board_f.c and board_r.c and the Kconfig options below. See doc/develop/event.rst for more information.
Signature · 1 line
2.37.2.672.g94769d06f0-goog
PATCH 6/21 dm: core: Pass a root node to of_find_node_by_phandle()
In reply to Simon GlassThis function currently assumes that the control FDT is used. Update it to allow a root node to be passed, so it can work with any tree.
Also add a comment to ofnode_get_by_phandle() so that its purpose is clear.
---
drivers/core/of_access.c | 7 ++++--- drivers/core/ofnode.c | 2 +- include/dm/of_access.h | 4 +++- include/dm/ofnode.h | 2 ++ 4 files changed, 10 insertions(+), 5 deletions(-)
drivers/core/of_access.c +4 -3
@@ -445,14 +445,15 @@ struct device_node *of_find_node_by_prop_value(struct device_node *from,return np; } -struct device_node *of_find_node_by_phandle (phandle handle) +struct device_node *of_find_node_by_phandle (struct device_node *root, +phandle handle) {struct device_node *np;if (!handle)return NULL ; -for_each_of_allnodes (np) +for_each_of_allnodes_from (root, np)if (np->phandle == handle)break ; (void )of_node_get (np);
@@ -659,7 +660,7 @@ static int __of_parse_phandle_with_args(const struct device_node *np,* below. */ if (cells_name || cur_index == index) { - node =of_find_node_by_phandle (phandle); + node =of_find_node_by_phandle (NULL , phandle);if (!node) {debug ("%s: could not find phandle\n" , np->full_name);
drivers/core/ofnode.c +1 -1
@@ -329,7 +329,7 @@ ofnode ofnode_get_by_phandle(uint phandle)ofnode node;if (of_live_active ()) - node =np_to_ofnode (of_find_node_by_phandle (phandle)); + node =np_to_ofnode (of_find_node_by_phandle (NULL , phandle));else node.of_offset =fdt_node_offset_by_phandle (gd->fdt_blob, phandle);
include/dm/of_access.h +3 -1
@@ -258,11 +258,13 @@ struct device_node *of_find_node_by_prop_value(struct device_node *from,/** * of_find_node_by_phandle() - Find a node given a phandle * +* @root: root node to start from (NULL for default device tree) * @handle: phandle of the node to find * * Return: node pointer, or NULL if not found */ -struct device_node *of_find_node_by_phandle (phandle handle); +struct device_node *of_find_node_by_phandle (struct device_node *root, +phandle handle);/** * of_read_u32() - Find and read a 32-bit integer from a property
include/dm/ofnode.h +2 -0
@@ -461,6 +461,8 @@ int ofnode_get_path(ofnode node, char *buf, int buflen);/** * ofnode_get_by_phandle() - get ofnode from phandle * +* This uses the default (control) device tree +* * @phandle: phandle to look up * Return: ofnode reference to the phandle */
Signature · 1 line
2.37.2.672.g94769d06f0-goog
PATCH 7/21 event: Pass the images to EVT_FT_FIXUP
In reply to Simon GlassPass the boot images along as well, in case the fixups need to look at them.
---
boot/image-fdt.c | 1 + include/event.h | 2 ++ 2 files changed, 3 insertions(+)
boot/image-fdt.c +1 -0
@@ -669,6 +669,7 @@ int image_setup_libfdt(struct bootm_headers *images, void *blob,struct event_ft_fixup fixup; fixup.tree =oftree_default (); + fixup.images = images; ret =event_notify (EVT_FT_FIXUP , &fixup,sizeof (fixup));if (ret) {printf ("ERROR: fdt fixup event failed: %d\n" , ret);
include/event.h +2 -0
@@ -60,9 +60,11 @@ union event_data {* struct event_ft_fixup - FDT fixup before booting * * @tree: tree to update +* @images: images which are being booted */ struct event_ft_fixup {oftree tree; +struct bootm_headers *images; } ft_fixup; };
Signature · 1 line
2.37.2.672.g94769d06f0-goog
PATCH 8/21 dm: core: Allow adding ofnode subnodes
In reply to Simon GlassAdd this feature to the ofnode interface, supporting both livetree and flattree.
---
drivers/core/of_access.c | 50 ++++++++++++++++++++++++++++++++++++++++ drivers/core/ofnode.c | 30 ++++++++++++++++++++++++ include/dm/of_access.h | 12 ++++++++++ include/dm/ofnode.h | 12 ++++++++++ test/dm/ofnode.c | 17 ++++++++++++++ 5 files changed, 121 insertions(+)
drivers/core/of_access.c +50 -0
@@ -931,3 +931,53 @@ int of_write_prop(struct device_node *np, const char *propname, int len,return 0 ; } + +int of_add_subnode (struct device_node *parent,const char *name,int len, +struct device_node **childp) +{ +struct device_node *child, *new, *last_sibling =NULL ; +char *new_name, *full_name; +int parent_fnl; + +__for_each_child_of_node (parent, child) { +if (!strncmp (child->name, name, len) &&strlen (name) == len) +return -EEXIST ; + last_sibling = child; + } + +/* Property does not exist -> append new property */ + new =calloc (1 ,sizeof (struct device_node )); +if (!new) +return -ENOMEM ; + + new_name =malloc (len +1 ); +if (!name) { +free (new); +return -ENOMEM ; + } +strlcpy (new_name, name, len +1 ); + new->name = new_name; + + parent_fnl = parent->name ?strlen (parent->full_name) :0 ; + full_name =calloc (1 , parent_fnl +1 + len +1 ); +if (!full_name) { +free (new_name); +free (new); +return -ENOMEM ; + } +strcpy (full_name, parent->full_name); + full_name[parent_fnl] ='/' ; +strlcpy (&full_name[parent_fnl +1 ], name, len +1 ); + new->full_name = full_name; + +/* Add as last sibling of the parent */ +if (last_sibling) + last_sibling->sibling = new; +if (!parent->child) + parent->child = new; + new->parent = parent; + + *childp = new; + +return 0 ; +}
drivers/core/ofnode.c +30 -0
@@ -1227,3 +1227,33 @@ phy_interface_t ofnode_read_phy_mode(ofnode node)return PHY_INTERFACE_MODE_NA ; } + +int ofnode_add_subnode (ofnode node,const char *name,ofnode *subnodep) +{ +ofnode subnode; +int ret; + +assert (ofnode_valid (node)); + +if (ofnode_is_np (node)) { +struct device_node *np, *child; + + np = (struct device_node *)ofnode_to_np (node); + ret =of_add_subnode (np, name,strlen (name), &child); +if (ret) +return ret; + subnode =np_to_ofnode (child); + }else { +int offset; + + offset =fdt_add_subnode ((void *)gd->fdt_blob, +ofnode_to_offset (node), name); +if (offset <0 ) +return offset == -FDT_ERR_EXISTS ? -EEXIST :0 ; + subnode =offset_to_ofnode (offset); + } + + *subnodep = subnode; + +return 0 ; +}
include/dm/of_access.h +12 -0
@@ -533,4 +533,16 @@ struct device_node *of_get_stdout(void);int of_write_prop (struct device_node *np,const char *propname,int len,const void *value); +/** +* of_add_subnode() - add a new subnode to a node +* +* @node: parent node to add to +* @name: name of subnode +* @len: length of name +* @subnodep: returns pointer to new subnode +* Returns 0 if OK, -ve on error +*/ +int of_add_subnode (struct device_node *node,const char *name,int len, +struct device_node **subnodep); +#endif
include/dm/ofnode.h +12 -0
@@ -1260,6 +1260,18 @@ static inline const char *ofnode_conf_read_str(const char *prop_name) {return NULL ; } +#endif /* CONFIG_DM */ +/** +* of_add_subnode() - add a new subnode to a node +* +* @parent: parent node to add to +* @name: name of subnode +* @nodep: returns pointer to new subnode +* Returns 0 if OK, -EEXIST if already exists, -ENOMEM if out of memory, other +* -ve on other error +*/ +int ofnode_add_subnode (ofnode parent,const char *name,ofnode *nodep); +#endif
test/dm/ofnode.c +17 -0
@@ -601,3 +601,20 @@ static int dm_test_ofnode_u32(struct unit_test_state *uts) }DM_TEST (dm_test_ofnode_u32,UT_TESTF_SCAN_PDATA |UT_TESTF_SCAN_FDT |UT_TESTF_LIVE_OR_FLAT ); + +static int dm_test_ofnode_add_subnode (struct unit_test_state *uts) +{ +ofnode node, check, subnode; + + node =ofnode_path ("/lcd" ); +ut_assert (ofnode_valid (node)); +ut_assertok (ofnode_add_subnode (node,"edmund" , &subnode)); + check =ofnode_path ("/lcd/edmund" ); +ut_asserteq (check.of_offset, subnode.of_offset); + +ut_asserteq (-EEXIST ,ofnode_add_subnode (node,"edmund" , &subnode)); + +return 0 ; +} +DM_TEST (dm_test_ofnode_add_subnode, +UT_TESTF_SCAN_PDATA |UT_TESTF_SCAN_FDT |UT_TESTF_LIVE_OR_FLAT );
Signature · 1 line
2.37.2.672.g94769d06f0-goog
Re: [PATCH 08/21] dm: core: Allow adding ofnode subnodes
Quoted 21 lines · Simon Glass
Add this feature to the ofnode interface, supporting both livetree and flattree.
Signed-off-by Simon Glass <[email protected]>---
drivers/core/of_access.c | 50 ++++++++++++++++++++++++++++++++++++++++ drivers/core/ofnode.c | 30 ++++++++++++++++++++++++ include/dm/of_access.h | 12 ++++++++++ include/dm/ofnode.h | 12 ++++++++++ test/dm/ofnode.c | 17 ++++++++++++++ 5 files changed, 121 insertions(+)drivers/core/of_access.c +0
-0@@ -931,3 +931,53 @@ int of_write_prop(struct device_node *np, const char *propname, int len,return 0 ; }
drivers/core/of_access.c int of_write_prop(struct device_node *np, const char *propname, int len, · line 943
Quoted 10 lines
drivers/core/of_access.c +10
-0+ +int of_add_subnode (struct device_node *parent,const char *name,int len, +struct device_node **childp) +{ +struct device_node *child, *new, *last_sibling =NULL ; +char *new_name, *full_name; +int parent_fnl; + +__for_each_child_of_node (parent, child) { +if (!strncmp (child->name, name, len) &&strlen (name) == len)
I'm confused. The documentation comment further down says that len is the length of name. So why this check? And further, the only caller (at least introduced here, haven't been through the whole series) indeed passes strlen(name).
So why is that even a parameter? Can't of_add_subnode() just do len=strlen(name) itself? And then of course the strlen(name)==len condition goes away, and the strncmp() can just be spelled strcmp() - which also looks much more natural when asking "does such a child node already exist".
drivers/core/of_access.c int of_write_prop(struct device_node *np, const char *propname, int len, · line 944
Quoted 1 line
drivers/core/of_access.c +1
-0+return -EEXIST ;
It seems natural to provide the existing node in *childp when -EEXIST. Callers that want to error out on -EEXIST can just do that and ignore that value, but callers that just wants to ensure there is a subnode with the given name can avoid doing a find_subnode() upfront, which should make much code much more compact.
drivers/core/of_access.c int of_write_prop(struct device_node *np, const char *propname, int len, · line 948
Quoted 4 lines
drivers/core/of_access.c +4
-0+ last_sibling = child; + } + +/* Property does not exist -> append new property */
s/property/[sub]node/, or just delete the comment, it's obvious.
drivers/core/of_access.c int of_write_prop(struct device_node *np, const char *propname, int len, · line 954
Quoted 6 lines
drivers/core/of_access.c +6
-0+ new =calloc (1 ,sizeof (struct device_node )); +if (!new) +return -ENOMEM ; + + new_name =malloc (len +1 ); +if (!name) {
That's not the variable you want to test...
drivers/core/of_access.c int of_write_prop(struct device_node *np, const char *propname, int len, · line 959
Quoted 5 lines
drivers/core/of_access.c +5
-0+free (new); +return -ENOMEM ; + } +strlcpy (new_name, name, len +1 ); + new->name = new_name;
new->name = memdup(name, len+1);
if (!new->name) {...}
is a bit shorter.
drivers/core/of_access.c int of_write_prop(struct device_node *np, const char *propname, int len, · line 968
Quoted 8 lines
drivers/core/of_access.c +8
-0+ parent_fnl = parent->name ?strlen (parent->full_name) :0 ; + full_name =calloc (1 , parent_fnl +1 + len +1 ); +if (!full_name) { +free (new_name); +free (new); +return -ENOMEM ; + } +strcpy (full_name, parent->full_name);
Confused. Above, we use parent->name as a condition for whether parent->full_name exists (or at least whether we should compute its strlen). Here we unconditionally access parent->full_name. I don't know the rules for the root node, but I can kind of guess that it has ->name NULL and ->full_name set to "". Perhaps that could be clarified in the documentation for struct device_node?
And if I'm right, that means there's no point asking if parent->name is NULL or not; strlen(parent->full_name) gives the right answer regardless.
Rasmus
PATCH 9/21 dm: core: Support writing a property to an empty node
In reply to Simon GlassAt present this does not work with livetree. Fix it and add a test.
---
drivers/core/of_access.c | 8 ++++---- test/dm/ofnode.c | 3 +++ 2 files changed, 7 insertions(+), 4 deletions(-)
drivers/core/of_access.c +4 -4
@@ -909,9 +909,6 @@ int of_write_prop(struct device_node *np, const char *propname, int len, pp_last = pp; } -if (!pp_last) -return -ENOENT ; -/* Property does not exist -> append new property */ new =malloc (sizeof (struct property ));if (!new)
@@ -927,7 +924,10 @@ int of_write_prop(struct device_node *np, const char *propname, int len, new->length = len; new->next =NULL ; - pp_last->next = new; +if (pp_last) + pp_last->next = new; +else + np->properties = new;return 0 ; }
test/dm/ofnode.c +3 -0
@@ -612,6 +612,9 @@ static int dm_test_ofnode_add_subnode(struct unit_test_state *uts) check =ofnode_path ("/lcd/edmund" );ut_asserteq (check.of_offset, subnode.of_offset); +/* write to the empty node */ +ut_assertok (ofnode_write_string (subnode,"compatible" ,"sandbox,usb" )); +ut_asserteq (-EEXIST ,ofnode_add_subnode (node,"edmund" , &subnode));return 0 ;
Signature · 1 line
2.37.2.672.g94769d06f0-goog
PATCH 10/21 dm: core: Drop the const from ofnode
In reply to Simon GlassNow that we support writing to ofnodes, the const is not accurate. Drop it to avoid undesirable casting.
---
drivers/core/ofnode.c | 2 +- include/dm/ofnode.h | 4 ++-- include/dm/ofnode_decl.h | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-)
drivers/core/ofnode.c +1 -1
@@ -206,7 +206,7 @@ ofnode ofnode_find_subnode(ofnode node, const char *subnode_name)debug ("%s: %s: " , __func__, subnode_name);if (ofnode_is_np (node)) { -const struct device_node *np =ofnode_to_np (node); +struct device_node *np =ofnode_to_np (node);for (np = np->child; np; np = np->sibling) {if (!strcmp (subnode_name, np->name))
include/dm/ofnode.h +2 -2
@@ -35,7 +35,7 @@ struct ofnode_phandle_args {* @node: Reference containing struct device_node * (possibly invalid) * Return: pointer to device node (can be NULL) */ -static inline const struct device_node *ofnode_to_np (ofnode node) +static inline struct device_node *ofnode_to_np (ofnode node) {#ifdef OF_CHECKS if (!of_live_active ())
@@ -117,7 +117,7 @@ static inline ofnode offset_to_ofnode(int of_offset)* @np: Live node pointer (can be NULL) * Return: reference to the associated node pointer */ -static inline ofnode np_to_ofnode (const struct device_node *np) +static inline ofnode np_to_ofnode (struct device_node *np) {ofnode node;
include/dm/ofnode_decl.h +1 -1
@@ -39,7 +39,7 @@* is not a really a pointer to a node: it is an offset value. See above. */ typedef union ofnode_union { -const struct device_node *np; +struct device_node *np;long of_offset; }ofnode ;
Signature · 1 line
2.37.2.672.g94769d06f0-goog
PATCH 11/21 test: Make a copy of the device tree before running a test
In reply to Simon GlassWhen the flat device tree changes it can mess up the live tree since that uses the flat tree for its strings. This affects only a few sandbox tests which modify the device tree, but the number will grow as ofnode support for writing improves.
While the control FDT is not intended to change while U-Boot is running, some tests do so. For example, the ofnode interface only supports modifying properties in the control FDT, so tests must use that.
To solve this problem, keep a copy of the FDT and restore it as needed when the test is finished. The copy only happens on sandbox (except SPL builds), to reduce memory usage and because these tests are not useful on other boards. For other boards, a checksum is taken to ensure that nothing changes.
It would be possible to always checksum the FDT on sandbox and only restore it if needed, but this is slightly slower than restoring it every time, at least with crc8.
---
doc/develop/driver-model/livetree.rst | 17 ++----- include/test/test.h | 6 +++ test/test-main.c | 69 +++++++++++++++++++++++++++ 3 files changed, 78 insertions(+), 14 deletions(-)
doc/develop/driver-model/livetree.rst +3 -14
@@ -235,20 +235,9 @@ tree either present or absent. This is to make sure that the flat tree functions work correctly even with OF_LIVE is enabled. But if a test modifies the flat device tree, then the live tree can become invalid. Any live tree tests that run after that point will use a corrupted tree, e.g. with an incorrect property name -or worse. To deal with this we use a flag UT_TESTF_LIVE_OR_FLAT then ensures -that tests which write to the flat tree are not run if OF_LIVE is enabled. Only -the live tree version of the test is run, when OF_LIVE is enabled, with -sandbox_flattree running the flat tree version. - -This is of course a work-around, even if a reasonable one. One solution to this -problem would be to make a copy of the flat tree before the test and restore it -afterwards, in the same memory location, so that the live tree pointers work -again. Another would be to regenerate the live tree if a test modified the flat -tree. - -Neither of these solutions is currently implemented, since the situation that -causes the problem can only occur in sandbox tests, is somewhat esoteric and -the UT_TESTF_LIVE_OR_FLAT flag deals with it in a reasonable way. +or worse. To deal with this we take a copy of the device tree and restore it +after any test that modifies it. Note that this copy is not made on other +boards, only sandbox. Multiple livetrees
include/test/test.h +6 -0
@@ -20,6 +20,9 @@* @testdev: Test device * @force_fail_alloc: Force all memory allocs to fail * @skip_post_probe: Skip uclass post-probe processing +* @fdt_chksum: crc8 of the device tree contents +* @fdt_copy: Copy of the device tree +* @fdt_size: Size of the device-tree copy * @expect_str: Temporary string used to hold expected string value * @actual_str: Temporary string used to hold actual string value */
@@ -32,6 +35,9 @@ struct unit_test_state {struct udevice *testdev;int force_fail_alloc;int skip_post_probe; +uint fdt_chksum; +void *fdt_copy; +uint fdt_size;char expect_str[512 ];char actual_str[512 ]; };
test/test-main.c +69 -0
102 lines not on this page · raw message
Signature · 1 line
2.37.2.672.g94769d06f0-goog
PATCH 12/21 test: Detect a change in the device tree
In reply to Simon GlassIf the device tree changes during a test and we cannot restore it, mark it as such so that future tests which need the live tree are skipped.
---
include/asm-generic/global_data.h | 4 ++++ test/test-main.c | 19 ++++++++++++++++--- 2 files changed, 20 insertions(+), 3 deletions(-)
include/asm-generic/global_data.h +4 -0
@@ -635,6 +635,10 @@ enum gd_flags {* @GD_FLG_SMP_READY: SMP initialization is complete */ GD_FLG_SMP_READY =0x80000 , +/* +* @GD_FLG_FDT_CHANGED: Device tree change has been detected by tests +*/ + GD_FLG_FDT_CHANGED = 0x100000, };#endif /* __ASSEMBLY__ */
test/test-main.c +16 -3
@@ -77,6 +77,10 @@ static int dm_test_pre_run(struct unit_test_state *uts) {bool of_live = uts->of_live; +if (of_live && (gd->flags &GD_FLG_FDT_CHANGED )) { +printf ("Cannot run live tree test as device tree changed\n" ); +return -EFAULT ; + } uts->root =NULL ; uts->testdev =NULL ; uts->force_fail_alloc = false;
@@ -110,9 +114,17 @@ static int dm_test_post_run(struct unit_test_state *uts)uint chksum; chksum =crc8 (0 , gd->fdt_blob,fdt_totalsize (gd->fdt_blob)); - -if (chksum != uts->fdt_chksum) +if (chksum != uts->fdt_chksum) { +/* +* We cannot run any more tests that need the +* live tree, since its strings point into the +* flat tree, which has changed. This likely +* means that at least some of the pointers from +* the live tree point to different things +*/ printf ("Device tree changed: cannot run live tree tests\n" ); + gd->flags |=GD_FLG_FDT_CHANGED ; + }break ; }case FDTCHK_NONE :
@@ -411,7 +423,8 @@ static int ut_run_test_live_flat(struct unit_test_state *uts,* or it is a core test. */ if (!(test->flags &UT_TESTF_LIVE_TREE ) && - (!runs ||ut_test_run_on_flattree (test))) { + (!runs ||ut_test_run_on_flattree (test)) && + !(gd->flags &GD_FLG_FDT_CHANGED )) { uts->of_live = false;ut_assertok (ut_run_test (uts, test, test->name)); runs++;
Signature · 1 line
2.37.2.672.g94769d06f0-goog
PATCH 13/21 test: Drop the UT_TESTF_LIVE_OR_FLAT flag
In reply to Simon GlassThis was a workaround for a rare situation. Now that it will be more common and we have a proper fix, drop the flag. We can run both types of tests in the same sandbox executable, even if the flat device tree is modified.
---
include/test/test.h | 2 -- test/dm/ofnode.c | 8 +++----- test/test-main.c | 3 +-- 3 files changed, 4 insertions(+), 9 deletions(-)
include/test/test.h +0 -2
@@ -52,8 +52,6 @@ enum {UT_TESTF_CONSOLE_REC =BIT (5 ),/* needs console recording */ /* do extra driver model init and uninit */ UT_TESTF_DM = BIT(6), -/* live or flat device tree, but not both in the same executable */ - UT_TESTF_LIVE_OR_FLAT = BIT(4), };/**
test/dm/ofnode.c +3 -5
@@ -584,7 +584,7 @@ static int dm_test_ofnode_livetree_writing(struct unit_test_state *uts)return 0 ; }DM_TEST (dm_test_ofnode_livetree_writing, -UT_TESTF_SCAN_PDATA |UT_TESTF_SCAN_FDT |UT_TESTF_LIVE_OR_FLAT ); +UT_TESTF_SCAN_PDATA |UT_TESTF_SCAN_FDT );static int dm_test_ofnode_u32 (struct unit_test_state *uts) {
@@ -599,8 +599,7 @@ static int dm_test_ofnode_u32(struct unit_test_state *uts)return 0 ; } -DM_TEST (dm_test_ofnode_u32, -UT_TESTF_SCAN_PDATA |UT_TESTF_SCAN_FDT |UT_TESTF_LIVE_OR_FLAT ); +DM_TEST (dm_test_ofnode_u32,UT_TESTF_SCAN_PDATA |UT_TESTF_SCAN_FDT );static int dm_test_ofnode_add_subnode (struct unit_test_state *uts) {
@@ -619,5 +618,4 @@ static int dm_test_ofnode_add_subnode(struct unit_test_state *uts)return 0 ; } -DM_TEST (dm_test_ofnode_add_subnode, -UT_TESTF_SCAN_PDATA |UT_TESTF_SCAN_FDT |UT_TESTF_LIVE_OR_FLAT ); +DM_TEST (dm_test_ofnode_add_subnode,UT_TESTF_SCAN_PDATA |UT_TESTF_SCAN_FDT );
test/test-main.c +1 -2
@@ -410,8 +410,7 @@ static int ut_run_test_live_flat(struct unit_test_state *uts,/* Run with the live tree if possible */ runs =0 ;if (CONFIG_IS_ENABLED (OF_LIVE )) { -if (!(test->flags & - (UT_TESTF_FLAT_TREE |UT_TESTF_LIVE_OR_FLAT ))) { +if (!(test->flags &UT_TESTF_FLAT_TREE )) { uts->of_live = true;ut_assertok (ut_run_test (uts, test, test->name)); runs++;
Signature · 1 line
2.37.2.672.g94769d06f0-goog
PATCH 14/21 dm: core: Provide a way to reset the device tree
In reply to Simon GlassAt present there is only one device tree used by the ofnode functions, except for some esoteric use of live tree. In preparation for supporting more than one, add a way to reset the list of device trees.
For now this does nothing.
---
common/board_r.c | 2 ++ include/dm/ofnode.h | 8 ++++++++ lib/fdtdec.c | 5 ++++- test/test-main.c | 2 ++ 4 files changed, 16 insertions(+), 1 deletion(-)
common/board_r.c +2 -0
@@ -233,6 +233,8 @@ static int initr_dm(void) {int ret; +oftree_reset (); +/* Save the pre-reloc driver model and start a new one */ gd->dm_root_f = gd->dm_root; gd->dm_root =NULL ;
include/dm/ofnode.h +8 -0
@@ -27,6 +27,14 @@ struct ofnode_phandle_args {uint32_t args[OF_MAX_PHANDLE_ARGS ]; }; +/** +* oftree_reset() - reset the state of the oftree list +* +* Reset the oftree list so it can be started again. This should be called +* once the control FDT is in place, but before the ofnode interface is used. +*/ +static inline void oftree_reset (void ) {} +/** * ofnode_to_np() - convert an ofnode to a live DT node pointer *
lib/fdtdec.c +4 -1
@@ -13,7 +13,6 @@#include <log.h> #include <malloc.h> #include <net.h> -#include <dm/of_extra.h> #include <env.h> #include <errno.h> #include <fdtdec.h>
@@ -24,6 +23,8 @@#include <serial.h> #include <asm/global_data.h> #include <asm/sections.h> +#include <dm/ofnode.h> +#include <dm/of_extra.h> #include <linux/ctype.h> #include <linux/lzo.h> #include <linux/ioport.h>
@@ -1668,6 +1669,8 @@ int fdtdec_setup(void) ret =fdtdec_prepare_fdt ();if (!ret) ret =fdtdec_board_setup (gd->fdt_blob); +oftree_reset (); +return ret; }
test/test-main.c +2 -0
@@ -8,6 +8,7 @@#include <console.h> #include <dm.h> #include <event.h> +#include <dm/ofnode.h> #include <dm/root.h> #include <dm/test.h> #include <dm/uclass-internal.h>
@@ -95,6 +96,7 @@ static int dm_test_pre_run(struct unit_test_state *uts)/* Determine whether to make the live tree available */ gd_set_of_root (of_live ? uts->of_root :NULL ); +oftree_reset ();ut_assertok (dm_init (of_live)); uts->root =dm_root ();
Signature · 1 line
2.37.2.672.g94769d06f0-goog
PATCH 15/21 dm: core: Add an ofnode function to obtain the flat tree
In reply to Simon GlassThe flat device tree is assumed to be the control FDT but this is not always the case. Update the ofnode implementation to obtain the node via an function call so we can eventually add support for selecting different trees.
---
drivers/core/ofnode.c | 93 ++++++++++++++++++++++++------------------- include/dm/ofnode.h | 19 +++++++++ 2 files changed, 70 insertions(+), 42 deletions(-)
drivers/core/ofnode.c +51 -42
@@ -57,8 +57,8 @@ int ofnode_read_u32_index(ofnode node, const char *propname, int index,return of_read_u32_index (ofnode_to_np (node), propname, index, outp); - cell =fdt_getprop (gd->fdt_blob,ofnode_to_offset (node), propname, - &len); + cell =fdt_getprop (ofnode_to_fdt (node),ofnode_to_offset (node), + propname, &len);if (!cell) {debug ("(not found)\n" );return -EINVAL ;
@@ -103,8 +103,8 @@ int ofnode_read_u64(ofnode node, const char *propname, u64 *outp)if (ofnode_is_np (node))return of_read_u64 (ofnode_to_np (node), propname, outp); - cell =fdt_getprop (gd->fdt_blob,ofnode_to_offset (node), propname, - &len); + cell =fdt_getprop (ofnode_to_fdt (node),ofnode_to_offset (node), + propname, &len);if (!cell || len <sizeof (*cell)) {debug ("(not found)\n" );return -EINVAL ;
@@ -155,7 +155,7 @@ const void *ofnode_read_prop(ofnode node, const char *propname, int *sizep) len = prop->length; } }else { - val =fdt_getprop (gd->fdt_blob,ofnode_to_offset (node), + val =fdt_getprop (ofnode_to_fdt (node),ofnode_to_offset (node), propname, &len); }if (!val) {
@@ -214,7 +214,7 @@ ofnode ofnode_find_subnode(ofnode node, const char *subnode_name) } subnode =np_to_ofnode (np); }else { -int ooffset =fdt_subnode_offset (gd->fdt_blob, +int ooffset =fdt_subnode_offset (ofnode_to_fdt (node),ofnode_to_offset (node), subnode_name); subnode =offset_to_ofnode (ooffset); }
@@ -234,7 +234,7 @@ int ofnode_read_u32_array(ofnode node, const char *propname,return of_read_u32_array (ofnode_to_np (node), propname, out_values, sz); }else { -return fdtdec_get_int_array (gd->fdt_blob, +return fdtdec_get_int_array (ofnode_to_fdt (node),ofnode_to_offset (node), propname, out_values, sz); }
@@ -246,7 +246,7 @@ bool ofnode_is_enabled(ofnode node)if (ofnode_is_np (node)) {return of_device_is_available (ofnode_to_np (node)); }else { -return fdtdec_get_is_enabled (gd->fdt_blob, +return fdtdec_get_is_enabled (ofnode_to_fdt (node),ofnode_to_offset (node)); } }
@@ -258,7 +258,7 @@ ofnode ofnode_first_subnode(ofnode node)return np_to_ofnode (node.np->child);return offset_to_ofnode ( -fdt_first_subnode (gd->fdt_blob,ofnode_to_offset (node))); +fdt_first_subnode (ofnode_to_fdt (node),ofnode_to_offset (node))); }ofnode ofnode_next_subnode (ofnode node)
@@ -268,7 +268,7 @@ ofnode ofnode_next_subnode(ofnode node)return np_to_ofnode (node.np->sibling);return offset_to_ofnode ( - fdt_next_subnode(gd->fdt_blob, ofnode_to_offset(node))); + fdt_next_subnode(ofnode_to_fdt(node), ofnode_to_offset(node))); }#endif /* !DM_INLINE_OFNODE */
@@ -280,7 +280,7 @@ ofnode ofnode_get_parent(ofnode node)if (ofnode_is_np (node)) parent =np_to_ofnode (of_get_parent (ofnode_to_np (node)));else - parent.of_offset =fdt_parent_offset (gd->fdt_blob, + parent.of_offset =fdt_parent_offset (ofnode_to_fdt (node),ofnode_to_offset (node));return parent;
@@ -296,7 +296,7 @@ const char *ofnode_get_name(ofnode node)if (ofnode_is_np (node))return strrchr (node.np->full_name,'/' ) +1 ; -return fdt_get_name (gd->fdt_blob,ofnode_to_offset (node),NULL ); +return fdt_get_name (ofnode_to_fdt (node),ofnode_to_offset (node),NULL ); }int ofnode_get_path (ofnode node,char *buf,int buflen)
@@ -313,7 +313,7 @@ int ofnode_get_path(ofnode node, char *buf, int buflen) }else {int res; - res =fdt_get_path (gd->fdt_blob,ofnode_to_offset (node), buf, + res =fdt_get_path (ofnode_to_fdt (node),ofnode_to_offset (node), buf, buflen);if (!res)return res;
@@ -369,7 +369,7 @@ static fdt_addr_t __ofnode_get_addr_size_index(ofnode node, int index, }else { na =ofnode_read_simple_addr_cells (ofnode_get_parent (node)); ns =ofnode_read_simple_size_cells (ofnode_get_parent (node)); -return fdtdec_get_addr_size_fixed (gd->fdt_blob, +return fdtdec_get_addr_size_fixed (ofnode_to_fdt (node),ofnode_to_offset (node),"reg" , index, na, ns, size, translate);
@@ -417,7 +417,7 @@ int ofnode_stringlist_search(ofnode node, const char *property, }else {int ret; - ret =fdt_stringlist_search (gd->fdt_blob, + ret =fdt_stringlist_search (ofnode_to_fdt (node),ofnode_to_offset (node), property, string);if (ret == -FDT_ERR_NOTFOUND )
@@ -438,7 +438,8 @@ int ofnode_read_string_index(ofnode node, const char *property, int index, }else {int len; - *outp =fdt_stringlist_get (gd->fdt_blob,ofnode_to_offset (node), + *outp =fdt_stringlist_get (ofnode_to_fdt (node), +ofnode_to_offset (node), property, index, &len);if (len <0 )return -EINVAL ;
@@ -451,7 +452,7 @@ int ofnode_read_string_count(ofnode node, const char *property)if (ofnode_is_np (node)) {return of_property_count_strings (ofnode_to_np (node), property); }else { -return fdt_stringlist_count (gd->fdt_blob, +return fdt_stringlist_count (ofnode_to_fdt (node),ofnode_to_offset (node), property); } }
@@ -520,7 +521,7 @@ int ofnode_parse_phandle_with_args(ofnode node, const char *list_name,struct fdtdec_phandle_args args;int ret; - ret =fdtdec_parse_phandle_with_args (gd->fdt_blob, + ret =fdtdec_parse_phandle_with_args (ofnode_to_fdt (node),ofnode_to_offset (node), list_name, cells_name, cell_count, index, &args);
@@ -539,7 +540,7 @@ int ofnode_count_phandle_with_args(ofnode node, const char *list_name,return of_count_phandle_with_args (ofnode_to_np (node), list_name, cells_name, cell_count); else - return fdtdec_parse_phandle_with_args(gd->fdt_blob, + return fdtdec_parse_phandle_with_args(ofnode_to_fdt(node),ofnode_to_offset (node), list_name, cells_name, cell_count,-1 ,NULL ); }
@@ -714,7 +715,7 @@ const void *ofnode_get_property(ofnode node, const char *propname, int *lenp)if (ofnode_is_np (node))return of_get_property (ofnode_to_np (node), propname, lenp);else -return fdt_getprop (gd->fdt_blob,ofnode_to_offset (node), +return fdt_getprop (ofnode_to_fdt (node),ofnode_to_offset (node), propname, lenp); }
@@ -728,7 +729,7 @@ int ofnode_get_first_property(ofnode node, struct ofprop *prop)return -FDT_ERR_NOTFOUND ; }else { prop->offset = -fdt_first_property_offset (gd->fdt_blob, +fdt_first_property_offset (ofnode_to_fdt (node),ofnode_to_offset (prop->node));if (prop->offset <0 )return prop->offset;
@@ -745,8 +746,9 @@ int ofnode_get_next_property(struct ofprop *prop)if (!prop->prop)return -FDT_ERR_NOTFOUND ; }else { - prop->offset =fdt_next_property_offset (gd->fdt_blob, - prop->offset); + prop->offset = +fdt_next_property_offset (ofnode_to_fdt (prop->node), + prop->offset);if (prop->offset <0 )return prop->offset; }
@@ -761,7 +763,7 @@ const void *ofnode_get_property_by_prop(const struct ofprop *prop,return of_get_property_by_prop (ofnode_to_np (prop->node), prop->prop, propname, lenp); else - return fdt_getprop_by_offset(gd->fdt_blob, + return fdt_getprop_by_offset(ofnode_to_fdt(prop->node), prop->offset, propname, lenp); }
@@ -771,7 +773,7 @@ bool ofnode_is_available(ofnode node)if (ofnode_is_np (node))return of_device_is_available (ofnode_to_np (node));else -return fdtdec_get_is_enabled (gd->fdt_blob, +return fdtdec_get_is_enabled (ofnode_to_fdt (node),ofnode_to_offset (node)); }
@@ -795,7 +797,7 @@ fdt_addr_t ofnode_get_addr_size(ofnode node, const char *property,else return of_read_number (prop, na); }else { -return fdtdec_get_addr_size (gd->fdt_blob, +return fdtdec_get_addr_size (ofnode_to_fdt (node),ofnode_to_offset (node), property, sizep); }
@@ -814,7 +816,7 @@ const uint8_t *ofnode_read_u8_array_ptr(ofnode node, const char *propname,return (uint8_t *)prop; }else { -return fdtdec_locate_byte_array (gd->fdt_blob, +return fdtdec_locate_byte_array (ofnode_to_fdt (node),ofnode_to_offset (node), propname, sz); } }
@@ -950,10 +952,10 @@ int ofnode_read_addr_cells(ofnode node)if (ofnode_is_np (node)) {return of_n_addr_cells (ofnode_to_np (node)); }else { -int parent =fdt_parent_offset (gd->fdt_blob, +int parent =fdt_parent_offset (ofnode_to_fdt (node),ofnode_to_offset (node)); -return fdt_address_cells (gd->fdt_blob, parent); +return fdt_address_cells (ofnode_to_fdt (node), parent); } }
@@ -962,10 +964,10 @@ int ofnode_read_size_cells(ofnode node)if (ofnode_is_np (node)) {return of_n_size_cells (ofnode_to_np (node)); }else { -int parent =fdt_parent_offset (gd->fdt_blob, +int parent =fdt_parent_offset (ofnode_to_fdt (node),ofnode_to_offset (node)); -return fdt_size_cells (gd->fdt_blob, parent); +return fdt_size_cells (ofnode_to_fdt (node), parent); } }
@@ -974,7 +976,8 @@ int ofnode_read_simple_addr_cells(ofnode node)if (ofnode_is_np (node))return of_simple_addr_cells (ofnode_to_np (node));else -return fdt_address_cells (gd->fdt_blob,ofnode_to_offset (node)); +return fdt_address_cells (ofnode_to_fdt (node), +ofnode_to_offset (node)); }int ofnode_read_simple_size_cells (ofnode node)
@@ -982,7 +985,8 @@ int ofnode_read_simple_size_cells(ofnode node)if (ofnode_is_np (node))return of_simple_size_cells (ofnode_to_np (node));else -return fdt_size_cells (gd->fdt_blob,ofnode_to_offset (node)); +return fdt_size_cells (ofnode_to_fdt (node), +ofnode_to_offset (node)); }bool ofnode_pre_reloc (ofnode node)
@@ -1019,7 +1023,8 @@ int ofnode_read_resource(ofnode node, uint index, struct resource *res)struct fdt_resource fres;int ret; - ret =fdt_get_resource (gd->fdt_blob,ofnode_to_offset (node), + ret =fdt_get_resource (ofnode_to_fdt (node), +ofnode_to_offset (node),"reg" , index, &fres);if (ret <0 )return -EINVAL ;
@@ -1048,7 +1053,8 @@ u64 ofnode_translate_address(ofnode node, const fdt32_t *in_addr)if (ofnode_is_np (node))return of_translate_address (ofnode_to_np (node), in_addr);else -return fdt_translate_address (gd->fdt_blob,ofnode_to_offset (node), in_addr); +return fdt_translate_address (ofnode_to_fdt (node), +ofnode_to_offset (node), in_addr); }u64 ofnode_translate_dma_address (ofnode node,const fdt32_t *in_addr)
@@ -1056,7 +1062,8 @@ u64 ofnode_translate_dma_address(ofnode node, const fdt32_t *in_addr)if (ofnode_is_np (node))return of_translate_dma_address (ofnode_to_np (node), in_addr);else -return fdt_translate_dma_address (gd->fdt_blob,ofnode_to_offset (node), in_addr); +return fdt_translate_dma_address (ofnode_to_fdt (node), +ofnode_to_offset (node), in_addr); }int ofnode_get_dma_range (ofnode node,phys_addr_t *cpu,dma_addr_t *bus,u64 *size)
@@ -1064,7 +1071,8 @@ int ofnode_get_dma_range(ofnode node, phys_addr_t *cpu, dma_addr_t *bus, u64 *siif (ofnode_is_np (node))return of_get_dma_range (ofnode_to_np (node), cpu, bus, size);else -return fdt_get_dma_range (gd->fdt_blob,ofnode_to_offset (node), +return fdt_get_dma_range (ofnode_to_fdt (node), +ofnode_to_offset (node), cpu, bus, size); }
@@ -1074,7 +1082,7 @@ int ofnode_device_is_compatible(ofnode node, const char *compat)return of_device_is_compatible (ofnode_to_np (node), compat,NULL ,NULL ); else - return !fdt_node_check_compatible(gd->fdt_blob, + return !fdt_node_check_compatible(ofnode_to_fdt(node),ofnode_to_offset (node), compat); }
@@ -1087,7 +1095,8 @@ ofnode ofnode_by_compatible(ofnode from, const char *compat) compat)); }else {return offset_to_ofnode (fdt_node_offset_by_compatible ( - gd->fdt_blob,ofnode_to_offset (from), compat)); +ofnode_to_fdt (from), +ofnode_to_offset (from), compat)); } }
@@ -1100,7 +1109,7 @@ ofnode ofnode_by_prop_value(ofnode from, const char *propname, propval, proplen)); }else {return offset_to_ofnode (fdt_node_offset_by_prop_value ( - gd->fdt_blob,ofnode_to_offset (from), +ofnode_to_fdt (from),ofnode_to_offset (from), propname, propval, proplen)); } }
@@ -1111,7 +1120,7 @@ int ofnode_write_prop(ofnode node, const char *propname, const void *value,if (of_live_active ())return of_write_prop (ofnode_to_npw (node), propname, len, value);else -return fdt_setprop ((void *)gd->fdt_blob,ofnode_to_offset (node), +return fdt_setprop (ofnode_to_fdt (node),ofnode_to_offset (node), propname, value, len);return 0 ;
@@ -1246,7 +1255,7 @@ int ofnode_add_subnode(ofnode node, const char *name, ofnode *subnodep) }else {int offset; - offset =fdt_add_subnode ((void *)gd->fdt_blob, + offset =fdt_add_subnode (ofnode_to_fdt (node),ofnode_to_offset (node), name);if (offset <0 )return offset == -FDT_ERR_EXISTS ? -EEXIST :0 ;
include/dm/ofnode.h +19 -0
@@ -35,6 +35,25 @@ struct ofnode_phandle_args {*/ static inline void oftree_reset (void ) {} +/** +* ofnode_to_fdt() - convert an ofnode to a flat DT pointer +* +* This cannot be called if the reference contains a node pointer. +* +* @node: Reference containing offset (possibly invalid) +* Return: DT offset (can be NULL) +*/ +static inline void *ofnode_to_fdt (ofnode node) +{ +#ifdef OF_CHECKS +if (of_live_active ()) +return NULL ; +#endif + +/* Use the control FDT by default */ +return (void *)gd->fdt_blob; +} +/** * ofnode_to_np() - convert an ofnode to a live DT node pointer *
Signature · 1 line
2.37.2.672.g94769d06f0-goog
PATCH 16/21 dm: core: Add ofnode functions to obtain an oftree
In reply to Simon GlassAt present dm_test_ofnode_root() does this manually. Add some inline functions to handle it, so this code can be centralised.
---
include/dm/ofnode.h | 31 +++++++++++++++++++++++++++++++ test/dm/ofnode.c | 4 ++-- 2 files changed, 33 insertions(+), 2 deletions(-)
include/dm/ofnode.h +31 -0
@@ -238,6 +238,37 @@ static inline oftree oftree_default(void)return tree; } +/** +* oftree_from_np() - Returns an oftree from a node pointer +* +* @root: Root node of the tree +* Returns: reference to the given node +*/ +static inline oftree oftree_from_np (struct device_node *root) +{ +oftree tree; + + tree.np = root; + +return tree; +} + +/** +* oftree_from_fdt() - Returns an oftree from a flat device tree pointer +* +* @fdt: Device tree to use +* +* Returns: reference to the given node +*/ +static inline oftree oftree_from_fdt (void *fdt) +{ +oftree tree; + + tree.fdt = fdt; + +return tree; +} +/** * ofnode_name_eq() - Check if the node name is equivalent to a given name * ignoring the unit address
test/dm/ofnode.c +2 -2
@@ -518,9 +518,9 @@ static int dm_test_ofnode_root(struct unit_test_state *uts)ut_assertok (make_ofnode_fdt (uts, fdt,sizeof (fdt)));if (of_live_active ()) {ut_assertok (unflatten_device_tree (fdt, &root)); - tree.np = root; + tree =oftree_from_np (root); }else { - tree.fdt = fdt; + tree =oftree_from_fdt (fdt); }/* Make sure they don't work on this new tree */
Signature · 1 line
2.37.2.672.g94769d06f0-goog
PATCH 17/21 dm: core: Add a way to look up a phandle in an oftree
In reply to Simon GlassWhen we have multiple trees, the ofnode logic needs to be told which one to use. Create a new function which takes an oftree argument, along with a helper to obtain the FDT pointer from an oftree.
---
drivers/core/ofnode.c | 14 ++++++++++++++ include/dm/ofnode.h | 25 +++++++++++++++++++++++++ test/dm/ofnode.c | 2 ++ 3 files changed, 41 insertions(+)
drivers/core/ofnode.c +14 -0
@@ -337,6 +337,20 @@ ofnode ofnode_get_by_phandle(uint phandle)return node; } +ofnode oftree_get_by_phandle (oftree tree,uint phandle) +{ +ofnode node; + +if (of_live_active ()) + node =np_to_ofnode (of_find_node_by_phandle (tree.np, phandle)); +else + node.of_offset = +fdt_node_offset_by_phandle (oftree_lookup_fdt (tree), + phandle); + +return node; +} +static fdt_addr_t __ofnode_get_addr_size_index (ofnode node,int index,fdt_size_t *size,bool translate) {
include/dm/ofnode.h +25 -0
@@ -120,6 +120,22 @@ static inline bool ofnode_valid(ofnode node)return node.of_offset >=0 ; } +/** +* oftree_lookup_fdt() - object the FDT pointer from an oftree +* +* This can only be called when flat tree is enabled +* +* @tree: Tree to look at +* @return FDT pointer from the tree +*/ +static inline void *oftree_lookup_fdt (oftree tree) +{ +if (of_live_active ()) +return NULL ; +else +return tree.fdt; +} +/** * offset_to_ofnode() - convert a DT offset to an ofnode *
@@ -526,6 +542,15 @@ int ofnode_get_path(ofnode node, char *buf, int buflen);*/ ofnode ofnode_get_by_phandle (uint phandle); +/** +* oftree_get_by_phandle() - get ofnode from phandle +* +* @tree: tree to use +* @phandle: phandle to look up +* Return: ofnode reference to the phandle +*/ +ofnode oftree_get_by_phandle (oftree tree,uint phandle); +/** * ofnode_read_size() - read the size of a property *
test/dm/ofnode.c +2 -0
@@ -36,6 +36,8 @@ static int dm_test_ofnode_get_by_phandle(struct unit_test_state *uts)/* test unknown phandle */ ut_assert (!ofnode_valid (ofnode_get_by_phandle (0x1000000 ))); +ut_assert (ofnode_valid (oftree_get_by_phandle (oftree_default (),1 ))); +return 0 ; }DM_TEST (dm_test_ofnode_get_by_phandle,UT_TESTF_SCAN_PDATA |UT_TESTF_SCAN_FDT );
Signature · 1 line
2.37.2.672.g94769d06f0-goog
PATCH 18/21 dm: core: Allow obtaining a node offset in the same tree
In reply to Simon GlassIn some cases we want to obtain an ofnode in the same tree as a different ofnode, such as when looking up a subnode. At present this is trivial, since there is only one tree. When there are multiple trees, this implementation will change.
Also move the ofnode_to_offset() function up higher in the header file, since we will need to provide a different implementation with multiple trees.
---
drivers/core/ofnode.c | 2 +- include/dm/ofnode.h | 39 +++++++++++++++++++++++++++++---------- 2 files changed, 30 insertions(+), 11 deletions(-)
drivers/core/ofnode.c +1 -1
@@ -1273,7 +1273,7 @@ int ofnode_add_subnode(ofnode node, const char *name, ofnode *subnodep) ofnode_to_offset(node), name);if (offset <0 )return offset == -FDT_ERR_EXISTS ? -EEXIST :0 ; - subnode =offset_to_ofnode (offset); + subnode =noffset_to_ofnode (node, offset); } *subnodep = subnode;
include/dm/ofnode.h +29 -10
@@ -54,6 +54,23 @@ static inline void *ofnode_to_fdt(ofnode node)return (void *)gd->fdt_blob; } +/** +* ofnode_to_offset() - convert an ofnode to a flat DT offset +* +* This cannot be called if the reference contains a node pointer. +* +* @node: Reference containing offset (possibly invalid) +* Return: DT offset (can be -1) +*/ +static inline int ofnode_to_offset (ofnode node) +{ +#ifdef OF_CHECKS +if (of_live_active ()) +return -1 ; +#endif +return node.of_offset; +} +/** * ofnode_to_np() - convert an ofnode to a live DT node pointer *
@@ -90,20 +107,22 @@ static inline struct device_node *ofnode_to_npw(ofnode node) }/** -* ofnode_to_offset() - convert an ofnode to a flat DT offset +* noffset_to_ofnode() - convert a DT offset to an ofnode * -* This cannot be called if the reference contains a node pointer. -* -* @node: Reference containing offset (possibly invalid) -* Return: DT offset (can be -1) +* @other_node: Node in the same tree to use as a reference +* @of_offset: DT offset (either valid, or -1) +* Return: reference to the associated DT offset */ -static inline int ofnode_to_offset (ofnode node) +static inline ofnode noffset_to_ofnode (ofnode other_node,int of_offset) { -#ifdef OF_CHECKS +ofnode node; +if (of_live_active ()) -return -1 ; -#endif -return node.of_offset; + node.np =NULL ; +else + node.of_offset = of_offset; + +return node; }/**
Signature · 1 line
2.37.2.672.g94769d06f0-goog
PATCH 19/21 dm: core: Add definitions for multiple ofnode trees
In reply to Simon GlassAt present, unless OF_LIVE is enabled, ofnode only supports access to one device tree, the control FDT. This is because only the node offset is encoded in ofnode, with the tree being implicit.
This makes ofnode (without OF_LIVE) unsuitable for device tree fixups, as implemented by ft_board_setup() and other such functions.
To solve this, we can use the top bits of the node offset to hold a tree ID.
Add the definitions for this.
---
drivers/core/Kconfig | 24 ++++++++++++++++++++++++ include/dm/ofnode_decl.h | 29 +++++++++++++++++++++++++++-- 2 files changed, 51 insertions(+), 2 deletions(-)
drivers/core/Kconfig +24 -0
@@ -400,6 +400,30 @@ config DM_DEV_READ_INLINE bool default y if !OF_LIVE +config OFNODE_MULTI_TREE + bool "Allow the ofnode interface to access any tree" + default y if EVENT && !DM_DEV_READ_INLINE && !DM_INLINE_OFNODE + help + Normally U-Boot makes use of its control FDT, the one used to bind + devices and provide options. In some cases, U-Boot must also process + a separate FDT, e.g. one provided by the operating system, which + needs additions to the /chosen node. + + This works fine with live tree (OF_LIVE), but with flat tree the + offset provided in ofnode is only useful with the control FDT. This + option adds a 'tree ID' to the offset, so that multiple trees can + be used. Call ofnode_path_root() to register a new tree. + +config OFNODE_MULTI_TREE_MAX + int "Maximum number of FDTs" + range 2 8 + depends on OFNODE_MULTI_TREE + default 4 + help + Sets the maximum number of device trees which can be used with the + ofnode interface when using flat trees (OF_LIVE). This is only + available in U-Boot proper and only after relocation. + config ACPIGEN bool "Support ACPI table generation in driver model" default y if SANDBOX || (GENERATE_ACPI_TABLE && !QEMU)
include/dm/ofnode_decl.h +27 -2
@@ -31,8 +31,14 @@* this increases code size slightly due to the subtraction. Since it offers no * real benefit, the approach described here seems best. * -* For now these points use constant types, since we don't allow writing -* the DT. +* Where multiple trees are in use, this works without any trouble with live +* tree, except for aliases, such as ofnode_path("mmc0"), which only work on the +* control FDT. When the flat tree is in use, the trees are registered and a +* 'tree ID' is encoded into the top bits of @of_offset - see immediately below +* for the associated macro definitions. Note that 64-bit machines use the same +* encoding, even though there is more space available. This is partly because +* the FDT format contains 32-bit values for things like the string-table +* offset, therefore 64-bit offsets cannot be supported anyway. * * @np: Pointer to device node, used for live tree * @of_offset: Pointer into flat device tree, used for flat tree. Note that this
@@ -43,6 +49,25 @@ typedef union ofnode_union {long of_offset; } ofnode; +/* shift for the tree ID within of_offset */ +#define OF_TREE_SHIFT 28 + +/* mask to obtain the device tree offset from of_offset */ +#define OF_TREE_MASK ((1 << OF_TREE_SHIFT) - 1) + +/* encode a tree ID and node offset into an of_offset value */ +#define OFTREE_NODE (tree_id, offs) ((tree_id) << OF_TREE_SHIFT | (offs)) + +/* decode the node offset from an of_offset value */ +#define OFTREE_OFFSET (of_offs) ((of_offs) & OF_TREE_MASK) + +/* decode the tree ID from an of_offset value */ +#define OFTREE_TREE_ID (of_offs) ((of_offs) >> OF_TREE_SHIFT) + +/* encode a node offset in the tree given by another node's of_offset value */ +#define OFTREE_MAKE_NODE (other_of_offset, offs) \ + (((offs) & OF_TREE_MASK) | ((other_of_offset) & ~OF_TREE_MASK)) +/** * struct ofprop - reference to a property of a device tree node *
Signature · 1 line
2.37.2.672.g94769d06f0-goog
PATCH 20/21 dm: core: Reduce code size with dev_of_offset()
In reply to Simon GlassUpdate the function to mark it with the const attribute. Also avoid calling it multiple times in the devfdt_get_addr_index() function.
---
drivers/core/fdtaddr.c | 18 +++++++++--------- include/dm/device.h | 6 +++--- 2 files changed, 12 insertions(+), 12 deletions(-)
drivers/core/fdtaddr.c +9 -9
@@ -21,6 +21,8 @@ DECLARE_GLOBAL_DATA_PTR;fdt_addr_t devfdt_get_addr_index (const struct udevice *dev,int index) {#if CONFIG_IS_ENABLED (OF_REAL ) +int offset =dev_of_offset (dev); +int parent =dev_of_offset (dev->parent);fdt_addr_t addr;if (CONFIG_IS_ENABLED (OF_TRANSLATE )) {
@@ -28,21 +30,19 @@ fdt_addr_t devfdt_get_addr_index(const struct udevice *dev, int index)int len =0 ;int na, ns; - na =fdt_address_cells (gd->fdt_blob, -dev_of_offset (dev->parent)); + na =fdt_address_cells (gd->fdt_blob, parent);if (na <1 ) {debug ("bad #address-cells\n" );return FDT_ADDR_T_NONE ; } - ns =fdt_size_cells (gd->fdt_blob,dev_of_offset (dev->parent)); + ns =fdt_size_cells (gd->fdt_blob, parent);if (ns <0 ) {debug ("bad #size-cells\n" );return FDT_ADDR_T_NONE ; } - reg =fdt_getprop (gd->fdt_blob,dev_of_offset (dev),"reg" , - &len); + reg =fdt_getprop (gd->fdt_blob, offset,"reg" , &len);if (!reg || (len <= (index *sizeof (fdt32_t) * (na + ns)))) {debug ("Req index out of range\n" );return FDT_ADDR_T_NONE ;
@@ -56,7 +56,7 @@ fdt_addr_t devfdt_get_addr_index(const struct udevice *dev, int index)* bus setups. */ addr =fdt_translate_address ((void *)gd->fdt_blob, -dev_of_offset (dev), reg); + offset, reg); }else {/* Non translatable if #size-cells == 0 */ addr =fdt_read_number (reg, na);
@@ -66,9 +66,9 @@ fdt_addr_t devfdt_get_addr_index(const struct udevice *dev, int index)* Use the "simple" translate function for less complex * bus setups. */ - addr =fdtdec_get_addr_size_auto_parent (gd->fdt_blob, -dev_of_offset (dev->parent),dev_of_offset (dev), -"reg" , index,NULL , false); + addr =fdtdec_get_addr_size_auto_parent (gd->fdt_blob, parent, + offset,"reg" , index, +NULL , false);if (CONFIG_IS_ENABLED (SIMPLE_BUS ) && addr !=FDT_ADDR_T_NONE ) {if (device_get_uclass_id (dev->parent) ==UCLASS_SIMPLE_BUS )
include/dm/device.h +3 -3
@@ -253,7 +253,7 @@ static inline void dev_bic_flags(struct udevice *dev, u32 bic)* @dev: device to check * Return: reference of the device's DT node */ -static inline ofnode dev_ofnode (const struct udevice *dev) +static inline __attribute_const__ ofnode dev_ofnode(const struct udevice *dev) {#if CONFIG_IS_ENABLED (OF_REAL )return dev->node_;
@@ -273,7 +273,7 @@ static inline ofnode dev_ofnode(const struct udevice *dev)#define dev_get_dma_offset (_dev) 0#endif -static inline int dev_of_offset (const struct udevice *dev) +static inline __attribute_const__ int dev_of_offset(const struct udevice *dev) {#if CONFIG_IS_ENABLED (OF_REAL )return ofnode_to_offset (dev_ofnode (dev));
@@ -282,7 +282,7 @@ static inline int dev_of_offset(const struct udevice *dev)#endif } -static inline bool dev_has_ofnode (const struct udevice *dev) +static inline __attribute_const__ bool dev_has_ofnode(const struct udevice *dev) {#if CONFIG_IS_ENABLED (OF_REAL )return ofnode_valid (dev_ofnode (dev));
Signature · 1 line
2.37.2.672.g94769d06f0-goog
PATCH 21/21 dm: core: Add the ofnode multi-tree implementation
In reply to Simon GlassAdd the logic to redirect requests for the device tree through a function which can look up the tree ID. This works by using the top bits of ofnode.of_offset to encode a tree.
It is assumed that there will only be a few device trees used at runtime, typically the control FDT (always tree ID 0) and possibly a separate FDT to be passed the OS.
The maximum number of device trees supported at runtime is 8, with this implementation. That would use bits 30:28 of the node-offset value, meaning that the positive offset range is limited to bits 27:0, versus 30:1 with this feature disabled. That still allows a device tree of up to 256MB, which should be enough for most FITs. Larger ones can be supported by using external data with the FIT, or by enabling OF_LIVE.
Update the documentation a little.
---
doc/develop/driver-model/livetree.rst | 13 +-- drivers/core/ofnode.c | 124 +++++++++++++++++++++++++- include/dm/ofnode.h | 41 ++++++--- 3 files changed, 161 insertions(+), 17 deletions(-)
doc/develop/driver-model/livetree.rst +8 -5
@@ -250,11 +250,14 @@ a flat tree. It would be helpful to use livetree for fixups, since adding a lot of nodes and properties would involve less memory copying and be more efficient. As a step towards this, an `oftree` type has been introduced. It is normally set to -oftree_default() but can be set to other values. Eventually this should allow -the use of FDT fixups using the ofnode interface, instead of the low-level -libfdt one. - -See dm_test_ofnode_root() for some examples. +oftree_default() but can be set to other values using oftree_from_fdt(). +So long as OF_LIVE is disabled, it is possible to do fixups using the ofnode +interface. The OF_LIVE support required addition of the flattening step at the +end. + +See dm_test_ofnode_root() for some examples. The ofnode_path_root() function +causes a flat device tree to be 'registered' such that it can be used by the +ofnode interface. Internal implementation
drivers/core/ofnode.c +123 -1
142 lines not on this page · raw message
include/dm/ofnode.h +30 -11
81 lines not on this page · raw message
Signature · 1 line
2.37.2.672.g94769d06f0-goog