1/* 2 * Copyright (c) 2004-2005 The Regents of The University of Michigan 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are 7 * met: redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer; --- 26 unchanged lines hidden (view full) --- 35 36#include <string> 37 38#include "base/bitfield.hh" 39#include "base/time.hh" 40#include "base/trace.hh" 41#include "dev/mc146818.hh" 42#include "dev/rtcreg.h" |
43 44using namespace std; 45 46static uint8_t 47bcdize(uint8_t val) 48{ 49 uint8_t result; 50 result = val % 10; --- 49 unchanged lines hidden (view full) --- 100 stat_regB |= RTCB_BIN; 101 102 setTime(time); 103 DPRINTFN("Real-time clock set to %s", asctime(&time)); 104} 105 106MC146818::~MC146818() 107{ |
108 deschedule(tickEvent); 109 deschedule(event); |
110} 111 112void 113MC146818::writeData(const uint8_t addr, const uint8_t data) 114{ 115 if (addr < RTC_STAT_REGA) { 116 clock_data[addr] = data; 117 curTime.tm_sec = unbcdize(sec); --- 80 unchanged lines hidden (view full) --- 198{ 199 if (stat_regB & RTCB_NO_UPDT) 200 return; 201 time_t calTime = mkutctime(&curTime); 202 calTime++; 203 setTime(*gmtime(&calTime)); 204} 205 |
206void 207MC146818::serialize(const string &base, ostream &os) 208{ 209 arrayParamOut(os, base + ".clock_data", clock_data, sizeof(clock_data)); 210 paramOut(os, base + ".stat_regA", stat_regA); 211 paramOut(os, base + ".stat_regB", stat_regB); 212 213 // 214 // save the timer tick and rtc clock tick values to correctly reschedule 215 // them during unserialize 216 // |
217 Tick rtcTimerInterruptTickOffset = event.when() - curTick; |
218 SERIALIZE_SCALAR(rtcTimerInterruptTickOffset); |
219 Tick rtcClockTickOffset = event.when() - curTick; |
220 SERIALIZE_SCALAR(rtcClockTickOffset); 221} 222 223void 224MC146818::unserialize(const string &base, Checkpoint *cp, 225 const string §ion) 226{ 227 arrayParamIn(cp, section, base + ".clock_data", clock_data, --- 55 unchanged lines hidden --- |