summaryrefslogtreecommitdiffstats
path: root/pbl
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2016-07-12 12:18:05 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2016-09-15 09:23:43 +0200
commit80c55cb4837594a7db7f2cedb8e2f177e2697510 (patch)
tree16c5466b541c8d9de3f3b44c1925346dc5196cec /pbl
parent7dc3354ac8fa4312b2c309037ec1f138212c393a (diff)
downloadbarebox-80c55cb4837594a7db7f2cedb8e2f177e2697510.tar.gz
barebox-80c55cb4837594a7db7f2cedb8e2f177e2697510.tar.xz
pbl: console: Let console pointer survive BSS clearing
The PBL console support may be configured before the BSS segment is cleared. Put the pointer into the data section so that it is not affected by the BSS clearing. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'pbl')
-rw-r--r--pbl/console.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/pbl/console.c b/pbl/console.c
index 4cefe74808..007e4e4b83 100644
--- a/pbl/console.c
+++ b/pbl/console.c
@@ -1,8 +1,13 @@
#include <common.h>
#include <debug_ll.h>
+#include <linux/err.h>
-static void (*__putc)(void *ctx, int c);
-static void *putc_ctx;
+/*
+ * Put these in the data section so that they survive the clearing of the
+ * BSS segment.
+ */
+static __attribute__ ((section(".data"))) void (*__putc)(void *ctx, int c);
+static __attribute__ ((section(".data"))) void *putc_ctx;
/**
* pbl_set_putc() - setup UART used for PBL console
@@ -20,10 +25,10 @@ void pbl_set_putc(void (*putcf)(void *ctx, int c), void *ctx)
void console_putc(unsigned int ch, char c)
{
- if (!__putc)
- putc_ll(c);
- else
+ if (__putc)
__putc(putc_ctx, c);
+ else
+ putc_ll(c);
}
int console_puts(unsigned int ch, const char *str)