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

Generated on Fri Feb 28 2020 16:27:01 for gem5 by doxygen 1.8.13