gem5  v22.1.0.0
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 
44 #include "arch/arm/interrupts.hh"
45 #include "arch/arm/types.hh"
46 #include "dev/arm/base_gic.hh"
47 #include "params/Gicv3.hh"
48 
49 namespace gem5
50 {
51 
52 class Gicv3CPUInterface;
53 class Gicv3Distributor;
54 class Gicv3Redistributor;
55 class Gicv3Its;
56 
58 {
59  public:
60  virtual uint32_t readDistributor(Addr daddr) = 0;
61  virtual uint32_t readRedistributor(const ArmISA::Affinity &aff,
62  Addr daddr) = 0;
63  virtual RegVal readCpu(const ArmISA::Affinity &aff,
64  ArmISA::MiscRegIndex misc_reg) = 0;
65 
66  virtual void writeDistributor(Addr daddr, uint32_t data) = 0;
67  virtual void writeRedistributor(const ArmISA::Affinity &aff,
68  Addr daddr, uint32_t data) = 0;
69  virtual void writeCpu(const ArmISA::Affinity &aff,
70  ArmISA::MiscRegIndex misc_reg, RegVal data) = 0;
71 
72  protected:
73  static void copyDistRegister(Gicv3Registers* from,
75  Addr daddr);
76  static void copyRedistRegister(Gicv3Registers* from,
78  const ArmISA::Affinity &aff, Addr daddr);
79  static void copyCpuRegister(Gicv3Registers* from,
81  const ArmISA::Affinity &aff,
82  ArmISA::MiscRegIndex misc_reg);
84  const ArmISA::Affinity &aff, Addr daddr);
85  static void copyRedistRange(Gicv3Registers* from,
87  const ArmISA::Affinity &aff,
88  Addr daddr, size_t size);
89  static void copyDistRange(Gicv3Registers* from,
91  Addr daddr, size_t size);
92  static void clearDistRange(Gicv3Registers* to, Addr daddr, size_t size);
93 };
94 
95 class Gicv3 : public BaseGic, public Gicv3Registers
96 {
97  protected:
98  friend class Gicv3CPUInterface;
99  friend class Gicv3Redistributor;
100  friend class Gicv3Distributor;
101 
109  uint64_t redistSize;
110 
111  public:
112 
113  // Special interrupt IDs, as per SPEC 2.2.1 section
114  static const int INTID_SECURE = 1020;
115  static const int INTID_NONSECURE = 1021;
116  static const int INTID_SPURIOUS = 1023;
117 
118  // Number of Software Generated Interrupts
119  static const int SGI_MAX = 16;
120  // Number of Private Peripheral Interrupts
121  static const int PPI_MAX = 16;
122 
123  // Interrupt states for PPIs, SGIs and SPIs, as per SPEC 4.1.2 section
125  {
130  };
131 
132  // Interrupt groups, as per SPEC section 4.6
133  enum GroupId
134  {
138  };
139 
141  {
144  };
145 
146  protected:
147 
148  void clearInt(uint32_t int_id) override;
149  void clearPPInt(uint32_t int_id, uint32_t cpu) override;
150 
151  inline AddrRangeList
152  getAddrRanges() const override
153  {
154  return addrRanges;
155  }
156 
157  void init() override;
158 
160 
161  Tick read(PacketPtr pkt) override;
162  void reset();
163  void sendInt(uint32_t int_id) override;
164  void sendPPInt(uint32_t int_id, uint32_t cpu) override;
165  void serialize(CheckpointOut & cp) const override;
166  void unserialize(CheckpointIn & cp) override;
167  Tick write(PacketPtr pkt) override;
168  bool supportsVersion(GicVersion version) override;
169 
170  public:
171 
172  Gicv3(const Params &p);
173  void deassertInt(uint32_t cpu, ArmISA::InterruptTypes int_type);
174  void deassertAll(uint32_t cpu);
175  bool haveAsserted(uint32_t cpu) const;
176 
177  inline Gicv3CPUInterface *
178  getCPUInterface(int cpu_id) const
179  {
180  assert(cpu_id < cpuInterfaces.size() and cpuInterfaces[cpu_id]);
181  return cpuInterfaces[cpu_id];
182  }
183 
184  inline Gicv3Distributor *
186  {
187  return distributor;
188  }
189 
190  inline Gicv3Redistributor *
191  getRedistributor(ContextID context_id) const
192  {
193  assert(context_id < redistributors.size() and
194  redistributors[context_id]);
195  return redistributors[context_id];
196  }
197 
199  getCPUInterfaceByAffinity(const ArmISA::Affinity &aff) const;
200 
202  getRedistributorByAffinity(const ArmISA::Affinity &aff) const;
203 
205  getRedistributorByAddr(Addr address) const;
206 
207  void postInt(uint32_t cpu, ArmISA::InterruptTypes int_type);
208 
209  protected: // GIC state transfer
211 
212  public: // Gicv3Registers
213  uint32_t readDistributor(Addr daddr) override;
214  uint32_t readRedistributor(const ArmISA::Affinity &aff,
215  Addr daddr) override;
216  RegVal readCpu(const ArmISA::Affinity &aff,
217  ArmISA::MiscRegIndex misc_reg) override;
218 
219  void writeDistributor(Addr daddr, uint32_t data) override;
220  void writeRedistributor(const ArmISA::Affinity &aff,
221  Addr daddr, uint32_t data) override;
222  void writeCpu(const ArmISA::Affinity &aff,
223  ArmISA::MiscRegIndex misc_reg, RegVal data) override;
224 };
225 
226 } // namespace gem5
227 
228 #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
BaseGicParams Params
Definition: base_gic.hh:75
GICv3 ITS module.
Definition: gic_v3_its.hh:84
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 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:119
void writeRedistributor(const ArmISA::Affinity &aff, Addr daddr, uint32_t data) override
Definition: gic_v3.cc:380
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
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:425
void serialize(CheckpointOut &cp) const override
Serialize an object.
Definition: gic_v3.cc:409
void deassertInt(uint32_t cpu, ArmISA::InterruptTypes int_type)
Definition: gic_v3.cc:297
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:290
uint32_t readRedistributor(const ArmISA::Affinity &aff, Addr daddr) override
Definition: gic_v3.cc:358
void writeCpu(const ArmISA::Affinity &aff, ArmISA::MiscRegIndex misc_reg, RegVal data) override
Definition: gic_v3.cc:388
Gicv3CPUInterface * getCPUInterface(int cpu_id) const
Definition: gic_v3.hh:178
AddrRangeList addrRanges
Definition: gic_v3.hh:108
bool haveAsserted(uint32_t cpu) const
Definition: gic_v3.cc:311
@ INT_LEVEL_SENSITIVE
Definition: gic_v3.hh:142
@ INT_EDGE_TRIGGERED
Definition: gic_v3.hh:143
@ INT_ACTIVE_PENDING
Definition: gic_v3.hh:129
@ INT_ACTIVE
Definition: gic_v3.hh:128
@ INT_PENDING
Definition: gic_v3.hh:127
@ INT_INACTIVE
Definition: gic_v3.hh:126
static const int PPI_MAX
Definition: gic_v3.hh:121
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:152
static const int INTID_NONSECURE
Definition: gic_v3.hh:115
void deassertAll(uint32_t cpu)
Definition: gic_v3.cc:304
Gicv3CPUInterface * getCPUInterfaceByAffinity(const ArmISA::Affinity &aff) const
Definition: gic_v3.cc:318
std::vector< Gicv3CPUInterface * > cpuInterfaces
Definition: gic_v3.hh:104
static const int INTID_SPURIOUS
Definition: gic_v3.hh:116
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:324
Gicv3Redistributor * getRedistributor(ContextID context_id) const
Definition: gic_v3.hh:191
AddrRange redistRange
Definition: gic_v3.hh:107
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:336
static const int INTID_SECURE
Definition: gic_v3.hh:114
uint32_t readDistributor(Addr daddr) override
Definition: gic_v3.cc:352
Gicv3Its * its
Definition: gic_v3.hh:105
void postInt(uint32_t cpu, ArmISA::InterruptTypes int_type)
Definition: gic_v3.cc:282
Gicv3Distributor * getDistributor() const
Definition: gic_v3.hh:185
std::vector< Gicv3Redistributor * > redistributors
Definition: gic_v3.hh:103
void writeDistributor(Addr daddr, uint32_t data) override
Definition: gic_v3.cc:374
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:366
void copyGicState(Gicv3Registers *from, Gicv3Registers *to)
Definition: gic_v3.cc:397
Gicv3Distributor * distributor
Definition: gic_v3.hh:102
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:106
uint64_t redistSize
Definition: gic_v3.hh:109
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition: packet.hh:294
STL vector class.
Definition: stl.hh:37
MiscRegIndex
Definition: misc.hh:64
Bitfield< 25, 21 > to
Definition: types.hh:96
Bitfield< 54 > p
Definition: pagetable.hh:70
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
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
int ContextID
Globally unique thread context ID.
Definition: types.hh:239
uint64_t RegVal
Definition: types.hh:173
int64 int_type
Definition: sc_nbdefs.hh:206

Generated on Wed Dec 21 2022 10:22:32 for gem5 by doxygen 1.9.1