gem5 v24.0.0.0
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#include "params/Gicv3Its.hh"
52
53namespace gem5
54{
55
56class Gicv3;
57class Gicv3Redistributor;
58class ItsProcess;
59class ItsTranslation;
60class ItsCommand;
61
62enum class ItsActionType
63{
67};
68
75
84{
85 friend class gem5::ItsProcess;
87 friend class gem5::ItsCommand;
88
89 public:
90 class DataPort : public RequestPort
91 {
92 protected:
94
95 public:
96 DataPort(const std::string &_name, Gicv3Its &_its) :
98 its(_its)
99 {}
100
101 virtual ~DataPort() {}
102
103 bool recvTimingResp(PacketPtr pkt) { return its.recvTimingResp(pkt); }
104 void recvReqRetry() { return its.recvReqRetry(); }
105 };
106
108
109 Port & getPort(const std::string &if_name, PortID idx) override;
110 bool recvTimingResp(PacketPtr pkt);
111 void recvReqRetry();
112
113 Gicv3Its(const Gicv3ItsParams &params);
114
115 void setGIC(Gicv3 *_gic);
116
117 static const uint32_t itsControl = 0x0;
118 static const uint32_t itsTranslate = 0x10000;
119
120 // Address range part of Control frame
121 static const AddrRange GITS_BASER;
122
123 static const uint32_t NUM_BASER_REGS = 8;
124
125 // We currently don't support two level ITS tables
126 // The indirect bit is RAZ/WI for implementations that only
127 // support flat tables.
128 static const uint64_t BASER_INDIRECT = 0x4000000000000000;
129 static const uint64_t BASER_TYPE = 0x0700000000000000;
130 static const uint64_t BASER_ESZ = 0x001F000000000000;
131 static const uint64_t BASER_SZ = 0x00000000000000FF;
132 static const uint64_t BASER_WMASK =
134 static const uint64_t BASER_WMASK_UNIMPL =
136
137 // GITS_CTLR.quiescent mask
138 static const uint32_t CTLR_QUIESCENT;
139
140 enum : Addr
141 {
142 // Control frame
150
151 // Translation frame
153 };
154
155 AddrRangeList getAddrRanges() const override;
156
157 Tick read(PacketPtr pkt) override;
158 Tick write(PacketPtr pkt) override;
159
160 DrainState drain() override;
161 void serialize(CheckpointOut & cp) const override;
162 void unserialize(CheckpointIn & cp) override;
163
164 void translate(PacketPtr pkt);
165
167 Bitfield<31> quiescent;
168 Bitfield<7, 4> itsNumber;
169 Bitfield<1> imDe;
170 Bitfield<0> enabled;
172
173 // Command read/write, (CREADR, CWRITER)
174 BitUnion64(CRDWR)
175 Bitfield<63, 32> high;
176 Bitfield<31, 0> low;
177 Bitfield<19, 5> offset;
178 Bitfield<0> retry;
179 Bitfield<0> stalled;
181
182 BitUnion64(CBASER)
183 Bitfield<63, 32> high;
184 Bitfield<31, 0> low;
185 Bitfield<63> valid;
186 Bitfield<61, 59> innerCache;
187 Bitfield<55, 53> outerCache;
188 Bitfield<51, 12> physAddr;
189 Bitfield<11, 10> shareability;
190 Bitfield<7, 0> size;
192
193 BitUnion64(BASER)
194 Bitfield<63> valid;
195 Bitfield<62> indirect;
196 Bitfield<61, 59> innerCache;
197 Bitfield<58, 56> type;
198 Bitfield<55, 53> outerCache;
199 Bitfield<52, 48> entrySize;
200 Bitfield<47, 12> physAddr;
201 Bitfield<11, 10> shareability;
202 Bitfield<9, 8> pageSize;
203 Bitfield<7, 0> size;
205
206 BitUnion64(TYPER)
207 Bitfield<63, 32> high;
208 Bitfield<31, 0> low;
209 Bitfield<37> vmovp;
210 Bitfield<36> cil;
211 Bitfield<35, 32> cidBits;
212 Bitfield<31, 24> hcc;
213 Bitfield<19> pta;
214 Bitfield<18> seis;
215 Bitfield<17, 13> devBits;
216 Bitfield<12, 8> idBits;
217 Bitfield<7, 4> ittEntrySize;
218 Bitfield<2> cct;
219 Bitfield<1> _virtual;
220 Bitfield<0> physical;
222
223 CTLR gitsControl;
228 uint32_t gitsIidr;
230
232
237 bool idOutOfRange(uint32_t event_id, uint8_t itt_range) const;
238
244 bool deviceOutOfRange(uint32_t device_id) const;
245
252 bool sizeOutOfRange(uint32_t size) const;
253
259 bool collectionOutOfRange(uint32_t collection_id) const;
260
265 bool lpiOutOfRange(uint32_t intid) const;
266
267 private: // Command
268 uint64_t maxCommands() const;
269 void checkCommandQueue();
271
272 public: // TableWalk
274 Bitfield<57, 53> ittRange;
275 Bitfield<52, 1> ittAddress;
276 Bitfield<0> valid;
278
279 BitUnion64(ITTE)
280 Bitfield<59, 46> vpeid;
281 Bitfield<45, 30> icid;
282 Bitfield<29, 16> intNumHyp;
283 Bitfield<15, 2> intNum;
284 Bitfield<1> intType;
285 Bitfield<0> valid;
287
288 BitUnion64(CTE)
289 Bitfield<40, 1> rdBase;
290 Bitfield<0> valid;
292
293 enum InterruptType
294 {
295 VIRTUAL_INTERRUPT = 0,
296 PHYSICAL_INTERRUPT = 1
297 };
298
299 private:
300 Gicv3Redistributor* getRedistributor(uint64_t rd_base);
302 {
303 return getRedistributor(cte.rdBase);
304 }
305
309
317
324
325 Addr pageAddress(enum ItsTables table);
326
329
330 private:
331 std::queue<ItsAction> packetsToRetry;
332 uint32_t requestorId;
335
338};
339
356{
357 public:
358 using DTE = Gicv3Its::DTE;
359 using ITTE = Gicv3Its::ITTE;
360 using CTE = Gicv3Its::CTE;
363
364 ItsProcess(Gicv3Its &_its);
365 virtual ~ItsProcess();
366
368 const std::string name() const;
369
371
372 protected:
373 void reinit();
374 virtual void main(Yield &yield) = 0;
375
376 void writeDeviceTable(Yield &yield, uint32_t device_id, DTE dte);
377
379 Yield &yield, const Addr itt_base, uint32_t event_id, ITTE itte);
380
382 Yield &yield, uint32_t collection_id, CTE cte);
383
384 uint64_t readDeviceTable(
385 Yield &yield, uint32_t device_id);
386
388 Yield &yield, const Addr itt_base, uint32_t event_id);
389
390 uint64_t readIrqCollectionTable(Yield &yield, uint32_t collection_id);
391
392 void doRead(Yield &yield, Addr addr, void *ptr, size_t size);
393 void doWrite(Yield &yield, Addr addr, void *ptr, size_t size);
394 void terminate(Yield &yield);
395
396 protected:
398
399 private:
400 std::unique_ptr<Coroutine> coroutine;
401};
402
410{
411 public:
414
415 protected:
416 void main(Yield &yield) override;
417
419 translateLPI(Yield &yield, uint32_t device_id, uint32_t event_id);
420};
421
428class ItsCommand : public ItsProcess
429{
430 public:
432 {
433 struct
434 {
435 uint32_t type;
436 uint32_t deviceId;
437 uint32_t eventId;
438 uint32_t pintId;
439
440 uint32_t data[4];
441 };
442 uint64_t raw[4];
443 };
444
445 enum CommandType : uint32_t
446 {
447 CLEAR = 0x04,
448 DISCARD = 0x0F,
449 INT = 0x03,
450 INV = 0x0C,
451 INVALL = 0x0D,
452 MAPC = 0x09,
453 MAPD = 0x08,
454 MAPI = 0x0B,
455 MAPTI = 0x0A,
456 MOVALL = 0x0E,
457 MOVI = 0x01,
458 SYNC = 0x05,
459 VINVALL = 0x2D,
460 VMAPI = 0x2B,
461 VMAPP = 0x29,
462 VMAPTI = 0x2A,
463 VMOVI = 0x21,
464 VMOVP = 0x22,
465 VSYNC = 0x25
466 };
467
468 ItsCommand(Gicv3Its &_its);
469 ~ItsCommand();
470
471 protected:
478 {
479 using ExecFn = std::function<void(ItsCommand*, Yield&, CommandEntry&)>;
480
481 DispatchEntry(std::string _name, ExecFn _exec)
482 : name(_name), exec(_exec)
483 {}
484
485 std::string name;
487 };
488
489 using DispatchTable = std::unordered_map<
490 std::underlying_type<enum CommandType>::type, DispatchEntry>;
491
493
494 static std::string commandName(uint32_t cmd);
495
496 void main(Yield &yield) override;
497
498 void readCommand(Yield &yield, CommandEntry &command);
499 void processCommand(Yield &yield, CommandEntry &command);
500
501 // Commands
502 void clear(Yield &yield, CommandEntry &command);
503 void discard(Yield &yield, CommandEntry &command);
504 void mapc(Yield &yield, CommandEntry &command);
505 void mapd(Yield &yield, CommandEntry &command);
506 void mapi(Yield &yield, CommandEntry &command);
507 void mapti(Yield &yield, CommandEntry &command);
508 void movall(Yield &yield, CommandEntry &command);
509 void movi(Yield &yield, CommandEntry &command);
510 void sync(Yield &yield, CommandEntry &command);
511 void doInt(Yield &yield, CommandEntry &command);
512 void inv(Yield &yield, CommandEntry &command);
513 void invall(Yield &yield, CommandEntry &command);
514 void vinvall(Yield &yield, CommandEntry &command);
515 void vmapi(Yield &yield, CommandEntry &command);
516 void vmapp(Yield &yield, CommandEntry &command);
517 void vmapti(Yield &yield, CommandEntry &command);
518 void vmovi(Yield &yield, CommandEntry &command);
519 void vmovp(Yield &yield, CommandEntry &command);
520 void vsync(Yield &yield, CommandEntry &command);
521
522 protected: // Helpers
523 bool idOutOfRange(CommandEntry &command, DTE dte) const
524 {
525 return its.idOutOfRange(command.eventId, dte.ittRange);
526 }
527
528 bool deviceOutOfRange(CommandEntry &command) const
529 {
530 return its.deviceOutOfRange(command.deviceId);
531 }
532
533 bool sizeOutOfRange(CommandEntry &command) const
534 {
535 const auto size = bits(command.raw[1], 4, 0);
536 const auto valid = bits(command.raw[2], 63);
537 if (valid)
538 return its.sizeOutOfRange(size);
539 else
540 return false;
541 }
542
544 {
545 return its.collectionOutOfRange(bits(command.raw[2], 15, 0));
546 }
547};
548
549} // namespace gem5
550
551#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
CallerType: A reference to an object of this class will be passed to the coroutine task.
Definition coroutine.hh:85
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:96
GICv3 ITS module.
Definition gic_v3_its.hh:84
static const uint32_t CTLR_QUIESCENT
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:80
void terminate(Yield &yield)
Gicv3Its::DTE DTE
virtual ~ItsProcess()
Definition gic_v3_its.cc:68
ItsAction run(PacketPtr pkt)
Definition gic_v3_its.cc:86
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:63
std::unique_ptr< Coroutine > coroutine
void doRead(Yield &yield, Addr addr, void *ptr, size_t size)
Definition gic_v3_its.cc:94
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:41
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition packet.hh:295
Ports are used to interface objects to each other.
Definition port.hh:62
A RequestPort is a specialisation of a Port, which implements the default protocol for the three diff...
Definition port.hh:136
STL pair class.
Definition stl.hh:58
int main()
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
#define EndBitUnion(name)
This closes off the class and union started by the above macro.
Definition bitunion.hh:428
DrainState
Object drain/handover states.
Definition drain.hh:75
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 - Pranith Kumar Copyright (c) 2020 Inria 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:63
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
Overload hash function for BasicBlockRange type.
Definition binary32.hh:81
PacketPtr pkt
Definition gic_v3_its.hh:72
ItsActionType type
Definition gic_v3_its.hh:71
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 Tue Jun 18 2024 16:24:02 for gem5 by doxygen 1.11.0