From 39d8034475f09187bee91f90391db26bde287506 Mon Sep 17 00:00:00 2001 From: Andreas Sandberg Date: Fri, 7 Aug 2015 09:59:15 +0100 Subject: dev, x86: Fix serialization bug in the i8042 device The i8042 device drops the contents of a PS2 device's buffer when serializing, which results in corrupted PS2 state when continuing simulation after a checkpoint. This changeset fixes this bug and transitions the i8042 model to use the new serialization API that requires the serialize() method to be const. --- src/dev/x86/i8042.hh | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'src/dev/x86/i8042.hh') diff --git a/src/dev/x86/i8042.hh b/src/dev/x86/i8042.hh index 9d2548857..fd32b4c53 100644 --- a/src/dev/x86/i8042.hh +++ b/src/dev/x86/i8042.hh @@ -31,7 +31,7 @@ #ifndef __DEV_X86_I8042_HH__ #define __DEV_X86_I8042_HH__ -#include +#include #include "dev/x86/intdev.hh" #include "dev/io_device.hh" @@ -45,7 +45,7 @@ class IntPin; class PS2Device { protected: - std::queue outBuffer; + std::deque outBuffer; static const uint16_t NoCommand = (uint16_t)(-1); @@ -61,6 +61,9 @@ class 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(); @@ -69,7 +72,7 @@ class PS2Device uint8_t getData() { uint8_t data = outBuffer.front(); - outBuffer.pop(); + outBuffer.pop_front(); return data; } @@ -117,8 +120,10 @@ class PS2Mouse : public PS2Device bool processData(uint8_t data); - void serialize(const std::string &base, CheckpointOut &cp); - void unserialize(const std::string &base, CheckpointIn &cp); + void serialize(const std::string &base, + CheckpointOut &cp) const M5_ATTR_OVERRIDE; + void unserialize(const std::string &base, + CheckpointIn &cp) M5_ATTR_OVERRIDE; }; class PS2Keyboard : public PS2Device @@ -149,9 +154,6 @@ class PS2Keyboard : public PS2Device public: bool processData(uint8_t data); - - void serialize(const std::string &base, CheckpointOut &cp); - void unserialize(const std::string &base, CheckpointIn &cp); }; class I8042 : public BasicPioDevice @@ -247,7 +249,7 @@ class I8042 : public BasicPioDevice Tick write(PacketPtr pkt); - void serializeOld(CheckpointOut &cp) M5_ATTR_OVERRIDE; + void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE; void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE; }; -- cgit v1.2.3