spl: Use linker list and parameters for SPL image loading
Subsystems (7)
cover spl: Use linker list and parameters for SPL image loading
At present the SPL code uses a global spl_image variable which is shared amongst lots of files, some in common/spl and some elsewhere. There is no need for this to be global, and in fact a parameter makes it easier to understand what information the functions act on. It also reduces the BSS use in the SPL (at the expense of stack) which is useful on boards which don't have BSS available early on.
There are many global functions for loading images from each boot device type, like spl_mmc_load_image() and spl_spi_load_image(). Mostly these take the same parameters (none or a u32). There are various rules for compiling in calls to these functions and in some cases somewhat different rules for compiling in the functions themselves. For example, spl_spi_load_image() is called if either of CONFIG_SPL_SPI_SUPPORT or CONFIG_SPL_SPI__FLASHSUPPORT is enabled, but included in the image if CONFIG_SPL_SPI_LOAD is enabled.
There is work in progress to look at that problem (Andrew F. Davis has sent some patches [1]), and this series does not address it. But even with that fixed its seems better to use a linker list and a consistent function signature for loading images.
This series converts spl_image into a parameter and moves the SPL load functions into a linker list, where each method is declared in the file that provides it. The existing dispatching code is dropped.
There is a priorty value attached to each loader which should allow the existing ordering to be maintained.
Code size is about 20 bytes larger on average which I think is acceptable. The BSS size drops by about 64 bytes, but really this just transfers to the stack.
There is an obvious follow-on from this, to move boot_name_table[] into the same linker list struct (i.e. add a name field to struct spl_image_loader). The complication here is that we don't want naming if CONFIG_SPL_LIBCOMMON_SUPPORT is not enabled, since it bloats the code. In addition I think that common/spl/spl.c can be tidied up a little.
Finally, my reading of the load functions is that they could do with some rationalisation once we have a way to init any device without subsystem-specific function calls. For example, spl_sata.c and spl_usb.c contain very similar code but for the init methods.
[1] http://patchwork.ozlabs.org/patch/662945/
Simon Glass (27):
spl: Move spl_board_load_image() into a generic header
spl: Add a parameter to spl_set_header_raw_uboot()
spl: Add a parameter to spl_parse_image_header()
spl: Add a parameter to jump_to_image_linux()
spl: Add function comments to spl_start_uboot()
spl: Kconfig: Move SPL_DISPLAY_PRINT to Kconfig
spl: Convert boot_device into a struct
spl: Add a way to declare an SPL image loader
spl: Convert spl_ram_load_image() to use linker list
spl: Convert spl_mmc_load_image() to use linker list
spl: Convert spl_ubi_load_image() to use linker list
spl: Convert spl_nand_load_image() to use linker list
spl: Convert spl_onenand_load_image() to use linker list
spl: Convert spl_nor_load_image() to use linker list
spl: Convert spl_ymodem_load_image() to use linker list
spl: Convert spl_usb_load_image() to use linker list
spl: Convert spl_sata_load_image() to use linker list
spl: spi: Move the generic SPI loader into common/spl
spl: Convert spl_spi_load_image() to use linker list
spi: Move freescale-specific code into a private header
spl: Convert spl_net_load_image() to use linker list
spl: Convert spl_board_load_image() to use linker list
spl: Pass spl_image as a parameter to load_image() methods
spl: Update ext functions to take an spl_image parameter
spl: Update fat functions to take an spl_image parameter
spl: Update spl_load_simple_fit() to take an spl_image param
spl: Make spl_boot_list a local variable
arch/arm/cpu/armv7/omap4/Kconfig | 3 + arch/arm/cpu/armv7/omap5/Kconfig | 3 + arch/arm/include/asm/spl.h | 9 -- arch/arm/lib/spl.c | 4 +- arch/arm/mach-sunxi/board.c | 6 +- arch/arm/mach-uniphier/boot-mode/spl_board.c | 10 +- arch/microblaze/cpu/spl.c | 4 +- arch/powerpc/lib/spl.c | 4 +- arch/sandbox/cpu/spl.c | 4 +- arch/sandbox/include/asm/spl.h | 8 - board/Arcturus/ucp1020/spl.c | 2 - board/freescale/common/spl.h | 13 ++ board/freescale/p1010rdb/spl.c | 3 +- board/freescale/p1022ds/spl.c | 3 +- board/freescale/p1_p2_rdb_pc/spl.c | 3 +- board/freescale/t102xqds/spl.c | 7 +- board/freescale/t102xrdb/spl.c | 7 +- board/freescale/t104xrdb/spl.c | 7 +- board/freescale/t208xqds/spl.c | 7 +- board/freescale/t208xrdb/spl.c | 7 +- common/spl/Kconfig | 9 ++ common/spl/Makefile | 1 + common/spl/spl.c | 177 ++++++++------------- common/spl/spl_ext.c | 21 +-- common/spl/spl_fat.c | 23 +-- common/spl/spl_fit.c | 9 +- common/spl/spl_mmc.c | 72 +++++---- common/spl/spl_nand.c | 37 +++-- common/spl/spl_net.c | 36 ++++- common/spl/spl_nor.c | 18 ++- common/spl/spl_onenand.c | 9 +- common/spl/spl_sata.c | 15 +- .../mtd/spi/spi_spl_load.c => common/spl/spl_spi.c | 22 +-- common/spl/spl_ubi.c | 14 +- common/spl/spl_usb.c | 17 +- common/spl/spl_ymodem.c | 13 +- drivers/mtd/spi/Makefile | 1 - drivers/mtd/spi/fsl_espi_spl.c | 4 +- drivers/mtd/spi/sunxi_spi_spl.c | 11 +- include/configs/ti_omap4_common.h | 1 - include/configs/ti_omap5_common.h | 1 - include/spi_flash.h | 3 - include/spl.h | 151 ++++++++++++++---- 43 files changed, 462 insertions(+), 317 deletions(-) create mode 100644 board/freescale/common/spl.h rename drivers/mtd/spi/spi_spl_load.c => common/spl/spl_spi.c (78%)
Signature · 1 line
2.8.0.rc3.226.g39d4020
PATCH 1/27 spl: Move spl_board_load_image() into a generic header
At present this is only used on ARM and sandbox, but it is just as applicable to other architectures. Move the function prototype into the generic SPL header.
---
arch/arm/include/asm/spl.h | 9 --------- arch/sandbox/include/asm/spl.h | 8 -------- include/spl.h | 8 ++++++++ 3 files changed, 8 insertions(+), 17 deletions(-)
arch/arm/include/asm/spl.h +0 -9
@@ -32,15 +32,6 @@ enum { };#endif -/** -* Board specific load method for boards that have a special way of loading -* U-Boot, which does not fit with the existing SPL code. -* -* @return 0 on success, negative errno value on failure. -*/ - -int spl_board_load_image (void ); -/* Linker symbols. */ extern char __bss_start[], __bss_end[];
arch/sandbox/include/asm/spl.h +0 -8
@@ -8,14 +8,6 @@#define CONFIG_SPL_BOARD_LOAD_IMAGE -/** -* Board-specific load method for boards that have a special way of loading -* U-Boot, which does not fit with the existing SPL code. -* -* @return 0 on success, negative errno value on failure. -*/ -int spl_board_load_image (void ); -enum {BOOT_DEVICE_BOARD , };
include/spl.h +8 -0
@@ -144,4 +144,12 @@ void spl_board_init(void);*/ bool spl_was_boot_source (void ); +/** +* Board-specific load method for boards that have a special way of loading +* U-Boot, which does not fit with the existing SPL code. +* +* @return 0 on success, negative errno value on failure. +*/ +int spl_board_load_image (void ); +#endif
Signature · 1 line
2.8.0.rc3.226.g39d4020
PATCH 1/27 spl: Move spl_board_load_image() into a generic header
Quoted 5 lines · Simon Glass
At present this is only used on ARM and sandbox, but it is just as applicable to other architectures. Move the function prototype into the generic SPL header.
Signed-off-by Simon Glass <[email protected]>
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160918/149e7297/attachment.sig>
PATCH 2/27 spl: Add a parameter to spl_set_header_raw_uboot()
In reply to Simon GlassRather than act on the global variable, pass the required struct in as a parameter.
---
common/spl/spl.c | 14 +++++++------- common/spl/spl_nand.c | 2 +- include/spl.h | 13 ++++++++++++- 3 files changed, 20 insertions(+), 9 deletions(-)
common/spl/spl.c +7 -7
@@ -82,13 +82,13 @@ __weak void spl_board_prepare_for_boot(void)/* Nothing to do! */ } -void spl_set_header_raw_uboot (void ) +void spl_set_header_raw_uboot (struct spl_image_info *spl_image) { - spl_image.size =CONFIG_SYS_MONITOR_LEN ; - spl_image.entry_point =CONFIG_SYS_UBOOT_START ; - spl_image.load_addr =CONFIG_SYS_TEXT_BASE ; - spl_image.os =IH_OS_U_BOOT ; - spl_image.name ="U-Boot" ; + spl_image->size =CONFIG_SYS_MONITOR_LEN ; + spl_image->entry_point =CONFIG_SYS_UBOOT_START ; + spl_image->load_addr =CONFIG_SYS_TEXT_BASE ; + spl_image->os =IH_OS_U_BOOT ; + spl_image->name ="U-Boot" ; }int spl_parse_image_header (const struct image_header *header)
@@ -153,7 +153,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_set_header_raw_uboot (&spl_image);#endif }return 0 ;
common/spl/spl_nand.c +1 -1
@@ -20,7 +20,7 @@ int spl_nand_load_image(void)nand_spl_load_image (CONFIG_SYS_NAND_U_BOOT_OFFS ,CONFIG_SYS_NAND_U_BOOT_SIZE , (void *)CONFIG_SYS_NAND_U_BOOT_DST ); -spl_set_header_raw_uboot (); +spl_set_header_raw_uboot (&spl_image);nand_deselect ();return 0 ;
include/spl.h +12 -1
@@ -67,7 +67,18 @@ extern struct spl_image_info spl_image;void preloader_console_init (void );u32 spl_boot_device (void );u32 spl_boot_mode (const u32 boot_device); -void spl_set_header_raw_uboot (void ); + +/** +* spl_set_header_raw_uboot() - Set up a standard SPL image structure +* +* This sets up the given spl_image which the standard values obtained from +* config options: CONFIG_SYS_MONITOR_LEN, CONFIG_SYS_UBOOT_START, +* CONFIG_SYS_TEXT_BASE. +* +* @spl_image: Image 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);void spl_board_prepare_for_linux (void );void spl_board_prepare_for_boot (void );
Signature · 1 line
2.8.0.rc3.226.g39d4020
PATCH 2/27 spl: Add a parameter to spl_set_header_raw_uboot()
Quoted 4 lines · Simon Glass
Rather than act on the global variable, pass the required struct in as a parameter.
Signed-off-by Simon Glass <[email protected]>
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160918/2641c4f1/attachment.sig>
PATCH 3/27 spl: Add a parameter to spl_parse_image_header()
In reply to Simon GlassInstead of using the global spl_image variable, pass the required struct in as an argument.
---
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(-)
arch/arm/mach-uniphier/boot-mode/spl_board.c +1 -1
@@ -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;
common/spl/spl.c +21 -20
81 lines not on this page · raw message
common/spl/spl_ext.c +1 -1
@@ -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;
common/spl/spl_fat.c +1 -1
@@ -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;
common/spl/spl_mmc.c +1 -1
@@ -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;
common/spl/spl_nand.c +2 -2
@@ -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 ) {
common/spl/spl_net.c +2 -1
@@ -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); }
common/spl/spl_nor.c +2 -2
@@ -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;
common/spl/spl_onenand.c +1 -1
@@ -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,
common/spl/spl_ubi.c +2 -2
@@ -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 )
common/spl/spl_ymodem.c +3 -2
@@ -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;
drivers/mtd/spi/spi_spl_load.c +2 -2
@@ -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,
drivers/mtd/spi/sunxi_spi_spl.c +1 -1
@@ -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;
include/spl.h +18 -2
@@ -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);
Signature · 1 line
2.8.0.rc3.226.g39d4020
PATCH 3/27 spl: Add a parameter to spl_parse_image_header()
Quoted 4 lines · Simon Glass
Instead of using the global
spl_imagevariable, pass the required struct in as an argument.Signed-off-by Simon Glass <[email protected]>
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160918/59f460eb/attachment.sig>
PATCH 4/27 spl: Add a parameter to jump_to_image_linux()
In reply to Simon GlassInstead of using the global spl_image variable, pass the required struct in as an argument.
---
arch/arm/lib/spl.c | 4 ++-- arch/microblaze/cpu/spl.c | 4 ++-- arch/powerpc/lib/spl.c | 4 ++-- common/spl/spl.c | 3 ++- include/spl.h | 12 +++++++++++- 5 files changed, 19 insertions(+), 8 deletions(-)
arch/arm/lib/spl.c +2 -2
@@ -47,7 +47,7 @@ void __weak board_init_f(ulong dummy)* arg: Pointer to paramter image in RAM */ #ifdef CONFIG_SPL_OS_BOOT -void __noreturn jump_to_image_linux (void *arg) +void __noreturn jump_to_image_linux (struct spl_image_info *spl_image,void *arg) {unsigned long machid =0xffffffff ;#ifdef CONFIG_MACH_TYPE
@@ -58,7 +58,7 @@ void __noreturn jump_to_image_linux(void *arg)typedef void (*image_entry_arg_t )(int ,int ,void *) __attribute__ ((noreturn));image_entry_arg_t image_entry = - (image_entry_arg_t )(uintptr_t ) spl_image.entry_point; + (image_entry_arg_t )(uintptr_t ) spl_image->entry_point;cleanup_before_linux ();image_entry (0 , machid, arg); }
arch/microblaze/cpu/spl.c +2 -2
@@ -29,13 +29,13 @@ void spl_board_init(void) }#ifdef CONFIG_SPL_OS_BOOT -void __noreturn jump_to_image_linux (void *arg) +void __noreturn jump_to_image_linux (struct spl_image_info *spl_image,void *arg) {debug ("Entering kernel arg pointer: 0x%p\n" , arg);typedef void (*image_entry_arg_t )(char *,ulong ,ulong ) __attribute__ ((noreturn));image_entry_arg_t image_entry = - (image_entry_arg_t )spl_image.entry_point; + (image_entry_arg_t )spl_image->entry_point;image_entry (NULL ,0 , (ulong )arg); }
arch/powerpc/lib/spl.c +2 -2
@@ -17,14 +17,14 @@ DECLARE_GLOBAL_DATA_PTR;* arg: Pointer to paramter image in RAM */ #ifdef CONFIG_SPL_OS_BOOT -void __noreturn jump_to_image_linux (void *arg) +void __noreturn jump_to_image_linux (struct spl_image_info *spl_image,void *arg) {debug ("Entering kernel arg pointer: 0x%p\n" , arg);typedef void (*image_entry_arg_t )(void *,ulong r4,ulong r5,ulong r6,ulong r7,ulong r8,ulong r9) __attribute__ ((noreturn));image_entry_arg_t image_entry = - (image_entry_arg_t )spl_image.entry_point; + (image_entry_arg_t )spl_image->entry_point;image_entry (arg,0 ,0 ,EPAPR_MAGIC ,CONFIG_SYS_BOOTMAPSZ ,0 ,0 ); }
common/spl/spl.c +2 -1
@@ -466,7 +466,8 @@ void board_init_r(gd_t *dummy1, ulong dummy2)case IH_OS_LINUX :debug ("Jumping to Linux\n" );spl_board_prepare_for_linux (); -jump_to_image_linux ((void *)CONFIG_SYS_SPL_ARGS_ADDR ); +jump_to_image_linux (&spl_image, + (void *)CONFIG_SYS_SPL_ARGS_ADDR );#endif default :debug ("Unsupported OS image.. Jumping nevertheless..\n" );
include/spl.h +11 -1
@@ -99,7 +99,17 @@ int spl_parse_image_header(struct spl_image_info *spl_image,void spl_board_prepare_for_linux (void );void spl_board_prepare_for_boot (void );int spl_board_ubi_load_image (u32 boot_device); -void __noreturn jump_to_image_linux (void *arg); + +/** +* jump_to_image_linux() - Jump to a Linux kernel from SPL +* +* This jumps into a Linux kernel using the information in @spl_image. +* +* @spl_image: Image description to set up +* @arg: Argument to pass to Linux (typically a device tree pointer) +*/ +void __noreturn jump_to_image_linux (struct spl_image_info *spl_image, +void *arg);int spl_start_uboot (void );void spl_display_print (void );
Signature · 1 line
2.8.0.rc3.226.g39d4020
PATCH 4/27 spl: Add a parameter to jump_to_image_linux()
Quoted 4 lines · Simon Glass
Instead of using the global
spl_imagevariable, pass the required struct in as an argument.Signed-off-by Simon Glass <[email protected]>
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160918/ff1bea16/attachment.sig>
PATCH 5/27 spl: Add function comments to spl_start_uboot()
In reply to Simon GlassAdd some comments to describe this function.
---
include/spl.h | 11 +++++++++++ 1 file changed, 11 insertions(+)
include/spl.h +11 -0
@@ -110,7 +110,18 @@ int spl_board_ubi_load_image(u32 boot_device);*/ void __noreturn jump_to_image_linux (struct spl_image_info *spl_image,void *arg); + +/** +* spl_start_uboot() - Check if SPL should start the kernel or U-Boot +* +* This is called by the various SPL loaders to determine whether the board +* wants to load the kernel or U-Boot. This function should be provided by +* the board. +* +* @return 0 if SPL should start the kernel, 1 if U-Boot must be started +*/ int spl_start_uboot (void ); +void spl_display_print (void );/* NAND SPL functions */
Signature · 1 line
2.8.0.rc3.226.g39d4020
PATCH 5/27 spl: Add function comments to spl_start_uboot()
Quoted 3 lines · Simon Glass
Add some comments to describe this function.
Signed-off-by Simon Glass <[email protected]>
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160918/5e63284a/attachment.sig>
PATCH 6/27 spl: Kconfig: Move SPL_DISPLAY_PRINT to Kconfig
In reply to Simon GlassMove this option to Kconfig and tidy up existing uses. Also add a function comment to the header file.
---
arch/arm/cpu/armv7/omap4/Kconfig | 3 +++ arch/arm/cpu/armv7/omap5/Kconfig | 3 +++ common/spl/Kconfig | 9 +++++++++ include/configs/ti_omap4_common.h | 1 - include/configs/ti_omap5_common.h | 1 - include/spl.h | 7 +++++++ 6 files changed, 22 insertions(+), 2 deletions(-)
arch/arm/cpu/armv7/omap4/Kconfig +3 -0
@@ -33,6 +33,9 @@ config SPL_POWER_SUPPORT config SPL_SERIAL_SUPPORT default y +config SPL_DISPLAY_PRINT + default y + choice prompt "OMAP4 board select" optional
arch/arm/cpu/armv7/omap5/Kconfig +3 -0
@@ -33,6 +33,9 @@ config SPL_POWER_SUPPORT config SPL_SERIAL_SUPPORT default y +config SPL_DISPLAY_PRINT + default y + choice prompt "OMAP5 board select" optional
common/spl/Kconfig +9 -0
@@ -61,6 +61,15 @@ config SPL_SEPARATE_BSS location is used. Normally we put the device tree at the end of BSS but with this option enabled, it goes at _image_binary_end. +config SPL_DISPLAY_PRINT + depends on SPL + bool "Display a board-specific message in SPL" + help + If this option is enabled, U-Boot will call the function + spl_display_print() immediately after displaying the SPL console + banner ("U-Boot SPL ..."). This function should be provided by + the board. + config TPL bool depends on SPL && SUPPORT_TPL
include/configs/ti_omap4_common.h +0 -1
@@ -151,7 +151,6 @@* So moving TEXT_BASE down to non-HS limit. */ #define CONFIG_SPL_TEXT_BASE 0x40300000 -#define CONFIG_SPL_DISPLAY_PRINT #define CONFIG_SPL_LDSCRIPT "$(CPUDIR)/omap-common/u-boot-spl.lds"#define CONFIG_SYS_SPL_ARGS_ADDR (CONFIG_SYS_SDRAM_BASE + \ (128 << 20))
include/configs/ti_omap5_common.h +0 -1
@@ -154,7 +154,6 @@#define CONFIG_SPL_TEXT_BASE 0x40300000#endif -#define CONFIG_SPL_DISPLAY_PRINT #define CONFIG_SPL_LDSCRIPT "$(CPUDIR)/omap-common/u-boot-spl.lds"#define CONFIG_SYS_SPL_ARGS_ADDR (CONFIG_SYS_SDRAM_BASE + \ (128 << 20))
include/spl.h +7 -0
@@ -122,6 +122,13 @@ void __noreturn jump_to_image_linux(struct spl_image_info *spl_image,*/ int spl_start_uboot (void ); +/** +* spl_display_print() - Display a board-specific message in SPL +* +* If CONFIG_SPL_DISPLAY_PRINT is enabled, U-Boot will call this function +* immediately after displaying the SPL console banner ("U-Boot SPL ..."). +* This function should be provided by the board. +*/ void spl_display_print (void );/* NAND SPL functions */
Signature · 1 line
2.8.0.rc3.226.g39d4020
PATCH 6/27 spl: Kconfig: Move SPL_DISPLAY_PRINT to Kconfig
Quoted 4 lines · Simon Glass
Move this option to
Kconfigand tidy up existing uses. Also add a function comment to the header file.Signed-off-by Simon Glass <[email protected]>
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160918/583e04fa/attachment.sig>
PATCH 7/27 spl: Convert boot_device into a struct
In reply to Simon GlassAt present some spl_xxx_load_image() functions take a parameter and some don't. Of those that do, most take an integer but one takes a string.
Convert this parameter into a struct so that we can pass all functions the same thing. This will allow us to use a common function signature.
---
arch/arm/mach-sunxi/board.c | 2 +- arch/arm/mach-uniphier/boot-mode/spl_board.c | 2 +- arch/sandbox/cpu/spl.c | 2 +- common/spl/spl.c | 37 ++++++++++++++----------- common/spl/spl_mmc.c | 6 ++--- common/spl/spl_nand.c | 2 +- common/spl/spl_net.c | 6 ++--- common/spl/spl_nor.c | 2 +- common/spl/spl_onenand.c | 2 +- common/spl/spl_sata.c | 2 +- common/spl/spl_ubi.c | 6 ++--- common/spl/spl_usb.c | 2 +- common/spl/spl_ymodem.c | 2 +- drivers/mtd/spi/spi_spl_load.c | 2 +- drivers/mtd/spi/sunxi_spi_spl.c | 2 +- include/spl.h | 40 ++++++++++++++++++++-------- 16 files changed, 70 insertions(+), 47 deletions(-)
arch/arm/mach-sunxi/board.c +1 -1
@@ -133,7 +133,7 @@ static int gpio_init(void)return 0 ; } -int spl_board_load_image (void ) +int spl_board_load_image (struct spl_boot_device *bootdev) {debug ("Returning to FEL sp=%x, lr=%x\n" , fel_stash.sp, fel_stash.lr);return_to_fel (fel_stash.sp, fel_stash.lr);
arch/arm/mach-uniphier/boot-mode/spl_board.c +1 -1
@@ -65,7 +65,7 @@ int uniphier_rom_get_mmc_funcptr(int (**send_cmd)(u32, u32),return 0 ; } -int spl_board_load_image (void ) +int spl_board_load_image (struct spl_boot_device *bootdev) {int (*send_cmd)(u32 cmd,u32 arg);int (*card_blockaddr)(u32 rca);
arch/sandbox/cpu/spl.c +1 -1
@@ -38,7 +38,7 @@ void spl_board_announce_boot_device(void)printf ("%s\n" , fname); } -int spl_board_load_image (void ) +int spl_board_load_image (struct spl_boot_device *bootdev) {char fname[256 ];int ret;
common/spl/spl.c +21 -16
@@ -185,7 +185,7 @@ static ulong spl_ram_load_read(struct spl_load_info *load, ulong sector,return count; } -static int spl_ram_load_image (void ) +static int spl_ram_load_image (struct spl_boot_device *bootdev) {struct image_header *header;
@@ -346,66 +346,71 @@ static inline void announce_boot_device(u32 boot_device) { }static int spl_load_image (u32 boot_device) { +struct spl_boot_device bootdev; + + bootdev.boot_device = boot_device; + bootdev.boot_device_name =NULL ; +switch (boot_device) {#ifdef CONFIG_SPL_RAM_DEVICE case BOOT_DEVICE_RAM : -return spl_ram_load_image (); +return spl_ram_load_image (&bootdev);#endif #ifdef CONFIG_SPL_MMC_SUPPORT case BOOT_DEVICE_MMC1 :case BOOT_DEVICE_MMC2 :case BOOT_DEVICE_MMC2_2 : -return spl_mmc_load_image (boot_device); +return spl_mmc_load_image (&bootdev);#endif #ifdef CONFIG_SPL_UBI case BOOT_DEVICE_NAND :case BOOT_DEVICE_ONENAND : -return spl_ubi_load_image (boot_device); +return spl_ubi_load_image (&bootdev);#else #ifdef CONFIG_SPL_NAND_SUPPORT case BOOT_DEVICE_NAND : -return spl_nand_load_image (); +return spl_nand_load_image (&bootdev);#endif #ifdef CONFIG_SPL_ONENAND_SUPPORT case BOOT_DEVICE_ONENAND : -return spl_onenand_load_image (); +return spl_onenand_load_image (&bootdev);#endif #endif #ifdef CONFIG_SPL_NOR_SUPPORT case BOOT_DEVICE_NOR : -return spl_nor_load_image (); +return spl_nor_load_image (&bootdev);#endif #ifdef CONFIG_SPL_YMODEM_SUPPORT case BOOT_DEVICE_UART : -return spl_ymodem_load_image (); +return spl_ymodem_load_image (&bootdev);#endif #if defined(CONFIG_SPL_SPI_SUPPORT ) || defined(CONFIG_SPL_SPI_FLASH_SUPPORT )case BOOT_DEVICE_SPI : -return spl_spi_load_image (); +return spl_spi_load_image (&bootdev);#endif #ifdef CONFIG_SPL_ETH_SUPPORT case BOOT_DEVICE_CPGMAC :#ifdef CONFIG_SPL_ETH_DEVICE -return spl_net_load_image (CONFIG_SPL_ETH_DEVICE ); -#else -return spl_net_load_image (NULL ); + bootdev.boot_device_name =CONFIG_SPL_ETH_DEVICE ;#endif +return spl_net_load_image (&bootdev);#endif #ifdef CONFIG_SPL_USBETH_SUPPORT case BOOT_DEVICE_USBETH : -return spl_net_load_image ("usb_ether" ); + bootdev.boot_device_name ="usb_ether" ; +return spl_net_load_image (&bootdev);#endif #ifdef CONFIG_SPL_USB_SUPPORT case BOOT_DEVICE_USB : -return spl_usb_load_image (); +return spl_usb_load_image (&bootdev);#endif #ifdef CONFIG_SPL_SATA_SUPPORT case BOOT_DEVICE_SATA : -return spl_sata_load_image (); +return spl_sata_load_image (&bootdev);#endif #ifdef CONFIG_SPL_BOARD_LOAD_IMAGE case BOOT_DEVICE_BOARD : -return spl_board_load_image (); +return spl_board_load_image (&bootdev);#endif default :#if defined(CONFIG_SPL_SERIAL_SUPPORT ) && defined(CONFIG_SPL_LIBCOMMON_SUPPORT )
common/spl/spl_mmc.c +3 -3
@@ -267,14 +267,14 @@ int spl_mmc_do_fs_boot(struct mmc *mmc) }#endif -int spl_mmc_load_image (u32 boot_device) +int spl_mmc_load_image (struct spl_boot_device *bootdev) {struct mmc *mmc =NULL ;u32 boot_mode;int err =0 ;__maybe_unused int part; - err =spl_mmc_find_device (&mmc, boot_device); + err =spl_mmc_find_device (&mmc, bootdev->boot_device);if (err)return err;
@@ -286,7 +286,7 @@ int spl_mmc_load_image(u32 boot_device)return err; } - boot_mode =spl_boot_mode (boot_device); + boot_mode =spl_boot_mode (bootdev->boot_device); err = -EINVAL ;switch (boot_mode) {case MMCSD_MODE_EMMCBOOT :
common/spl/spl_nand.c +1 -1
@@ -13,7 +13,7 @@#include <fdt.h> #if defined(CONFIG_SPL_NAND_RAW_ONLY ) -int spl_nand_load_image (void ) +int spl_nand_load_image (struct spl_boot_device *bootdev) {nand_init ();
common/spl/spl_net.c +3 -3
@@ -14,7 +14,7 @@DECLARE_GLOBAL_DATA_PTR ; -int spl_net_load_image (const char *device) +int spl_net_load_image (struct spl_boot_device *bootdev) {int rv;
@@ -27,8 +27,8 @@ int spl_net_load_image(const char *device)printf ("No Ethernet devices found\n" );return -ENODEV ; } -if (device) -setenv ("ethact" , device); +if (bootdev->boot_device_name) +setenv ("ethact" , bootdev->boot_device_name); rv =net_loop (BOOTP );if (rv <0 ) {printf ("Problem booting with BOOTP\n" );
common/spl/spl_nor.c +1 -1
@@ -7,7 +7,7 @@#include <common.h> #include <spl.h> -int spl_nor_load_image (void ) +int spl_nor_load_image (struct spl_boot_device *bootdev) {int ret;/*
common/spl/spl_onenand.c +1 -1
@@ -14,7 +14,7 @@#include <asm/io.h> #include <onenand_uboot.h> -int spl_onenand_load_image (void ) +int spl_onenand_load_image (struct spl_boot_device *bootdev) {struct image_header *header;int ret;
common/spl/spl_sata.c +1 -1
@@ -20,7 +20,7 @@DECLARE_GLOBAL_DATA_PTR ; -int spl_sata_load_image (void ) +int spl_sata_load_image (struct spl_boot_device *bootdev) {int err;struct blk_desc *stor_dev;
common/spl/spl_ubi.c +3 -3
@@ -12,14 +12,14 @@#include <ubispl.h> #include <spl.h> -int spl_ubi_load_image (u32 boot_device) +int spl_ubi_load_image (struct spl_boot_device *bootdev) {struct image_header *header;struct ubispl_info info;struct ubispl_load volumes[2 ];int ret =1 ; -switch (boot_device) { +switch (bootdev->boot_device) {#ifdef CONFIG_SPL_NAND_SUPPORT case BOOT_DEVICE_NAND :nand_init ();
@@ -71,7 +71,7 @@ int spl_ubi_load_image(u32 boot_device)spl_parse_image_header (&spl_image, header); out:#ifdef CONFIG_SPL_NAND_SUPPORT -if (boot_device ==BOOT_DEVICE_NAND ) +if (bootdev->boot_device ==BOOT_DEVICE_NAND )nand_deselect ();#endif return ret;
common/spl/spl_usb.c +1 -1
@@ -22,7 +22,7 @@ DECLARE_GLOBAL_DATA_PTR;static int usb_stor_curr_dev =-1 ;/* current device */ #endif -int spl_usb_load_image (void ) +int spl_usb_load_image (struct spl_boot_device *bootdev) {int err;struct blk_desc *stor_dev;
common/spl/spl_ymodem.c +1 -1
@@ -68,7 +68,7 @@ static ulong ymodem_read_fit(struct spl_load_info *load, ulong offset,return size; } -int spl_ymodem_load_image (void ) +int spl_ymodem_load_image (struct spl_boot_device *bootdev) {int size =0 ;int err;
drivers/mtd/spi/spi_spl_load.c +1 -1
@@ -65,7 +65,7 @@ static ulong spl_spi_fit_read(struct spl_load_info *load, ulong sector,* configured and available since this code loads the main U-Boot image * from SPI into SDRAM and starts it from there. */ -int spl_spi_load_image (void ) +int spl_spi_load_image (struct spl_boot_device *bootdev) {int err =0 ;struct spi_flash *flash;
drivers/mtd/spi/sunxi_spi_spl.c +1 -1
@@ -262,7 +262,7 @@ static void spi0_read_data(void *buf, u32 addr, u32 len)/*****************************************************************************/ -int spl_spi_load_image (void ) +int spl_spi_load_image (struct spl_boot_device *bootdev) {int err;struct image_header *header;
include/spl.h +29 -11
@@ -131,35 +131,53 @@ int spl_start_uboot(void);*/ void spl_display_print (void ); +/** +* struct spl_boot_device - Describes a boot device used by SPL +* +* @boot_device: A number indicating the BOOT_DEVICE type. There are various +* BOOT_DEVICE... #defines and enums in U-Boot and they are not consistently +* numbered. +* @boot_device_name: Named boot device, or NULL if none. +* +* Note: Additional fields can be added here, bearing in mind that SPL is +* size-sensitive and common fields will be present on all boards. This +* struct can also be used to return additional information about the load +* process if that becomes useful. +*/ +struct spl_boot_device { +uint boot_device; +const char *boot_device_name; +}; +/* NAND SPL functions */ -int spl_nand_load_image (void ); +int spl_nand_load_image (struct spl_boot_device *bootdev);/* OneNAND SPL functions */ -int spl_onenand_load_image (void ); +int spl_onenand_load_image (struct spl_boot_device *bootdev);/* NOR SPL functions */ -int spl_nor_load_image (void ); +int spl_nor_load_image (struct spl_boot_device *bootdev);/* UBI SPL functions */ -int spl_ubi_load_image (u32 boot_device); +int spl_ubi_load_image (struct spl_boot_device *bootdev);/* MMC SPL functions */ -int spl_mmc_load_image (u32 boot_device); +int spl_mmc_load_image (struct spl_boot_device *bootdev);/* YMODEM SPL functions */ -int spl_ymodem_load_image (void ); +int spl_ymodem_load_image (struct spl_boot_device *bootdev);/* SPI SPL functions */ -int spl_spi_load_image (void ); +int spl_spi_load_image (struct spl_boot_device *bootdev);/* Ethernet SPL functions */ -int spl_net_load_image (const char *device); +int spl_net_load_image (struct spl_boot_device *bootdev);/* USB SPL functions */ -int spl_usb_load_image (void ); +int spl_usb_load_image (struct spl_boot_device *bootdev);/* SATA SPL functions */ -int spl_sata_load_image (void ); +int spl_sata_load_image (struct spl_boot_device *bootdev);/* SPL FAT image functions */ int spl_load_image_fat(struct blk_desc *block_dev, int partition,
@@ -205,6 +223,6 @@ bool spl_was_boot_source(void);* * @return 0 on success, negative errno value on failure. */ -int spl_board_load_image (void ); +int spl_board_load_image (struct spl_boot_device *bootdev);#endif
Signature · 1 line
2.8.0.rc3.226.g39d4020
PATCH 7/27 spl: Convert boot_device into a struct
Quoted 7 lines · Simon Glass
At present some
spl_xxx_load_image()functions take a parameter and some don't. Of those that do, most take an integer but one takes a string.Convert this parameter into a struct so that we can pass all functions the same thing. This will allow us to use a common function signature.
Signed-off-by Simon Glass <[email protected]>
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160918/9e5ee57b/attachment.sig>
PATCH 8/27 spl: Add a way to declare an SPL image loader
In reply to Simon GlassAdd a linker list macro which can be used to declare an SPL image loader. Update spl_load_image() to search available loaders for the correct one.
---
common/spl/spl.c | 20 ++++++++++++++++++++ include/spl.h | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+)
common/spl/spl.c +20 -0
@@ -344,12 +344,32 @@ static void announce_boot_device(u32 boot_device)static inline void announce_boot_device (u32 boot_device) { }#endif +static struct spl_image_loader *spL_find_loader (uint boot_device) +{ +struct spl_image_loader *drv = + ll_entry_start(struct spl_image_loader, spl_image_loader); +const int n_ents = + ll_entry_count(struct spl_image_loader, spl_image_loader); +struct spl_image_loader *entry; + +for (entry = drv; entry != drv + n_ents; entry++) { +if (boot_device == entry->boot_device) +return entry; + } + +/* Not found */ +return NULL ; +} +static int spl_load_image (u32 boot_device) {struct spl_boot_device bootdev; +struct spl_image_loader *loader =spL_find_loader (boot_device); bootdev.boot_device = boot_device; bootdev.boot_device_name =NULL ; +if (loader) +return loader->load_image (&bootdev);switch (boot_device) {#ifdef CONFIG_SPL_RAM_DEVICE
include/spl.h +32 -0
@@ -149,6 +149,38 @@ struct spl_boot_device {const char *boot_device_name; }; +/** +* Holds information about a way of loading an SPL image +* +* @boot_device: Boot device that this loader supports +* @load_image: Function to call to load image +*/ +struct spl_image_loader { +uint boot_device; +/** +* load_image() - Load an SPL image +* +* @bootdev: describes the boot device to load from +*/ +int (*load_image)(struct spl_boot_device *bootdev); +}; + +/* Declare an SPL image loader */ +#define SPL_LOAD_IMAGE (__name) \ + ll_entry_declare(struct spl_image_loader, __name, spl_image_loader) + +/* +* __priority is the priority of this method, 0 meaning it will be the top +* choice for this device, 9 meaning it is the bottom choice. +* __boot_device is the BOOT_DEVICE_... value +* __method is the load_image function to call +*/ +#define SPL_LOAD_IMAGE_METHOD (__priority, __boot_device, __method) \ + SPL_LOAD_IMAGE(__method ## __priority ## __boot_device) = { \ + .boot_device = __boot_device, \ + .load_image = __method, \ + } +/* NAND SPL functions */ int spl_nand_load_image (struct spl_boot_device *bootdev);
Signature · 1 line
2.8.0.rc3.226.g39d4020
PATCH 8/27 spl: Add a way to declare an SPL image loader
Quoted 15 lines · Simon Glass
Add a linker list macro which can be used to declare an SPL image loader. Update
spl_load_image()to search available loaders for the correct one.Signed-off-by Simon Glass <[email protected]>---
common/spl/spl.c | 20 ++++++++++++++++++++ include/spl.h | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+)common/spl/spl.c +0
-0
common/spl/spl.c static void announce_boot_device(u32 boot_device) · line 347
Quoted 4 lines
common/spl/spl.c +1
-0@@ -344,12 +344,32 @@ static void announce_boot_device(u32 boot_device)static inline void announce_boot_device (u32 boot_device) { }#endif +static struct spl_image_loader *spL_find_loader (uint boot_device)
I don't like spL here, I mis-read that as a typo the second time I saw it. Maybe a function comment and spl_ll_find_loader ?
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160918/ba17cc95/attachment.sig>
PATCH 8/27 spl: Add a way to declare an SPL image loader
Hi Tom,
Quoted 19 lines · Tom Rini
Quoted 18 lines · Simon Glass
Add a linker list macro which can be used to declare an SPL image loader. Update
spl_load_image()to search available loaders for the correct one.Signed-off-by Simon Glass <[email protected]>---
common/spl/spl.c | 20 ++++++++++++++++++++ include/spl.h | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+)common/spl/spl.c +0
-0@@ -344,12 +344,32 @@ static void announce_boot_device(u32 boot_device)static inline void announce_boot_device (u32 boot_device) { }#endif
Quoted 4 lines
common/spl/spl.c static void announce_boot_device(u32 boot_device) · line 347
Quoted 1 line
common/spl/spl.c +1
-0+static struct spl_image_loader *spL_find_loader (uint boot_device)I don't like spL here, I mis-read that as a typo the second time I saw it. Maybe a function comment and
spl_ll_find_loader?
Oops that was a typo. Fixed, thanks.
Regards,
Simon
PATCH 9/27 spl: Convert spl_ram_load_image() to use linker list
In reply to Simon GlassAdd a linker list declaration for this method and remove the explicit switch() code.
---
common/spl/spl.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
common/spl/spl.c +1 -4
@@ -215,6 +215,7 @@ static int spl_ram_load_image(struct spl_boot_device *bootdev) return 0; } +SPL_LOAD_IMAGE_METHOD (0 ,BOOT_DEVICE_RAM , spl_ram_load_image);#endif int spl_init (void )
@@ -372,10 +373,6 @@ static int spl_load_image(u32 boot_device)return loader->load_image (&bootdev);switch (boot_device) { -#ifdef CONFIG_SPL_RAM_DEVICE -case BOOT_DEVICE_RAM : -return spl_ram_load_image (&bootdev); -#endif #ifdef CONFIG_SPL_MMC_SUPPORT case BOOT_DEVICE_MMC1 :case BOOT_DEVICE_MMC2 :
Signature · 1 line
2.8.0.rc3.226.g39d4020
PATCH 10/27 spl: Convert spl_mmc_load_image() to use linker list
In reply to Simon GlassAdd a linker list declaration for this method and remove the explicit switch() code.
---
common/spl/spl.c | 6 ------ common/spl/spl_mmc.c | 6 +++++- include/spl.h | 3 --- 3 files changed, 5 insertions(+), 10 deletions(-)
common/spl/spl.c +0 -6
@@ -373,12 +373,6 @@ static int spl_load_image(u32 boot_device)return loader->load_image (&bootdev);switch (boot_device) { -#ifdef CONFIG_SPL_MMC_SUPPORT -case BOOT_DEVICE_MMC1 : -case BOOT_DEVICE_MMC2 : -case BOOT_DEVICE_MMC2_2 : -return spl_mmc_load_image (&bootdev); -#endif #ifdef CONFIG_SPL_UBI case BOOT_DEVICE_NAND :case BOOT_DEVICE_ONENAND :
common/spl/spl_mmc.c +5 -1
@@ -267,7 +267,7 @@ int spl_mmc_do_fs_boot(struct mmc *mmc) }#endif -int spl_mmc_load_image (struct spl_boot_device *bootdev) +static int spl_mmc_load_image (struct spl_boot_device *bootdev) {struct mmc *mmc =NULL ;u32 boot_mode;
@@ -345,3 +345,7 @@ int spl_mmc_load_image(struct spl_boot_device *bootdev)return err; } + +SPL_LOAD_IMAGE_METHOD (0 ,BOOT_DEVICE_MMC1 , spl_mmc_load_image); +SPL_LOAD_IMAGE_METHOD (0 ,BOOT_DEVICE_MMC2 , spl_mmc_load_image); +SPL_LOAD_IMAGE_METHOD (0 ,BOOT_DEVICE_MMC2_2 , spl_mmc_load_image);
include/spl.h +0 -3
@@ -193,9 +193,6 @@ int spl_nor_load_image(struct spl_boot_device *bootdev);/* UBI SPL functions */ int spl_ubi_load_image (struct spl_boot_device *bootdev); -/* MMC SPL functions */ -int spl_mmc_load_image (struct spl_boot_device *bootdev); -/* YMODEM SPL functions */ int spl_ymodem_load_image (struct spl_boot_device *bootdev);
Signature · 1 line
2.8.0.rc3.226.g39d4020
PATCH 11/27 spl: Convert spl_ubi_load_image() to use linker list
In reply to Simon GlassAdd a linker list declaration for this method and remove the explicit switch() code.
---
common/spl/spl.c | 6 ------ common/spl/spl_ubi.c | 3 +++ include/spl.h | 3 --- 3 files changed, 3 insertions(+), 9 deletions(-)
common/spl/spl.c +0 -6
@@ -373,11 +373,6 @@ static int spl_load_image(u32 boot_device)return loader->load_image (&bootdev);switch (boot_device) { -#ifdef CONFIG_SPL_UBI -case BOOT_DEVICE_NAND : -case BOOT_DEVICE_ONENAND : -return spl_ubi_load_image (&bootdev); -#else #ifdef CONFIG_SPL_NAND_SUPPORT case BOOT_DEVICE_NAND :return spl_nand_load_image (&bootdev);
@@ -386,7 +381,6 @@ static int spl_load_image(u32 boot_device)case BOOT_DEVICE_ONENAND :return spl_onenand_load_image (&bootdev);#endif -#endif #ifdef CONFIG_SPL_NOR_SUPPORT case BOOT_DEVICE_NOR :return spl_nor_load_image (&bootdev);
common/spl/spl_ubi.c +3 -0
@@ -76,3 +76,6 @@ out:#endif return ret; } +/* Use priorty 0 so that Ubi will override NAND and ONENAND methods */ +SPL_LOAD_IMAGE_METHOD (0 ,BOOT_DEVICE_NAND , spl_ubi_load_image); +SPL_LOAD_IMAGE_METHOD (0 ,BOOT_DEVICE_ONENAND , spl_ubi_load_image);
include/spl.h +0 -3
@@ -190,9 +190,6 @@ int spl_onenand_load_image(struct spl_boot_device *bootdev);/* NOR SPL functions */ int spl_nor_load_image (struct spl_boot_device *bootdev); -/* UBI SPL functions */ -int spl_ubi_load_image (struct spl_boot_device *bootdev); -/* YMODEM SPL functions */ int spl_ymodem_load_image (struct spl_boot_device *bootdev);
Signature · 1 line
2.8.0.rc3.226.g39d4020
PATCH 12/27 spl: Convert spl_nand_load_image() to use linker list
In reply to Simon GlassAdd a linker list declaration for this method and remove the explicit switch() code.
---
common/spl/spl.c | 4 ---- common/spl/spl_nand.c | 4 +++- include/spl.h | 3 --- 3 files changed, 3 insertions(+), 8 deletions(-)
common/spl/spl.c +0 -4
@@ -373,10 +373,6 @@ static int spl_load_image(u32 boot_device)return loader->load_image (&bootdev);switch (boot_device) { -#ifdef CONFIG_SPL_NAND_SUPPORT -case BOOT_DEVICE_NAND : -return spl_nand_load_image (&bootdev); -#endif #ifdef CONFIG_SPL_ONENAND_SUPPORT case BOOT_DEVICE_ONENAND :return spl_onenand_load_image (&bootdev);
common/spl/spl_nand.c +3 -1
@@ -67,7 +67,7 @@ static int spl_nand_load_element(int offset, struct image_header *header) } } -int spl_nand_load_image (void ) +static int spl_nand_load_image (struct spl_boot_device *bootdev) {int err;struct image_header *header;
@@ -145,3 +145,5 @@ int spl_nand_load_image(void) return err; }#endif +/* Use priorty 1 so that Ubi can override this */ +SPL_LOAD_IMAGE_METHOD (1 ,BOOT_DEVICE_NAND , spl_nand_load_image);
include/spl.h +0 -3
@@ -181,9 +181,6 @@ struct spl_image_loader { .load_image = __method, \ } -/* NAND SPL functions */ -int spl_nand_load_image (struct spl_boot_device *bootdev); -/* OneNAND SPL functions */ int spl_onenand_load_image (struct spl_boot_device *bootdev);
Signature · 1 line
2.8.0.rc3.226.g39d4020
PATCH 13/27 spl: Convert spl_onenand_load_image() to use linker list
In reply to Simon GlassAdd a linker list declaration for this method and remove the explicit switch() code.
---
common/spl/spl.c | 4 ---- common/spl/spl_onenand.c | 4 +++- include/spl.h | 3 --- 3 files changed, 3 insertions(+), 8 deletions(-)
common/spl/spl.c +0 -4
@@ -373,10 +373,6 @@ static int spl_load_image(u32 boot_device)return loader->load_image (&bootdev);switch (boot_device) { -#ifdef CONFIG_SPL_ONENAND_SUPPORT -case BOOT_DEVICE_ONENAND : -return spl_onenand_load_image (&bootdev); -#endif #ifdef CONFIG_SPL_NOR_SUPPORT case BOOT_DEVICE_NOR :return spl_nor_load_image (&bootdev);
common/spl/spl_onenand.c +3 -1
@@ -14,7 +14,7 @@#include <asm/io.h> #include <onenand_uboot.h> -int spl_onenand_load_image (struct spl_boot_device *bootdev) +static int spl_onenand_load_image (struct spl_boot_device *bootdev) {struct image_header *header;int ret;
@@ -34,3 +34,5 @@ int spl_onenand_load_image(struct spl_boot_device *bootdev)return 0 ; } +/* Use priorty 1 so that Ubi can override this */ +SPL_LOAD_IMAGE_METHOD (1 ,BOOT_DEVICE_ONENAND , spl_onenand_load_image);
include/spl.h +0 -3
@@ -181,9 +181,6 @@ struct spl_image_loader { .load_image = __method, \ } -/* OneNAND SPL functions */ -int spl_onenand_load_image (struct spl_boot_device *bootdev); -/* NOR SPL functions */ int spl_nor_load_image (struct spl_boot_device *bootdev);
Signature · 1 line
2.8.0.rc3.226.g39d4020
PATCH 14/27 spl: Convert spl_nor_load_image() to use linker list
In reply to Simon GlassAdd a linker list declaration for this method and remove the explicit switch() code.
---
common/spl/spl.c | 4 ---- common/spl/spl_nor.c | 3 ++- include/spl.h | 3 --- 3 files changed, 2 insertions(+), 8 deletions(-)
common/spl/spl.c +0 -4
@@ -373,10 +373,6 @@ static int spl_load_image(u32 boot_device)return loader->load_image (&bootdev);switch (boot_device) { -#ifdef CONFIG_SPL_NOR_SUPPORT -case BOOT_DEVICE_NOR : -return spl_nor_load_image (&bootdev); -#endif #ifdef CONFIG_SPL_YMODEM_SUPPORT case BOOT_DEVICE_UART :return spl_ymodem_load_image (&bootdev);
common/spl/spl_nor.c +2 -1
@@ -7,7 +7,7 @@#include <common.h> #include <spl.h> -int spl_nor_load_image (struct spl_boot_device *bootdev) +static int spl_nor_load_image (struct spl_boot_device *bootdev) {int ret;/*
@@ -70,3 +70,4 @@ int spl_nor_load_image(struct spl_boot_device *bootdev)return 0 ; } +SPL_LOAD_IMAGE_METHOD (0 ,BOOT_DEVICE_NOR , spl_nor_load_image);
include/spl.h +0 -3
@@ -181,9 +181,6 @@ struct spl_image_loader { .load_image = __method, \ } -/* NOR SPL functions */ -int spl_nor_load_image (struct spl_boot_device *bootdev); -/* YMODEM SPL functions */ int spl_ymodem_load_image (struct spl_boot_device *bootdev);
Signature · 1 line
2.8.0.rc3.226.g39d4020
PATCH 15/27 spl: Convert spl_ymodem_load_image() to use linker list
In reply to Simon GlassAdd a linker list declaration for this method and remove the explicit switch() code.
---
common/spl/spl.c | 4 ---- common/spl/spl_ymodem.c | 3 ++- include/spl.h | 3 --- 3 files changed, 2 insertions(+), 8 deletions(-)
common/spl/spl.c +0 -4
@@ -373,10 +373,6 @@ static int spl_load_image(u32 boot_device)return loader->load_image (&bootdev);switch (boot_device) { -#ifdef CONFIG_SPL_YMODEM_SUPPORT -case BOOT_DEVICE_UART : -return spl_ymodem_load_image (&bootdev); -#endif #if defined(CONFIG_SPL_SPI_SUPPORT ) || defined(CONFIG_SPL_SPI_FLASH_SUPPORT )case BOOT_DEVICE_SPI :return spl_spi_load_image (&bootdev);
common/spl/spl_ymodem.c +2 -1
@@ -68,7 +68,7 @@ static ulong ymodem_read_fit(struct spl_load_info *load, ulong offset,return size; } -int spl_ymodem_load_image (struct spl_boot_device *bootdev) +static int spl_ymodem_load_image (struct spl_boot_device *bootdev) {int size =0 ;int err;
@@ -132,3 +132,4 @@ end_stream:printf ("Loaded %d bytes\n" , size);return 0 ; } +SPL_LOAD_IMAGE_METHOD (0 ,BOOT_DEVICE_UART , spl_ymodem_load_image);
include/spl.h +0 -3
@@ -181,9 +181,6 @@ struct spl_image_loader { .load_image = __method, \ } -/* YMODEM SPL functions */ -int spl_ymodem_load_image (struct spl_boot_device *bootdev); -/* SPI SPL functions */ int spl_spi_load_image (struct spl_boot_device *bootdev);
Signature · 1 line
2.8.0.rc3.226.g39d4020
PATCH 16/27 spl: Convert spl_usb_load_image() to use linker list
In reply to Simon GlassAdd a linker list declaration for this method and remove the explicit switch() code.
---
common/spl/spl.c | 4 ---- common/spl/spl_usb.c | 3 ++- include/spl.h | 3 --- 3 files changed, 2 insertions(+), 8 deletions(-)
common/spl/spl.c +0 -4
@@ -389,10 +389,6 @@ static int spl_load_image(u32 boot_device) bootdev.boot_device_name ="usb_ether" ;return spl_net_load_image (&bootdev);#endif -#ifdef CONFIG_SPL_USB_SUPPORT -case BOOT_DEVICE_USB : -return spl_usb_load_image (&bootdev); -#endif #ifdef CONFIG_SPL_SATA_SUPPORT case BOOT_DEVICE_SATA :return spl_sata_load_image (&bootdev);
common/spl/spl_usb.c +2 -1
@@ -22,7 +22,7 @@ DECLARE_GLOBAL_DATA_PTR;static int usb_stor_curr_dev =-1 ;/* current device */ #endif -int spl_usb_load_image (struct spl_boot_device *bootdev) +static int spl_usb_load_image (struct spl_boot_device *bootdev) {int err;struct blk_desc *stor_dev;
@@ -61,3 +61,4 @@ int spl_usb_load_image(struct spl_boot_device *bootdev)return 0 ; } +SPL_LOAD_IMAGE_METHOD (0 ,BOOT_DEVICE_USB , spl_usb_load_image);
include/spl.h +0 -3
@@ -187,9 +187,6 @@ int spl_spi_load_image(struct spl_boot_device *bootdev);/* Ethernet SPL functions */ int spl_net_load_image (struct spl_boot_device *bootdev); -/* USB SPL functions */ -int spl_usb_load_image (struct spl_boot_device *bootdev); -/* SATA SPL functions */ int spl_sata_load_image (struct spl_boot_device *bootdev);
Signature · 1 line
2.8.0.rc3.226.g39d4020
PATCH 17/27 spl: Convert spl_sata_load_image() to use linker list
In reply to Simon GlassAdd a linker list declaration for this method and remove the explicit switch() code.
---
common/spl/spl.c | 4 ---- common/spl/spl_sata.c | 3 ++- include/spl.h | 3 --- 3 files changed, 2 insertions(+), 8 deletions(-)
common/spl/spl.c +0 -4
@@ -389,10 +389,6 @@ static int spl_load_image(u32 boot_device) bootdev.boot_device_name ="usb_ether" ;return spl_net_load_image (&bootdev);#endif -#ifdef CONFIG_SPL_SATA_SUPPORT -case BOOT_DEVICE_SATA : -return spl_sata_load_image (&bootdev); -#endif #ifdef CONFIG_SPL_BOARD_LOAD_IMAGE case BOOT_DEVICE_BOARD :return spl_board_load_image (&bootdev);
common/spl/spl_sata.c +2 -1
@@ -20,7 +20,7 @@DECLARE_GLOBAL_DATA_PTR ; -int spl_sata_load_image (struct spl_boot_device *bootdev) +static int spl_sata_load_image (struct spl_boot_device *bootdev) {int err;struct blk_desc *stor_dev;
@@ -53,3 +53,4 @@ int spl_sata_load_image(struct spl_boot_device *bootdev)return 0 ; } +SPL_LOAD_IMAGE_METHOD (0 ,BOOT_DEVICE_SATA , spl_sata_load_image);
include/spl.h +0 -3
@@ -187,9 +187,6 @@ int spl_spi_load_image(struct spl_boot_device *bootdev);/* Ethernet SPL functions */ int spl_net_load_image (struct spl_boot_device *bootdev); -/* SATA SPL functions */ -int spl_sata_load_image (struct spl_boot_device *bootdev); -/* SPL FAT image functions */ int spl_load_image_fat (struct blk_desc *block_dev,int partition,const char *filename);
Signature · 1 line
2.8.0.rc3.226.g39d4020
PATCH 18/27 spl: spi: Move the generic SPI loader into common/spl
In reply to Simon GlassAll the other SPL loaders are in this directory, so move the SPI one in there too.
There are two board-specific SPI loaders (fsl and sunxi). These remain in the drivers/mtd/spi directory, since they do not contain generic code.
---
common/spl/Makefile | 1 + drivers/mtd/spi/spi_spl_load.c => common/spl/spl_spi.c | 0 drivers/mtd/spi/Makefile | 1 - 3 files changed, 1 insertion(+), 1 deletion(-) rename drivers/mtd/spi/spi_spl_load.c => common/spl/spl_spi.c (100%)
common/spl/Makefile +1 -0
@@ -24,4 +24,5 @@ obj-$(CONFIG_SPL_USB_SUPPORT) += spl_usb.o obj-$(CONFIG_SPL_FAT_SUPPORT) += spl_fat.o obj-$(CONFIG_SPL_EXT_SUPPORT) += spl_ext.o obj-$(CONFIG_SPL_SATA_SUPPORT) += spl_sata.o +obj-$(CONFIG_SPL_SPI_LOAD) += spl_spi.o endif
common/spl/spl_spi.c renamed from drivers/mtd/spi/spi_spl_load.c +0 -0
drivers/mtd/spi/Makefile +0 -1
@@ -8,7 +8,6 @@ obj-$(CONFIG_DM_SPI_FLASH) += sf-uclass.o ifdef CONFIG_SPL_BUILD -obj-$(CONFIG_SPL_SPI_LOAD) += spi_spl_load.o obj-$(CONFIG_SPL_SPI_BOOT) += fsl_espi_spl.o obj-$(CONFIG_SPL_SPI_SUNXI) += sunxi_spi_spl.o endif
Signature · 1 line
2.8.0.rc3.226.g39d4020
PATCH 18/27 spl: spi: Move the generic SPI loader into common/spl
Quoted 7 lines · Simon Glass
All the other SPL loaders are in this directory, so move the SPI one in there too.
There are two board-specific SPI loaders (fsl and sunxi). These remain in the
drivers/mtd/spidirectory, since they do not contain generic code.Signed-off-by Simon Glass <[email protected]>
I think this was probably a historical mistake, so..
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160918/4567899e/attachment.sig>
PATCH 19/27 spl: Convert spl_spi_load_image() to use linker list
In reply to Simon GlassAdd a linker list declaration for this method and remove the explicit switch() code. Also set up the sunxi function.
---
common/spl/spl.c | 4 ---- common/spl/spl_spi.c | 4 +++- drivers/mtd/spi/sunxi_spi_spl.c | 4 +++- include/spl.h | 3 --- 4 files changed, 6 insertions(+), 9 deletions(-)
common/spl/spl.c +0 -4
@@ -373,10 +373,6 @@ static int spl_load_image(u32 boot_device)return loader->load_image (&bootdev);switch (boot_device) { -#if defined(CONFIG_SPL_SPI_SUPPORT ) || defined(CONFIG_SPL_SPI_FLASH_SUPPORT ) -case BOOT_DEVICE_SPI : -return spl_spi_load_image (&bootdev); -#endif #ifdef CONFIG_SPL_ETH_SUPPORT case BOOT_DEVICE_CPGMAC :#ifdef CONFIG_SPL_ETH_DEVICE
common/spl/spl_spi.c +3 -1
@@ -65,7 +65,7 @@ static ulong spl_spi_fit_read(struct spl_load_info *load, ulong sector,* configured and available since this code loads the main U-Boot image * from SPI into SDRAM and starts it from there. */ -int spl_spi_load_image (struct spl_boot_device *bootdev) +static int spl_spi_load_image (struct spl_boot_device *bootdev) {int err =0 ;struct spi_flash *flash;
@@ -121,3 +121,5 @@ int spl_spi_load_image(struct spl_boot_device *bootdev)return err; } +/* Use priorty 1 so that boards can override this */ +SPL_LOAD_IMAGE_METHOD (1 ,BOOT_DEVICE_SPI , spl_spi_load_image);
drivers/mtd/spi/sunxi_spi_spl.c +3 -1
@@ -262,7 +262,7 @@ static void spi0_read_data(void *buf, u32 addr, u32 len)/*****************************************************************************/ -int spl_spi_load_image (struct spl_boot_device *bootdev) +static int spl_spi_load_image (struct spl_boot_device *bootdev) {int err;struct image_header *header;
@@ -281,3 +281,5 @@ int spl_spi_load_image(struct spl_boot_device *bootdev)spi0_deinit ();return 0 ; } +/* Use priorty 0 to override the default if it happens to be linked in */ +SPL_LOAD_IMAGE_METHOD (0 ,BOOT_DEVICE_SPI , spl_spi_load_image);
include/spl.h +0 -3
@@ -181,9 +181,6 @@ struct spl_image_loader { .load_image = __method, \ } -/* SPI SPL functions */ -int spl_spi_load_image (struct spl_boot_device *bootdev); -/* Ethernet SPL functions */ int spl_net_load_image (struct spl_boot_device *bootdev);
Signature · 1 line
2.8.0.rc3.226.g39d4020
PATCH 20/27 spi: Move freescale-specific code into a private header
In reply to Simon GlassAt present there are two SPI functions only used by freescale which are defined in the spi_flash.h header. One function name matches an existing generic SPL function.
Move these into a private header to avoid confusion.
Arcturus looks like it does not actually support SPI, so drop the SPI code from that board.
---
board/Arcturus/ucp1020/spl.c | 2 -- board/freescale/common/spl.h | 13 +++++++++++++ board/freescale/p1010rdb/spl.c | 3 ++- board/freescale/p1022ds/spl.c | 3 ++- board/freescale/p1_p2_rdb_pc/spl.c | 3 ++- board/freescale/t102xqds/spl.c | 7 ++++--- board/freescale/t102xrdb/spl.c | 7 ++++--- board/freescale/t104xrdb/spl.c | 7 ++++--- board/freescale/t208xqds/spl.c | 7 ++++--- board/freescale/t208xrdb/spl.c | 7 ++++--- drivers/mtd/spi/fsl_espi_spl.c | 4 ++-- include/spi_flash.h | 3 --- 12 files changed, 41 insertions(+), 25 deletions(-) create mode 100644 board/freescale/common/spl.h
board/Arcturus/ucp1020/spl.c +0 -2
@@ -119,8 +119,6 @@ void board_init_r(gd_t *gd, ulong dest_addr)#ifdef CONFIG_SPL_MMC_BOOT mmc_boot (); -#elif defined(CONFIG_SPL_SPI_BOOT ) -spi_boot ();#elif defined(CONFIG_SPL_NAND_BOOT )nand_boot ();#endif
board/freescale/common/spl.h new file +13 -0
@@ -0,0 +1,13 @@ +/* +* Copyright 2016 Google, Inc +* +* SPDX-License-Identifier: GPL-2.0+ +*/ + +#ifndef __FREESCALE_BOARD_SPL_H +#define __FREESCALE_BOARD_SPL_H + +void fsl_spi_spl_load_image (uint32_t offs,unsigned int size,void *vdst); +void fsl_spi_boot (void )__noreturn ; + +#endif
board/freescale/p1010rdb/spl.c +2 -1
@@ -12,6 +12,7 @@#include <i2c.h> #include <fsl_esdhc.h> #include <spi_flash.h> +#include "../common/spl.h" DECLARE_GLOBAL_DATA_PTR ;
@@ -103,7 +104,7 @@ void board_init_r(gd_t *gd, ulong dest_addr)#ifdef CONFIG_SPL_MMC_BOOT mmc_boot ();#elif defined(CONFIG_SPL_SPI_BOOT ) -spi_boot (); +fsl_spi_boot ();#elif defined(CONFIG_SPL_NAND_BOOT )nand_boot ();#endif
board/freescale/p1022ds/spl.c +2 -1
@@ -14,6 +14,7 @@#include "../common/ngpixis.h" #include <fsl_esdhc.h> #include <spi_flash.h> +#include "../common/spl.h" DECLARE_GLOBAL_DATA_PTR ;
@@ -120,7 +121,7 @@ void board_init_r(gd_t *gd, ulong dest_addr)#ifdef CONFIG_SPL_MMC_BOOT mmc_boot ();#elif defined(CONFIG_SPL_SPI_BOOT ) -spi_boot (); +fsl_spi_boot ();#elif defined(CONFIG_SPL_NAND_BOOT )nand_boot ();#endif
board/freescale/p1_p2_rdb_pc/spl.c +2 -1
@@ -13,6 +13,7 @@#include <i2c.h> #include <fsl_esdhc.h> #include <spi_flash.h> +#include "../common/spl.h" DECLARE_GLOBAL_DATA_PTR ;
@@ -117,7 +118,7 @@ void board_init_r(gd_t *gd, ulong dest_addr)#ifdef CONFIG_SPL_MMC_BOOT mmc_boot ();#elif defined(CONFIG_SPL_SPI_BOOT ) -spi_boot (); +fsl_spi_boot ();#elif defined(CONFIG_SPL_NAND_BOOT )nand_boot ();#endif
board/freescale/t102xqds/spl.c +4 -3
@@ -14,6 +14,7 @@#include <spi_flash.h> #include "../common/qixis.h" #include "t102xqds_qixis.h" +#include "../common/spl.h" DECLARE_GLOBAL_DATA_PTR ;
@@ -132,8 +133,8 @@ void board_init_r(gd_t *gd, ulong dest_addr) (uchar *)CONFIG_ENV_ADDR);#endif #ifdef CONFIG_SPL_SPI_BOOT -spi_spl_load_image (CONFIG_ENV_OFFSET ,CONFIG_ENV_SIZE , - (uchar *)CONFIG_ENV_ADDR ); +fsl_spi_spl_load_image (CONFIG_ENV_OFFSET ,CONFIG_ENV_SIZE , + (uchar *)CONFIG_ENV_ADDR );#endif gd->env_addr = (ulong)(CONFIG_ENV_ADDR );
@@ -146,7 +147,7 @@ void board_init_r(gd_t *gd, ulong dest_addr)#ifdef CONFIG_SPL_MMC_BOOT mmc_boot ();#elif defined(CONFIG_SPL_SPI_BOOT ) -spi_boot (); +fsl_spi_boot ();#elif defined(CONFIG_SPL_NAND_BOOT )nand_boot ();#endif
board/freescale/t102xrdb/spl.c +4 -3
@@ -13,6 +13,7 @@#include <fsl_esdhc.h> #include <spi_flash.h> #include "../common/sleep.h" +#include "../common/spl.h" DECLARE_GLOBAL_DATA_PTR ;
@@ -119,8 +120,8 @@ void board_init_r(gd_t *gd, ulong dest_addr) (uchar *)CONFIG_ENV_ADDR);#endif #ifdef CONFIG_SPL_SPI_BOOT -spi_spl_load_image (CONFIG_ENV_OFFSET ,CONFIG_ENV_SIZE , - (uchar *)CONFIG_ENV_ADDR ); +fsl_spi_spl_load_image (CONFIG_ENV_OFFSET ,CONFIG_ENV_SIZE , + (uchar *)CONFIG_ENV_ADDR );#endif gd->env_addr = (ulong)(CONFIG_ENV_ADDR );
@@ -133,7 +134,7 @@ void board_init_r(gd_t *gd, ulong dest_addr)#ifdef CONFIG_SPL_MMC_BOOT mmc_boot ();#elif defined(CONFIG_SPL_SPI_BOOT ) -spi_boot (); +fsl_spi_boot ();#elif defined(CONFIG_SPL_NAND_BOOT )nand_boot ();#endif
board/freescale/t104xrdb/spl.c +4 -3
@@ -13,6 +13,7 @@#include <fsl_esdhc.h> #include <spi_flash.h> #include "../common/sleep.h" +#include "../common/spl.h" DECLARE_GLOBAL_DATA_PTR ;
@@ -114,8 +115,8 @@ void board_init_r(gd_t *gd, ulong dest_addr) (uchar *)CONFIG_ENV_ADDR);#endif #ifdef CONFIG_SPL_SPI_BOOT -spi_spl_load_image (CONFIG_ENV_OFFSET ,CONFIG_ENV_SIZE , - (uchar *)CONFIG_ENV_ADDR ); +fsl_spi_spl_load_image (CONFIG_ENV_OFFSET ,CONFIG_ENV_SIZE , + (uchar *)CONFIG_ENV_ADDR );#endif gd->env_addr = (ulong)(CONFIG_ENV_ADDR ); gd->env_valid =1 ;
@@ -129,7 +130,7 @@ void board_init_r(gd_t *gd, ulong dest_addr)#ifdef CONFIG_SPL_MMC_BOOT mmc_boot ();#elif defined(CONFIG_SPL_SPI_BOOT ) -spi_boot (); +fsl_spi_boot ();#elif defined(CONFIG_SPL_NAND_BOOT )nand_boot ();#endif
board/freescale/t208xqds/spl.c +4 -3
@@ -14,6 +14,7 @@#include <spi_flash.h> #include "../common/qixis.h" #include "t208xqds_qixis.h" +#include "../common/spl.h" DECLARE_GLOBAL_DATA_PTR ;
@@ -118,8 +119,8 @@ void board_init_r(gd_t *gd, ulong dest_addr) (uchar *)CONFIG_ENV_ADDR);#endif #ifdef CONFIG_SPL_SPI_BOOT -spi_spl_load_image (CONFIG_ENV_OFFSET ,CONFIG_ENV_SIZE , - (uchar *)CONFIG_ENV_ADDR ); +fsl_spi_spl_load_image (CONFIG_ENV_OFFSET ,CONFIG_ENV_SIZE , + (uchar *)CONFIG_ENV_ADDR );#endif gd->env_addr = (ulong)(CONFIG_ENV_ADDR );
@@ -132,7 +133,7 @@ void board_init_r(gd_t *gd, ulong dest_addr)#ifdef CONFIG_SPL_MMC_BOOT mmc_boot ();#elif defined(CONFIG_SPL_SPI_BOOT ) -spi_boot (); +fsl_spi_boot ();#elif defined(CONFIG_SPL_NAND_BOOT )nand_boot ();#endif
board/freescale/t208xrdb/spl.c +4 -3
@@ -12,6 +12,7 @@#include <mmc.h> #include <fsl_esdhc.h> #include <spi_flash.h> +#include "../common/spl.h" DECLARE_GLOBAL_DATA_PTR ;
@@ -88,8 +89,8 @@ void board_init_r(gd_t *gd, ulong dest_addr) (uchar *)CONFIG_ENV_ADDR);#endif #ifdef CONFIG_SPL_SPI_BOOT -spi_spl_load_image (CONFIG_ENV_OFFSET ,CONFIG_ENV_SIZE , - (uchar *)CONFIG_ENV_ADDR ); +fsl_spi_spl_load_image (CONFIG_ENV_OFFSET ,CONFIG_ENV_SIZE , + (uchar *)CONFIG_ENV_ADDR );#endif gd->env_addr = (ulong)(CONFIG_ENV_ADDR );
@@ -102,7 +103,7 @@ void board_init_r(gd_t *gd, ulong dest_addr)#ifdef CONFIG_SPL_MMC_BOOT mmc_boot ();#elif defined(CONFIG_SPL_SPI_BOOT ) -spi_boot (); +fsl_spi_boot ();#elif defined(CONFIG_SPL_NAND_BOOT )nand_boot ();#endif
drivers/mtd/spi/fsl_espi_spl.c +2 -2
@@ -12,7 +12,7 @@#define ESPI_BOOT_IMAGE_ADDR 0x50#define CONFIG_CFG_DATA_SECTOR 0 -void spi_spl_load_image (uint32_t offs,unsigned int size,void *vdst) +void fsl_spi_spl_load_image (uint32_t offs,unsigned int size,void *vdst) {struct spi_flash *flash;
@@ -31,7 +31,7 @@ void spi_spl_load_image(uint32_t offs, unsigned int size, void *vdst)* configured and available since this code loads the main U-Boot image * from SPI into SDRAM and starts it from there. */ -void spi_boot (void ) +void fsl_spi_boot (void ) {void (*uboot)(void )__noreturn ;u32 offset, code_len, copy_len =0 ;
include/spi_flash.h +0 -3
@@ -239,7 +239,4 @@ static inline int spi_flash_protect(struct spi_flash *flash, u32 ofs, u32 len, return flash->flash_unlock(flash, ofs, len); } -void spi_boot (void )__noreturn ; -void spi_spl_load_image (uint32_t offs,unsigned int size,void *vdst); -#endif /* _SPI_FLASH_H_ */
Signature · 1 line
2.8.0.rc3.226.g39d4020
PATCH 21/27 spl: Convert spl_net_load_image() to use linker list
In reply to Simon GlassAdd a linker list declaration for this method and remove the explicit switch() code. We need two variants - one for BOOT_DEVICE_CPGMAC and one for BOOT_DEVICE_USBETH.
---
common/spl/spl.c | 12 ------------ common/spl/spl_net.c | 26 +++++++++++++++++++++++++- include/spl.h | 3 --- 3 files changed, 25 insertions(+), 16 deletions(-)
common/spl/spl.c +0 -12
@@ -373,18 +373,6 @@ static int spl_load_image(u32 boot_device)return loader->load_image (&bootdev);switch (boot_device) { -#ifdef CONFIG_SPL_ETH_SUPPORT -case BOOT_DEVICE_CPGMAC : -#ifdef CONFIG_SPL_ETH_DEVICE - bootdev.boot_device_name =CONFIG_SPL_ETH_DEVICE ; -#endif -return spl_net_load_image (&bootdev); -#endif -#ifdef CONFIG_SPL_USBETH_SUPPORT -case BOOT_DEVICE_USBETH : - bootdev.boot_device_name ="usb_ether" ; -return spl_net_load_image (&bootdev); -#endif #ifdef CONFIG_SPL_BOARD_LOAD_IMAGE case BOOT_DEVICE_BOARD :return spl_board_load_image (&bootdev);
common/spl/spl_net.c +25 -1
@@ -14,7 +14,8 @@DECLARE_GLOBAL_DATA_PTR ; -int spl_net_load_image (struct spl_boot_device *bootdev) +#if defined(CONFIG_SPL_ETH_SUPPORT ) || defined(CONFIG_SPL_USBETH_SUPPORT ) +static int spl_net_load_image (struct spl_boot_device *bootdev) {int rv;
@@ -37,3 +38,26 @@ int spl_net_load_image(struct spl_boot_device *bootdev)return spl_parse_image_header (&spl_image, (struct image_header *)load_addr); } +#endif + +#ifdef CONFIG_SPL_ETH_SUPPORT +int spl_net_load_image_cpgmac (struct spl_boot_device *bootdev) +{ +#ifdef CONFIG_SPL_ETH_DEVICE + bootdev->boot_device_name =CONFIG_SPL_ETH_DEVICE ; +#endif + +return spl_net_load_image (bootdev); +} +SPL_LOAD_IMAGE_METHOD (0 ,BOOT_DEVICE_CPGMAC , spl_net_load_image_cpgmac); +#endif + +#ifdef CONFIG_SPL_USBETH_SUPPORT +int spl_net_load_image_usb (struct spl_boot_device *bootdev) +{ + bootdev->boot_device_name ="usb_ether" ; + +return spl_net_load_image (bootdev); +} +SPL_LOAD_IMAGE_METHOD (0 ,BOOT_DEVICE_USBETH , spl_net_load_image_usb); +#endif
include/spl.h +0 -3
@@ -181,9 +181,6 @@ struct spl_image_loader { .load_image = __method, \ } -/* Ethernet SPL functions */ -int spl_net_load_image (struct spl_boot_device *bootdev); -/* SPL FAT image functions */ int spl_load_image_fat (struct blk_desc *block_dev,int partition,const char *filename);
Signature · 1 line
2.8.0.rc3.226.g39d4020
PATCH 22/27 spl: Convert spl_board_load_image() to use linker list
In reply to Simon GlassAdd a linker list declaration for this method and remove the explicit switch() code. Update existing users.
---
arch/arm/mach-sunxi/board.c | 5 ++++- arch/arm/mach-uniphier/boot-mode/spl_board.c | 3 ++- arch/sandbox/cpu/spl.c | 3 ++- common/spl/spl.c | 13 ++----------- include/spl.h | 8 -------- 5 files changed, 10 insertions(+), 22 deletions(-)
arch/arm/mach-sunxi/board.c +4 -1
@@ -133,13 +133,16 @@ static int gpio_init(void)return 0 ; } -int spl_board_load_image (struct spl_boot_device *bootdev) +#ifdef CONFIG_SPL_BUILD +static int spl_board_load_image (struct spl_boot_device *bootdev) {debug ("Returning to FEL sp=%x, lr=%x\n" , fel_stash.sp, fel_stash.lr);return_to_fel (fel_stash.sp, fel_stash.lr);return 0 ; } +SPL_LOAD_IMAGE_METHOD (0 ,BOOT_DEVICE_BOARD , spl_board_load_image); +#endif void s_init (void ) {
arch/arm/mach-uniphier/boot-mode/spl_board.c +2 -1
@@ -65,7 +65,7 @@ int uniphier_rom_get_mmc_funcptr(int (**send_cmd)(u32, u32),return 0 ; } -int spl_board_load_image (struct spl_boot_device *bootdev) +static int spl_board_load_image (struct spl_boot_device *bootdev) {int (*send_cmd)(u32 cmd,u32 arg);int (*card_blockaddr)(u32 rca);
@@ -126,3 +126,4 @@ int spl_board_load_image(struct spl_boot_device *bootdev)return 0 ; } +SPL_LOAD_IMAGE_METHOD (0 ,BOOT_DEVICE_BOARD , spl_board_load_image);
arch/sandbox/cpu/spl.c +2 -1
@@ -38,7 +38,7 @@ void spl_board_announce_boot_device(void)printf ("%s\n" , fname); } -int spl_board_load_image (struct spl_boot_device *bootdev) +static int spl_board_load_image (struct spl_boot_device *bootdev) {char fname[256 ];int ret;
@@ -50,6 +50,7 @@ int spl_board_load_image(struct spl_boot_device *bootdev)/* Hopefully this will not return */ return os_spl_to_uboot (fname); } +SPL_LOAD_IMAGE_METHOD (0 ,BOOT_DEVICE_BOARD , spl_board_load_image);void spl_board_init (void ) {
common/spl/spl.c +2 -11
@@ -372,19 +372,10 @@ static int spl_load_image(u32 boot_device)if (loader)return loader->load_image (&bootdev); -switch (boot_device) { -#ifdef CONFIG_SPL_BOARD_LOAD_IMAGE -case BOOT_DEVICE_BOARD : -return spl_board_load_image (&bootdev); -#endif -default :#if defined(CONFIG_SPL_SERIAL_SUPPORT ) && defined(CONFIG_SPL_LIBCOMMON_SUPPORT ) -puts ("SPL: Unsupported Boot Device!\n" ); +puts ("SPL: Unsupported Boot Device!\n" );#endif -return -ENODEV ; - } - -return -EINVAL ; +return -ENODEV ; }void board_init_r (gd_t *dummy1,ulong dummy2)
include/spl.h +0 -8
@@ -219,12 +219,4 @@ void spl_board_init(void);*/ bool spl_was_boot_source (void ); -/** -* Board-specific load method for boards that have a special way of loading -* U-Boot, which does not fit with the existing SPL code. -* -* @return 0 on success, negative errno value on failure. -*/ -int spl_board_load_image (struct spl_boot_device *bootdev); -#endif
Signature · 1 line
2.8.0.rc3.226.g39d4020
PATCH 23/27 spl: Pass spl_image as a parameter to load_image() methods
In reply to Simon GlassRather than having a global variable, pass the spl_image as a parameter. This avoids BSS use, and makes it clearer what the function is actually doing.
---
arch/arm/mach-sunxi/board.c | 3 +- arch/arm/mach-uniphier/boot-mode/spl_board.c | 9 ++--- arch/sandbox/cpu/spl.c | 3 +- common/spl/spl.c | 7 ++-- common/spl/spl_mmc.c | 54 +++++++++++++++------------- common/spl/spl_nand.c | 33 +++++++++-------- common/spl/spl_net.c | 15 ++++---- common/spl/spl_nor.c | 17 ++++----- common/spl/spl_onenand.c | 7 ++-- common/spl/spl_sata.c | 3 +- common/spl/spl_spi.c | 18 +++++----- common/spl/spl_ubi.c | 7 ++-- common/spl/spl_usb.c | 3 +- common/spl/spl_ymodem.c | 9 ++--- include/spl.h | 4 ++- 15 files changed, 110 insertions(+), 82 deletions(-)
arch/arm/mach-sunxi/board.c +2 -1
@@ -134,7 +134,8 @@ static int gpio_init(void) }#ifdef CONFIG_SPL_BUILD -static int spl_board_load_image (struct spl_boot_device *bootdev) +static int spl_board_load_image (struct spl_image_info *spl_image, +struct spl_boot_device *bootdev) {debug ("Returning to FEL sp=%x, lr=%x\n" , fel_stash.sp, fel_stash.lr);return_to_fel (fel_stash.sp, fel_stash.lr);
arch/arm/mach-uniphier/boot-mode/spl_board.c +5 -4
@@ -65,7 +65,8 @@ int uniphier_rom_get_mmc_funcptr(int (**send_cmd)(u32, u32),return 0 ; } -static int spl_board_load_image (struct spl_boot_device *bootdev) +static int spl_board_load_image (struct spl_image_info *spl_image, +struct spl_boot_device *bootdev) {int (*send_cmd)(u32 cmd,u32 arg);int (*card_blockaddr)(u32 rca);
@@ -113,12 +114,12 @@ static int spl_board_load_image(struct spl_boot_device *bootdev)return ret; } - ret =spl_parse_image_header (&spl_image, (void *)CONFIG_SYS_TEXT_BASE ); + ret =spl_parse_image_header (spl_image, (void *)CONFIG_SYS_TEXT_BASE );if (ret)return ret; - ret = (*load_image)(dev_addr, spl_image.load_addr, - spl_image.size /512 ); + ret = (*load_image)(dev_addr, spl_image->load_addr, + spl_image->size /512 );if (ret) {printf ("failed to load image\n" );return ret;
arch/sandbox/cpu/spl.c +2 -1
@@ -38,7 +38,8 @@ void spl_board_announce_boot_device(void)printf ("%s\n" , fname); } -static int spl_board_load_image (struct spl_boot_device *bootdev) +static int spl_board_load_image (struct spl_image_info *spl_image, +struct spl_boot_device *bootdev) {char fname[256 ];int ret;
common/spl/spl.c +4 -3
@@ -185,7 +185,8 @@ static ulong spl_ram_load_read(struct spl_load_info *load, ulong sector,return count; } -static int spl_ram_load_image (struct spl_boot_device *bootdev) +static int spl_ram_load_image (struct spl_image_info *spl_image, +struct spl_boot_device *bootdev) {struct image_header *header;
@@ -210,7 +211,7 @@ static int spl_ram_load_image(struct spl_boot_device *bootdev) header = (struct image_header *) (CONFIG_SYS_TEXT_BASE -sizeof (struct image_header )); -spl_parse_image_header (&spl_image, header); +spl_parse_image_header (spl_image, header); }return 0 ;
@@ -370,7 +371,7 @@ static int spl_load_image(u32 boot_device) bootdev.boot_device = boot_device; bootdev.boot_device_name =NULL ;if (loader) -return loader->load_image (&bootdev); +return loader->load_image (&spl_image, &bootdev);#if defined(CONFIG_SPL_SERIAL_SUPPORT ) && defined(CONFIG_SPL_LIBCOMMON_SUPPORT )puts ("SPL: Unsupported Boot Device!\n" );
common/spl/spl_mmc.c +30 -24
162 lines not on this page · raw message
common/spl/spl_nand.c +19 -14
@@ -13,14 +13,15 @@#include <fdt.h> #if defined(CONFIG_SPL_NAND_RAW_ONLY ) -int spl_nand_load_image (struct spl_boot_device *bootdev) +int spl_nand_load_image (struct spl_image_info *spl_image, +struct spl_boot_device *bootdev) {nand_init ();nand_spl_load_image (CONFIG_SYS_NAND_U_BOOT_OFFS ,CONFIG_SYS_NAND_U_BOOT_SIZE , (void *)CONFIG_SYS_NAND_U_BOOT_DST ); -spl_set_header_raw_uboot (&spl_image); +spl_set_header_raw_uboot (spl_image);nand_deselect ();return 0 ;
@@ -39,7 +40,8 @@ static ulong spl_nand_fit_read(struct spl_load_info *load, ulong offs,return 0 ; } -static int spl_nand_load_element (int offset,struct image_header *header) +static int spl_nand_load_element (struct spl_image_info *spl_image, +int offset,struct image_header *header) {int err;
@@ -59,15 +61,16 @@ 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 (&spl_image, header); + err =spl_parse_image_header (spl_image, header);if (err)return err; -return nand_spl_load_image (offset, spl_image.size, - (void *)(ulong )spl_image.load_addr); +return nand_spl_load_image (offset, spl_image->size, + (void *)(ulong )spl_image->load_addr); } } -static int spl_nand_load_image (struct spl_boot_device *bootdev) +static int spl_nand_load_image (struct spl_image_info *spl_image, +struct spl_boot_device *bootdev) {int err;struct image_header *header;
@@ -107,15 +110,15 @@ static int spl_nand_load_image(struct spl_boot_device *bootdev)/* load linux */ nand_spl_load_image (CONFIG_SYS_NAND_SPL_KERNEL_OFFS ,sizeof (*header), (void *)header); - err =spl_parse_image_header (&spl_image, header); + err =spl_parse_image_header (spl_image, header);if (err)return err;if (header->ih_os ==IH_OS_LINUX ) {/* happy - was a linux */ err =nand_spl_load_image (CONFIG_SYS_NAND_SPL_KERNEL_OFFS , - spl_image.size, - (void *)spl_image.load_addr); + spl_image->size, + (void *)spl_image->load_addr);nand_deselect ();return err; }else {
@@ -127,17 +130,19 @@ static int spl_nand_load_image(struct spl_boot_device *bootdev) }#endif #ifdef CONFIG_NAND_ENV_DST -spl_nand_load_element (CONFIG_ENV_OFFSET , header); +spl_nand_load_element (spl_image,CONFIG_ENV_OFFSET , header);#ifdef CONFIG_ENV_OFFSET_REDUND -spl_nand_load_element (CONFIG_ENV_OFFSET_REDUND , header); +spl_nand_load_element (spl_image,CONFIG_ENV_OFFSET_REDUND , header);#endif #endif /* Load u-boot */ - err =spl_nand_load_element (CONFIG_SYS_NAND_U_BOOT_OFFS , header); + err =spl_nand_load_element (spl_image,CONFIG_SYS_NAND_U_BOOT_OFFS , + header);#ifdef CONFIG_SYS_NAND_U_BOOT_OFFS_REDUND #if CONFIG_SYS_NAND_U_BOOT_OFFS !=CONFIG_SYS_NAND_U_BOOT_OFFS_REDUND if (err) - err =spl_nand_load_element (CONFIG_SYS_NAND_U_BOOT_OFFS_REDUND , + err =spl_nand_load_element (spl_image, +CONFIG_SYS_NAND_U_BOOT_OFFS_REDUND , header);#endif #endif
common/spl/spl_net.c +9 -6
@@ -15,7 +15,8 @@DECLARE_GLOBAL_DATA_PTR ;#if defined(CONFIG_SPL_ETH_SUPPORT ) || defined(CONFIG_SPL_USBETH_SUPPORT ) -static int spl_net_load_image (struct spl_boot_device *bootdev) +static int spl_net_load_image (struct spl_image_info *spl_image, +struct spl_boot_device *bootdev) {int rv;
@@ -35,29 +36,31 @@ static int spl_net_load_image(struct spl_boot_device *bootdev)printf ("Problem booting with BOOTP\n" ); return rv; } -return spl_parse_image_header (&spl_image, +return spl_parse_image_header (spl_image, (struct image_header *)load_addr); }#endif #ifdef CONFIG_SPL_ETH_SUPPORT -int spl_net_load_image_cpgmac (struct spl_boot_device *bootdev) +int spl_net_load_image_cpgmac (struct spl_image_info *spl_image, +struct spl_boot_device *bootdev) {#ifdef CONFIG_SPL_ETH_DEVICE bootdev->boot_device_name =CONFIG_SPL_ETH_DEVICE ;#endif -return spl_net_load_image (bootdev); +return spl_net_load_image (spl_image, bootdev); }SPL_LOAD_IMAGE_METHOD (0 ,BOOT_DEVICE_CPGMAC , spl_net_load_image_cpgmac);#endif #ifdef CONFIG_SPL_USBETH_SUPPORT -int spl_net_load_image_usb (struct spl_boot_device *bootdev) +int spl_net_load_image_usb (struct spl_image_info *spl_image, +struct spl_boot_device *bootdev) { bootdev->boot_device_name ="usb_ether" ; -return spl_net_load_image (bootdev); +return spl_net_load_image (spl_image, bootdev); }SPL_LOAD_IMAGE_METHOD (0 ,BOOT_DEVICE_USBETH , spl_net_load_image_usb);#endif
common/spl/spl_nor.c +9 -8
@@ -7,14 +7,15 @@#include <common.h> #include <spl.h> -static int spl_nor_load_image (struct spl_boot_device *bootdev) +static int spl_nor_load_image (struct spl_image_info *spl_image, +struct spl_boot_device *bootdev) {int ret;/* * Loading of the payload to SDRAM is done with skipping of * the mkimage header in this SPL NOR driver */ - spl_image.flags |=SPL_COPY_PAYLOAD_ONLY ; + spl_image->flags |=SPL_COPY_PAYLOAD_ONLY ;#ifdef CONFIG_SPL_OS_BOOT if (!spl_start_uboot ()) {
@@ -29,14 +30,14 @@ static int spl_nor_load_image(struct spl_boot_device *bootdev)if (image_get_os (header) ==IH_OS_LINUX ) {/* happy - was a Linux */ - ret =spl_parse_image_header (&spl_image, header); + ret =spl_parse_image_header (spl_image, header);if (ret)return ret; -memcpy ((void *)spl_image.load_addr, +memcpy ((void *)spl_image->load_addr, (void *)(CONFIG_SYS_OS_BASE +sizeof (struct image_header )), - spl_image.size); + spl_image->size);/* * Copy DT blob (fdt) to SDRAM. Passing pointer to
@@ -59,14 +60,14 @@ static int spl_nor_load_image(struct spl_boot_device *bootdev)* Load real U-Boot from its location in NOR flash to its * defined location in SDRAM */ - ret =spl_parse_image_header (&spl_image, + ret =spl_parse_image_header (spl_image, (const struct image_header *)CONFIG_SYS_UBOOT_BASE );if (ret)return ret; -memcpy ((void *)(unsigned long )spl_image.load_addr, +memcpy ((void *)(unsigned long )spl_image->load_addr, (void *)(CONFIG_SYS_UBOOT_BASE +sizeof (struct image_header )), - spl_image.size); + spl_image->size);return 0 ; }
common/spl/spl_onenand.c +4 -3
@@ -14,7 +14,8 @@#include <asm/io.h> #include <onenand_uboot.h> -static int spl_onenand_load_image (struct spl_boot_device *bootdev) +static int spl_onenand_load_image (struct spl_image_info *spl_image, +struct spl_boot_device *bootdev) {struct image_header *header;int ret;
@@ -26,11 +27,11 @@ static int spl_onenand_load_image(struct spl_boot_device *bootdev)/* 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 (&spl_image, header); + ret =spl_parse_image_header (spl_image, header);if (ret)return ret;onenand_spl_load_image (CONFIG_SYS_ONENAND_U_BOOT_OFFS , - spl_image.size, (void *)spl_image.load_addr); + spl_image->size, (void *)spl_image->load_addr);return 0 ; }
common/spl/spl_sata.c +2 -1
@@ -20,7 +20,8 @@DECLARE_GLOBAL_DATA_PTR ; -static int spl_sata_load_image (struct spl_boot_device *bootdev) +static int spl_sata_load_image (struct spl_image_info *spl_image, +struct spl_boot_device *bootdev) {int err;struct blk_desc *stor_dev;
common/spl/spl_spi.c +10 -8
@@ -20,7 +20,8 @@* Load the kernel, check for a valid header we can parse, and if found load * the kernel and then device tree. */ -static int spi_load_image_os (struct spi_flash *flash, +static int spi_load_image_os (struct spl_image_info *spl_image, +struct spi_flash *flash,struct image_header *header) {int err;
@@ -32,12 +33,12 @@ static int spi_load_image_os(struct spi_flash *flash,if (image_get_magic (header) !=IH_MAGIC )return -1 ; - err =spl_parse_image_header (&spl_image, header); + err =spl_parse_image_header (spl_image, header);if (err)return err;spi_flash_read (flash,CONFIG_SYS_SPI_KERNEL_OFFS , - spl_image.size, (void *)spl_image.load_addr); + spl_image->size, (void *)spl_image->load_addr);/* Read device tree. */ spi_flash_read(flash, CONFIG_SYS_SPI_ARGS_OFFS,
@@ -65,7 +66,8 @@ static ulong spl_spi_fit_read(struct spl_load_info *load, ulong sector,* configured and available since this code loads the main U-Boot image * from SPI into SDRAM and starts it from there. */ -static int spl_spi_load_image (struct spl_boot_device *bootdev) +static int spl_spi_load_image (struct spl_image_info *spl_image, +struct spl_boot_device *bootdev) {int err =0 ;struct spi_flash *flash;
@@ -88,7 +90,7 @@ static int spl_spi_load_image(struct spl_boot_device *bootdev) header = (struct image_header *)(CONFIG_SYS_TEXT_BASE );#ifdef CONFIG_SPL_OS_BOOT - if (spl_start_uboot() || spi_load_image_os(flash, header)) + if (spl_start_uboot() || spi_load_image_os(spl_image, flash, header))#endif {/* Load u-boot, mkimage header is 64 bytes. */
@@ -110,12 +112,12 @@ static int spl_spi_load_image(struct spl_boot_device *bootdev)CONFIG_SYS_SPI_U_BOOT_OFFS , header); }else { - err =spl_parse_image_header (&spl_image, header); + err =spl_parse_image_header (spl_image, header);if (err)return err; err =spi_flash_read (flash,CONFIG_SYS_SPI_U_BOOT_OFFS , - spl_image.size, - (void *)spl_image.load_addr); + spl_image->size, + (void *)spl_image->load_addr); } }
common/spl/spl_ubi.c +4 -3
@@ -12,7 +12,8 @@#include <ubispl.h> #include <spl.h> -int spl_ubi_load_image (struct spl_boot_device *bootdev) +int spl_ubi_load_image (struct spl_image_info *spl_image, +struct spl_boot_device *bootdev) {struct image_header *header;struct ubispl_info info;
@@ -54,7 +55,7 @@ int spl_ubi_load_image(struct spl_boot_device *bootdev) ret =ubispl_load_volumes (&info, volumes,2 );if (!ret) { header = (struct image_header *)volumes[0 ].load_addr; -spl_parse_image_header (&spl_image, header); +spl_parse_image_header (spl_image, header);puts ("Linux loaded.\n" ); goto out; }
@@ -68,7 +69,7 @@ int spl_ubi_load_image(struct spl_boot_device *bootdev) ret =ubispl_load_volumes (&info, volumes,1 );if (!ret) -spl_parse_image_header (&spl_image, header); +spl_parse_image_header (spl_image, header); out:#ifdef CONFIG_SPL_NAND_SUPPORT if (bootdev->boot_device ==BOOT_DEVICE_NAND )
common/spl/spl_usb.c +2 -1
@@ -22,7 +22,8 @@ DECLARE_GLOBAL_DATA_PTR;static int usb_stor_curr_dev =-1 ;/* current device */ #endif -static int spl_usb_load_image (struct spl_boot_device *bootdev) +static int spl_usb_load_image (struct spl_image_info *spl_image, +struct spl_boot_device *bootdev) {int err;struct blk_desc *stor_dev;
common/spl/spl_ymodem.c +5 -4
@@ -68,7 +68,8 @@ static ulong ymodem_read_fit(struct spl_load_info *load, ulong offset,return size; } -static int spl_ymodem_load_image (struct spl_boot_device *bootdev) +static int spl_ymodem_load_image (struct spl_image_info *spl_image, +struct spl_boot_device *bootdev) {int size =0 ;int err;
@@ -108,12 +109,12 @@ static int spl_ymodem_load_image(struct spl_boot_device *bootdev)while ((res =xyzModem_stream_read (buf,BUF_SIZE , &err)) >0 ) size += res; }else { -spl_parse_image_header (&spl_image, (struct image_header *)buf); - ret =spl_parse_image_header (&spl_image, +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; + addr = spl_image->load_addr;memcpy ((void *)addr, buf, res); size += res; addr += res;
include/spl.h +3 -1
@@ -160,9 +160,11 @@ struct spl_image_loader {/** * load_image() - Load an SPL image * +* @spl_image: place to put image information * @bootdev: describes the boot device to load from */ -int (*load_image)(struct spl_boot_device *bootdev); +int (*load_image)(struct spl_image_info *spl_image, +struct spl_boot_device *bootdev); };/* Declare an SPL image loader */
Signature · 1 line
2.8.0.rc3.226.g39d4020
PATCH 23/27 spl: Pass spl_image as a parameter to load_image() methods
Quoted 5 lines · Simon Glass
Rather than having a global variable, pass the
spl_imageas a parameter. This avoids BSS use, and makes it clearer what the function is actually doing.Signed-off-by Simon Glass <[email protected]>
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160918/52782f28/attachment.sig>
PATCH 24/27 spl: Update ext functions to take an spl_image parameter
In reply to Simon GlassUpdate the ext loader to avoid using the spl_image global variable.
---
common/spl/spl_ext.c | 21 ++++++++++++--------- common/spl/spl_mmc.c | 4 ++-- drivers/mtd/spi/sunxi_spi_spl.c | 9 +++++---- include/spl.h | 6 ++++-- 4 files changed, 23 insertions(+), 17 deletions(-)
common/spl/spl_ext.c +12 -9
@@ -10,9 +10,9 @@#include <image.h> #ifdef CONFIG_SPL_EXT_SUPPORT -int spl_load_image_ext (struct blk_desc *block_dev, -int partition, -const char *filename) +int spl_load_image_ext (struct spl_image_info *spl_image, +struct blk_desc *block_dev,int partition, +const char *filename) {s32 err;struct image_header *header;
@@ -48,13 +48,13 @@ int spl_load_image_ext(struct blk_desc *block_dev, goto end; } - err =spl_parse_image_header (&spl_image, header); + err =spl_parse_image_header (spl_image, header);if (err <0 ) {puts ("spl: ext: failed to parse image header\n" ); goto end; } - err =ext4fs_read ((char *)spl_image.load_addr, filelen, &actlen); + err =ext4fs_read ((char *)spl_image->load_addr, filelen, &actlen); end: #ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
@@ -67,7 +67,8 @@ end: }#ifdef CONFIG_SPL_OS_BOOT -int spl_load_image_ext_os (struct blk_desc *block_dev,int partition) +int spl_load_image_ext_os (struct spl_image_info *spl_image, +struct blk_desc *block_dev,int partition) {int err;__maybe_unused loff_t filelen, actlen;
@@ -104,7 +105,8 @@ int spl_load_image_ext_os(struct blk_desc *block_dev, int partition) } file =getenv ("falcon_image_file" );if (file) { - err =spl_load_image_ext (block_dev, partition, file); + err =spl_load_image_ext (spl_image, block_dev, + partition, file);if (err !=0 ) {puts ("spl: falling back to default\n" ); goto defaults;
@@ -134,11 +136,12 @@ defaults: return -1; } -return spl_load_image_ext (block_dev, partition, +return spl_load_image_ext (spl_image, block_dev, partition,CONFIG_SPL_FS_LOAD_KERNEL_NAME ); }#else -int spl_load_image_ext_os (struct blk_desc *block_dev,int partition) +int spl_load_image_ext_os (struct spl_image_info *spl_image, +struct blk_desc *block_dev,int partition) {return -ENOSYS ; }
common/spl/spl_mmc.c +2 -2
@@ -245,13 +245,13 @@ static int spl_mmc_do_fs_boot(struct spl_image_info *spl_image, struct mmc *mmc)#endif #ifdef CONFIG_SPL_EXT_SUPPORT if (!spl_start_uboot ()) { - err =spl_load_image_ext_os (&mmc->block_dev, + err =spl_load_image_ext_os (spl_image, &mmc->block_dev,CONFIG_SYS_MMCSD_FS_BOOT_PARTITION );if (!err)return err; }#ifdef CONFIG_SPL_FS_LOAD_PAYLOAD_NAME - err =spl_load_image_ext (&mmc->block_dev, + err =spl_load_image_ext (spl_image, &mmc->block_dev,CONFIG_SYS_MMCSD_FS_BOOT_PARTITION ,CONFIG_SPL_FS_LOAD_PAYLOAD_NAME );if (!err)
drivers/mtd/spi/sunxi_spi_spl.c +5 -4
@@ -262,7 +262,8 @@ static void spi0_read_data(void *buf, u32 addr, u32 len)/*****************************************************************************/ -static int spl_spi_load_image (struct spl_boot_device *bootdev) +static int spl_spi_load_image (struct spl_image_info *spl_image, +struct spl_boot_device *bootdev) {int err;struct image_header *header;
@@ -271,12 +272,12 @@ static int spl_spi_load_image(struct spl_boot_device *bootdev)spi0_init ();spi0_read_data ((void *)header,CONFIG_SYS_SPI_U_BOOT_OFFS ,0x40 ); - err =spl_parse_image_header (&spl_image, header); + err =spl_parse_image_header (spl_image, header);if (err)return err; -spi0_read_data ((void *)spl_image.load_addr,CONFIG_SYS_SPI_U_BOOT_OFFS , - spl_image.size); +spi0_read_data ((void *)spl_image->load_addr,CONFIG_SYS_SPI_U_BOOT_OFFS , + spl_image->size);spi0_deinit ();return 0 ;
include/spl.h +4 -2
@@ -191,9 +191,11 @@ int spl_load_image_fat_os(struct blk_desc *block_dev, int partition);void __noreturn jump_to_image_no_args (struct spl_image_info *spl_image);/* SPL EXT image functions */ -int spl_load_image_ext (struct blk_desc *block_dev,int partition, +int spl_load_image_ext (struct spl_image_info *spl_image, +struct blk_desc *block_dev,int partition,const char *filename); -int spl_load_image_ext_os (struct blk_desc *block_dev,int partition); +int spl_load_image_ext_os (struct spl_image_info *spl_image, +struct blk_desc *block_dev,int partition);/** * spl_init() - Set up device tree and driver model in SPL if enabled
Signature · 1 line
2.8.0.rc3.226.g39d4020
PATCH 24/27 spl: Update ext functions to take an spl_image parameter
Quoted 3 lines · Simon Glass
Update the ext loader to avoid using the
spl_imageglobal variable.Signed-off-by Simon Glass <[email protected]>
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160918/dca8f51d/attachment.sig>
PATCH 25/27 spl: Update fat functions to take an spl_image parameter
In reply to Simon GlassUpdate the fat loader to avoid using the spl_image global variable.
---
common/spl/spl_fat.c | 21 ++++++++++++--------- common/spl/spl_mmc.c | 4 ++-- common/spl/spl_sata.c | 11 +++++++---- common/spl/spl_usb.c | 13 ++++++++----- include/spl.h | 6 ++++-- 5 files changed, 33 insertions(+), 22 deletions(-)
common/spl/spl_fat.c +12 -9
@@ -54,9 +54,9 @@ static ulong spl_fit_read(struct spl_load_info *load, ulong file_offset,return actread; } -int spl_load_image_fat (struct blk_desc *block_dev, -int partition, -const char *filename) +int spl_load_image_fat (struct spl_image_info *spl_image, +struct blk_desc *block_dev,int partition, +const char *filename) {int err;struct image_header *header;
@@ -84,12 +84,12 @@ int spl_load_image_fat(struct blk_desc *block_dev,return spl_load_simple_fit (&load,0 , header); }else { - err =spl_parse_image_header (&spl_image, header); + err =spl_parse_image_header (spl_image, header);if (err) goto end; err =file_fat_read (filename, - (u8 *)(uintptr_t )spl_image.load_addr,0 ); + (u8 *)(uintptr_t )spl_image->load_addr,0 ); } end:
@@ -103,7 +103,8 @@ end: }#ifdef CONFIG_SPL_OS_BOOT -int spl_load_image_fat_os (struct blk_desc *block_dev,int partition) +int spl_load_image_fat_os (struct spl_image_info *spl_image, +struct blk_desc *block_dev,int partition) {int err;__maybe_unused char *file;
@@ -123,7 +124,8 @@ int spl_load_image_fat_os(struct blk_desc *block_dev, int partition) } file =getenv ("falcon_image_file" );if (file) { - err =spl_load_image_fat (block_dev, partition, file); + err =spl_load_image_fat (spl_image, block_dev, + partition, file);if (err !=0 ) {puts ("spl: falling back to default\n" ); goto defaults;
@@ -148,11 +150,12 @@ defaults: return -1; } -return spl_load_image_fat (block_dev, partition, +return spl_load_image_fat (spl_image, block_dev, partition,CONFIG_SPL_FS_LOAD_KERNEL_NAME ); }#else -int spl_load_image_fat_os (struct blk_desc *block_dev,int partition) +int spl_load_image_fat_os (struct spl_image_info *spl_image, +struct blk_desc *block_dev,int partition) {return -ENOSYS ; }
common/spl/spl_mmc.c +2 -2
@@ -230,13 +230,13 @@ static int spl_mmc_do_fs_boot(struct spl_image_info *spl_image, struct mmc *mmc)#ifdef CONFIG_SPL_FAT_SUPPORT if (!spl_start_uboot ()) { - err =spl_load_image_fat_os (mmc_get_blk_desc (mmc), + err =spl_load_image_fat_os (spl_image,mmc_get_blk_desc (mmc),CONFIG_SYS_MMCSD_FS_BOOT_PARTITION );if (!err)return err; }#ifdef CONFIG_SPL_FS_LOAD_PAYLOAD_NAME - err =spl_load_image_fat (mmc_get_blk_desc (mmc), + err =spl_load_image_fat (spl_image,mmc_get_blk_desc (mmc),CONFIG_SYS_MMCSD_FS_BOOT_PARTITION ,CONFIG_SPL_FS_LOAD_PAYLOAD_NAME );if (!err)
common/spl/spl_sata.c +7 -4
@@ -41,12 +41,15 @@ static int spl_sata_load_image(struct spl_image_info *spl_image, }#ifdef CONFIG_SPL_OS_BOOT -if (spl_start_uboot () ||spl_load_image_fat_os (stor_dev, - CONFIG_SYS_SATA_FAT_BOOT_PARTITION)) +if (spl_start_uboot () || +spl_load_image_fat_os (spl_image, stor_dev, + CONFIG_SYS_SATA_FAT_BOOT_PARTITION))#endif - err =spl_load_image_fat (stor_dev, -CONFIG_SYS_SATA_FAT_BOOT_PARTITION , + { + err =spl_load_image_fat (spl_image, stor_dev, +CONFIG_SYS_SATA_FAT_BOOT_PARTITION ,CONFIG_SPL_FS_LOAD_PAYLOAD_NAME ); + }if (err) {puts ("Error loading sata device\n" );return err;
common/spl/spl_usb.c +8 -5
@@ -48,12 +48,15 @@ static int spl_usb_load_image(struct spl_image_info *spl_image,debug ("boot mode - FAT\n" );#ifdef CONFIG_SPL_OS_BOOT -if (spl_start_uboot () ||spl_load_image_fat_os (stor_dev, - CONFIG_SYS_USB_FAT_BOOT_PARTITION)) +if (spl_start_uboot () || +spl_load_image_fat_os (spl_image, stor_dev, + CONFIG_SYS_USB_FAT_BOOT_PARTITION))#endif - err =spl_load_image_fat (stor_dev, -CONFIG_SYS_USB_FAT_BOOT_PARTITION , -CONFIG_SPL_FS_LOAD_PAYLOAD_NAME ); + { + err =spl_load_image_fat (spl_image, stor_dev, +CONFIG_SYS_USB_FAT_BOOT_PARTITION , +CONFIG_SPL_FS_LOAD_PAYLOAD_NAME ); + }if (err) {puts ("Error loading from USB device\n" );
include/spl.h +4 -2
@@ -184,9 +184,11 @@ struct spl_image_loader { }/* SPL FAT image functions */ -int spl_load_image_fat (struct blk_desc *block_dev,int partition, +int spl_load_image_fat (struct spl_image_info *spl_image, +struct blk_desc *block_dev,int partition,const char *filename); -int spl_load_image_fat_os (struct blk_desc *block_dev,int partition); +int spl_load_image_fat_os (struct spl_image_info *spl_image, +struct blk_desc *block_dev,int partition);void __noreturn jump_to_image_no_args (struct spl_image_info *spl_image);
Signature · 1 line
2.8.0.rc3.226.g39d4020
PATCH 25/27 spl: Update fat functions to take an spl_image parameter
Quoted 3 lines · Simon Glass
Update the fat loader to avoid using the
spl_imageglobal variable.Signed-off-by Simon Glass <[email protected]>
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160918/5884a013/attachment.sig>
PATCH 26/27 spl: Update spl_load_simple_fit() to take an spl_image param
In reply to Simon GlassUpda the SPL FIT code to use the spl_image parameter.
---
common/spl/spl.c | 2 +- common/spl/spl_fat.c | 2 +- common/spl/spl_fit.c | 9 +++++---- common/spl/spl_mmc.c | 2 +- common/spl/spl_nand.c | 2 +- common/spl/spl_spi.c | 2 +- common/spl/spl_ymodem.c | 2 +- include/spl.h | 4 +++- 8 files changed, 14 insertions(+), 11 deletions(-)
common/spl/spl.c +1 -1
@@ -199,7 +199,7 @@ static int spl_ram_load_image(struct spl_image_info *spl_image,debug ("Found FIT\n" ); load.bl_len =1 ; load.read = spl_ram_load_read; -spl_load_simple_fit (&load,0 , header); +spl_load_simple_fit (spl_image, &load,0 , header); }else {debug ("Legacy image\n" );/*
common/spl/spl_fat.c +1 -1
@@ -82,7 +82,7 @@ int spl_load_image_fat(struct spl_image_info *spl_image, load.filename = (void *)filename; load.priv =NULL ; -return spl_load_simple_fit (&load,0 , header); +return spl_load_simple_fit (spl_image, &load,0 , header); }else { err =spl_parse_image_header (spl_image, header);if (err)
common/spl/spl_fit.c +5 -4
@@ -123,7 +123,8 @@ static int get_aligned_image_size(struct spl_load_info *info, int data_size,return (data_size + info->bl_len -1 ) / info->bl_len; } -int spl_load_simple_fit (struct spl_load_info *info,ulong sector,void *fit) +int spl_load_simple_fit (struct spl_image_info *spl_image, +struct spl_load_info *info,ulong sector,void *fit) {int sectors;ulong size, load;
@@ -184,9 +185,9 @@ int spl_load_simple_fit(struct spl_load_info *info, ulong sector, void *fit) data_size =fdt_getprop_u32 (fit, node,"data-size" ); load =fdt_getprop_u32 (fit, node,"load" );debug ("data_offset=%x, data_size=%x\n" , data_offset, data_size); - spl_image.load_addr = load; - spl_image.entry_point = load; - spl_image.os =IH_OS_U_BOOT ; + spl_image->load_addr = load; + spl_image->entry_point = load; + spl_image->os =IH_OS_U_BOOT ;/* * Work out where to place the image. We read it so that the first
common/spl/spl_mmc.c +1 -1
@@ -80,7 +80,7 @@ static int mmc_load_image_raw_sector(struct spl_image_info *spl_image, load.filename =NULL ; load.bl_len = mmc->read_bl_len; load.read = h_spl_load_read; - ret =spl_load_simple_fit (&load, sector, header); + ret =spl_load_simple_fit (spl_image, &load, sector, header); }else { ret =mmc_load_legacy (spl_image, mmc, sector, header); }
common/spl/spl_nand.c +1 -1
@@ -59,7 +59,7 @@ static int spl_nand_load_element(struct spl_image_info *spl_image, load.filename =NULL ; load.bl_len =1 ; load.read = spl_nand_fit_read; -return spl_load_simple_fit (&load, offset, header); +return spl_load_simple_fit (spl_image, &load, offset, header); }else { err =spl_parse_image_header (spl_image, header);if (err)
common/spl/spl_spi.c +1 -1
@@ -108,7 +108,7 @@ static int spl_spi_load_image(struct spl_image_info *spl_image, load.filename =NULL ; load.bl_len =1 ; load.read = spl_spi_fit_read; - err =spl_load_simple_fit (&load, + err =spl_load_simple_fit (spl_image, &load,CONFIG_SYS_SPI_U_BOOT_OFFS , header); }else {
common/spl/spl_ymodem.c +1 -1
@@ -103,7 +103,7 @@ static int spl_ymodem_load_image(struct spl_image_info *spl_image, info.buf = buf; info.image_read =BUF_SIZE ; load.read = ymodem_read_fit; - ret =spl_load_simple_fit (&load,0 , (void *)buf); + ret =spl_load_simple_fit (spl_image, &load,0 , (void *)buf); size = info.image_read;while ((res =xyzModem_stream_read (buf,BUF_SIZE , &err)) >0 )
include/spl.h +3 -1
@@ -49,6 +49,7 @@ struct spl_load_info {/** * spl_load_simple_fit() - Loads a fit image from a device. +* @spl_image: Image description to set up * @info: Structure containing the information required to load data. * @sector: Sector number where FIT image is located in the device * @fdt: Pointer to the copied FIT header.
@@ -57,7 +58,8 @@ struct spl_load_info {* specified load address and copies the dtb to end of u-boot image. * Returns 0 on success. */ -int spl_load_simple_fit (struct spl_load_info *info,ulong sector,void *fdt); +int spl_load_simple_fit (struct spl_image_info *spl_image, +struct spl_load_info *info,ulong sector,void *fdt);#define SPL_COPY_PAYLOAD_ONLY 1
Signature · 1 line
2.8.0.rc3.226.g39d4020
PATCH 26/27 spl: Update spl_load_simple_fit() to take an spl_image param
Quoted 3 lines · Simon Glass
Upda the SPL FIT code to use the
spl_imageparameter.Signed-off-by Simon Glass <[email protected]>
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160918/e2eb6ff4/attachment.sig>
PATCH 27/27 spl: Make spl_boot_list a local variable
In reply to Simon GlassThere is no need for this to be in the BSS region. By moving it we can delay use of BSS in SPL. This is useful for machines where the BSS region is not in writeable space. On 64-bit x86, SPL runs from SPI flash and it is easier to eliminate BSS use than link SPL to run with BSS at a particular cache-as-RAM (CAR) address.
---
common/spl/spl.c | 23 +++++++++++------------ include/spl.h | 2 -- 2 files changed, 11 insertions(+), 14 deletions(-)
common/spl/spl.c +11 -12
@@ -29,7 +29,6 @@ DECLARE_GLOBAL_DATA_PTR;#endif u32 *boot_params_ptr =NULL ; -struct spl_image_info spl_image;/* Define board data structure */ static bd_t bdata __attribute__ ((section(".data")));
@@ -255,14 +254,6 @@ int spl_init(void)#define BOOT_DEVICE_NONE 0xdeadbeef#endif -static u32 spl_boot_list[] = { -BOOT_DEVICE_NONE , -BOOT_DEVICE_NONE , -BOOT_DEVICE_NONE , -BOOT_DEVICE_NONE , -BOOT_DEVICE_NONE , -}; -__weak void board_boot_order (u32 *spl_boot_list) { spl_boot_list[0 ] =spl_boot_device ();
@@ -363,7 +354,7 @@ static struct spl_image_loader *spL_find_loader(uint boot_device)return NULL ; } -static int spl_load_image (u32 boot_device) +static int spl_load_image (struct spl_image_info *spl_image,u32 boot_device) {struct spl_boot_device bootdev;struct spl_image_loader *loader =spL_find_loader (boot_device);
@@ -371,7 +362,7 @@ static int spl_load_image(u32 boot_device) bootdev.boot_device = boot_device; bootdev.boot_device_name =NULL ;if (loader) -return loader->load_image (&spl_image, &bootdev); +return loader->load_image (spl_image, &bootdev);#if defined(CONFIG_SPL_SERIAL_SUPPORT ) && defined(CONFIG_SPL_LIBCOMMON_SUPPORT )puts ("SPL: Unsupported Boot Device!\n" );
@@ -381,6 +372,14 @@ static int spl_load_image(u32 boot_device)void board_init_r (gd_t *dummy1,ulong dummy2) { +u32 spl_boot_list[] = { +BOOT_DEVICE_NONE , +BOOT_DEVICE_NONE , +BOOT_DEVICE_NONE , +BOOT_DEVICE_NONE , +BOOT_DEVICE_NONE , + }; +struct spl_image_info spl_image;int i;debug (">>spl:board_init_r()\n" );
@@ -410,7 +409,7 @@ void board_init_r(gd_t *dummy1, ulong dummy2)for (i =0 ; i <ARRAY_SIZE (spl_boot_list) && spl_boot_list[i] !=BOOT_DEVICE_NONE ; i++) {announce_boot_device (spl_boot_list[i]); -if (!spl_load_image (spl_boot_list[i])) +if (!spl_load_image (&spl_image, spl_boot_list[i]))break ; }
include/spl.h +0 -2
@@ -63,8 +63,6 @@ int spl_load_simple_fit(struct spl_image_info *spl_image,#define SPL_COPY_PAYLOAD_ONLY 1 -extern struct spl_image_info spl_image; -/* SPL common functions */ void preloader_console_init (void );u32 spl_boot_device (void );
Signature · 1 line
2.8.0.rc3.226.g39d4020
PATCH 27/27 spl: Make spl_boot_list a local variable
Quoted 7 lines · Simon Glass
There is no need for this to be in the BSS region. By moving it we can delay use of BSS in SPL. This is useful for machines where the BSS region is not in writeable space. On 64-bit x86, SPL runs from SPI flash and it is easier to eliminate BSS use than link SPL to run with BSS at a particular cache-as-RAM (CAR) address.
Signed-off-by Simon Glass <[email protected]>
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160918/a0510caa/attachment.sig>
cover spl: Use linker list and parameters for SPL image loading
In reply to Simon GlassQuoted 6 lines · Simon Glass
At present the SPL code uses a global
spl_imagevariable which is shared amongst lots of files, some in common/spl and some elsewhere. There is no need for this to be global, and in fact a parameter makes it easier to understand what information the functions act on. It also reduces the BSS use in the SPL (at the expense of stack) which is useful on boards which don't have BSS available early on.
Thanks for taking a stab at cleaning this up.
[snip]
Quoted 2 lines
There is a priorty value attached to each loader which should allow the existing ordering to be maintained.
I worry here about some of the corner cases, but it's probably no more or less fragile than currently at least. I'm actually not sure how that's working in this version of the series, everyone gets priority 0 filled in so it seems like we're on linker order. But I'm also not convinced that it's a problem here. As far as I can recall, the use cases are that a given binary will support say NAND and MMC, and at run time knows that it came from NAND or MMC, and thus we need to look at the same device for U-Boot itself. So order doesn't matter there. So we can just drop that part I think.
Quoted 3 lines
Code size is about 20 bytes larger on average which I think is acceptable. The BSS size drops by about 64 bytes, but really this just transfers to the stack.
How about the worst case growths in what we have today?
Quoted 5 lines
There is an obvious follow-on from this, to move boot_name_table[] into the same linker list struct (i.e. add a name field to struct
spl_image_loader). The complication here is that we don't want naming ifCONFIG_SPL_LIBCOMMON_SUPPORTis not enabled, since it bloats the code. In addition I think thatcommon/spl/spl.ccan be tidied up a little.
Yeah, I worry about size growth in doing that too. But maybe we can be a little clever when declaring the ll and just not have the strings if !LIBCOMMON ?
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160918/82b41b0e/attachment.sig>
cover spl: Use linker list and parameters for SPL image loading
Hi Tom,
Quoted 10 lines · Tom Rini
Quoted 6 lines · Simon Glass
At present the SPL code uses a global
spl_imagevariable which is shared amongst lots of files, some in common/spl and some elsewhere. There is no need for this to be global, and in fact a parameter makes it easier to understand what information the functions act on. It also reduces the BSS use in the SPL (at the expense of stack) which is useful on boards which don't have BSS available early on.Thanks for taking a stab at cleaning this up.
I ran into it with the 64-bit x86 stuff and decided to take a detour :-)
Quoted 5 lines
[snip]
Quoted 2 lines
There is a priorty value attached to each loader which should allow the existing ordering to be maintained.
Quoted 9 lines
I worry here about some of the corner cases, but it's probably no more or less fragile than currently at least. I'm actually not sure how that's working in this version of the series, everyone gets priority 0 filled in so it seems like we're on linker order. But I'm also not convinced that it's a problem here. As far as I can recall, the use cases are that a given binary will support say NAND and MMC, and at run time knows that it came from NAND or MMC, and thus we need to look at the same device for U-Boot itself. So order doesn't matter there. So we can just drop that part I think.
I see in the code that if Ubifs is enabled, it uses that instead of NAND and ONENAND. There is another case too - SPI might have a board-specific loader which takes precedence (although I suspect in the sunxi case the generic loader is not present).
If these are not needed then we can drop it.
At present priority is handled by adding the priority value into the linker list element name. Since they are sorted in order within the image, this gives the required result.
Quoted 6 lines
Quoted 4 lines
Code size is about 20 bytes larger on average which I think is acceptable. The BSS size drops by about 64 bytes, but really this just transfers to the stack.
How about the worst case growths in what we have today?
Ah well that's something buildman cannot tell me! There is a small overhead for the lookup code (about 20-30 bytes) and 8-12 bytes for each loader method. Here's the buildman summary.
$ buildman -b spl -s --step 0 -S
boards.cfg is up to date. Nothing to do.
Summary of 2 commits for 1196 boards (32 threads, 1 job per thread)
01: Makefile: Give a build error if ad-hoc CONFIG options are added
blackfin: + cm-bf527 bf609-ezkit bf537-stamp
sparc: + grsim grsim_leon2 gr_cpci_ax2000 gr_xc3s_1500 gr_ep2s60
nios2: + 10m50 3c120
microblaze: + microblaze-generic
openrisc: + openrisc-generic
28: spl: Make spl_boot_list a local variable
aarch64: (for 51/51 boards) spl/u-boot-spl:all +36.8
spl/u-boot-spl:bss -6.3 spl/u-boot-spl:data +5.6
spl/u-boot-spl:rodata +7.5 spl/u-boot-spl:text +29.9
powerpc: (for 415/415 boards) spl/u-boot-spl:all -24.7
spl/u-boot-spl:bss -0.1 spl/u-boot-spl:data -0.1
spl/u-boot-spl:rodata -15.9 spl/u-boot-spl:text -8.6
sandbox: (for 3/3 boards) spl/u-boot-spl:all +37.3
spl/u-boot-spl:bss -10.7 spl/u-boot-spl:rodata +10.7
spl/u-boot-spl:text +37.3
arm: (for 552/552 boards) all -0.8 bss -0.8 data -0.1
spl/u-boot-spl:all -66.3 spl/u-boot-spl:bss -22.3
spl/u-boot-spl:data -5.1 spl/u-boot-spl:rodata +0.5
spl/u-boot-spl:text -39.3Quoted 10 lines
Quoted 6 lines
There is an obvious follow-on from this, to move boot_name_table[] into the same linker list struct (i.e. add a name field to struct
spl_image_loader). The complication here is that we don't want naming ifCONFIG_SPL_LIBCOMMON_SUPPORTis not enabled, since it bloats the code. In addition I think thatcommon/spl/spl.ccan be tidied up a little.Yeah, I worry about size growth in doing that too. But maybe we can be a little clever when declaring the ll and just not have the strings if !LIBCOMMON ?
Yes I think so...perhaps someone else might take a look, or I'll wait for a rainy day!
Regards,
Simon
cover spl: Use linker list and parameters for SPL image loading
Quoted 36 lines · Simon Glass
Hi Tom,
Quoted 10 lines · Tom Rini
Quoted 6 lines · Simon Glass
At present the SPL code uses a global
spl_imagevariable which is shared amongst lots of files, some in common/spl and some elsewhere. There is no need for this to be global, and in fact a parameter makes it easier to understand what information the functions act on. It also reduces the BSS use in the SPL (at the expense of stack) which is useful on boards which don't have BSS available early on.Thanks for taking a stab at cleaning this up.
I ran into it with the 64-bit x86 stuff and decided to take a detour :-)
Quoted 5 lines
[snip]
Quoted 2 lines
There is a priorty value attached to each loader which should allow the existing ordering to be maintained.
Quoted 9 lines
I worry here about some of the corner cases, but it's probably no more or less fragile than currently at least. I'm actually not sure how that's working in this version of the series, everyone gets priority 0 filled in so it seems like we're on linker order. But I'm also not convinced that it's a problem here. As far as I can recall, the use cases are that a given binary will support say NAND and MMC, and at run time knows that it came from NAND or MMC, and thus we need to look at the same device for U-Boot itself. So order doesn't matter there. So we can just drop that part I think.
I see in the code that if Ubifs is enabled, it uses that instead of NAND and ONENAND. There is another case too - SPI might have a board-specific loader which takes precedence (although I suspect in the sunxi case the generic loader is not present).
Quoted 5 lines
If these are not needed then we can drop it.
At present priority is handled by adding the priority value into the linker list element name. Since they are sorted in order within the image, this gives the required result.
Looking over the code, UBI is setup as mutually exclusive. It also looks like that SPL_SPI_BOOT, SPL_SPI_SUNXI and SPL_SPI_LOAD are all exclusive as well. So we should clean that up so that we select the right back end if SPL_SPI is set, and we can drop the order part.
Quoted 25 lines
Quoted 5 lines
Quoted 3 lines
Code size is about 20 bytes larger on average which I think is acceptable. The BSS size drops by about 64 bytes, but really this just transfers to the stack.
How about the worst case growths in what we have today?
Ah well that's something buildman cannot tell me! There is a small overhead for the lookup code (about 20-30 bytes) and 8-12 bytes for each loader method. Here's the buildman summary.
$ buildman -b spl -s --step 0 -S boards.cfg is up to date. Nothing to do. Summary of 2 commits for 1196 boards (32 threads, 1 job per thread) 01: Makefile: Give a build error if ad-hoc CONFIG options are added blackfin: + cm-bf527 bf609-ezkit bf537-stamp sparc: + grsim grsim_leon2 gr_cpci_ax2000 gr_xc3s_1500 gr_ep2s60 nios2: + 10m50 3c120 microblaze: + microblaze-generic openrisc: + openrisc-generic 28: spl: Make spl_boot_list a local variable aarch64: (for 51/51 boards) spl/u-boot-spl:all +36.8 spl/u-boot-spl:bss -6.3 spl/u-boot-spl:data +5.6 spl/u-boot-spl:rodata +7.5 spl/u-boot-spl:text +29.9 powerpc: (for 415/415 boards) spl/u-boot-spl:all -24.7 spl/u-boot-spl:bss -0.1 spl/u-boot-spl:data -0.1
Quoted 8 lines
spl/u-boot-spl:rodata -15.9 spl/u-boot-spl:text -8.6
sandbox: (for 3/3 boards) spl/u-boot-spl:all +37.3
spl/u-boot-spl:bss -10.7 spl/u-boot-spl:rodata +10.7
spl/u-boot-spl:text +37.3
arm: (for 552/552 boards) all -0.8 bss -0.8 data -0.1
spl/u-boot-spl:all -66.3 spl/u-boot-spl:bss -22.3
spl/u-boot-spl:data -5.1 spl/u-boot-spl:rodata +0.5
spl/u-boot-spl:text -39.3You should have a bit more output :) Adding in -d will list every board and then what I do (since I do -SCdvel and -Ssdel after to log it) is read over the list and manually look at the deviations.
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
There is an obvious follow-on from this, to move boot_name_table[] into the same linker list struct (i.e. add a name field to struct
spl_image_loader). The complication here is that we don't want naming ifCONFIG_SPL_LIBCOMMON_SUPPORTis not enabled, since it bloats the code. In addition I think thatcommon/spl/spl.ccan be tidied up a little.
Quoted 6 lines
Quoted 3 lines
Yeah, I worry about size growth in doing that too. But maybe we can be a little clever when declaring the ll and just not have the strings if !LIBCOMMON ?
Yes I think so...perhaps someone else might take a look, or I'll wait for a rainy day!
Sounds good enough for now, thanks.
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160919/d2e063f7/attachment.sig>
cover spl: Use linker list and parameters for SPL image loading
In reply to Simon GlassHi,
Quoted 7 lines · Simon Glass
At present the SPL code uses a global
spl_imagevariable which is shared amongst lots of files, some in common/spl and some elsewhere. There is no need for this to be global, and in fact a parameter makes it easier to understand what information the functions act on. It also reduces the BSS use in the SPL (at the expense of stack) which is useful on boards which don't have BSS available early on.
Quoted 7 lines
There are many global functions for loading images from each boot device type, like
spl_mmc_load_image()andspl_spi_load_image(). Mostly these take the same parameters (none or a u32). There are various rules for compiling in calls to these functions and in some cases somewhat different rules for compiling in the functions themselves. For example,spl_spi_load_image()is called if either ofCONFIG_SPL_SPI_SUPPORTorCONFIG_SPL_SPI__FLASHSUPPORTis enabled, but included in the image ifCONFIG_SPL_SPI_LOADis enabled.
Unfortunately there is a missing memset() in this series which can cause booting to fail because the spl_image flags can be non-zero.
I'll send v2 after allowing time for more comments, but in the meantime if you want to test it, see u-boot-dm/spl-working.
Regards,
Simon