gem5 v24.0.0.0
Loading...
Searching...
No Matches
mc146818.hh
Go to the documentation of this file.
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;
9 * redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution;
12 * neither the name of the copyright holders nor the names of its
13 * contributors may be used to endorse or promote products derived from
14 * this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29#ifndef __DEV_MC146818_HH__
30#define __DEV_MC146818_HH__
31
32#include "base/bitunion.hh"
33#include "base/logging.hh"
34#include "sim/core.hh"
35#include "sim/eventq.hh"
36
37namespace gem5
38{
39
41class MC146818 : public EventManager
42{
43 protected:
44 virtual void handleEvent()
45 {
46 warn("No RTC event handler defined.\n");
47 }
48
49 private:
51 struct RTCEvent : public Event
52 {
56
57 RTCEvent(MC146818 * _parent, Tick i);
58
60 void scheduleIntr();
61
63 virtual void process();
64
66 virtual const char *description() const;
67 };
68
70 struct RTCTickEvent : public Event
71 {
74
76 parent(_parent), offset(sim_clock::as_int::s)
77 {}
78
80 void process();
81
83 const char *description() const;
84 };
85
86 private:
87 std::string _name;
88 const std::string &name() const { return _name; }
89
92
95
97 union
98 {
99 uint8_t clock_data[10];
100
101 struct
102 {
103 uint8_t sec;
104 uint8_t sec_alrm;
105 uint8_t min;
106 uint8_t min_alrm;
107 uint8_t hour;
108 uint8_t hour_alrm;
109 uint8_t wday;
110 uint8_t mday;
111 uint8_t mon;
112 uint8_t year;
113 };
114 };
115
116 struct tm curTime;
117
118 void setTime(const struct tm time);
119
120 BitUnion8(RtcRegA)
121 Bitfield<7> uip;
122 Bitfield<6, 4> dv;
132 Bitfield<3, 0> rs;
133 EndBitUnion(RtcRegA)
134
135
136 static inline bool rega_dv_disabled(const RtcRegA &reg);
137
138 BitUnion8(RtcRegB)
139 Bitfield<7> set;
140 Bitfield<6> pie;
141 Bitfield<5> aie;
142 Bitfield<4> uie;
143 Bitfield<3> sqwe;
144 Bitfield<2> dm;
145 Bitfield<1> format24h;
146 Bitfield<0> dse;
147 EndBitUnion(RtcRegB)
148
149
150 RtcRegA stat_regA;
151
153 RtcRegB stat_regB;
154
155 public:
156 MC146818(EventManager *em, const std::string &name, const struct tm time,
157 bool bcd, Tick frequency);
158 virtual ~MC146818();
159
161 virtual void startup();
162
164 void writeData(const uint8_t addr, const uint8_t data);
165
167 uint8_t readData(const uint8_t addr);
168
169 void tickClock();
170
176 void serialize(const std::string &base, CheckpointOut &cp) const;
177
184 void unserialize(const std::string &base, CheckpointIn &cp);
185};
186
187} // namespace gem5
188
189#endif // __DEV_MC146818_HH__
const char data[]
Real-Time Clock (MC146818)
Definition mc146818.hh:42
virtual void handleEvent()
Definition mc146818.hh:44
EndBitUnion(RtcRegA) static inline bool rega_dv_disabled(const RtcRegA &reg)
Is the DV field in regA set to disabled?
void setTime(const struct tm time)
Definition mc146818.cc:64
uint8_t hour_alrm
Definition mc146818.hh:108
MC146818(EventManager *em, const std::string &name, const struct tm time, bool bcd, Tick frequency)
Definition mc146818.cc:91
const std::string & name() const
Definition mc146818.hh:88
RTCTickEvent tickEvent
RTC tick event.
Definition mc146818.hh:94
Bitfield< 2 > dm
1 = output sqare wave at SQW pin
Definition mc146818.hh:144
EndBitUnion(RtcRegB) RtcRegA stat_regA
USA Daylight Savings Time enable.
Bitfield< 6, 4 > dv
1 = date and time update in progress
Definition mc146818.hh:122
uint8_t sec_alrm
Definition mc146818.hh:104
virtual void startup()
Start ticking.
Definition mc146818.cc:124
Bitfield< 3 > sqwe
1 = enable update-ended interrupt
Definition mc146818.hh:143
Bitfield< 1 > format24h
0 = BCD, 1 = Binary coded time
Definition mc146818.hh:145
RtcRegB stat_regB
RTC status register B.
Definition mc146818.hh:153
uint8_t clock_data[10]
Definition mc146818.hh:99
void tickClock()
Definition mc146818.cc:255
Bitfield< 6 > pie
stop clock updates
Definition mc146818.hh:140
Bitfield< 4 > uie
1 = enable alarm interrupt
Definition mc146818.hh:142
Bitfield< 5 > aie
1 = enable periodic clock interrupt
Definition mc146818.hh:141
Bitfield< 0 > dse
0 = 12 hours, 1 = 24 hours
Definition mc146818.hh:146
BitUnion8(RtcRegB) Bitfield< 7 > set
BitUnion8(RtcRegA) Bitfield< 7 > uip
virtual ~MC146818()
Definition mc146818.cc:110
void serialize(const std::string &base, CheckpointOut &cp) const
Serialize this object to the given output stream.
Definition mc146818.cc:267
void unserialize(const std::string &base, CheckpointIn &cp)
Reconstruct the state of this object from a checkpoint.
Definition mc146818.cc:287
Bitfield< 3, 0 > rs
Divider configuration.
Definition mc146818.hh:132
std::string _name
Definition mc146818.hh:87
struct tm curTime
Definition mc146818.hh:116
RTCEvent event
RTC periodic interrupt event.
Definition mc146818.hh:91
uint8_t readData(const uint8_t addr)
RTC read data.
Definition mc146818.cc:229
void writeData(const uint8_t addr, const uint8_t data)
RTC write data.
Definition mc146818.cc:136
uint8_t min_alrm
Definition mc146818.hh:106
#define warn(...)
Definition logging.hh:256
Bitfield< 4 > s
Bitfield< 7 > i
Definition misc_types.hh:67
Bitfield< 12, 11 > set
Bitfield< 32 > tm
Definition misc.hh:112
Bitfield< 5, 3 > reg
Definition types.hh:92
Bitfield< 51, 12 > base
Definition pagetable.hh:141
Bitfield< 3 > addr
Definition types.hh:84
Bitfield< 2 > em
Definition misc.hh:617
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
Definition binary32.hh:36
std::ostream CheckpointOut
Definition serialize.hh:66
uint64_t Tick
Tick count type.
Definition types.hh:58
Event for RTC periodic interrupt.
Definition mc146818.hh:52
virtual const char * description() const
Event description.
Definition mc146818.cc:331
RTCEvent(MC146818 *_parent, Tick i)
Definition mc146818.cc:310
virtual void process()
Event process to occur at interrupt.
Definition mc146818.cc:323
void scheduleIntr()
Schedule the RTC periodic interrupt.
Definition mc146818.cc:317
Event for RTC periodic interrupt.
Definition mc146818.hh:71
const char * description() const
Event description.
Definition mc146818.cc:345
RTCTickEvent(MC146818 *_parent)
Definition mc146818.hh:75
void process()
Event process to occur at interrupt.
Definition mc146818.cc:337

Generated on Tue Jun 18 2024 16:24:03 for gem5 by doxygen 1.11.0