gem5 v24.0.0.0
Loading...
Searching...
No Matches
gic_v3_redistributor.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_REDISTRIBUTOR_H__
42#define __DEV_ARM_GICV3_REDISTRIBUTOR_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
51class Gicv3CPUInterface;
52class Gicv3Distributor;
53class Gicv3Its;
54
56{
57 private:
58
59 friend class Gicv3CPUInterface;
60 friend class Gicv3Distributor;
61 friend class Gicv3Its;
62
63 protected:
64
68 uint32_t cpuId;
70
71 /*
72 * GICv3 defines 2 contiguous 64KB frames for each redistributor.
73 * Order of frames must be RD_base, SGI_base.
74 */
75 static const uint32_t RD_base = 0x0;
76 static const uint32_t SGI_base = 0x10000;
77
78 enum
79 {
80 // Control Register
81 GICR_CTLR = RD_base + 0x0000,
82 // Implementer Identification Register
83 GICR_IIDR = RD_base + 0x0004,
84 // Type Register
85 GICR_TYPER = RD_base + 0x0008,
86 // Wake Register
87 GICR_WAKER = RD_base + 0x0014,
88 // Peripheral ID0 Register
89 GICR_PIDR0 = RD_base + 0xffe0,
90 // Peripheral ID1 Register
91 GICR_PIDR1 = RD_base + 0xffe4,
92 // Peripheral ID2 Register
93 GICR_PIDR2 = RD_base + 0xffe8,
94 // Peripheral ID3 Register
95 GICR_PIDR3 = RD_base + 0xffec,
96 // Peripheral ID4 Register
97 GICR_PIDR4 = RD_base + 0xffd0,
98 // Peripheral ID5 Register
99 GICR_PIDR5 = RD_base + 0xffd4,
100 // Peripheral ID6 Register
101 GICR_PIDR6 = RD_base + 0xffd8,
102 // Peripheral ID7 Register
103 GICR_PIDR7 = RD_base + 0xffdc,
104 };
105
106 static const uint32_t GICR_WAKER_ProcessorSleep = 1 << 1;
107 static const uint32_t GICR_WAKER_ChildrenAsleep = 1 << 2;
108
110
111 enum
112 {
113 // Interrupt Group Register 0
115 // Interrupt Set-Enable Register 0
117 // Interrupt Clear-Enable Register 0
119 // Interrupt Set-Pending Register 0
121 // Interrupt Clear-Pending Register 0
123 // Interrupt Set-Active Register 0
125 // Interrupt Clear-Active Register 0
127 // SGI Configuration Register
129 // PPI Configuration Register
131 // Interrupt Group Modifier Register 0
133 // Non-secure Access Control Register
135 };
136
137 // Interrupt Priority Registers
139
140 // GIC physical LPI Redistributor register
141 enum
142 {
143 // Set LPI Pending Register
145 // Clear LPI Pending Register
147 //Redistributor Properties Base Address Register
149 // Redistributor LPI Pending Table Base Address Register
151 // Redistributor Invalidate LPI Register
153 // Redistributor Invalidate All Register
155 // Redistributor Synchronize Register
156 GICR_SYNCR = RD_base + 0x00C0,
157 };
158
159 std::vector <uint8_t> irqGroup;
160 std::vector <bool> irqEnabled;
161 std::vector <bool> irqPending;
162 std::vector <bool> irqPendingIspendr;
163 std::vector <bool> irqActive;
164 std::vector <uint8_t> irqPriority;
165 std::vector <Gicv3::IntTriggerType> irqConfig;
166 std::vector <uint8_t> irqGrpmod;
167 std::vector <uint8_t> irqNsacr;
168
169 bool DPG1S;
170 bool DPG1NS;
171 bool DPG0;
173
175 uint8_t lpiIDBits;
177
178 BitUnion8(LPIConfigurationTableEntry)
179 Bitfield<7, 2> priority;
180 Bitfield<1> res1;
181 Bitfield<0> enable;
182 EndBitUnion(LPIConfigurationTableEntry)
183
184 static const uint32_t GICR_CTLR_ENABLE_LPIS = 1 << 0;
185 static const uint32_t GICR_CTLR_DPG0 = 1 << 24;
186 static const uint32_t GICR_CTLR_DPG1NS = 1 << 25;
187 static const uint32_t GICR_CTLR_DPG1S = 1 << 26;
188
189 public:
190
191 /*
192 * GICv3 defines only 2 64K consecutive frames for the redistributor
193 * (RD_base and SGI_base) but we are using 2 extra 64K stride frames
194 * to match GICv4 that defines 4 64K consecutive frames for them.
195 * Note this must match with DTB/DTS GIC node definition and boot
196 * loader code.
197 */
198 const uint32_t addrRangeSize;
199
200 static const uint32_t SMALLEST_LPI_ID = 8192;
201
202
203 void activateIRQ(uint32_t int_id);
204 bool canBeSelectedFor1toNInterrupt(Gicv3::GroupId group) const;
205 void deactivateIRQ(uint32_t int_id);
206
207 inline Gicv3CPUInterface *
209 {
210 return cpuInterface;
211 }
212
213 uint32_t
215 {
216 return cpuId;
217 }
218
219 Gicv3::GroupId getIntGroup(int int_id) const;
220 Gicv3::IntStatus intStatus(uint32_t int_id) const;
221 uint8_t readEntryLPI(uint32_t intid);
222 void writeEntryLPI(uint32_t intid, uint8_t lpi_entry);
223 bool isPendingLPI(uint32_t intid);
224 void setClrLPI(uint64_t data, bool set);
225 void sendSGI(uint32_t int_id, Gicv3::GroupId group, bool ns);
226 void serialize(CheckpointOut & cp) const override;
227 void unserialize(CheckpointIn & cp) override;
228 void update();
229 void updateDistributor();
230
231 protected:
232
233 bool isLevelSensitive(uint32_t int_id) const
234 {
235 return irqConfig[int_id] == Gicv3::INT_LEVEL_SENSITIVE;
236 }
237
249 bool treatAsEdgeTriggered(uint32_t int_id) const
250 {
251 return !isLevelSensitive(int_id) || irqPendingIspendr[int_id];
252 }
253
254 public:
255
256 Gicv3Redistributor(Gicv3 * gic, uint32_t cpu_id);
257 uint32_t getAffinity() const;
258 void init();
259 uint64_t read(Addr addr, size_t size, bool is_secure_access);
260 void sendPPInt(uint32_t int_id);
261 void clearPPInt(uint32_t int_id);
262 void write(Addr addr, uint64_t data, size_t size, bool is_secure_access);
263
264 void copy(Gicv3Registers *from, Gicv3Registers *to);
265};
266
267} // namespace gem5
268
269#endif //__DEV_ARM_GICV3_REDISTRIBUTOR_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
GICv3 ITS module.
Definition gic_v3_its.hh:84
uint8_t readEntryLPI(uint32_t intid)
static const uint32_t GICR_WAKER_ProcessorSleep
void clearPPInt(uint32_t int_id)
bool isPendingLPI(uint32_t intid)
static const uint32_t GICR_CTLR_DPG1S
std::vector< uint8_t > irqGroup
Gicv3CPUInterface * getCPUInterface() const
std::vector< uint8_t > irqPriority
bool canBeSelectedFor1toNInterrupt(Gicv3::GroupId group) const
void activateIRQ(uint32_t int_id)
Gicv3Redistributor(Gicv3 *gic, uint32_t cpu_id)
static const uint32_t GICR_WAKER_ChildrenAsleep
std::vector< uint8_t > irqNsacr
void writeEntryLPI(uint32_t intid, uint8_t lpi_entry)
void sendPPInt(uint32_t int_id)
bool isLevelSensitive(uint32_t int_id) const
Gicv3::GroupId getIntGroup(int int_id) const
static const uint32_t SGI_base
void serialize(CheckpointOut &cp) const override
Serialize an object.
void copy(Gicv3Registers *from, Gicv3Registers *to)
void deactivateIRQ(uint32_t int_id)
std::vector< Gicv3::IntTriggerType > irqConfig
static const uint32_t SMALLEST_LPI_ID
static const uint32_t GICR_CTLR_DPG1NS
static const uint32_t GICR_CTLR_DPG0
static const uint32_t RD_base
void sendSGI(uint32_t int_id, Gicv3::GroupId group, bool ns)
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...
BitUnion8(LPIConfigurationTableEntry) Bitfield< 7
static const AddrRange GICR_IPRIORITYR
Gicv3::IntStatus intStatus(uint32_t int_id) const
std::vector< uint8_t > irqGrpmod
Gicv3CPUInterface * cpuInterface
uint64_t read(Addr addr, size_t size, bool is_secure_access)
void write(Addr addr, uint64_t data, size_t size, bool is_secure_access)
void unserialize(CheckpointIn &cp) override
Unserialize an object.
void setClrLPI(uint64_t data, bool set)
std::vector< bool > irqPendingIspendr
@ INT_LEVEL_SENSITIVE
Definition gic_v3.hh:142
This object is a proxy for a port or other object which implements the functional response protocol,...
Definition port_proxy.hh:87
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
Bitfield< 0 > ns
Bitfield< 12, 11 > set
Bitfield< 25, 21 > to
Definition types.hh:96
Bitfield< 3 > addr
Definition types.hh:84
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

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