gem5  v21.0.0.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
timer_cpulocal.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2010-2011,2018 ARM Limited
3  * All rights reserved
4  *
5  * The license below extends only to copyright in the software and shall
6  * not be construed as granting a license to any other intellectual
7  * property including but not limited to intellectual property relating
8  * to a hardware implementation of the functionality of the software
9  * licensed hereunder. You may use the software subject to the license
10  * terms below provided that you ensure that this notice is replicated
11  * unmodified and in its entirety in all distributions of the software,
12  * modified or unmodified, in source code or in binary form.
13  *
14  * Redistribution and use in source and binary forms, with or without
15  * modification, are permitted provided that the following conditions are
16  * met: redistributions of source code must retain the above copyright
17  * notice, this list of conditions and the following disclaimer;
18  * redistributions in binary form must reproduce the above copyright
19  * notice, this list of conditions and the following disclaimer in the
20  * documentation and/or other materials provided with the distribution;
21  * neither the name of the copyright holders nor the names of its
22  * contributors may be used to endorse or promote products derived from
23  * this software without specific prior written permission.
24  *
25  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
31  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36  */
37 
38 #ifndef __DEV_ARM_LOCALTIMER_HH__
39 #define __DEV_ARM_LOCALTIMER_HH__
40 
41 #include <cstdint>
42 #include <memory>
43 #include <vector>
44 
45 #include "base/bitunion.hh"
46 #include "base/types.hh"
47 #include "dev/io_device.hh"
48 #include "params/CpuLocalTimer.hh"
49 #include "sim/serialize.hh"
50 
56 class BaseGic;
57 class ArmInterruptPin;
58 
60 {
61  protected:
62  class Timer : public Serializable
63  {
64 
65  public:
66  enum {
67  TimerLoadReg = 0x00,
77  Size = 0x38
78  };
79 
80  BitUnion32(TimerCtrl)
81  Bitfield<0> enable;
82  Bitfield<1> autoReload;
83  Bitfield<2> intEnable;
84  Bitfield<7,3> reserved;
85  Bitfield<15,8> prescalar;
86  EndBitUnion(TimerCtrl)
87 
88  BitUnion32(WatchdogCtrl)
89  Bitfield<0> enable;
90  Bitfield<1> autoReload;
91  Bitfield<2> intEnable;
92  Bitfield<3> watchdogMode;
93  Bitfield<7,4> reserved;
94  Bitfield<15,8> prescalar;
95  EndBitUnion(WatchdogCtrl)
96 
97  protected:
98  std::string _name;
99 
102 
106 
108  TimerCtrl timerControl;
109  WatchdogCtrl watchdogControl;
110 
117 
122 
124  uint32_t timerLoadValue;
126 
128  void timerAtZero();
130 
131  void watchdogAtZero();
133  public:
136  void restartTimerCounter(uint32_t val);
137  void restartWatchdogCounter(uint32_t val);
138 
139  Timer(const std::string &name,
140  CpuLocalTimer* _parent,
141  ArmInterruptPin* int_timer,
142  ArmInterruptPin* int_watchdog);
143 
144  std::string name() const { return _name; }
145 
147  void read(PacketPtr pkt, Addr daddr);
148 
150  void write(PacketPtr pkt, Addr daddr);
151 
152  void serialize(CheckpointOut &cp) const override;
153  void unserialize(CheckpointIn &cp) override;
154 
155  friend class CpuLocalTimer;
156  };
157 
160 
163 
164  public:
166 
171  CpuLocalTimer(const Params &p);
172 
174  void init() override;
175 
181  Tick read(PacketPtr pkt) override;
182 
188  Tick write(PacketPtr pkt) override;
189 
190  void serialize(CheckpointOut &cp) const override;
191  void unserialize(CheckpointIn &cp) override;
192 };
193 
194 
195 #endif // __DEV_ARM_SP804_HH__
196 
CpuLocalTimer::Timer::Size
@ Size
Definition: timer_cpulocal.hh:77
CpuLocalTimer::Timer::watchdogMode
Bitfield< 3 > watchdogMode
Definition: timer_cpulocal.hh:92
CpuLocalTimer::Timer::WatchdogControlReg
@ WatchdogControlReg
Definition: timer_cpulocal.hh:73
CpuLocalTimer::Timer::WatchdogLoadReg
@ WatchdogLoadReg
Definition: timer_cpulocal.hh:71
io_device.hh
CpuLocalTimer::Timer::watchdogAtZero
void watchdogAtZero()
Definition: timer_cpulocal.cc:326
CpuLocalTimer::unserialize
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition: timer_cpulocal.cc:440
CpuLocalTimer::Timer::serialize
void serialize(CheckpointOut &cp) const override
Serialize an object.
Definition: timer_cpulocal.cc:357
CpuLocalTimer::Timer::unserialize
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition: timer_cpulocal.cc:393
serialize.hh
CpuLocalTimer::Timer::timerControl
TimerCtrl timerControl
Control register as specified above.
Definition: timer_cpulocal.hh:108
CpuLocalTimer::Timer::TimerLoadReg
@ TimerLoadReg
Definition: timer_cpulocal.hh:67
CpuLocalTimer::Timer::write
void write(PacketPtr pkt, Addr daddr)
Handle write for a single timer.
Definition: timer_cpulocal.cc:189
Serializable
Basic support for object serialization.
Definition: serialize.hh:175
CpuLocalTimer::Timer::intTimer
ArmInterruptPin * intTimer
Interrupt to cause/clear.
Definition: timer_cpulocal.hh:104
CpuLocalTimer::Timer::TimerControlReg
@ TimerControlReg
Definition: timer_cpulocal.hh:69
Tick
uint64_t Tick
Tick count type.
Definition: types.hh:59
CpuLocalTimer::Timer::watchdogZeroEvent
EventFunctionWrapper watchdogZeroEvent
Definition: timer_cpulocal.hh:132
CpuLocalTimer::Timer::watchdogControl
WatchdogCtrl watchdogControl
Definition: timer_cpulocal.hh:109
CpuLocalTimer::Timer::prescalar
Bitfield< 15, 8 > prescalar
Definition: timer_cpulocal.hh:85
std::vector
STL vector class.
Definition: stl.hh:37
CpuLocalTimer::Timer::restartWatchdogCounter
void restartWatchdogCounter(uint32_t val)
Definition: timer_cpulocal.cc:284
CpuLocalTimer::Timer::watchdogLoadValue
uint32_t watchdogLoadValue
Definition: timer_cpulocal.hh:125
CpuLocalTimer::Timer::reserved
Bitfield< 7, 4 > reserved
Definition: timer_cpulocal.hh:93
CpuLocalTimer::Timer::WatchdogResetStatusReg
@ WatchdogResetStatusReg
Definition: timer_cpulocal.hh:75
CpuLocalTimer::init
void init() override
Inits the local timers.
Definition: timer_cpulocal.cc:58
EventFunctionWrapper
Definition: eventq.hh:1112
CpuLocalTimer::Timer::TimerIntStatusReg
@ TimerIntStatusReg
Definition: timer_cpulocal.hh:70
CpuLocalTimer::Timer::watchdogDisableReg
uint32_t watchdogDisableReg
Definition: timer_cpulocal.hh:116
CpuLocalTimer::Timer::reserved
Bitfield< 7, 3 > reserved
Definition: timer_cpulocal.hh:84
CpuLocalTimer::PARAMS
PARAMS(CpuLocalTimer)
cp
Definition: cprintf.cc:37
CpuLocalTimer::read
Tick read(PacketPtr pkt) override
Handle a read to the device.
Definition: timer_cpulocal.cc:92
CpuLocalTimer
Definition: timer_cpulocal.hh:59
CpuLocalTimer::Timer::name
std::string name() const
Definition: timer_cpulocal.hh:144
CpuLocalTimer::Timer::WatchdogIntStatusReg
@ WatchdogIntStatusReg
Definition: timer_cpulocal.hh:74
CpuLocalTimer::Timer::WatchdogDisableReg
@ WatchdogDisableReg
Definition: timer_cpulocal.hh:76
CpuLocalTimer::Timer::autoReload
Bitfield< 1 > autoReload
Definition: timer_cpulocal.hh:82
bitunion.hh
CpuLocalTimer::Timer::pendingIntTimer
bool pendingIntTimer
If an interrupt is currently pending.
Definition: timer_cpulocal.hh:120
CpuLocalTimer::write
Tick write(PacketPtr pkt) override
Handle a write to the device.
Definition: timer_cpulocal.cc:170
CpuLocalTimer::Timer::EndBitUnion
EndBitUnion(TimerCtrl) BitUnion32(WatchdogCtrl) Bitfield< 0 > enable
CpuLocalTimer::Timer::WatchdogCounterReg
@ WatchdogCounterReg
Definition: timer_cpulocal.hh:72
X86ISA::val
Bitfield< 63 > val
Definition: misc.hh:769
CpuLocalTimer::Timer::timerLoadValue
uint32_t timerLoadValue
Value to load into counters when periodic mode reaches 0.
Definition: timer_cpulocal.hh:124
CpuLocalTimer::Timer::rawIntWatchdog
bool rawIntWatchdog
Definition: timer_cpulocal.hh:114
Addr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:148
CpuLocalTimer::Timer::timerZeroEvent
EventFunctionWrapper timerZeroEvent
Definition: timer_cpulocal.hh:129
CpuLocalTimer::Timer::BitUnion32
BitUnion32(TimerCtrl) Bitfield< 0 > enable
CpuLocalTimer::Timer::rawResetWatchdog
bool rawResetWatchdog
Definition: timer_cpulocal.hh:115
CpuLocalTimer::Timer::intWatchdog
ArmInterruptPin * intWatchdog
Definition: timer_cpulocal.hh:105
BaseGic
Definition: base_gic.hh:64
types.hh
CpuLocalTimer::Timer::intEnable
Bitfield< 2 > intEnable
Definition: timer_cpulocal.hh:83
CpuLocalTimer::Timer::restartTimerCounter
void restartTimerCounter(uint32_t val)
Restart the counter ticking at val.
Definition: timer_cpulocal.cc:266
X86ISA::enable
Bitfield< 11 > enable
Definition: misc.hh:1051
Packet
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition: packet.hh:258
BasicPioDevice
Definition: io_device.hh:144
ArmInterruptPin
Generic representation of an Arm interrupt pin.
Definition: base_gic.hh:179
CpuLocalTimer::Timer::read
void read(PacketPtr pkt, Addr daddr)
Handle read for a single timer.
Definition: timer_cpulocal.cc:112
CpuLocalTimer::gic
BaseGic * gic
Pointer to the GIC for causing an interrupt.
Definition: timer_cpulocal.hh:159
CheckpointOut
std::ostream CheckpointOut
Definition: serialize.hh:64
CpuLocalTimer::Timer
Definition: timer_cpulocal.hh:62
CpuLocalTimer::Timer::pendingIntWatchdog
bool pendingIntWatchdog
Definition: timer_cpulocal.hh:121
CpuLocalTimer::Timer::rawIntTimer
bool rawIntTimer
If timer has caused an interrupt.
Definition: timer_cpulocal.hh:113
CpuLocalTimer::Timer::TimerCounterReg
@ TimerCounterReg
Definition: timer_cpulocal.hh:68
MipsISA::p
Bitfield< 0 > p
Definition: pra_constants.hh:323
CheckpointIn
Definition: serialize.hh:68
CpuLocalTimer::Timer::timerAtZero
void timerAtZero()
Called when the counter reaches 0.
Definition: timer_cpulocal.cc:303
CpuLocalTimer::localTimer
std::vector< std::unique_ptr< Timer > > localTimer
Timers that do the actual work.
Definition: timer_cpulocal.hh:162
PioDevice::Params
PioDeviceParams Params
Definition: io_device.hh:131
CpuLocalTimer::serialize
void serialize(CheckpointOut &cp) const override
Serialize an object.
Definition: timer_cpulocal.cc:433
CpuLocalTimer::Timer::parent
EndBitUnion(WatchdogCtrl) protected CpuLocalTimer * parent
Pointer to parent class.
Definition: timer_cpulocal.hh:95
CpuLocalTimer::CpuLocalTimer
CpuLocalTimer(const Params &p)
The constructor for RealView just registers itself with the MMU.
Definition: timer_cpulocal.cc:52
CpuLocalTimer::Timer::Timer
Timer(const std::string &name, CpuLocalTimer *_parent, ArmInterruptPin *int_timer, ArmInterruptPin *int_watchdog)
Definition: timer_cpulocal.cc:76

Generated on Tue Mar 23 2021 19:41:26 for gem5 by doxygen 1.8.17