changeset 7fcfb515d7bf in /z/repo/m5
details: http://repo.m5sim.org/m5?cmd=changeset;node=7fcfb515d7bf
description:
        x86: Add checkpointing capability to devices

        Add checkpointing capability to the Intel 8254 timer, CMOS, I8042,
        PS2 Keyboard and Mouse, I82094AA, I8237, I8254, I8259, and speaker
        devices

diffstat:

 src/dev/intel_8254_timer.cc |    4 +-
 src/dev/x86/cmos.cc         |   20 ++++++++
 src/dev/x86/cmos.hh         |    4 +
 src/dev/x86/i8042.cc        |  109 ++++++++++++++++++++++++++++++++++++++++++++
 src/dev/x86/i8042.hh        |   11 ++++
 src/dev/x86/i82094aa.cc     |   29 +++++++++++
 src/dev/x86/i82094aa.hh     |    3 +
 src/dev/x86/i8237.cc        |   14 +++++-
 src/dev/x86/i8237.hh        |    3 +
 src/dev/x86/i8254.cc        |   12 ++++
 src/dev/x86/i8254.hh        |    4 +
 src/dev/x86/i8259.cc        |   36 ++++++++++++++
 src/dev/x86/i8259.hh        |    3 +
 src/dev/x86/speaker.cc      |   15 ++++++
 src/dev/x86/speaker.hh      |    4 +
 15 files changed, 269 insertions(+), 2 deletions(-)

diffs (truncated from 440 to 300 lines):

diff -r aafb4a7384d4 -r 7fcfb515d7bf src/dev/intel_8254_timer.cc
--- a/src/dev/intel_8254_timer.cc       Sun Feb 06 22:14:17 2011 -0800
+++ b/src/dev/intel_8254_timer.cc       Sun Feb 06 22:14:18 2011 -0800
@@ -247,7 +247,9 @@
     paramIn(cp, section, base + ".read_byte", read_byte);
     paramIn(cp, section, base + ".write_byte", write_byte);
 
-    Tick event_tick;
+    Tick event_tick = 0;
+    if (event.scheduled())
+        parent->deschedule(event);
     paramIn(cp, section, base + ".event_tick", event_tick);
     if (event_tick)
         parent->schedule(event, event_tick);
diff -r aafb4a7384d4 -r 7fcfb515d7bf src/dev/x86/cmos.cc
--- a/src/dev/x86/cmos.cc       Sun Feb 06 22:14:17 2011 -0800
+++ b/src/dev/x86/cmos.cc       Sun Feb 06 22:14:18 2011 -0800
@@ -111,6 +111,26 @@
     }
 }
 
+void
+X86ISA::Cmos::serialize(std::ostream &os)
+{
+    SERIALIZE_SCALAR(address);
+    SERIALIZE_ARRAY(regs, numRegs);
+
+    // Serialize the timer
+    rtc.serialize("rtc", os);
+}
+
+void
+X86ISA::Cmos::unserialize(Checkpoint *cp, const std::string &section)
+{
+    UNSERIALIZE_SCALAR(address);
+    UNSERIALIZE_ARRAY(regs, numRegs);
+
+    // Serialize the timer
+    rtc.unserialize("rtc", cp, section);
+}
+
 X86ISA::Cmos *
 CmosParams::create()
 {
diff -r aafb4a7384d4 -r 7fcfb515d7bf src/dev/x86/cmos.hh
--- a/src/dev/x86/cmos.hh       Sun Feb 06 22:14:17 2011 -0800
+++ b/src/dev/x86/cmos.hh       Sun Feb 06 22:14:18 2011 -0800
@@ -82,6 +82,10 @@
     Tick read(PacketPtr pkt);
 
     Tick write(PacketPtr pkt);
+
+    virtual void serialize(std::ostream &os);
+    virtual void unserialize(Checkpoint *cp, const std::string &section);
+
 };
 
 } // namespace X86ISA
diff -r aafb4a7384d4 -r 7fcfb515d7bf src/dev/x86/i8042.cc
--- a/src/dev/x86/i8042.cc      Sun Feb 06 22:14:17 2011 -0800
+++ b/src/dev/x86/i8042.cc      Sun Feb 06 22:14:18 2011 -0800
@@ -439,6 +439,115 @@
     return latency;
 }
 
