The k project

Keyboard

Description

The keyboard driver is used to add a first form of input in k. It just detects when a key is pressed by configuring the keyboard controller to trigger interrupt when a key is pressed. You have to implement the non-blocking syscall readkey(). The chip managing the keyboard on the IBM PC is the Intel 8042.

Syscall interface

NAME
    readkey - handle the keyboard
SYNOPSIS
    int readkey(struct key_event *event);
DESCRIPTION
    readkey() returns the key events as a FIFO.

    The `event` argument is a `struct key_event` (as specified in `<kstd.h>`):

        struct key_event {
            int state; /* KEY_PRESSED or KEY_RELEASED */
            int key;   /* scan code */
        }

RETURN VALUE
    readkey() returns 0 in case of success.
ERRORS
    -EAGAIN no key event since last call.
SEE ALSO
    Useful constants for scan codes are defined in k/kstd.h.

Possible bug causes