X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?p=pintos-anon;a=blobdiff_plain;f=src%2Fdevices%2Fkbd.c;fp=src%2Fdevices%2Fkbd.c;h=a26498477cb3397c5f1d771b06303c5c6c3ffaaf;hp=9cd28400864abddcc1a18fa586eaf5951d9a96bb;hb=838c30d0075a3ee0413ba4909944b37f4970a10d;hpb=cc409b1863cc91b6a2dbfc963d221ab548132762 diff --git a/src/devices/kbd.c b/src/devices/kbd.c index 9cd2840..a264984 100644 --- a/src/devices/kbd.c +++ b/src/devices/kbd.c @@ -25,6 +25,9 @@ static unsigned shift_state; /* Keyboard buffer. */ static struct intq buffer; +/* Number of keys pressed. */ +static int64_t key_cnt; + static intr_handler_func keyboard_interrupt; /* Initializes the keyboard. */ @@ -49,6 +52,13 @@ kbd_getc (void) return key; } + +/* Prints keyboard statistics. */ +void +kbd_print_stats (void) +{ + printf ("Keyboard: %lld keys pressed\n", key_cnt); +} /* 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. */ - if (!intq_full (&buffer)) - intq_putc (&buffer, c); + if (!intq_full (&buffer)) + { + key_cnt++; + intq_putc (&buffer, c); + } } } else