mc146818.hh (5606:6da7a58b0bc8) mc146818.hh (6620:ade9a088bb14)
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;

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

59
60 /** Event process to occur at interrupt*/
61 virtual void process();
62
63 /** Event description */
64 virtual const char *description() const;
65 };
66
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;

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

59
60 /** Event process to occur at interrupt*/
61 virtual void process();
62
63 /** Event description */
64 virtual const char *description() const;
65 };
66
67 /** Event for RTC periodic interrupt */
68 struct RTCTickEvent : public Event
69 {
70 MC146818 * parent;
71
72 RTCTickEvent(MC146818 * _parent) : parent(_parent)
73 {
74 parent->schedule(this, curTick + Clock::Int::s);
75 }
76
77 /** Event process to occur at interrupt*/
78 void process();
79
80 /** Event description */
81 const char *description() const;
82 };
83
67 private:
68 std::string _name;
69 const std::string &name() const { return _name; }
70
71 /** RTC periodic interrupt event */
72 RTCEvent event;
73
84 private:
85 std::string _name;
86 const std::string &name() const { return _name; }
87
88 /** RTC periodic interrupt event */
89 RTCEvent event;
90
91 /** RTC tick event */
92 RTCTickEvent tickEvent;
93
74 /** Data for real-time clock function */
75 union {
76 uint8_t clock_data[10];
77
78 struct {
79 uint8_t sec;
80 uint8_t sec_alrm;
81 uint8_t min;
82 uint8_t min_alrm;
83 uint8_t hour;
84 uint8_t hour_alrm;
85 uint8_t wday;
86 uint8_t mday;
87 uint8_t mon;
88 uint8_t year;
89 };
90 };
91
94 /** Data for real-time clock function */
95 union {
96 uint8_t clock_data[10];
97
98 struct {
99 uint8_t sec;
100 uint8_t sec_alrm;
101 uint8_t min;
102 uint8_t min_alrm;
103 uint8_t hour;
104 uint8_t hour_alrm;
105 uint8_t wday;
106 uint8_t mday;
107 uint8_t mon;
108 uint8_t year;
109 };
110 };
111
112 struct tm curTime;
113
114 void setTime(const struct tm time);
115
92 /** RTC status register A */
93 uint8_t stat_regA;
94
95 /** RTC status register B */
96 uint8_t stat_regB;
97
98 public:
99 MC146818(EventManager *em, const std::string &name, const struct tm time,
100 bool bcd, Tick frequency);
101 virtual ~MC146818();
102
103 /** RTC write data */
104 void writeData(const uint8_t addr, const uint8_t data);
105
106 /** RTC read data */
107 uint8_t readData(const uint8_t addr);
108
116 /** RTC status register A */
117 uint8_t stat_regA;
118
119 /** RTC status register B */
120 uint8_t stat_regB;
121
122 public:
123 MC146818(EventManager *em, const std::string &name, const struct tm time,
124 bool bcd, Tick frequency);
125 virtual ~MC146818();
126
127 /** RTC write data */
128 void writeData(const uint8_t addr, const uint8_t data);
129
130 /** RTC read data */
131 uint8_t readData(const uint8_t addr);
132
133 void tickClock();
134
109 /**
110 * Serialize this object to the given output stream.
111 * @param base The base name of the counter object.
112 * @param os The stream to serialize to.
113 */
114 void serialize(const std::string &base, std::ostream &os);
115
116 /**
117 * Reconstruct the state of this object from a checkpoint.
118 * @param base The base name of the counter object.
119 * @param cp The checkpoint use.
120 * @param section The section name of this object
121 */
122 void unserialize(const std::string &base, Checkpoint *cp,
123 const std::string &section);
124};
125
126#endif // __DEV_MC146818_HH__
135 /**
136 * Serialize this object to the given output stream.
137 * @param base The base name of the counter object.
138 * @param os The stream to serialize to.
139 */
140 void serialize(const std::string &base, std::ostream &os);
141
142 /**
143 * Reconstruct the state of this object from a checkpoint.
144 * @param base The base name of the counter object.
145 * @param cp The checkpoint use.
146 * @param section The section name of this object
147 */
148 void unserialize(const std::string &base, Checkpoint *cp,
149 const std::string &section);
150};
151
152#endif // __DEV_MC146818_HH__