Daniel Carvalho has uploaded this change for review. ( https://gem5-review.googlesource.com/c/public/gem5/+/45395 )

Change subject: dev: Put PS2 classes in the ps2 namespace
......................................................................

dev: Put PS2 classes in the ps2 namespace

These classes belong in the ps2 namespace. Use this
opportunity to rename PS2Device as ps2::Device, and
PS2TouchKit as ps2::TouchKit.

Unfortunately, since the ps2::Mouse and ps2::Keyboard
namespaces are being deprecated, these names cannot be
used as of now to rename PS2Mouse and PS2Keyboard.

Change-Id: I9a57b87053a6a0acb380a919e09ab427fdb8eca4
Signed-off-by: Daniel R. Carvalho <[email protected]>
---
M src/dev/arm/kmi.hh
M src/dev/ps2/PS2.py
M src/dev/ps2/device.cc
M src/dev/ps2/device.hh
M src/dev/ps2/keyboard.cc
M src/dev/ps2/keyboard.hh
M src/dev/ps2/mouse.cc
M src/dev/ps2/mouse.hh
M src/dev/ps2/touchkit.cc
M src/dev/ps2/touchkit.hh
M src/dev/x86/i8042.hh
11 files changed, 113 insertions(+), 63 deletions(-)



diff --git a/src/dev/arm/kmi.hh b/src/dev/arm/kmi.hh
index 03e9dbd..5a9894b 100644
--- a/src/dev/arm/kmi.hh
+++ b/src/dev/arm/kmi.hh
@@ -52,7 +52,9 @@
 #include "dev/arm/amba_device.hh"
 #include "params/Pl050.hh"

-class PS2Device;
+namespace ps2 {
+class Device;
+} // namespace ps2

 class Pl050 : public AmbaIntDevice
 {
@@ -123,7 +125,7 @@
     InterruptReg getInterrupt() const;

     /** PS2 device connected to this KMI interface */
-    PS2Device *ps2Device;
+    ps2::Device *ps2Device;

   public:
     Pl050(const Pl050Params &p);
diff --git a/src/dev/ps2/PS2.py b/src/dev/ps2/PS2.py
index b250859..3c31b6b 100644
--- a/src/dev/ps2/PS2.py
+++ b/src/dev/ps2/PS2.py
@@ -40,20 +40,24 @@
 class PS2Device(SimObject):
     type = 'PS2Device'
     cxx_header = "dev/ps2/device.hh"
+    cxx_class = "ps2::Device"
     abstract = True

 class PS2Keyboard(PS2Device):
     type = 'PS2Keyboard'
     cxx_header = "dev/ps2/keyboard.hh"
+    cxx_class = "ps2::PS2Keyboard"

     vnc = Param.VncInput(Parent.any, "VNC server providing keyboard input")

 class PS2Mouse(PS2Device):
     type = 'PS2Mouse'
     cxx_header = "dev/ps2/mouse.hh"
+    cxx_class = "ps2::PS2Mouse"

 class PS2TouchKit(PS2Device):
     type = 'PS2TouchKit'
     cxx_header = "dev/ps2/touchkit.hh"
+    cxx_class = "ps2::TouchKit"

     vnc = Param.VncInput(Parent.any, "VNC server providing mouse input")
diff --git a/src/dev/ps2/device.cc b/src/dev/ps2/device.cc
index b9dfafb..34d5387 100644
--- a/src/dev/ps2/device.cc
+++ b/src/dev/ps2/device.cc
@@ -40,6 +40,8 @@

 #include "dev/ps2/device.hh"

+#include <algorithm>
+
 #include "base/logging.hh"
 #include "base/trace.hh"
 #include "debug/PS2.hh"
@@ -47,14 +49,16 @@
 #include "params/PS2Device.hh"
 #include "sim/serialize.hh"

-PS2Device::PS2Device(const PS2DeviceParams &p)
+namespace ps2 {
+
+Device::Device(const PS2DeviceParams &p)
     : SimObject(p)
 {
     inBuffer.reserve(16);
 }

 void
-PS2Device::serialize(CheckpointOut &cp) const
+Device::serialize(CheckpointOut &cp) const
 {
     std::vector<uint8_t> buffer(outBuffer.size());
     std::copy(outBuffer.begin(), outBuffer.end(), buffer.begin());
@@ -64,7 +68,7 @@
 }

 void
-PS2Device::unserialize(CheckpointIn &cp)
+Device::unserialize(CheckpointIn &cp)
 {
     std::vector<uint8_t> buffer;
     arrayParamIn(cp, "outBuffer", buffer);
@@ -75,7 +79,7 @@
 }

 void
-PS2Device::hostRegDataAvailable(const std::function<void()> &c)
+Device::hostRegDataAvailable(const std::function<void()> &c)
 {
     fatal_if(dataAvailableCallback,
"A data pending callback has already been associated with this "
@@ -85,7 +89,7 @@
 }

 uint8_t
-PS2Device::hostRead()
+Device::hostRead()
 {
     uint8_t data = outBuffer.front();
     outBuffer.pop_front();
@@ -93,7 +97,7 @@
 }

 void
-PS2Device::hostWrite(uint8_t c)
+Device::hostWrite(uint8_t c)
 {
     DPRINTF(PS2, "PS2: Host -> device: %#x\n", c);
     inBuffer.push_back(c);
@@ -102,7 +106,7 @@
 }

 void
-PS2Device::send(const uint8_t *data, size_t size)
+Device::send(const uint8_t *data, size_t size)
 {
     assert(data || size == 0);
     while (size) {
@@ -117,7 +121,9 @@
 }

 void
-PS2Device::sendAck()
+Device::sendAck()
 {
-    send(ps2::Ack);
+    send(Ack);
 }
+
+} // namespace ps2
diff --git a/src/dev/ps2/device.hh b/src/dev/ps2/device.hh
index 9671876..5eecb55 100644
--- a/src/dev/ps2/device.hh
+++ b/src/dev/ps2/device.hh
@@ -41,17 +41,24 @@
 #ifndef __DEV_PS2_DEVICE_HH__
 #define __DEV_PS2_DEVICE_HH__

+#include <cstdint>
 #include <deque>
+#include <functional>
 #include <vector>

+#include "base/compiler.hh"
 #include "sim/sim_object.hh"

 struct PS2DeviceParams;

-class PS2Device : public SimObject
+namespace ps2 {
+
+GEM5_DEPRECATED_CLASS(PS2Device, Device);
+
+class Device : public SimObject
 {
   public:
-    PS2Device(const PS2DeviceParams &p);
+    Device(const PS2DeviceParams &p);

     void serialize(CheckpointOut &cp) const override;
     void unserialize(CheckpointIn &cp) override;
@@ -142,4 +149,6 @@
     std::function<void()> dataAvailableCallback;
 };

+} // namespace ps2
+
 #endif // __DEV_PS2_HOUSE_HH__
diff --git a/src/dev/ps2/keyboard.cc b/src/dev/ps2/keyboard.cc
index 29ff9ee..87dca9c 100644
--- a/src/dev/ps2/keyboard.cc
+++ b/src/dev/ps2/keyboard.cc
@@ -40,16 +40,21 @@

 #include "dev/ps2/keyboard.hh"

+#include <cstdint>
+#include <list>
+
 #include "base/logging.hh"
 #include "base/trace.hh"
 #include "debug/PS2.hh"
 #include "dev/ps2/types.hh"
 #include "params/PS2Keyboard.hh"

+namespace ps2 {
+
 const std::vector<uint8_t> PS2Keyboard::ID{0xAB, 0x83};

 PS2Keyboard::PS2Keyboard(const PS2KeyboardParams &p)
-    : PS2Device(p),
+    : Device(p),
       shiftDown(false),
       enabled(false)
 {
@@ -60,7 +65,7 @@
 void
 PS2Keyboard::serialize(CheckpointOut &cp) const
 {
-    PS2Device::serialize(cp);
+    Device::serialize(cp);
     SERIALIZE_SCALAR(shiftDown);
     SERIALIZE_SCALAR(enabled);
 }
@@ -68,7 +73,7 @@
 void
 PS2Keyboard::unserialize(CheckpointIn &cp)
 {
-    PS2Device::unserialize(cp);
+    Device::unserialize(cp);
     UNSERIALIZE_SCALAR(shiftDown);
     UNSERIALIZE_SCALAR(enabled);
 }
@@ -77,33 +82,33 @@
 PS2Keyboard::recv(const std::vector<uint8_t> &data)
 {
     switch (data[0]) {
-      case ps2::ReadID:
+      case ReadID:
         DPRINTF(PS2, "Got keyboard read ID command.\n");
         sendAck();
         send(ID);
         return true;
-      case ps2::Enable:
+      case Enable:
         DPRINTF(PS2, "Enabling the keyboard.\n");
         enabled = true;
         sendAck();
         return true;
-      case ps2::Disable:
+      case Disable:
         DPRINTF(PS2, "Disabling the keyboard.\n");
         enabled = false;
         sendAck();
         return true;
-      case ps2::DefaultsAndDisable:
+      case DefaultsAndDisable:
         DPRINTF(PS2, "Disabling and resetting the keyboard.\n");
         enabled = false;
         sendAck();
         return true;
-      case ps2::Reset:
+      case Reset:
         DPRINTF(PS2, "Resetting keyboard.\n");
         enabled = true;
         sendAck();
-        send(ps2::SelfTestPass);
+        send(SelfTestPass);
         return true;
-      case ps2::Resend:
+      case Resend:
         panic("Keyboard resend unimplemented.\n");

       case LEDWrite:
@@ -161,7 +166,7 @@

     // convert the X11 keysym into ps2 codes and update the shift
     // state (shiftDown)
-    ps2::keySymToPs2(key, down, shiftDown, keys);
+    keySymToPs2(key, down, shiftDown, keys);

     // Drop key presses if the keyboard hasn't been enabled by the
     // host. We do that after translating the key code to ensure that
@@ -173,3 +178,5 @@
     for (uint8_t c : keys)
         send(c);
 }
+
+} // namespace ps2
diff --git a/src/dev/ps2/keyboard.hh b/src/dev/ps2/keyboard.hh
index b213333..28a98d4 100644
--- a/src/dev/ps2/keyboard.hh
+++ b/src/dev/ps2/keyboard.hh
@@ -49,7 +49,9 @@

 struct PS2KeyboardParams;

-class PS2Keyboard : public PS2Device, VncKeyboard
+namespace ps2 {
+
+class PS2Keyboard : public Device, VncKeyboard
 {
   protected:
     /** is the shift key currently down */
@@ -81,12 +83,13 @@
     void serialize(CheckpointOut &cp) const override;
     void unserialize(CheckpointIn &cp) override;

-  protected: // PS2Device
+  protected: // from Device
     bool recv(const std::vector<uint8_t> &data) override;

   public: // VncKeyboard
     void keyPress(uint32_t key, bool down) override;
 };

-#endif // __DEV_PS2_KEYBOARD_hH__
+} // namespace ps2

+#endif // __DEV_PS2_KEYBOARD_hH__
diff --git a/src/dev/ps2/mouse.cc b/src/dev/ps2/mouse.cc
index 5d71019..19d6fdd 100644
--- a/src/dev/ps2/mouse.cc
+++ b/src/dev/ps2/mouse.cc
@@ -47,10 +47,12 @@
 #include "params/PS2Mouse.hh"
 #include "sim/serialize.hh"

+namespace ps2 {
+
 const std::vector<uint8_t> PS2Mouse::ID{0x00};

 PS2Mouse::PS2Mouse(const PS2MouseParams &p)
-    : PS2Device(p),
+    : Device(p),
       status(0), resolution(4), sampleRate(100)
 {
 }
@@ -59,31 +61,31 @@
 PS2Mouse::recv(const std::vector<uint8_t> &data)
 {
     switch (data[0]) {
-      case ps2::ReadID:
+      case ReadID:
         DPRINTF(PS2, "Mouse ID requested.\n");
         sendAck();
         send(ID);
         return true;
-      case ps2::Disable:
+      case Disable:
         DPRINTF(PS2, "Disabling data reporting.\n");
         status.enabled = 0;
         sendAck();
         return true;
-      case ps2::Enable:
+      case Enable:
         DPRINTF(PS2, "Enabling data reporting.\n");
         status.enabled = 1;
         sendAck();
         return true;
-      case ps2::Resend:
+      case Resend:
         panic("Mouse resend unimplemented.\n");
-      case ps2::Reset:
+      case Reset:
         DPRINTF(PS2, "Resetting the mouse.\n");
         sampleRate = 100;
         resolution = 4;
         status.twoToOne = 0;
         status.enabled = 0;
         sendAck();
-        send(ps2::SelfTestPass);
+        send(SelfTestPass);
         send(ID);
         return true;

@@ -135,7 +137,7 @@
             sendAck();
             return true;
         }
-      case ps2::DefaultsAndDisable:
+      case DefaultsAndDisable:
         DPRINTF(PS2, "Disabling and resetting mouse.\n");
         sampleRate = 100;
         resolution = 4;
@@ -145,7 +147,7 @@
         return true;
       default:
         warn("Unknown mouse command %#02x.\n", data[0]);
-        send(ps2::Resend);
+        send(Resend);
         return true;
     }
 }
@@ -153,7 +155,7 @@
 void
 PS2Mouse::serialize(CheckpointOut &cp) const
 {
-    PS2Device::serialize(cp);
+    Device::serialize(cp);

     SERIALIZE_SCALAR(status);
     SERIALIZE_SCALAR(resolution);
@@ -163,9 +165,11 @@
 void
 PS2Mouse::unserialize(CheckpointIn &cp)
 {
-    PS2Device::unserialize(cp);
+    Device::unserialize(cp);

     UNSERIALIZE_SCALAR(status);
     UNSERIALIZE_SCALAR(resolution);
     UNSERIALIZE_SCALAR(sampleRate);
 }
+
+} // namespace ps2
diff --git a/src/dev/ps2/mouse.hh b/src/dev/ps2/mouse.hh
index 7536cd9..441762f 100644
--- a/src/dev/ps2/mouse.hh
+++ b/src/dev/ps2/mouse.hh
@@ -49,7 +49,9 @@

 struct PS2MouseParams;

-class PS2Mouse : public PS2Device
+namespace ps2 {
+
+class PS2Mouse : public Device
 {
   protected:
     BitUnion8(Status)
@@ -85,11 +87,11 @@
     void serialize(CheckpointOut &cp) const override;
     void unserialize(CheckpointIn &cp) override;

-  protected: // PS2Device
+  protected: // from Device
     bool recv(const std::vector<uint8_t> &data) override;
 };

-const std::vector<uint8_t> PS2Mouse::ID{0x00};
+} // namespace ps2

 #endif // __DEV_PS2_MOUSE_hH__

diff --git a/src/dev/ps2/touchkit.cc b/src/dev/ps2/touchkit.cc
index 8b564b1..db2f563 100644
--- a/src/dev/ps2/touchkit.cc
+++ b/src/dev/ps2/touchkit.cc
@@ -40,14 +40,19 @@

 #include "dev/ps2/touchkit.hh"

+#include <cstdint>
+
 #include "base/logging.hh"
 #include "base/trace.hh"
 #include "debug/PS2.hh"
+#include "dev/ps2/mouse.hh"
 #include "dev/ps2/types.hh"
 #include "params/PS2TouchKit.hh"

-PS2TouchKit::PS2TouchKit(const PS2TouchKitParams &p)
-    : PS2Device(p),
+namespace ps2 {
+
+TouchKit::TouchKit(const PS2TouchKitParams &p)
+    : Device(p),
       vnc(p.vnc),
       enabled(false), touchKitEnabled(false)
 {
@@ -56,53 +61,53 @@
 }

 void
-PS2TouchKit::serialize(CheckpointOut &cp) const
+TouchKit::serialize(CheckpointOut &cp) const
 {
-    PS2Device::serialize(cp);
+    Device::serialize(cp);

     SERIALIZE_SCALAR(enabled);
     SERIALIZE_SCALAR(touchKitEnabled);
 }

 void
-PS2TouchKit::unserialize(CheckpointIn &cp)
+TouchKit::unserialize(CheckpointIn &cp)
 {
-    PS2Device::unserialize(cp);
+    Device::unserialize(cp);

     UNSERIALIZE_SCALAR(enabled);
     UNSERIALIZE_SCALAR(touchKitEnabled);
 }

 bool
-PS2TouchKit::recv(const std::vector<uint8_t> &data)
+TouchKit::recv(const std::vector<uint8_t> &data)
 {
     switch (data[0]) {
-      case ps2::Reset:
+      case Reset:
         DPRINTF(PS2, "Resetting device.\n");
         enabled = false;
         touchKitEnabled = false;
         sendAck();
-        send(ps2::SelfTestPass);
+        send(SelfTestPass);
         return true;

-      case ps2::ReadID:
+      case ReadID:
         sendAck();
         send(PS2Mouse::ID);
         return true;

-      case ps2::Disable:
+      case Disable:
         DPRINTF(PS2, "Disabling device.\n");
         enabled = false;
         sendAck();
         return true;

-      case ps2::Enable:
+      case Enable:
         DPRINTF(PS2, "Enabling device.\n");
         enabled = true;
         sendAck();
         return true;

-      case ps2::DefaultsAndDisable:
+      case DefaultsAndDisable:
         DPRINTF(PS2, "Setting defaults and disabling device.\n");
         enabled = false;
         sendAck();
@@ -143,7 +148,7 @@
 }

 bool
-PS2TouchKit::recvTouchKit(const std::vector<uint8_t> &data)
+TouchKit::recvTouchKit(const std::vector<uint8_t> &data)
 {
     // Ack all incoming bytes
     sendAck();
@@ -173,7 +178,7 @@
 }

 void
-PS2TouchKit::sendTouchKit(const uint8_t *data, size_t size)
+TouchKit::sendTouchKit(const uint8_t *data, size_t size)
 {
     send(TouchKitDiag);
     send(size);
@@ -183,7 +188,7 @@


 void
-PS2TouchKit::mouseAt(uint16_t x, uint16_t y, uint8_t buttons)
+TouchKit::mouseAt(uint16_t x, uint16_t y, uint8_t buttons)
 {
// If the driver hasn't initialized the device yet, no need to try and send // it anything. Similarly we can get vnc mouse events orders of magnitude
@@ -204,3 +209,5 @@

     send(resp, sizeof(resp));
 }
+
+} // namespace ps2
diff --git a/src/dev/ps2/touchkit.hh b/src/dev/ps2/touchkit.hh
index 3b1a6ab..59407e0 100644
--- a/src/dev/ps2/touchkit.hh
+++ b/src/dev/ps2/touchkit.hh
@@ -38,12 +38,17 @@
 #ifndef __DEV_PS2_TOUCHKIT_HH__
 #define __DEV_PS2_TOUCHKIT_HH__

+#include "base/compiler.hh"
 #include "base/vnc/vncinput.hh"
 #include "dev/ps2/device.hh"

 struct PS2TouchKitParams;

-class PS2TouchKit : public PS2Device, public VncMouse
+namespace ps2 {
+
+GEM5_DEPRECATED_CLASS(PS2TouchKit, TouchKit);
+
+class TouchKit : public Device, public VncMouse
 {
   protected:
     enum PS2Commands
@@ -60,12 +65,12 @@
     };

   public:
-    PS2TouchKit(const PS2TouchKitParams &p);
+    TouchKit(const PS2TouchKitParams &p);

     void serialize(CheckpointOut &cp) const override;
     void unserialize(CheckpointIn &cp) override;

-  protected: // PS2Device
+  protected: // from Device
     bool recv(const std::vector<uint8_t> &data) override;

   public: // VncMouse
@@ -89,5 +94,6 @@
     bool touchKitEnabled;
 };

-#endif // __DEV_PS2_TOUCHKIT_HH__
+} // namespace ps2

+#endif // __DEV_PS2_TOUCHKIT_HH__
diff --git a/src/dev/x86/i8042.hh b/src/dev/x86/i8042.hh
index f05403a..ec65d61 100644
--- a/src/dev/x86/i8042.hh
+++ b/src/dev/x86/i8042.hh
@@ -110,8 +110,8 @@
     std::vector<IntSourcePin<I8042> *> mouseIntPin;
     std::vector<IntSourcePin<I8042> *> keyboardIntPin;

-    PS2Device *mouse;
-    PS2Device *keyboard;
+    ps2::Device *mouse;
+    ps2::Device *keyboard;

     void writeData(uint8_t newData, bool mouse_output_full = false);
     uint8_t readDataOut();

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/45395
To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings

Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: I9a57b87053a6a0acb380a919e09ab427fdb8eca4
Gerrit-Change-Number: 45395
Gerrit-PatchSet: 1
Gerrit-Owner: Daniel Carvalho <[email protected]>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

Reply via email to