gem5  v19.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  * Authors: Ali Saidi
38  * Geoffrey Blake
39  */
40 
41 #ifndef __DEV_ARM_LOCALTIMER_HH__
42 #define __DEV_ARM_LOCALTIMER_HH__
43 
44 #include "base/bitunion.hh"
45 #include "dev/io_device.hh"
46 #include "params/CpuLocalTimer.hh"
47 
53 class BaseGic;
54 class ArmInterruptPin;
55 
57 {
58  protected:
59  class Timer : public Serializable
60  {
61 
62  public:
63  enum {
64  TimerLoadReg = 0x00,
74  Size = 0x38
75  };
76 
77  BitUnion32(TimerCtrl)
78  Bitfield<0> enable;
79  Bitfield<1> autoReload;
80  Bitfield<2> intEnable;
81  Bitfield<7,3> reserved;
82  Bitfield<15,8> prescalar;
83  EndBitUnion(TimerCtrl)
84 
85  BitUnion32(WatchdogCtrl)
86  Bitfield<0> enable;
87  Bitfield<1> autoReload;
88  Bitfield<2> intEnable;
89  Bitfield<3> watchdogMode;
90  Bitfield<7,4> reserved;
91  Bitfield<15,8> prescalar;
92  EndBitUnion(WatchdogCtrl)
93 
94  protected:
95  std::string _name;
96 
99 
103 
105  TimerCtrl timerControl;
106  WatchdogCtrl watchdogControl;
107 
114 
119 
121  uint32_t timerLoadValue;
123 
125  void timerAtZero();
127 
128  void watchdogAtZero();
130  public:
133  void restartTimerCounter(uint32_t val);
134  void restartWatchdogCounter(uint32_t val);
135 
136  Timer(const std::string &name,
137  CpuLocalTimer* _parent,
138  ArmInterruptPin* int_timer,
139  ArmInterruptPin* int_watchdog);
140 
141  std::string name() const { return _name; }
142 
144  void read(PacketPtr pkt, Addr daddr);
145 
147  void write(PacketPtr pkt, Addr daddr);
148 
149  void serialize(CheckpointOut &cp) const override;
150  void unserialize(CheckpointIn &cp) override;
151 
152  friend class CpuLocalTimer;
153  };
154 
157 
160 
161  public:
162  typedef CpuLocalTimerParams Params;
163  const Params *
164  params() const
165  {
166  return dynamic_cast<const Params *>(_params);
167  }
172  CpuLocalTimer(Params *p);
173 
175  void init() override;
176 
182  Tick read(PacketPtr pkt) override;
183 
189  Tick write(PacketPtr pkt) override;
190 
191  void serialize(CheckpointOut &cp) const override;
192  void unserialize(CheckpointIn &cp) override;
193 };
194 
195 
196 #endif // __DEV_ARM_SP804_HH__
197 
BitUnion32(TimerCtrl) Bitfield< 0 > enable
void read(PacketPtr pkt, Addr daddr)
Handle read for a single timer.
ArmInterruptPin * intWatchdog
void restartTimerCounter(uint32_t val)
Restart the counter ticking at val.
bool pendingIntTimer
If an interrupt is currently pending.
EndBitUnion(TimerCtrl) BitUnion32(WatchdogCtrl) Bitfield< 0 > enable
Timer(const std::string &name, CpuLocalTimer *_parent, ArmInterruptPin *int_timer, ArmInterruptPin *int_watchdog)
Bitfield< 1 > autoReload
uint32_t timerLoadValue
Value to load into counters when periodic mode reaches 0.
Definition: cprintf.cc:42
const Params * params() const
EndBitUnion(WatchdogCtrl) protected CpuLocalTimer * parent
Pointer to parent class.
BaseGic * gic
Pointer to the GIC for causing an interrupt.
STL vector class.
Definition: stl.hh:40
EventFunctionWrapper timerZeroEvent
Bitfield< 63 > val
Definition: misc.hh:771
void serialize(CheckpointOut &cp) const override
Serialize an object.
CpuLocalTimerParams Params
friend class CpuLocalTimer
Bitfield< 11 > enable
Definition: misc.hh:1053
ArmInterruptPin * intTimer
Interrupt to cause/clear.
std::vector< std::unique_ptr< Timer > > localTimer
Timers that do the actual work.
TimerCtrl timerControl
Control register as specified above.
uint64_t Tick
Tick count type.
Definition: types.hh:63
void write(PacketPtr pkt, Addr daddr)
Handle write for a single timer.
Bitfield< 2 > intEnable
EventFunctionWrapper watchdogZeroEvent
Bitfield< 15, 8 > prescalar
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:142
bool rawIntTimer
If timer has caused an interrupt.
A Packet is used to encapsulate a transfer between two objects in the memory system (e...
Definition: packet.hh:255
Basic support for object serialization.
Definition: serialize.hh:153
Bitfield< 7, 3 > reserved
void restartWatchdogCounter(uint32_t val)
void timerAtZero()
Called when the counter reaches 0.
Bitfield< 3 > watchdogMode
void init() override
Inits the local timers.
Bitfield< 7, 4 > reserved
std::ostream CheckpointOut
Definition: serialize.hh:68
const SimObjectParams * _params
Cached copy of the object parameters.
Definition: sim_object.hh:110
std::string name() const
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Bitfield< 0 > p
Generic representation of an Arm interrupt pin.
Definition: base_gic.hh:178
WatchdogCtrl watchdogControl

Generated on Fri Feb 28 2020 16:27:00 for gem5 by doxygen 1.8.13