gem5  v20.1.0.0
i8042.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2008 The Regents of The University of Michigan
3  * All rights reserved.
4  *
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.
15  *
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.
27  */
28 
29 #ifndef __DEV_X86_I8042_HH__
30 #define __DEV_X86_I8042_HH__
31 
32 #include <deque>
33 
34 #include "dev/intpin.hh"
35 #include "dev/io_device.hh"
36 #include "dev/ps2/device.hh"
37 #include "params/I8042.hh"
38 
39 namespace X86ISA
40 {
41 
42 class I8042 : public BasicPioDevice
43 {
44  protected:
45  enum Command
46  {
52  LoadPassword = 0xA5,
53  CheckPassword = 0xA6,
54  DisableMouse = 0xA7,
55  EnableMouse = 0xA8,
56  TestMouse = 0xA9,
57  SelfTest = 0xAA,
58  InterfaceTest = 0xAB,
62  ReadInputPort = 0xC0,
69  WriteToMouse = 0xD4,
70  DisableA20 = 0xDD,
71  EnableA20 = 0xDF,
74  SystemReset = 0xFE
75  };
76 
77  BitUnion8(StatusReg)
78  Bitfield<7> parityError;
79  Bitfield<6> timeout;
80  Bitfield<5> mouseOutputFull;
81  Bitfield<4> keyboardUnlocked;
82  Bitfield<3> commandLast;
83  Bitfield<2> passedSelfTest;
84  Bitfield<1> inputFull;
85  Bitfield<0> outputFull;
86  EndBitUnion(StatusReg)
87 
88  BitUnion8(CommandByte)
89  Bitfield<6> convertScanCodes;
90  Bitfield<5> disableMouse;
91  Bitfield<4> disableKeyboard;
92  Bitfield<2> passedSelfTest;
93  Bitfield<1> mouseFullInt;
94  Bitfield<0> keyboardFullInt;
95  EndBitUnion(CommandByte)
96 
97  Tick latency;
100 
101  StatusReg statusReg;
102  CommandByte commandByte;
103 
104  uint8_t dataReg;
105 
106  static const uint16_t NoCommand = (uint16_t)(-1);
107  uint16_t lastCommand;
108 
111 
114 
115  void writeData(uint8_t newData, bool mouse = false);
116  uint8_t readDataOut();
117 
118  public:
119  typedef I8042Params Params;
120 
121  const Params *
122  params() const
123  {
124  return dynamic_cast<const Params *>(_params);
125  }
126 
127  I8042(Params *p);
128 
129  Port &
130  getPort(const std::string &if_name, PortID idx=InvalidPortID) override
131  {
132  if (if_name == "mouse_int_pin")
133  return *mouseIntPin.at(idx);
134  else if (if_name == "keyboard_int_pin")
135  return *keyboardIntPin.at(idx);
136  else
137  return BasicPioDevice::getPort(if_name, idx);
138  }
139 
140  AddrRangeList getAddrRanges() const override;
141 
142  Tick read(PacketPtr pkt) override;
143 
144  Tick write(PacketPtr pkt) override;
145 
146  void serialize(CheckpointOut &cp) const override;
147  void unserialize(CheckpointIn &cp) override;
148 };
149 
150 } // namespace X86ISA
151 
152 #endif //__DEV_X86_I8042_HH__
X86ISA::I8042::timeout
Bitfield< 6 > timeout
Definition: i8042.hh:79
X86ISA::I8042::EnableA20
@ EnableA20
Definition: i8042.hh:71
X86ISA::I8042::lastCommand
uint16_t lastCommand
Definition: i8042.hh:107
X86ISA::I8042::ReadInputPort
@ ReadInputPort
Definition: i8042.hh:62
io_device.hh
X86ISA::I8042::I8042
I8042(Params *p)
Definition: i8042.cc:47
InvalidPortID
const PortID InvalidPortID
Definition: types.hh:238
X86ISA::I8042::getPort
Port & getPort(const std::string &if_name, PortID idx=InvalidPortID) override
Get a port with a given name and index.
Definition: i8042.hh:130
X86ISA::I8042::readDataOut
uint8_t readDataOut()
Definition: i8042.cc:111
X86ISA::I8042::WriteOutputPort
@ WriteOutputPort
Definition: i8042.hh:66
X86ISA::I8042::params
const Params * params() const
Definition: i8042.hh:122
X86ISA::I8042::keyboardIntPin
std::vector< IntSourcePin< I8042 > * > keyboardIntPin
Definition: i8042.hh:110
X86ISA::I8042::Command
Command
Definition: i8042.hh:45
X86ISA::I8042::statusReg
StatusReg statusReg
Definition: i8042.hh:101
X86ISA::I8042::commandLast
Bitfield< 3 > commandLast
Definition: i8042.hh:82
Tick
uint64_t Tick
Tick count type.
Definition: types.hh:63
PortID
int16_t PortID
Port index/ID type, and a symbolic name for an invalid port id.
Definition: types.hh:237
X86ISA::I8042::ContinuousPollHigh
@ ContinuousPollHigh
Definition: i8042.hh:64
X86ISA::I8042::disableKeyboard
Bitfield< 4 > disableKeyboard
Definition: i8042.hh:91
X86ISA::I8042::serialize
void serialize(CheckpointOut &cp) const override
Serialize an object.
Definition: i8042.cc:288
std::vector
STL vector class.
Definition: stl.hh:37
X86ISA::I8042::keyboardUnlocked
Bitfield< 4 > keyboardUnlocked
Definition: i8042.hh:81
X86ISA::I8042::EndBitUnion
EndBitUnion(StatusReg) BitUnion8(CommandByte) Bitfield< 6 > convertScanCodes
PS2Device
Definition: device.hh:51
X86ISA::I8042::mouseFullInt
Bitfield< 1 > mouseFullInt
Definition: i8042.hh:93
X86ISA::I8042::SystemReset
@ SystemReset
Definition: i8042.hh:74
X86ISA::I8042::passedSelfTest
Bitfield< 2 > passedSelfTest
Definition: i8042.hh:83
X86ISA::I8042::DisableMouse
@ DisableMouse
Definition: i8042.hh:54
X86ISA::I8042::WriteToMouse
@ WriteToMouse
Definition: i8042.hh:69
X86ISA::I8042::keyboard
PS2Device * keyboard
Definition: i8042.hh:113
X86ISA::I8042::BitUnion8
BitUnion8(StatusReg) Bitfield< 7 > parityError
X86ISA::I8042::unserialize
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition: i8042.cc:299
X86ISA::I8042::ReadOutputPort
@ ReadOutputPort
Definition: i8042.hh:65
cp
Definition: cprintf.cc:40
X86ISA::I8042::commandPort
Addr commandPort
Definition: i8042.hh:99
X86ISA::I8042::WriteKeyboardOutputBuff
@ WriteKeyboardOutputBuff
Definition: i8042.hh:67
X86ISA::I8042::CheckPassword
@ CheckPassword
Definition: i8042.hh:53
X86ISA::I8042::write
Tick write(PacketPtr pkt) override
Pure virtual function that the device must implement.
Definition: i8042.cc:144
PioDevice::getPort
Port & getPort(const std::string &if_name, PortID idx=InvalidPortID) override
Get a port with a given name and index.
Definition: io_device.cc:64
X86ISA::I8042::getAddrRanges
AddrRangeList getAddrRanges() const override
Determine the address ranges that this device responds to.
Definition: i8042.cc:77
X86ISA::I8042::writeData
void writeData(uint8_t newData, bool mouse=false)
Definition: i8042.cc:87
X86ISA::I8042
Definition: i8042.hh:42
X86ISA::I8042::DisableA20
@ DisableA20
Definition: i8042.hh:70
X86ISA::I8042::mouseOutputFull
Bitfield< 5 > mouseOutputFull
Definition: i8042.hh:80
Port
Ports are used to interface objects to each other.
Definition: port.hh:56
X86ISA::I8042::GetCommandByte
@ GetCommandByte
Definition: i8042.hh:47
X86ISA::I8042::inputFull
Bitfield< 1 > inputFull
Definition: i8042.hh:84
PioDevice::Params
PioDeviceParams Params
Definition: io_device.hh:131
X86ISA::I8042::EnableKeyboard
@ EnableKeyboard
Definition: i8042.hh:61
X86ISA::I8042::mouse
PS2Device * mouse
Definition: i8042.hh:112
X86ISA::I8042::read
Tick read(PacketPtr pkt) override
Pure virtual function that the device must implement.
Definition: i8042.cc:125
X86ISA::I8042::DiagnosticDump
@ DiagnosticDump
Definition: i8042.hh:59
X86ISA::I8042::disableMouse
Bitfield< 5 > disableMouse
Definition: i8042.hh:90
X86ISA::I8042::DisableKeyboard
@ DisableKeyboard
Definition: i8042.hh:60
X86ISA::I8042::commandByte
CommandByte commandByte
Definition: i8042.hh:102
X86ISA
This is exposed globally, independent of the ISA.
Definition: acpi.hh:55
Addr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:142
device.hh
X86ISA::I8042::ContinuousPollLow
@ ContinuousPollLow
Definition: i8042.hh:63
X86ISA::I8042::keyboardFullInt
Bitfield< 0 > keyboardFullInt
Definition: i8042.hh:94
X86ISA::I8042::SelfTest
@ SelfTest
Definition: i8042.hh:57
X86ISA::I8042::Params
I8042Params Params
Definition: i8042.hh:119
X86ISA::I8042::EnableMouse
@ EnableMouse
Definition: i8042.hh:55
X86ISA::I8042::PulseOutputBitBase
@ PulseOutputBitBase
Definition: i8042.hh:73
X86ISA::I8042::ReadControllerRamBase
@ ReadControllerRamBase
Definition: i8042.hh:48
X86ISA::I8042::dataReg
uint8_t dataReg
Definition: i8042.hh:104
X86ISA::p
Bitfield< 0 > p
Definition: pagetable.hh:151
SimObject::_params
const SimObjectParams * _params
Cached copy of the object parameters.
Definition: sim_object.hh:110
Packet
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition: packet.hh:257
BasicPioDevice
Definition: io_device.hh:150
X86ISA::I8042::ReadTestInputs
@ ReadTestInputs
Definition: i8042.hh:72
X86ISA::I8042::TestMouse
@ TestMouse
Definition: i8042.hh:56
X86ISA::I8042::mouseIntPin
std::vector< IntSourcePin< I8042 > * > mouseIntPin
Definition: i8042.hh:109
X86ISA::I8042::dataPort
Addr dataPort
Definition: i8042.hh:98
X86ISA::I8042::WriteMouseOutputBuff
@ WriteMouseOutputBuff
Definition: i8042.hh:68
CheckpointOut
std::ostream CheckpointOut
Definition: serialize.hh:63
intpin.hh
X86ISA::I8042::WriteControllerRamBase
@ WriteControllerRamBase
Definition: i8042.hh:50
X86ISA::I8042::LoadPassword
@ LoadPassword
Definition: i8042.hh:52
X86ISA::I8042::InterfaceTest
@ InterfaceTest
Definition: i8042.hh:58
std::list< AddrRange >
CheckpointIn
Definition: serialize.hh:67
X86ISA::I8042::WriteCommandByte
@ WriteCommandByte
Definition: i8042.hh:49
X86ISA::I8042::NoCommand
static const uint16_t NoCommand
Definition: i8042.hh:106
X86ISA::I8042::CheckForPassword
@ CheckForPassword
Definition: i8042.hh:51
X86ISA::I8042::outputFull
Bitfield< 0 > outputFull
Definition: i8042.hh:85

Generated on Wed Sep 30 2020 14:02:11 for gem5 by doxygen 1.8.17