All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 00/50] image: Reduce #ifdefs and ad-hoc defines in image code
@ 2021-05-06 14:23 Simon Glass
  2021-05-06 14:23 ` [PATCH v2 01/50] lib: Add memdup() Simon Glass
                   ` (49 more replies)
  0 siblings, 50 replies; 91+ messages in thread
From: Simon Glass @ 2021-05-06 14:23 UTC (permalink / raw)
  To: u-boot

Much of the image-handling code predates the introduction of Kconfig and
has quite a few #ifdefs in it. It also uses its own IMAGE_... defines to
help reduce the #ifdefs, which is unnecessary now that we can use
IS_ENABLED() et al.

The image code is also where quite a bit of code is shared with the host
tools. At present this uses a lot of checks of USE_HOSTCC.

This series introduces 'host' Kconfig options and a way to use
CONFIG_IS_ENABLED() to check them. This works in a similar way to SPL, so

   CONFIG_IS_ENABLED(FIT)

will evaluate to true on the host build (USE_HOSTCC) if CONFIG_HOST_FIT is
enabled. This allows quite a bit of clean-up of the image.h header file
and many of the image C files.

The 'host' Kconfig options should help to solve a more general problem in
that we mostly want the host tools to build with all features enabled, no
matter which features the 'target' build actually uses. This is a pain to
arrange at present, but with 'host' Kconfigs, we can just define them all
to y.

There are cases where the host tools do not have features which are
present on the target, for example environment and physical addressing.
To help with this, some of the core image code is split out into
image-board.c and image-host.c files.

Even with these changes, some #ifdefs remain (101 down to 42 in
common/image*). But the code is somewhat easier to follow and there are
fewer build paths.

In service of the above, this series includes a patch to add an API function
for zstd, so the code can be dropped from bootm.c

It also introduces a function to handle manual relocation.

Changes in v2:
- Add a patch to introduce a memdup() function
- Add new abuf_init_set() function
- Update abuf_realloc() to return after every case
- Use const for abuf_data() and abuf_size()
- Make use of memdup()
- Add abuf_init_move()
- Add comments about the assumptions made by lib_test_abuf_realloc()
- Add better comments about why some tests are skipped at present
- Correct 'hose' typo
- Fix up comment to put an underscore after every CONFIG
- Correct comment about USE_HOSTCC being undefined in CONFIG_VAL()
- Add SPL_ Kconfigs also, since otherwise hashing algorithms drop from SPL
- Drop unnecessary setting of rd_len, etc.
- Correct logic for the non-FIT case
- Consider selecting a raw FDT to be success

Simon Glass (50):
  lib: Add memdup()
  Add support for an owned buffer
  compiler: Add a comment to host_build()
  zstd: Create a function for use from U-Boot
  btrfs: Use U-Boot API for decompression
  image: Avoid switch default in image_decomp()
  image: Update zstd to avoid reporting error twice
  gzip: Avoid use of u64
  image: Update image_decomp() to avoid ifdefs
  image: Split board code out into its own file
  image: Fix up checkpatch warnings in image-board.c
  image: Split host code out into its own file
  image: Create a function to do manual relocation
  image: Avoid #ifdefs for manual relocation
  image: Remove ifdefs around image_setup_linux() el at
  image: Add Kconfig options for FIT in the host build
  kconfig: Add host support to CONFIG_IS_ENABLED()
  image: Shorten FIT_ENABLE_SHAxxx_SUPPORT
  image: Rename SPL_SHAxxx_SUPPORT to SPL_FIT_SHAxxx
  hash: Use Kconfig to enable hashing in host tools
  hash: Drop some #ifdefs in hash.c
  image: Drop IMAGE_ENABLE_FIT
  image: Drop IMAGE_ENABLE_OF_LIBFDT
  image: Use Kconfig to enable CONFIG_FIT_VERBOSE on host
  image: Rename CONFIG_FIT_ENABLE_RSASSA_PSS_SUPPORT
  image: Use Kconfig to enable FIT_RSASSA_PSS on host
  Kconfig: Rename SPL_CRC32_SUPPORT to SPL_CRC32
  image: Drop IMAGE_ENABLE_CRC32
  Kconfig: Rename SPL_MD5_SUPPORT to SPL_MD5
  image: Drop IMAGE_ENABLE_MD5
  image: Drop IMAGE_ENABLE_SHA1
  image: Drop IMAGE_ENABLE_SHAxxx
  image: Drop IMAGE_BOOT_GET_CMDLINE
  image: Drop IMAGE_OF_BOARD_SETUP
  image: Drop IMAGE_OF_SYSTEM_SETUP
  image: Drop IMAGE_ENABLE_IGNORE
  image: Drop IMAGE_ENABLE_SIGN/VERIFY defines
  image: Drop IMAGE_ENABLE_BEST_MATCH
  image: Drop IMAGE_ENABLE_EN/DECRYPT defines
  image: Tidy up fit_unsupported_reset()
  image: Drop unnecessary #ifdefs from image.h
  image: Drop #ifdefs for fit_print_contents()
  image: Drop most #ifdefs in image-board.c
  image: Reduce variable scope in boot_get_ramdisk()
  image: Split up boot_get_ramdisk()
  image: Remove #ifdefs from select_ramdisk()
  image: Remove some #ifdefs from image-fit and image-fit-sig
  image: Reduce variable scope in boot_get_fdt()
  image: Split up boot_get_fdt()
  image: Remove #ifdefs from select_fdt()

 arch/arc/lib/bootm.c                      |    2 +-
 arch/arm/lib/bootm.c                      |    4 +-
 arch/arm/mach-imx/hab.c                   |    2 +-
 arch/microblaze/lib/bootm.c               |    2 +-
 arch/nds32/lib/bootm.c                    |    4 +-
 arch/riscv/lib/bootm.c                    |    4 +-
 board/synopsys/hsdk/hsdk.c                |    2 +-
 common/Kconfig.boot                       |   18 +-
 common/Makefile                           |    2 +-
 common/bootm.c                            |   30 +-
 common/bootm_os.c                         |    8 +
 common/hash.c                             |   96 +-
 common/image-board.c                      |  957 +++++++++++++++++
 common/image-cipher.c                     |    6 +-
 common/image-fdt.c                        |  276 ++---
 common/image-fit-sig.c                    |    7 +-
 common/image-fit.c                        |   42 +-
 common/image-host.c                       |   27 +
 common/image-sig.c                        |   57 +-
 common/image.c                            | 1179 ++-------------------
 common/spl/Kconfig                        |   90 +-
 configs/axm_defconfig                     |    2 +-
 configs/bcm963158_ram_defconfig           |    2 +-
 configs/chromebit_mickey_defconfig        |    2 +-
 configs/chromebook_jerry_defconfig        |    2 +-
 configs/chromebook_minnie_defconfig       |    2 +-
 configs/chromebook_speedy_defconfig       |    2 +-
 configs/evb-px30_defconfig                |    2 +-
 configs/firefly-px30_defconfig            |    2 +-
 configs/imxrt1020-evk_defconfig           |    2 +-
 configs/imxrt1050-evk_defconfig           |    2 +-
 configs/mt8516_pumpkin_defconfig          |    2 +-
 configs/odroid-go2_defconfig              |    2 +-
 configs/px30-core-ctouch2-px30_defconfig  |    2 +-
 configs/px30-core-edimm2.2-px30_defconfig |    2 +-
 configs/sandbox_defconfig                 |    3 +-
 configs/socfpga_agilex_atf_defconfig      |    2 +-
 configs/socfpga_agilex_vab_defconfig      |    2 +-
 configs/socfpga_stratix10_atf_defconfig   |    2 +-
 configs/taurus_defconfig                  |    2 +-
 fs/btrfs/compression.c                    |   51 +-
 include/abuf.h                            |  159 +++
 include/compiler.h                        |    8 +
 include/fdt_support.h                     |    2 +-
 include/gzip.h                            |    8 +-
 include/image.h                           |  178 +---
 include/linux/kconfig.h                   |   13 +-
 include/linux/string.h                    |   13 +
 include/linux/zstd.h                      |   11 +
 include/relocate.h                        |   30 +-
 include/u-boot/aes.h                      |    8 +-
 include/u-boot/ecdsa.h                    |    2 +-
 include/u-boot/hash-checksum.h            |    5 +-
 include/u-boot/rsa.h                      |   12 +-
 lib/Kconfig                               |    5 +
 lib/Makefile                              |    5 +-
 lib/abuf.c                                |  109 ++
 lib/gunzip.c                              |   28 +-
 lib/hash-checksum.c                       |    2 +-
 lib/lmb.c                                 |    2 +-
 lib/rsa/rsa-sign.c                        |    4 +-
 lib/rsa/rsa-verify.c                      |    4 +-
 lib/string.c                              |   13 +
 lib/zstd/Makefile                         |    2 +-
 lib/zstd/zstd.c                           |   64 ++
 test/lib/Makefile                         |    1 +
 test/lib/abuf.c                           |  344 ++++++
 test/lib/string.c                         |   32 +
 tools/Kconfig                             |  111 ++
 tools/Makefile                            |   19 +-
 tools/image-host.c                        |    6 +-
 71 files changed, 2455 insertions(+), 1650 deletions(-)
 create mode 100644 common/image-board.c
 create mode 100644 common/image-host.c
 create mode 100644 include/abuf.h
 create mode 100644 lib/abuf.c
 create mode 100644 lib/zstd/zstd.c
 create mode 100644 test/lib/abuf.c

