U-Boot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Simon Glass <sjg@chromium.org>
To: U-Boot Mailing List <u-boot@lists.denx.de>
Cc: Tom Rini <trini@konsulko.com>,
	Ilias Apalodimas <ilias.apalodimas@linaro.org>,
	Heinrich Schuchardt <xypron.glpk@gmx.de>,
	Simon Glass <sjg@chromium.org>,
	Eddie James <eajames@linux.ibm.com>,
	Marek Vasut <marek.vasut+renesas@mailbox.org>,
	Mattijs Korpershoek <mkorpershoek@baylibre.com>,
	Safae Ouajih <souajih@baylibre.com>,
	Sean Anderson <sean.anderson@seco.com>,
	Tobias Waldekranz <tobias@waldekranz.com>
Subject: [PATCH 17/29] bootm: Reduce arguments to boot_get_ramdisk()
Date: Sat, 11 Nov 2023 17:09:02 -0700	[thread overview]
Message-ID: <20231112000923.73568-18-sjg@chromium.org> (raw)
In-Reply-To: <20231112000923.73568-1-sjg@chromium.org>

This function normally only uses one argument so pass it in directly.
Move comments to the header file so could one day include these
functions in API docs. Fix up the u8 argument while here, since it
avoids the compiler having to mask the value on some machines.

The Android case here is bit strange, since it can use argv[0], so deal
with that in the caller.

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

 boot/bootm.c       | 15 ++++++++++++++-
 boot/image-board.c | 39 ++-------------------------------------
 include/image.h    | 27 +++++++++++++++++++++++++--
 3 files changed, 41 insertions(+), 40 deletions(-)

