1/**
2 * \file
3 */
4
5/*
6 * Copyright (c) 2009, ETH Zurich.
7 * All rights reserved.
8 *
9 * This file is distributed under the terms in the attached LICENSE file.
10 * If you do not find this file, copies can be found by writing to:
11 * ETH Zurich D-INFK, Universitaetstrasse 6, CH-8092 Zurich. Attn: Systems Group.
12 */
13
14#ifndef KEYBOARD_H
15#define KEYBOARD_H
16
17#include <stdint.h>
18#include "guest.h"
19#include "x86.h"
20
21struct keyboard {
22    struct guest *guest;
23    uint8_t status;             ///< The status register of this controller
24    uint8_t write_cmd;          ///< Pending write command to the data reg
25};
26
27#define KEYBOARD_STATUS_OUT_DATA            (1 << 0)
28#define KEYBOARD_STATUS_IN_DATA             (1 << 1)
29#define KEYBOARD_STATUS_SYSTEM_FLAG         (1 << 2)
30#define KEYBOARD_STATUS_IN_CMD              (1 << 3)
31#define KEYBOARD_STATUS_ENABLED             (1 << 4)
32#define KEYBOARD_STATUS_TR_TIMEOUT          (1 << 5)
33#define KEYBOARD_STATUS_RC_TIMEOUT          (1 << 6)
34#define KEYBOARD_STATUS_PARITY              (1 << 7)
35
36struct keyboard *keyboard_new (struct guest *g);
37int keyboard_handle_pio_read (struct keyboard *k, uint16_t port,
38                              enum opsize size, uint32_t *val);
39int keyboard_handle_pio_write (struct keyboard *k, uint16_t port,
40                               enum opsize size, uint32_t val);
41int keyboard_handle_int16 (struct keyboard *k, struct guest *g);
42
43#endif // KEYBOARD_H
44