summaryrefslogtreecommitdiff
path: root/cpu/blackfin/initcode.c
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2009-02-13 17:10:58 -0500
committerMike Frysinger <vapier@gentoo.org>2009-04-02 06:41:56 -0400
commitad9073211ca9e62162a39851e082b8d07a662fb6 (patch)
treeba4c415b936854441c8860f720d20858d3387021 /cpu/blackfin/initcode.c
parent84a9dda324c3faa56be14449d7519b993d9397a9 (diff)
downloadu-boot-imx-ad9073211ca9e62162a39851e082b8d07a662fb6.zip
u-boot-imx-ad9073211ca9e62162a39851e082b8d07a662fb6.tar.gz
u-boot-imx-ad9073211ca9e62162a39851e082b8d07a662fb6.tar.bz2
Blackfin: fix crash when booting from external memory
When testing a u-boot binary that hasn't been booted from the bootrom, we have to make sure the bootstruct structure has sane storage space. If we don't, the initcode will crash when it tries to dereference an invalid pointer. Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Diffstat (limited to 'cpu/blackfin/initcode.c')
-rw-r--r--cpu/blackfin/initcode.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/cpu/blackfin/initcode.c b/cpu/blackfin/initcode.c
index 7bd4b22..3120447 100644
--- a/cpu/blackfin/initcode.c
+++ b/cpu/blackfin/initcode.c
@@ -249,6 +249,8 @@ static inline void serial_putc(char c)
BOOTROM_CALLED_FUNC_ATTR
void initcode(ADI_BOOT_DATA *bootstruct)
{
+ ADI_BOOT_DATA bootstruct_scratch;
+
/* Save the clock pieces that are used in baud rate calculation */
unsigned int sdivB, divB, vcoB;
serial_init();
@@ -260,6 +262,13 @@ void initcode(ADI_BOOT_DATA *bootstruct)
serial_putc('A');
+ /* If the bootstruct is NULL, then it's because we're loading
+ * dynamically and not via LDR (bootrom). So set the struct to
+ * some scratch space.
+ */
+ if (!bootstruct)
+ bootstruct = &bootstruct_scratch;
+
#ifdef CONFIG_HW_WATCHDOG
# ifndef CONFIG_HW_WATCHDOG_TIMEOUT_INITCODE
# define CONFIG_HW_WATCHDOG_TIMEOUT_INITCODE 20000