#include <debug.h>
#include <stdio.h>
#include <string.h>
-#include "devices/intq.h"
+#include "devices/input.h"
#include "threads/interrupt.h"
#include "threads/io.h"
True when on, false when off. */
static bool caps_lock;
-/* Keyboard buffer. */
-static struct intq buffer;
-
/* Number of keys pressed. */
static int64_t key_cnt;
void
kbd_init (void)
{
- intq_init (&buffer);
intr_register_ext (0x21, keyboard_interrupt, "8042 Keyboard");
}
-/* Retrieves a key from the keyboard buffer.
- If the buffer is empty, waits for a key to be pressed. */
-uint8_t
-kbd_getc (void)
-{
- enum intr_level old_level;
- uint8_t key;
-
- old_level = intr_disable ();
- key = intq_getc (&buffer);
- intr_set_level (old_level);
-
- return key;
-}
-
/* Prints keyboard statistics. */
void
kbd_print_stats (void)
{0x01, "\033"},
{0x0e, "\b"},
{0x0f, "\tQWERTYUIOP"},
- {0x1c, "\n"},
+ {0x1c, "\r"},
{0x1e, "ASDFGHJKL"},
{0x2c, "ZXCVBNM"},
{0x37, "*"},
c += 0x80;
/* Append to keyboard buffer. */
- if (!intq_full (&buffer))
+ if (!input_full ())
{
key_cnt++;
- intq_putc (&buffer, c);
+ input_putc (c);
}
}
}