gem5 [DEVELOP-FOR-25.1]
Loading...
Searching...
No Matches
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 <cstdint>
42#include <memory>
43#include <queue>
44#include <vector>
45
46#include "base/addr_range.hh"
47#include "base/bitunion.hh"
48#include "base/coroutine.hh"
49#include "base/types.hh"
50#include "dev/dma_device.hh"
51
52namespace gem5
53{
54
55class Gicv3;
57class ItsProcess;
58class ItsTranslation;
59class ItsCommand;
60
61struct Gicv3ItsParams;
62
69
76
85{
86 friend class gem5::ItsProcess;
88 friend class gem5::ItsCommand;
89
90 public:
91 class DataPort : public RequestPort
92 {
93 protected:
95
96 public:
97 DataPort(const std::string &_name, Gicv3Its &_its) :
99 its(_its)
100 {}
101
102 virtual ~DataPort() {}
103
104 bool recvTimingResp(PacketPtr pkt) { return its.recvTimingResp(pkt); }
105 void recvReqRetry() { return its.recvReqRetry(); }
106 };
107
109
110 Port & getPort(const std::string &if_name, PortID idx) override;
111 bool recvTimingResp(PacketPtr pkt);
112 void recvReqRetry();
113
114 Gicv3Its(const Gicv3ItsParams &params);
115
116 void setGIC(Gicv3 *_gic);
117
118 static const uint32_t itsControl = 0x0;
119 static const uint32_t itsTranslate = 0x10000;
120
121 // Address range part of Control frame
122 static const AddrRange GITS_BASER;
123
124 static const uint32_t NUM_BASER_REGS = 8;
125
126 // We currently don't support two level ITS tables
127 // The indirect bit is RAZ/WI for implementations that only
128 // support flat tables.
129 static const uint64_t BASER_INDIRECT = 0x4000000000000000;
130 static const uint64_t BASER_TYPE = 0x0700000000000000;
131 static const uint64_t BASER_ESZ = 0x001F000000000000;
132 static const uint64_t BASER_SZ = 0x00000000000000FF;
133 static const uint64_t BASER_WMASK =
135 static const uint64_t BASER_WMASK_UNIMPL =
137
138 // GITS_CTLR.quiescent mask
139 static const uint32_t CTLR_QUIESCENT;
140
141 enum : Addr
142 {
143 // Control frame
151
152 // Translation frame
154 };
155
156 AddrRangeList getAddrRanges() const override;
157
158 Tick read(PacketPtr pkt) override;
159 Tick write(PacketPtr pkt) override;
160
161 DrainState drain() override;
162 void serialize(CheckpointOut & cp) const override;
163 void unserialize(CheckpointIn & cp) override;
164
165 void translate(PacketPtr pkt);
166
168 Bitfield<31> quiescent;
169 Bitfield<7, 4> itsNumber;
170 Bitfield<1> imDe;
171 Bitfield<0> enabled;
173
174 // Command read/write, (CREADR, CWRITER)
175 BitUnion64(CRDWR)
176 Bitfield<63, 32> high;
177 Bitfield<31, 0> low;
178 Bitfield<19, 5> offset;
179 Bitfield<0> retry;
180 Bitfield<0> stalled;
182
183 BitUnion64(CBASER)
184 Bitfield<63, 32> high;
185 Bitfield<31, 0> low;
186 Bitfield<63> valid;
187 Bitfield<61, 59> innerCache;
188 Bitfield<55, 53> outerCache;
189 Bitfield<51, 12> physAddr;
190 Bitfield<11, 10> shareability;
191 Bitfield<7, 0> size;
193
194 BitUnion64(BASER)
195 Bitfield<63> valid;
196 Bitfield<62> indirect;
197 Bitfield<61, 59> innerCache;
198 Bitfield<58, 56> type;
199 Bitfield<55, 53> outerCache;
200 Bitfield<52, 48> entrySize;
201 Bitfield<47, 12> physAddr;
202 Bitfield<11, 10> shareability;
203 Bitfield<9, 8> pageSize;
204 Bitfield<7, 0> size;
206
207 BitUnion64(TYPER)
208 Bitfield<63, 32> high;
209 Bitfield<31, 0> low;
210 Bitfield<37> vmovp;
211 Bitfield<36> cil;
212 Bitfield<35, 32> cidBits;
213 Bitfield<31, 24> hcc;
214 Bitfield<19> pta;
215 Bitfield<18> seis;
216 Bitfield<17, 13> devBits;
217 Bitfield<12, 8> idBits;
218 Bitfield<7, 4> ittEntrySize;
219 Bitfield<2> cct;
220 Bitfield<1> _virtual;
221 Bitfield<0> physical;
223
224 CTLR gitsControl;
229 uint32_t gitsIidr;
231
233
238 bool idOutOfRange(uint32_t event_id, uint8_t itt_range) const;
239
245 bool deviceOutOfRange(uint32_t device_id) const;
246
253 bool sizeOutOfRange(uint32_t size) const;
254
260 bool collectionOutOfRange(uint32_t collection_id) const;
261
266 bool lpiOutOfRange(uint32_t intid) const;
267
268 private: // Command
269 uint64_t maxCommands() const;
270 void checkCommandQueue();
272
273 public: // TableWalk
275 Bitfield<57, 53> ittRange;
276 Bitfield<52, 1> ittAddress;
277 Bitfield<0> valid;
279
280 BitUnion64(ITTE)
281 Bitfield<59, 46> vpeid;
282 Bitfield<45, 30> icid;
283 Bitfield<29, 16> intNumHyp;
284 Bitfield<15, 2> intNum;
285 Bitfield<1> intType;
286 Bitfield<0> valid;
288
289 BitUnion64(CTE)
290 Bitfield<40, 1> rdBase;
291 Bitfield<0> valid;
293
294 enum InterruptType
295 {
296 VIRTUAL_INTERRUPT = 0,
297 PHYSICAL_INTERRUPT = 1
298 };
299
300 private:
301 Gicv3Redistributor* getRedistributor(uint64_t rd_base);
303 {
304 return getRedistributor(cte.rdBase);
305 }
306
310
318
325
326 Addr pageAddress(enum ItsTables table);
327
330
331 private:
332 std::queue<ItsAction> packetsToRetry;
333 uint32_t requestorId;
336
339};
340
357{
358 public:
359 using DTE = Gicv3Its::DTE;
360 using ITTE = Gicv3Its::ITTE;
361 using CTE = Gicv3Its::CTE;
363 using Yield = Coroutine::CallerType;
364
365 ItsProcess(Gicv3Its &_its);
366 virtual ~ItsProcess();
367
369 const std::string name() const;
370
372
373 protected:
374 void reinit();
375 virtual void main(Yield &yield) = 0;
376
377 void writeDeviceTable(Yield &yield, uint32_t device_id, DTE dte);
378
380 Yield &yield, const Addr itt_base, uint32_t event_id, ITTE itte);
381
383 Yield &yield, uint32_t collection_id, CTE cte);
384
385 uint64_t readDeviceTable(
386 Yield &yield, uint32_t device_id);
387
389 Yield &yield, const Addr itt_base, uint32_t event_id);
390
391 uint64_t readIrqCollectionTable(Yield &yield, uint32_t collection_id);
392
393 void doRead(Yield &yield, Addr addr, void *ptr, size_t size);
394 void doWrite(Yield &yield, Addr addr, void *ptr, size_t size);
395 void terminate(Yield &yield);
396
397 protected:
399
400 private:
401 std::unique_ptr<Coroutine> coroutine;
402};
403
411{
412 public:
415
416 protected:
417 void main(Yield &yield) override;
418
420 translateLPI(Yield &yield, uint32_t device_id, uint32_t event_id);
421};
422
429class ItsCommand : public ItsProcess
430{
431 public:
433 {
434 struct
435 {
436 uint32_t type;
437 uint32_t deviceId;
438 uint32_t eventId;
439 uint32_t pintId;
440
441 uint32_t data[4];
442 };
443 uint64_t raw[4];
444 };
445
446 enum CommandType : uint32_t
447 {
448 CLEAR = 0x04,
449 DISCARD = 0x0F,
450 INT = 0x03,
451 INV = 0x0C,
452 INVALL = 0x0D,
453 MAPC = 0x09,
454 MAPD = 0x08,
455 MAPI = 0x0B,
456 MAPTI = 0x0A,
457 MOVALL = 0x0E,
458 MOVI = 0x01,
459 SYNC = 0x05,
460 VINVALL = 0x2D,
461 VMAPI = 0x2B,
462 VMAPP = 0x29,
463 VMAPTI = 0x2A,
464 VMOVI = 0x21,
465 VMOVP = 0x22,
466 VSYNC = 0x25
467 };
468
469 ItsCommand(Gicv3Its &_its);
470 ~ItsCommand();
471
472 protected:
479 {
480 using ExecFn = std::function<void(ItsCommand*, Yield&, CommandEntry&)>;
481
482 DispatchEntry(std::string _name, ExecFn _exec)
483 : name(_name), exec(_exec)
484 {}
485
486 std::string name;
488 };
489
490 using DispatchTable = std::unordered_map<
491 std::underlying_type<enum CommandType>::type, DispatchEntry>;
492
494
495 static std::string commandName(uint32_t cmd);
496
497 void main(Yield &yield) override;
498
499 void readCommand(Yield &yield, CommandEntry &command);
500 void processCommand(Yield &yield, CommandEntry &command);
501
502 // Commands
503 void clear(Yield &yield, CommandEntry &command);
504 void discard(Yield &yield, CommandEntry &command);
505 void mapc(Yield &yield, CommandEntry &command);
506 void mapd(Yield &yield, CommandEntry &command);
507 void mapi(Yield &yield, CommandEntry &command);
508 void mapti(Yield &yield, CommandEntry &command);
509 void movall(Yield &yield, CommandEntry &command);
510 void movi(Yield &yield, CommandEntry &command);
511 void sync(Yield &yield, CommandEntry &command);
512 void doInt(Yield &yield, CommandEntry &command);
513 void inv(Yield &yield, CommandEntry &command);
514 void invall(Yield &yield, CommandEntry &command);
515 void vinvall(Yield &yield, CommandEntry &command);
516 void vmapi(Yield &yield, CommandEntry &command);
517 void vmapp(Yield &yield, CommandEntry &command);
518 void vmapti(Yield &yield, CommandEntry &command);
519 void vmovi(Yield &yield, CommandEntry &command);
520 void vmovp(Yield &yield, CommandEntry &command);
521 void vsync(Yield &yield, CommandEntry &command);
522
523 protected: // Helpers
524 bool idOutOfRange(CommandEntry &command, DTE dte) const
525 {
526 return its.idOutOfRange(command.eventId, dte.ittRange);
527 }
528
529 bool deviceOutOfRange(CommandEntry &command) const
530 {
531 return its.deviceOutOfRange(command.deviceId);
532 }
533
534 bool sizeOutOfRange(CommandEntry &command) const
535 {
536 const auto size = bits(command.raw[1], 4, 0);
537 const auto valid = bits(command.raw[2], 63);
538 if (valid)
539 return its.sizeOutOfRange(size);
540 else
541 return false;
542 }
543
545 {
546 return its.collectionOutOfRange(bits(command.raw[2], 15, 0));
547 }
548};
549
550} // namespace gem5
551
552#endif
Defines global host-dependent types: Counter, Tick, and (indirectly) {int,uint}{8,...
The AddrRange class encapsulates an address range, and supports a number of tests to check if two ran...
Definition addr_range.hh:82
BasicPioDevice(const Params &p, Addr size)
Definition io_device.cc:75
This template defines a Coroutine wrapper type with a Boost-like interface.
Definition coroutine.hh:64
bool recvTimingResp(PacketPtr pkt)
Receive a timing response from the peer.
void recvReqRetry()
Called by the peer if sendTimingReq was called on this peer (causing recvTimingReq to be called on th...
DataPort(const std::string &_name, Gicv3Its &_its)
Definition gic_v3_its.hh:97
GICv3 ITS module.
Definition gic_v3_its.hh:85
static const uint32_t CTLR_QUIESCENT
BitUnion64(DTE) Bitfield< 57
uint32_t gitsTranslater
Bitfield< 31, 0 > low
Bitfield< 0 > enabled
void moveAllPendingState(Gicv3Redistributor *rd1, Gicv3Redistributor *rd2)
Bitfield< 58, 56 > type
Bitfield< 9, 8 > pageSize
void checkCommandQueue()
uint32_t gitsIidr
bool lpiOutOfRange(uint32_t intid) const
Returns TRUE if the value supplied is larger than that permitted by GICD_TYPER.IDbits or not in the L...
EndBitUnion(CTLR) BitUnion64(CRDWR) Bitfield< 63
Bitfield< 12, 8 > idBits
Port & getPort(const std::string &if_name, PortID idx) override
Get a port with a given name and index.
Bitfield< 18 > seis
Tick read(PacketPtr pkt) override
Pure virtual function that the device must implement.
Bitfield< 35, 32 > cidBits
bool deviceOutOfRange(uint32_t device_id) const
Returns TRUE if the value supplied has bits above the implemented range or if the value supplied exce...
Bitfield< 52, 48 > entrySize
Bitfield< 7, 0 > size
Bitfield< 0 > physical
static const uint64_t BASER_WMASK_UNIMPL
static const uint32_t NUM_BASER_REGS
Bitfield< 61, 59 > innerCache
bool collectionOutOfRange(uint32_t collection_id) const
Returns TRUE if the value supplied has bits above the implemented range or if the value exceeds the t...
void translate(PacketPtr pkt)
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Bitfield< 1 > imDe
EventFunctionWrapper commandEvent
Gicv3Redistributor * getRedistributor(uint64_t rd_base)
DataPort dmaPort
std::vector< BASER > tableBases
Bitfield< 52, 1 > ittAddress
Bitfield< 29, 16 > intNumHyp
bool idOutOfRange(uint32_t event_id, uint8_t itt_range) const
Returns TRUE if the eventID supplied has bits above the implemented size or above the itt_range.
ItsAction runProcessTiming(ItsProcess *proc, PacketPtr pkt)
AddrRangeList getAddrRanges() const override
Determine the address ranges that this device responds to.
Bitfield< 11, 10 > shareability
Bitfield< 1 > intType
Bitfield< 19, 5 > offset
ItsAction runProcess(ItsProcess *proc, PacketPtr pkt)
Tick write(PacketPtr pkt) override
Pure virtual function that the device must implement.
Gicv3Redistributor * getRedistributor(CTE cte)
void serialize(CheckpointOut &cp) const override
Serialize an object.
Bitfield< 19 > pta
static const uint64_t BASER_INDIRECT
Gicv3Its(const Gicv3ItsParams &params)
ItsAction runProcessAtomic(ItsProcess *proc, PacketPtr pkt)
static const uint64_t BASER_SZ
Bitfield< 0 > stalled
Bitfield< 63 > valid
static const uint32_t itsTranslate
Bitfield< 2 > cct
DrainState drain() override
Draining is the process of clearing out the states of SimObjects.These are the SimObjects that are pa...
Addr pageAddress(enum ItsTables table)
Bitfield< 62 > indirect
bool sizeOutOfRange(uint32_t size) const
Returns TRUE if the value (size) supplied exceeds the maximum allowed by GITS_TYPER....
Bitfield< 0 > retry
uint32_t requestorId
Bitfield< 7, 4 > ittEntrySize
uint64_t maxCommands() const
Bitfield< 36 > cil
Bitfield< 51, 12 > physAddr
Bitfield< 17, 13 > devBits
Bitfield< 1 > _virtual
Bitfield< 7, 4 > itsNumber
Bitfield< 55, 53 > outerCache
static const uint64_t BASER_WMASK
static const AddrRange GITS_BASER
void setGIC(Gicv3 *_gic)
static const uint64_t BASER_TYPE
static const uint32_t itsControl
Bitfield< 31, 24 > hcc
static const uint64_t BASER_ESZ
Bitfield< 37 > vmovp
bool recvTimingResp(PacketPtr pkt)
Bitfield< 45, 30 > icid
BitUnion32(CTLR) Bitfield< 31 > quiescent
std::queue< ItsAction > packetsToRetry
Bitfield< 15, 2 > intNum
void incrementReadPointer()
uint32_t pendingTranslations
An ItsCommand is created whenever there is a new command in the command queue.
void movall(Yield &yield, CommandEntry &command)
bool sizeOutOfRange(CommandEntry &command) const
void doInt(Yield &yield, CommandEntry &command)
bool idOutOfRange(CommandEntry &command, DTE dte) const
ItsCommand(Gicv3Its &_its)
void sync(Yield &yield, CommandEntry &command)
void vsync(Yield &yield, CommandEntry &command)
void invall(Yield &yield, CommandEntry &command)
void vmapp(Yield &yield, CommandEntry &command)
void readCommand(Yield &yield, CommandEntry &command)
void mapd(Yield &yield, CommandEntry &command)
void discard(Yield &yield, CommandEntry &command)
void processCommand(Yield &yield, CommandEntry &command)
void vmovp(Yield &yield, CommandEntry &command)
void vmovi(Yield &yield, CommandEntry &command)
void vmapti(Yield &yield, CommandEntry &command)
void clear(Yield &yield, CommandEntry &command)
void movi(Yield &yield, CommandEntry &command)
void mapc(Yield &yield, CommandEntry &command)
void vinvall(Yield &yield, CommandEntry &command)
void vmapi(Yield &yield, CommandEntry &command)
static std::string commandName(uint32_t cmd)
bool deviceOutOfRange(CommandEntry &command) const
static DispatchTable cmdDispatcher
std::unordered_map< std::underlying_type< enum CommandType >::type, DispatchEntry > DispatchTable
bool collectionOutOfRange(CommandEntry &command) const
void mapi(Yield &yield, CommandEntry &command)
void mapti(Yield &yield, CommandEntry &command)
ItsProcess is a base coroutine wrapper which is spawned by the Gicv3Its module when the latter needs ...
void writeIrqTranslationTable(Yield &yield, const Addr itt_base, uint32_t event_id, ITTE itte)
uint64_t readIrqCollectionTable(Yield &yield, uint32_t collection_id)
const std::string name() const
Returns the Gicv3Its name.
Definition gic_v3_its.cc:81
void terminate(Yield &yield)
Gicv3Its::DTE DTE
virtual ~ItsProcess()
Definition gic_v3_its.cc:69
Coroutine::CallerType Yield
ItsAction run(PacketPtr pkt)
Definition gic_v3_its.cc:87
void writeDeviceTable(Yield &yield, uint32_t device_id, DTE dte)
void doWrite(Yield &yield, Addr addr, void *ptr, size_t size)
ItsProcess(Gicv3Its &_its)
Definition gic_v3_its.cc:64
std::unique_ptr< Coroutine > coroutine
void doRead(Yield &yield, Addr addr, void *ptr, size_t size)
Definition gic_v3_its.cc:95
gem5::Coroutine< PacketPtr, ItsAction > Coroutine
uint64_t readIrqTranslationTable(Yield &yield, const Addr itt_base, uint32_t event_id)
Gicv3Its::CTE CTE
virtual void main(Yield &yield)=0
uint64_t readDeviceTable(Yield &yield, uint32_t device_id)
void writeIrqCollectionTable(Yield &yield, uint32_t collection_id, CTE cte)
Gicv3Its::ITTE ITTE
An ItsTranslation is created whenever a peripheral writes a message in GITS_TRANSLATER (MSI).
ItsTranslation(Gicv3Its &_its)
std::pair< uint32_t, Gicv3Redistributor * > translateLPI(Yield &yield, uint32_t device_id, uint32_t event_id)
const std::string _name
Definition named.hh:54
Ports are used to interface objects to each other.
Definition port.hh:62
RequestPort(const std::string &name, SimObject *_owner, PortID id=InvalidPortID)
Request port.
Definition port.cc:125
STL pair class.
Definition stl.hh:58
int main()
std::list< AddrRange > AddrRangeList
Convenience typedef for a collection of address ranges.
Definition addr_range.hh:64
constexpr T bits(T val, unsigned first, unsigned last)
Extract the bitfield from position 'first' to 'last' (inclusive) from 'val' and right justify it.
Definition bitfield.hh:79
#define BitUnion64(name)
Use this to define conveniently sized values overlayed with bitfields.
Definition bitunion.hh:494
DrainState
Object drain/handover states.
Definition drain.hh:76
const Params & params() const
Bitfield< 23 > inv
Definition misc.hh:843
Bitfield< 3 > addr
Definition types.hh:84
Bitfield< 15, 8 > vector
Definition intmessage.hh:48
Copyright (c) 2024 Arm Limited All rights reserved.
Definition binary32.hh:36
std::ostream CheckpointOut
Definition serialize.hh:66
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition types.hh:147
ItsActionType
Definition gic_v3_its.hh:64
int16_t PortID
Port index/ID type, and a symbolic name for an invalid port id.
Definition types.hh:245
uint64_t Tick
Tick count type.
Definition types.hh:58
Packet * PacketPtr
Overload hash function for BasicBlockRange type.
Definition binary32.hh:81
PacketPtr pkt
Definition gic_v3_its.hh:73
ItsActionType type
Definition gic_v3_its.hh:72
Dispatch entry is a metadata struct which contains information about the command (like the name) and ...
DispatchEntry(std::string _name, ExecFn _exec)
std::function< void(ItsCommand *, Yield &, CommandEntry &)> ExecFn
A virtual base opaque structure used to hold state associated with the packet (e.g....
Definition packet.hh:469

Generated on Mon Oct 27 2025 04:13:01 for gem5 by doxygen 1.14.0