gem5  v21.0.0.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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 "base/bitunion.hh"
35 #include "dev/intpin.hh"
36 #include "dev/io_device.hh"
37 #include "dev/ps2/device.hh"
38 #include "params/I8042.hh"
39 
40 namespace X86ISA
41 {
42 
43 class I8042 : public BasicPioDevice
44 {
45  protected:
46  enum Command
47  {
53  LoadPassword = 0xA5,
54  CheckPassword = 0xA6,
55  DisableMouse = 0xA7,
56  EnableMouse = 0xA8,
57  TestMouse = 0xA9,
58  SelfTest = 0xAA,
59  InterfaceTest = 0xAB,
63  ReadInputPort = 0xC0,
70  WriteToMouse = 0xD4,
71  DisableA20 = 0xDD,
72  EnableA20 = 0xDF,
75  SystemReset = 0xFE
76  };
77 
78  BitUnion8(StatusReg)
79  Bitfield<7> parityError;
80  Bitfield<6> timeout;
81  Bitfield<5> mouseOutputFull;
82  Bitfield<4> keyboardUnlocked;
83  Bitfield<3> commandLast;
84  Bitfield<2> passedSelfTest;
85  Bitfield<1> inputFull;
86  Bitfield<0> outputFull;
87  EndBitUnion(StatusReg)
88 
89  BitUnion8(CommandByte)
90  Bitfield<6> convertScanCodes;
91  Bitfield<5> disableMouse;
92  Bitfield<4> disableKeyboard;
93  Bitfield<2> passedSelfTest;
94  Bitfield<1> mouseFullInt;
95  Bitfield<0> keyboardFullInt;
96  EndBitUnion(CommandByte)
97 
98  Tick latency;
101 
102  StatusReg statusReg;
103  CommandByte commandByte;
104 
105  uint8_t dataReg;
106 
107  static const uint16_t NoCommand = (uint16_t)(-1);
108  uint16_t lastCommand;
109 
112 
115 
116  void writeData(uint8_t newData, bool mouse = false);
117  uint8_t readDataOut();
118 
119  public:
120  using Params = I8042Params;
121 
122  I8042(const Params &p);
123 
124  Port &
125  getPort(const std::string &if_name, PortID idx=InvalidPortID) override
126  {
127  if (if_name == "mouse_int_pin")
128  return *mouseIntPin.at(idx);
129  else if (if_name == "keyboard_int_pin")
130  return *keyboardIntPin.at(idx);
131  else
132  return BasicPioDevice::getPort(if_name, idx);
133  }
134 
135  AddrRangeList getAddrRanges() const override;
136 
137  Tick read(PacketPtr pkt) override;
138 
139  Tick write(PacketPtr pkt) override;
140 
141  void serialize(CheckpointOut &cp) const override;
142  void unserialize(CheckpointIn &cp) override;
143 };
144 
145 } // namespace X86ISA
146 
147 #endif //__DEV_X86_I8042_HH__
X86ISA::I8042::timeout
Bitfield< 6 > timeout
Definition: i8042.hh:80
X86ISA::I8042::I8042
I8042(const Params &p)
Definition: i8042.cc:47
X86ISA::I8042::EnableA20
@ EnableA20
Definition: i8042.hh:72
X86ISA::I8042::lastCommand
uint16_t lastCommand
Definition: i8042.hh:108
X86ISA::I8042::ReadInputPort
@ ReadInputPort
Definition: i8042.hh:63
io_device.hh
InvalidPortID
const PortID InvalidPortID
Definition: types.hh:244
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:125
X86ISA::I8042::readDataOut
uint8_t readDataOut()
Definition: i8042.cc:111
X86ISA::I8042::WriteOutputPort
@ WriteOutputPort
Definition: i8042.hh:67
X86ISA::I8042::keyboardIntPin
std::vector< IntSourcePin< I8042 > * > keyboardIntPin
Definition: i8042.hh:111
X86ISA::I8042::Command
Command
Definition: i8042.hh:46
X86ISA::I8042::statusReg
StatusReg statusReg
Definition: i8042.hh:102
X86ISA::I8042::commandLast
Bitfield< 3 > commandLast
Definition: i8042.hh:83
Tick
uint64_t Tick
Tick count type.
Definition: types.hh:59
PortID
int16_t PortID
Port index/ID type, and a symbolic name for an invalid port id.
Definition: types.hh:243
X86ISA::I8042::ContinuousPollHigh
@ ContinuousPollHigh
Definition: i8042.hh:65
X86ISA::I8042::disableKeyboard
Bitfield< 4 > disableKeyboard
Definition: i8042.hh:92
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:82
X86ISA::I8042::EndBitUnion
EndBitUnion(StatusReg) BitUnion8(CommandByte) Bitfield< 6 > convertScanCodes
PS2Device
Definition: device.hh:51
X86ISA::I8042::mouseFullInt
Bitfield< 1 > mouseFullInt
Definition: i8042.hh:94
X86ISA::I8042::SystemReset
@ SystemReset
Definition: i8042.hh:75
X86ISA::I8042::passedSelfTest
Bitfield< 2 > passedSelfTest
Definition: i8042.hh:84
X86ISA::I8042::DisableMouse
@ DisableMouse
Definition: i8042.hh:55
X86ISA::I8042::WriteToMouse
@ WriteToMouse
Definition: i8042.hh:70
X86ISA::I8042::keyboard
PS2Device * keyboard
Definition: i8042.hh:114
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:66
cp
Definition: cprintf.cc:37
X86ISA::I8042::commandPort
Addr commandPort
Definition: i8042.hh:100
X86ISA::I8042::WriteKeyboardOutputBuff
@ WriteKeyboardOutputBuff
Definition: i8042.hh:68
X86ISA::I8042::CheckPassword
@ CheckPassword
Definition: i8042.hh:54
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:43
X86ISA::I8042::DisableA20
@ DisableA20
Definition: i8042.hh:71
X86ISA::I8042::mouseOutputFull
Bitfield< 5 > mouseOutputFull
Definition: i8042.hh:81
Port
Ports are used to interface objects to each other.
Definition: port.hh:56
bitunion.hh
X86ISA::I8042::GetCommandByte
@ GetCommandByte
Definition: i8042.hh:48
X86ISA::I8042::inputFull
Bitfield< 1 > inputFull
Definition: i8042.hh:85
X86ISA::I8042::EnableKeyboard
@ EnableKeyboard
Definition: i8042.hh:62
X86ISA::I8042::mouse
PS2Device * mouse
Definition: i8042.hh:113
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:60
X86ISA::I8042::disableMouse
Bitfield< 5 > disableMouse
Definition: i8042.hh:91
X86ISA::I8042::DisableKeyboard
@ DisableKeyboard
Definition: i8042.hh:61
X86ISA::I8042::commandByte
CommandByte commandByte
Definition: i8042.hh:103
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:148
device.hh
X86ISA::I8042::ContinuousPollLow
@ ContinuousPollLow
Definition: i8042.hh:64
X86ISA::I8042::keyboardFullInt
Bitfield< 0 > keyboardFullInt
Definition: i8042.hh:95
X86ISA::I8042::SelfTest
@ SelfTest
Definition: i8042.hh:58
X86ISA::I8042::EnableMouse
@ EnableMouse
Definition: i8042.hh:56
X86ISA::I8042::PulseOutputBitBase
@ PulseOutputBitBase
Definition: i8042.hh:74
X86ISA::I8042::ReadControllerRamBase
@ ReadControllerRamBase
Definition: i8042.hh:49
X86ISA::I8042::dataReg
uint8_t dataReg
Definition: i8042.hh:105
X86ISA::p
Bitfield< 0 > p
Definition: pagetable.hh:148
Packet
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition: packet.hh:258
BasicPioDevice
Definition: io_device.hh:144
X86ISA::I8042::ReadTestInputs
@ ReadTestInputs
Definition: i8042.hh:73
X86ISA::I8042::TestMouse
@ TestMouse
Definition: i8042.hh:57
X86ISA::I8042::mouseIntPin
std::vector< IntSourcePin< I8042 > * > mouseIntPin
Definition: i8042.hh:110
X86ISA::I8042::dataPort
Addr dataPort
Definition: i8042.hh:99
X86ISA::I8042::WriteMouseOutputBuff
@ WriteMouseOutputBuff
Definition: i8042.hh:69
CheckpointOut
std::ostream CheckpointOut
Definition: serialize.hh:64
intpin.hh
X86ISA::I8042::WriteControllerRamBase
@ WriteControllerRamBase
Definition: i8042.hh:51
X86ISA::I8042::LoadPassword
@ LoadPassword
Definition: i8042.hh:53
X86ISA::I8042::InterfaceTest
@ InterfaceTest
Definition: i8042.hh:59
std::list< AddrRange >
CheckpointIn
Definition: serialize.hh:68
X86ISA::I8042::WriteCommandByte
@ WriteCommandByte
Definition: i8042.hh:50
X86ISA::I8042::NoCommand
static const uint16_t NoCommand
Definition: i8042.hh:107
PioDevice::Params
PioDeviceParams Params
Definition: io_device.hh:131
X86ISA::I8042::CheckForPassword
@ CheckForPassword
Definition: i8042.hh:52
X86ISA::I8042::outputFull
Bitfield< 0 > outputFull
Definition: i8042.hh:86

Generated on Tue Mar 23 2021 19:41:27 for gem5 by doxygen 1.8.17