gem5 v24.0.0.0
Loading...
Searching...
No Matches
gic_v3_distributor.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_DISTRIBUTOR_H__
42#define __DEV_ARM_GICV3_DISTRIBUTOR_H__
43
44#include "base/addr_range.hh"
45#include "dev/arm/gic_v3.hh"
46#include "sim/serialize.hh"
47
48namespace gem5
49{
50
52{
53 private:
54
55 friend class Gicv3Redistributor;
56 friend class Gicv3CPUInterface;
57 friend class Gicv3Its;
58
59 protected:
60
62 const uint32_t itLines;
63
64 enum
65 {
66 // Control Register
67 GICD_CTLR = 0x0000,
68 // Interrupt Controller Type Register
69 GICD_TYPER = 0x0004,
70 // Implementer Identification Register
71 GICD_IIDR = 0x0008,
72 // Interrupt Controller Type Register 2
73 GICD_TYPER2 = 0x000C,
74 // Error Reporting Status Register
75 GICD_STATUSR = 0x0010,
76 // Set Non-secure SPI Pending Register
78 // Clear Non-secure SPI Pending Register
80 // Set Secure SPI Pending Register
82 // Clear Secure SPI Pending Register
84 // Software Generated Interrupt Register
85 GICD_SGIR = 0x0f00,
86 // Peripheral ID0 Register
87 GICD_PIDR0 = 0xffe0,
88 // Peripheral ID1 Register
89 GICD_PIDR1 = 0xffe4,
90 // Peripheral ID2 Register
91 GICD_PIDR2 = 0xffe8,
92 // Peripheral ID3 Register
93 GICD_PIDR3 = 0xffec,
94 // Peripheral ID4 Register
95 GICD_PIDR4 = 0xffd0,
96 // Peripheral ID5 Register
97 GICD_PIDR5 = 0xffd4,
98 // Peripheral ID6 Register
99 GICD_PIDR6 = 0xffd8,
100 // Peripheral ID7 Register
101 GICD_PIDR7 = 0xffdc,
102 };
103
104 // Interrupt Group Registers
106 // Interrupt Set-Enable Registers
108 // Interrupt Clear-Enable Registers
110 // Interrupt Set-Pending Registers
112 // Interrupt Clear-Pending Registers
114 // Interrupt Set-Active Registers
116 // Interrupt Clear-Active Registers
118 // Interrupt Priority Registers
120 // Interrupt Processor Targets Registers
121 static const AddrRange GICD_ITARGETSR; // GICv2 legacy
122 // Interrupt Configuration Registers
123 static const AddrRange GICD_ICFGR;
124 // Interrupt Group Modifier Registers
126 // Non-secure Access Control Registers
127 static const AddrRange GICD_NSACR;
128 // SGI Clear-Pending Registers
129 static const AddrRange GICD_CPENDSGIR; // GICv2 legacy
130 // SGI Set-Pending Registers
131 static const AddrRange GICD_SPENDSGIR; // GICv2 legacy
132 // Interrupt Routing Registers
134
135 BitUnion64(IROUTER)
136 Bitfield<63, 40> res0_1;
137 Bitfield<39, 32> Aff3;
138 Bitfield<31> IRM;
139 Bitfield<30, 24> res0_2;
140 Bitfield<23, 16> Aff2;
141 Bitfield<15, 8> Aff1;
142 Bitfield<7, 0> Aff0;
143 EndBitUnion(IROUTER)
144
145 static const uint32_t GICD_CTLR_ENABLEGRP0 = 1 << 0;
146 static const uint32_t GICD_CTLR_ENABLEGRP1 = 1 << 0;
147 static const uint32_t GICD_CTLR_ENABLEGRP1NS = 1 << 1;
148 static const uint32_t GICD_CTLR_ENABLEGRP1A = 1 << 1;
149 static const uint32_t GICD_CTLR_ENABLEGRP1S = 1 << 2;
150 static const uint32_t GICD_CTLR_DS = 1 << 6;
151
152 bool ARE;
153 bool DS;
157 std::vector <uint8_t> irqGroup;
163 std::vector <Gicv3::IntTriggerType> irqConfig;
164 std::vector <uint8_t> irqGrpmod;
165 std::vector <uint8_t> irqNsacr;
167
168 uint32_t gicdTyper;
169 uint32_t gicdPidr0;
170 uint32_t gicdPidr1;
171 uint32_t gicdPidr2;
172 uint32_t gicdPidr3;
173 uint32_t gicdPidr4;
174
175 public:
176
177 static const uint32_t ADDR_RANGE_SIZE = 0x10000;
178 static const uint32_t IDBITS = 0xf;
179
180 protected:
181
182 void activateIRQ(uint32_t int_id);
183 void deactivateIRQ(uint32_t int_id);
185 Gicv3::GroupId getIntGroup(int int_id) const;
186
187 inline bool
188 groupEnabled(Gicv3::GroupId group) const
189 {
190 if (DS == 0) {
191 switch (group) {
192 case Gicv3::G0S:
193 return EnableGrp0;
194
195 case Gicv3::G1S:
196 return EnableGrp1S;
197
198 case Gicv3::G1NS:
199 return EnableGrp1NS;
200
201 default:
202 panic("Gicv3Distributor::groupEnabled(): "
203 "invalid group!\n");
204 }
205 } else {
206 switch (group) {
207 case Gicv3::G0S:
208 return EnableGrp0;
209
210 case Gicv3::G1S:
211 case Gicv3::G1NS:
212 return EnableGrp1NS;
213
214 default:
215 panic("Gicv3Distributor::groupEnabled(): "
216 "invalid group!\n");
217 }
218 }
219 }
220
221 Gicv3::IntStatus intStatus(uint32_t int_id) const;
222
223 inline bool isNotSPI(uint32_t int_id) const
224 {
225 if (int_id < (Gicv3::SGI_MAX + Gicv3::PPI_MAX) || int_id >= itLines) {
226 return true;
227 } else {
228 return false;
229 }
230 }
231
232 bool isLevelSensitive(uint32_t int_id) const
233 {
234 return irqConfig[int_id] == Gicv3::INT_LEVEL_SENSITIVE;
235 }
236
248 bool treatAsEdgeTriggered(uint32_t int_id) const
249 {
250 return !isLevelSensitive(int_id) || irqPendingIspendr[int_id];
251 }
252
253 inline bool nsAccessToSecInt(uint32_t int_id, bool is_secure_access) const
254 {
255 return !DS && !is_secure_access && getIntGroup(int_id) != Gicv3::G1NS;
256 }
257
258 void serialize(CheckpointOut & cp) const override;
259 void unserialize(CheckpointIn & cp) override;
260 Gicv3CPUInterface* route(uint32_t int_id);
261
262 public:
263
264 Gicv3Distributor(Gicv3 * gic, uint32_t it_lines);
265
266 void sendInt(uint32_t int_id);
267 void clearInt(uint32_t int_id);
268 void deassertSPI(uint32_t int_id);
269 void clearIrqCpuInterface(uint32_t int_id);
270 void init();
271 uint64_t read(Addr addr, size_t size, bool is_secure_access);
272 void write(Addr addr, uint64_t data, size_t size,
273 bool is_secure_access);
274
275 void copy(Gicv3Registers *from, Gicv3Registers *to);
276 void update();
277};
278
279} // namespace gem5
280
281#endif //__DEV_ARM_GICV3_DISTRIBUTOR_H__
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
std::vector< uint8_t > irqPriority
BitUnion64(IROUTER) Bitfield< 63
std::vector< bool > irqActive
static const AddrRange GICD_IGROUPR
static const AddrRange GICD_ISPENDR
static const AddrRange GICD_ICFGR
static const AddrRange GICD_ICACTIVER
std::vector< uint8_t > irqGrpmod
void sendInt(uint32_t int_id)
std::vector< bool > irqPending
void unserialize(CheckpointIn &cp) override
Unserialize an object.
std::vector< bool > irqEnabled
static const AddrRange GICD_NSACR
bool groupEnabled(Gicv3::GroupId group) const
bool isNotSPI(uint32_t int_id) const
std::vector< uint8_t > irqNsacr
void clearInt(uint32_t int_id)
static const AddrRange GICD_IGRPMODR
std::vector< uint8_t > irqGroup
std::vector< IROUTER > irqAffinityRouting
static const uint32_t IDBITS
static const AddrRange GICD_ISENABLER
bool treatAsEdgeTriggered(uint32_t int_id) const
This helper is used to check if an interrupt should be treated as edge triggered in the following sce...
Gicv3::IntStatus intStatus(uint32_t int_id) const
void copy(Gicv3Registers *from, Gicv3Registers *to)
static const uint32_t GICD_CTLR_ENABLEGRP1A
static const uint32_t ADDR_RANGE_SIZE
std::vector< Gicv3::IntTriggerType > irqConfig
static const AddrRange GICD_SPENDSGIR
void activateIRQ(uint32_t int_id)
Gicv3CPUInterface * route(uint32_t int_id)
static const uint32_t GICD_CTLR_ENABLEGRP1
static const AddrRange GICD_ICENABLER
static const AddrRange GICD_IROUTER
static const AddrRange GICD_ICPENDR
bool nsAccessToSecInt(uint32_t int_id, bool is_secure_access) const
std::vector< bool > irqPendingIspendr
bool isLevelSensitive(uint32_t int_id) const
void write(Addr addr, uint64_t data, size_t size, bool is_secure_access)
static const AddrRange GICD_ITARGETSR
void deactivateIRQ(uint32_t int_id)
static const AddrRange GICD_IPRIORITYR
void deassertSPI(uint32_t int_id)
Gicv3::GroupId getIntGroup(int int_id) const
static const uint32_t GICD_CTLR_ENABLEGRP1NS
void clearIrqCpuInterface(uint32_t int_id)
Gicv3Distributor(Gicv3 *gic, uint32_t it_lines)
static const uint32_t GICD_CTLR_ENABLEGRP1S
uint64_t read(Addr addr, size_t size, bool is_secure_access)
static const AddrRange GICD_ISACTIVER
void serialize(CheckpointOut &cp) const override
Serialize an object.
static const uint32_t GICD_CTLR_DS
static const AddrRange GICD_CPENDSGIR
GICv3 ITS module.
Definition gic_v3_its.hh:84
static const int SGI_MAX
Definition gic_v3.hh:119
@ INT_LEVEL_SENSITIVE
Definition gic_v3.hh:142
static const int PPI_MAX
Definition gic_v3.hh:121
Basic support for object serialization.
Definition serialize.hh:170
#define EndBitUnion(name)
This closes off the class and union started by the above macro.
Definition bitunion.hh:428
#define panic(...)
This implements a cprintf based panic() function.
Definition logging.hh:188
Bitfield< 25, 21 > to
Definition types.hh:96
Bitfield< 3 > addr
Definition types.hh:84
Bitfield< 15, 8 > vector
Definition intmessage.hh:48
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
Definition binary32.hh:36
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
Overload hash function for BasicBlockRange type.
Definition binary32.hh:81

Generated on Tue Jun 18 2024 16:24:02 for gem5 by doxygen 1.11.0