summaryrefslogtreecommitdiff
path: root/src/kernel/arch/i386/driver
diff options
context:
space:
mode:
Diffstat (limited to 'src/kernel/arch/i386/driver')
-rw-r--r--src/kernel/arch/i386/driver/ps2.c9
-rw-r--r--src/kernel/arch/i386/driver/ps2.h1
2 files changed, 5 insertions, 5 deletions
diff --git a/src/kernel/arch/i386/driver/ps2.c b/src/kernel/arch/i386/driver/ps2.c
index 697bd34..5121b9e 100644
--- a/src/kernel/arch/i386/driver/ps2.c
+++ b/src/kernel/arch/i386/driver/ps2.c
@@ -7,17 +7,16 @@
static volatile uint8_t backlog[BACKLOG_CAPACITY] = {};
static volatile size_t backlog_size = 0;
+bool ps2_ready(void) {
+ return backlog_size > 0;
+}
+
void ps2_recv(uint8_t s) {
if (backlog_size >= BACKLOG_CAPACITY) return;
backlog[backlog_size++] = s;
}
size_t ps2_read(uint8_t *buf, size_t len) {
- irq_interrupt_flag(true);
- while (backlog_size == 0)
- asm("hlt" ::: "memory");
- irq_interrupt_flag(false);
-
if (backlog_size <= len)
len = backlog_size;
backlog_size -= len; /* guaranteed to never be < 0 */
diff --git a/src/kernel/arch/i386/driver/ps2.h b/src/kernel/arch/i386/driver/ps2.h
index 4b56056..712b157 100644
--- a/src/kernel/arch/i386/driver/ps2.h
+++ b/src/kernel/arch/i386/driver/ps2.h
@@ -3,5 +3,6 @@
#include <stddef.h>
#include <stdint.h>
+bool ps2_ready(void);
void ps2_recv(uint8_t scancode);
size_t ps2_read(uint8_t *buf, size_t max_len);