Deleted Added
sdiff udiff text old ( 6617:6d3645f68654 ) new ( 6620:ade9a088bb14 )
full compact
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;

--- 29 unchanged lines hidden (view full) ---

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
46MC146818::MC146818(EventManager *em, const string &n, const struct tm time,
47 bool bcd, Tick frequency)
48 : EventManager(em), _name(n), event(this, frequency)
49{
50 memset(clock_data, 0, sizeof(clock_data));
51 stat_regA = RTCA_32768HZ | RTCA_1024HZ;
52 stat_regB = RTCB_PRDC_IE | RTCB_24HR;
53 if (!bcd)
54 stat_regB |= RTCB_BIN;
55
56 year = time.tm_year;
57
58 if (bcd) {
59 // The datasheet says that the year field can be either BCD or
60 // years since 1900. Linux seems to be happy with years since
61 // 1900.
62 year = year % 100;
63 int tens = year / 10;
64 int ones = year % 10;
65 year = (tens << 4) + ones;
66 }
67
68 // Unix is 0-11 for month, data seet says start at 1
69 mon = time.tm_mon + 1;
70 mday = time.tm_mday;
71 hour = time.tm_hour;
72 min = time.tm_min;
73 sec = time.tm_sec;
74
75 // Datasheet says 1 is sunday
76 wday = time.tm_wday + 1;
77
78 DPRINTFN("Real-time clock set to %s", asctime(&time));
79}
80
81MC146818::~MC146818()
82{
83}
84
85void

--- 50 unchanged lines hidden (view full) ---

136 return 0x00;
137 break;
138 default:
139 panic("Shouldn't be here");
140 }
141 }
142}
143
144void
145MC146818::serialize(const string &base, ostream &os)
146{
147 arrayParamOut(os, base + ".clock_data", clock_data, sizeof(clock_data));
148 paramOut(os, base + ".stat_regA", stat_regA);
149 paramOut(os, base + ".stat_regB", stat_regB);
150}
151
152void

--- 32 unchanged lines hidden (view full) ---

185 parent->handleEvent();
186}
187
188const char *
189MC146818::RTCEvent::description() const
190{
191 return "RTC interrupt";
192}