summaryrefslogtreecommitdiff
path: root/src/dev/x86/i8042.hh
diff options
context:
space:
mode:
authorAndreas Sandberg <andreas.sandberg@arm.com>2017-07-11 16:26:24 +0100
committerAndreas Sandberg <andreas.sandberg@arm.com>2018-04-17 08:46:33 +0000
commit18f62ac208a3fc8d385e66c3b5ff22473229d1d7 (patch)
treed4a2cb0daa1d3735e59696bc5484162acbd62cb9 /src/dev/x86/i8042.hh
parent7c21795304e6ec79ed8c35873c4419a6342eb1e3 (diff)
downloadgem5-18f62ac208a3fc8d385e66c3b5ff22473229d1d7.tar.xz
ps2: Factor out PS/2 devices into their own subsystem
PS/2 devices are currently emulated both in the i8042 model and the Arm KMI model. This is undesirable since it leads to code duplication. This change introduces a common PS/2 device interface and factor out the x86 keyboard and mouse model. A subsequent commit will implement support for this interface in the Arm KMI model. Change-Id: I440e83517fd9dce362fdc1676db477cc6eee5211 Signed-off-by: Andreas Sandberg <andreas.sandberg@arm.com> Reviewed-by: Giacomo Travaglini <giacomo.travaglini@arm.com> Reviewed-on: https://gem5-review.googlesource.com/9762 Reviewed-by: Gabe Black <gabeblack@google.com> Maintainer: Gabe Black <gabeblack@google.com>
Diffstat (limited to 'src/dev/x86/i8042.hh')
-rw-r--r--src/dev/x86/i8042.hh119
1 files changed, 4 insertions, 115 deletions
diff --git a/src/dev/x86/i8042.hh b/src/dev/x86/i8042.hh
index 82d07e9cf..0f38da9ba 100644
--- a/src/dev/x86/i8042.hh
+++ b/src/dev/x86/i8042.hh
@@ -33,8 +33,9 @@
#include <deque>
-#include "dev/x86/intdev.hh"
#include "dev/io_device.hh"
+#include "dev/ps2/device.hh"
+#include "dev/x86/intdev.hh"
#include "params/I8042.hh"
namespace X86ISA
@@ -42,118 +43,6 @@ namespace X86ISA
class IntPin;
-class PS2Device
-{
- protected:
- std::deque<uint8_t> outBuffer;
-
- static const uint16_t NoCommand = (uint16_t)(-1);
-
- uint16_t lastCommand;
- void bufferData(const uint8_t *data, int size);
- void ack();
- void nack();
-
- public:
- virtual ~PS2Device()
- {};
-
- PS2Device() : lastCommand(NoCommand)
- {}
-
- virtual void serialize(const std::string &base, CheckpointOut &cp) const;
- virtual void unserialize(const std::string &base, CheckpointIn &cp);
-
- bool hasData()
- {
- return !outBuffer.empty();
- }
-
- uint8_t getData()
- {
- uint8_t data = outBuffer.front();
- outBuffer.pop_front();
- return data;
- }
-
- virtual bool processData(uint8_t data) = 0;
-};
-
-class PS2Mouse : public PS2Device
-{
- protected:
- static const uint8_t ID[];
-
- enum Command
- {
- Scale1to1 = 0xE6,
- Scale2to1 = 0xE7,
- SetResolution = 0xE8,
- GetStatus = 0xE9,
- ReadData = 0xEB,
- ResetWrapMode = 0xEC,
- WrapMode = 0xEE,
- RemoteMode = 0xF0,
- ReadID = 0xF2,
- SampleRate = 0xF3,
- EnableReporting = 0xF4,
- DisableReporting = 0xF5,
- DefaultsAndDisable = 0xF6,
- Resend = 0xFE,
- Reset = 0xFF
- };
-
- BitUnion8(Status)
- Bitfield<6> remote;
- Bitfield<5> enabled;
- Bitfield<4> twoToOne;
- Bitfield<2> leftButton;
- Bitfield<0> rightButton;
- EndBitUnion(Status)
-
- Status status;
- uint8_t resolution;
- uint8_t sampleRate;
- public:
- PS2Mouse() : PS2Device(), status(0), resolution(4), sampleRate(100)
- {}
-
- bool processData(uint8_t data) override;
-
- void serialize(const std::string &base, CheckpointOut &cp) const override;
- void unserialize(const std::string &base, CheckpointIn &cp) override;
-};
-
-class PS2Keyboard : public PS2Device
-{
- protected:
- static const uint8_t ID[];
-
- enum Command
- {
- LEDWrite = 0xED,
- DiagnosticEcho = 0xEE,
- AlternateScanCodes = 0xF0,
- ReadID = 0xF2,
- TypematicInfo = 0xF3,
- Enable = 0xF4,
- Disable = 0xF5,
- DefaultsAndDisable = 0xF6,
- AllKeysToTypematic = 0xF7,
- AllKeysToMakeRelease = 0xF8,
- AllKeysToMake = 0xF9,
- AllKeysToTypematicMakeRelease = 0xFA,
- KeyToTypematic = 0xFB,
- KeyToMakeRelease = 0xFC,
- KeyToMakeOnly = 0xFD,
- Resend = 0xFE,
- Reset = 0xFF
- };
-
- public:
- bool processData(uint8_t data) override;
-};
-
class I8042 : public BasicPioDevice
{
protected:
@@ -224,8 +113,8 @@ class I8042 : public BasicPioDevice
IntSourcePin *mouseIntPin;
IntSourcePin *keyboardIntPin;
- PS2Mouse mouse;
- PS2Keyboard keyboard;
+ PS2Device *mouse;
+ PS2Device *keyboard;
void writeData(uint8_t newData, bool mouse = false);
uint8_t readDataOut();