projects
/
pintos-anon
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Clarify that adding code where interrupts are already disabled may be
[pintos-anon]
/
src
/
devices
/
kbd.c
diff --git
a/src/devices/kbd.c
b/src/devices/kbd.c
index 9cd28400864abddcc1a18fa586eaf5951d9a96bb..1ddf3e243c38220640016f3beb02280b5fa6f049 100644
(file)
--- a/
src/devices/kbd.c
+++ b/
src/devices/kbd.c
@@
-25,14
+25,17
@@
static unsigned shift_state;
/* Keyboard buffer. */
static struct intq buffer;
/* 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)
{
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.
}
/* Retrieves a key from the keyboard buffer.
@@
-49,6
+52,13
@@
kbd_getc (void)
return key;
}
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
\f
/* Maps a set of contiguous scancodes into characters. */
struct keymap
@@
-160,8
+170,11
@@
keyboard_interrupt (struct intr_frame *args UNUSED)
c += 0x80;
/* Append to keyboard buffer. */
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
}
}
else