+void
+X86ISA::I8042::serialize(std::ostream &os)
+{
+    uint8_t statusRegData = statusReg.__data;
+    uint8_t commandByteData = commandByte.__data;
+    
+    SERIALIZE_SCALAR(dataPort);
+    SERIALIZE_SCALAR(commandPort);
+    SERIALIZE_SCALAR(statusRegData);
+    SERIALIZE_SCALAR(commandByteData);
+    SERIALIZE_SCALAR(dataReg);
+    SERIALIZE_SCALAR(lastCommand);
+    mouse.serialize("mouse", os);
+    keyboard.serialize("keyboard", os);
+}
+
+void
+X86ISA::I8042::unserialize(Checkpoint *cp, const std::string &section)
+{
+    uint8_t statusRegData;
+    uint8_t commandByteData;
+
+    UNSERIALIZE_SCALAR(dataPort);
+    UNSERIALIZE_SCALAR(commandPort);
+    UNSERIALIZE_SCALAR(statusRegData);
+    UNSERIALIZE_SCALAR(commandByteData);
+    UNSERIALIZE_SCALAR(dataReg);
+    UNSERIALIZE_SCALAR(lastCommand);
+    mouse.unserialize("mouse", cp, section);
+    keyboard.unserialize("keyboard", cp, section);
+
+    statusReg.__data = statusRegData;
+    commandByte.__data = commandByteData;
+}
+
+void
+X86ISA::PS2Keyboard::serialize(const std::string &base, std::ostream &os)
+{
+    paramOut(os, base + ".lastCommand", lastCommand);
+    int bufferSize = outBuffer.size();
+    paramOut(os, 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(os, base + ".outBuffer.elts", buffer,
+            bufferSize*sizeof(uint8_t));
+    delete buffer;
+}
+
+void
+X86ISA::PS2Keyboard::unserialize(const std::string &base, Checkpoint *cp,
+        const std::string &section)
+{
+    paramIn(cp, section, base + ".lastCommand", lastCommand);
+    int bufferSize;
+    paramIn(cp, section, base + ".outBuffer.size", bufferSize);
+    uint8_t *buffer = new uint8_t[bufferSize];
+    arrayParamIn(cp, section, base + ".outBuffer.elts", buffer,
+            bufferSize*sizeof(uint8_t));
+    for (int i = 0; i < bufferSize; ++i) {
+        outBuffer.push(buffer[i]);
+    }
+    delete buffer;
+}
+
+void
+X86ISA::PS2Mouse::serialize(const std::string &base, std::ostream &os)
+{
+    uint8_t statusData = status.__data;
+    paramOut(os, base + ".lastCommand", lastCommand);
+    int bufferSize = outBuffer.size();
+    paramOut(os, 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(os, base + ".outBuffer.elts", buffer,
+            bufferSize*sizeof(uint8_t));
+    delete buffer;
+    paramOut(os, base + ".status", statusData);
+    paramOut(os, base + ".resolution", resolution);
+    paramOut(os, base + ".sampleRate", sampleRate);
+}
+
+void
+X86ISA::PS2Mouse::unserialize(const std::string &base, Checkpoint *cp,
+        const std::string &section)
+{
+    uint8_t statusData;
+    paramIn(cp, section, base + ".lastCommand", lastCommand);
+    int bufferSize;
+    paramIn(cp, section, base + ".outBuffer.size", bufferSize);
+    uint8_t *buffer = new uint8_t[bufferSize];
+    arrayParamIn(cp, section, base + ".outBuffer.elts", buffer,
+            bufferSize*sizeof(uint8_t));
+    for (int i = 0; i < bufferSize; ++i) {
+        outBuffer.push(buffer[i]);
+    }
+    delete buffer;
+    paramIn(cp, section, base + ".status", statusData);
+    paramIn(cp, section, base + ".resolution", resolution);
+    paramIn(cp, section, base + ".sampleRate", sampleRate);
+
+    status.__data = statusData;
+}
+
 X86ISA::I8042 *
 I8042Params::create()
 {
diff -r aafb4a7384d4 -r 7fcfb515d7bf src/dev/x86/i8042.hh
--- a/src/dev/x86/i8042.hh      Sun Feb 06 22:14:17 2011 -0800
+++ b/src/dev/x86/i8042.hh      Sun Feb 06 22:14:18 2011 -0800
@@ -116,6 +116,10 @@
     {}
 
     bool processData(uint8_t data);
+
+    void serialize(const std::string &base, std::ostream &os);
+    void unserialize(const std::string &base, Checkpoint *cp,
+            const std::string &section);
 };
 
 class PS2Keyboard : public PS2Device
@@ -146,6 +150,10 @@
 
   public:
     bool processData(uint8_t data);
+
+    void serialize(const std::string &base, std::ostream &os);
+    void unserialize(const std::string &base, Checkpoint *cp,
+            const std::string &section);
 };
 
 class I8042 : public BasicPioDevice
@@ -252,6 +260,9 @@
     Tick read(PacketPtr pkt);
 
     Tick write(PacketPtr pkt);
+
+    virtual void serialize(std::ostream &os);
+    virtual void unserialize(Checkpoint *cp, const std::string &section);
 };
 
 } // namespace X86ISA
