gem5  v19.0.0.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
gic_v3_its.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  * Redistribution and use in source and binary forms, with or without
15  * modification, are permitted provided that the following conditions are
16  * met: redistributions of source code must retain the above copyright
17  * notice, this list of conditions and the following disclaimer;
18  * redistributions in binary form must reproduce the above copyright
19  * notice, this list of conditions and the following disclaimer in the
20  * documentation and/or other materials provided with the distribution;
21  * neither the name of the copyright holders nor the names of its
22  * contributors may be used to endorse or promote products derived from
23  * this software without specific prior written permission.
24  *
25  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
31  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36  *
37  * Authors: Giacomo Travaglini
38  */
39 
40 #ifndef __DEV_ARM_GICV3_ITS_H__
41 #define __DEV_ARM_GICV3_ITS_H__
42 
43 #include <queue>
44 
45 #include "base/coroutine.hh"
46 #include "dev/dma_device.hh"
47 #include "params/Gicv3Its.hh"
48 
49 class Gicv3;
50 class Gicv3Redistributor;
51 class ItsProcess;
52 class ItsTranslation;
53 class ItsCommand;
54 
55 enum class ItsActionType
56 {
58  SEND_REQ,
59  TERMINATE,
60 };
61 
62 struct ItsAction
63 {
67 };
68 
76 class Gicv3Its : public BasicPioDevice
77 {
78  friend class ::ItsProcess;
79  friend class ::ItsTranslation;
80  friend class ::ItsCommand;
81  public:
82  class DataPort : public MasterPort
83  {
84  protected:
86 
87  public:
88  DataPort(const std::string &_name, Gicv3Its &_its) :
89  MasterPort(_name, &_its),
90  its(_its)
91  {}
92 
93  virtual ~DataPort() {}
94 
95  bool recvTimingResp(PacketPtr pkt) { return its.recvTimingResp(pkt); }
96  void recvReqRetry() { return its.recvReqRetry(); }
97  };
98 
100 
101  Port & getPort(const std::string &if_name, PortID idx) override;
102  bool recvTimingResp(PacketPtr pkt);
103  void recvReqRetry();
104 
105  Gicv3Its(const Gicv3ItsParams *params);
106 
107  void setGIC(Gicv3 *_gic);
108 
109  static const uint32_t itsControl = 0x0;
110  static const uint32_t itsTranslate = 0x10000;
111 
112  // Address range part of Control frame
113  static const AddrRange GITS_BASER;
114 
115  static const uint32_t NUM_BASER_REGS = 8;
116 
117  // We currently don't support two level ITS tables
118  // The indirect bit is RAZ/WI for implementations that only
119  // support flat tables.
120  static const uint64_t BASER_INDIRECT = 0x4000000000000000;
121  static const uint64_t BASER_TYPE = 0x0700000000000000;
122  static const uint64_t BASER_ESZ = 0x001F000000000000;
123  static const uint64_t BASER_SZ = 0x00000000000000FF;
124  static const uint64_t BASER_WMASK =
125  ~(BASER_INDIRECT | BASER_TYPE | BASER_ESZ);
126  static const uint64_t BASER_WMASK_UNIMPL =
127  ~(BASER_INDIRECT | BASER_TYPE | BASER_ESZ | BASER_SZ);
128 
129  // GITS_CTLR.quiescent mask
130  static const uint32_t CTLR_QUIESCENT;
131 
132  enum : Addr
133  {
134  // Control frame
135  GITS_CTLR = itsControl + 0x0000,
136  GITS_IIDR = itsControl + 0x0004,
137  GITS_TYPER = itsControl + 0x0008,
138  GITS_CBASER = itsControl + 0x0080,
139  GITS_CWRITER = itsControl + 0x0088,
140  GITS_CREADR = itsControl + 0x0090,
141  GITS_PIDR2 = itsControl + 0xffe8,
142 
143  // Translation frame
144  GITS_TRANSLATER = itsTranslate + 0x0040
145  };
146 
147  AddrRangeList getAddrRanges() const override;
148 
149  Tick read(PacketPtr pkt) override;
150  Tick write(PacketPtr pkt) override;
151 
152  DrainState drain() override;
153  void serialize(CheckpointOut & cp) const override;
154  void unserialize(CheckpointIn & cp) override;
155 
156  void translate(PacketPtr pkt);
157 
158  BitUnion32(CTLR)
159  Bitfield<31> quiescent;
160  Bitfield<7, 4> itsNumber;
161  Bitfield<1> imDe;
162  Bitfield<0> enabled;
163  EndBitUnion(CTLR)
164 
165  // Command read/write, (CREADR, CWRITER)
166  BitUnion64(CRDWR)
167  Bitfield<63, 32> high;
168  Bitfield<31, 0> low;
169  Bitfield<19, 5> offset;
170  Bitfield<0> retry;
171  Bitfield<0> stalled;
172  EndBitUnion(CRDWR)
173 
174  BitUnion64(CBASER)
175  Bitfield<63, 32> high;
176  Bitfield<31, 0> low;
177  Bitfield<63> valid;
178  Bitfield<61, 59> innerCache;
179  Bitfield<55, 53> outerCache;
180  Bitfield<51, 12> physAddr;
181  Bitfield<11, 10> shareability;
182  Bitfield<7, 0> size;
183  EndBitUnion(CBASER)
184 
185  BitUnion64(BASER)
186  Bitfield<63> valid;
187  Bitfield<62> indirect;
188  Bitfield<61, 59> innerCache;
189  Bitfield<58, 56> type;
190  Bitfield<55, 53> outerCache;
191  Bitfield<52, 48> entrySize;
192  Bitfield<47, 12> physAddr;
193  Bitfield<11, 10> shareability;
194  Bitfield<9, 8> pageSize;
195  Bitfield<7, 0> size;
196  EndBitUnion(BASER)
197 
198  BitUnion64(TYPER)
199  Bitfield<63, 32> high;
200  Bitfield<31, 0> low;
201  Bitfield<37> vmovp;
202  Bitfield<36> cil;
203  Bitfield<35, 32> cidBits;
204  Bitfield<31, 24> hcc;
205  Bitfield<19> pta;
206  Bitfield<18> seis;
207  Bitfield<17, 13> devBits;
208  Bitfield<12, 8> idBits;
209  Bitfield<7, 4> ittEntrySize;
210  Bitfield<2> cct;
211  Bitfield<1> _virtual;
212  Bitfield<0> physical;
213  EndBitUnion(TYPER)
214 
215  CTLR gitsControl;
216  TYPER gitsTyper;
217  CBASER gitsCbaser;
218  CRDWR gitsCreadr;
219  CRDWR gitsCwriter;
220  uint32_t gitsIidr;
221  uint32_t gitsTranslater;
222 
223  std::vector<BASER> tableBases;
224 
229  bool idOutOfRange(uint32_t event_id, uint8_t itt_range) const;
230 
236  bool deviceOutOfRange(uint32_t device_id) const;
237 
244  bool sizeOutOfRange(uint32_t size) const;
245 
251  bool collectionOutOfRange(uint32_t collection_id) const;
252 
257  bool lpiOutOfRange(uint32_t intid) const;
258 
259  private: // Command
260  uint64_t maxCommands() const;
261  void checkCommandQueue();
262  void incrementReadPointer();
263 
264  public: // TableWalk
265  BitUnion64(DTE)
266  Bitfield<57, 53> ittRange;
267  Bitfield<52, 1> ittAddress;
268  Bitfield<0> valid;
269  EndBitUnion(DTE)
270 
271  BitUnion64(ITTE)
272  Bitfield<59, 46> vpeid;
273  Bitfield<45, 30> icid;
274  Bitfield<29, 16> intNumHyp;
275  Bitfield<15, 2> intNum;
276  Bitfield<1> intType;
277  Bitfield<0> valid;
278  EndBitUnion(ITTE)
279 
280  BitUnion64(CTE)
281  Bitfield<40, 1> rdBase;
282  Bitfield<0> valid;
284 
285  enum InterruptType
286  {
287  VIRTUAL_INTERRUPT = 0,
288  PHYSICAL_INTERRUPT = 1
289  };
290 
291  private:
292  Gicv3Redistributor* getRedistributor(uint64_t rd_base);
294  {
295  return getRedistributor(cte.rdBase);
296  }
297 
298  ItsAction runProcess(ItsProcess *proc, PacketPtr pkt);
299  ItsAction runProcessTiming(ItsProcess *proc, PacketPtr pkt);
300  ItsAction runProcessAtomic(ItsProcess *proc, PacketPtr pkt);
301 
303  {
304  DEVICE_TABLE = 1,
305  VPE_TABLE = 2,
306  TRANSLATION_TABLE = 3,
307  COLLECTION_TABLE = 4
308  };
309 
310  enum PageSize
311  {
314  SIZE_64K
315  };
316 
317  Addr pageAddress(enum ItsTables table);
318 
319  void moveAllPendingState(
321 
322  private:
323  std::queue<ItsAction> packetsToRetry;
324  uint32_t masterId;
327 
330 };
331 
348 {
349  public:
350  using DTE = Gicv3Its::DTE;
351  using ITTE = Gicv3Its::ITTE;
352  using CTE = Gicv3Its::CTE;
355 
356  ItsProcess(Gicv3Its &_its);
357  virtual ~ItsProcess();
358 
360  const std::string name() const;
361 
362  ItsAction run(PacketPtr pkt);
363 
364  protected:
365  void reinit();
366  virtual void main(Yield &yield) = 0;
367 
368  void writeDeviceTable(Yield &yield, uint32_t device_id, DTE dte);
369 
370  void writeIrqTranslationTable(
371  Yield &yield, const Addr itt_base, uint32_t event_id, ITTE itte);
372 
373  void writeIrqCollectionTable(
374  Yield &yield, uint32_t collection_id, CTE cte);
375 
376  uint64_t readDeviceTable(
377  Yield &yield, uint32_t device_id);
378 
379  uint64_t readIrqTranslationTable(
380  Yield &yield, const Addr itt_base, uint32_t event_id);
381 
382  uint64_t readIrqCollectionTable(Yield &yield, uint32_t collection_id);
383 
384  void doRead(Yield &yield, Addr addr, void *ptr, size_t size);
385  void doWrite(Yield &yield, Addr addr, void *ptr, size_t size);
386  void terminate(Yield &yield);
387 
388  protected:
390 
391  private:
392  std::unique_ptr<Coroutine> coroutine;
393 };
394 
402 {
403  public:
404  ItsTranslation(Gicv3Its &_its);
405  ~ItsTranslation();
406 
407  protected:
408  void main(Yield &yield) override;
409 
411  translateLPI(Yield &yield, uint32_t device_id, uint32_t event_id);
412 };
413 
420 class ItsCommand : public ItsProcess
421 {
422  public:
424  {
425  struct
426  {
427  uint32_t type;
428  uint32_t deviceId;
429  uint32_t eventId;
430  uint32_t pintId;
431 
432  uint32_t data[4];
433  };
434  uint64_t raw[4];
435  };
436 
437  enum CommandType : uint32_t
438  {
439  CLEAR = 0x04,
440  DISCARD = 0x0F,
441  INT = 0x03,
442  INV = 0x0C,
443  INVALL = 0x0D,
444  MAPC = 0x09,
445  MAPD = 0x08,
446  MAPI = 0x0B,
447  MAPTI = 0x0A,
448  MOVALL = 0x0E,
449  MOVI = 0x01,
450  SYNC = 0x05,
451  VINVALL = 0x2D,
452  VMAPI = 0x2B,
453  VMAPP = 0x29,
454  VMAPTI = 0x2A,
455  VMOVI = 0x21,
456  VMOVP = 0x22,
457  VSYNC = 0x25
458  };
459 
460  ItsCommand(Gicv3Its &_its);
461  ~ItsCommand();
462 
463  protected:
470  {
471  using ExecFn = std::function<void(ItsCommand*, Yield&, CommandEntry&)>;
472 
473  DispatchEntry(std::string _name, ExecFn _exec)
474  : name(_name), exec(_exec)
475  {}
476 
477  std::string name;
479  };
480 
481  using DispatchTable = std::unordered_map<
483 
485 
486  static std::string commandName(uint32_t cmd);
487 
488  void main(Yield &yield) override;
489 
490  void readCommand(Yield &yield, CommandEntry &command);
491  void processCommand(Yield &yield, CommandEntry &command);
492 
493  // Commands
494  void clear(Yield &yield, CommandEntry &command);
495  void discard(Yield &yield, CommandEntry &command);
496  void mapc(Yield &yield, CommandEntry &command);
497  void mapd(Yield &yield, CommandEntry &command);
498  void mapi(Yield &yield, CommandEntry &command);
499  void mapti(Yield &yield, CommandEntry &command);
500  void movall(Yield &yield, CommandEntry &command);
501  void movi(Yield &yield, CommandEntry &command);
502  void sync(Yield &yield, CommandEntry &command);
503  void doInt(Yield &yield, CommandEntry &command);
504  void inv(Yield &yield, CommandEntry &command);
505  void invall(Yield &yield, CommandEntry &command);
506  void vinvall(Yield &yield, CommandEntry &command);
507  void vmapi(Yield &yield, CommandEntry &command);
508  void vmapp(Yield &yield, CommandEntry &command);
509  void vmapti(Yield &yield, CommandEntry &command);
510  void vmovi(Yield &yield, CommandEntry &command);
511  void vmovp(Yield &yield, CommandEntry &command);
512  void vsync(Yield &yield, CommandEntry &command);
513 
514  protected: // Helpers
515  bool idOutOfRange(CommandEntry &command, DTE dte) const
516  {
517  return its.idOutOfRange(command.eventId, dte.ittRange);
518  }
519 
520  bool deviceOutOfRange(CommandEntry &command) const
521  {
522  return its.deviceOutOfRange(command.deviceId);
523  }
524 
525  bool sizeOutOfRange(CommandEntry &command) const
526  {
527  const auto size = bits(command.raw[1], 4, 0);
528  const auto valid = bits(command.raw[2], 63);
529  if (valid)
530  return its.sizeOutOfRange(size);
531  else
532  return false;
533  }
534 
535  bool collectionOutOfRange(CommandEntry &command) const
536  {
537  return its.collectionOutOfRange(bits(command.raw[2], 15, 0));
538  }
539 };
540 
541 #endif
A MasterPort is a specialisation of a BaseMasterPort, which implements the default protocol for the t...
Definition: port.hh:75
Bitfield< 0 > enabled
Definition: gic_v3_its.hh:162
Gicv3Its::CTE CTE
Definition: gic_v3_its.hh:352
Ports are used to interface objects to each other.
Definition: port.hh:60
bool deviceOutOfRange(CommandEntry &command) const
Definition: gic_v3_its.hh:520
Definition: gic_v3.hh:54
Gicv3Its::DTE DTE
Definition: gic_v3_its.hh:350
const std::string & name()
Definition: trace.cc:54
EndBitUnion(UserDescFlags) struct UserDesc32
Definition: process.cc:160
STL pair class.
Definition: stl.hh:61
DrainState
Object drain/handover states.
Definition: drain.hh:71
static const AddrRange GITS_BASER
Definition: gic_v3_its.hh:113
PacketPtr pkt
Definition: gic_v3_its.hh:65
Tick delay
Definition: gic_v3_its.hh:66
physAddr
Definition: misc.hh:833
ip6_addr_t addr
Definition: inet.hh:335
Gicv3Its & its
Definition: gic_v3_its.hh:85
EventFunctionWrapper commandEvent
Definition: gic_v3_its.hh:326
Bitfield< 23, 0 > offset
Definition: types.hh:154
Overload hash function for BasicBlockRange type.
Definition: vec_reg.hh:586
Bitfield< 23 > inv
Definition: misc.hh:810
An ItsTranslation is created whenever a peripheral writes a message in GITS_TRANSLATER (MSI)...
Definition: gic_v3_its.hh:401
Definition: cprintf.cc:42
bool sizeOutOfRange(CommandEntry &command) const
Definition: gic_v3_its.hh:525
int main(int argc, char **argv)
Definition: marshal.cc:48
CallerType: A reference to an object of this class will be passed to the coroutine task...
Definition: coroutine.hh:85
virtual ~DataPort()
Definition: gic_v3_its.hh:93
Gicv3Its & its
Definition: gic_v3_its.hh:389
uint32_t masterId
Definition: gic_v3_its.hh:324
Gicv3 * gic
Definition: gic_v3_its.hh:325
Dispatch entry is a metadata struct which contains information about the command (like the name) and ...
Definition: gic_v3_its.hh:469
The AddrRange class encapsulates an address range, and supports a number of tests to check if two ran...
Definition: addr_range.hh:72
bool recvTimingResp(PacketPtr pkt)
Definition: gic_v3_its.cc:1134
ItsActionType
Definition: gic_v3_its.hh:55
uint8_t type
Definition: inet.hh:333
std::unordered_map< std::underlying_type< enum CommandType >::type, DispatchEntry > DispatchTable
Definition: gic_v3_its.hh:482
uint64_t Tick
Tick count type.
Definition: types.hh:63
DataPort dmaPort
Definition: gic_v3_its.hh:99
This template defines a Coroutine wrapper type with a Boost-like interface.
Definition: coroutine.hh:64
void serialize(const ThreadContext &tc, CheckpointOut &cp)
Thread context serialization helpers.
Bitfield< 7, 4 > itsNumber
Definition: gic_v3_its.hh:160
ItsProcess is a base coroutine wrapper which is spawned by the Gicv3Its module when the latter needs ...
Definition: gic_v3_its.hh:347
An ItsCommand is created whenever there is a new command in the command queue.
Definition: gic_v3_its.hh:420
bool collectionOutOfRange(CommandEntry &command) const
Definition: gic_v3_its.hh:535
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:142
A Packet is used to encapsulate a transfer between two objects in the memory system (e...
Definition: packet.hh:255
Bitfield< 15, 8 > vector
Definition: intmessage.hh:46
std::unique_ptr< Coroutine > coroutine
Definition: gic_v3_its.hh:392
bool recvTimingResp(PacketPtr pkt)
Receive a timing response from the peer.
Definition: gic_v3_its.hh:95
A virtual base opaque structure used to hold state associated with the packet (e.g., an MSHR), specific to a SimObject that sees the packet.
Definition: packet.hh:403
Gicv3Redistributor * getRedistributor(CTE cte)
Definition: gic_v3_its.hh:293
Gicv3Its::ITTE ITTE
Definition: gic_v3_its.hh:351
std::queue< ItsAction > packetsToRetry
Definition: gic_v3_its.hh:323
bool pendingCommands
Definition: gic_v3_its.hh:328
static const uint32_t CTLR_QUIESCENT
Definition: gic_v3_its.hh:130
std::ostream CheckpointOut
Definition: serialize.hh:68
DataPort(const std::string &_name, Gicv3Its &_its)
Definition: gic_v3_its.hh:88
static DispatchTable cmdDispatcher
Definition: gic_v3_its.hh:484
void unserialize(ThreadContext &tc, CheckpointIn &cp)
int16_t PortID
Port index/ID type, and a symbolic name for an invalid port id.
Definition: types.hh:237
BitUnion32(UserDescFlags) Bitfield< 0 > seg_32bit
std::function< void(ItsCommand *, Yield &, CommandEntry &)> ExecFn
Definition: gic_v3_its.hh:471
T bits(T val, int first, int last)
Extract the bitfield from position &#39;first&#39; to &#39;last&#39; (inclusive) from &#39;val&#39; and right justify it...
Definition: bitfield.hh:72
Bitfield< 1 > imDe
Definition: gic_v3_its.hh:161
#define BitUnion64(name)
Definition: bitunion.hh:376
ItsActionType type
Definition: gic_v3_its.hh:64
DispatchEntry(std::string _name, ExecFn _exec)
Definition: gic_v3_its.hh:473
const char data[]
bool idOutOfRange(CommandEntry &command, DTE dte) const
Definition: gic_v3_its.hh:515
void recvReqRetry()
Called by the peer if sendTimingReq was called on this peer (causing recvTimingReq to be called on th...
Definition: gic_v3_its.hh:96
uint32_t pendingTranslations
Definition: gic_v3_its.hh:329
GICv3 ITS module.
Definition: gic_v3_its.hh:76
void recvReqRetry()
Definition: gic_v3_its.cc:1117

Generated on Fri Feb 28 2020 16:27:00 for gem5 by doxygen 1.8.13