The global data structure has grown quite a lot over the years, being the best place to put an important pointer or something that must be accessed before and after relocation.
This series attempts to reduce the size a little, by moving some things out and shrinking and aligning some fields. Some fields are needed during init but not afterwards. To deal with this a new 'boardf' structure is created, which sits on the stack and is only present during board_init_f(). It is possible that more fields could move to this struct, but for now only 4 are moved. An assumption is made that an int is 32-bits wide on all architectures, which seems to be true, but maintainers should be able to confirm. Mostly the code-size impact is neutral, but the patch 'Use less space for environment fields' does increase U-Boot's size by about 30 bytes on aarch64. For firefly-rk3399 (64-bit) the size of global reduces from 456 to 368 bytes. For SPL it reduces from 416 to 272 bytes. There are other things which could be attempted, for example: - Using hlist instead of list for some lists - Checking that only necessary fields are present in SPL Simon Glass (35): global_data: Move pci_clk to m68k and powerpc x86: Drop use of global_data fb_base video: Add a function to obtain the framebuffer address video: mxc: Avoid setting global_data fb_base video: mxs: Avoid setting global_data fb_base arm: friendlyarm: Avoid accessing global_data fb_base arm: ronetix: Avoid accessing global_data fb_base zynqmp: Avoid setting the framebuffer address video: Avoid setting global_data fb_base from SPL handoff video: Avoid setting global_data fb_base in video setup global_data: Drop fb_base global_data: Convert have_console into a flag global_data: Remove pci_ram_top global_data: Drop global_data hose global_data: Drop pci_bootdelay global_data: Use less space for environment fields board_f: Add a new struct to hold pre-relocation info board_f: Move fdt_size to board board_f: Move new_bootstage to boardf board_f: Move new_bloblist to boardf global_data: Drop spl_handoff global_data: Collect common fields at the top global_data: Reduce the size of bus_clk and mem_clk global_data: Reduce the size of mon_len global_data: log: Reorder and shrink fields global_data: Reduce size of early-malloc vars global_data: Move baud_rate field lower global_data: Move env_addr field higher global_data: Put phys_addr fields near the top global_data: Move ulong fields together global_data: Move pointer members together global_data: Remove jump table in SPL global_data: Remove environment members if not used doc: Move generic-board documentation into rst doc: Add some guidelines about global data arch/arm/cpu/arm926ejs/mxs/spl_boot.c | 2 +- arch/arm/lib/bdinfo.c | 2 +- arch/arm/mach-exynos/spl_boot.c | 2 +- arch/arm/mach-k3/common.c | 2 +- arch/arm/mach-k3/r5/sysfw-loader.c | 2 +- arch/arm/mach-tegra/board2.c | 4 - arch/arm/mach-tegra/cboot.c | 4 - arch/m68k/cpu/mcf5445x/cpu.c | 2 +- arch/m68k/include/asm/global_data.h | 2 + arch/m68k/lib/bdinfo.c | 2 +- arch/mips/mach-ath79/ar934x/clk.c | 4 +- arch/mips/mach-octeon/cpu.c | 2 +- arch/powerpc/cpu/mpc83xx/pci.c | 4 +- arch/powerpc/cpu/mpc83xx/speed.c | 2 +- arch/powerpc/include/asm/global_data.h | 2 + arch/x86/cpu/i386/cpu.c | 8 - arch/x86/cpu/intel_common/cpu_from_spl.c | 4 +- arch/x86/cpu/ivybridge/cpu.c | 5 - arch/x86/lib/fsp/fsp_graphics.c | 1 - arch/x86/lib/fsp2/fsp_dram.c | 4 +- board/freescale/ls2080ardb/eth_ls2080rdb.c | 2 +- board/friendlyarm/nanopi2/board.c | 9 +- board/ronetix/pm9263/pm9263.c | 6 +- board/siemens/common/board_am335x.c | 2 +- cmd/bdinfo.c | 2 - cmd/sb.c | 6 +- common/board_f.c | 59 ++- common/board_r.c | 2 +- common/console.c | 17 +- common/hwconfig.c | 8 +- common/init/handoff.c | 12 + common/malloc_simple.c | 7 +- common/spl/spl.c | 6 +- doc/develop/global_data.rst | 25 ++ .../historical/generic_board.rst} | 16 +- doc/develop/historical/index.rst | 12 + doc/develop/index.rst | 8 + drivers/clk/mpc83xx_clk.c | 2 +- drivers/clk/rockchip/clk_rk3399.c | 3 +- drivers/video/imx/mxc_ipuv3_fb.c | 2 - drivers/video/mxsfb.c | 1 - drivers/video/video-uclass.c | 16 +- drivers/video/zynqmp/zynqmp_dpsub.c | 3 +- include/asm-generic/global_data.h | 349 ++++++++---------- include/board_f.h | 35 ++ include/env_default.h | 3 - include/env_internal.h | 1 + include/handoff.h | 7 + include/video.h | 11 + lib/asm-offsets.c | 2 + test/cmd/bdinfo.c | 3 - test/log/log_test.c | 6 +- 52 files changed, 373 insertions(+), 330 deletions(-) rename doc/{README.generic-board => develop/historical/generic_board.rst} (96%) create mode 100644 doc/develop/historical/index.rst create mode 100644 include/board_f.h -- 2.34.1