gem5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
gic_pl390.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2010, 2013, 2015-2017 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) 2005 The Regents of The University of Michigan
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  * Authors: Ali Saidi
41  */
42 
43 
48 #ifndef __DEV_ARM_GIC_PL390_H__
49 #define __DEV_ARM_GIC_PL390_H__
50 
51 #include <vector>
52 
53 #include "base/addr_range.hh"
54 #include "base/bitunion.hh"
55 #include "cpu/intr_control.hh"
56 #include "dev/arm/base_gic.hh"
57 #include "dev/io_device.hh"
58 #include "dev/platform.hh"
59 #include "params/Pl390.hh"
60 
61 class Pl390 : public BaseGic, public BaseGicRegisters
62 {
63  protected:
64  // distributor memory addresses
65  enum {
66  GICD_CTLR = 0x000, // control register
67  GICD_TYPER = 0x004, // controller type
68  GICD_IIDR = 0x008, // implementer id
69  GICD_SGIR = 0xf00, // software generated interrupt
70 
71  DIST_SIZE = 0xfff
72  };
73 
74  static const AddrRange GICD_IGROUPR; // interrupt group (unimplemented)
75  static const AddrRange GICD_ISENABLER; // interrupt set enable
76  static const AddrRange GICD_ICENABLER; // interrupt clear enable
77  static const AddrRange GICD_ISPENDR; // set pending interrupt
78  static const AddrRange GICD_ICPENDR; // clear pending interrupt
79  static const AddrRange GICD_ISACTIVER; // active bit registers
80  static const AddrRange GICD_ICACTIVER; // clear bit registers
81  static const AddrRange GICD_IPRIORITYR; // interrupt priority registers
82  static const AddrRange GICD_ITARGETSR; // processor target registers
83  static const AddrRange GICD_ICFGR; // interrupt config registers
84 
85  // cpu memory addresses
86  enum {
87  GICC_CTLR = 0x00, // CPU control register
88  GICC_PMR = 0x04, // Interrupt priority mask
89  GICC_BPR = 0x08, // binary point register
90  GICC_IAR = 0x0C, // interrupt ack register
91  GICC_EOIR = 0x10, // end of interrupt
92  GICC_RPR = 0x14, // running priority
93  GICC_HPPIR = 0x18, // highest pending interrupt
94  GICC_ABPR = 0x1c, // aliased binary point
95  GICC_IIDR = 0xfc, // cpu interface id register
96 
97  CPU_SIZE = 0xff
98  };
99 
100  static const int SGI_MAX = 16; // Number of Software Gen Interrupts
101  static const int PPI_MAX = 16; // Number of Private Peripheral Interrupts
102 
104  static const int SGI_MASK = 0xFFFF0000;
105 
107  static const int NN_CONFIG_MASK = 0x55555555;
108 
109  static const int CPU_MAX = 256; // Max number of supported CPU interfaces
110  static const int SPURIOUS_INT = 1023;
111  static const int INT_BITS_MAX = 32;
112  static const int INT_LINES_MAX = 1020;
114 
117  static const int GICC_BPR_MINIMUM = 2;
118 
119  BitUnion32(SWI)
120  Bitfield<3,0> sgi_id;
121  Bitfield<23,16> cpu_list;
122  Bitfield<25,24> list_type;
123  EndBitUnion(SWI)
124 
125  BitUnion32(IAR)
126  Bitfield<9,0> ack_id;
127  Bitfield<12,10> cpu_id;
129 
130  protected: /* Params */
132  const AddrRange distRange;
133 
135  const AddrRange cpuRange;
136 
139 
142 
145 
148 
149  protected:
151  bool enabled;
152 
154  const bool haveGem5Extensions;
155 
158 
160  uint32_t itLines;
161 
163  struct BankedRegs : public Serializable {
166  uint32_t intEnabled;
167 
170  uint32_t pendingInt;
171 
174  uint32_t activeInt;
175 
179 
180  void serialize(CheckpointOut &cp) const override;
181  void unserialize(CheckpointIn &cp) override;
182 
184  intEnabled(0), pendingInt(0), activeInt(0), intPriority {0}
185  {}
186  };
188 
190 
195 
196  uint32_t& getIntEnabled(ContextID ctx, uint32_t ix) {
197  if (ix == 0) {
198  return getBankedRegs(ctx).intEnabled;
199  } else {
200  return intEnabled[ix - 1];
201  }
202  }
203 
208 
209  uint32_t& getPendingInt(ContextID ctx, uint32_t ix) {
210  assert(ix < INT_BITS_MAX);
211  if (ix == 0) {
212  return getBankedRegs(ctx).pendingInt;
213  } else {
214  return pendingInt[ix - 1];
215  }
216  }
217 
221  uint32_t activeInt[INT_BITS_MAX-1];
222 
223  uint32_t& getActiveInt(ContextID ctx, uint32_t ix) {
224  assert(ix < INT_BITS_MAX);
225  if (ix == 0) {
226  return getBankedRegs(ctx).activeInt;
227  } else {
228  return activeInt[ix - 1];
229  }
230  }
231 
233  uint32_t iccrpr[CPU_MAX];
234 
240 
241  uint8_t& getIntPriority(ContextID ctx, uint32_t ix) {
242  assert(ix < INT_LINES_MAX);
243  if (ix < SGI_MAX + PPI_MAX) {
244  return getBankedRegs(ctx).intPriority[ix];
245  } else {
246  return intPriority[ix - (SGI_MAX + PPI_MAX)];
247  }
248  }
249 
254 
255  uint8_t getCpuTarget(ContextID ctx, uint32_t ix) {
256  assert(ctx < sys->numRunningContexts());
257  assert(ix < INT_LINES_MAX);
258  if (ix < SGI_MAX + PPI_MAX) {
259  // "GICD_ITARGETSR0 to GICD_ITARGETSR7 are read-only, and each
260  // field returns a value that corresponds only to the processor
261  // reading the register."
262  uint32_t ctx_mask;
263  if (gem5ExtensionsEnabled) {
264  ctx_mask = ctx;
265  } else {
266  // convert the CPU id number into a bit mask
267  ctx_mask = power(2, ctx);
268  }
269  return ctx_mask;
270  } else {
271  return cpuTarget[ix - 32];
272  }
273  }
274 
277  uint32_t intConfig[INT_BITS_MAX*2];
278 
281 
284  uint8_t getCpuPriority(unsigned cpu); // BPR-adjusted priority value
285 
287  uint8_t cpuBpr[CPU_MAX];
288 
291 
298 
304 
309 
311  bool irqEnable;
312 
316  void softInt(ContextID ctx, SWI swi);
317 
321  void updateIntState(int hint);
322 
325  void updateRunPri();
326 
328  uint64_t genSwiMask(int cpu);
329 
330  int intNumToWord(int num) const { return num >> 5; }
331  int intNumToBit(int num) const { return num % 32; }
332 
336  void postInt(uint32_t cpu, Tick when);
337 
341  void postDelayedInt(uint32_t cpu);
342 
345  class PostIntEvent : public Event
346  {
347  private:
349  uint32_t cpu;
350  public:
351  PostIntEvent(Pl390 &_parent, uint32_t _cpu)
352  : parent(_parent), cpu(_cpu)
353  { }
355  const char *description() const { return "Post Interrupt to CPU"; }
356  };
359 
360  public:
361  typedef Pl390Params Params;
362  const Params *
363  params() const
364  {
365  return dynamic_cast<const Params *>(_params);
366  }
367  Pl390(const Params *p);
368 
369  DrainState drain() override;
370 
371  void serialize(CheckpointOut &cp) const override;
372  void unserialize(CheckpointIn &cp) override;
373 
374  public: /* PioDevice */
375  AddrRangeList getAddrRanges() const override { return addrRanges; }
376 
380  Tick read(PacketPtr pkt) override;
381 
385  Tick write(PacketPtr pkt) override;
386 
387  public: /* BaseGic */
388  void sendInt(uint32_t number) override;
389  void clearInt(uint32_t number) override;
390 
391  void sendPPInt(uint32_t num, uint32_t cpu) override;
392  void clearPPInt(uint32_t num, uint32_t cpu) override;
393 
394  public: // Test & debug intefaces
396  /* Various functions fer testing and debugging */
397  void driveSPI(uint32_t spi);
398  void driveLegIRQ(bool state);
399  void driveLegFIQ(bool state);
400  void driveIrqEn(bool state);
403  protected:
408  uint32_t readDistributor(ContextID ctx, Addr daddr,
409  size_t resp_sz);
410  uint32_t readDistributor(ContextID ctx, Addr daddr) override {
411  return readDistributor(ctx, daddr, 4);
412  }
413 
417  Tick readCpu(PacketPtr pkt);
418  uint32_t readCpu(ContextID ctx, Addr daddr) override;
419 
424  void writeDistributor(ContextID ctx, Addr daddr,
425  uint32_t data, size_t data_sz);
426  void writeDistributor(ContextID ctx, Addr daddr,
427  uint32_t data) override {
428  return writeDistributor(ctx, daddr, data, 4);
429  }
430 
434  Tick writeCpu(PacketPtr pkt);
435  void writeCpu(ContextID ctx, Addr daddr, uint32_t data) override;
436 };
437 
438 #endif //__DEV_ARM_GIC_H__
Tick write(PacketPtr pkt) override
A PIO read to the device, immediately split up into writeDistributor() or writeCpu() ...
Definition: gic_pl390.cc:113
uint32_t iccrpr[CPU_MAX]
read only running priority register, 1 per cpu
Definition: gic_pl390.hh:233
void clearInt(uint32_t number) override
Clear an interrupt from a device that is connected to the GIC.
Definition: gic_pl390.cc:825
AddrRangeList getAddrRanges() const override
Every PIO device is obliged to provide an implementation that returns the address ranges the device r...
Definition: gic_pl390.hh:375
uint8_t & getIntPriority(ContextID ctx, uint32_t ix)
Definition: gic_pl390.hh:241
std::vector< BankedRegs * > bankedRegs
Definition: gic_pl390.hh:187
DrainState
Object drain/handover states.
Definition: drain.hh:71
uint32_t intEnabled[INT_BITS_MAX-1]
GICD_I{S,C}ENABLER{1..31} interrupt enable bits for global interrupts 1b per interrupt, 32 bits per word, 31 words.
Definition: gic_pl390.hh:194
static const AddrRange GICD_ITARGETSR
Definition: gic_pl390.hh:82
void serialize(CheckpointOut &cp) const override
Serialize an object.
Definition: gic_pl390.cc:869
Bitfield< 25, 24 > list_type
Definition: gic_pl390.hh:122
uint32_t itLines
Number of itLines enabled.
Definition: gic_pl390.hh:160
const char * description() const
Return a C string describing the event.
Definition: gic_pl390.hh:355
EndBitUnion(IAR) protected const AddrRange cpuRange
Address range for the distributor interface.
Definition: gic_pl390.hh:128
uint8_t getCpuPriority(unsigned cpu)
Definition: gic_pl390.cc:683
Tick writeCpu(PacketPtr pkt)
Handle a write to the cpu portion of the GIC.
Definition: gic_pl390.cc:523
bool gem5ExtensionsEnabled
gem5 many-core extension enabled by driver
Definition: gic_pl390.hh:157
Pl390Params Params
Definition: gic_pl390.hh:361
static const AddrRange GICD_ISACTIVER
Definition: gic_pl390.hh:79
static const int SPURIOUS_INT
Definition: gic_pl390.hh:110
static const int INT_BITS_MAX
Definition: gic_pl390.hh:111
Bitfield< 23, 16 > cpu_list
Definition: gic_pl390.hh:121
uint32_t pendingInt
GICD_I{S,C}PENDR0 interrupt pending bits for first 32 interrupts, 1b per interrupt.
Definition: gic_pl390.hh:170
const Tick intLatency
Latency for a interrupt to get to CPU.
Definition: gic_pl390.hh:147
static const int CPU_MAX
Definition: gic_pl390.hh:109
EndBitUnion(SWI) BitUnion32(IAR) Bitfield<9
uint32_t readDistributor(ContextID ctx, Addr daddr) override
Definition: gic_pl390.hh:410
Tick read(PacketPtr pkt) override
A PIO read to the device, immediately split up into readDistributor() or readCpu() ...
Definition: gic_pl390.cc:99
static const AddrRange GICD_ISENABLER
Definition: gic_pl390.hh:75
static const AddrRange GICD_ISPENDR
Definition: gic_pl390.hh:77
const Tick distPioDelay
Latency for a distributor operation.
Definition: gic_pl390.hh:141
static const AddrRange GICD_ICACTIVER
Definition: gic_pl390.hh:80
void clearPPInt(uint32_t num, uint32_t cpu) override
Definition: gic_pl390.cc:831
const bool haveGem5Extensions
Are gem5 extensions available?
Definition: gic_pl390.hh:154
PostIntEvent(Pl390 &_parent, uint32_t _cpu)
Definition: gic_pl390.hh:351
STL vector class.
Definition: stl.hh:40
uint32_t & getIntEnabled(ContextID ctx, uint32_t ix)
Definition: gic_pl390.hh:196
const char data[]
Definition: circlebuf.cc:43
int intNumToBit(int num) const
Definition: gic_pl390.hh:331
uint32_t activeInt
GICD_I{S,C}ACTIVER0 interrupt active bits for first 32 interrupts, 1b per interrupt.
Definition: gic_pl390.hh:174
uint32_t intEnabled
GICD_I{S,C}ENABLER0 interrupt enable bits for first 32 interrupts, 1b per interrupt.
Definition: gic_pl390.hh:166
void updateRunPri()
Update the register that records priority of the highest priority active interrupt.
Definition: gic_pl390.cc:773
The AddrRange class encapsulates an address range, and supports a number of tests to check if two ran...
Definition: addr_range.hh:72
uint32_t cpuPpiPending[CPU_MAX]
One bit per private peripheral interrupt.
Definition: gic_pl390.hh:307
static const int NN_CONFIG_MASK
Mask for bits that config N:N mode in GICD_ICFGR's.
Definition: gic_pl390.hh:107
uint32_t cpuHighestInt[CPU_MAX]
highest interrupt that is interrupting CPU
Definition: gic_pl390.hh:290
uint32_t & getPendingInt(ContextID ctx, uint32_t ix)
Definition: gic_pl390.hh:209
BitUnion32(SWI) Bitfield<3
void driveLegFIQ(bool state)
Definition: gic_pl390.cc:1007
uint8_t cpuTarget[GLOBAL_INT_LINES]
GICD_ITARGETSR{8..255} an 8 bit cpu target id for each global interrupt.
Definition: gic_pl390.hh:253
void driveLegIRQ(bool state)
Definition: gic_pl390.cc:995
bool enabled
Gic enabled.
Definition: gic_pl390.hh:151
void sendInt(uint32_t number) override
Post an interrupt from a device that is connected to the GIC.
Definition: gic_pl390.cc:802
uint64_t Tick
Tick count type.
Definition: types.hh:63
uint64_t power(uint32_t n, uint32_t e)
Definition: intmath.hh:79
uint32_t pendingInt[INT_BITS_MAX-1]
GICD_I{S,C}PENDR{1..31} interrupt pending bits for global interrupts 1b per interrupt, 32 bits per word, 31 words.
Definition: gic_pl390.hh:207
uint32_t cpuSgiActiveExt[CPU_MAX]
Definition: gic_pl390.hh:303
uint32_t cpuSgiPendingExt[CPU_MAX]
SGI pending arrays for gem5 GIC extension mode, which instead keeps 16 SGI pending bits for each of t...
Definition: gic_pl390.hh:302
void driveSPI(uint32_t spi)
Definition: gic_pl390.cc:977
Event definition to post interrupt to CPU after a delay.
Definition: gic_pl390.hh:345
void writeDistributor(ContextID ctx, Addr daddr, uint32_t data) override
Definition: gic_pl390.hh:426
static const AddrRange GICD_ICPENDR
Definition: gic_pl390.hh:78
uint8_t getCpuTarget(ContextID ctx, uint32_t ix)
Definition: gic_pl390.hh:255
uint8_t intPriority[GLOBAL_INT_LINES]
GICD_IPRIORITYR{8..255} an 8 bit priority (lower is higher priority) for each of the global (not repl...
Definition: gic_pl390.hh:239
STL list class.
Definition: stl.hh:54
Registers "banked for each connected processor" per ARM IHI0048B.
Definition: gic_pl390.hh:163
uint32_t cpuPpiActive[CPU_MAX]
Definition: gic_pl390.hh:308
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:142
uint8_t cpuBpr[CPU_MAX]
Binary point registers.
Definition: gic_pl390.hh:287
struct BaseGicParams Params
Definition: base_gic.hh:54
DrainState drain() override
Notify an object that it needs to drain its state.
Definition: gic_pl390.cc:859
A Packet is used to encapsulate a transfer between two objects in the memory system (e...
Definition: packet.hh:245
bool cpuEnabled[CPU_MAX]
CPU enabled.
Definition: gic_pl390.hh:280
Basic support for object serialization.
Definition: serialize.hh:220
void postInt(uint32_t cpu, Tick when)
Post an interrupt to a CPU with a delay.
Definition: gic_pl390.cc:840
const Params * params() const
Definition: gic_pl390.hh:363
uint8_t cpuPriority[CPU_MAX]
CPU priority.
Definition: gic_pl390.hh:283
Pl390(const Params *p)
Definition: gic_pl390.cc:66
static const int INT_LINES_MAX
Definition: gic_pl390.hh:112
uint32_t & getActiveInt(ContextID ctx, uint32_t ix)
Definition: gic_pl390.hh:223
int intNumToWord(int num) const
Definition: gic_pl390.hh:330
uint32_t intConfig[INT_BITS_MAX *2]
2 bit per interrupt signaling if it's level or edge sensitive and if it is 1:N or N:N ...
Definition: gic_pl390.hh:277
static const int SGI_MASK
Mask off SGI's when setting/clearing pending bits.
Definition: gic_pl390.hh:104
Generic interface for platforms.
Base class for ARM GIC implementations.
std::ostream CheckpointOut
Definition: serialize.hh:67
uint64_t cpuSgiPending[SGI_MAX]
One bit per cpu per software interrupt that is pending for each possible sgi source.
Definition: gic_pl390.hh:296
static const AddrRange GICD_ICFGR
Definition: gic_pl390.hh:83
Bitfield< 12, 10 > cpu_id
Definition: gic_pl390.hh:127
uint8_t intPriority[SGI_MAX+PPI_MAX]
GICD_IPRIORITYR{0..7} interrupt priority for SGIs and PPIs.
Definition: gic_pl390.hh:178
Definition: eventq.hh:185
uint32_t activeInt[INT_BITS_MAX-1]
GICD_I{S,C}ACTIVER{1..31} interrupt active bits for global interrupts 1b per interrupt, 32 bits per word, 31 words.
Definition: gic_pl390.hh:221
Tick writeDistributor(PacketPtr pkt)
Handle a write to the distributor portion of the GIC.
Definition: gic_pl390.cc:357
static const AddrRange GICD_IPRIORITYR
Definition: gic_pl390.hh:81
uint64_t cpuSgiActive[SGI_MAX]
Definition: gic_pl390.hh:297
const SimObjectParams * _params
Cached copy of the object parameters.
Definition: sim_object.hh:107
void driveIrqEn(bool state)
Definition: gic_pl390.cc:987
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition: gic_pl390.cc:912
bool irqEnable
IRQ Enable Used for debug.
Definition: gic_pl390.hh:311
Tick readDistributor(PacketPtr pkt)
Handle a read to the distributor portion of the GIC.
Definition: gic_pl390.cc:126
static const AddrRange GICD_IGROUPR
Definition: gic_pl390.hh:74
static const AddrRange GICD_ICENABLER
Definition: gic_pl390.hh:76
uint64_t genSwiMask(int cpu)
generate a bit mask to check cpuSgi for an interrupt.
Definition: gic_pl390.cc:675
static const int GLOBAL_INT_LINES
Definition: gic_pl390.hh:113
const AddrRangeList addrRanges
All address ranges used by this GIC.
Definition: gic_pl390.hh:138
int pendingDelayedInterrupts
Definition: gic_pl390.hh:358
PostIntEvent * postIntEvent[CPU_MAX]
Definition: gic_pl390.hh:357
void sendPPInt(uint32_t num, uint32_t cpu) override
Interface call for private peripheral interrupts.
Definition: gic_pl390.cc:816
static const int GICC_BPR_MINIMUM
minimum value for Binary Point Register ("IMPLEMENTATION DEFINED"); chosen for consistency with Lin...
Definition: gic_pl390.hh:117
Bitfield< 0 > p
void softInt(ContextID ctx, SWI swi)
software generated interrupt
Definition: gic_pl390.cc:605
static const int SGI_MAX
Definition: gic_pl390.hh:100
Tick readCpu(PacketPtr pkt)
Handle a read to the cpu portion of the GIC.
Definition: gic_pl390.cc:262
void postDelayedInt(uint32_t cpu)
Deliver a delayed interrupt to the target CPU.
Definition: gic_pl390.cc:849
int ContextID
Globally unique thread context ID.
Definition: types.hh:175
BankedRegs & getBankedRegs(ContextID)
Definition: gic_pl390.cc:595
const Tick cpuPioDelay
Latency for a cpu operation.
Definition: gic_pl390.hh:144
static const int PPI_MAX
Definition: gic_pl390.hh:101
void updateIntState(int hint)
See if some processor interrupt flags need to be enabled/disabled.
Definition: gic_pl390.cc:694

Generated on Fri Jun 9 2017 13:03:45 for gem5 by doxygen 1.8.6