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__
36 #include "dev/intpin.hh"
37 #include "dev/io_device.hh"
38 #include "dev/ps2/device.hh"
39 #include "params/I8042.hh"
44 class I8042 : public BasicPioDevice
49 GetCommandByte = 0x20,
50 ReadControllerRamBase = 0x20,
51 WriteCommandByte = 0x60,
52 WriteControllerRamBase = 0x60,
53 CheckForPassword = 0xA4,
61 DiagnosticDump = 0xAC,
62 DisableKeyboard = 0xAD,
63 EnableKeyboard = 0xAE,
65 ContinuousPollLow = 0xC1,
66 ContinuousPollHigh = 0xC2,
67 ReadOutputPort = 0xD0,
68 WriteOutputPort = 0xD1,
69 WriteKeyboardOutputBuff = 0xD2,
70 WriteMouseOutputBuff = 0xD3,
74 ReadTestInputs = 0xE0,
75 PulseOutputBitBase = 0xF0,
80 Bitfield<7> parityError;
82 Bitfield<5> mouseOutputFull;
83 Bitfield<4> keyboardUnlocked;
84 Bitfield<3> commandLast;
85 Bitfield<2> passedSelfTest;
86 Bitfield<1> inputFull;
87 Bitfield<0> outputFull;
88 EndBitUnion(StatusReg)
90 BitUnion8(CommandByte)
91 Bitfield<6> convertScanCodes;
92 Bitfield<5> disableMouse;
93 Bitfield<4> disableKeyboard;
94 Bitfield<2> passedSelfTest;
95 Bitfield<1> mouseFullInt;
96 Bitfield<0> keyboardFullInt;
97 EndBitUnion(CommandByte)
104 CommandByte commandByte;
108 static const uint16_t NoCommand = (uint16_t)(-1);
109 uint16_t lastCommand;
111 std::vector<IntSourcePin<I8042> *> mouseIntPin;
112 std::vector<IntSourcePin<I8042> *> keyboardIntPin;
117 void writeData(uint8_t newData, bool mouse = false);
118 uint8_t readDataOut();
121 typedef I8042Params Params;
126 return dynamic_cast<const Params *>(_params);
132 getPort(const std::string &if_name, PortID idx=InvalidPortID) override
134 if (if_name == "mouse_int_pin")
135 return *mouseIntPin.at(idx);
136 else if (if_name == "keyboard_int_pin")
137 return *keyboardIntPin.at(idx);
139 return BasicPioDevice::getPort(if_name, idx);
142 AddrRangeList getAddrRanges() const override;
144 Tick read(PacketPtr pkt) override;
146 Tick write(PacketPtr pkt) override;
148 void serialize(CheckpointOut &cp) const override;
149 void unserialize(CheckpointIn &cp) override;
152 } // namespace X86ISA
154 #endif //__DEV_X86_I8042_HH__