gem5 [DEVELOP-FOR-25.1]
Loading...
Searching...
No Matches
gic_v3.hh
Go to the documentation of this file.
1/*
2 * Copyright (c) 2019, 2022 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 * Copyright (c) 2018 Metempsy Technology Consulting
15 * All rights reserved.
16 *
17 * Redistribution and use in source and binary forms, with or without
18 * modification, are permitted provided that the following conditions are
19 * met: redistributions of source code must retain the above copyright
20 * notice, this list of conditions and the following disclaimer;
21 * redistributions in binary form must reproduce the above copyright
22 * notice, this list of conditions and the following disclaimer in the
23 * documentation and/or other materials provided with the distribution;
24 * neither the name of the copyright holders nor the names of its
25 * contributors may be used to endorse or promote products derived from
26 * this software without specific prior written permission.
27 *
28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
29 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
31 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
32 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
33 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
34 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
35 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
36 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
37 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
38 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39 */
40
41#ifndef __DEV_ARM_GICV3_H__
42#define __DEV_ARM_GICV3_H__
43
45#include "arch/arm/types.hh"
46#include "dev/arm/base_gic.hh"
47#include "params/Gicv3.hh"
48
49namespace gem5
50{
51
55class Gicv3Its;
56
58{
59 public:
60 virtual ~Gicv3Registers() = default;
61 virtual uint32_t readDistributor(Addr daddr) = 0;
62 virtual uint32_t readRedistributor(const ArmISA::Affinity &aff,
63 Addr daddr) = 0;
64 virtual RegVal readCpu(const ArmISA::Affinity &aff,
66
67 virtual void writeDistributor(Addr daddr, uint32_t data) = 0;
68 virtual void writeRedistributor(const ArmISA::Affinity &aff,
69 Addr daddr, uint32_t data) = 0;
70 virtual void writeCpu(const ArmISA::Affinity &aff,
72
73 protected:
74 static void copyDistRegister(Gicv3Registers* from,
76 Addr daddr);
77 static void copyRedistRegister(Gicv3Registers* from,
79 const ArmISA::Affinity &aff, Addr daddr);
80 static void copyCpuRegister(Gicv3Registers* from,
82 const ArmISA::Affinity &aff,
85 const ArmISA::Affinity &aff, Addr daddr);
86 static void copyRedistRange(Gicv3Registers* from,
88 const ArmISA::Affinity &aff,
89 Addr daddr, size_t size);
90 static void copyDistRange(Gicv3Registers* from,
92 Addr daddr, size_t size);
93 static void clearDistRange(Gicv3Registers* to, Addr daddr, size_t size);
94};
95
96class Gicv3 : public BaseGic, public Gicv3Registers
97{
98 protected:
99 friend class Gicv3CPUInterface;
100 friend class Gicv3Redistributor;
101 friend class Gicv3Distributor;
102
110 uint64_t redistSize;
111
112 public:
113
114 // Special interrupt IDs, as per SPEC 2.2.1 section
115 static const int INTID_SECURE = 1020;
116 static const int INTID_NONSECURE = 1021;
117 static const int INTID_SPURIOUS = 1023;
118
119 // Number of Software Generated Interrupts
120 static const int SGI_MAX = 16;
121 // Number of Private Peripheral Interrupts
122 static const int PPI_MAX = 16;
123
124 // Interrupt states for PPIs, SGIs and SPIs, as per SPEC 4.1.2 section
132
133 // Interrupt groups, as per SPEC section 4.6
135 {
139 };
140
146
147 protected:
148
149 void clearInt(uint32_t int_id) override;
150 void clearPPInt(uint32_t int_id, uint32_t cpu) override;
151
152 inline AddrRangeList
153 getAddrRanges() const override
154 {
155 return addrRanges;
156 }
157
158 void init() override;
159
161
162 Tick read(PacketPtr pkt) override;
163 void reset();
164 void sendInt(uint32_t int_id) override;
165 void sendPPInt(uint32_t int_id, uint32_t cpu) override;
166 void serialize(CheckpointOut & cp) const override;
167 void unserialize(CheckpointIn & cp) override;
168 Tick write(PacketPtr pkt) override;
169 bool supportsVersion(GicVersion version) override;
170
171 template<typename... Args>
172 void
173 reserved(const char* fmt, Args... args) const
174 {
175 if (params().reserved_is_res0) {
176 warn(fmt, args...);
177 } else {
178 panic(fmt, args...);
179 }
180 }
181
182 public:
183
184 Gicv3(const Params &p);
185 void deassertInt(uint32_t cpu, ArmISA::InterruptTypes int_type);
186 void deassertAll(uint32_t cpu);
187 bool haveAsserted(uint32_t cpu) const;
188
189 inline Gicv3CPUInterface *
190 getCPUInterface(int cpu_id) const
191 {
192 assert(cpu_id < cpuInterfaces.size() and cpuInterfaces[cpu_id]);
193 return cpuInterfaces[cpu_id];
194 }
195
196 inline Gicv3Distributor *
198 {
199 return distributor;
200 }
201
202 inline Gicv3Redistributor *
203 getRedistributor(ContextID context_id) const
204 {
205 assert(context_id < redistributors.size() and
206 redistributors[context_id]);
207 return redistributors[context_id];
208 }
209
211 getCPUInterfaceByAffinity(const ArmISA::Affinity &aff) const;
212
214 getRedistributorByAffinity(const ArmISA::Affinity &aff) const;
215
217 getRedistributorByAddr(Addr address) const;
218
219 void postInt(uint32_t cpu, ArmISA::InterruptTypes int_type);
220
221 void update();
222
223 protected: // GIC state transfer
225
226 public: // Gicv3Registers
227 uint32_t readDistributor(Addr daddr) override;
228 uint32_t readRedistributor(const ArmISA::Affinity &aff,
229 Addr daddr) override;
230 RegVal readCpu(const ArmISA::Affinity &aff,
232
233 void writeDistributor(Addr daddr, uint32_t data) override;
234 void writeRedistributor(const ArmISA::Affinity &aff,
235 Addr daddr, uint32_t data) override;
236 void writeCpu(const ArmISA::Affinity &aff,
238};
239
240} // namespace gem5
241
242#endif //__DEV_ARM_GICV3_H__
Base class for ARM GIC implementations.
const char data[]
The AddrRange class encapsulates an address range, and supports a number of tests to check if two ran...
Definition addr_range.hh:82
const Params & params() const
Definition base_gic.cc:78
BaseGicParams Params
Definition base_gic.hh:75
BaseGic(const Params &p)
Definition base_gic.cc:52
GICv3 ITS module.
Definition gic_v3_its.hh:85
static void clearRedistRegister(Gicv3Registers *to, const ArmISA::Affinity &aff, Addr daddr)
Definition gic_v3.cc:98
static void clearDistRange(Gicv3Registers *to, Addr daddr, size_t size)
Definition gic_v3.cc:124
static void copyRedistRange(Gicv3Registers *from, Gicv3Registers *to, const ArmISA::Affinity &aff, Addr daddr, size_t size)
Definition gic_v3.cc:105
virtual ~Gicv3Registers()=default
virtual void writeCpu(const ArmISA::Affinity &aff, ArmISA::MiscRegIndex misc_reg, RegVal data)=0
virtual void writeDistributor(Addr daddr, uint32_t data)=0
static void copyDistRegister(Gicv3Registers *from, Gicv3Registers *to, Addr daddr)
Definition gic_v3.cc:58
virtual uint32_t readRedistributor(const ArmISA::Affinity &aff, Addr daddr)=0
static void copyCpuRegister(Gicv3Registers *from, Gicv3Registers *to, const ArmISA::Affinity &aff, ArmISA::MiscRegIndex misc_reg)
Definition gic_v3.cc:82
static void copyRedistRegister(Gicv3Registers *from, Gicv3Registers *to, const ArmISA::Affinity &aff, Addr daddr)
Definition gic_v3.cc:68
static void copyDistRange(Gicv3Registers *from, Gicv3Registers *to, Addr daddr, size_t size)
Definition gic_v3.cc:115
virtual uint32_t readDistributor(Addr daddr)=0
virtual RegVal readCpu(const ArmISA::Affinity &aff, ArmISA::MiscRegIndex misc_reg)=0
virtual void writeRedistributor(const ArmISA::Affinity &aff, Addr daddr, uint32_t data)=0
static const int SGI_MAX
Definition gic_v3.hh:120
void writeRedistributor(const ArmISA::Affinity &aff, Addr daddr, uint32_t data) override
Definition gic_v3.cc:386
void init() override
init() is called after all C++ SimObjects have been created and all ports are connected.
Definition gic_v3.cc:137
Gicv3(const Params &p)
Definition gic_v3.cc:131
Gicv3Redistributor * getRedistributor(ContextID context_id) const
Definition gic_v3.hh:203
void clearPPInt(uint32_t int_id, uint32_t cpu) override
Definition gic_v3.cc:273
void reset()
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition gic_v3.cc:431
void serialize(CheckpointOut &cp) const override
Serialize an object.
Definition gic_v3.cc:415
void deassertInt(uint32_t cpu, ArmISA::InterruptTypes int_type)
Definition gic_v3.cc:303
Tick read(PacketPtr pkt) override
Pure virtual function that the device must implement.
Definition gic_v3.cc:176
bool supportsVersion(GicVersion version) override
Check if version supported.
Definition gic_v3.cc:296
friend class Gicv3Distributor
Definition gic_v3.hh:101
Gicv3Distributor * getDistributor() const
Definition gic_v3.hh:197
void reserved(const char *fmt, Args... args) const
Definition gic_v3.hh:173
uint32_t readRedistributor(const ArmISA::Affinity &aff, Addr daddr) override
Definition gic_v3.cc:364
void writeCpu(const ArmISA::Affinity &aff, ArmISA::MiscRegIndex misc_reg, RegVal data) override
Definition gic_v3.cc:394
friend class Gicv3Redistributor
Definition gic_v3.hh:100
Gicv3CPUInterface * getCPUInterface(int cpu_id) const
Definition gic_v3.hh:190
AddrRangeList addrRanges
Definition gic_v3.hh:109
bool haveAsserted(uint32_t cpu) const
Definition gic_v3.cc:317
@ INT_LEVEL_SENSITIVE
Definition gic_v3.hh:143
@ INT_EDGE_TRIGGERED
Definition gic_v3.hh:144
@ INT_ACTIVE_PENDING
Definition gic_v3.hh:130
static const int PPI_MAX
Definition gic_v3.hh:122
AddrRangeList getAddrRanges() const override
Every PIO device is obliged to provide an implementation that returns the address ranges the device r...
Definition gic_v3.hh:153
friend class Gicv3CPUInterface
Definition gic_v3.hh:99
static const int INTID_NONSECURE
Definition gic_v3.hh:116
void deassertAll(uint32_t cpu)
Definition gic_v3.cc:310
Gicv3CPUInterface * getCPUInterfaceByAffinity(const ArmISA::Affinity &aff) const
Definition gic_v3.cc:324
std::vector< Gicv3CPUInterface * > cpuInterfaces
Definition gic_v3.hh:105
static const int INTID_SPURIOUS
Definition gic_v3.hh:117
Tick write(PacketPtr pkt) override
Pure virtual function that the device must implement.
Definition gic_v3.cc:213
PARAMS(Gicv3)
Gicv3Redistributor * getRedistributorByAffinity(const ArmISA::Affinity &aff) const
Definition gic_v3.cc:330
AddrRange redistRange
Definition gic_v3.hh:108
void clearInt(uint32_t int_id) override
Clear an interrupt from a device that is connected to the GIC.
Definition gic_v3.cc:257
Gicv3Redistributor * getRedistributorByAddr(Addr address) const
Definition gic_v3.cc:342
static const int INTID_SECURE
Definition gic_v3.hh:115
uint32_t readDistributor(Addr daddr) override
Definition gic_v3.cc:358
Gicv3Its * its
Definition gic_v3.hh:106
void postInt(uint32_t cpu, ArmISA::InterruptTypes int_type)
Definition gic_v3.cc:282
void update()
Definition gic_v3.cc:290
std::vector< Gicv3Redistributor * > redistributors
Definition gic_v3.hh:104
void writeDistributor(Addr daddr, uint32_t data) override
Definition gic_v3.cc:380
void sendInt(uint32_t int_id) override
Post an interrupt from a device that is connected to the GIC.
Definition gic_v3.cc:250
RegVal readCpu(const ArmISA::Affinity &aff, ArmISA::MiscRegIndex misc_reg) override
Definition gic_v3.cc:372
void copyGicState(Gicv3Registers *from, Gicv3Registers *to)
Definition gic_v3.cc:403
Gicv3Distributor * distributor
Definition gic_v3.hh:103
void sendPPInt(uint32_t int_id, uint32_t cpu) override
Interface call for private peripheral interrupts.
Definition gic_v3.cc:264
AddrRange distRange
Definition gic_v3.hh:107
uint64_t redistSize
Definition gic_v3.hh:110
STL vector class.
Definition stl.hh:37
std::list< AddrRange > AddrRangeList
Convenience typedef for a collection of address ranges.
Definition addr_range.hh:64
#define panic(...)
This implements a cprintf based panic() function.
Definition logging.hh:220
#define warn(...)
Definition logging.hh:288
Bitfield< 0 > p
Bitfield< 25, 21 > to
Definition types.hh:96
Copyright (c) 2024 Arm Limited All rights reserved.
Definition binary32.hh:36
uint64_t RegVal
Definition types.hh:173
std::ostream CheckpointOut
Definition serialize.hh:66
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition types.hh:147
uint64_t Tick
Tick count type.
Definition types.hh:58
Packet * PacketPtr
int ContextID
Globally unique thread context ID.
Definition types.hh:239

Generated on Mon Oct 27 2025 04:13:01 for gem5 by doxygen 1.14.0