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#include "sim/sim_object.hh" |
44 45using namespace std; 46 47static uint8_t 48bcdize(uint8_t val) 49{ 50 uint8_t result; 51 result = val % 10; --- 49 unchanged lines hidden (view full) --- 101 stat_regB |= RTCB_BIN; 102 103 setTime(time); 104 DPRINTFN("Real-time clock set to %s", asctime(&time)); 105} 106 107MC146818::~MC146818() 108{ |
109 if (tickEvent.scheduled()) { 110 deschedule(tickEvent); 111 } 112 if (event.scheduled()) { 113 deschedule(event); 114 } |
115} 116 117void 118MC146818::writeData(const uint8_t addr, const uint8_t data) 119{ 120 if (addr < RTC_STAT_REGA) { 121 clock_data[addr] = data; 122 curTime.tm_sec = unbcdize(sec); --- 80 unchanged lines hidden (view full) --- 203{ 204 if (stat_regB & RTCB_NO_UPDT) 205 return; 206 time_t calTime = mkutctime(&curTime); 207 calTime++; 208 setTime(*gmtime(&calTime)); 209} 210 |
211unsigned int 212MC146818::drain(Event *de) 213{ 214 if (event.scheduled()) { 215 rtcTimerInterruptTickOffset = event.when() - curTick; 216 rtcClockTickOffset = event.when() - curTick; 217 deschedule(event); 218 } 219 if (tickEvent.scheduled()) { 220 deschedule(tickEvent); 221 } 222 return 0; 223} 224 |
225void 226MC146818::serialize(const string &base, ostream &os) 227{ 228 arrayParamOut(os, base + ".clock_data", clock_data, sizeof(clock_data)); 229 paramOut(os, base + ".stat_regA", stat_regA); 230 paramOut(os, base + ".stat_regB", stat_regB); 231 232 // 233 // save the timer tick and rtc clock tick values to correctly reschedule 234 // them during unserialize 235 // |
236 SERIALIZE_SCALAR(rtcTimerInterruptTickOffset); |
237 SERIALIZE_SCALAR(rtcClockTickOffset); 238} 239 240void 241MC146818::unserialize(const string &base, Checkpoint *cp, 242 const string §ion) 243{ 244 arrayParamIn(cp, section, base + ".clock_data", clock_data, --- 55 unchanged lines hidden --- |