summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
Diffstat (limited to 'common')
-rw-r--r--common/Kconfig3
-rw-r--r--common/Makefile1
-rw-r--r--common/console.c5
-rw-r--r--common/poller.c45
4 files changed, 54 insertions, 0 deletions
diff --git a/common/Kconfig b/common/Kconfig
index 617f640a57..02bc67ed90 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -414,6 +414,9 @@ config DEFAULT_ENVIRONMENT_PATH
Relative pathes will be relative to the barebox Toplevel dir, but absolute
pathes are fine aswell.
+config POLLER
+ bool "generic polling infrastructure"
+
endmenu
menu "Debugging "
diff --git a/common/Makefile b/common/Makefile
index 753455b64f..98c9d36c12 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -5,6 +5,7 @@ obj-$(CONFIG_OF_FLAT_TREE) += ft_build.o
obj-$(CONFIG_KALLSYMS) += kallsyms.o
obj-$(CONFIG_ENV_HANDLING) += environment.o
obj-$(CONFIG_AUTO_COMPLETE) += complete.o
+obj-$(CONFIG_POLLER) += poller.o
obj-y += dlmalloc.o
obj-y += clock.o
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;
diff --git a/common/poller.c b/common/poller.c
new file mode 100644
index 0000000000..0583a532cf
--- /dev/null
+++ b/common/poller.c
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2010 Marc Kleine-Budde <mkl@pengutronix.de>
+ *
+ * This file is released under the GPLv2
+ *
+ */
+
+#include <common.h>
+#include <driver.h>
+#include <malloc.h>
+#include <module.h>
+#include <param.h>
+#include <poller.h>
+
+static LIST_HEAD(poller_list);
+static int poller_active;
+
+int poller_register(struct poller_struct *poller)
+{
+ list_add_tail(&poller->list, &poller_list);
+
+ return 0;
+}
+
+int poller_unregister(struct poller_struct *poller)
+{
+ list_del(&poller->list);
+
+ return 0;
+}
+
+void poller_call(void)
+{
+ struct poller_struct *poller, *tmp;
+
+ if (poller_active)
+ return;
+
+ poller_active = 1;
+
+ list_for_each_entry_safe(poller, tmp, &poller_list, list)
+ poller->func(poller);
+
+ poller_active = 0;
+}