diff options
author | Stefano Babic <sbabic@denx.de> | 2015-03-05 15:05:10 (GMT) |
---|---|---|
committer | Stefano Babic <sbabic@denx.de> | 2015-03-05 15:05:10 (GMT) |
commit | 9b5b60a05cb8bba2d135439419b2030764e359bd (patch) | |
tree | 15e249ac39e9c547668327218e63a0faf54a3283 /common/spl/spl.c | |
parent | 32df39c741788e8637cffe6633d73594b26d70fb (diff) | |
parent | 7ae8350f67eea861280a4cbd2d067777a0e87153 (diff) | |
download | u-boot-fsl-qoriq-9b5b60a05cb8bba2d135439419b2030764e359bd.tar.xz |
Merge branch 'master' of git://git.denx.de/u-boot
Diffstat (limited to 'common/spl/spl.c')
-rw-r--r-- | common/spl/spl.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/common/spl/spl.c b/common/spl/spl.c index ded0f30..cd75bbc 100644 --- a/common/spl/spl.c +++ b/common/spl/spl.c @@ -281,3 +281,38 @@ void preloader_console_init(void) spl_display_print(); #endif } + +/** + * spl_relocate_stack_gd() - Relocate stack ready for board_init_r() execution + * + * Sometimes board_init_f() runs with a stack in SRAM but we want to use SDRAM + * for the main board_init_r() execution. This is typically because we need + * more stack space for things like the MMC sub-system. + * + * This function calculates the stack position, copies the global_data into + * place and returns the new stack position. The caller is responsible for + * setting up the sp register. + * + * @return new stack location, or 0 to use the same stack + */ +ulong spl_relocate_stack_gd(void) +{ +#ifdef CONFIG_SPL_STACK_R + gd_t *new_gd; + ulong ptr; + + /* Get stack position: use 8-byte alignment for ABI compliance */ + ptr = CONFIG_SPL_STACK_R - sizeof(gd_t); + ptr &= ~7; + new_gd = (gd_t *)ptr; + memcpy(new_gd, (void *)gd, sizeof(gd_t)); + gd = new_gd; + + /* Clear the BSS. */ + memset(__bss_start, 0, __bss_end - __bss_start); + + return ptr; +#else + return 0; +#endif +} |