2 * Copyright (c) 2008 The Regents of The University of Michigan
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;
9 * redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution;
12 * neither the name of the copyright holders nor the names of its
13 * contributors may be used to endorse or promote products derived from
14 * this software without specific prior written permission.
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 #ifndef __DEV_X86_I8042_HH__
32 #define __DEV_X86_I8042_HH__
34 #include "dev/io_device.hh"
35 #include "dev/x86/intdev.hh"
36 #include "params/I8042.hh"
45 class I8042 : public BasicPioDevice
49 Bitfield<7> parityError;
51 Bitfield<5> mouseOutputFull;
52 Bitfield<4> keyboardUnlocked;
53 Bitfield<3> commandLast;
54 Bitfield<2> passedSelfTest;
55 Bitfield<1> inputFull;
56 Bitfield<0> outputFull;
57 EndBitUnion(StatusReg)
59 BitUnion8(CommandByte)
60 Bitfield<6> convertScanCodes;
61 Bitfield<5> disableMouse;
62 Bitfield<4> disableKeyboard;
63 Bitfield<2> passedSelfTest;
64 Bitfield<1> mouseFullInt;
65 Bitfield<0> keyboardFullInt;
66 EndBitUnion(CommandByte)
73 CommandByte commandByte;
77 static const uint16_t NoCommand = (uint16_t)(-1);
80 BitUnion8(MouseStatus)
84 Bitfield<2> leftButton;
85 Bitfield<0> rightButton;
86 EndBitUnion(MouseStatus)
88 IntSourcePin *mouseIntPin;
89 std::queue<uint8_t> mouseBuffer;
90 uint16_t lastMouseCommand;
91 uint8_t mouseResolution;
92 uint8_t mouseSampleRate;
93 MouseStatus mouseStatus;
96 IntSourcePin *keyboardIntPin;
97 std::queue<uint8_t> keyboardBuffer;
98 uint16_t lastKeyboardCommand;
100 bool writeData(uint8_t newData, bool mouse = false);
102 void writeKeyboardData(const uint8_t *data, int size);
105 void writeMouseData(const uint8_t *data, int size);
106 uint8_t readDataOut();
109 typedef I8042Params Params;
114 return dynamic_cast<const Params *>(_params);
117 I8042(Params *p) : BasicPioDevice(p), latency(p->pio_latency),
118 dataPort(p->data_port), commandPort(p->command_port),
119 statusReg(0), commandByte(0), dataReg(0), lastCommand(NoCommand),
120 mouseIntPin(p->mouse_int_pin), lastMouseCommand(NoCommand),
121 keyboardIntPin(p->keyboard_int_pin),
122 lastKeyboardCommand(NoCommand)
124 statusReg.passedSelfTest = 1;
125 statusReg.commandLast = 1;
126 statusReg.keyboardUnlocked = 1;
128 commandByte.convertScanCodes = 1;
129 commandByte.passedSelfTest = 1;
130 commandByte.keyboardFullInt = 1;
133 void addressRanges(AddrRangeList &range_list);
135 Tick read(PacketPtr pkt);
137 Tick write(PacketPtr pkt);
140 }; // namespace X86ISA
142 #endif //__DEV_X86_I8042_HH__