gem5  v20.1.0.0
gic_v3_redistributor.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2019-2020 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 
48 class Gicv3CPUInterface;
49 class Gicv3Distributor;
50 class Gicv3Its;
51 
53 {
54  private:
55 
56  friend class Gicv3CPUInterface;
57  friend class Gicv3Distributor;
58  friend class Gicv3Its;
59 
60  protected:
61 
65  uint32_t cpuId;
67 
68  /*
69  * GICv3 defines 2 contiguous 64KB frames for each redistributor.
70  * Order of frames must be RD_base, SGI_base.
71  */
72  static const uint32_t RD_base = 0x0;
73  static const uint32_t SGI_base = 0x10000;
74 
75  enum {
76  // Control Register
77  GICR_CTLR = RD_base + 0x0000,
78  // Implementer Identification Register
79  GICR_IIDR = RD_base + 0x0004,
80  // Type Register
81  GICR_TYPER = RD_base + 0x0008,
82  // Wake Register
83  GICR_WAKER = RD_base + 0x0014,
84  // Peripheral ID0 Register
85  GICR_PIDR0 = RD_base + 0xffe0,
86  // Peripheral ID1 Register
87  GICR_PIDR1 = RD_base + 0xffe4,
88  // Peripheral ID2 Register
89  GICR_PIDR2 = RD_base + 0xffe8,
90  // Peripheral ID3 Register
91  GICR_PIDR3 = RD_base + 0xffec,
92  // Peripheral ID4 Register
93  GICR_PIDR4 = RD_base + 0xffd0,
94  // Peripheral ID5 Register
95  GICR_PIDR5 = RD_base + 0xffd4,
96  // Peripheral ID6 Register
97  GICR_PIDR6 = RD_base + 0xffd8,
98  // Peripheral ID7 Register
99  GICR_PIDR7 = RD_base + 0xffdc,
100  };
101 
102  static const uint32_t GICR_WAKER_ProcessorSleep = 1 << 1;
103  static const uint32_t GICR_WAKER_ChildrenAsleep = 1 << 2;
104 
106 
107  enum {
108  // Interrupt Group Register 0
110  // Interrupt Set-Enable Register 0
112  // Interrupt Clear-Enable Register 0
114  // Interrupt Set-Pending Register 0
116  // Interrupt Clear-Pending Register 0
118  // Interrupt Set-Active Register 0
120  // Interrupt Clear-Active Register 0
122  // SGI Configuration Register
123  GICR_ICFGR0 = SGI_base + 0x0c00,
124  // PPI Configuration Register
125  GICR_ICFGR1 = SGI_base + 0x0c04,
126  // Interrupt Group Modifier Register 0
128  // Non-secure Access Control Register
129  GICR_NSACR = SGI_base + 0x0e00,
130  };
131 
132  // Interrupt Priority Registers
134 
135  // GIC physical LPI Redistributor register
136  enum {
137  // Set LPI Pending Register
138  GICR_SETLPIR = RD_base + 0x0040,
139  // Clear LPI Pending Register
140  GICR_CLRLPIR = RD_base + 0x0048,
141  //Redistributor Properties Base Address Register
143  // Redistributor LPI Pending Table Base Address Register
145  // Redistributor Invalidate LPI Register
146  GICR_INVLPIR = RD_base + 0x00A0,
147  // Redistributor Invalidate All Register
148  GICR_INVALLR = RD_base + 0x00B0,
149  // Redistributor Synchronize Register
150  GICR_SYNCR = RD_base + 0x00C0,
151  };
152 
162 
163  bool DPG1S;
164  bool DPG1NS;
165  bool DPG0;
167 
169  uint8_t lpiIDBits;
171 
172  BitUnion8(LPIConfigurationTableEntry)
173  Bitfield<7, 2> priority;
174  Bitfield<1> res1;
175  Bitfield<0> enable;
176  EndBitUnion(LPIConfigurationTableEntry)
177 
178  static const uint32_t GICR_CTLR_ENABLE_LPIS = 1 << 0;
179  static const uint32_t GICR_CTLR_DPG0 = 1 << 24;
180  static const uint32_t GICR_CTLR_DPG1NS = 1 << 25;
181  static const uint32_t GICR_CTLR_DPG1S = 1 << 26;
182 
183  public:
184 
185  /*
186  * GICv3 defines only 2 64K consecutive frames for the redistributor
187  * (RD_base and SGI_base) but we are using 2 extra 64K stride frames
188  * to match GICv4 that defines 4 64K consecutive frames for them.
189  * Note this must match with DTB/DTS GIC node definition and boot
190  * loader code.
191  */
192  const uint32_t addrRangeSize;
193 
194  static const uint32_t SMALLEST_LPI_ID = 8192;
195 
196 
197  void activateIRQ(uint32_t int_id);
198  bool canBeSelectedFor1toNInterrupt(Gicv3::GroupId group) const;
199  void deactivateIRQ(uint32_t int_id);
200 
201  inline Gicv3CPUInterface *
203  {
204  return cpuInterface;
205  }
206 
207  uint32_t
209  {
210  return cpuId;
211  }
212 
213  Gicv3::GroupId getIntGroup(int int_id) const;
214  Gicv3::IntStatus intStatus(uint32_t int_id) const;
215  uint8_t readEntryLPI(uint32_t intid);
216  void writeEntryLPI(uint32_t intid, uint8_t lpi_entry);
217  bool isPendingLPI(uint32_t intid);
218  void setClrLPI(uint64_t data, bool set);
219  void sendSGI(uint32_t int_id, Gicv3::GroupId group, bool ns);
220  void serialize(CheckpointOut & cp) const override;
221  void unserialize(CheckpointIn & cp) override;
222  void update();
223  void updateDistributor();
224 
225  protected:
226 
227  bool isLevelSensitive(uint32_t int_id) const
228  {
229  return irqConfig[int_id] == Gicv3::INT_LEVEL_SENSITIVE;
230  }
231 
243  bool treatAsEdgeTriggered(uint32_t int_id) const
244  {
245  return !isLevelSensitive(int_id) || irqPendingIspendr[int_id];
246  }
247 
248  public:
249 
250  Gicv3Redistributor(Gicv3 * gic, uint32_t cpu_id);
251  uint32_t getAffinity() const;
252  void init();
253  uint64_t read(Addr addr, size_t size, bool is_secure_access);
254  void sendPPInt(uint32_t int_id);
255  void clearPPInt(uint32_t int_id);
256  void write(Addr addr, uint64_t data, size_t size, bool is_secure_access);
257 };
258 
259 #endif //__DEV_ARM_GICV3_REDISTRIBUTOR_H__
Gicv3Redistributor::gic
Gicv3 * gic
Definition: gic_v3_redistributor.hh:62
Gicv3Redistributor::activateIRQ
void activateIRQ(uint32_t int_id)
Definition: gic_v3_redistributor.cc:995
Gicv3Redistributor::getAffinity
uint32_t getAffinity() const
Definition: gic_v3_redistributor.cc:1010
ArmISA::ns
Bitfield< 0 > ns
Definition: miscregs_types.hh:328
Gicv3Redistributor::irqPendingIspendr
std::vector< bool > irqPendingIspendr
Definition: gic_v3_redistributor.hh:156
Gicv3Redistributor::lpiIDBits
uint8_t lpiIDBits
Definition: gic_v3_redistributor.hh:169
Gicv3Redistributor::GICR_PENDBASER
@ GICR_PENDBASER
Definition: gic_v3_redistributor.hh:144
Gicv3Its::size
Bitfield< 7, 0 > size
Definition: gic_v3_its.hh:180
Gicv3Redistributor::distributor
Gicv3Distributor * distributor
Definition: gic_v3_redistributor.hh:63
data
const char data[]
Definition: circlebuf.test.cc:42
Gicv3Redistributor::GICR_IIDR
@ GICR_IIDR
Definition: gic_v3_redistributor.hh:79
Gicv3Redistributor::GICR_PIDR2
@ GICR_PIDR2
Definition: gic_v3_redistributor.hh:89
serialize.hh
Gicv3Redistributor::GICR_ICPENDR0
@ GICR_ICPENDR0
Definition: gic_v3_redistributor.hh:117
Gicv3Redistributor::GICR_WAKER_ProcessorSleep
static const uint32_t GICR_WAKER_ProcessorSleep
Definition: gic_v3_redistributor.hh:102
Gicv3Redistributor::lpiConfigurationTablePtr
Addr lpiConfigurationTablePtr
Definition: gic_v3_redistributor.hh:168
Gicv3Redistributor::read
uint64_t read(Addr addr, size_t size, bool is_secure_access)
Definition: gic_v3_redistributor.cc:90
Gicv3Redistributor::GICR_PIDR0
@ GICR_PIDR0
Definition: gic_v3_redistributor.hh:85
Gicv3Redistributor::GICR_CTLR_DPG0
static const uint32_t GICR_CTLR_DPG0
Definition: gic_v3_redistributor.hh:179
Serializable
Basic support for object serialization.
Definition: serialize.hh:172
Gicv3Redistributor::writeEntryLPI
void writeEntryLPI(uint32_t intid, uint8_t lpi_entry)
Definition: gic_v3_redistributor.cc:897
Gicv3Redistributor::GICR_ISACTIVER0
@ GICR_ISACTIVER0
Definition: gic_v3_redistributor.hh:119
Gicv3Redistributor::Gicv3Redistributor
Gicv3Redistributor(Gicv3 *gic, uint32_t cpu_id)
Definition: gic_v3_redistributor.cc:53
Gicv3Redistributor::GICR_IGRPMODR0
@ GICR_IGRPMODR0
Definition: gic_v3_redistributor.hh:127
Gicv3Redistributor::irqPending
std::vector< bool > irqPending
Definition: gic_v3_redistributor.hh:155
Gicv3Redistributor::cpuId
uint32_t cpuId
Definition: gic_v3_redistributor.hh:65
std::vector< uint8_t >
Gicv3Redistributor::GICR_CTLR
@ GICR_CTLR
Definition: gic_v3_redistributor.hh:77
Gicv3Redistributor::GICR_SYNCR
@ GICR_SYNCR
Definition: gic_v3_redistributor.hh:150
Gicv3Redistributor::irqActive
std::vector< bool > irqActive
Definition: gic_v3_redistributor.hh:157
Gicv3Redistributor::isPendingLPI
bool isPendingLPI(uint32_t intid)
Definition: gic_v3_redistributor.cc:907
Gicv3Redistributor::GICR_WAKER
@ GICR_WAKER
Definition: gic_v3_redistributor.hh:83
Gicv3Redistributor::isLevelSensitive
bool isLevelSensitive(uint32_t int_id) const
Definition: gic_v3_redistributor.hh:227
Gicv3Redistributor::irqGroup
std::vector< uint8_t > irqGroup
Definition: gic_v3_redistributor.hh:153
Gicv3Redistributor::irqPriority
std::vector< uint8_t > irqPriority
Definition: gic_v3_redistributor.hh:158
Gicv3Redistributor::GICR_CTLR_DPG1S
static const uint32_t GICR_CTLR_DPG1S
Definition: gic_v3_redistributor.hh:181
Gicv3Redistributor::priority
priority
Definition: gic_v3_redistributor.hh:173
Gicv3Redistributor::GICR_ICFGR1
@ GICR_ICFGR1
Definition: gic_v3_redistributor.hh:125
Gicv3Redistributor::EnableLPIs
bool EnableLPIs
Definition: gic_v3_redistributor.hh:166
Gicv3Redistributor::readEntryLPI
uint8_t readEntryLPI(uint32_t intid)
Definition: gic_v3_redistributor.cc:884
Gicv3Redistributor::clearPPInt
void clearPPInt(uint32_t int_id)
Definition: gic_v3_redistributor.cc:724
Gicv3Redistributor::irqConfig
std::vector< Gicv3::IntTriggerType > irqConfig
Definition: gic_v3_redistributor.hh:159
Gicv3Redistributor::getIntGroup
Gicv3::GroupId getIntGroup(int int_id) const
Definition: gic_v3_redistributor.cc:969
Gicv3::INT_LEVEL_SENSITIVE
@ INT_LEVEL_SENSITIVE
Definition: gic_v3.hh:97
cp
Definition: cprintf.cc:40
Gicv3Redistributor::GICR_CTLR_DPG1NS
static const uint32_t GICR_CTLR_DPG1NS
Definition: gic_v3_redistributor.hh:180
AddrRange
The AddrRange class encapsulates an address range, and supports a number of tests to check if two ran...
Definition: addr_range.hh:68
Gicv3Redistributor::irqEnabled
std::vector< bool > irqEnabled
Definition: gic_v3_redistributor.hh:154
Gicv3Redistributor::cpuInterface
Gicv3CPUInterface * cpuInterface
Definition: gic_v3_redistributor.hh:64
Gicv3Redistributor::GICR_INVLPIR
@ GICR_INVLPIR
Definition: gic_v3_redistributor.hh:146
Gicv3Redistributor::peInLowPowerState
bool peInLowPowerState
Definition: gic_v3_redistributor.hh:105
Gicv3Its
GICv3 ITS module.
Definition: gic_v3_its.hh:74
Gicv3Redistributor::GICR_ISPENDR0
@ GICR_ISPENDR0
Definition: gic_v3_redistributor.hh:115
Gicv3Redistributor::GICR_PIDR7
@ GICR_PIDR7
Definition: gic_v3_redistributor.hh:99
Gicv3::IntStatus
IntStatus
Definition: gic_v3.hh:82
Gicv3Redistributor::lpiPendingTablePtr
Addr lpiPendingTablePtr
Definition: gic_v3_redistributor.hh:170
Gicv3Redistributor::GICR_PIDR1
@ GICR_PIDR1
Definition: gic_v3_redistributor.hh:87
Gicv3Redistributor::GICR_PIDR6
@ GICR_PIDR6
Definition: gic_v3_redistributor.hh:97
Gicv3
Definition: gic_v3.hh:53
Gicv3Redistributor::GICR_PIDR4
@ GICR_PIDR4
Definition: gic_v3_redistributor.hh:93
Gicv3Redistributor::GICR_ICACTIVER0
@ GICR_ICACTIVER0
Definition: gic_v3_redistributor.hh:121
Gicv3Redistributor::getCPUInterface
Gicv3CPUInterface * getCPUInterface() const
Definition: gic_v3_redistributor.hh:202
Gicv3::GroupId
GroupId
Definition: gic_v3.hh:90
Gicv3Redistributor::GICR_NSACR
@ GICR_NSACR
Definition: gic_v3_redistributor.hh:129
Addr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:142
Gicv3Redistributor::GICR_TYPER
@ GICR_TYPER
Definition: gic_v3_redistributor.hh:81
Gicv3Redistributor::RD_base
static const uint32_t RD_base
Definition: gic_v3_redistributor.hh:72
Gicv3Redistributor::res1
Bitfield< 1 > res1
Definition: gic_v3_redistributor.hh:174
Gicv3Redistributor::GICR_IGROUPR0
@ GICR_IGROUPR0
Definition: gic_v3_redistributor.hh:109
Gicv3Redistributor::GICR_IPRIORITYR
static const AddrRange GICR_IPRIORITYR
Definition: gic_v3_redistributor.hh:133
addr_range.hh
Gicv3Redistributor::BitUnion8
BitUnion8(LPIConfigurationTableEntry) Bitfield< 7
Gicv3CPUInterface
Definition: gic_v3_cpu_interface.hh:50
Gicv3Redistributor::DPG0
bool DPG0
Definition: gic_v3_redistributor.hh:165
Gicv3Redistributor::GICR_SETLPIR
@ GICR_SETLPIR
Definition: gic_v3_redistributor.hh:138
Gicv3Redistributor::DPG1NS
bool DPG1NS
Definition: gic_v3_redistributor.hh:164
Gicv3Redistributor::GICR_WAKER_ChildrenAsleep
static const uint32_t GICR_WAKER_ChildrenAsleep
Definition: gic_v3_redistributor.hh:103
Gicv3Redistributor::sendSGI
void sendSGI(uint32_t int_id, Gicv3::GroupId group, bool ns)
Definition: gic_v3_redistributor.cc:735
Gicv3Redistributor::GICR_ISENABLER0
@ GICR_ISENABLER0
Definition: gic_v3_redistributor.hh:111
Gicv3Redistributor::GICR_PROPBASER
@ GICR_PROPBASER
Definition: gic_v3_redistributor.hh:142
Gicv3Redistributor::intStatus
Gicv3::IntStatus intStatus(uint32_t int_id) const
Definition: gic_v3_redistributor.cc:773
Gicv3Redistributor::GICR_PIDR5
@ GICR_PIDR5
Definition: gic_v3_redistributor.hh:95
PortProxy
This object is a proxy for a port or other object which implements the functional response protocol,...
Definition: port_proxy.hh:80
Gicv3Redistributor::write
void write(Addr addr, uint64_t data, size_t size, bool is_secure_access)
Definition: gic_v3_redistributor.cc:385
Gicv3Redistributor::serialize
void serialize(CheckpointOut &cp) const override
Serialize an object.
Definition: gic_v3_redistributor.cc:1053
Gicv3Redistributor::GICR_INVALLR
@ GICR_INVALLR
Definition: gic_v3_redistributor.hh:148
Gicv3Redistributor::DPG1S
bool DPG1S
Definition: gic_v3_redistributor.hh:163
Gicv3Redistributor::processorNumber
uint32_t processorNumber() const
Definition: gic_v3_redistributor.hh:208
Gicv3Redistributor::sendPPInt
void sendPPInt(uint32_t int_id)
Definition: gic_v3_redistributor.cc:712
Gicv3Distributor
Definition: gic_v3_distributor.hh:48
addr
ip6_addr_t addr
Definition: inet.hh:423
Gicv3Redistributor::irqGrpmod
std::vector< uint8_t > irqGrpmod
Definition: gic_v3_redistributor.hh:160
Gicv3Redistributor::deactivateIRQ
void deactivateIRQ(uint32_t int_id)
Definition: gic_v3_redistributor.cc:1004
Gicv3Redistributor::update
void update()
Definition: gic_v3_redistributor.cc:801
Gicv3Redistributor::GICR_ICFGR0
@ GICR_ICFGR0
Definition: gic_v3_redistributor.hh:123
Gicv3Redistributor::EndBitUnion
EndBitUnion(LPIConfigurationTableEntry) static const uint32_t GICR_CTLR_ENABLE_LPIS
Gicv3Redistributor::init
void init()
Definition: gic_v3_redistributor.cc:81
CheckpointOut
std::ostream CheckpointOut
Definition: serialize.hh:63
Gicv3Redistributor::enable
Bitfield< 0 > enable
Definition: gic_v3_redistributor.hh:175
Gicv3Redistributor::SMALLEST_LPI_ID
static const uint32_t SMALLEST_LPI_ID
Definition: gic_v3_redistributor.hh:194
Gicv3Redistributor::updateDistributor
void updateDistributor()
Definition: gic_v3_redistributor.cc:791
Gicv3Redistributor::SGI_base
static const uint32_t SGI_base
Definition: gic_v3_redistributor.hh:73
Gicv3Redistributor::treatAsEdgeTriggered
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...
Definition: gic_v3_redistributor.hh:243
Gicv3Redistributor::canBeSelectedFor1toNInterrupt
bool canBeSelectedFor1toNInterrupt(Gicv3::GroupId group) const
Definition: gic_v3_redistributor.cc:1027
Gicv3Redistributor::GICR_CLRLPIR
@ GICR_CLRLPIR
Definition: gic_v3_redistributor.hh:140
CheckpointIn
Definition: serialize.hh:67
Gicv3Redistributor::GICR_PIDR3
@ GICR_PIDR3
Definition: gic_v3_redistributor.hh:91
gic_v3.hh
Gicv3Redistributor
Definition: gic_v3_redistributor.hh:52
Gicv3Redistributor::unserialize
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition: gic_v3_redistributor.cc:1075
Gicv3Redistributor::addrRangeSize
const uint32_t addrRangeSize
Definition: gic_v3_redistributor.hh:192
Gicv3Redistributor::setClrLPI
void setClrLPI(uint64_t data, bool set)
Definition: gic_v3_redistributor.cc:919
Gicv3Redistributor::GICR_ICENABLER0
@ GICR_ICENABLER0
Definition: gic_v3_redistributor.hh:113
Gicv3Redistributor::memProxy
PortProxy * memProxy
Definition: gic_v3_redistributor.hh:66
Gicv3Redistributor::irqNsacr
std::vector< uint8_t > irqNsacr
Definition: gic_v3_redistributor.hh:161

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