Lots of fixes to serialization and naming of various device
authorNathan Binkert <binkertn@umich.edu>
Tue, 23 Aug 2005 15:45:52 +0000 (11:45 -0400)
committerNathan Binkert <binkertn@umich.edu>
Tue, 23 Aug 2005 15:45:52 +0000 (11:45 -0400)
objects.  The improper serialization of arrays was particularly
bad.

dev/alpha_console.cc:
dev/isa_fake.cc:
dev/ns_gige.cc:
dev/pciconfigall.cc:
dev/tsunami_cchip.cc:
dev/tsunami_io.cc:
dev/tsunami_pchip.cc:
    the pio interface is a different simobject and should have a
    different name.
dev/ethertap.cc:
    fix serialization.
dev/ide_ctrl.cc:
    - the pio interface is a different simobject and should have a
    different name.
    - properly initialize variables
    - When serializing an array, the size is the number of elements,
    not the number of bytes!
dev/pcidev.cc:
    When serializing an array, the size is the number of elements,
    not the number of bytes!
dev/tsunami_io.hh:
    Don't make objects SimObjects if they're not exposed to python.
    Don't add serialization functions to events, it's generally not
    what you want.
    allow the real time clock and interval timer to serialize themselves,
    must pass a base name since it is not a SimObject and the values will
    be going into the section of the parent.

--HG--
extra : convert_revision : 3fc5de9b858ed770c8f385cf38b53242cf859c33

dev/alpha_console.cc
dev/ethertap.cc
dev/ide_ctrl.cc
dev/isa_fake.cc
dev/ns_gige.cc
dev/pciconfigall.cc
dev/pcidev.cc
dev/tsunami_cchip.cc
dev/tsunami_io.cc
dev/tsunami_io.hh
dev/tsunami_pchip.cc

