mc146818.cc (7064:586b0e3a12b3) | mc146818.cc (7559:017baf09599f) |
---|---|
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" | 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" |
|
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{ | 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{ |
108 deschedule(tickEvent); 109 deschedule(event); | 109 if (tickEvent.scheduled()) { 110 deschedule(tickEvent); 111 } 112 if (event.scheduled()) { 113 deschedule(event); 114 } |
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 | 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 |
|
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 // | 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 // |
217 Tick rtcTimerInterruptTickOffset = event.when() - curTick; | |
218 SERIALIZE_SCALAR(rtcTimerInterruptTickOffset); | 236 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 --- | 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 --- |