gem5  v20.1.0.0
gic_v3.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2019 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 "dev/arm/base_gic.hh"
46 #include "params/Gicv3.hh"
47 
48 class Gicv3CPUInterface;
49 class Gicv3Distributor;
50 class Gicv3Redistributor;
51 class Gicv3Its;
52 
53 class Gicv3 : public BaseGic
54 {
55  protected:
56  friend class Gicv3CPUInterface;
57  friend class Gicv3Redistributor;
58 
59  typedef Gicv3Params Params;
67  uint64_t redistSize;
68 
69  public:
70 
71  // Special interrupt IDs, as per SPEC 2.2.1 section
72  static const int INTID_SECURE = 1020;
73  static const int INTID_NONSECURE = 1021;
74  static const int INTID_SPURIOUS = 1023;
75 
76  // Number of Software Generated Interrupts
77  static const int SGI_MAX = 16;
78  // Number of Private Peripheral Interrupts
79  static const int PPI_MAX = 16;
80 
81  // Interrupt states for PPIs, SGIs and SPIs, as per SPEC 4.1.2 section
82  typedef enum {
87  } IntStatus;
88 
89  // Interrupt groups, as per SPEC section 4.6
90  typedef enum {
91  G0S,
92  G1S,
94  } GroupId;
95 
96  typedef enum {
100 
101  protected:
102 
103  void clearInt(uint32_t int_id) override;
104  void clearPPInt(uint32_t int_id, uint32_t cpu) override;
105 
106  inline AddrRangeList
107  getAddrRanges() const override
108  {
109  return addrRanges;
110  }
111 
112  void init() override;
113 
114  const Params *
115  params() const
116  {
117  return dynamic_cast<const Params *>(_params);
118  }
119 
120  Tick read(PacketPtr pkt) override;
121  void reset();
122  void sendInt(uint32_t int_id) override;
123  void sendPPInt(uint32_t int_id, uint32_t cpu) override;
124  void serialize(CheckpointOut & cp) const override;
125  void unserialize(CheckpointIn & cp) override;
126  Tick write(PacketPtr pkt) override;
127  bool supportsVersion(GicVersion version) override;
128 
129  public:
130 
131  Gicv3(const Params * p);
132  void deassertInt(uint32_t cpu, ArmISA::InterruptTypes int_type);
133  void deassertAll(uint32_t cpu);
134  bool haveAsserted(uint32_t cpu) const;
135 
136  inline Gicv3CPUInterface *
137  getCPUInterface(int cpu_id) const
138  {
139  assert(cpu_id < cpuInterfaces.size() and cpuInterfaces[cpu_id]);
140  return cpuInterfaces[cpu_id];
141  }
142 
143  inline Gicv3Distributor *
145  {
146  return distributor;
147  }
148 
149  inline Gicv3Redistributor *
150  getRedistributor(ContextID context_id) const
151  {
152  assert(context_id < redistributors.size() and
153  redistributors[context_id]);
154  return redistributors[context_id];
155  }
156 
158  getRedistributorByAffinity(uint32_t affinity) const;
159 
161  getRedistributorByAddr(Addr address) const;
162 
163  void postInt(uint32_t cpu, ArmISA::InterruptTypes int_type);
164 };
165 
166 #endif //__DEV_ARM_GICV3_H__
Gicv3::INT_EDGE_TRIGGERED
@ INT_EDGE_TRIGGERED
Definition: gic_v3.hh:98
Gicv3::reset
void reset()
Gicv3::cpuInterfaces
std::vector< Gicv3CPUInterface * > cpuInterfaces
Definition: gic_v3.hh:62
Gicv3::INTID_SECURE
static const int INTID_SECURE
Definition: gic_v3.hh:72
BaseGic::Params
BaseGicParams Params
Definition: base_gic.hh:65
Gicv3::G1NS
@ G1NS
Definition: gic_v3.hh:93
Gicv3::getRedistributorByAddr
Gicv3Redistributor * getRedistributorByAddr(Addr address) const
Definition: gic_v3.cc:249
Gicv3::PPI_MAX
static const int PPI_MAX
Definition: gic_v3.hh:79
Gicv3::getDistributor
Gicv3Distributor * getDistributor() const
Definition: gic_v3.hh:144
Gicv3::its
Gicv3Its * its
Definition: gic_v3.hh:63
sc_dt::int_type
int64 int_type
Definition: sc_nbdefs.hh:240
ContextID
int ContextID
Globally unique thread context ID.
Definition: types.hh:231
base_gic.hh
Gicv3::SGI_MAX
static const int SGI_MAX
Definition: gic_v3.hh:77
Gicv3::redistSize
uint64_t redistSize
Definition: gic_v3.hh:67
Tick
uint64_t Tick
Tick count type.
Definition: types.hh:63
Gicv3::IntTriggerType
IntTriggerType
Definition: gic_v3.hh:96
std::vector< Gicv3Redistributor * >
Gicv3::clearPPInt
void clearPPInt(uint32_t int_id, uint32_t cpu) override
Definition: gic_v3.cc:196
Gicv3::getRedistributorByAffinity
Gicv3Redistributor * getRedistributorByAffinity(uint32_t affinity) const
Definition: gic_v3.cc:237
Gicv3::params
const Params * params() const
Definition: gic_v3.hh:115
Gicv3::distributor
Gicv3Distributor * distributor
Definition: gic_v3.hh:60
Gicv3::Params
Gicv3Params Params
Definition: gic_v3.hh:59
Gicv3::addrRanges
AddrRangeList addrRanges
Definition: gic_v3.hh:66
Gicv3::INTID_NONSECURE
static const int INTID_NONSECURE
Definition: gic_v3.hh:73
Gicv3::clearInt
void clearInt(uint32_t int_id) override
Clear an interrupt from a device that is connected to the GIC.
Definition: gic_v3.cc:180
Gicv3::G0S
@ G0S
Definition: gic_v3.hh:91
Gicv3::INT_ACTIVE_PENDING
@ INT_ACTIVE_PENDING
Definition: gic_v3.hh:86
Gicv3::getAddrRanges
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:107
Gicv3::INT_LEVEL_SENSITIVE
@ INT_LEVEL_SENSITIVE
Definition: gic_v3.hh:97
cp
Definition: cprintf.cc:40
interrupts.hh
Gicv3::serialize
void serialize(CheckpointOut &cp) const override
Serialize an object.
Definition: gic_v3.cc:265
AddrRange
The AddrRange class encapsulates an address range, and supports a number of tests to check if two ran...
Definition: addr_range.hh:68
Gicv3::INT_ACTIVE
@ INT_ACTIVE
Definition: gic_v3.hh:85
Gicv3Its
GICv3 ITS module.
Definition: gic_v3_its.hh:74
Gicv3::deassertInt
void deassertInt(uint32_t cpu, ArmISA::InterruptTypes int_type)
Definition: gic_v3.cc:219
ArmISA::InterruptTypes
InterruptTypes
Definition: interrupts.hh:57
Gicv3::IntStatus
IntStatus
Definition: gic_v3.hh:82
Gicv3
Definition: gic_v3.hh:53
Gicv3::GroupId
GroupId
Definition: gic_v3.hh:90
Gicv3::sendPPInt
void sendPPInt(uint32_t int_id, uint32_t cpu) override
Interface call for private peripheral interrupts.
Definition: gic_v3.cc:187
Addr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:142
Gicv3::G1S
@ G1S
Definition: gic_v3.hh:92
Gicv3::getRedistributor
Gicv3Redistributor * getRedistributor(ContextID context_id) const
Definition: gic_v3.hh:150
Gicv3::deassertAll
void deassertAll(uint32_t cpu)
Definition: gic_v3.cc:225
Gicv3::Gicv3
Gicv3(const Params *p)
Definition: gic_v3.cc:54
Gicv3CPUInterface
Definition: gic_v3_cpu_interface.hh:50
Gicv3::redistributors
std::vector< Gicv3Redistributor * > redistributors
Definition: gic_v3.hh:61
Gicv3::distRange
AddrRange distRange
Definition: gic_v3.hh:64
Gicv3::postInt
void postInt(uint32_t cpu, ArmISA::InterruptTypes int_type)
Definition: gic_v3.cc:205
BaseGic
Definition: base_gic.hh:62
Gicv3::INTID_SPURIOUS
static const int INTID_SPURIOUS
Definition: gic_v3.hh:74
Gicv3::haveAsserted
bool haveAsserted(uint32_t cpu) const
Definition: gic_v3.cc:231
SimObject::_params
const SimObjectParams * _params
Cached copy of the object parameters.
Definition: sim_object.hh:110
Gicv3::getCPUInterface
Gicv3CPUInterface * getCPUInterface(int cpu_id) const
Definition: gic_v3.hh:137
Packet
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition: packet.hh:257
Gicv3::read
Tick read(PacketPtr pkt) override
Pure virtual function that the device must implement.
Definition: gic_v3.cc:99
Gicv3Distributor
Definition: gic_v3_distributor.hh:48
Gicv3::init
void init() override
init() is called after all C++ SimObjects have been created and all ports are connected.
Definition: gic_v3.cc:60
Gicv3::INT_PENDING
@ INT_PENDING
Definition: gic_v3.hh:84
Gicv3::write
Tick write(PacketPtr pkt) override
Pure virtual function that the device must implement.
Definition: gic_v3.cc:136
CheckpointOut
std::ostream CheckpointOut
Definition: serialize.hh:63
Gicv3::supportsVersion
bool supportsVersion(GicVersion version) override
Check if version supported.
Definition: gic_v3.cc:212
MipsISA::p
Bitfield< 0 > p
Definition: pra_constants.hh:323
Gicv3::unserialize
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition: gic_v3.cc:281
std::list< AddrRange >
Gicv3::redistRange
AddrRange redistRange
Definition: gic_v3.hh:65
CheckpointIn
Definition: serialize.hh:67
BaseGic::GicVersion
GicVersion
Definition: base_gic.hh:66
Gicv3Redistributor
Definition: gic_v3_redistributor.hh:52
Gicv3::sendInt
void sendInt(uint32_t int_id) override
Post an interrupt from a device that is connected to the GIC.
Definition: gic_v3.cc:173
Gicv3::INT_INACTIVE
@ INT_INACTIVE
Definition: gic_v3.hh:83

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