gem5  v20.0.0.2
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
gic_v3_redistributor.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_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
109  GICR_IGROUPR0 = SGI_base + 0x0080,
110  // Interrupt Set-Enable Register 0
111  GICR_ISENABLER0 = SGI_base + 0x0100,
112  // Interrupt Clear-Enable Register 0
113  GICR_ICENABLER0 = SGI_base + 0x0180,
114  // Interrupt Set-Pending Register 0
115  GICR_ISPENDR0 = SGI_base + 0x0200,
116  // Interrupt Clear-Pending Register 0
117  GICR_ICPENDR0 = SGI_base + 0x0280,
118  // Interrupt Set-Active Register 0
119  GICR_ISACTIVER0 = SGI_base + 0x0300,
120  // Interrupt Clear-Active Register 0
121  GICR_ICACTIVER0 = SGI_base + 0x0380,
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
127  GICR_IGRPMODR0 = SGI_base + 0x0d00,
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
142  GICR_PROPBASER = RD_base + 0x0070,
143  // Redistributor LPI Pending Table Base Address Register
144  GICR_PENDBASER = RD_base + 0x0078,
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 
161 
162  bool DPG1S;
163  bool DPG1NS;
164  bool DPG0;
166 
168  uint8_t lpiIDBits;
170 
171  BitUnion8(LPIConfigurationTableEntry)
172  Bitfield<7, 2> priority;
173  Bitfield<1> res1;
174  Bitfield<0> enable;
175  EndBitUnion(LPIConfigurationTableEntry)
176 
177  static const uint32_t GICR_CTLR_ENABLE_LPIS = 1 << 0;
178  static const uint32_t GICR_CTLR_DPG0 = 1 << 24;
179  static const uint32_t GICR_CTLR_DPG1NS = 1 << 25;
180  static const uint32_t GICR_CTLR_DPG1S = 1 << 26;
181 
182  public:
183 
184  /*
185  * GICv3 defines only 2 64K consecutive frames for the redistributor
186  * (RD_base and SGI_base) but we are using 2 extra 64K stride frames
187  * to match GICv4 that defines 4 64K consecutive frames for them.
188  * Note this must match with DTB/DTS GIC node definition and boot
189  * loader code.
190  */
191  const uint32_t addrRangeSize;
192 
193  static const uint32_t SMALLEST_LPI_ID = 8192;
194 
195 
196  void activateIRQ(uint32_t int_id);
197  bool canBeSelectedFor1toNInterrupt(Gicv3::GroupId group) const;
198  void deactivateIRQ(uint32_t int_id);
199 
200  inline Gicv3CPUInterface *
202  {
203  return cpuInterface;
204  }
205 
206  uint32_t
208  {
209  return cpuId;
210  }
211 
212  Gicv3::GroupId getIntGroup(int int_id) const;
213  Gicv3::IntStatus intStatus(uint32_t int_id) const;
214  uint8_t readEntryLPI(uint32_t intid);
215  void writeEntryLPI(uint32_t intid, uint8_t lpi_entry);
216  bool isPendingLPI(uint32_t intid);
217  void setClrLPI(uint64_t data, bool set);
218  void sendSGI(uint32_t int_id, Gicv3::GroupId group, bool ns);
219  void serialize(CheckpointOut & cp) const override;
220  void unserialize(CheckpointIn & cp) override;
221  void update();
222  void updateDistributor();
223 
224  public:
225 
226  Gicv3Redistributor(Gicv3 * gic, uint32_t cpu_id);
227  uint32_t getAffinity() const;
228  void init();
229  uint64_t read(Addr addr, size_t size, bool is_secure_access);
230  void sendPPInt(uint32_t int_id);
231  void write(Addr addr, uint64_t data, size_t size, bool is_secure_access);
232 };
233 
234 #endif //__DEV_ARM_GICV3_REDISTRIBUTOR_H__
uint8_t readEntryLPI(uint32_t intid)
void deactivateIRQ(uint32_t int_id)
static const uint32_t GICR_CTLR_DPG0
Definition: gic_v3.hh:52
bool isPendingLPI(uint32_t intid)
static const uint32_t RD_base
static const AddrRange GICR_IPRIORITYR
static const uint32_t SGI_base
Bitfield< 7, 0 > size
Definition: gic_v3_its.hh:180
ip6_addr_t addr
Definition: inet.hh:330
Gicv3CPUInterface * cpuInterface
void serialize(CheckpointOut &cp) const override
Serialize an object.
std::vector< Gicv3::IntTriggerType > irqConfig
std::vector< uint8_t > irqPriority
Definition: cprintf.cc:40
bool canBeSelectedFor1toNInterrupt(Gicv3::GroupId group) const
std::vector< bool > irqEnabled
std::vector< bool > irqPending
The AddrRange class encapsulates an address range, and supports a number of tests to check if two ran...
Definition: addr_range.hh:68
Bitfield< 0 > ns
void sendPPInt(uint32_t int_id)
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Gicv3CPUInterface * getCPUInterface() const
void writeEntryLPI(uint32_t intid, uint8_t lpi_entry)
std::vector< bool > irqActive
std::vector< uint8_t > irqGroup
void activateIRQ(uint32_t int_id)
static const uint32_t GICR_WAKER_ChildrenAsleep
void setClrLPI(uint64_t data, bool set)
GroupId
Definition: gic_v3.hh:89
BitUnion8(LPIConfigurationTableEntry) Bitfield< 7
Gicv3::IntStatus intStatus(uint32_t int_id) const
const uint32_t addrRangeSize
void write(Addr addr, uint64_t data, size_t size, bool is_secure_access)
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:140
Gicv3Distributor * distributor
uint32_t processorNumber() const
Basic support for object serialization.
Definition: serialize.hh:166
std::vector< uint8_t > irqGrpmod
This object is a proxy for a port or other object which implements the functional response protocol...
Definition: port_proxy.hh:80
static const uint32_t SMALLEST_LPI_ID
IntStatus
Definition: gic_v3.hh:81
static const uint32_t GICR_CTLR_DPG1S
std::ostream CheckpointOut
Definition: serialize.hh:63
std::vector< uint8_t > irqNsacr
static const uint32_t GICR_WAKER_ProcessorSleep
uint32_t getAffinity() const
Gicv3::GroupId getIntGroup(int int_id) const
static const uint32_t GICR_CTLR_DPG1NS
const char data[]
void sendSGI(uint32_t int_id, Gicv3::GroupId group, bool ns)
EndBitUnion(LPIConfigurationTableEntry) static const uint32_t GICR_CTLR_ENABLE_LPIS
GICv3 ITS module.
Definition: gic_v3_its.hh:74
uint64_t read(Addr addr, size_t size, bool is_secure_access)
Gicv3Redistributor(Gicv3 *gic, uint32_t cpu_id)

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