gem5  v22.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 "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 gem5
41 {
42 
43 namespace X86ISA
44 {
45 
46 class I8042 : public PioDevice
47 {
48  protected:
49  enum Command
50  {
56  LoadPassword = 0xA5,
57  CheckPassword = 0xA6,
58  DisableMouse = 0xA7,
59  EnableMouse = 0xA8,
60  TestMouse = 0xA9,
61  SelfTest = 0xAA,
62  InterfaceTest = 0xAB,
66  ReadInputPort = 0xC0,
73  WriteToMouse = 0xD4,
74  DisableA20 = 0xDD,
75  EnableA20 = 0xDF,
78  SystemReset = 0xFE
79  };
80 
81  BitUnion8(StatusReg)
82  Bitfield<7> parityError;
83  Bitfield<6> timeout;
84  Bitfield<5> mouseOutputFull;
85  Bitfield<4> keyboardUnlocked;
86  Bitfield<3> commandLast;
87  Bitfield<2> passedSelfTest;
88  Bitfield<1> inputFull;
89  Bitfield<0> outputFull;
90  EndBitUnion(StatusReg)
91 
92  BitUnion8(CommandByte)
93  Bitfield<6> convertScanCodes;
94  Bitfield<5> disableMouse;
95  Bitfield<4> disableKeyboard;
96  Bitfield<2> passedSelfTest;
97  Bitfield<1> mouseFullInt;
98  Bitfield<0> keyboardFullInt;
99  EndBitUnion(CommandByte)
100 
101  Tick latency = 0;
104 
105  StatusReg statusReg = 0;
106  CommandByte commandByte = 0;
107 
108  uint8_t dataReg = 0;
109 
110  static inline const uint16_t NoCommand = (uint16_t)(-1);
111  uint16_t lastCommand = NoCommand;
112 
115 
116  ps2::Device *mouse = nullptr;
117  ps2::Device *keyboard = nullptr;
118 
119  void writeData(uint8_t newData, bool mouse=false);
120  uint8_t readDataOut();
121 
122  public:
123  using Params = I8042Params;
124 
125  I8042(const Params &p);
126 
127  Port &
128  getPort(const std::string &if_name, PortID idx=InvalidPortID) override
129  {
130  if (if_name == "mouse_int_pin")
131  return *mouseIntPin.at(idx);
132  else if (if_name == "keyboard_int_pin")
133  return *keyboardIntPin.at(idx);
134  else
135  return PioDevice::getPort(if_name, idx);
136  }
137 
138  AddrRangeList getAddrRanges() const override;
139 
140  Tick read(PacketPtr pkt) override;
141 
142  Tick write(PacketPtr pkt) override;
143 
144  void serialize(CheckpointOut &cp) const override;
145  void unserialize(CheckpointIn &cp) override;
146 };
147 
148 } // namespace X86ISA
149 } // namespace gem5
150 
151 #endif //__DEV_X86_I8042_HH__
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition: packet.hh:294
This device is the base class which all devices senstive to an address range inherit from.
Definition: io_device.hh:103
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
PioDeviceParams Params
Definition: io_device.hh:134
Ports are used to interface objects to each other.
Definition: port.hh:62
Bitfield< 5 > disableMouse
Definition: i8042.hh:94
uint8_t readDataOut()
Definition: i8042.cc:109
Bitfield< 5 > mouseOutputFull
Definition: i8042.hh:84
@ WriteKeyboardOutputBuff
Definition: i8042.hh:71
@ WriteControllerRamBase
Definition: i8042.hh:54
ps2::Device * mouse
Definition: i8042.hh:116
uint8_t dataReg
Definition: i8042.hh:108
void writeData(uint8_t newData, bool mouse=false)
Definition: i8042.cc:85
uint16_t lastCommand
Definition: i8042.hh:111
Port & getPort(const std::string &if_name, PortID idx=InvalidPortID) override
Get a port with a given name and index.
Definition: i8042.hh:128
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition: i8042.cc:312
Bitfield< 4 > disableKeyboard
Definition: i8042.hh:95
Bitfield< 0 > keyboardFullInt
Definition: i8042.hh:98
ps2::Device * keyboard
Definition: i8042.hh:117
static const uint16_t NoCommand
Definition: i8042.hh:110
EndBitUnion(StatusReg) BitUnion8(CommandByte) Bitfield< 6 > convertScanCodes
BitUnion8(StatusReg) Bitfield< 7 > parityError
StatusReg statusReg
Definition: i8042.hh:105
I8042(const Params &p)
Definition: i8042.cc:50
std::vector< IntSourcePin< I8042 > * > keyboardIntPin
Definition: i8042.hh:114
Bitfield< 3 > commandLast
Definition: i8042.hh:86
Bitfield< 0 > outputFull
Definition: i8042.hh:89
EndBitUnion(CommandByte) Tick latency=0
Bitfield< 1 > mouseFullInt
Definition: i8042.hh:97
std::vector< IntSourcePin< I8042 > * > mouseIntPin
Definition: i8042.hh:113
Tick write(PacketPtr pkt) override
Pure virtual function that the device must implement.
Definition: i8042.cc:142
Bitfield< 4 > keyboardUnlocked
Definition: i8042.hh:85
Bitfield< 2 > passedSelfTest
Definition: i8042.hh:87
CommandByte commandByte
Definition: i8042.hh:106
void serialize(CheckpointOut &cp) const override
Serialize an object.
Definition: i8042.cc:301
AddrRangeList getAddrRanges() const override
Every PIO device is obliged to provide an implementation that returns the address ranges the device r...
Definition: i8042.cc:76
Bitfield< 6 > timeout
Definition: i8042.hh:83
Tick read(PacketPtr pkt) override
Pure virtual function that the device must implement.
Definition: i8042.cc:123
Bitfield< 1 > inputFull
Definition: i8042.hh:88
STL vector class.
Definition: stl.hh:37
Bitfield< 0 > p
Definition: pagetable.hh:151
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
const PortID InvalidPortID
Definition: types.hh:246
std::ostream CheckpointOut
Definition: serialize.hh:66
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:147
int16_t PortID
Port index/ID type, and a symbolic name for an invalid port id.
Definition: types.hh:245
uint64_t Tick
Tick count type.
Definition: types.hh:58

Generated on Wed Dec 21 2022 10:22:35 for gem5 by doxygen 1.9.1