gem5  v20.1.0.0
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  }
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__
A9GlobalTimer::Params
A9GlobalTimerParams Params
Definition: timer_a9global.hh:145
A9GlobalTimer::read
Tick read(PacketPtr pkt) override
Handle a read to the device.
Definition: timer_a9global.cc:63
A9GlobalTimer::Timer::autoIncValue
uint32_t autoIncValue
Value to add to comparator when counter reaches comparator.
Definition: timer_a9global.hh:110
io_device.hh
A9GlobalTimer::Timer::ControlReg
@ ControlReg
Definition: timer_a9global.hh:65
A9GlobalTimer::Timer::unserialize
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition: timer_a9global.cc:277
A9GlobalTimer::Timer::CmpValRegHigh32
@ CmpValRegHigh32
Definition: timer_a9global.hh:68
A9GlobalTimer::unserialize
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition: timer_a9global.cc:307
A9GlobalTimer::Timer::reserved
Bitfield< 7, 4 > reserved
Definition: timer_a9global.hh:79
A9GlobalTimer::write
Tick write(PacketPtr pkt) override
Handle a write to the device.
Definition: timer_a9global.cc:143
Serializable
Basic support for object serialization.
Definition: serialize.hh:172
A9GlobalTimer
Definition: timer_a9global.hh:52
A9GlobalTimer::Timer::cmpVal
uint64_t cmpVal
Value of the comparator.
Definition: timer_a9global.hh:106
EventWrapper
Definition: eventq.hh:1070
Tick
uint64_t Tick
Tick count type.
Definition: types.hh:63
A9GlobalTimer::Timer::read
void read(PacketPtr pkt, Addr daddr)
Handle read for a single timer.
Definition: timer_a9global.cc:85
A9GlobalTimer::Timer::CounterRegHigh32
@ CounterRegHigh32
Definition: timer_a9global.hh:64
A9GlobalTimer::Timer::Timer
Timer(std::string __name, A9GlobalTimer *parent, int int_num)
Definition: timer_a9global.cc:55
A9GlobalTimer::Timer::serialize
void serialize(CheckpointOut &cp) const override
Serialize an object.
Definition: timer_a9global.cc:254
A9GlobalTimer::Timer::cmpValEvent
EventWrapper< Timer, &Timer::counterAtCmpVal > cmpValEvent
Definition: timer_a9global.hh:114
A9GlobalTimer::Timer::parent
EndBitUnion(CTRL) protected A9GlobalTimer * parent
Pointer to parent class.
Definition: timer_a9global.hh:81
A9GlobalTimer::Timer::intNum
const uint32_t intNum
Number of interrupt to cause/clear.
Definition: timer_a9global.hh:90
A9GlobalTimer::global_timer
Timer global_timer
Timer that does the actual work.
Definition: timer_a9global.hh:142
A9GlobalTimer::Timer::cmpEnable
Bitfield< 1 > cmpEnable
Definition: timer_a9global.hh:76
A9GlobalTimer::params
const Params * params() const
Definition: timer_a9global.hh:147
A9GlobalTimer::Timer::counterAtCmpVal
void counterAtCmpVal()
Called when the counter reaches the comparator.
Definition: timer_a9global.cc:230
cp
Definition: cprintf.cc:40
A9GlobalTimer::Timer::restartCounter
void restartCounter()
Restart the counter ticking.
Definition: timer_a9global.cc:209
A9GlobalTimer::Timer::prescalar
Bitfield< 15, 8 > prescalar
Definition: timer_a9global.hh:80
A9GlobalTimer::Timer::autoIncrement
Bitfield< 3 > autoIncrement
Definition: timer_a9global.hh:78
A9GlobalTimer::Timer::Size
@ Size
Definition: timer_a9global.hh:70
Addr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:142
A9GlobalTimer::Timer::AutoIncrementReg
@ AutoIncrementReg
Definition: timer_a9global.hh:69
A9GlobalTimer::Timer::write
void write(PacketPtr pkt, Addr daddr)
Handle write for a single timer.
Definition: timer_a9global.cc:162
A9GlobalTimer::Timer::CmpValRegLow32
@ CmpValRegLow32
Definition: timer_a9global.hh:67
A9GlobalTimer::Timer::getTimeCounterFromTicks
uint64_t getTimeCounterFromTicks(Tick ticks)
Convert a number of ticks into the time counter format.
Definition: timer_a9global.cc:79
A9GlobalTimer::Timer::CounterRegLow32
@ CounterRegLow32
Definition: timer_a9global.hh:63
A9GlobalTimer::gic
BaseGic * gic
Pointer to the GIC for causing an interrupt.
Definition: timer_a9global.hh:139
BaseGic
Definition: base_gic.hh:62
A9GlobalTimer::Timer::BitUnion32
BitUnion32(CTRL) Bitfield< 0 > enable
A9GlobalTimer::serialize
void serialize(CheckpointOut &cp) const override
Serialize an object.
Definition: timer_a9global.cc:301
SimObject::_params
const SimObjectParams * _params
Cached copy of the object parameters.
Definition: sim_object.hh:110
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:257
BasicPioDevice
Definition: io_device.hh:150
A9GlobalTimer::Timer::control
CTRL control
Control register as specified above.
Definition: timer_a9global.hh:94
A9GlobalTimer::Timer
Definition: timer_a9global.hh:55
CheckpointOut
std::ostream CheckpointOut
Definition: serialize.hh:63
A9GlobalTimer::Timer::rawInt
bool rawInt
If timer has caused an interrupt.
Definition: timer_a9global.hh:99
MipsISA::p
Bitfield< 0 > p
Definition: pra_constants.hh:323
A9GlobalTimer::Timer::pendingInt
bool pendingInt
If an interrupt is currently pending.
Definition: timer_a9global.hh:103
CheckpointIn
Definition: serialize.hh:67
A9GlobalTimer::Timer::IntStatusReg
@ IntStatusReg
Definition: timer_a9global.hh:66
EndBitUnion
EndBitUnion(UserDescFlags) struct UserDesc32
Definition: process.cc:149
A9GlobalTimer::A9GlobalTimer
A9GlobalTimer(Params *p)
The constructor for RealView just registers itself with the MMU.
Definition: timer_a9global.cc:49
A9GlobalTimer::Timer::intEnable
Bitfield< 2 > intEnable
Definition: timer_a9global.hh:77
A9GlobalTimer::Timer::name
std::string name() const
Definition: timer_a9global.hh:126

Generated on Wed Sep 30 2020 14:02:10 for gem5 by doxygen 1.8.17