/* Keyboard buffer. */
static struct intq buffer;
+/* Number of keys pressed. */
+static int64_t key_cnt;
+
static intr_handler_func keyboard_interrupt;
/* Initializes the keyboard. */
void
kbd_init (void)
{
- intq_init (&buffer, "keyboard");
- intr_register (0x21, 0, INTR_OFF, keyboard_interrupt, "8042 Keyboard");
+ intq_init (&buffer);
+ intr_register_ext (0x21, keyboard_interrupt, "8042 Keyboard");
}
/* Retrieves a key from the keyboard buffer.
return key;
}
+
+/* Prints keyboard statistics. */
+void
+kbd_print_stats (void)
+{
+ printf ("Keyboard: %lld keys pressed\n", key_cnt);
+}
\f
/* Maps a set of contiguous scancodes into characters. */
struct keymap
c += 0x80;
/* Append to keyboard buffer. */
- if (!intq_full (&buffer))
- intq_putc (&buffer, c);
+ if (!intq_full (&buffer))
+ {
+ key_cnt++;
+ intq_putc (&buffer, c);
+ }
}
}
else