gem5  v20.0.0.2
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
timer_a9global.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017 Gedare Bloom
3  * Copyright (c) 2010 ARM Limited
4  * All rights reserved
5  *
6  * The license below extends only to copyright in the software and shall
7  * not be construed as granting a license to any other intellectual
8  * property including but not limited to intellectual property relating
9  * to a hardware implementation of the functionality of the software
10  * licensed hereunder. You may use the software subject to the license
11  * terms below provided that you ensure that this notice is replicated
12  * unmodified and in its entirety in all distributions of the software,
13  * modified or unmodified, in source code or in binary form.
14  *
15  * Redistribution and use in source and binary forms, with or without
16  * modification, are permitted provided that the following conditions are
17  * met: redistributions of source code must retain the above copyright
18  * notice, this list of conditions and the following disclaimer;
19  * redistributions in binary form must reproduce the above copyright
20  * notice, this list of conditions and the following disclaimer in the
21  * documentation and/or other materials provided with the distribution;
22  * neither the name of the copyright holders nor the names of its
23  * contributors may be used to endorse or promote products derived from
24  * this software without specific prior written permission.
25  *
26  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
27  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
28  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
29  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
30  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
31  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
32  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
33  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
34  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
35  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
36  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37  */
38 
39 #ifndef __DEV_ARM_GLOBAL_TIMER_HH__
40 #define __DEV_ARM_GLOBAL_TIMER_HH__
41 
42 #include "dev/io_device.hh"
43 #include "params/A9GlobalTimer.hh"
44 
50 class BaseGic;
51 
53 {
54  protected:
55  class Timer : public Serializable
56  {
57 
58  public:
59  /* TODO: IntStatusReg, CmpValRegLow32, CmpValRegHigh32,
60  * and AutoIncrementReg are banked per-cpu. Some bits of
61  * ControlReg are also banked per-cpu, see below. */
62  enum {
65  ControlReg = 0x08,
66  IntStatusReg = 0x0C,
70  Size = 0x1C
71  };
72 
73  /* TODO: bits 1--3 are banked per-cpu */
74  BitUnion32(CTRL)
75  Bitfield<0> enable;
76  Bitfield<1> cmpEnable;
77  Bitfield<2> intEnable;
78  Bitfield<3> autoIncrement;
79  Bitfield<7,4> reserved;
80  Bitfield<15,8> prescalar;
82 
83  protected:
84  std::string _name;
85 
88 
90  const uint32_t intNum;
91 
93  /* TODO: one per-cpu? */
94  CTRL control;
95 
98  /* TODO: one per-cpu */
99  bool rawInt;
100 
104 
106  uint64_t cmpVal;
107 
109  /* TODO: one per-cpu */
110  uint32_t autoIncValue;
111 
113  void counterAtCmpVal();
115 
116  public:
118  void restartCounter();
123  uint64_t getTimeCounterFromTicks(Tick ticks);
124  Timer(std::string __name, A9GlobalTimer *parent, int int_num);
125 
126  std::string name() const { return _name; }
127 
129  void read(PacketPtr pkt, Addr daddr);
130 
132  void write(PacketPtr pkt, Addr daddr);
133 
134  void serialize(CheckpointOut &cp) const override;
135  void unserialize(CheckpointIn &cp) override;
136  };
137 
140 
143 
144  public:
145  typedef A9GlobalTimerParams Params;
146  const Params *
147  params() const
148  {
149  return dynamic_cast<const Params *>(_params);
150  }
155  A9GlobalTimer(Params *p);
156 
162  Tick read(PacketPtr pkt) override;
163 
169  Tick write(PacketPtr pkt) override;
170 
171  void serialize(CheckpointOut &cp) const override;
172  void unserialize(CheckpointIn &cp) override;
173 };
174 
175 #endif // __DEV_ARM_GLOBAL_TIMER_HH__
Bitfield< 2 > intEnable
void write(PacketPtr pkt, Addr daddr)
Handle write for a single timer.
BaseGic * gic
Pointer to the GIC for causing an interrupt.
void unserialize(CheckpointIn &cp) override
Unserialize an object.
uint64_t getTimeCounterFromTicks(Tick ticks)
Convert a number of ticks into the time counter format.
A9GlobalTimer(Params *p)
The constructor for RealView just registers itself with the MMU.
EndBitUnion(UserDescFlags) struct UserDesc32
Definition: process.cc:152
Bitfield< 1 > cmpEnable
CTRL control
Control register as specified above.
EventWrapper< Timer, &Timer::counterAtCmpVal > cmpValEvent
Timer global_timer
Timer that does the actual work.
Definition: cprintf.cc:40
Timer(std::string __name, A9GlobalTimer *parent, int int_num)
void restartCounter()
Restart the counter ticking.
Bitfield< 11 > enable
Definition: misc.hh:1051
EndBitUnion(CTRL) protected A9GlobalTimer * parent
Pointer to parent class.
uint64_t Tick
Tick count type.
Definition: types.hh:61
const uint32_t intNum
Number of interrupt to cause/clear.
BitUnion32(CTRL) Bitfield< 0 > enable
bool pendingInt
If an interrupt is currently pending.
uint64_t cmpVal
Value of the comparator.
void serialize(CheckpointOut &cp) const override
Serialize an object.
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:140
Bitfield< 3 > autoIncrement
A Packet is used to encapsulate a transfer between two objects in the memory system (e...
Definition: packet.hh:249
Basic support for object serialization.
Definition: serialize.hh:166
void counterAtCmpVal()
Called when the counter reaches the comparator.
A9GlobalTimerParams Params
std::ostream CheckpointOut
Definition: serialize.hh:63
const SimObjectParams * _params
Cached copy of the object parameters.
Definition: sim_object.hh:110
Bitfield< 7, 4 > reserved
void read(PacketPtr pkt, Addr daddr)
Handle read for a single timer.
bool rawInt
If timer has caused an interrupt.
const Params * params() const
Bitfield< 15, 8 > prescalar
uint32_t autoIncValue
Value to add to comparator when counter reaches comparator.
Bitfield< 0 > p
std::string name() const

Generated on Mon Jun 8 2020 15:45:10 for gem5 by doxygen 1.8.13