43 #include "debug/MC146818.hh"
53 result += (val / 10) << 4;
62 result += (val >> 4) * 10;
72 mon = time.tm_mon + 1;
79 wday = time.tm_wday + 1;
95 bool bcd,
Tick frequency)
110 DPRINTFN(
"Real-time clock set to %s", asctime(&time));
120 MC146818::rega_dv_disabled(
const RtcRegA &
reg)
134 if (!rega_dv_disabled(stat_regA))
141 bool panic_unsupported(
false);
155 RtcRegA old_rega(stat_regA);
158 stat_regA.uip = old_rega;
160 if (!rega_dv_disabled(stat_regA) &&
162 inform(
"RTC: Unimplemented divider configuration: %i\n",
164 panic_unsupported =
true;
168 inform(
"RTC: Unimplemented interrupt rate: %i\n",
170 panic_unsupported =
true;
173 if (rega_dv_disabled(stat_regA)) {
178 }
else if (rega_dv_disabled(old_rega)) {
190 inform(
"RTC: Unimplemented interrupt configuration: %s %s\n",
193 panic_unsupported =
true;
197 inform(
"RTC: The binary interface is not fully implemented.\n");
198 panic_unsupported =
true;
202 inform(
"RTC: The 12h time format not supported.\n");
203 panic_unsupported =
true;
207 inform(
"RTC: Automatic daylight saving time not supported.\n");
208 panic_unsupported =
true;
221 panic(
"RTC status registers C and D are not implemented.\n");
226 if (panic_unsupported)
227 panic(
"Unimplemented RTC configuration!\n");
240 stat_regA.uip = !stat_regA.uip;
251 panic(
"Shouldn't be here");
259 assert(!rega_dv_disabled(stat_regA));
271 uint8_t regA_serial(stat_regA);
275 paramOut(cp, base +
".stat_regA", (uint8_t)regA_serial);
276 paramOut(cp, base +
".stat_regB", (uint8_t)regB_serial);
282 Tick rtcTimerInterruptTickOffset =
event.when() -
curTick();
296 paramIn(cp, base +
".stat_regA", tmp8);
298 paramIn(cp, base +
".stat_regB", tmp8);
304 Tick rtcTimerInterruptTickOffset;
306 event.offset = rtcTimerInterruptTickOffset;
307 Tick rtcClockTickOffset;
313 : parent(_parent), interval(i),
offset(i)
321 parent->schedule(
this,
curTick() + interval);
328 parent->schedule(
this,
curTick() + interval);
329 parent->handleEvent();
335 return "RTC interrupt";
349 return "RTC clock tick";
static uint8_t bcdize(uint8_t val)
uint8_t readData(const uint8_t addr)
RTC read data.
Real-Time Clock (MC146818)
void writeData(const uint8_t addr, const uint8_t data)
RTC write data.
MC146818(EventManager *em, const std::string &name, const struct tm time, bool bcd, Tick frequency)
static const int RTC_STAT_REGA
static uint8_t unbcdize(uint8_t val)
bool scheduled() const
Determine if the current event is scheduled.
const char * description() const
Event description.
static const int RTC_STAT_REGC
void serialize(const std::string &base, CheckpointOut &cp) const
Serialize this object to the given output stream.
void deschedule(Event &event)
RtcRegB stat_regB
RTC status register B.
#define UNSERIALIZE_SCALAR(scalar)
Tick curTick()
The current simulated tick.
RTCEvent(MC146818 *_parent, Tick i)
RTCEvent event
RTC periodic interrupt event.
virtual void process()
Event process to occur at interrupt.
RTCTickEvent tickEvent
RTC tick event.
Tick when() const
Get the time that the event is scheduled.
uint64_t Tick
Tick count type.
void scheduleIntr()
Schedule the RTC periodic interrupt.
void paramOut(CheckpointOut &cp, const string &name, ExtMachInst const &machInst)
static const int RTC_STAT_REGB
static const int RTCA_RS_1024HZ
void arrayParamOut(CheckpointOut &cp, const std::string &name, const CircleBuf< T > ¶m)
void setTime(const struct tm time)
virtual const char * description() const
Event description.
static const int RTCA_DV_DISABLED1
#define SERIALIZE_SCALAR(scalar)
std::ostream CheckpointOut
time_t mkutctime(struct tm *time)
virtual void startup()
Start ticking.
void unserialize(const std::string &base, CheckpointIn &cp)
Reconstruct the state of this object from a checkpoint.
static const int RTCA_DV_DISABLED0
void schedule(Event &event, Tick when)
void paramIn(CheckpointIn &cp, const string &name, ExtMachInst &machInst)
void arrayParamIn(CheckpointIn &cp, const std::string &name, CircleBuf< T > ¶m)
static const int RTC_STAT_REGD
static const int RTCA_DV_32768HZ
void process()
Event process to occur at interrupt.