PKUOS - Pintos
Pintos source browser for PKU Operating System course
|
#include "devices/kbd.h"
#include <ctype.h>
#include <debug.h>
#include <stdio.h>
#include <string.h>
#include "devices/input.h"
#include "devices/shutdown.h"
#include "threads/interrupt.h"
#include "threads/io.h"
Go to the source code of this file.
Data Structures | |
struct | keymap |
Maps a set of contiguous scancodes into characters. More... | |
Macros | |
#define | DATA_REG 0x60 |
Keyboard data register port. More... | |
Functions | |
void | kbd_init (void) |
Initializes the keyboard. More... | |
void | kbd_print_stats (void) |
Prints keyboard statistics. More... | |
static bool | map_key (const struct keymap k[], unsigned scancode, uint8_t *c) |
Scans the array of keymaps K for SCANCODE. More... | |
static void | keyboard_interrupt (struct intr_frame *args UNUSED) |
Variables | |
static bool | left_shift |
Current state of shift keys. More... | |
static bool | right_shift |
Left and right Shift keys. More... | |
static bool | left_alt |
static bool | right_alt |
Left and right Alt keys. More... | |
static bool | left_ctrl |
static bool | right_ctrl |
Left and right Ctl keys. More... | |
static bool | caps_lock |
Status of Caps Lock. More... | |
static int64_t | key_cnt |
Number of keys pressed. More... | |
static intr_handler_func | keyboard_interrupt |
static const struct keymap | invariant_keymap [] |
Keys that produce the same characters regardless of whether the Shift keys are down. More... | |
static const struct keymap | unshifted_keymap [] |
Characters for keys pressed without Shift, for those keys where it matters. More... | |
static const struct keymap | shifted_keymap [] |
Characters for keys pressed with Shift, for those keys where it matters. More... | |
void kbd_init | ( | void | ) |
Initializes the keyboard.
Definition at line 31 of file kbd.c.
References intr_register_ext(), and keyboard_interrupt.
Referenced by pintos_init().
void kbd_print_stats | ( | void | ) |
Prints keyboard statistics.
Definition at line 38 of file kbd.c.
References key_cnt, and printf().
Referenced by print_stats().
|
static |
Definition at line 96 of file kbd.c.
References caps_lock, DATA_REG, inb(), input_full(), input_putc(), invariant_keymap, key_cnt, left_alt, left_ctrl, left_shift, map_key(), NULL, right_alt, right_ctrl, right_shift, shifted_keymap, shutdown_reboot(), tolower(), and unshifted_keymap.
Scans the array of keymaps K for SCANCODE.
If found, sets *C to the corresponding character and returns true. If not found, returns false and C is ignored.
Definition at line 202 of file kbd.c.
References keymap::chars, keymap::first_scancode, and strlen().
Referenced by keyboard_interrupt().
|
static |
Status of Caps Lock.
True when on, false when off.
Definition at line 22 of file kbd.c.
Referenced by keyboard_interrupt().
|
static |
Keys that produce the same characters regardless of whether the Shift keys are down.
Case of letters is an exception that we handle elsewhere.
Definition at line 55 of file kbd.c.
Referenced by keyboard_interrupt().
|
static |
Number of keys pressed.
Definition at line 25 of file kbd.c.
Referenced by kbd_print_stats(), and keyboard_interrupt().
|
static |
Definition at line 27 of file kbd.c.
Referenced by kbd_init().
|
static |
Definition at line 17 of file kbd.c.
Referenced by keyboard_interrupt().
|
static |
Definition at line 18 of file kbd.c.
Referenced by keyboard_interrupt().
|
static |
Current state of shift keys.
True if depressed, false otherwise.
Definition at line 16 of file kbd.c.
Referenced by keyboard_interrupt().
|
static |
|
static |
|
static |
|
static |
Characters for keys pressed with Shift, for those keys where it matters.
Definition at line 83 of file kbd.c.
Referenced by keyboard_interrupt().
|
static |
Characters for keys pressed without Shift, for those keys where it matters.
Definition at line 71 of file kbd.c.
Referenced by keyboard_interrupt().