gem5  v22.1.0.0
smmu_v3.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013, 2018-2020 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_SMMU_V3_HH__
39 #define __DEV_ARM_SMMU_V3_HH__
40 
41 #include <list>
42 #include <map>
43 #include <queue>
44 #include <string>
45 #include <vector>
46 
47 #include "base/statistics.hh"
50 #include "dev/arm/smmu_v3_defs.hh"
53 #include "dev/arm/smmu_v3_ports.hh"
54 #include "dev/arm/smmu_v3_proc.hh"
55 #include "mem/packet.hh"
56 #include "params/SMMUv3.hh"
57 #include "sim/clocked_object.hh"
58 #include "sim/eventq.hh"
59 
79 namespace gem5
80 {
81 
82 class SMMUTranslationProcess;
83 
84 class SMMUv3 : public ClockedObject
85 {
86  protected:
87 
88  friend class SMMUProcess;
89  friend class SMMUTranslationProcess;
90  friend class SMMUCommandExecProcess;
91  friend class SMMUv3DeviceInterface;
92 
93  const System &system;
95 
99 
100  const bool irqInterfaceEnable;
101 
106 
107  const bool tlbEnable;
108  const bool configCacheEnable;
109  const bool ipaCacheEnable;
110  const bool walkCacheEnable;
112 
114  const unsigned walkCacheS1Levels;
115  const unsigned walkCacheS2Levels;
116  const unsigned requestPortWidth; // in bytes
117 
125 
126  SMMUSemaphore transSem; // max N transactions in SMMU
127  SMMUSemaphore ptwSem; // max N concurrent PTWs
128  SMMUSemaphore cycleSem; // max 1 table walk per cycle
129 
130  // Timing parameters
131  const Cycles tlbLat;
135  const Cycles ipaLat;
137 
138  // Stats
140  {
148  } stats;
149 
151 
153 
156 
157  bool inSecureBlock(uint32_t offs) const;
158 
159  std::queue<SMMUAction> packetsToRetry;
160  std::queue<SMMUAction> packetsTableWalkToRetry;
161 
162 
163  void scheduleDeviceRetries();
164 
168 
169  void processCommands();
171 
172  void processCommand(const SMMUCommand &cmd);
173 
174  public:
175  SMMUv3(const SMMUv3Params &p);
176  virtual ~SMMUv3() {}
177 
178  virtual void init() override;
179 
182  bool recvTimingResp(PacketPtr pkt);
183  void recvReqRetry();
184 
186  void tableWalkRecvReqRetry();
187 
190 
191  DrainState drain() override;
192  void serialize(CheckpointOut &cp) const override;
193  void unserialize(CheckpointIn &cp) override;
194 
195  virtual Port &getPort(const std::string &name,
196  PortID id = InvalidPortID) override;
197 };
198 
199 } // namespace gem5
200 
201 #endif /* __DEV_ARM_SMMU_V3_HH__ */
The AddrRange class encapsulates an address range, and supports a number of tests to check if two ran...
Definition: addr_range.hh:82
The ClockedObject class extends the SimObject with a clock and accessor functions to relate ticks to ...
Cycles is a wrapper class for representing cycle counts, i.e.
Definition: types.hh:79
virtual std::string name() const
Definition: named.hh:47
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition: packet.hh:294
Ports are used to interface objects to each other.
Definition: port.hh:62
const System & system
Definition: smmu_v3.hh:93
const Cycles tlbLat
Definition: smmu_v3.hh:131
const bool ipaCacheEnable
Definition: smmu_v3.hh:109
const unsigned requestPortWidth
Definition: smmu_v3.hh:116
SMMUCommandExecProcess commandExecutor
Definition: smmu_v3.hh:152
gem5::SMMUv3::SMMUv3Stats stats
const AddrRange regsMap
Definition: smmu_v3.hh:154
Tick readControl(PacketPtr pkt)
Definition: smmu_v3.cc:571
SMMUSemaphore requestPortSem
Definition: smmu_v3.hh:124
const bool irqInterfaceEnable
Definition: smmu_v3.hh:100
Tick recvAtomic(PacketPtr pkt, PortID id)
void recvReqRetry()
Definition: smmu_v3.cc:150
SMMUSemaphore walkSem
Definition: smmu_v3.hh:123
void serialize(CheckpointOut &cp) const override
Serialize an object.
Definition: smmu_v3.cc:780
SMMUAction runProcess(SMMUProcess *proc, PacketPtr pkt)
Definition: smmu_v3.cc:225
virtual ~SMMUv3()
Definition: smmu_v3.hh:176
const bool configCacheEnable
Definition: smmu_v3.hh:108
SMMUSemaphore ptwSem
Definition: smmu_v3.hh:127
SMMUSemaphore cycleSem
Definition: smmu_v3.hh:128
std::vector< SMMUv3DeviceInterface * > deviceInterfaces
Definition: smmu_v3.hh:150
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition: smmu_v3.cc:788
SMMUSemaphore tlbSem
Definition: smmu_v3.hh:118
ARMArchTLB tlb
Definition: smmu_v3.hh:102
SMMUSemaphore transSem
Definition: smmu_v3.hh:126
ConfigCache configCache
Definition: smmu_v3.hh:103
SMMUControlPort controlPort
Definition: smmu_v3.hh:98
SMMUTableWalkPort tableWalkPort
Definition: smmu_v3.hh:97
virtual void init() override
init() is called after all C++ SimObjects have been created and all ports are connected.
Definition: smmu_v3.cc:715
WalkCache walkCache
Definition: smmu_v3.hh:105
const Cycles configLat
Definition: smmu_v3.hh:134
SMMUAction runProcessAtomic(SMMUProcess *proc, PacketPtr pkt)
Definition: smmu_v3.cc:237
const bool tlbEnable
Definition: smmu_v3.hh:107
bool recvTimingResp(PacketPtr pkt)
Definition: smmu_v3.cc:133
const Cycles smmuIfcLat
Definition: smmu_v3.hh:133
bool inSecureBlock(uint32_t offs) const
Definition: smmu_v3.cc:706
const Cycles ifcSmmuLat
Definition: smmu_v3.hh:132
const bool walkCacheNonfinalEnable
Definition: smmu_v3.hh:113
virtual Port & getPort(const std::string &name, PortID id=InvalidPortID) override
Get a port with a given name and index.
Definition: smmu_v3.cc:796
Tick writeControl(PacketPtr pkt)
Definition: smmu_v3.cc:604
const Cycles walkLat
Definition: smmu_v3.hh:136
const unsigned walkCacheS1Levels
Definition: smmu_v3.hh:114
SMMURequestPort requestPort
Definition: smmu_v3.hh:96
const bool walkCacheEnable
Definition: smmu_v3.hh:110
void scheduleDeviceRetries()
Definition: smmu_v3.cc:217
std::queue< SMMUAction > packetsTableWalkToRetry
Definition: smmu_v3.hh:160
DrainState drain() override
Draining is the process of clearing out the states of SimObjects.These are the SimObjects that are pa...
Definition: smmu_v3.cc:770
const unsigned walkCacheS2Levels
Definition: smmu_v3.hh:115
IPACache ipaCache
Definition: smmu_v3.hh:104
bool tableWalkPortEnable
Definition: smmu_v3.hh:111
EventWrapper< SMMUv3, &SMMUv3::processCommands > processCommandsEvent
Definition: smmu_v3.hh:170
const RequestorID requestorId
Definition: smmu_v3.hh:94
std::queue< SMMUAction > packetsToRetry
Definition: smmu_v3.hh:159
bool recvTimingReq(PacketPtr pkt, PortID id)
SMMUSemaphore ifcSmmuSem
Definition: smmu_v3.hh:119
void processCommand(const SMMUCommand &cmd)
Definition: smmu_v3.cc:389
SMMUSemaphore smmuIfcSem
Definition: smmu_v3.hh:120
void tableWalkRecvReqRetry()
Definition: smmu_v3.cc:196
SMMURegs regs
Definition: smmu_v3.hh:155
SMMUv3(const SMMUv3Params &p)
Definition: smmu_v3.cc:58
void processCommands()
Definition: smmu_v3.cc:373
SMMUAction runProcessTiming(SMMUProcess *proc, PacketPtr pkt)
Definition: smmu_v3.cc:286
bool tableWalkRecvTimingResp(PacketPtr pkt)
Definition: smmu_v3.cc:179
const Cycles ipaLat
Definition: smmu_v3.hh:135
SMMUSemaphore configSem
Definition: smmu_v3.hh:121
SMMUSemaphore ipaSem
Definition: smmu_v3.hh:122
A simple distribution stat.
Definition: statistics.hh:2085
Statistics container.
Definition: group.hh:94
This is a simple scalar statistic, like a counter.
Definition: statistics.hh:1931
STL vector class.
Definition: stl.hh:37
ClockedObject declaration and implementation.
DrainState
Object drain/handover states.
Definition: drain.hh:75
Bitfield< 54 > p
Definition: pagetable.hh:70
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
const PortID InvalidPortID
Definition: types.hh:246
std::ostream CheckpointOut
Definition: serialize.hh:66
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
uint16_t RequestorID
Definition: request.hh:95
Declaration of the Packet class.
Declaration of Statistics objects.
SMMUv3Stats(statistics::Group *parent)
Definition: smmu_v3.cc:735
statistics::Distribution ptwTimeDist
Definition: smmu_v3.hh:147
statistics::Scalar cdL1Fetches
Definition: smmu_v3.hh:144
statistics::Scalar steL1Fetches
Definition: smmu_v3.hh:142
statistics::Scalar steFetches
Definition: smmu_v3.hh:143
statistics::Distribution translationTimeDist
Definition: smmu_v3.hh:146
statistics::Scalar cdFetches
Definition: smmu_v3.hh:145

Generated on Wed Dec 21 2022 10:22:33 for gem5 by doxygen 1.9.1