projects
/
pintos-anon
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Updates.
[pintos-anon]
/
src
/
devices
/
kbd.c
diff --git
a/src/devices/kbd.c
b/src/devices/kbd.c
index 9cd28400864abddcc1a18fa586eaf5951d9a96bb..a26498477cb3397c5f1d771b06303c5c6c3ffaaf 100644
(file)
--- a/
src/devices/kbd.c
+++ b/
src/devices/kbd.c
@@
-25,6
+25,9
@@
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. */
static intr_handler_func keyboard_interrupt;
/* Initializes the keyboard. */
@@
-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