diff --git a/boot/bootm.c b/boot/bootm.c
index 2358d68c2861..5782a1e2a57b 100644
--- a/boot/bootm.c
+++ b/boot/bootm.c
@@ -488,10 +488,23 @@ static int bootm_find_os(const char *addr_fit)
 int bootm_find_images(int flag, int argc, char *const argv[], ulong start,
 		      ulong size)
 {
+	const char *select = NULL;
 	int ret;
 
+	if (IS_ENABLED(CONFIG_ANDROID_BOOT_IMAGE)) {
+		char *buf;
+
+		/* Look for an Android boot image */
+		buf = map_sysmem(images.os.start, 0);
+		if (buf && genimg_get_format(buf) == IMAGE_FORMAT_ANDROID)
+			select = argc ? argv[0] : env_get("loadaddr");
+	}
+
+	if (argc >= 2)
+		select = argv[1];
+
 	/* find ramdisk */
-	ret = boot_get_ramdisk(argc, argv, &images, IH_INITRD_ARCH,
+	ret = boot_get_ramdisk(select, &images, IH_INITRD_ARCH,
 			       &images.rd_start, &images.rd_end);
 	if (ret) {
 		puts("Ramdisk image is corrupt or invalid\n");
diff --git a/boot/image-board.c b/boot/image-board.c
index 062c76badecc..60e514fc150e 100644
--- a/boot/image-board.c
+++ b/boot/image-board.c
@@ -456,49 +456,14 @@ static int select_ramdisk(struct bootm_headers *images, const char *select, u8 a
 	return 0;
 }
 
-/**
- * boot_get_ramdisk - main ramdisk handling routine
- * @argc: command argument count
- * @argv: command argument list
- * @images: pointer to the bootm images structure
- * @arch: expected ramdisk architecture
- * @rd_start: pointer to a ulong variable, will hold ramdisk start address
- * @rd_end: pointer to a ulong variable, will hold ramdisk end
- *
- * boot_get_ramdisk() is responsible for finding a valid ramdisk image.
- * Currently supported are the following ramdisk sources:
- *      - multicomponent kernel/ramdisk image,
- *      - commandline provided address of decicated ramdisk image.
- *
- * returns:
- *     0, if ramdisk image was found and valid, or skiped
- *     rd_start and rd_end are set to ramdisk start/end addresses if
- *     ramdisk image is found and valid
- *
- *     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[], struct bootm_headers *images,
-		     u8 arch, ulong *rd_start, ulong *rd_end)
+int boot_get_ramdisk(char const *select, struct bootm_headers *images,
+		     uint arch, ulong *rd_start, ulong *rd_end)
 {
 	ulong rd_data, rd_len;
-	const char *select = NULL;
 
 	*rd_start = 0;
 	*rd_end = 0;
 
-	if (IS_ENABLED(CONFIG_ANDROID_BOOT_IMAGE)) {
-		char *buf;
-
-		/* Look for an Android boot image */
-		buf = map_sysmem(images->os.start, 0);
-		if (buf && genimg_get_format(buf) == IMAGE_FORMAT_ANDROID)
-			select = (argc == 0) ? env_get("loadaddr") : argv[0];
-	}
-
-	if (argc >= 2)
-		select = argv[1];
-
 	/*
 	 * Look for a '-' which indicates to ignore the
 	 * ramdisk argument
diff --git a/include/image.h b/include/image.h
index d37e44721672..3e48ad5b303e 100644
--- a/include/image.h
+++ b/include/image.h
@@ -644,8 +644,31 @@ int genimg_has_config(struct bootm_headers *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[], struct bootm_headers *images,
-		     uint8_t arch, ulong *rd_start, ulong *rd_end);
+
+/**
+ * boot_get_ramdisk() - Locate the ramdisk
+ *
+ * @select: address or name of ramdisk to use, or NULL for default
+ * @images: pointer to the bootm images structure
+ * @arch: expected ramdisk architecture
+ * @rd_start: pointer to a ulong variable, will hold ramdisk start address
+ * @rd_end: pointer to a ulong variable, will hold ramdisk end
+ *
+ * boot_get_ramdisk() is responsible for finding a valid ramdisk image.
+ * Currently supported are the following ramdisk sources:
+ *      - multicomponent kernel/ramdisk image,
+ *      - commandline provided address of decicated ramdisk image.
+ *
+ * returns:
+ *     0, if ramdisk image was found and valid, or skiped
+ *     rd_start and rd_end are set to ramdisk start/end addresses if
+ *     ramdisk image is found and valid
+ *
+ *     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(char const *select, struct bootm_headers *images,
+		     uint arch, ulong *rd_start, ulong *rd_end);
 
 /**
  * boot_get_loadable - routine to load a list of binaries to memory
-- 
2.42.0.869.gea05f2083d-goog


  parent reply	other threads:[~2023-11-12  0:19 UTC|newest]

Thread overview: 60+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-12  0:08 [PATCH 00/29] bootm: Refactoring to reduce reliance on CMDLINE (part A) Simon Glass
2023-11-12  0:08 ` [PATCH 01/29] arm: x86: Drop discarding of command linker-lists Simon Glass
2023-11-15 19:55   ` Tom Rini
2023-11-12  0:08 ` [PATCH 02/29] mmc: env: Unify the U_BOOT_ENV_LOCATION conditions Simon Glass
2023-11-15 10:02   ` Heinrich Schuchardt
2023-11-19 14:49     ` Simon Glass
2023-11-21 18:12       ` Tom Rini
2023-11-12  0:08 ` [PATCH 03/29] treewide: Tidy up semicolon after command macros Simon Glass
2023-11-15 19:58   ` Tom Rini
2023-11-12  0:08 ` [PATCH 04/29] bootstd: Add missing header file from bootdev.h Simon Glass
2023-11-12  0:08 ` [PATCH 05/29] bootstd: Introduce programmable boot Simon Glass
2023-11-12  0:08 ` [PATCH 06/29] bootm: Drop arguments from bootm_start() Simon Glass
2023-11-15 22:36   ` Tom Rini
2023-11-12  0:08 ` [PATCH 07/29] bootm: Simplify arguments for bootm_pre_load() Simon Glass
2023-11-15 22:36   ` Tom Rini
2023-11-12  0:08 ` [PATCH 08/29] bootm: Move boot_get_kernel() higher in the file Simon Glass
2023-11-15 22:36   ` Tom Rini
2023-11-12  0:08 ` [PATCH 09/29] image: Tidy up genimg_get_kernel_addr_fit() Simon Glass
2023-11-15 22:36   ` Tom Rini
2023-11-12  0:08 ` [PATCH 10/29] bootm: Reduce arguments to boot_get_kernel() Simon Glass
2023-11-15 22:36   ` Tom Rini
2023-11-12  0:08 ` [PATCH 11/29] image: Document error codes from fit_image_load() Simon Glass
2023-11-15 22:36   ` Tom Rini
2023-11-12  0:08 ` [PATCH 12/29] bootm: Adjust boot_get_kernel() to return an error Simon Glass
2023-11-15 22:36   ` Tom Rini
2023-11-12  0:08 ` [PATCH 13/29] bootm: Use the error return from boot_get_kernel() Simon Glass
2023-11-15 22:36   ` Tom Rini
2023-11-12  0:08 ` [PATCH 14/29] bootstage: Drop BOOTSTAGE_ID_FIT_KERNEL_INFO Simon Glass
2023-11-15 22:37   ` Tom Rini
2023-11-12  0:09 ` [PATCH 15/29] bootm: Move error printing out of boot_get_kernel() Simon Glass
2023-11-15 22:37   ` Tom Rini
2023-11-12  0:09 ` [PATCH 16/29] bootm: Reduce arguments to boot_find_os() Simon Glass
2023-11-15 22:37   ` Tom Rini
2023-11-12  0:09 ` Simon Glass [this message]
2023-11-15 22:37   ` [PATCH 17/29] bootm: Reduce arguments to boot_get_ramdisk() Tom Rini
2023-11-12  0:09 ` [PATCH 18/29] fdt: Allow use of fdt_support inside if() statements Simon Glass
2023-11-15 22:37   ` Tom Rini
2023-11-12  0:09 ` [PATCH 19/29] bootm: Drop #ifdef in bootm_find_images() Simon Glass
2023-11-12  0:09 ` [PATCH 20/29] bootm: Pass image buffer to boot_get_fdt() Simon Glass
2023-11-12  0:09 ` [PATCH 21/29] bootm: Reduce arguments " Simon Glass
2023-11-15 22:37   ` Tom Rini
2023-11-12  0:09 ` [PATCH 22/29] bootm: Reduce arguments to boot_get_fpga() Simon Glass
2023-11-15 22:37   ` Tom Rini
2023-11-12  0:09 ` [PATCH 23/29] bootm: Reduce arguments to boot_get_loadables() Simon Glass
2023-11-15 22:37   ` Tom Rini
2023-11-12  0:09 ` [PATCH 24/29] bootm: Simplify Android ramdisk addr in bootm_find_images() Simon Glass
2023-11-15 22:37   ` Tom Rini
2023-11-12  0:09 ` [PATCH 25/29] bootm: efi: Drop special call to bootm_find_other() Simon Glass
2023-11-12  0:09 ` [PATCH 26/29] bootm: optee: " Simon Glass
2023-11-12  0:09 ` [PATCH 27/29] bootm: Adjust the parameters of bootm_find_images() Simon Glass
2023-11-15 22:38   ` Tom Rini
2023-11-16  1:42     ` Simon Glass
2023-11-16  1:47       ` Tom Rini
2023-11-16  1:56         ` Simon Glass
2023-11-16  2:07           ` Tom Rini
2023-11-16  2:35             ` Simon Glass
2023-11-12  0:09 ` [PATCH 28/29] bootm: Add a function to check overlap Simon Glass
2023-11-15 22:38   ` Tom Rini
2023-11-12  0:09 ` [PATCH 29/29] bootm: Reduce arguments to bootm_find_other() Simon Glass
2023-11-15 22:38   ` Tom Rini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231112000923.73568-18-sjg@chromium.org \
    --to=sjg@chromium.org \
    --cc=eajames@linux.ibm.com \
    --cc=ilias.apalodimas@linaro.org \
    --cc=marek.vasut+renesas@mailbox.org \
    --cc=mkorpershoek@baylibre.com \
    --cc=sean.anderson@seco.com \
    --cc=souajih@baylibre.com \
    --cc=tobias@waldekranz.com \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.denx.de \
    --cc=xypron.glpk@gmx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox