timer_cpulocal.hh (12086:069c529a76fd) timer_cpulocal.hh (13106:3af014b59080)
1/*
1/*
2 * Copyright (c) 2010-2011 ARM Limited
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

--- 35 unchanged lines hidden (view full) ---

46#include "params/CpuLocalTimer.hh"
47
48/** @file
49 * This implements the cpu local timer from the Cortex-A9 MPCore
50 * Technical Reference Manual rev r2p2 (ARM DDI 0407F)
51 */
52
53class BaseGic;
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

--- 35 unchanged lines hidden (view full) ---

46#include "params/CpuLocalTimer.hh"
47
48/** @file
49 * This implements the cpu local timer from the Cortex-A9 MPCore
50 * Technical Reference Manual rev r2p2 (ARM DDI 0407F)
51 */
52
53class BaseGic;
54class ArmInterruptPin;
54
55class CpuLocalTimer : public BasicPioDevice
56{
57 protected:
58 class Timer : public Serializable
59 {
60
61 public:

--- 29 unchanged lines hidden (view full) ---

91 EndBitUnion(WatchdogCtrl)
92
93 protected:
94 std::string _name;
95
96 /** Pointer to parent class */
97 CpuLocalTimer *parent;
98
55
56class CpuLocalTimer : public BasicPioDevice
57{
58 protected:
59 class Timer : public Serializable
60 {
61
62 public:

--- 29 unchanged lines hidden (view full) ---

92 EndBitUnion(WatchdogCtrl)
93
94 protected:
95 std::string _name;
96
97 /** Pointer to parent class */
98 CpuLocalTimer *parent;
99
99 /** Number of interrupt to cause/clear */
100 uint32_t intNumTimer;
101 uint32_t intNumWatchdog;
100 /** Interrupt to cause/clear */
101 ArmInterruptPin *intTimer;
102 ArmInterruptPin *intWatchdog;
102
103
103 /** Cpu this timer is attached to */
104 uint32_t cpuNum;
105
106 /** Control register as specified above */
107 TimerCtrl timerControl;
108 WatchdogCtrl watchdogControl;
109
110 /** If timer has caused an interrupt. This is irrespective of
111 * interrupt enable */
112 bool rawIntTimer;
113 bool rawIntWatchdog;

--- 16 unchanged lines hidden (view full) ---

130 void watchdogAtZero();
131 EventFunctionWrapper watchdogZeroEvent;
132 public:
133 /** Restart the counter ticking at val
134 * @param val the value to start at */
135 void restartTimerCounter(uint32_t val);
136 void restartWatchdogCounter(uint32_t val);
137
104 /** Control register as specified above */
105 TimerCtrl timerControl;
106 WatchdogCtrl watchdogControl;
107
108 /** If timer has caused an interrupt. This is irrespective of
109 * interrupt enable */
110 bool rawIntTimer;
111 bool rawIntWatchdog;

--- 16 unchanged lines hidden (view full) ---

128 void watchdogAtZero();
129 EventFunctionWrapper watchdogZeroEvent;
130 public:
131 /** Restart the counter ticking at val
132 * @param val the value to start at */
133 void restartTimerCounter(uint32_t val);
134 void restartWatchdogCounter(uint32_t val);
135
138 Timer();
136 Timer(const std::string &name,
137 CpuLocalTimer* _parent,
138 ArmInterruptPin* int_timer,
139 ArmInterruptPin* int_watchdog);
139
140 std::string name() const { return _name; }
141
142 /** Handle read for a single timer */
143 void read(PacketPtr pkt, Addr daddr);
144
145 /** Handle write for a single timer */
146 void write(PacketPtr pkt, Addr daddr);
147
148 void serialize(CheckpointOut &cp) const override;
149 void unserialize(CheckpointIn &cp) override;
150
151 friend class CpuLocalTimer;
152 };
153
140
141 std::string name() const { return _name; }
142
143 /** Handle read for a single timer */
144 void read(PacketPtr pkt, Addr daddr);
145
146 /** Handle write for a single timer */
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
154 static const int CPU_MAX = 8;
155
156 /** Pointer to the GIC for causing an interrupt */
157 BaseGic *gic;
158
159 /** Timers that do the actual work */
155 /** Pointer to the GIC for causing an interrupt */
156 BaseGic *gic;
157
158 /** Timers that do the actual work */
160 Timer localTimer[CPU_MAX];
159 std::vector<std::unique_ptr<Timer>> localTimer;
161
162 public:
163 typedef CpuLocalTimerParams Params;
164 const Params *
165 params() const
166 {
167 return dynamic_cast<const Params *>(_params);
168 }
169 /**
170 * The constructor for RealView just registers itself with the MMU.
171 * @param p params structure
172 */
173 CpuLocalTimer(Params *p);
174
160
161 public:
162 typedef CpuLocalTimerParams Params;
163 const Params *
164 params() const
165 {
166 return dynamic_cast<const Params *>(_params);
167 }
168 /**
169 * The constructor for RealView just registers itself with the MMU.
170 * @param p params structure
171 */
172 CpuLocalTimer(Params *p);
173
174 /** Inits the local timers */
175 void init() override;
176
175 /**
176 * Handle a read to the device
177 * @param pkt The memory request.
178 * @return Returns latency of device read
179 */
180 Tick read(PacketPtr pkt) override;
181
182 /**

--- 13 unchanged lines hidden ---
177 /**
178 * Handle a read to the device
179 * @param pkt The memory request.
180 * @return Returns latency of device read
181 */
182 Tick read(PacketPtr pkt) override;
183
184 /**

--- 13 unchanged lines hidden ---