summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2008-03-11 00:00:37 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2008-03-11 00:00:37 +0100
commit8759e68de2e2b4ce1793d36d668359eb80278c2c (patch)
treed30cd455f52e37bea10e8ac4cc296fc8d85e7a7c
parent4dba16c692bbe50ae22e3d678a01d054c4e52bb4 (diff)
downloadbarebox-8759e68de2e2b4ce1793d36d668359eb80278c2c.tar.gz
barebox-8759e68de2e2b4ce1793d36d668359eb80278c2c.tar.xz
Add the possibility to have an architecture specific ctrlc() function.
This allows us to return immediately in ctrlc() on sandbox and thus not slow down network througput.
-rw-r--r--arch/sandbox/lib/common.c13
-rw-r--r--common/console.c2
-rw-r--r--include/asm-sandbox/common.h7
3 files changed, 18 insertions, 4 deletions
diff --git a/arch/sandbox/lib/common.c b/arch/sandbox/lib/common.c
index 0924c9bb9a..21ec720d7c 100644
--- a/arch/sandbox/lib/common.c
+++ b/arch/sandbox/lib/common.c
@@ -97,9 +97,7 @@ int linux_tstc(int fd)
/*
* We set the timeout here to 100us, because otherwise
* U-Boot would eat all cpu resources while waiting
- * for input. On the other hand this makes some
- * things like networking slow, because U-Boot will
- * poll this function very often.
+ * for input.
*/
ret = select(fd + 1, &rfds, NULL, NULL, &tv);
@@ -109,6 +107,15 @@ int linux_tstc(int fd)
return 0;
}
+int ctrlc(void)
+{
+ char chr;
+
+ if (linux_read_nonblock(0, &chr, 1) == 1 && chr == 3)
+ return 1;
+ return 0;
+}
+
int linux_getc(void)
{
char ret;
diff --git a/common/console.c b/common/console.c
index 80f8cdb890..e47c46061e 100644
--- a/common/console.c
+++ b/common/console.c
@@ -357,6 +357,7 @@ int vprintf (const char *fmt, va_list args)
}
EXPORT_SYMBOL(vprintf);
+#ifndef ARCH_HAS_CTRLC
/* test if ctrl-c was pressed */
int ctrlc (void)
{
@@ -365,6 +366,7 @@ int ctrlc (void)
return 0;
}
EXPORT_SYMBOL(ctrlc);
+#endif /* ARCH_HAS_CTRC */
#ifdef CONFIG_HAS_EARLY_INIT
diff --git a/include/asm-sandbox/common.h b/include/asm-sandbox/common.h
index da84fa5f6b..9b8bd2d94c 100644
--- a/include/asm-sandbox/common.h
+++ b/include/asm-sandbox/common.h
@@ -1 +1,6 @@
-/* nothing */
+#ifndef ASM_COMMON_H
+#define ASM_COMMON_H
+
+#define ARCH_HAS_CTRLC
+
+#endif /* ASM_COMMON_H */