}
}
+void
+X86ISA::PS2Device::serialize(const std::string &base, CheckpointOut &cp) const
+{
+ paramOut(cp, base + ".lastCommand", lastCommand);
+
+ std::vector<uint8_t> buffer(outBuffer.size());
+ std::copy(outBuffer.begin(), outBuffer.end(), buffer.begin());
+ arrayParamOut(cp, base + ".outBuffer.elts", buffer);
+}
+
+void
+X86ISA::PS2Device::unserialize(const std::string &base, CheckpointIn &cp)
+{
+ paramIn(cp, base + ".lastCommand", lastCommand);
+
+ std::vector<uint8_t> buffer;
+ arrayParamIn(cp, base + ".outBuffer.elts", buffer);
+ assert(outBuffer.empty());
+ for (auto c : buffer)
+ outBuffer.push_back(c);
+}
+
+
void
X86ISA::PS2Device::ack()
{
{
assert(data || size == 0);
while (size) {
- outBuffer.push(*(data++));
+ outBuffer.push_back(*(data++));
size--;
}
}
}
void
-X86ISA::I8042::serializeOld(CheckpointOut &cp)
+X86ISA::I8042::serialize(CheckpointOut &cp) const
{
uint8_t statusRegData = statusReg.__data;
uint8_t commandByteData = commandByte.__data;
}
void
-X86ISA::PS2Keyboard::serialize(const std::string &base, CheckpointOut &cp)
-{
- paramOut(cp, base + ".lastCommand", lastCommand);
- int bufferSize = outBuffer.size();
- paramOut(cp, base + ".outBuffer.size", bufferSize);
- uint8_t *buffer = new uint8_t[bufferSize];
- for (int i = 0; i < bufferSize; ++i) {
- buffer[i] = outBuffer.front();
- outBuffer.pop();
- }
- arrayParamOut(cp, base + ".outBuffer.elts", buffer,
- bufferSize*sizeof(uint8_t));
- delete[] buffer;
-}
-
-void
-X86ISA::PS2Keyboard::unserialize(const std::string &base, CheckpointIn &cp)
+X86ISA::PS2Mouse::serialize(const std::string &base, CheckpointOut &cp) const
{
- paramIn(cp, base + ".lastCommand", lastCommand);
- int bufferSize;
- paramIn(cp, base + ".outBuffer.size", bufferSize);
- uint8_t *buffer = new uint8_t[bufferSize];
- arrayParamIn(cp, base + ".outBuffer.elts", buffer,
- bufferSize*sizeof(uint8_t));
- for (int i = 0; i < bufferSize; ++i) {
- outBuffer.push(buffer[i]);
- }
- delete[] buffer;
-}
+ PS2Device::serialize(base, cp);
-void
-X86ISA::PS2Mouse::serialize(const std::string &base, CheckpointOut &cp)
-{
- uint8_t statusData = status.__data;
- paramOut(cp, base + ".lastCommand", lastCommand);
- int bufferSize = outBuffer.size();
- paramOut(cp, base + ".outBuffer.size", bufferSize);
- uint8_t *buffer = new uint8_t[bufferSize];
- for (int i = 0; i < bufferSize; ++i) {
- buffer[i] = outBuffer.front();
- outBuffer.pop();
- }
- arrayParamOut(cp, base + ".outBuffer.elts", buffer,
- bufferSize*sizeof(uint8_t));
- delete[] buffer;
- paramOut(cp, base + ".status", statusData);
+ paramOut(cp, base + ".status", status);
paramOut(cp, base + ".resolution", resolution);
paramOut(cp, base + ".sampleRate", sampleRate);
}
void
X86ISA::PS2Mouse::unserialize(const std::string &base, CheckpointIn &cp)
{
- uint8_t statusData;
- paramIn(cp, base + ".lastCommand", lastCommand);
- int bufferSize;
- paramIn(cp, base + ".outBuffer.size", bufferSize);
- uint8_t *buffer = new uint8_t[bufferSize];
- arrayParamIn(cp, base + ".outBuffer.elts", buffer,
- bufferSize*sizeof(uint8_t));
- for (int i = 0; i < bufferSize; ++i) {
- outBuffer.push(buffer[i]);
- }
- delete[] buffer;
- paramIn(cp, base + ".status", statusData);
+ PS2Device::unserialize(base, cp);
+
+ paramIn(cp, base + ".status", status);
paramIn(cp, base + ".resolution", resolution);
paramIn(cp, base + ".sampleRate", sampleRate);
-
- status.__data = statusData;
}
X86ISA::I8042 *
#ifndef __DEV_X86_I8042_HH__
#define __DEV_X86_I8042_HH__
-#include <queue>
+#include <deque>
#include "dev/x86/intdev.hh"
#include "dev/io_device.hh"
class PS2Device
{
protected:
- std::queue<uint8_t> outBuffer;
+ std::deque<uint8_t> outBuffer;
static const uint16_t NoCommand = (uint16_t)(-1);
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();
+ outBuffer.pop_front();
return data;
}
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
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
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;
};