diff -r aafb4a7384d4 -r 7fcfb515d7bf src/dev/x86/i82094aa.cc
--- a/src/dev/x86/i82094aa.cc   Sun Feb 06 22:14:17 2011 -0800
+++ b/src/dev/x86/i82094aa.cc   Sun Feb 06 22:14:18 2011 -0800
@@ -236,6 +236,35 @@
     localApics[initialId] = localApic;
 }
 
+void
+X86ISA::I82094AA::serialize(std::ostream &os)
+{
+    uint64_t* redirTableArray = (uint64_t*)redirTable;
+    SERIALIZE_SCALAR(regSel);
+    SERIALIZE_SCALAR(initialApicId);
+    SERIALIZE_SCALAR(id);
+    SERIALIZE_SCALAR(arbId);
+    SERIALIZE_SCALAR(lowestPriorityOffset);
+    SERIALIZE_ARRAY(redirTableArray, TableSize);
+    SERIALIZE_ARRAY(pinStates, TableSize);
+}
+
+void
+X86ISA::I82094AA::unserialize(Checkpoint *cp, const std::string &section)
+{
+    uint64_t redirTableArray[TableSize];
+    UNSERIALIZE_SCALAR(regSel);
+    UNSERIALIZE_SCALAR(initialApicId);
+    UNSERIALIZE_SCALAR(id);
+    UNSERIALIZE_SCALAR(arbId);
+    UNSERIALIZE_SCALAR(lowestPriorityOffset);
+    UNSERIALIZE_ARRAY(redirTableArray, TableSize);
+    UNSERIALIZE_ARRAY(pinStates, TableSize);
+    for (int i = 0; i < TableSize; i++) {
+        redirTable[i] = (RedirTableEntry)redirTableArray[i];
+    }
+}
+
 X86ISA::I82094AA *
 I82094AAParams::create()
 {
diff -r aafb4a7384d4 -r 7fcfb515d7bf src/dev/x86/i82094aa.hh
--- a/src/dev/x86/i82094aa.hh   Sun Feb 06 22:14:17 2011 -0800
+++ b/src/dev/x86/i82094aa.hh   Sun Feb 06 22:14:18 2011 -0800
@@ -130,6 +130,9 @@
     void raiseInterruptPin(int number);
     void lowerInterruptPin(int number);
     void registerLocalApic(int id, Interrupts *localApic);
+
+    virtual void serialize(std::ostream &os);
+    virtual void unserialize(Checkpoint *cp, const std::string &section);
 };
 
 } // namespace X86ISA
diff -r aafb4a7384d4 -r 7fcfb515d7bf src/dev/x86/i8237.cc
--- a/src/dev/x86/i8237.cc      Sun Feb 06 22:14:17 2011 -0800
+++ b/src/dev/x86/i8237.cc      Sun Feb 06 22:14:18 2011 -0800
@@ -119,12 +119,24 @@
       case 0xf:
         panic("Write to i8237 write all mask register bits unimplemented.\n");
       default:
-        panic("Write to undefined i8254 register.\n");
+        panic("Write to undefined i8237 register.\n");
     }
     pkt->makeAtomicResponse();
     return latency;
 }
 
+void
+X86ISA::I8237::serialize(std::ostream &os)
+{
+    SERIALIZE_SCALAR(maskReg);
+}
+
+void
+X86ISA::I8237::unserialize(Checkpoint *cp, const std::string &section)
+{
+    UNSERIALIZE_SCALAR(maskReg);
+}
+
 X86ISA::I8237 *
 I8237Params::create()
 {
diff -r aafb4a7384d4 -r 7fcfb515d7bf src/dev/x86/i8237.hh
--- a/src/dev/x86/i8237.hh      Sun Feb 06 22:14:17 2011 -0800
+++ b/src/dev/x86/i8237.hh      Sun Feb 06 22:14:18 2011 -0800
@@ -59,6 +59,9 @@
     Tick read(PacketPtr pkt);
 
     Tick write(PacketPtr pkt);
_______________________________________________
m5-dev mailing list
m5-dev@m5sim.org
http://m5sim.org/mailman/listinfo/m5-dev

Reply via email to