summaryrefslogtreecommitdiff
path: root/common/init
AgeCommit message (Collapse)AuthorFilesLines
2022-07-08board_init: Do not reserve MALLOC_F area on stack if non-zero MALLOC_F_ADDRMarek Vasut1-0/+2
In case the MALLOC_F_ADDR is set to non-zero value, the early malloc area is not going to be placed just below stack top, but elsewhere. Do not reserve MALLOC_F bytes in this case, as that wastes stack space and may even cause insufficient stack space in SPL. This functionality is particularly useful on i.MX8M, where the insufficient stack space can be triggered. Signed-off-by: Marek Vasut <marex@denx.de> Cc: Albert ARIBAUD <albert.u.boot@aribaud.net> Cc: Fabio Estevam <festevam@denx.de> Cc: Peng Fan <peng.fan@nxp.com> Cc: Simon Glass <sjg@chromium.org> Cc: Stefano Babic <sbabic@denx.de> Cc: Thomas Chou <thomas@wytron.com.tw> Cc: Tom Rini <trini@konsulko.com>
2021-10-31bootstage: Add SPL supportMarek Vasut1-1/+1
Allow usage of the bootstage facilities in SPL. Signed-off-by: Marek Vasut <marex@denx.de> Cc: Simon Glass <sjg@chromium.org> Reviewed-by: Simon Glass <sjg@chromium.org>
2021-07-07bootstage: Eliminate when not enabledTom Rini1-0/+2
When we do not have bootstage enabled, rather than include an empty dummy function, we just don't reference it. This saves us space in some tight builds. This also shows a few cases where show_boot_progress was incorrectly guarded before. Cc: Simon Glass <sjg@chromium.org> Signed-off-by: Tom Rini <trini@konsulko.com>
2021-02-02common: Drop asm/global_data.h from common headerSimon Glass2-0/+2
Move this out of the common header and include it only where needed. In a number of cases this requires adding "struct udevice;" to avoid adding another large header or in other cases replacing / adding missing header files that had been pulled in, very indirectly. Finally, we have a few cases where we did not need to include <asm/global_data.h> at all, so remove that include. Signed-off-by: Simon Glass <sjg@chromium.org> Signed-off-by: Tom Rini <trini@konsulko.com>
2020-08-26CONFIG_NR_DRAM_BANKS: Remove unreferenced code as its always definedStefan Roese1-20/+13
Since commit 86cf1c82850f ("configs: Migrate CONFIG_NR_DRAM_BANKS") & commit 999a772d9f24 ("Kconfig: Migrate CONFIG_NR_DRAM_BANKS"), CONFIG_NR_DRAM_BANKS is always defined with a value (4 is default). It makes no sense to still carry code that is guarded with "#ifndef CONFIG_NR_DRAM_BANKS" (and similar). This patch removes all these unreferenced code paths. Signed-off-by: Stefan Roese <sr@denx.de> Reviewed-by: Pali Rohár <pali@kernel.org> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
2020-05-19common: Drop init.h from common headerSimon Glass1-0/+1
Move this uncommon header out of the common header. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-05-19common: Drop bootstage.h from common headerSimon Glass1-0/+1
Move this fairly uncommon header out of the common header. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-01-23board_init: remove meaningless increment in board_init_f_init_reserve()Masahiro Yamada1-2/+0
The base is not used in the code that follows this increment. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
2020-01-10spl: fix stack usage check if gd is not initializedSimon Goldschmidt1-0/+17
Most platforms do not set up gd->start_addr_sp in SPL. Since this is required for CONFIG_SPL_SYS_REPORT_SACK_F_USAGE to work correctly, set up gd->start_addr_sp in SPL to the value passed to board_init_f_init_reserve if it is not set yet. Fixes: d8c0332031 ("spl: implement stack usage check") Signed-off-by: Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com>
2019-08-11spl: implement stack usage checkSimon Goldschmidt1-0/+20
This implements a stack usage check in SPL. Many boards start up SPL to run code + data from one common, rather small SRAM. To implement a sophisticated SPL binary size limit on such boards, the stack size (as well as malloc size and global data size) must be subtracted from this SRAM size. However, to do that properly, the stack size first needs to be known. This patch adds a new Kconfig option: - SPL_SYS_REPORT_STACK_F_USAGE: memset(0xaa) the whole area of the stack very early and check stack usage based on this constant later before the stack is switched to DRAM Initializing the stack and checking it is implemented in weak functions, in case a board does not use the stack as saved in gd->start_addr_sp. Signed-off-by: Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com>
2018-11-26spl: Add support for passing handoff info to U-Boot properSimon Glass2-0/+48
There is some basic informaton that SPL normally wants to pass through to U-Boot, such as the SDRAM size and bank information. Mkae use of the new bloblist structure for this. Add a new 'handoff' blob which is set up in SPL and passed to U-Boot proper. Also adda test for sandbox_spl that checks that this works correctly and a new 'sb' command to show the information passed from SPL. Reviewed-by: Tom Rini <trini@konsulko.com> Signed-off-by: Simon Glass <sjg@chromium.org>
2018-05-07SPDX: Convert all of our single license tags to Linux Kernel styleTom Rini1-2/+1
When U-Boot started using SPDX tags we were among the early adopters and there weren't a lot of other examples to borrow from. So we picked the area of the file that usually had a full license text and replaced it with an appropriate SPDX-License-Identifier: entry. Since then, the Linux Kernel has adopted SPDX tags and they place it as the very first line in a file (except where shebangs are used, then it's second line) and with slightly different comment styles than us. In part due to community overlap, in part due to better tag visibility and in part for other minor reasons, switch over to that style. This commit changes all instances where we have a single declared license in the tag as both the before and after are identical in tag contents. There's also a few places where I found we did not have a tag and have introduced one. Signed-off-by: Tom Rini <trini@konsulko.com>
2017-07-27spl: make SPL and normal u-boot stage use independent SYS_MALLOC_F_LENAndy Yan1-4/+4
Some platforms have very limited SRAM to run SPL code, so there may not be the same amount space for a malloc pool before relocation in the SPL stage as the normal U-Boot stage. Make SPL and (the full) U-Boot stage use independent SYS_MALLOC_F_LEN, so the size of pre-relocation malloc pool can be configured memory space independently. Signed-off-by: Andy Yan <andy.yan@rock-chips.com> Reviewed-by: Tom Rini <trini@konsulko.com> Acked-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com> Reviewed-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com> [fixed up commit-message:] Signed-off-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
2017-01-20board_init.c: Always use memset()Tom Rini1-18/+0
We can make the code read more easily here by simply using memset() always as when we don't have an optimized version of the function we will still have a version of this function around anyhow. Cc: Simon Glass <sjg@chromium.org> Signed-off-by: Tom Rini <trini@konsulko.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2017-01-20ARM: Default to using optimized memset and memcpy routinesTom Rini1-1/+1
We have long had available optimized versions of the memset and memcpy functions that are borrowed from the Linux kernel. We should use these in normal conditions as the speed wins in many workflows outweigh the relatively minor size increase. However, we have a number of places where we're simply too close to size limits in SPL and must be able to make the size vs performance trade-off in those cases. Cc: Philippe Reynes <tremyfr@yahoo.fr> Cc: Eric Jarrige <eric.jarrige@armadeus.org> Cc: Heiko Schocher <hs@denx.de> Cc: Magnus Lilja <lilja.magnus@gmail.com> Cc: Lokesh Vutla <lokeshvutla@ti.com> Cc: Chander Kashyap <k.chander@samsung.com> Cc: Akshay Saraswat <akshay.s@samsung.com> Cc: Simon Glass <sjg@chromium.org> Cc: Stefan Roese <sr@denx.de> Signed-off-by: Tom Rini <trini@konsulko.com> Acked-by: Stefan Roese <sr@denx.de> Reviewed-by: Simon Glass <sjg@chromium.org>
2016-06-09bootstage: call show_boot_progress also in SPLHeiko Schocher1-0/+5
show_boot_progress() is now called from SPL also. Signed-off-by: Heiko Schocher <hs@denx.de>
2016-01-15x86: Fix board init breakageSimon Glass1-1/+1
Commit ecc30663 ("Fix board init code to respect the C runtime environment") breaks x86. This was mentioned on https://patchwork.ozlabs.org/patch/548644 but not addressed. Correct it so that x86 boards boot again. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Tom Rini <trini@konsulko.com>
2016-01-14arm: move gd handling outside of C codeAlbert ARIBAUD1-4/+4
As of gcc 5.2.1 for Thumb-1, it is not possible any more to assign gd from C code, as gd is mapped to r9, and r9 may now be saved in the prolog sequence, and restored in the epilog sequence, of any C functions. Therefore arch_setup_gd(), which is supposed to set r9, may actually have no effect, causing U-Boot to use a bad address to access GD. Fix this by never calling arch_setup_gd() for ARM, and instead setting r9 in arch/arm/lib/crt0.S, to the value returned by board_init_f_alloc_reserve(). Signed-off-by: Albert ARIBAUD <albert.u.boot@aribaud.net> Reviewed-by: Simon Glass <sjg@chromium.org>
2016-01-14Fix board init code to respect the C runtime environmentAlbert ARIBAUD1-10/+99
board_init_f_mem() alters the C runtime environment's stack it is actually already using. This is not a valid behaviour within a C runtime environment. Split board_init_f_mem into C functions which do not alter their own stack and always behave properly with respect to their C runtime environment. Signed-off-by: Albert ARIBAUD <albert.u.boot@aribaud.net> Acked-by: Thomas Chou <thomas@wytron.com.tw>
2015-11-13board_init: Change the logic to setup malloc_baseFabio Estevam1-2/+1
Prior to commit 5ba534d247d418 ("arm: Switch 32-bit ARM to using generic global_data setup") we used to have assembly code that configured the malloc_base address. Since this commit we use the board_init_f_mem() function in C to setup malloc_base address. In board_init_f_mem() there was a deliberate choice to support only early malloc() or full malloc() in SPL, but not both. Adapt this logic to allow both to be used, one after the other, in SPL. This issue has been observed in a Congatec board, where we need to retrieve the manufacturing information from the SPI NOR (the SPI API calls malloc) prior to configuring the DRAM. In this case as malloc_base was not configured we always see malloc to fail. With this change we are able to use malloc in SPL prior to DRAM gets initialized. Also update the CONFIG_SYS_SPL_MALLOC_START entry in the README file. Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2015-10-24board_init_f_mem(): Don't create an unused early malloc() areaSimon Glass1-1/+2
Change the #ifdef so that the early malloc() area is not set up in SPL if CONFIG_SYS_SPL_MALLOC_START is defined. In that case it would never actually be used, and just chews up stack space. Signed-off-by: Simon Glass <sjg@chromium.org> Tested-by: Masahiro Yamada <yamada.masahiro@socionext.com>
2015-10-24board_init_f_mem(): Don't require memset()Simon Glass1-0/+18
Unfortunately memset() is not always available, so provide a substitute when needed. Signed-off-by: Simon Glass <sjg@chromium.org>
2015-10-24Move board_init_f_mem() into a common locationSimon Glass2-0/+48
This function will be used by both SPL and U-Boot proper. So move it into a common place. Also change the #ifdef so that the early malloc() area is not set up in SPL if CONFIG_SYS_SPL_MALLOC_START is defined. In that case it would never actually be used, and just chews up stack space. Signed-off-by: Simon Glass <sjg@chromium.org>