summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2015-01-09 17:38:26 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2015-01-09 17:38:26 +0100
commit39c6c3480a9cb88e722af1142c7b31a00e9ec546 (patch)
tree3381f97f7485a14df8f2c47249d1aedfa509d205 /common
parentff6383c8e4bde31036fbd31f7961539be288d6af (diff)
parentbdcdcaad8199aba9774197e6f3296f659d30c399 (diff)
downloadbarebox-39c6c3480a9cb88e722af1142c7b31a00e9ec546.tar.gz
barebox-39c6c3480a9cb88e722af1142c7b31a00e9ec546.tar.xz
Merge branch 'for-next/mxs'
Diffstat (limited to 'common')
-rw-r--r--common/Kconfig11
-rw-r--r--common/console_common.c2
-rw-r--r--common/memory.c8
-rw-r--r--common/misc.c22
4 files changed, 42 insertions, 1 deletions
diff --git a/common/Kconfig b/common/Kconfig
index 4614965899..00e4f36d62 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -882,6 +882,17 @@ config DEBUG_INITCALLS
bool "Trace initcalls"
help
If enabled this will print initcall traces.
+
+config PBL_CONSOLE
+ depends on DEBUG_LL
+ bool "Enable console support in PBL"
+ help
+ This enables printf/pr_* support in the PBL to get more
+ informational output earlier during startup. Note that
+ printf/pr_* need a valid C environment, so the binary
+ must be running at the address it's linked at and bss must
+ be cleared. On ARM that would be after setup_c().
+
endmenu
config HAS_DEBUG_LL
diff --git a/common/console_common.c b/common/console_common.c
index cc25f97d9d..df1b085982 100644
--- a/common/console_common.c
+++ b/common/console_common.c
@@ -101,7 +101,7 @@ void pr_puts(int level, const char *str)
{
struct log_entry *log;
- if (IS_ENABLED(CONFIG_LOGBUF)) {
+ if (IS_ENABLED(CONFIG_LOGBUF) && mem_malloc_is_initialized()) {
if (barebox_log_max_messages > 0)
log_clean(barebox_log_max_messages - 1);
diff --git a/common/memory.c b/common/memory.c
index 57c73abb22..4725f6e382 100644
--- a/common/memory.c
+++ b/common/memory.c
@@ -49,6 +49,13 @@ unsigned long mem_malloc_end(void)
tlsf_pool tlsf_mem_pool;
#endif
+int mem_malloc_initialized;
+
+int mem_malloc_is_initialized(void)
+{
+ return mem_malloc_initialized;
+}
+
void mem_malloc_init(void *start, void *end)
{
malloc_start = (unsigned long)start;
@@ -57,6 +64,7 @@ void mem_malloc_init(void *start, void *end)
#ifdef CONFIG_MALLOC_TLSF
tlsf_mem_pool = tlsf_create(start, end - start + 1);
#endif
+ mem_malloc_initialized = 1;
}
#if !defined __SANDBOX__ && !defined CONFIG_ARCH_EFI
diff --git a/common/misc.c b/common/misc.c
index 65f3306bee..6da71c7ab7 100644
--- a/common/misc.c
+++ b/common/misc.c
@@ -22,6 +22,7 @@
#include <magicvar.h>
#include <globalvar.h>
#include <environment.h>
+#include <led.h>
#include <of.h>
int errno;
@@ -188,3 +189,24 @@ EXPORT_SYMBOL(barebox_get_hostname);
BAREBOX_MAGICVAR_NAMED(global_hostname, global.hostname,
"shortname of the board. Also used as hostname for DHCP requests");
+
+void __noreturn panic(const char *fmt, ...)
+{
+ va_list args;
+ va_start(args, fmt);
+ vprintf(fmt, args);
+ putchar('\n');
+ va_end(args);
+
+ dump_stack();
+
+ led_trigger(LED_TRIGGER_PANIC, TRIGGER_ENABLE);
+
+ if (IS_ENABLED(CONFIG_PANIC_HANG)) {
+ hang();
+ } else {
+ udelay(100000); /* allow messages to go out */
+ reset_cpu(0);
+ }
+}
+EXPORT_SYMBOL(panic);