projects
/
pintos-anon
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add makefiles for cleaning grades, top level.
[pintos-anon]
/
src
/
devices
/
kbd.c
diff --git
a/src/devices/kbd.c
b/src/devices/kbd.c
index ea9835876a53626e11d00d663e92b7501c4ba157..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. */
@@
-40,14
+43,22
@@
kbd_init (void)
uint8_t
kbd_getc (void)
{
uint8_t
kbd_getc (void)
{
+ enum intr_level old_level;
uint8_t key;
uint8_t key;
-
-
intq_lock (&buffer
);
+
+
old_level = intr_disable (
);
key = intq_getc (&buffer);
key = intq_getc (&buffer);
- int
q_unlock (&buffer
);
+ int
r_set_level (old_level
);
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
@@
-159,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