path: root/common/startup.c
diff options
authorSascha Hauer <>2013-01-20 13:59:47 +0100
committerSascha Hauer <>2013-01-20 16:30:20 +0100
commit7b4d66ab28fdd3c7bfd4e427a1f7ccddbffd355c (patch)
tree10f4995ddfb779d5c80392986359a0ee6f4fdba7 /common/startup.c
parent3de3b677ee3adc4e10235b623a8e0aa45be48893 (diff)
startup: call a barebox_main function pointer at the end of the startup
Currently Kconfig dependencies are used to allow non-interactive builds. This leads to problems in Kconfig getting the dependencies right. This patch adds a barebox_main function pointer which is called at the end of the startup process. This defaults to run_shell when a shell is enabled. With this the HAVE_NOSHELL Kconfig variable can be removed. Non interactive builds can now be enabled for every board allowing to compile a binary without further Kconfig dependencies. This also allows for more flexibility, for example boards may decide to try non-interactive startup first and call run_shell if that fails. Signed-off-by: Sascha Hauer <>
Diffstat (limited to 'common/startup.c')
1 files changed, 12 insertions, 1 deletions
diff --git a/common/startup.c b/common/startup.c
index 14409a2..6309f53 100644
--- a/common/startup.c
+++ b/common/startup.c
@@ -88,6 +88,8 @@ static int mount_root(void)
+int (*barebox_main)(void);
void start_barebox (void)
initcall_t *initcall;
@@ -96,6 +98,9 @@ void start_barebox (void)
struct stat s;
+ barebox_main = run_shell;
for (initcall = __barebox_initcalls_start;
initcall < __barebox_initcalls_end; initcall++) {
debug("initcall-> %pS\n", *initcall);
@@ -126,9 +131,15 @@ void start_barebox (void)
printf("not found\n");
+ if (!barebox_main) {
+ printf("No main function! aborting.\n");
+ hang();
+ }
/* main_loop() can return to retry autoboot, if so just run it again. */
for (;;)
- run_shell();
+ barebox_main();
/* NOTREACHED - no way out of command loop except booting */