diff options
author | Richard Braun <rbraun@sceen.net> | 2017-05-31 23:51:54 +0200 |
---|---|---|
committer | Richard Braun <rbraun@sceen.net> | 2017-05-31 23:53:01 +0200 |
commit | 0890cc62c32ad48118bc0731ad07df226fb60431 (patch) | |
tree | 68739bd47e2920b103ffc52138a676332ed3d01f | |
parent | e4d73f8405441ab7a09003773664a16e10b40fed (diff) |
kern/console: optimize interrupt handling
-rw-r--r-- | arch/x86/machine/atcons.c | 4 | ||||
-rw-r--r-- | arch/x86/machine/atcons.h | 2 | ||||
-rw-r--r-- | arch/x86/machine/atkbd.c | 5 | ||||
-rw-r--r-- | kern/console.c | 17 | ||||
-rw-r--r-- | kern/console.h | 2 |
5 files changed, 17 insertions, 13 deletions
diff --git a/arch/x86/machine/atcons.c b/arch/x86/machine/atcons.c index c4c48069..223298c4 100644 --- a/arch/x86/machine/atcons.c +++ b/arch/x86/machine/atcons.c @@ -50,7 +50,7 @@ atcons_setup(void) } void -atcons_intr(char c) +atcons_intr(const char *s) { - console_intr(&atcons_console, c); + console_intr(&atcons_console, s); } diff --git a/arch/x86/machine/atcons.h b/arch/x86/machine/atcons.h index 05b870fc..ffe22dc9 100644 --- a/arch/x86/machine/atcons.h +++ b/arch/x86/machine/atcons.h @@ -39,6 +39,6 @@ void atcons_setup(void); * This function is called by the AT keyboard interrupt handler * to handle machine-independent console management. */ -void atcons_intr(char c); +void atcons_intr(const char *s); #endif /* _X86_ATCONS_H */ diff --git a/arch/x86/machine/atkbd.c b/arch/x86/machine/atkbd.c index 26bf9d1f..6223d30f 100644 --- a/arch/x86/machine/atkbd.c +++ b/arch/x86/machine/atkbd.c @@ -606,10 +606,7 @@ atkbd_key_process_chars(const struct atkbd_key *key, s = chars[key->id]; if (s != NULL) { - while (*s != '\0') { - atcons_intr(*s); - s++; - } + atcons_intr(s); } } diff --git a/kern/console.c b/kern/console.c index e8c0c28a..d7104e47 100644 --- a/kern/console.c +++ b/kern/console.c @@ -136,17 +136,24 @@ console_register(struct console *console) } void -console_intr(struct console *console, char c) +console_intr(struct console *console, const char *s) { assert(!cpu_intr_enabled()); + if (*s == '\0') { + return; + } + spinlock_lock(&console->lock); - if (cbuf_size(&console->recvbuf) == cbuf_capacity(&console->recvbuf)) { - goto out; - } + while (*s != '\0') { + if (cbuf_size(&console->recvbuf) == cbuf_capacity(&console->recvbuf)) { + goto out; + } - cbuf_push(&console->recvbuf, c); + cbuf_push(&console->recvbuf, *s); + s++; + } if ((console->waiter != NULL) && (console->waiter != thread_self())) { thread_wakeup(console->waiter); diff --git a/kern/console.h b/kern/console.h index b967c0dd..7455a051 100644 --- a/kern/console.h +++ b/kern/console.h @@ -81,7 +81,7 @@ void console_register(struct console *console); * * Interrupts must be disabled when calling this function. */ -void console_intr(struct console *console, char c); +void console_intr(struct console *console, const char *s); /* * Write/read a single character to all registered console devices. |