// 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);
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;
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
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));
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;
}
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 §ion)
+TsunamiIO::RTC::unserialize(const string &base, Checkpoint *cp,
+ const string §ion)
{
- 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)
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 §ion)
+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
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 §ion)
+TsunamiIO::PITimer::unserialize(const string &base, Checkpoint *cp,
+ const string §ion)
{
// 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)
{
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;
}
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 §ion)
+TsunamiIO::PITimer::Counter::unserialize(const string &base, Checkpoint *cp,
+ const string §ion)
{
- 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)
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 §ion)
-{
- 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;
}
void
-TsunamiIO::serialize(std::ostream &os)
+TsunamiIO::serialize(ostream &os)
{
SERIALIZE_SCALAR(timerData);
SERIALIZE_SCALAR(mask1);
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 §ion)
+TsunamiIO::unserialize(Checkpoint *cp, const string §ion)
{
UNSERIALIZE_SCALAR(timerData);
UNSERIALIZE_SCALAR(mask1);
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)
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 §ion);
- };
+ 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;
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);
* 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 §ion);
+ void unserialize(const std::string &base, Checkpoint *cp,
+ const std::string §ion);
};
/** 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
/** 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 §ion);
-
friend class Counter;
};
private:
+ std::string _name;
+ const std::string &name() const { return _name; }
+
CounterEvent event;
/** Current count value */
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();
* 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 §ion);
+ void unserialize(const std::string &base, Checkpoint *cp,
+ const std::string §ion);
};
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);
* 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 §ion);
+ void unserialize(const std::string &base, Checkpoint *cp,
+ const std::string §ion);
};
/** Mask of the PIC1 */