index c4799bf6b370a058c473b5ca805f3d33d25b3dc4..bbda449a4db591e1a354fd659d21278c933bedb7 100644 (file)
@@ -63,7 +63,7 @@ AlphaConsole::AlphaConsole(const string &name, SimConsole *cons, SimpleDisk *d,
     mmu->add_child(this, RangeSize(addr, size));
 
     if (bus) {
-        pioInterface = newPioInterface(name, hier, bus, this,
+        pioInterface = newPioInterface(name + ".pio", hier, bus, this,
                                        &AlphaConsole::cacheAccess);
         pioInterface->addAddrRange(RangeSize(addr, size));
     }
index fdd2425fcea057166a21d7321727925455f85e16..7589991ef7fd3ec1ec84bda413e7bf63ddcddc87 100644 (file)
@@ -270,7 +270,8 @@ EtherTap::serialize(ostream &os)
 {
     SERIALIZE_SCALAR(socket);
     SERIALIZE_SCALAR(buflen);
-    SERIALIZE_ARRAY((uint8_t *)buffer,buflen);
+    uint8_t *buffer = (uint8_t *)this->buffer;
+    SERIALIZE_ARRAY(buffer, buflen);
     SERIALIZE_SCALAR(buffer_offset);
     SERIALIZE_SCALAR(data_len);
 
@@ -290,7 +291,8 @@ EtherTap::unserialize(Checkpoint *cp, const std::string &section)
 {
     UNSERIALIZE_SCALAR(socket);
     UNSERIALIZE_SCALAR(buflen);
-    UNSERIALIZE_ARRAY((uint8_t *)buffer,buflen);
+    uint8_t *buffer = (uint8_t *)this->buffer;
+    UNSERIALIZE_ARRAY(buffer, buflen);
     UNSERIALIZE_SCALAR(buffer_offset);
     UNSERIALIZE_SCALAR(data_len);
 
index b9b9df6547149a25096c5d52a1cabc5b90b0eefc..6aac136a6b1af95abd5347b107a0dda0c7e7225f 100644 (file)
@@ -92,7 +92,7 @@ IdeController::IdeController(Params *p)
 
     // create the PIO and DMA interfaces
     if (params()->host_bus) {
-        pioInterface = newPioInterface(name(), params()->hier,
+        pioInterface = newPioInterface(name() + ".pio", params()->hier,
                                        params()->host_bus, this,
                                        &IdeController::cacheAccess);
 
@@ -101,10 +101,13 @@ IdeController::IdeController(Params *p)
                                              params()->host_bus, 1,
                                              true);
         pioLatency = params()->pio_latency * params()->host_bus->clockRate;
+    } else {
+        pioInterface = NULL;
+        dmaInterface = NULL;
     }
 
     // setup the disks attached to controller
-    memset(disks, 0, sizeof(IdeDisk *) * 4);
+    memset(disks, 0, sizeof(disks));
     dev[0] = 0;
     dev[1] = 0;
 
@@ -648,14 +651,17 @@ IdeController::serialize(std::ostream &os)
     SERIALIZE_SCALAR(bmi_size);
 
     // Serialize registers
-    SERIALIZE_ARRAY(bmi_regs.data, sizeof(bmi_regs));
-    SERIALIZE_ARRAY(dev, sizeof(dev));
-    SERIALIZE_ARRAY(config_regs.data, sizeof(config_regs));
+    SERIALIZE_ARRAY(bmi_regs.data,
+                    sizeof(bmi_regs.data) / sizeof(bmi_regs.data[0]));
+    SERIALIZE_ARRAY(dev, sizeof(dev) / sizeof(dev[0]));
+    SERIALIZE_ARRAY(config_regs.data,
+                    sizeof(config_regs.data) / sizeof(config_regs.data[0]));
 
     // Serialize internal state
     SERIALIZE_SCALAR(io_enabled);
     SERIALIZE_SCALAR(bm_enabled);
-    SERIALIZE_ARRAY(cmd_in_progress, sizeof(cmd_in_progress));
+    SERIALIZE_ARRAY(cmd_in_progress,
+                    sizeof(cmd_in_progress) / sizeof(cmd_in_progress[0]));
 }
 
 void
@@ -677,14 +683,17 @@ IdeController::unserialize(Checkpoint *cp, const std::string &section)
     UNSERIALIZE_SCALAR(bmi_size);
 
     // Unserialize registers
-    UNSERIALIZE_ARRAY(bmi_regs.data, sizeof(bmi_regs));
-    UNSERIALIZE_ARRAY(dev, sizeof(dev));
-    UNSERIALIZE_ARRAY(config_regs.data, sizeof(config_regs));
+    UNSERIALIZE_ARRAY(bmi_regs.data,
+                      sizeof(bmi_regs.data) / sizeof(bmi_regs.data[0]));
+    UNSERIALIZE_ARRAY(dev, sizeof(dev) / sizeof(dev[0]));
+    UNSERIALIZE_ARRAY(config_regs.data,
+                      sizeof(config_regs.data) / sizeof(config_regs.data[0]));
 
     // Unserialize internal state
     UNSERIALIZE_SCALAR(io_enabled);
     UNSERIALIZE_SCALAR(bm_enabled);
-    UNSERIALIZE_ARRAY(cmd_in_progress, sizeof(cmd_in_progress));
+    UNSERIALIZE_ARRAY(cmd_in_progress,
+                      sizeof(cmd_in_progress) / sizeof(cmd_in_progress[0]));
 
     if (pioInterface) {
         pioInterface->addAddrRange(RangeSize(pri_cmd_addr, pri_cmd_size));
index af8005f9cd3118845acf5f062b988d20e96ad749..fa93fe2d2ff704044925b94a61e2ee34fa55d18f 100644 (file)
@@ -53,7 +53,7 @@ IsaFake::IsaFake(const string &name, Addr a, MemoryController *mmu,
     mmu->add_child(this, RangeSize(addr, size));
 
     if (bus) {
-        pioInterface = newPioInterface(name, hier, bus, this,
+        pioInterface = newPioInterface(name + ".pio", hier, bus, this,
                                       &IsaFake::cacheAccess);
         pioInterface->addAddrRange(RangeSize(addr, size));
     }
index f2fd610f92cf8397369928cb29dc6aa602467b52..d93e155bf4f8413d5d1eb9f540bc574edc8e0d2d 100644 (file)
@@ -110,7 +110,7 @@ NSGigE::NSGigE(Params *p)
       intrEvent(0), interface(0)
 {
     if (p->header_bus) {
-        pioInterface = newPioInterface(name(), p->hier,
+        pioInterface = newPioInterface(name() + ".pio", p->hier,
                                        p->header_bus, this,
                                        &NSGigE::cacheAccess);
 
@@ -127,7 +127,7 @@ NSGigE::NSGigE(Params *p)
                                                  p->header_bus, 1,
                                                  p->dma_no_allocate);
     } else if (p->payload_bus) {
-        pioInterface = newPioInterface(name(), p->hier,
+        pioInterface = newPioInterface(name() + ".pio2", p->hier,
                                        p->payload_bus, this,
                                        &NSGigE::cacheAccess);
 
index 6a5b2e56f7d600544626e332357f5265a7326774..b2bff6cb644e5b8fcda16650125f36223f6e4ef4 100644 (file)
@@ -56,7 +56,7 @@ PciConfigAll::PciConfigAll(const string &name,
     mmu->add_child(this, RangeSize(addr, size));
 
     if (bus) {
-        pioInterface = newPioInterface(name, hier, bus, this,
+        pioInterface = newPioInterface(name + ".pio", hier, bus, this,
                                       &PciConfigAll::cacheAccess);
         pioInterface->addAddrRange(RangeSize(addr, size));
         pioLatency = pio_latency * bus->clockRate;
index 2bfd8a1c716950c5f65cec5dd8120b27df9fbe49..dd83b2e21920d63609b2c95a0c1fc3e98210ebaf 100644 (file)
@@ -228,17 +228,18 @@ PciDev::writeConfig(int offset, int size, const uint8_t *data)
 void
 PciDev::serialize(ostream &os)
 {
-    SERIALIZE_ARRAY(BARSize, sizeof(BARSize));
-    SERIALIZE_ARRAY(BARAddrs, sizeof(BARAddrs));
-    SERIALIZE_ARRAY(config.data, sizeof(config.data));
+    SERIALIZE_ARRAY(BARSize, sizeof(BARSize) / sizeof(BARSize[0]));
+    SERIALIZE_ARRAY(BARAddrs, sizeof(BARAddrs) / sizeof(BARAddrs[0]));
+    SERIALIZE_ARRAY(config.data, sizeof(config.data) / sizeof(config.data[0]));
 }
 
 void
 PciDev::unserialize(Checkpoint *cp, const std::string &section)
 {
-    UNSERIALIZE_ARRAY(BARSize, sizeof(BARSize));
-    UNSERIALIZE_ARRAY(BARAddrs, sizeof(BARAddrs));
-    UNSERIALIZE_ARRAY(config.data, sizeof(config.data));
+    UNSERIALIZE_ARRAY(BARSize, sizeof(BARSize) / sizeof(BARSize[0]));
+    UNSERIALIZE_ARRAY(BARAddrs, sizeof(BARAddrs) / sizeof(BARAddrs[0]));
+    UNSERIALIZE_ARRAY(config.data,
+                      sizeof(config.data) / sizeof(config.data[0]));
 
     // Add the MMU mappings for the BARs
     for (int i=0; i < 6; i++) {
index a801c1284db2fc80d18a63004014bb3cc64f3b5c..3e2a712a9e6f5d015f11e39fc489b2400acbf068 100644 (file)
@@ -56,7 +56,7 @@ TsunamiCChip::TsunamiCChip(const string &name, Tsunami *t, Addr a,
     mmu->add_child(this, RangeSize(addr, size));
 
     if (bus) {
-        pioInterface = newPioInterface(name, hier, bus, this,
+        pioInterface = newPioInterface(name + ".pio", hier, bus, this,
                                       &TsunamiCChip::cacheAccess);
         pioInterface->addAddrRange(RangeSize(addr, size));
         pioLatency = pio_latency * bus->clockRate;
index 569bb46cbf6b4d61d4cf94a428b72dd8f3351d42..fd30d4fc179949172a4939c3d119b33bdfbbe3a9 100644 (file)
@@ -51,8 +51,8 @@
 
 using namespace std;
 
-TsunamiIO::RTC::RTC(Tsunami* t, Tick i)
-    : SimObject("RTC"), event(t, i), addr(0)
+TsunamiIO::RTC::RTC(const string &name, Tsunami* t, Tick i)
+    : _name(name), event(t, i), addr(0)
 {
     memset(clock_data, 0, sizeof(clock_data));
     stat_regA = RTCA_32768HZ | RTCA_1024HZ;
@@ -142,28 +142,28 @@ TsunamiIO::RTC::readData(uint8_t *data)
 }
 
 void
-TsunamiIO::RTC::serialize(std::ostream &os)
+TsunamiIO::RTC::serialize(const string &base, ostream &os)
 {
-    SERIALIZE_SCALAR(addr);
-    SERIALIZE_ARRAY(clock_data, sizeof(clock_data));
-    SERIALIZE_SCALAR(stat_regA);
-    SERIALIZE_SCALAR(stat_regB);
-
-    // serialize the RTC event
-    nameOut(os, csprintf("%s.event", name()));
-    event.serialize(os);
+    paramOut(os, base + ".addr", addr);
+    arrayParamOut(os, base + ".clock_data", clock_data, sizeof(clock_data));
+    paramOut(os, base + ".stat_regA", stat_regA);
+    paramOut(os, base + ".stat_regB", stat_regB);
 }
 
 void
-TsunamiIO::RTC::unserialize(Checkpoint *cp, const std::string &section)
+TsunamiIO::RTC::unserialize(const string &base, Checkpoint *cp,
+                            const string &section)
 {
-    UNSERIALIZE_SCALAR(addr);
-    UNSERIALIZE_ARRAY(clock_data, sizeof(clock_data));
-    UNSERIALIZE_SCALAR(stat_regA);
-    UNSERIALIZE_SCALAR(stat_regB);
+    paramIn(cp, section, base + ".addr", addr);
+    arrayParamIn(cp, section, base + ".clock_data", clock_data,
+                 sizeof(clock_data));
+    paramIn(cp, section, base + ".stat_regA", stat_regA);
+    paramIn(cp, section, base + ".stat_regB", stat_regB);
 
-    // unserialze the event
-    event.unserialize(cp, csprintf("%s.event", section));
+    // We're not unserializing the event here, but we need to
+    // rescehedule the event since curTick was moved forward by the
+    // checkpoint
+    event.reschedule(curTick + event.interval);
 }
 
 TsunamiIO::RTC::RTCEvent::RTCEvent(Tsunami*t, Tick i)
@@ -194,26 +194,13 @@ TsunamiIO::RTC::RTCEvent::description()
     return "tsunami RTC interrupt";
 }
 
-void
-TsunamiIO::RTC::RTCEvent::serialize(std::ostream &os)
-{
-    Tick time = when();
-    SERIALIZE_SCALAR(time);
-}
-
-void
-TsunamiIO::RTC::RTCEvent::unserialize(Checkpoint *cp, const std::string &section)
+TsunamiIO::PITimer::PITimer(const string &name)
+    : _name(name), counter0(name + ".counter0"), counter1(name + ".counter1"),
+      counter2(name + ".counter2")
 {
-    Tick time;
-    UNSERIALIZE_SCALAR(time);
-    reschedule(time);
-}
-
-TsunamiIO::PITimer::PITimer()
-    : SimObject("PITimer"), counter0(counter[0]), counter1(counter[1]),
-      counter2(counter[2])
-{
-
+    counter[0] = &counter0;
+    counter[1] = &counter0;
+    counter[2] = &counter0;
 }
 
 void
@@ -230,39 +217,35 @@ TsunamiIO::PITimer::writeControl(const uint8_t *data)
     rw = GET_CTRL_RW(*data);
 
     if (rw == PIT_RW_LATCH_COMMAND)
-        counter[sel].latchCount();
+        counter[sel]->latchCount();
     else {
-        counter[sel].setRW(rw);
-        counter[sel].setMode(GET_CTRL_MODE(*data));
-        counter[sel].setBCD(GET_CTRL_BCD(*data));
+        counter[sel]->setRW(rw);
+        counter[sel]->setMode(GET_CTRL_MODE(*data));
+        counter[sel]->setBCD(GET_CTRL_BCD(*data));
     }
 }
 
 void
-TsunamiIO::PITimer::serialize(std::ostream &os)
+TsunamiIO::PITimer::serialize(const string &base, ostream &os)
 {
     // serialize the counters
-    nameOut(os, csprintf("%s.counter0", name()));
-    counter0.serialize(os);
-
-    nameOut(os, csprintf("%s.counter1", name()));
-    counter1.serialize(os);
-
-    nameOut(os, csprintf("%s.counter2", name()));
-    counter2.serialize(os);
+    counter0.serialize(base + ".counter0", os);
+    counter1.serialize(base + ".counter1", os);
+    counter2.serialize(base + ".counter2", os);
 }
 
 void
-TsunamiIO::PITimer::unserialize(Checkpoint *cp, const std::string &section)
+TsunamiIO::PITimer::unserialize(const string &base, Checkpoint *cp,
+                                const string &section)
 {
     // unserialze the counters
-    counter0.unserialize(cp, csprintf("%s.counter0", section));
-    counter1.unserialize(cp, csprintf("%s.counter1", section));
-    counter2.unserialize(cp, csprintf("%s.counter2", section));
+    counter0.unserialize(base + ".counter0", cp, section);
+    counter1.unserialize(base + ".counter1", cp, section);
+    counter2.unserialize(base + ".counter2", cp, section);
 }
 
-TsunamiIO::PITimer::Counter::Counter()
-    : SimObject("Counter"), event(this), count(0), latched_count(0), period(0),
+TsunamiIO::PITimer::Counter::Counter(const string &name)
+    : _name(name), event(this), count(0), latched_count(0), period(0),
       mode(0), output_high(false), latch_on(false), read_byte(LSB),
       write_byte(LSB)
 {
@@ -327,7 +310,8 @@ TsunamiIO::PITimer::Counter::write(const uint8_t *data)
         period = count;
 
         if (period > 0) {
-            DPRINTF(Tsunami, "Timer set to curTick + %d\n", count * event.interval);
+            DPRINTF(Tsunami, "Timer set to curTick + %d\n",
+                    count * event.interval);
             event.schedule(curTick + count * event.interval);
         }
         write_byte = LSB;
@@ -366,36 +350,40 @@ TsunamiIO::PITimer::Counter::outputHigh()
 }
 
 void
-TsunamiIO::PITimer::Counter::serialize(std::ostream &os)
+TsunamiIO::PITimer::Counter::serialize(const string &base, ostream &os)
 {
-    SERIALIZE_SCALAR(count);
-    SERIALIZE_SCALAR(latched_count);
-    SERIALIZE_SCALAR(period);
-    SERIALIZE_SCALAR(mode);
-    SERIALIZE_SCALAR(output_high);
-    SERIALIZE_SCALAR(latch_on);
-    SERIALIZE_SCALAR(read_byte);
-    SERIALIZE_SCALAR(write_byte);
+    paramOut(os, base + ".count", count);
+    paramOut(os, base + ".latched_count", latched_count);
+    paramOut(os, base + ".period", period);
+    paramOut(os, base + ".mode", mode);
+    paramOut(os, base + ".output_high", output_high);
+    paramOut(os, base + ".latch_on", latch_on);
+    paramOut(os, base + ".read_byte", read_byte);
+    paramOut(os, base + ".write_byte", write_byte);
 
-    // serialize the counter event
-    nameOut(os, csprintf("%s.event", name()));
-    event.serialize(os);
+    Tick event_tick = 0;
+    if (event.scheduled())
+        event_tick = event.when();
+    paramOut(os, base + ".event_tick", event_tick);
 }
 
 void
-TsunamiIO::PITimer::Counter::unserialize(Checkpoint *cp, const std::string &section)
+TsunamiIO::PITimer::Counter::unserialize(const string &base, Checkpoint *cp,
+                                         const string &section)
 {
-    UNSERIALIZE_SCALAR(count);
-    UNSERIALIZE_SCALAR(latched_count);
-    UNSERIALIZE_SCALAR(period);
-    UNSERIALIZE_SCALAR(mode);
-    UNSERIALIZE_SCALAR(output_high);
-    UNSERIALIZE_SCALAR(latch_on);
-    UNSERIALIZE_SCALAR(read_byte);
-    UNSERIALIZE_SCALAR(write_byte);
+    paramIn(cp, section, base + ".count", count);
+    paramIn(cp, section, base + ".latched_count", latched_count);
+    paramIn(cp, section, base + ".period", period);
+    paramIn(cp, section, base + ".mode", mode);
+    paramIn(cp, section, base + ".output_high", output_high);
+    paramIn(cp, section, base + ".latch_on", latch_on);
+    paramIn(cp, section, base + ".read_byte", read_byte);
+    paramIn(cp, section, base + ".write_byte", write_byte);
 
-    // unserialze the counter event
-    event.unserialize(cp, csprintf("%s.event", section));
+    Tick event_tick;
+    paramIn(cp, section, base + ".event_tick", event_tick);
+    if (event_tick)
+        event.schedule(event_tick);
 }
 
 TsunamiIO::PITimer::Counter::CounterEvent::CounterEvent(Counter* c_ptr)
@@ -426,33 +414,16 @@ TsunamiIO::PITimer::Counter::CounterEvent::description()
     return "tsunami 8254 Interval timer";
 }
 
-void
-TsunamiIO::PITimer::Counter::CounterEvent::serialize(std::ostream &os)
-{
-    Tick time = scheduled() ? when() : 0;
-    SERIALIZE_SCALAR(time);
-    SERIALIZE_SCALAR(interval);
-}
-
-void
-TsunamiIO::PITimer::Counter::CounterEvent::unserialize(Checkpoint *cp, const std::string &section)
-{
-    Tick time;
-    UNSERIALIZE_SCALAR(time);
-    UNSERIALIZE_SCALAR(interval);
-    if (time)
-        schedule(time);
-}
-
 TsunamiIO::TsunamiIO(const string &name, Tsunami *t, time_t init_time,
                      Addr a, MemoryController *mmu, HierParams *hier, Bus *bus,
                      Tick pio_latency, Tick ci)
-    : PioDevice(name, t), addr(a), clockInterval(ci), tsunami(t), rtc(t, ci)
+    : PioDevice(name, t), addr(a), clockInterval(ci), tsunami(t),
+      pitimer(name + "pitimer"), rtc(name + ".rtc", t, ci)
 {
     mmu->add_child(this, RangeSize(addr, size));
 
     if (bus) {
-        pioInterface = newPioInterface(name, hier, bus, this,
+        pioInterface = newPioInterface(name + ".pio", hier, bus, this,
                                        &TsunamiIO::cacheAccess);
         pioInterface->addAddrRange(RangeSize(addr, size));
         pioLatency = pio_latency * bus->clockRate;
@@ -680,7 +651,7 @@ TsunamiIO::cacheAccess(MemReqPtr &req)
 }
 
 void
-TsunamiIO::serialize(std::ostream &os)
+TsunamiIO::serialize(ostream &os)
 {
     SERIALIZE_SCALAR(timerData);
     SERIALIZE_SCALAR(mask1);
@@ -691,14 +662,12 @@ TsunamiIO::serialize(std::ostream &os)
     SERIALIZE_SCALAR(picInterrupting);
 
     // Serialize the timers
-    nameOut(os, csprintf("%s.pitimer", name()));
-    pitimer.serialize(os);
-    nameOut(os, csprintf("%s.rtc", name()));
-    rtc.serialize(os);
+    pitimer.serialize("pitimer", os);
+    rtc.serialize("rtc", os);
 }
 
 void
-TsunamiIO::unserialize(Checkpoint *cp, const std::string &section)
+TsunamiIO::unserialize(Checkpoint *cp, const string &section)
 {
     UNSERIALIZE_SCALAR(timerData);
     UNSERIALIZE_SCALAR(mask1);
@@ -709,8 +678,8 @@ TsunamiIO::unserialize(Checkpoint *cp, const std::string &section)
     UNSERIALIZE_SCALAR(picInterrupting);
 
     // Unserialize the timers
-    pitimer.unserialize(cp, csprintf("%s.pitimer", section));
-    rtc.unserialize(cp, csprintf("%s.rtc", section));
+    pitimer.unserialize("pitimer", cp, section);
+    rtc.unserialize("rtc", cp, section);
 }
 
 BEGIN_DECLARE_SIM_OBJECT_PARAMS(TsunamiIO)
index 5f20cbf4ad5533889a03ec78011d2ccaf64c7125..35a417e6eadda964318f159bc993a707cc63818c 100644 (file)
@@ -54,45 +54,33 @@ class TsunamiIO : public PioDevice
     struct tm tm;
 
   protected:
-
     /** Real-Time Clock (MC146818) */
-    class RTC : public SimObject
+    class RTC
     {
-      /** Event for RTC periodic interrupt */
-      class RTCEvent : public Event
-      {
-        private:
-          /** A pointer back to tsunami to create interrupt the processor. */
-          Tsunami* tsunami;
-          Tick interval;
-
-        public:
-          RTCEvent(Tsunami* t, Tick i);
-
-          /** Schedule the RTC periodic interrupt */
-          void scheduleIntr();
-
-          /** Event process to occur at interrupt*/
-          virtual void process();
-
-          /** Event description */
-          virtual const char *description();
-
-          /**
-           * Serialize this object to the given output stream.
-           * @param os The stream to serialize to.
-           */
-          virtual void serialize(std::ostream &os);
-
-          /**
-           * Reconstruct the state of this object from a checkpoint.
-           * @param cp The checkpoint use.
-           * @param section The section name of this object
-           */
-          virtual void unserialize(Checkpoint *cp, const std::string &section);
-      };
+      private:
+        /** Event for RTC periodic interrupt */
+        struct RTCEvent : public Event
+        {
+            /** A pointer back to tsunami to create interrupt the processor. */
+            Tsunami* tsunami;
+            Tick interval;
+
+            RTCEvent(Tsunami* t, Tick i);
+
+            /** Schedule the RTC periodic interrupt */
+            void scheduleIntr();
+
+            /** Event process to occur at interrupt*/
+            virtual void process();
+
+            /** Event description */
+            virtual const char *description();
+        };
 
       private:
+        std::string _name;
+        const std::string &name() const { return _name; }
+
         /** RTC periodic interrupt event */
         RTCEvent event;
 
@@ -124,7 +112,7 @@ class TsunamiIO : public PioDevice
         uint8_t stat_regB;
 
       public:
-        RTC(Tsunami* t, Tick i);
+        RTC(const std::string &name, Tsunami* t, Tick i);
 
         /** Set the initial RTC time/date */
         void set_time(time_t t);
@@ -142,21 +130,22 @@ class TsunamiIO : public PioDevice
           * Serialize this object to the given output stream.
           * @param os The stream to serialize to.
           */
-        virtual void serialize(std::ostream &os);
+        void serialize(const std::string &base, std::ostream &os);
 
         /**
          * Reconstruct the state of this object from a checkpoint.
          * @param cp The checkpoint use.
          * @param section The section name of this object
          */
-        virtual void unserialize(Checkpoint *cp, const std::string &section);
+        void unserialize(const std::string &base, Checkpoint *cp,
+                         const std::string &section);
     };
 
     /** Programmable Interval Timer (Intel 8254) */
-    class PITimer : public SimObject
+    class PITimer
     {
         /** Counter element for PIT */
-        class Counter : public SimObject
+        class Counter
         {
             /** Event for counter interrupt */
             class CounterEvent : public Event
@@ -175,23 +164,13 @@ class TsunamiIO : public PioDevice
                 /** Event description */
                 virtual const char *description();
 
-                /**
-                 * Serialize this object to the given output stream.
-                 * @param os The stream to serialize to.
-                 */
-                virtual void serialize(std::ostream &os);
-
-                /**
-                 * Reconstruct the state of this object from a checkpoint.
-                 * @param cp The checkpoint use.
-                 * @param section The section name of this object
-                 */
-                virtual void unserialize(Checkpoint *cp, const std::string &section);
-
                 friend class Counter;
             };
 
           private:
+            std::string _name;
+            const std::string &name() const { return _name; }
+
             CounterEvent event;
 
             /** Current count value */
@@ -219,7 +198,7 @@ class TsunamiIO : public PioDevice
             uint8_t read_byte, write_byte;
 
           public:
-            Counter();
+            Counter(const std::string &name);
 
             /** Latch the current count (if one is not already latched) */
             void latchCount();
@@ -246,27 +225,31 @@ class TsunamiIO : public PioDevice
              * Serialize this object to the given output stream.
              * @param os The stream to serialize to.
              */
-            virtual void serialize(std::ostream &os);
+            void serialize(const std::string &base, std::ostream &os);
 
             /**
              * Reconstruct the state of this object from a checkpoint.
              * @param cp The checkpoint use.
              * @param section The section name of this object
              */
-            virtual void unserialize(Checkpoint *cp, const std::string &section);
+            void unserialize(const std::string &base, Checkpoint *cp,
+                             const std::string &section);
         };
 
       private:
+        std::string _name;
+        const std::string &name() const { return _name; }
+
         /** PIT has three seperate counters */
-        Counter counter[3];
+        Counter *counter[3];
 
       public:
         /** Public way to access individual counters (avoid array accesses) */
-        Counter &counter0;
-        Counter &counter1;
-        Counter &counter2;
+        Counter counter0;
+        Counter counter1;
+        Counter counter2;
 
-        PITimer();
+        PITimer(const std::string &name);
 
         /** Write control word */
         void writeControl(const uint8_t* data);
@@ -275,14 +258,15 @@ class TsunamiIO : public PioDevice
          * Serialize this object to the given output stream.
          * @param os The stream to serialize to.
          */
-        virtual void serialize(std::ostream &os);
+        void serialize(const std::string &base, std::ostream &os);
 
         /**
          * Reconstruct the state of this object from a checkpoint.
          * @param cp The checkpoint use.
          * @param section The section name of this object
          */
-        virtual void unserialize(Checkpoint *cp, const std::string &section);
+        void unserialize(const std::string &base, Checkpoint *cp,
+                         const std::string &section);
     };
 
     /** Mask of the PIC1 */
index e9db3b52916b1d13889098679c00c90c5d97f286..0bad8b0e759d60a8dcef0ba4b52d560428addd84 100644 (file)
@@ -62,7 +62,7 @@ TsunamiPChip::TsunamiPChip(const string &name, Tsunami *t, Addr a,
     }
 
     if (bus) {
-        pioInterface = newPioInterface(name, hier, bus, this,
+        pioInterface = newPioInterface(name + ".pio", hier, bus, this,
                                       &TsunamiPChip::cacheAccess);
         pioInterface->addAddrRange(RangeSize(addr, size));
         pioLatency = pio_latency * bus->clockRate;