From: Simon Glass <sjg@chromium.org>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 03/27] spl: Add a parameter to spl_parse_image_header()
Date: Sun, 18 Sep 2016 13:44:52 -0600 [thread overview]
Message-ID: <1474227917-9256-4-git-send-email-sjg@chromium.org> (raw)
In-Reply-To: <1474227917-9256-1-git-send-email-sjg@chromium.org>
Instead of using the global spl_image variable, pass the required struct in
as an argument.
Signed-off-by: Simon Glass <sjg@chromium.org>
---
arch/arm/mach-uniphier/boot-mode/spl_board.c | 2 +-
common/spl/spl.c | 41 ++++++++++++++--------------
common/spl/spl_ext.c | 2 +-
common/spl/spl_fat.c | 2 +-
common/spl/spl_mmc.c | 2 +-
common/spl/spl_nand.c | 4 +--
common/spl/spl_net.c | 3 +-
common/spl/spl_nor.c | 4 +--
common/spl/spl_onenand.c | 2 +-
common/spl/spl_ubi.c | 4 +--
common/spl/spl_ymodem.c | 5 ++--
drivers/mtd/spi/spi_spl_load.c | 4 +--
drivers/mtd/spi/sunxi_spi_spl.c | 2 +-
include/spl.h | 20 ++++++++++++--
14 files changed, 58 insertions(+), 39 deletions(-)
diff --git a/arch/arm/mach-uniphier/boot-mode/spl_board.c b/arch/arm/mach-uniphier/boot-mode/spl_board.c
index 86292b6..63ab41c 100644
--- a/arch/arm/mach-uniphier/boot-mode/spl_board.c
+++ b/arch/arm/mach-uniphier/boot-mode/spl_board.c
@@ -113,7 +113,7 @@ int spl_board_load_image(void)
return ret;
}
- ret = spl_parse_image_header((void *)CONFIG_SYS_TEXT_BASE);
+ ret = spl_parse_image_header(&spl_image, (void *)CONFIG_SYS_TEXT_BASE);
if (ret)
return ret;
diff --git a/common/spl/spl.c b/common/spl/spl.c
index 1a4a5d8..6195c06 100644
--- a/common/spl/spl.c
+++ b/common/spl/spl.c
@@ -91,33 +91,34 @@ void spl_set_header_raw_uboot(struct spl_image_info *spl_image)
spl_image->name = "U-Boot";
}
-int spl_parse_image_header(const struct image_header *header)
+int spl_parse_image_header(struct spl_image_info *spl_image,
+ const struct image_header *header)
{
u32 header_size = sizeof(struct image_header);
if (image_get_magic(header) == IH_MAGIC) {
- if (spl_image.flags & SPL_COPY_PAYLOAD_ONLY) {
+ if (spl_image->flags & SPL_COPY_PAYLOAD_ONLY) {
/*
* On some system (e.g. powerpc), the load-address and
* entry-point is located at address 0. We can't load
* to 0-0x40. So skip header in this case.
*/
- spl_image.load_addr = image_get_load(header);
- spl_image.entry_point = image_get_ep(header);
- spl_image.size = image_get_data_size(header);
+ spl_image->load_addr = image_get_load(header);
+ spl_image->entry_point = image_get_ep(header);
+ spl_image->size = image_get_data_size(header);
} else {
- spl_image.entry_point = image_get_load(header);
+ spl_image->entry_point = image_get_load(header);
/* Load including the header */
- spl_image.load_addr = spl_image.entry_point -
+ spl_image->load_addr = spl_image->entry_point -
header_size;
- spl_image.size = image_get_data_size(header) +
+ spl_image->size = image_get_data_size(header) +
header_size;
}
- spl_image.os = image_get_os(header);
- spl_image.name = image_get_name(header);
+ spl_image->os = image_get_os(header);
+ spl_image->name = image_get_name(header);
debug("spl: payload image: %.*s load addr: 0x%x size: %d\n",
- (int)sizeof(spl_image.name), spl_image.name,
- spl_image.load_addr, spl_image.size);
+ (int)sizeof(spl_image->name), spl_image->name,
+ spl_image->load_addr, spl_image->size);
} else {
#ifdef CONFIG_SPL_PANIC_ON_RAW_IMAGE
/*
@@ -135,13 +136,13 @@ int spl_parse_image_header(const struct image_header *header)
ulong start, end;
if (!bootz_setup((ulong)header, &start, &end)) {
- spl_image.name = "Linux";
- spl_image.os = IH_OS_LINUX;
- spl_image.load_addr = CONFIG_SYS_LOAD_ADDR;
- spl_image.entry_point = CONFIG_SYS_LOAD_ADDR;
- spl_image.size = end - start;
+ spl_image->name = "Linux";
+ spl_image->os = IH_OS_LINUX;
+ spl_image->load_addr = CONFIG_SYS_LOAD_ADDR;
+ spl_image->entry_point = CONFIG_SYS_LOAD_ADDR;
+ spl_image->size = end - start;
debug("spl: payload zImage, load addr: 0x%x size: %d\n",
- spl_image.load_addr, spl_image.size);
+ spl_image->load_addr, spl_image->size);
return 0;
}
#endif
@@ -153,7 +154,7 @@ int spl_parse_image_header(const struct image_header *header)
/* Signature not found - assume u-boot.bin */
debug("mkimage signature not found - ih_magic = %x\n",
header->ih_magic);
- spl_set_header_raw_uboot(&spl_image);
+ spl_set_header_raw_uboot(spl_image);
#endif
}
return 0;
@@ -209,7 +210,7 @@ static int spl_ram_load_image(void)
header = (struct image_header *)
(CONFIG_SYS_TEXT_BASE - sizeof(struct image_header));
- spl_parse_image_header(header);
+ spl_parse_image_header(&spl_image, header);
}
return 0;
diff --git a/common/spl/spl_ext.c b/common/spl/spl_ext.c
index a85dc85..e5af24e 100644
--- a/common/spl/spl_ext.c
+++ b/common/spl/spl_ext.c
@@ -48,7 +48,7 @@ int spl_load_image_ext(struct blk_desc *block_dev,
goto end;
}
- err = spl_parse_image_header(header);
+ err = spl_parse_image_header(&spl_image, header);
if (err < 0) {
puts("spl: ext: failed to parse image header\n");
goto end;
diff --git a/common/spl/spl_fat.c b/common/spl/spl_fat.c
index 73d33f5..68702a2 100644
--- a/common/spl/spl_fat.c
+++ b/common/spl/spl_fat.c
@@ -84,7 +84,7 @@ int spl_load_image_fat(struct blk_desc *block_dev,
return spl_load_simple_fit(&load, 0, header);
} else {
- err = spl_parse_image_header(header);
+ err = spl_parse_image_header(&spl_image, header);
if (err)
goto end;
diff --git a/common/spl/spl_mmc.c b/common/spl/spl_mmc.c
index 7c7f329..97c11b3 100644
--- a/common/spl/spl_mmc.c
+++ b/common/spl/spl_mmc.c
@@ -25,7 +25,7 @@ static int mmc_load_legacy(struct mmc *mmc, ulong sector,
unsigned long count;
int ret;
- ret = spl_parse_image_header(header);
+ ret = spl_parse_image_header(&spl_image, header);
if (ret)
return ret;
diff --git a/common/spl/spl_nand.c b/common/spl/spl_nand.c
index 8f9bd5da..f25220f 100644
--- a/common/spl/spl_nand.c
+++ b/common/spl/spl_nand.c
@@ -59,7 +59,7 @@ static int spl_nand_load_element(int offset, struct image_header *header)
load.read = spl_nand_fit_read;
return spl_load_simple_fit(&load, offset, header);
} else {
- err = spl_parse_image_header(header);
+ err = spl_parse_image_header(&spl_image, header);
if (err)
return err;
return nand_spl_load_image(offset, spl_image.size,
@@ -107,7 +107,7 @@ int spl_nand_load_image(void)
/* load linux */
nand_spl_load_image(CONFIG_SYS_NAND_SPL_KERNEL_OFFS,
sizeof(*header), (void *)header);
- err = spl_parse_image_header(header);
+ err = spl_parse_image_header(&spl_image, header);
if (err)
return err;
if (header->ih_os == IH_OS_LINUX) {
diff --git a/common/spl/spl_net.c b/common/spl/spl_net.c
index ae71d26..f417d17 100644
--- a/common/spl/spl_net.c
+++ b/common/spl/spl_net.c
@@ -34,5 +34,6 @@ int spl_net_load_image(const char *device)
printf("Problem booting with BOOTP\n");
return rv;
}
- return spl_parse_image_header((struct image_header *)load_addr);
+ return spl_parse_image_header(&spl_image,
+ (struct image_header *)load_addr);
}
diff --git a/common/spl/spl_nor.c b/common/spl/spl_nor.c
index 8ea874c..57771e8 100644
--- a/common/spl/spl_nor.c
+++ b/common/spl/spl_nor.c
@@ -29,7 +29,7 @@ int spl_nor_load_image(void)
if (image_get_os(header) == IH_OS_LINUX) {
/* happy - was a Linux */
- ret = spl_parse_image_header(header);
+ ret = spl_parse_image_header(&spl_image, header);
if (ret)
return ret;
@@ -59,7 +59,7 @@ int spl_nor_load_image(void)
* Load real U-Boot from its location in NOR flash to its
* defined location in SDRAM
*/
- ret = spl_parse_image_header(
+ ret = spl_parse_image_header(&spl_image,
(const struct image_header *)CONFIG_SYS_UBOOT_BASE);
if (ret)
return ret;
diff --git a/common/spl/spl_onenand.c b/common/spl/spl_onenand.c
index 1a28a84..8d2c51b 100644
--- a/common/spl/spl_onenand.c
+++ b/common/spl/spl_onenand.c
@@ -26,7 +26,7 @@ int spl_onenand_load_image(void)
/* Load u-boot */
onenand_spl_load_image(CONFIG_SYS_ONENAND_U_BOOT_OFFS,
CONFIG_SYS_ONENAND_PAGE_SIZE, (void *)header);
- ret = spl_parse_image_header(header);
+ ret = spl_parse_image_header(&spl_image, header);
if (ret)
return ret;
onenand_spl_load_image(CONFIG_SYS_ONENAND_U_BOOT_OFFS,
diff --git a/common/spl/spl_ubi.c b/common/spl/spl_ubi.c
index f97e1ef..5198bab 100644
--- a/common/spl/spl_ubi.c
+++ b/common/spl/spl_ubi.c
@@ -54,7 +54,7 @@ int spl_ubi_load_image(u32 boot_device)
ret = ubispl_load_volumes(&info, volumes, 2);
if (!ret) {
header = (struct image_header *)volumes[0].load_addr;
- spl_parse_image_header(header);
+ spl_parse_image_header(&spl_image, header);
puts("Linux loaded.\n");
goto out;
}
@@ -68,7 +68,7 @@ int spl_ubi_load_image(u32 boot_device)
ret = ubispl_load_volumes(&info, volumes, 1);
if (!ret)
- spl_parse_image_header(header);
+ spl_parse_image_header(&spl_image, header);
out:
#ifdef CONFIG_SPL_NAND_SUPPORT
if (boot_device == BOOT_DEVICE_NAND)
diff --git a/common/spl/spl_ymodem.c b/common/spl/spl_ymodem.c
index 5402301..1323b6f 100644
--- a/common/spl/spl_ymodem.c
+++ b/common/spl/spl_ymodem.c
@@ -108,8 +108,9 @@ int spl_ymodem_load_image(void)
while ((res = xyzModem_stream_read(buf, BUF_SIZE, &err)) > 0)
size += res;
} else {
- spl_parse_image_header((struct image_header *)buf);
- ret = spl_parse_image_header((struct image_header *)buf);
+ spl_parse_image_header(&spl_image, (struct image_header *)buf);
+ ret = spl_parse_image_header(&spl_image,
+ (struct image_header *)buf);
if (ret)
return ret;
addr = spl_image.load_addr;
diff --git a/drivers/mtd/spi/spi_spl_load.c b/drivers/mtd/spi/spi_spl_load.c
index bac1e85..ac5eae3 100644
--- a/drivers/mtd/spi/spi_spl_load.c
+++ b/drivers/mtd/spi/spi_spl_load.c
@@ -32,7 +32,7 @@ static int spi_load_image_os(struct spi_flash *flash,
if (image_get_magic(header) != IH_MAGIC)
return -1;
- err = spl_parse_image_header(header);
+ err = spl_parse_image_header(&spl_image, header);
if (err)
return err;
@@ -110,7 +110,7 @@ int spl_spi_load_image(void)
CONFIG_SYS_SPI_U_BOOT_OFFS,
header);
} else {
- err = spl_parse_image_header(header);
+ err = spl_parse_image_header(&spl_image, header);
if (err)
return err;
err = spi_flash_read(flash, CONFIG_SYS_SPI_U_BOOT_OFFS,
diff --git a/drivers/mtd/spi/sunxi_spi_spl.c b/drivers/mtd/spi/sunxi_spi_spl.c
index e3ded5b..a992bfa 100644
--- a/drivers/mtd/spi/sunxi_spi_spl.c
+++ b/drivers/mtd/spi/sunxi_spi_spl.c
@@ -271,7 +271,7 @@ int spl_spi_load_image(void)
spi0_init();
spi0_read_data((void *)header, CONFIG_SYS_SPI_U_BOOT_OFFS, 0x40);
- err = spl_parse_image_header(header);
+ err = spl_parse_image_header(&spl_image, header);
if (err)
return err;
diff --git a/include/spl.h b/include/spl.h
index ce449ff..8147e6d 100644
--- a/include/spl.h
+++ b/include/spl.h
@@ -75,11 +75,27 @@ u32 spl_boot_mode(const u32 boot_device);
* config options: CONFIG_SYS_MONITOR_LEN, CONFIG_SYS_UBOOT_START,
* CONFIG_SYS_TEXT_BASE.
*
- * @spl_image: Image to set up
+ * @spl_image: Image description to set up
*/
void spl_set_header_raw_uboot(struct spl_image_info *spl_image);
-int spl_parse_image_header(const struct image_header *header);
+/**
+ * spl_parse_image_header() - parse the image header and set up info
+ *
+ * This parses the legacy image header information at @header and sets up
+ * @spl_image according to what is found. If no image header is found, then
+ * a raw image or bootz is assumed. If CONFIG_SPL_PANIC_ON_RAW_IMAGE is
+ * enabled, then this causes a panic. If CONFIG_SPL_ABORT_ON_RAW_IMAGE is
+ * enabled then U-Boot gives up. Otherwise U-Boot sets up the image using
+ * spl_set_header_raw_uboot(), or possibly the bootz header.
+ *
+ * @spl_image: Image description to set up
+ * @header image header to parse
+ * @return 0 if a header was correctly parsed, -ve on error
+ */
+int spl_parse_image_header(struct spl_image_info *spl_image,
+ const struct image_header *header);
+
void spl_board_prepare_for_linux(void);
void spl_board_prepare_for_boot(void);
int spl_board_ubi_load_image(u32 boot_device);
--
2.8.0.rc3.226.g39d4020
next prev parent reply other threads:[~2016-09-18 19:44 UTC|newest]
Thread overview: 47+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-18 19:44 [U-Boot] [PATCH 00/27] spl: Use linker list and parameters for SPL image loading Simon Glass
2016-09-18 19:44 ` [U-Boot] [PATCH 01/27] spl: Move spl_board_load_image() into a generic header Simon Glass
2016-09-18 22:14 ` Tom Rini
2016-09-18 19:44 ` [U-Boot] [PATCH 02/27] spl: Add a parameter to spl_set_header_raw_uboot() Simon Glass
2016-09-18 22:14 ` Tom Rini
2016-09-18 19:44 ` Simon Glass [this message]
2016-09-18 22:15 ` [U-Boot] [PATCH 03/27] spl: Add a parameter to spl_parse_image_header() Tom Rini
2016-09-18 19:44 ` [U-Boot] [PATCH 04/27] spl: Add a parameter to jump_to_image_linux() Simon Glass
2016-09-18 22:15 ` Tom Rini
2016-09-18 19:44 ` [U-Boot] [PATCH 05/27] spl: Add function comments to spl_start_uboot() Simon Glass
2016-09-18 22:15 ` Tom Rini
2016-09-18 19:44 ` [U-Boot] [PATCH 06/27] spl: Kconfig: Move SPL_DISPLAY_PRINT to Kconfig Simon Glass
2016-09-18 22:15 ` Tom Rini
2016-09-18 19:44 ` [U-Boot] [PATCH 07/27] spl: Convert boot_device into a struct Simon Glass
2016-09-18 22:15 ` Tom Rini
2016-09-18 19:44 ` [U-Boot] [PATCH 08/27] spl: Add a way to declare an SPL image loader Simon Glass
2016-09-18 22:15 ` Tom Rini
2016-09-19 3:22 ` Simon Glass
2016-09-18 19:44 ` [U-Boot] [PATCH 09/27] spl: Convert spl_ram_load_image() to use linker list Simon Glass
2016-09-18 19:44 ` [U-Boot] [PATCH 10/27] spl: Convert spl_mmc_load_image() " Simon Glass
2016-09-18 19:45 ` [U-Boot] [PATCH 11/27] spl: Convert spl_ubi_load_image() " Simon Glass
2016-09-18 19:45 ` [U-Boot] [PATCH 12/27] spl: Convert spl_nand_load_image() " Simon Glass
2016-09-18 19:45 ` [U-Boot] [PATCH 13/27] spl: Convert spl_onenand_load_image() " Simon Glass
2016-09-18 19:45 ` [U-Boot] [PATCH 14/27] spl: Convert spl_nor_load_image() " Simon Glass
2016-09-18 19:45 ` [U-Boot] [PATCH 15/27] spl: Convert spl_ymodem_load_image() " Simon Glass
2016-09-18 19:45 ` [U-Boot] [PATCH 16/27] spl: Convert spl_usb_load_image() " Simon Glass
2016-09-18 19:45 ` [U-Boot] [PATCH 17/27] spl: Convert spl_sata_load_image() " Simon Glass
2016-09-18 19:45 ` [U-Boot] [PATCH 18/27] spl: spi: Move the generic SPI loader into common/spl Simon Glass
2016-09-19 0:30 ` Tom Rini
2016-09-18 19:45 ` [U-Boot] [PATCH 19/27] spl: Convert spl_spi_load_image() to use linker list Simon Glass
2016-09-18 19:45 ` [U-Boot] [PATCH 20/27] spi: Move freescale-specific code into a private header Simon Glass
2016-09-18 19:45 ` [U-Boot] [PATCH 21/27] spl: Convert spl_net_load_image() to use linker list Simon Glass
2016-09-18 19:45 ` [U-Boot] [PATCH 22/27] spl: Convert spl_board_load_image() " Simon Glass
2016-09-18 19:45 ` [U-Boot] [PATCH 23/27] spl: Pass spl_image as a parameter to load_image() methods Simon Glass
2016-09-19 0:30 ` Tom Rini
2016-09-18 19:45 ` [U-Boot] [PATCH 24/27] spl: Update ext functions to take an spl_image parameter Simon Glass
2016-09-19 0:30 ` Tom Rini
2016-09-18 19:45 ` [U-Boot] [PATCH 25/27] spl: Update fat " Simon Glass
2016-09-19 0:30 ` Tom Rini
2016-09-18 19:45 ` [U-Boot] [PATCH 26/27] spl: Update spl_load_simple_fit() to take an spl_image param Simon Glass
2016-09-19 0:31 ` Tom Rini
2016-09-18 19:45 ` [U-Boot] [PATCH 27/27] spl: Make spl_boot_list a local variable Simon Glass
2016-09-19 0:31 ` Tom Rini
2016-09-18 22:14 ` [U-Boot] [PATCH 00/27] spl: Use linker list and parameters for SPL image loading Tom Rini
2016-09-19 0:57 ` Simon Glass
2016-09-19 21:46 ` Tom Rini
2016-09-19 3:18 ` Simon Glass
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=1474227917-9256-4-git-send-email-sjg@chromium.org \
--to=sjg@chromium.org \
--cc=u-boot@lists.denx.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