[PATCH 07/16] bootstd: Move common zimage functions to bootm.h

Simon Glass sjg at chromium.org
Sun Jul 30 19:16:53 CEST 2023


We want to avoid using #ifdefs around header files and in the code. It
makes sense to collect the various functions used for loading images into
a single header which can be included by all architectures. The best place
for this is the arch-neutral bootm.h header, so use that.

Move some zimage functions into this bootm.h header.

Signed-off-by: Simon Glass <sjg at chromium.org>
---

 arch/x86/include/asm/zimage.h | 27 ---------------------------
 boot/bootmeth_cros.c          |  4 +---
 include/bootm.h               | 28 ++++++++++++++++++++++++++++
 3 files changed, 29 insertions(+), 30 deletions(-)

diff --git a/arch/x86/include/asm/zimage.h b/arch/x86/include/asm/zimage.h
index 9ad74dc0b946..000b38ea8993 100644
--- a/arch/x86/include/asm/zimage.h
+++ b/arch/x86/include/asm/zimage.h
@@ -72,31 +72,4 @@ int setup_zimage(struct boot_params *setup_base, char *cmd_line, int auto_boot,
  */
 void zimage_dump(struct boot_params *base_ptr);
 
-/**
- * zboot_start() - Boot a zimage
- *
- * Boot a zimage, given the component parts
- *
- * @addr: Address where the bzImage is moved before booting, either
- *	BZIMAGE_LOAD_ADDR or ZIMAGE_LOAD_ADDR
- * @base: Pointer to the boot parameters, typically at address
- *	DEFAULT_SETUP_BASE
- * @initrd: Address of the initial ramdisk, or 0 if none
- * @initrd_size: Size of the initial ramdisk, or 0 if none
- * @cmdline: Command line to use for booting
- * Return: -EFAULT on error (normally it does not return)
- */
-int zboot_start(ulong addr, ulong size, ulong initrd, ulong initrd_size,
-		ulong base, char *cmdline);
-
-/*
- * zimage_get_kernel_version() - Get the version string from a kernel
- *
- * @params: boot_params pointer
- * @kernel_base: base address of kernel
- * Return: Kernel version as a NUL-terminated string
- */
-const char *zimage_get_kernel_version(struct boot_params *params,
-				      void *kernel_base);
-
 #endif
diff --git a/boot/bootmeth_cros.c b/boot/bootmeth_cros.c
index 05284713f67b..3b9e75540aa8 100644
--- a/boot/bootmeth_cros.c
+++ b/boot/bootmeth_cros.c
@@ -12,15 +12,13 @@
 #include <blk.h>
 #include <bootdev.h>
 #include <bootflow.h>
+#include <bootm.h>
 #include <bootmeth.h>
 #include <display_options.h>
 #include <dm.h>
 #include <malloc.h>
 #include <mapmem.h>
 #include <part.h>
-#ifdef CONFIG_X86
-#include <asm/zimage.h>
-#endif
 #include <linux/sizes.h>
 #include "bootmeth_cros.h"
 
diff --git a/include/bootm.h b/include/bootm.h
index 044a4797ed36..6fe418e00272 100644
--- a/include/bootm.h
+++ b/include/bootm.h
@@ -9,6 +9,7 @@
 
 #include <image.h>
 
+struct boot_params;
 struct cmd_tbl;
 
 #define BOOTM_ERR_RESET		(-1)
@@ -124,4 +125,31 @@ int bootm_process_cmdline(char *buf, int maxlen, int flags);
  */
 int bootm_process_cmdline_env(int flags);
 
+/**
+ * zboot_start() - Boot a zimage
+ *
+ * Boot a zimage, given the component parts
+ *
+ * @addr: Address where the bzImage is moved before booting, either
+ *	BZIMAGE_LOAD_ADDR or ZIMAGE_LOAD_ADDR
+ * @base: Pointer to the boot parameters, typically at address
+ *	DEFAULT_SETUP_BASE
+ * @initrd: Address of the initial ramdisk, or 0 if none
+ * @initrd_size: Size of the initial ramdisk, or 0 if none
+ * @cmdline: Command line to use for booting
+ * Return: -EFAULT on error (normally it does not return)
+ */
+int zboot_start(ulong addr, ulong size, ulong initrd, ulong initrd_size,
+		ulong base, char *cmdline);
+
+/*
+ * zimage_get_kernel_version() - Get the version string from a kernel
+ *
+ * @params: boot_params pointer
+ * @kernel_base: base address of kernel
+ * Return: Kernel version as a NUL-terminated string
+ */
+const char *zimage_get_kernel_version(struct boot_params *params,
+				      void *kernel_base);
+
 #endif
-- 
2.41.0.487.g6d72f3e995-goog



More information about the U-Boot mailing list