-- 
2.31.1.607.g51e8a6a459-goog

^ permalink raw reply	[flat|nested] 91+ messages in thread

end of thread, other threads:[~2021-05-19 15:49 UTC | newest]

Thread overview: 91+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-06 14:23 [PATCH v2 00/50] image: Reduce #ifdefs and ad-hoc defines in image code Simon Glass
2021-05-06 14:23 ` [PATCH v2 01/50] lib: Add memdup() Simon Glass
2021-05-06 17:07   ` Pratyush Yadav
2021-05-06 17:41     ` Simon Glass
2021-05-06 17:57       ` Sean Anderson
2021-05-10  9:00       ` Rasmus Villemoes
2021-05-10 11:21         ` Heinrich Schuchardt
2021-05-10 16:28         ` Simon Glass
2021-05-06 14:23 ` [PATCH v2 02/50] Add support for an owned buffer Simon Glass
2021-05-06 14:23 ` [PATCH v2 03/50] compiler: Add a comment to host_build() Simon Glass
2021-05-06 14:23 ` [PATCH v2 04/50] zstd: Create a function for use from U-Boot Simon Glass
2021-05-06 14:23 ` [PATCH v2 05/50] btrfs: Use U-Boot API for decompression Simon Glass
2021-05-06 14:23 ` [PATCH v2 06/50] image: Avoid switch default in image_decomp() Simon Glass
2021-05-06 14:23 ` [PATCH v2 07/50] image: Update zstd to avoid reporting error twice Simon Glass
2021-05-06 14:23 ` [PATCH v2 08/50] gzip: Avoid use of u64 Simon Glass
2021-05-06 14:23 ` [PATCH v2 09/50] image: Update image_decomp() to avoid ifdefs Simon Glass
2021-05-06 14:23 ` [PATCH v2 10/50] image: Split board code out into its own file Simon Glass
2021-05-06 14:23 ` [PATCH v2 11/50] image: Fix up checkpatch warnings in image-board.c Simon Glass
2021-05-06 14:24 ` [PATCH v2 12/50] image: Split host code out into its own file Simon Glass
2021-05-06 14:24 ` [PATCH v2 13/50] image: Create a function to do manual relocation Simon Glass
2021-05-06 14:24 ` [PATCH v2 14/50] image: Avoid #ifdefs for " Simon Glass
2021-05-06 14:24 ` [PATCH v2 15/50] image: Remove ifdefs around image_setup_linux() el at Simon Glass
2021-05-06 14:24 ` [PATCH v2 16/50] image: Add Kconfig options for FIT in the host build Simon Glass
2021-05-11 19:57   ` Alex G.
2021-05-11 22:34     ` Tom Rini
2021-05-12  0:50       ` Alex G.
2021-05-12  1:10         ` Tom Rini
2021-05-12 15:52           ` Simon Glass
2021-05-12 16:19             ` Alex G.
2021-05-12 17:14               ` Tom Rini
2021-05-17 22:29                 ` Alex G.
2021-05-18  1:23                   ` AKASHI Takahiro
2021-05-19 15:49                     ` Alex G
2021-05-12 14:51     ` Simon Glass
2021-05-12 15:48       ` Alex G.
2021-05-12 15:54         ` Simon Glass
2021-05-12 16:18           ` Alex G.
2021-05-12 17:30             ` Simon Glass
2021-05-13 16:21               ` Alex G.
2021-05-13 23:56                 ` Simon Glass
2021-05-14 15:12                   ` Alex G.
2021-05-15 15:20                     ` Simon Glass
2021-05-06 14:24 ` [PATCH v2 17/50] kconfig: Add host support to CONFIG_IS_ENABLED() Simon Glass
2021-05-06 14:24 ` [PATCH v2 18/50] image: Shorten FIT_ENABLE_SHAxxx_SUPPORT Simon Glass
2021-05-14 15:30   ` Alex G.
2021-05-06 14:24 ` [PATCH v2 19/50] image: Rename SPL_SHAxxx_SUPPORT to SPL_FIT_SHAxxx Simon Glass
2021-05-14 15:34   ` Alex G.
2021-05-06 14:24 ` [PATCH v2 20/50] hash: Use Kconfig to enable hashing in host tools Simon Glass
2021-05-06 14:24 ` [PATCH v2 21/50] hash: Drop some #ifdefs in hash.c Simon Glass
2021-05-14 15:37   ` Alex G.
2021-05-14 20:43     ` Tom Rini
2021-05-06 14:24 ` [PATCH v2 22/50] image: Drop IMAGE_ENABLE_FIT Simon Glass
2021-05-06 14:24 ` [PATCH v2 23/50] image: Drop IMAGE_ENABLE_OF_LIBFDT Simon Glass
2021-05-06 14:24 ` [PATCH v2 24/50] image: Use Kconfig to enable CONFIG_FIT_VERBOSE on host Simon Glass
2021-05-06 14:24 ` [PATCH v2 25/50] image: Rename CONFIG_FIT_ENABLE_RSASSA_PSS_SUPPORT Simon Glass
2021-05-06 14:24 ` [PATCH v2 26/50] image: Use Kconfig to enable FIT_RSASSA_PSS on host Simon Glass
2021-05-06 14:24 ` [PATCH v2 27/50] Kconfig: Rename SPL_CRC32_SUPPORT to SPL_CRC32 Simon Glass
2021-05-14 21:31   ` Alex G.
2021-05-06 14:24 ` [PATCH v2 28/50] image: Drop IMAGE_ENABLE_CRC32 Simon Glass
2021-05-06 14:24 ` [PATCH v2 29/50] Kconfig: Rename SPL_MD5_SUPPORT to SPL_MD5 Simon Glass
2021-05-14 21:31   ` Alex G.
2021-05-06 14:24 ` [PATCH v2 30/50] image: Drop IMAGE_ENABLE_MD5 Simon Glass
2021-05-06 14:24 ` [PATCH v2 31/50] image: Drop IMAGE_ENABLE_SHA1 Simon Glass
2021-05-06 14:24 ` [PATCH v2 32/50] image: Drop IMAGE_ENABLE_SHAxxx Simon Glass
2021-05-06 14:24 ` [PATCH v2 33/50] image: Drop IMAGE_BOOT_GET_CMDLINE Simon Glass
2021-05-06 14:24 ` [PATCH v2 34/50] image: Drop IMAGE_OF_BOARD_SETUP Simon Glass
2021-05-06 14:24 ` [PATCH v2 35/50] image: Drop IMAGE_OF_SYSTEM_SETUP Simon Glass
2021-05-06 14:24 ` [PATCH v2 36/50] image: Drop IMAGE_ENABLE_IGNORE Simon Glass
2021-05-06 14:24 ` [PATCH v2 37/50] image: Drop IMAGE_ENABLE_SIGN/VERIFY defines Simon Glass
2021-05-14 20:38   ` Alex G.
2021-05-14 20:44     ` Simon Glass
2021-05-14 21:17       ` Alex G.
2021-05-15 15:20         ` Simon Glass
2021-05-06 14:24 ` [PATCH v2 38/50] image: Drop IMAGE_ENABLE_BEST_MATCH Simon Glass
2021-05-14 21:32   ` Alex G.
2021-05-06 14:24 ` [PATCH v2 39/50] image: Drop IMAGE_ENABLE_EN/DECRYPT defines Simon Glass
2021-05-06 14:24 ` [PATCH v2 40/50] image: Tidy up fit_unsupported_reset() Simon Glass
2021-05-06 14:24 ` [PATCH v2 41/50] image: Drop unnecessary #ifdefs from image.h Simon Glass
2021-05-14 21:45   ` Alex G.
2021-05-06 14:24 ` [PATCH v2 42/50] image: Drop #ifdefs for fit_print_contents() Simon Glass
2021-05-14 21:46   ` Alex G.
2021-05-06 14:24 ` [PATCH v2 43/50] image: Drop most #ifdefs in image-board.c Simon Glass
2021-05-06 14:24 ` [PATCH v2 44/50] image: Reduce variable scope in boot_get_ramdisk() Simon Glass
2021-05-06 14:24 ` [PATCH v2 45/50] image: Split up boot_get_ramdisk() Simon Glass
2021-05-06 14:24 ` [PATCH v2 46/50] image: Remove #ifdefs from select_ramdisk() Simon Glass
2021-05-06 14:24 ` [PATCH v2 47/50] image: Remove some #ifdefs from image-fit and image-fit-sig Simon Glass
2021-05-14 21:50   ` Alex G.
2021-05-15 15:20     ` Simon Glass
2021-05-06 14:24 ` [PATCH v2 48/50] image: Reduce variable scope in boot_get_fdt() Simon Glass
2021-05-06 14:24 ` [PATCH v2 49/50] image: Split up boot_get_fdt() Simon Glass
2021-05-06 14:24 ` [PATCH v2 50/50] image: Remove #ifdefs from select_fdt() Simon Glass

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.