1/*
2 * Copyright (c) 2007, 2008, 2009, 2011, ETH Zurich. All rights reserved.
3 *
4 * This file is distributed under the terms in the attached LICENSE file.
5 * If you do not find this file, copies can be found by writing to:
6 * ETH Zurich D-INFK, Universitaetstrasse 6, CH-8092 Zurich. Attn: Systems Group.
7 */
8
9/*
10 * lpc_kbd.dev
11 *
12 * DESCRIPTION: Legacy keyboard and mouse port
13 *
14 * This file does not fully describe the 8042, which is not supported
15 * on most PCs anymore.
16 *
17 * Ref: http://www.mcamafia.de/pdf/ibm_hitrc07.pdf
18 */
19
20device lpc_kbd msbfirst (io base) "LPC Keyboard" {
21    register input ro io(base, 0) "Input" type(uint8);
22    register status ro io(base, 4) "Status" {
23        perr    1 "Parity error";
24        timeout 1 "General timeout";
25        aobf    1 "Auxiliary device output buffer full";
26        is      1 "Inhibit switch";
27        cd      1 "Command/data";
28        sf      1 "System flag";
29        ibf     1 "Input buffer full";
30        obf     1 "Output buffer full";
31    };
32
33    register output wo also io(base, 0) "Output" type(uint8);
34
35    constants cmd "Command" {
36        /* XXX: I don't attempt to encode the silly read/write RAM commands,
37         * since they mix a bitfield and a constant in the same register.
38         */
39        rd_ccmd         = 0x20 "Read controller command byte";
40        wr_ccmd         = 0x60 "Write controller command byte";
41        aux_disable     = 0xa7 "Disable auxiliary device interface";
42        aux_enable      = 0xa8 "Enable auxiliary device interface";
43        kbd_disable     = 0xad "Disable keyboard interface";
44        kbd_enable      = 0xae "Enable keyboard interface";
45        read_input      = 0xc0 "Read input port";
46        poll_input_low  = 0xc1 "Poll input port low";
47        poll_input_high = 0xc2 "Poll input port high";
48        read_output     = 0xd0 "Read output port";
49        write_output    = 0xd1 "Write output port";
50        write_kbd_out   = 0xd2 "Write keyboard output buffer";
51        write_aux_out   = 0xd3 "Write auxiliary device output buffer";
52        write_aux       = 0xd4 "Write to auxiliary device";
53    };
54
55    // FIXME: why won't Mackerel allow this?
56    // register command wo also io(base, 4) "Command" type(command);
57    register command wo also io(base, 4) "Command" {
58        cmd     8 type(cmd) "Command";
59    };
60
61    /* This is the format of the "controller command" byte, which is data
62     * returned in response to an 0x20 command, and not to be confused with
63     * the command register, which is write-only.
64     */
65    regtype ccmd "Controller command byte" {
66        _       1;
67        kbd_xl  1 "Keyboard translate";
68        aux_dis 1 "Disable auxiliary device";
69        kbd_dis 1 "Disable keyboard";
70        _       1;
71        sysflg  1 "System flag";
72        aux_int 1 "Enable auxiliary interrupt";
73        kbd_int 1 "Enable keyboard interrupt";
74    };
75};
76