[U-Boot] [PATCH 27/27] spl: Make spl_boot_list a local variable

Simon Glass sjg at chromium.org
Sun Sep 18 21:45:16 CEST 2016


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 <sjg at chromium.org>
---

 common/spl/spl.c | 23 +++++++++++------------
 include/spl.h    |  2 --
 2 files changed, 11 insertions(+), 14 deletions(-)

diff --git a/common/spl/spl.c b/common/spl/spl.c
index 0a9c632..1e0cf86 100644
--- a/common/spl/spl.c
+++ b/common/spl/spl.c
@@ -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;
 	}
 
diff --git a/include/spl.h b/include/spl.h
index 7514d8e..b51ba90 100644
--- a/include/spl.h
+++ b/include/spl.h
@@ -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);
-- 
2.8.0.rc3.226.g39d4020



More information about the U-Boot mailing list