summaryrefslogtreecommitdiffstats
path: root/common/console.c
diff options
context:
space:
mode:
authorMarc Kleine-Budde <mkl@pengutronix.de>2010-12-18 11:25:34 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2010-12-20 09:28:21 +0100
commit0277a663bcbebe5be82dc88235fcd0a1465bd5e8 (patch)
tree039e836f2a424149bbffe1c154319be43ef9fe38 /common/console.c
parentf4b1ebd2fdbfb2fd2382de894e027d014d1505d8 (diff)
downloadbarebox-0277a663bcbebe5be82dc88235fcd0a1465bd5e8.tar.gz
barebox-0277a663bcbebe5be82dc88235fcd0a1465bd5e8.tar.xz
Add generic poll infrastructure
Barebox does not have interrupt functionality. Nevertheless it's sometimes useful to periodically call functions, like for example a heartbeat LED or watchdog reset. Instead of cluttering the code with calls to these functions this patch adds a generic polling infrastructure. Code which might run for longer now can call poller_call() periodically which in turn will call all registered pollers. This patch adds a call to poller_call in two generic pathes. First of them is getc() which covers waiting for uart input. Second is ctrlc() which should be called anyway from code which might run for longer. So instead adding poller_call directly to your code, consider checking ctrlc instead which also gives additional convenience to the user. The poller code is safe against reentrancy which means that it's safe to call poller_call inside a poller. Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'common/console.c')
-rw-r--r--common/console.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/common/console.c b/common/console.c
index 82786f2b03..39ead4b58b 100644
--- a/common/console.c
+++ b/common/console.c
@@ -34,6 +34,7 @@
#include <clock.h>
#include <kfifo.h>
#include <module.h>
+#include <poller.h>
#include <linux/list.h>
LIST_HEAD(console_list);
@@ -205,6 +206,8 @@ int getc(void)
*/
start = get_time_ns();
while (1) {
+ poller_call();
+
if (tstc()) {
kfifo_putc(console_input_buffer, getc_raw());
@@ -397,6 +400,8 @@ EXPORT_SYMBOL(vprintf);
/* test if ctrl-c was pressed */
int ctrlc (void)
{
+ poller_call();
+
if (tstc() && getc() == 3)
return 1;
return 0;