summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2011-11-01 03:49:48 (GMT)
committerH. Peter Anvin <hpa@zytor.com>2011-11-01 03:49:48 (GMT)
commita45424841619a95d0e83441b8862442b94b7c0eb (patch)
tree0ff592b6b3f98456eab09334c3a33234cc085204
parentc944b9eab634e4b3c619e1e9535c94436440ab9e (diff)
downloadabc8000-old-a45424841619a95d0e83441b8862442b94b7c0eb.zip
abc8000-old-a45424841619a95d0e83441b8862442b94b7c0eb.tar.gz
abc8000-old-a45424841619a95d0e83441b8862442b94b7c0eb.tar.bz2
abc8000-old-a45424841619a95d0e83441b8862442b94b7c0eb.tar.xz
keyboard: correct ring buffer wraparound
Correct ring buffer wraparound; add a prototype to keyboard initialization.
-rw-r--r--data/sysrom/keyboard.c2
-rw-r--r--data/sysrom/sysrom.h5
2 files changed, 6 insertions, 1 deletions
diff --git a/data/sysrom/keyboard.c b/data/sysrom/keyboard.c
index 7251009..34117c0 100644
--- a/data/sysrom/keyboard.c
+++ b/data/sysrom/keyboard.c
@@ -178,7 +178,7 @@ static void __attribute__((interrupt)) keyboard_irq(void)
sym = key_data[scan][bucky];
if (kbd_head != kbd_tail) {
kbd_ringbuf[kbd_head] = sym;
- kbd_head = (kbd_head + 1) % sizeof kbd_ringbuf;
+ kbd_head = (kbd_head + 1) % ELEMENTS(kbd_ringbuf);
}
break;
}
diff --git a/data/sysrom/sysrom.h b/data/sysrom/sysrom.h
index 8fe9e45..6d4ce5e 100644
--- a/data/sysrom/sysrom.h
+++ b/data/sysrom/sysrom.h
@@ -1,8 +1,11 @@
#ifndef SYSROM_H
+#define SYSROM_H
#include <klibc/compiler.h>
#include <stdint.h>
+#define ELEMENTS(x) (sizeof(x)/sizeof((x)[0]))
+
typedef void (*ivt_t)(void);
extern ivt_t ivt[256];
@@ -22,4 +25,6 @@ int sdcard_write_sectors(const void *buf, uint32_t lba, int count);
int exec_file(const char *filename, void *addr);
void disk_boot(void);
+void keyboard_init(void);
+
#endif /* SYSROM_H */