gem5  v20.0.0.2
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
gic_v3_distributor.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_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 
49 {
50  private:
51 
52  friend class Gicv3Redistributor;
53  friend class Gicv3CPUInterface;
54  friend class Gicv3Its;
55 
56  protected:
57 
59  const uint32_t itLines;
60 
61  enum {
62  // Control Register
63  GICD_CTLR = 0x0000,
64  // Interrupt Controller Type Register
65  GICD_TYPER = 0x0004,
66  // Implementer Identification Register
67  GICD_IIDR = 0x0008,
68  // Error Reporting Status Register
69  GICD_STATUSR = 0x0010,
70  // Set Non-secure SPI Pending Register
71  GICD_SETSPI_NSR = 0x0040,
72  // Clear Non-secure SPI Pending Register
73  GICD_CLRSPI_NSR = 0x0048,
74  // Set Secure SPI Pending Register
75  GICD_SETSPI_SR = 0x0050,
76  // Clear Secure SPI Pending Register
77  GICD_CLRSPI_SR = 0x0058,
78  // Software Generated Interrupt Register
79  GICD_SGIR = 0x0f00,
80  // Peripheral ID0 Register
81  GICD_PIDR0 = 0xffe0,
82  // Peripheral ID1 Register
83  GICD_PIDR1 = 0xffe4,
84  // Peripheral ID2 Register
85  GICD_PIDR2 = 0xffe8,
86  // Peripheral ID3 Register
87  GICD_PIDR3 = 0xffec,
88  // Peripheral ID4 Register
89  GICD_PIDR4 = 0xffd0,
90  // Peripheral ID5 Register
91  GICD_PIDR5 = 0xffd4,
92  // Peripheral ID6 Register
93  GICD_PIDR6 = 0xffd8,
94  // Peripheral ID7 Register
95  GICD_PIDR7 = 0xffdc,
96  };
97 
98  // Interrupt Group Registers
99  static const AddrRange GICD_IGROUPR;
100  // Interrupt Set-Enable Registers
101  static const AddrRange GICD_ISENABLER;
102  // Interrupt Clear-Enable Registers
103  static const AddrRange GICD_ICENABLER;
104  // Interrupt Set-Pending Registers
105  static const AddrRange GICD_ISPENDR;
106  // Interrupt Clear-Pending Registers
107  static const AddrRange GICD_ICPENDR;
108  // Interrupt Set-Active Registers
109  static const AddrRange GICD_ISACTIVER;
110  // Interrupt Clear-Active Registers
111  static const AddrRange GICD_ICACTIVER;
112  // Interrupt Priority Registers
114  // Interrupt Processor Targets Registers
115  static const AddrRange GICD_ITARGETSR; // GICv2 legacy
116  // Interrupt Configuration Registers
117  static const AddrRange GICD_ICFGR;
118  // Interrupt Group Modifier Registers
119  static const AddrRange GICD_IGRPMODR;
120  // Non-secure Access Control Registers
121  static const AddrRange GICD_NSACR;
122  // SGI Clear-Pending Registers
123  static const AddrRange GICD_CPENDSGIR; // GICv2 legacy
124  // SGI Set-Pending Registers
125  static const AddrRange GICD_SPENDSGIR; // GICv2 legacy
126  // Interrupt Routing Registers
127  static const AddrRange GICD_IROUTER;
128 
129  BitUnion64(IROUTER)
130  Bitfield<63, 40> res0_1;
131  Bitfield<39, 32> Aff3;
132  Bitfield<31> IRM;
133  Bitfield<30, 24> res0_2;
134  Bitfield<23, 16> Aff2;
135  Bitfield<15, 8> Aff1;
136  Bitfield<7, 0> Aff0;
137  EndBitUnion(IROUTER)
138 
139  static const uint32_t GICD_CTLR_ENABLEGRP0 = 1 << 0;
140  static const uint32_t GICD_CTLR_ENABLEGRP1 = 1 << 0;
141  static const uint32_t GICD_CTLR_ENABLEGRP1NS = 1 << 1;
142  static const uint32_t GICD_CTLR_ENABLEGRP1A = 1 << 1;
143  static const uint32_t GICD_CTLR_ENABLEGRP1S = 1 << 2;
144  static const uint32_t GICD_CTLR_DS = 1 << 6;
145 
146  bool ARE;
147  bool DS;
151  std::vector <uint8_t> irqGroup;
155  std::vector <uint8_t> irqPriority;
156  std::vector <Gicv3::IntTriggerType> irqConfig;
157  std::vector <uint8_t> irqGrpmod;
158  std::vector <uint8_t> irqNsacr;
160 
161  uint32_t gicdTyper;
162  uint32_t gicdPidr0;
163  uint32_t gicdPidr1;
164  uint32_t gicdPidr2;
165  uint32_t gicdPidr3;
166  uint32_t gicdPidr4;
167 
168  public:
169 
170  static const uint32_t ADDR_RANGE_SIZE = 0x10000;
171  static const uint32_t IDBITS = 0xf;
172 
173  protected:
174 
175  void activateIRQ(uint32_t int_id);
176  void deactivateIRQ(uint32_t int_id);
177  void fullUpdate();
178  Gicv3::GroupId getIntGroup(int int_id) const;
179 
180  inline bool
181  groupEnabled(Gicv3::GroupId group) const
182  {
183  if (DS == 0) {
184  switch (group) {
185  case Gicv3::G0S:
186  return EnableGrp0;
187 
188  case Gicv3::G1S:
189  return EnableGrp1S;
190 
191  case Gicv3::G1NS:
192  return EnableGrp1NS;
193 
194  default:
195  panic("Gicv3Distributor::groupEnabled(): "
196  "invalid group!\n");
197  }
198  } else {
199  switch (group) {
200  case Gicv3::G0S:
201  return EnableGrp0;
202 
203  case Gicv3::G1S:
204  case Gicv3::G1NS:
205  return EnableGrp1NS;
206 
207  default:
208  panic("Gicv3Distributor::groupEnabled(): "
209  "invalid group!\n");
210  }
211  }
212  }
213 
214  Gicv3::IntStatus intStatus(uint32_t int_id) const;
215 
216  inline bool isNotSPI(uint32_t int_id) const
217  {
218  if (int_id < (Gicv3::SGI_MAX + Gicv3::PPI_MAX) || int_id >= itLines) {
219  return true;
220  } else {
221  return false;
222  }
223  }
224 
225  inline bool nsAccessToSecInt(uint32_t int_id, bool is_secure_access) const
226  {
227  return !DS && !is_secure_access && getIntGroup(int_id) != Gicv3::G1NS;
228  }
229 
230  void serialize(CheckpointOut & cp) const override;
231  void unserialize(CheckpointIn & cp) override;
232  void update();
233  Gicv3CPUInterface* route(uint32_t int_id);
234 
235  public:
236 
237  Gicv3Distributor(Gicv3 * gic, uint32_t it_lines);
238 
239  void deassertSPI(uint32_t int_id);
240  void clearIrqCpuInterface(uint32_t int_id);
241  void init();
242  uint64_t read(Addr addr, size_t size, bool is_secure_access);
243  void sendInt(uint32_t int_id);
244  void write(Addr addr, uint64_t data, size_t size,
245  bool is_secure_access);
246 };
247 
248 #endif //__DEV_ARM_GICV3_DISTRIBUTOR_H__
#define panic(...)
This implements a cprintf based panic() function.
Definition: logging.hh:163
static const AddrRange GICD_SPENDSGIR
static const int PPI_MAX
Definition: gic_v3.hh:78
Definition: gic_v3.hh:52
std::vector< uint8_t > irqGrpmod
Bitfield< 7, 0 > size
Definition: gic_v3_its.hh:180
static const AddrRange GICD_ISENABLER
ip6_addr_t addr
Definition: inet.hh:330
uint64_t read(Addr addr, size_t size, bool is_secure_access)
std::vector< uint8_t > irqPriority
bool nsAccessToSecInt(uint32_t int_id, bool is_secure_access) const
Bitfield< 39, 32 > Aff3
Overload hash function for BasicBlockRange type.
Definition: vec_reg.hh:587
Bitfield< 23, 16 > Aff2
std::vector< uint8_t > irqNsacr
void write(Addr addr, uint64_t data, size_t size, bool is_secure_access)
Definition: cprintf.cc:40
std::vector< IROUTER > irqAffinityRouting
void sendInt(uint32_t int_id)
Bitfield< 15, 8 > Aff1
static const AddrRange GICD_CPENDSGIR
static const AddrRange GICD_IGROUPR
static const AddrRange GICD_ITARGETSR
void deassertSPI(uint32_t int_id)
void clearIrqCpuInterface(uint32_t int_id)
static const int SGI_MAX
Definition: gic_v3.hh:76
static const uint32_t GICD_CTLR_ENABLEGRP1
static const AddrRange GICD_ICENABLER
BitUnion64(IROUTER) Bitfield< 63
Bitfield< 7, 0 > Aff0
The AddrRange class encapsulates an address range, and supports a number of tests to check if two ran...
Definition: addr_range.hh:68
static const AddrRange GICD_ICFGR
static const AddrRange GICD_ISACTIVER
EndBitUnion(IROUTER) static const uint32_t GICD_CTLR_ENABLEGRP0
static const uint32_t IDBITS
static const AddrRange GICD_ISPENDR
std::vector< bool > irqPending
bool isNotSPI(uint32_t int_id) const
static const uint32_t ADDR_RANGE_SIZE
Gicv3Distributor(Gicv3 *gic, uint32_t it_lines)
void activateIRQ(uint32_t int_id)
std::vector< bool > irqEnabled
static const AddrRange GICD_ICACTIVER
const uint32_t itLines
void unserialize(CheckpointIn &cp) override
Unserialize an object.
static const AddrRange GICD_NSACR
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:140
Gicv3::IntStatus intStatus(uint32_t int_id) const
Bitfield< 15, 8 > vector
Definition: intmessage.hh:44
Basic support for object serialization.
Definition: serialize.hh:166
std::vector< bool > irqActive
IntStatus
Definition: gic_v3.hh:81
Gicv3::GroupId getIntGroup(int int_id) const
std::ostream CheckpointOut
Definition: serialize.hh:63
static const AddrRange GICD_IPRIORITYR
static const uint32_t GICD_CTLR_ENABLEGRP1S
Gicv3CPUInterface * route(uint32_t int_id)
std::vector< Gicv3::IntTriggerType > irqConfig
static const uint32_t GICD_CTLR_ENABLEGRP1NS
static const uint32_t GICD_CTLR_DS
bool groupEnabled(Gicv3::GroupId group) const
void serialize(CheckpointOut &cp) const override
Serialize an object.
const char data[]
Bitfield< 30, 24 > res0_2
static const AddrRange GICD_IGRPMODR
static const uint32_t GICD_CTLR_ENABLEGRP1A
static const AddrRange GICD_IROUTER
static const AddrRange GICD_ICPENDR
std::vector< uint8_t > irqGroup
void deactivateIRQ(uint32_t int_id)
GICv3 ITS module.
Definition: gic_v3_its.hh:74

Generated on Mon Jun 8 2020 15:45:09 for gem5 by doxygen 1.8.13