summaryrefslogtreecommitdiff
path: root/src/dev
diff options
context:
space:
mode:
authorAndreas Sandberg <andreas.sandberg@arm.com>2018-04-10 09:22:02 +0100
committerAndreas Sandberg <andreas.sandberg@arm.com>2018-04-17 12:24:17 +0000
commit2c0ce271a604be0000b2f1cc1084541714e436ac (patch)
tree457767e1bd2a3240031a1a39c4c59da71db5ad0c /src/dev
parent74e63a607af58c2df49cd2decbebd71a6d061915 (diff)
downloadgem5-2c0ce271a604be0000b2f1cc1084541714e436ac.tar.xz
ps2: Unify constant names
Move ps2.hh to dev/ps2/types.hh and update the device models to consistently use well-known constants from this header. Change-Id: Iadfdc774495957beb82f3d341107b1e9232ffd4c Signed-off-by: Andreas Sandberg <andreas.sandberg@arm.com> Reviewed-by: Giacomo Travaglini <giacomo.travaglini@arm.com> Reviewed-on: https://gem5-review.googlesource.com/9770 Reviewed-by: Gabe Black <gabeblack@google.com> Maintainer: Gabe Black <gabeblack@google.com>
Diffstat (limited to 'src/dev')
-rw-r--r--src/dev/SConscript1
-rw-r--r--src/dev/arm/kmi.cc1
-rw-r--r--src/dev/ps2/SConscript1
-rw-r--r--src/dev/ps2/device.cc2
-rw-r--r--src/dev/ps2/keyboard.cc83
-rw-r--r--src/dev/ps2/keyboard.hh24
-rw-r--r--src/dev/ps2/mouse.cc81
-rw-r--r--src/dev/ps2/mouse.hh21
-rw-r--r--src/dev/ps2/touchkit.cc59
-rw-r--r--src/dev/ps2/touchkit.hh5
-rw-r--r--src/dev/ps2/types.cc (renamed from src/dev/ps2.cc)7
-rw-r--r--src/dev/ps2/types.hh (renamed from src/dev/ps2.hh)74
12 files changed, 173 insertions, 186 deletions
diff --git a/src/dev/SConscript b/src/dev/SConscript
index 6939e03d1..c9526c2a9 100644
--- a/src/dev/SConscript
+++ b/src/dev/SConscript
@@ -50,7 +50,6 @@ Source('intel_8254_timer.cc')
Source('mc146818.cc')
Source('pixelpump.cc')
Source('platform.cc')
-Source('ps2.cc')
DebugFlag('Intel8254Timer')
DebugFlag('MC146818')
diff --git a/src/dev/arm/kmi.cc b/src/dev/arm/kmi.cc
index d80bc14e9..1636d5d62 100644
--- a/src/dev/arm/kmi.cc
+++ b/src/dev/arm/kmi.cc
@@ -47,7 +47,6 @@
#include "base/vnc/vncinput.hh"
#include "debug/Pl050.hh"
#include "dev/arm/amba_device.hh"
-#include "dev/ps2.hh"
#include "dev/ps2/device.hh"
#include "mem/packet.hh"
#include "mem/packet_access.hh"
diff --git a/src/dev/ps2/SConscript b/src/dev/ps2/SConscript
index a73e47a1f..59bc242e6 100644
--- a/src/dev/ps2/SConscript
+++ b/src/dev/ps2/SConscript
@@ -47,5 +47,6 @@ Source('device.cc')
Source('keyboard.cc')
Source('mouse.cc')
Source('touchkit.cc')
+Source('types.cc')
DebugFlag('PS2')
diff --git a/src/dev/ps2/device.cc b/src/dev/ps2/device.cc
index c4d33d505..eb13f8106 100644
--- a/src/dev/ps2/device.cc
+++ b/src/dev/ps2/device.cc
@@ -45,7 +45,7 @@
#include "base/logging.hh"
#include "debug/PS2.hh"
-#include "dev/ps2.hh"
+#include "dev/ps2/types.hh"
#include "params/PS2Device.hh"
PS2Device::PS2Device(const PS2DeviceParams *p)
diff --git a/src/dev/ps2/keyboard.cc b/src/dev/ps2/keyboard.cc
index c9bc21986..c7d5c1fab 100644
--- a/src/dev/ps2/keyboard.cc
+++ b/src/dev/ps2/keyboard.cc
@@ -45,11 +45,9 @@
#include "base/logging.hh"
#include "debug/PS2.hh"
-#include "dev/ps2.hh"
+#include "dev/ps2/types.hh"
#include "params/PS2Keyboard.hh"
-const uint8_t PS2Keyboard::ID[] = {0xab, 0x83};
-
PS2Keyboard::PS2Keyboard(const PS2KeyboardParams *p)
: PS2Device(p),
shiftDown(false),
@@ -79,7 +77,36 @@ bool
PS2Keyboard::recv(const std::vector<uint8_t> &data)
{
switch (data[0]) {
- case LEDWrite:
+ case Ps2::ReadID:
+ DPRINTF(PS2, "Got keyboard read ID command.\n");
+ sendAck();
+ send(Ps2::Keyboard::ID);
+ return true;
+ case Ps2::Enable:
+ DPRINTF(PS2, "Enabling the keyboard.\n");
+ enabled = true;
+ sendAck();
+ return true;
+ case Ps2::Disable:
+ DPRINTF(PS2, "Disabling the keyboard.\n");
+ enabled = false;
+ sendAck();
+ return true;
+ case Ps2::DefaultsAndDisable:
+ DPRINTF(PS2, "Disabling and resetting the keyboard.\n");
+ enabled = false;
+ sendAck();
+ return true;
+ case Ps2::Reset:
+ DPRINTF(PS2, "Resetting keyboard.\n");
+ enabled = true;
+ sendAck();
+ send(Ps2::SelfTestPass);
+ return true;
+ case Ps2::Resend:
+ panic("Keyboard resend unimplemented.\n");
+
+ case Ps2::Keyboard::LEDWrite:
if (data.size() == 1) {
DPRINTF(PS2, "Got LED write command.\n");
sendAck();
@@ -93,16 +120,11 @@ PS2Keyboard::recv(const std::vector<uint8_t> &data)
sendAck();
return true;
}
- case DiagnosticEcho:
+ case Ps2::Keyboard::DiagnosticEcho:
panic("Keyboard diagnostic echo unimplemented.\n");
- case AlternateScanCodes:
+ case Ps2::Keyboard::AlternateScanCodes:
panic("Accessing alternate scan codes unimplemented.\n");
- case ReadID:
- DPRINTF(PS2, "Got keyboard read ID command.\n");
- sendAck();
- send((uint8_t *)&ID, sizeof(ID));
- return true;
- case TypematicInfo:
+ case Ps2::Keyboard::TypematicInfo:
if (data.size() == 1) {
DPRINTF(PS2, "Setting typematic info.\n");
sendAck();
@@ -112,44 +134,21 @@ PS2Keyboard::recv(const std::vector<uint8_t> &data)
sendAck();
return true;
}
- case Enable:
- DPRINTF(PS2, "Enabling the keyboard.\n");
- enabled = true;
- sendAck();
- return true;
- case Disable:
- DPRINTF(PS2, "Disabling the keyboard.\n");
- enabled = false;
- sendAck();
- return true;
- case DefaultsAndDisable:
- DPRINTF(PS2, "Disabling and resetting the keyboard.\n");
- enabled = false;
- sendAck();
- return true;
- case Reset:
- DPRINTF(PS2, "Resetting keyboard.\n");
- sendAck();
- enabled = true;
- send(Ps2::SelfTestPass);
- return true;
- case AllKeysToTypematic:
+ case Ps2::Keyboard::AllKeysToTypematic:
panic("Setting all keys to typemantic unimplemented.\n");
- case AllKeysToMakeRelease:
+ case Ps2::Keyboard::AllKeysToMakeRelease:
panic("Setting all keys to make/release unimplemented.\n");
- case AllKeysToMake:
+ case Ps2::Keyboard::AllKeysToMake:
panic("Setting all keys to make unimplemented.\n");
- case AllKeysToTypematicMakeRelease:
+ case Ps2::Keyboard::AllKeysToTypematicMakeRelease:
panic("Setting all keys to "
"typematic/make/release unimplemented.\n");
- case KeyToTypematic:
+ case Ps2::Keyboard::KeyToTypematic:
panic("Setting a key to typematic unimplemented.\n");
- case KeyToMakeRelease:
+ case Ps2::Keyboard::KeyToMakeRelease:
panic("Setting a key to make/release unimplemented.\n");
- case KeyToMakeOnly:
+ case Ps2::Keyboard::KeyToMakeOnly:
panic("Setting key to make only unimplemented.\n");
- case Resend:
- panic("Keyboard resend unimplemented.\n");
default:
panic("Unknown keyboard command %#02x.\n", data[0]);
}
diff --git a/src/dev/ps2/keyboard.hh b/src/dev/ps2/keyboard.hh
index 33db1cc76..ae0ca85e6 100644
--- a/src/dev/ps2/keyboard.hh
+++ b/src/dev/ps2/keyboard.hh
@@ -52,30 +52,6 @@ struct PS2KeyboardParams;
class PS2Keyboard : public PS2Device, VncKeyboard
{
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
- };
-
-
/** is the shift key currently down */
bool shiftDown;
diff --git a/src/dev/ps2/mouse.cc b/src/dev/ps2/mouse.cc
index 5b6765bcc..ac8d0ae6a 100644
--- a/src/dev/ps2/mouse.cc
+++ b/src/dev/ps2/mouse.cc
@@ -45,11 +45,9 @@
#include "base/logging.hh"
#include "debug/PS2.hh"
+#include "dev/ps2/types.hh"
#include "params/PS2Mouse.hh"
-const uint8_t PS2Mouse::ID[] = {0x00};
-const uint8_t BatSuccessful = 0xaa;
-
PS2Mouse::PS2Mouse(const PS2MouseParams *p)
: PS2Device(p),
status(0), resolution(4), sampleRate(100)
@@ -60,17 +58,45 @@ bool
PS2Mouse::recv(const std::vector<uint8_t> &data)
{
switch (data[0]) {
- case Scale1to1:
+ case Ps2::ReadID:
+ DPRINTF(PS2, "Mouse ID requested.\n");
+ sendAck();
+ send(Ps2::Mouse::ID);
+ return true;
+ case Ps2::Disable:
+ DPRINTF(PS2, "Disabling data reporting.\n");
+ status.enabled = 0;
+ sendAck();
+ return true;
+ case Ps2::Enable:
+ DPRINTF(PS2, "Enabling data reporting.\n");
+ status.enabled = 1;
+ sendAck();
+ return true;
+ case Ps2::Resend:
+ panic("Mouse resend unimplemented.\n");
+ case Ps2::Reset:
+ DPRINTF(PS2, "Resetting the mouse.\n");
+ sampleRate = 100;
+ resolution = 4;
+ status.twoToOne = 0;
+ status.enabled = 0;
+ sendAck();
+ send(Ps2::SelfTestPass);
+ send(Ps2::Mouse::ID);
+ return true;
+
+ case Ps2::Mouse::Scale1to1:
DPRINTF(PS2, "Setting mouse scale to 1:1.\n");
status.twoToOne = 0;
sendAck();
return true;
- case Scale2to1:
+ case Ps2::Mouse::Scale2to1:
DPRINTF(PS2, "Setting mouse scale to 2:1.\n");
status.twoToOne = 1;
sendAck();
return true;
- case SetResolution:
+ case Ps2::Mouse::SetResolution:
if (data.size() == 1) {
DPRINTF(PS2, "Setting mouse resolution.\n");
sendAck();
@@ -81,27 +107,22 @@ PS2Mouse::recv(const std::vector<uint8_t> &data)
sendAck();
return true;
}
- case GetStatus:
+ case Ps2::Mouse::GetStatus:
DPRINTF(PS2, "Getting mouse status.\n");
sendAck();
send((uint8_t *)&(status), 1);
send(&resolution, sizeof(resolution));
send(&sampleRate, sizeof(sampleRate));
return true;
- case ReadData:
+ case Ps2::Mouse::ReadData:
panic("Reading mouse data unimplemented.\n");
- case ResetWrapMode:
+ case Ps2::Mouse::ResetWrapMode:
panic("Resetting mouse wrap mode unimplemented.\n");
- case WrapMode:
+ case Ps2::Mouse::WrapMode:
panic("Setting mouse wrap mode unimplemented.\n");
- case RemoteMode:
+ case Ps2::Mouse::RemoteMode:
panic("Setting mouse remote mode unimplemented.\n");
- case ReadID:
- DPRINTF(PS2, "Mouse ID requested.\n");
- sendAck();
- send(ID, sizeof(ID));
- return true;
- case SampleRate:
+ case Ps2::Mouse::SampleRate:
if (data.size() == 1) {
DPRINTF(PS2, "Setting mouse sample rate.\n");
sendAck();
@@ -113,17 +134,7 @@ PS2Mouse::recv(const std::vector<uint8_t> &data)
sendAck();
return true;
}
- case DisableReporting:
- DPRINTF(PS2, "Disabling data reporting.\n");
- status.enabled = 0;
- sendAck();
- return true;
- case EnableReporting:
- DPRINTF(PS2, "Enabling data reporting.\n");
- status.enabled = 1;
- sendAck();
- return true;
- case DefaultsAndDisable:
+ case Ps2::DefaultsAndDisable:
DPRINTF(PS2, "Disabling and resetting mouse.\n");
sampleRate = 100;
resolution = 4;
@@ -131,21 +142,9 @@ PS2Mouse::recv(const std::vector<uint8_t> &data)
status.enabled = 0;
sendAck();
return true;
- case Resend:
- panic("Mouse resend unimplemented.\n");
- case Reset:
- DPRINTF(PS2, "Resetting the mouse.\n");
- sampleRate = 100;
- resolution = 4;
- status.twoToOne = 0;
- status.enabled = 0;
- sendAck();
- send(&BatSuccessful, sizeof(BatSuccessful));
- send(ID, sizeof(ID));
- return true;
default:
warn("Unknown mouse command %#02x.\n", data[0]);
- send(Resend);
+ send(Ps2::Resend);
return true;
}
}
diff --git a/src/dev/ps2/mouse.hh b/src/dev/ps2/mouse.hh
index 9150f3f8f..c1a497173 100644
--- a/src/dev/ps2/mouse.hh
+++ b/src/dev/ps2/mouse.hh
@@ -51,27 +51,6 @@ struct PS2MouseParams;
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;
diff --git a/src/dev/ps2/touchkit.cc b/src/dev/ps2/touchkit.cc
index 819b06c5d..69387cfb4 100644
--- a/src/dev/ps2/touchkit.cc
+++ b/src/dev/ps2/touchkit.cc
@@ -46,11 +46,9 @@
#include "base/logging.hh"
#include "debug/PS2.hh"
-#include "dev/ps2.hh"
+#include "dev/ps2/types.hh"
#include "params/PS2TouchKit.hh"
-const uint8_t PS2TouchKit::ID[] = {0x00};
-
PS2TouchKit::PS2TouchKit(const PS2TouchKitParams *p)
: PS2Device(p),
vnc(p->vnc),
@@ -82,7 +80,7 @@ bool
PS2TouchKit::recv(const std::vector<uint8_t> &data)
{
switch (data[0]) {
- case Ps2::Ps2Reset:
+ case Ps2::Reset:
DPRINTF(PS2, "Resetting device.\n");
enabled = false;
touchKitEnabled = false;
@@ -90,29 +88,9 @@ PS2TouchKit::recv(const std::vector<uint8_t> &data)
send(Ps2::SelfTestPass);
return true;
- case Ps2::SetResolution:
- case Ps2::SetRate:
- case Ps2::SetStatusLed:
- sendAck();
- return data.size() == 2;
-
- case Ps2::ReadId:
- sendAck();
- send((const uint8_t *)&ID, sizeof(ID));
- return true;
-
- case Ps2::TpReadId:
- // We're not a trackpoint device, this should make the probe
- // go away
- sendAck();
- send(0);
- send(0);
- sendAck();
- return true;
-
- case Ps2::SetScaling1_1:
- case Ps2::SetScaling1_2:
+ case Ps2::ReadID:
sendAck();
+ send(Ps2::Mouse::ID);
return true;
case Ps2::Disable:
@@ -127,20 +105,39 @@ PS2TouchKit::recv(const std::vector<uint8_t> &data)
sendAck();
return true;
- case Ps2::SetDefaults:
+ case Ps2::DefaultsAndDisable:
DPRINTF(PS2, "Setting defaults and disabling device.\n");
enabled = false;
sendAck();
return true;
- case Ps2::StatusRequest:
+ case Ps2::Mouse::Scale1to1:
+ case Ps2::Mouse::Scale2to1:
+ sendAck();
+ return true;
+
+ case Ps2::Mouse::SetResolution:
+ case Ps2::Mouse::SampleRate:
+ sendAck();
+ return data.size() == 2;
+
+ case Ps2::Mouse::GetStatus:
sendAck();
send(0);
send(2); // default resolution
send(100); // default sample rate
return true;
- case Ps2::TouchKitId:
+ case TpReadId:
+ // We're not a trackpoint device, this should make the probe
+ // go away
+ sendAck();
+ send(0);
+ send(0);
+ sendAck();
+ return true;
+
+ case TouchKitDiag:
return recvTouchKit(data);
default:
@@ -155,7 +152,7 @@ PS2TouchKit::recvTouchKit(const std::vector<uint8_t> &data)
sendAck();
// Packet format is: 0x0A SIZE CMD DATA
- assert(data[0] == Ps2::TouchKitId);
+ assert(data[0] == TouchKitDiag);
if (data.size() < 3 || data.size() - 2 < data[1])
return false;
@@ -181,7 +178,7 @@ PS2TouchKit::recvTouchKit(const std::vector<uint8_t> &data)
void
PS2TouchKit::sendTouchKit(const uint8_t *data, size_t size)
{
- send(Ps2::TouchKitId);
+ send(TouchKitDiag);
send(size);
for (int i = 0; i < size; ++i)
send(data[i]);
diff --git a/src/dev/ps2/touchkit.hh b/src/dev/ps2/touchkit.hh
index dc98a78fa..aa413a599 100644
--- a/src/dev/ps2/touchkit.hh
+++ b/src/dev/ps2/touchkit.hh
@@ -48,7 +48,10 @@ struct PS2TouchKitParams;
class PS2TouchKit : public PS2Device, public VncMouse
{
protected:
- static const uint8_t ID[];
+ enum PS2Commands {
+ TpReadId = 0xE1,
+ TouchKitDiag = 0x0A,
+ };
enum TKCommands {
TouchKitActive = 'A',
diff --git a/src/dev/ps2.cc b/src/dev/ps2/types.cc
index 0d6052706..d921d7422 100644
--- a/src/dev/ps2.cc
+++ b/src/dev/ps2/types.cc
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011 ARM Limited
+ * Copyright (c) 2011, 2018 ARM Limited
* All rights reserved
*
* The license below extends only to copyright in the software and shall
@@ -37,13 +37,16 @@
* Authors: Ali Saidi
*/
-#include "dev/ps2.hh"
+#include "dev/ps2/types.hh"
#include <list>
#include "base/logging.hh"
#include "x11keysym/keysym.h"
+const std::vector<uint8_t> Ps2::Keyboard::ID{0xAB, 0x83};
+const std::vector<uint8_t> Ps2::Mouse::ID{0x00};
+
namespace Ps2 {
/** Table to convert simple key symbols (0x00XX) into ps2 bytes. Lower byte
diff --git a/src/dev/ps2.hh b/src/dev/ps2/types.hh
index 7b5783547..1fb3679fc 100644
--- a/src/dev/ps2.hh
+++ b/src/dev/ps2/types.hh
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011 ARM Limited
+ * Copyright (c) 2011, 2018 ARM Limited
* All rights reserved
*
* The license below extends only to copyright in the software and shall
@@ -41,34 +41,66 @@
#define __DEV_PS2_HH__
#include <stdint.h>
+
#include <list>
+#include <vector>
#include "base/bitunion.hh"
-/** @file misc functions and constants required to interface with or emulate ps2
- * devices
+/** @file misc functions and constants required to interface with or
+ * emulate ps2 devices
*/
namespace Ps2 {
+
+enum {
+ SelfTestPass = 0xAA,
+ ReadID = 0xF2,
+ Enable = 0xF4,
+ Disable = 0xF5,
+ DefaultsAndDisable = 0xF6,
+ SelfTestFail = 0xFC,
+ Ack = 0xFA,
+ Resend = 0xFE,
+ Reset = 0xFF,
+};
+
+namespace Keyboard {
+
+enum {
+ LEDWrite = 0xED,
+ DiagnosticEcho = 0xEE,
+ AlternateScanCodes = 0xF0,
+ TypematicInfo = 0xF3,
+ AllKeysToTypematic = 0xF7,
+ AllKeysToMakeRelease = 0xF8,
+ AllKeysToMake = 0xF9,
+ AllKeysToTypematicMakeRelease = 0xFA,
+ KeyToTypematic = 0xFB,
+ KeyToMakeRelease = 0xFC,
+ KeyToMakeOnly = 0xFD,
+};
+
+extern const std::vector<uint8_t> ID;
+
+};
+
+namespace Mouse {
+
enum {
- Ps2Reset = 0xff,
- SelfTestPass = 0xAA,
- SetStatusLed = 0xed,
- SetResolution = 0xe8,
- StatusRequest = 0xe9,
- SetScaling1_2 = 0xe7,
- SetScaling1_1 = 0xe6,
- ReadId = 0xf2,
- TpReadId = 0xe1,
- Ack = 0xfa,
- Resend = 0xfe,
- SetRate = 0xf3,
- Enable = 0xf4,
- Disable = 0xf5,
- SetDefaults = 0xf6,
- KeyboardId = 0xab,
- TouchKitId = 0x0a,
- MouseId = 0x00,
+ Scale1to1 = 0xE6,
+ Scale2to1 = 0xE7,
+ SetResolution = 0xE8,
+ GetStatus = 0xE9,
+ ReadData = 0xEB,
+ ResetWrapMode = 0xEC,
+ WrapMode = 0xEE,
+ RemoteMode = 0xF0,
+ SampleRate = 0xF3,
+};
+
+extern const std::vector<uint8_t> ID;
+
};
/** A bitfield that represents the first byte of a mouse movement packet