gem5  v20.0.0.3
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 
38 #ifndef __DEV_ARM_GICV3_ITS_H__
39 #define __DEV_ARM_GICV3_ITS_H__
40 
41 #include <queue>
42 
43 #include "base/coroutine.hh"
44 #include "dev/dma_device.hh"
45 #include "params/Gicv3Its.hh"
46 
47 class Gicv3;
48 class Gicv3Redistributor;
49 class ItsProcess;
50 class ItsTranslation;
51 class ItsCommand;
52 
53 enum class ItsActionType
54 {
56  SEND_REQ,
57  TERMINATE,
58 };
59 
60 struct ItsAction
61 {
65 };
66 
74 class Gicv3Its : public BasicPioDevice
75 {
76  friend class ::ItsProcess;
77  friend class ::ItsTranslation;
78  friend class ::ItsCommand;
79  public:
80  class DataPort : public MasterPort
81  {
82  protected:
84 
85  public:
86  DataPort(const std::string &_name, Gicv3Its &_its) :
87  MasterPort(_name, &_its),
88  its(_its)
89  {}
90 
91  virtual ~DataPort() {}
92 
93  bool recvTimingResp(PacketPtr pkt) { return its.recvTimingResp(pkt); }
94  void recvReqRetry() { return its.recvReqRetry(); }
95  };
96 
98 
99  Port & getPort(const std::string &if_name, PortID idx) override;
100  bool recvTimingResp(PacketPtr pkt);
101  void recvReqRetry();
102 
103  Gicv3Its(const Gicv3ItsParams *params);
104 
105  void setGIC(Gicv3 *_gic);
106 
107  static const uint32_t itsControl = 0x0;
108  static const uint32_t itsTranslate = 0x10000;
109 
110  // Address range part of Control frame
111  static const AddrRange GITS_BASER;
112 
113  static const uint32_t NUM_BASER_REGS = 8;
114 
115  // We currently don't support two level ITS tables
116  // The indirect bit is RAZ/WI for implementations that only
117  // support flat tables.
118  static const uint64_t BASER_INDIRECT = 0x4000000000000000;
119  static const uint64_t BASER_TYPE = 0x0700000000000000;
120  static const uint64_t BASER_ESZ = 0x001F000000000000;
121  static const uint64_t BASER_SZ = 0x00000000000000FF;
122  static const uint64_t BASER_WMASK =
123  ~(BASER_INDIRECT | BASER_TYPE | BASER_ESZ);
124  static const uint64_t BASER_WMASK_UNIMPL =
125  ~(BASER_INDIRECT | BASER_TYPE | BASER_ESZ | BASER_SZ);
126 
127  // GITS_CTLR.quiescent mask
128  static const uint32_t CTLR_QUIESCENT;
129 
130  enum : Addr
131  {
132  // Control frame
133  GITS_CTLR = itsControl + 0x0000,
134  GITS_IIDR = itsControl + 0x0004,
135  GITS_TYPER = itsControl + 0x0008,
136  GITS_CBASER = itsControl + 0x0080,
137  GITS_CWRITER = itsControl + 0x0088,
138  GITS_CREADR = itsControl + 0x0090,
139  GITS_PIDR2 = itsControl + 0xffe8,
140 
141  // Translation frame
142  GITS_TRANSLATER = itsTranslate + 0x0040
143  };
144 
145  AddrRangeList getAddrRanges() const override;
146 
147  Tick read(PacketPtr pkt) override;
148  Tick write(PacketPtr pkt) override;
149 
150  DrainState drain() override;
151  void serialize(CheckpointOut & cp) const override;
152  void unserialize(CheckpointIn & cp) override;
153 
154  void translate(PacketPtr pkt);
155 
156  BitUnion32(CTLR)
157  Bitfield<31> quiescent;
158  Bitfield<7, 4> itsNumber;
159  Bitfield<1> imDe;
160  Bitfield<0> enabled;
161  EndBitUnion(CTLR)
162 
163  // Command read/write, (CREADR, CWRITER)
164  BitUnion64(CRDWR)
165  Bitfield<63, 32> high;
166  Bitfield<31, 0> low;
167  Bitfield<19, 5> offset;
168  Bitfield<0> retry;
169  Bitfield<0> stalled;
170  EndBitUnion(CRDWR)
171 
172  BitUnion64(CBASER)
173  Bitfield<63, 32> high;
174  Bitfield<31, 0> low;
175  Bitfield<63> valid;
176  Bitfield<61, 59> innerCache;
177  Bitfield<55, 53> outerCache;
178  Bitfield<51, 12> physAddr;
179  Bitfield<11, 10> shareability;
180  Bitfield<7, 0> size;
181  EndBitUnion(CBASER)
182 
183  BitUnion64(BASER)
184  Bitfield<63> valid;
185  Bitfield<62> indirect;
186  Bitfield<61, 59> innerCache;
187  Bitfield<58, 56> type;
188  Bitfield<55, 53> outerCache;
189  Bitfield<52, 48> entrySize;
190  Bitfield<47, 12> physAddr;
191  Bitfield<11, 10> shareability;
192  Bitfield<9, 8> pageSize;
193  Bitfield<7, 0> size;
194  EndBitUnion(BASER)
195 
196  BitUnion64(TYPER)
197  Bitfield<63, 32> high;
198  Bitfield<31, 0> low;
199  Bitfield<37> vmovp;
200  Bitfield<36> cil;
201  Bitfield<35, 32> cidBits;
202  Bitfield<31, 24> hcc;
203  Bitfield<19> pta;
204  Bitfield<18> seis;
205  Bitfield<17, 13> devBits;
206  Bitfield<12, 8> idBits;
207  Bitfield<7, 4> ittEntrySize;
208  Bitfield<2> cct;
209  Bitfield<1> _virtual;
210  Bitfield<0> physical;
211  EndBitUnion(TYPER)
212 
213  CTLR gitsControl;
214  TYPER gitsTyper;
215  CBASER gitsCbaser;
216  CRDWR gitsCreadr;
217  CRDWR gitsCwriter;
218  uint32_t gitsIidr;
219  uint32_t gitsTranslater;
220 
221  std::vector<BASER> tableBases;
222 
227  bool idOutOfRange(uint32_t event_id, uint8_t itt_range) const;
228 
234  bool deviceOutOfRange(uint32_t device_id) const;
235 
242  bool sizeOutOfRange(uint32_t size) const;
243 
249  bool collectionOutOfRange(uint32_t collection_id) const;
250 
255  bool lpiOutOfRange(uint32_t intid) const;
256 
257  private: // Command
258  uint64_t maxCommands() const;
259  void checkCommandQueue();
260  void incrementReadPointer();
261 
262  public: // TableWalk
263  BitUnion64(DTE)
264  Bitfield<57, 53> ittRange;
265  Bitfield<52, 1> ittAddress;
266  Bitfield<0> valid;
267  EndBitUnion(DTE)
268 
269  BitUnion64(ITTE)
270  Bitfield<59, 46> vpeid;
271  Bitfield<45, 30> icid;
272  Bitfield<29, 16> intNumHyp;
273  Bitfield<15, 2> intNum;
274  Bitfield<1> intType;
275  Bitfield<0> valid;
276  EndBitUnion(ITTE)
277 
278  BitUnion64(CTE)
279  Bitfield<40, 1> rdBase;
280  Bitfield<0> valid;
282 
283  enum InterruptType
284  {
285  VIRTUAL_INTERRUPT = 0,
286  PHYSICAL_INTERRUPT = 1
287  };
288 
289  private:
290  Gicv3Redistributor* getRedistributor(uint64_t rd_base);
292  {
293  return getRedistributor(cte.rdBase);
294  }
295 
296  ItsAction runProcess(ItsProcess *proc, PacketPtr pkt);
297  ItsAction runProcessTiming(ItsProcess *proc, PacketPtr pkt);
298  ItsAction runProcessAtomic(ItsProcess *proc, PacketPtr pkt);
299 
301  {
302  DEVICE_TABLE = 1,
303  VPE_TABLE = 2,
304  TRANSLATION_TABLE = 3,
305  COLLECTION_TABLE = 4
306  };
307 
308  enum PageSize
309  {
312  SIZE_64K
313  };
314 
315  Addr pageAddress(enum ItsTables table);
316 
317  void moveAllPendingState(
319 
320  private:
321  std::queue<ItsAction> packetsToRetry;
322  uint32_t masterId;
325 
328 };
329 
346 {
347  public:
348  using DTE = Gicv3Its::DTE;
349  using ITTE = Gicv3Its::ITTE;
350  using CTE = Gicv3Its::CTE;
353 
354  ItsProcess(Gicv3Its &_its);
355  virtual ~ItsProcess();
356 
358  const std::string name() const;
359 
360  ItsAction run(PacketPtr pkt);
361 
362  protected:
363  void reinit();
364  virtual void main(Yield &yield) = 0;
365 
366  void writeDeviceTable(Yield &yield, uint32_t device_id, DTE dte);
367 
368  void writeIrqTranslationTable(
369  Yield &yield, const Addr itt_base, uint32_t event_id, ITTE itte);
370 
371  void writeIrqCollectionTable(
372  Yield &yield, uint32_t collection_id, CTE cte);
373 
374  uint64_t readDeviceTable(
375  Yield &yield, uint32_t device_id);
376 
377  uint64_t readIrqTranslationTable(
378  Yield &yield, const Addr itt_base, uint32_t event_id);
379 
380  uint64_t readIrqCollectionTable(Yield &yield, uint32_t collection_id);
381 
382  void doRead(Yield &yield, Addr addr, void *ptr, size_t size);
383  void doWrite(Yield &yield, Addr addr, void *ptr, size_t size);
384  void terminate(Yield &yield);
385 
386  protected:
388 
389  private:
390  std::unique_ptr<Coroutine> coroutine;
391 };
392 
400 {
401  public:
402  ItsTranslation(Gicv3Its &_its);
403  ~ItsTranslation();
404 
405  protected:
406  void main(Yield &yield) override;
407 
409  translateLPI(Yield &yield, uint32_t device_id, uint32_t event_id);
410 };
411 
418 class ItsCommand : public ItsProcess
419 {
420  public:
422  {
423  struct
424  {
425  uint32_t type;
426  uint32_t deviceId;
427  uint32_t eventId;
428  uint32_t pintId;
429 
430  uint32_t data[4];
431  };
432  uint64_t raw[4];
433  };
434 
435  enum CommandType : uint32_t
436  {
437  CLEAR = 0x04,
438  DISCARD = 0x0F,
439  INT = 0x03,
440  INV = 0x0C,
441  INVALL = 0x0D,
442  MAPC = 0x09,
443  MAPD = 0x08,
444  MAPI = 0x0B,
445  MAPTI = 0x0A,
446  MOVALL = 0x0E,
447  MOVI = 0x01,
448  SYNC = 0x05,
449  VINVALL = 0x2D,
450  VMAPI = 0x2B,
451  VMAPP = 0x29,
452  VMAPTI = 0x2A,
453  VMOVI = 0x21,
454  VMOVP = 0x22,
455  VSYNC = 0x25
456  };
457 
458  ItsCommand(Gicv3Its &_its);
459  ~ItsCommand();
460 
461  protected:
468  {
469  using ExecFn = std::function<void(ItsCommand*, Yield&, CommandEntry&)>;
470 
471  DispatchEntry(std::string _name, ExecFn _exec)
472  : name(_name), exec(_exec)
473  {}
474 
475  std::string name;
477  };
478 
479  using DispatchTable = std::unordered_map<
481 
483 
484  static std::string commandName(uint32_t cmd);
485 
486  void main(Yield &yield) override;
487 
488  void readCommand(Yield &yield, CommandEntry &command);
489  void processCommand(Yield &yield, CommandEntry &command);
490 
491  // Commands
492  void clear(Yield &yield, CommandEntry &command);
493  void discard(Yield &yield, CommandEntry &command);
494  void mapc(Yield &yield, CommandEntry &command);
495  void mapd(Yield &yield, CommandEntry &command);
496  void mapi(Yield &yield, CommandEntry &command);
497  void mapti(Yield &yield, CommandEntry &command);
498  void movall(Yield &yield, CommandEntry &command);
499  void movi(Yield &yield, CommandEntry &command);
500  void sync(Yield &yield, CommandEntry &command);
501  void doInt(Yield &yield, CommandEntry &command);
502  void inv(Yield &yield, CommandEntry &command);
503  void invall(Yield &yield, CommandEntry &command);
504  void vinvall(Yield &yield, CommandEntry &command);
505  void vmapi(Yield &yield, CommandEntry &command);
506  void vmapp(Yield &yield, CommandEntry &command);
507  void vmapti(Yield &yield, CommandEntry &command);
508  void vmovi(Yield &yield, CommandEntry &command);
509  void vmovp(Yield &yield, CommandEntry &command);
510  void vsync(Yield &yield, CommandEntry &command);
511 
512  protected: // Helpers
513  bool idOutOfRange(CommandEntry &command, DTE dte) const
514  {
515  return its.idOutOfRange(command.eventId, dte.ittRange);
516  }
517 
518  bool deviceOutOfRange(CommandEntry &command) const
519  {
520  return its.deviceOutOfRange(command.deviceId);
521  }
522 
523  bool sizeOutOfRange(CommandEntry &command) const
524  {
525  const auto size = bits(command.raw[1], 4, 0);
526  const auto valid = bits(command.raw[2], 63);
527  if (valid)
528  return its.sizeOutOfRange(size);
529  else
530  return false;
531  }
532 
533  bool collectionOutOfRange(CommandEntry &command) const
534  {
535  return its.collectionOutOfRange(bits(command.raw[2], 15, 0));
536  }
537 };
538 
539 #endif
A MasterPort is a specialisation of a BaseMasterPort, which implements the default protocol for the t...
Definition: port.hh:71
Bitfield< 0 > enabled
Definition: gic_v3_its.hh:160
Gicv3Its::CTE CTE
Definition: gic_v3_its.hh:350
Ports are used to interface objects to each other.
Definition: port.hh:56
bool deviceOutOfRange(CommandEntry &command) const
Definition: gic_v3_its.hh:518
Definition: gic_v3.hh:52
Gicv3Its::DTE DTE
Definition: gic_v3_its.hh:348
const std::string & name()
Definition: trace.cc:50
EndBitUnion(UserDescFlags) struct UserDesc32
Definition: process.cc:152
STL pair class.
Definition: stl.hh:58
static const AddrRange GITS_BASER
Definition: gic_v3_its.hh:111
PacketPtr pkt
Definition: gic_v3_its.hh:63
Tick delay
Definition: gic_v3_its.hh:64
physAddr
Definition: misc.hh:831
ip6_addr_t addr
Definition: inet.hh:330
Gicv3Its & its
Definition: gic_v3_its.hh:83
EventFunctionWrapper commandEvent
Definition: gic_v3_its.hh:324
Bitfield< 23, 0 > offset
Definition: types.hh:152
Overload hash function for BasicBlockRange type.
Definition: vec_reg.hh:587
Bitfield< 23 > inv
Definition: misc.hh:808
An ItsTranslation is created whenever a peripheral writes a message in GITS_TRANSLATER (MSI)...
Definition: gic_v3_its.hh:399
Definition: cprintf.cc:40
bool sizeOutOfRange(CommandEntry &command) const
Definition: gic_v3_its.hh:523
DrainState
Object drain/handover states.
Definition: drain.hh:71
int main(int argc, char **argv)
Definition: marshal.cc:46
CallerType: A reference to an object of this class will be passed to the coroutine task...
Definition: coroutine.hh:83
virtual ~DataPort()
Definition: gic_v3_its.hh:91
Gicv3Its & its
Definition: gic_v3_its.hh:387
uint32_t masterId
Definition: gic_v3_its.hh:322
Gicv3 * gic
Definition: gic_v3_its.hh:323
Dispatch entry is a metadata struct which contains information about the command (like the name) and ...
Definition: gic_v3_its.hh:467
The AddrRange class encapsulates an address range, and supports a number of tests to check if two ran...
Definition: addr_range.hh:68
bool recvTimingResp(PacketPtr pkt)
Definition: gic_v3_its.cc:1132
ItsActionType
Definition: gic_v3_its.hh:53
uint8_t type
Definition: inet.hh:328
std::unordered_map< std::underlying_type< enum CommandType >::type, DispatchEntry > DispatchTable
Definition: gic_v3_its.hh:480
uint64_t Tick
Tick count type.
Definition: types.hh:61
DataPort dmaPort
Definition: gic_v3_its.hh:97
This template defines a Coroutine wrapper type with a Boost-like interface.
Definition: coroutine.hh:62
void serialize(const ThreadContext &tc, CheckpointOut &cp)
Thread context serialization helpers.
Bitfield< 7, 4 > itsNumber
Definition: gic_v3_its.hh:158
ItsProcess is a base coroutine wrapper which is spawned by the Gicv3Its module when the latter needs ...
Definition: gic_v3_its.hh:345
An ItsCommand is created whenever there is a new command in the command queue.
Definition: gic_v3_its.hh:418
bool collectionOutOfRange(CommandEntry &command) const
Definition: gic_v3_its.hh:533
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:140
A Packet is used to encapsulate a transfer between two objects in the memory system (e...
Definition: packet.hh:249
Bitfield< 15, 8 > vector
Definition: intmessage.hh:44
std::unique_ptr< Coroutine > coroutine
Definition: gic_v3_its.hh:390
bool recvTimingResp(PacketPtr pkt)
Receive a timing response from the peer.
Definition: gic_v3_its.hh:93
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:397
Gicv3Redistributor * getRedistributor(CTE cte)
Definition: gic_v3_its.hh:291
Gicv3Its::ITTE ITTE
Definition: gic_v3_its.hh:349
std::queue< ItsAction > packetsToRetry
Definition: gic_v3_its.hh:321
bool pendingCommands
Definition: gic_v3_its.hh:326
static const uint32_t CTLR_QUIESCENT
Definition: gic_v3_its.hh:128
std::ostream CheckpointOut
Definition: serialize.hh:63
DataPort(const std::string &_name, Gicv3Its &_its)
Definition: gic_v3_its.hh:86
static DispatchTable cmdDispatcher
Definition: gic_v3_its.hh:482
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:235
BitUnion32(UserDescFlags) Bitfield< 0 > seg_32bit
std::function< void(ItsCommand *, Yield &, CommandEntry &)> ExecFn
Definition: gic_v3_its.hh:469
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:71
Bitfield< 1 > imDe
Definition: gic_v3_its.hh:159
#define BitUnion64(name)
Definition: bitunion.hh:374
ItsActionType type
Definition: gic_v3_its.hh:62
DispatchEntry(std::string _name, ExecFn _exec)
Definition: gic_v3_its.hh:471
const char data[]
bool idOutOfRange(CommandEntry &command, DTE dte) const
Definition: gic_v3_its.hh:513
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:94
uint32_t pendingTranslations
Definition: gic_v3_its.hh:327
GICv3 ITS module.
Definition: gic_v3_its.hh:74
void recvReqRetry()
Definition: gic_v3_its.cc:1115

Generated on Fri Jul 3 2020 15:53:01 for gem5 by doxygen 1.8.13