gem5  v22.1.0.0
smmu_v3_transl.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013, 2018-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_SMMU_V3_TRANSL_HH__
39 #define __DEV_ARM_SMMU_V3_TRANSL_HH__
40 
41 #include "base/compiler.hh"
43 #include "dev/arm/smmu_v3_proc.hh"
44 #include "mem/packet.hh"
45 
46 namespace gem5
47 {
48 
49 namespace ArmISA
50 {
51 struct PageTableOps;
52 }
53 
55 {
57  unsigned size;
58  uint32_t sid; // streamId
59  uint32_t ssid; // substreamId
60  bool isWrite;
61  bool isPrefetch;
63 
65 
66  static SMMUTranslRequest fromPacket(PacketPtr pkt, bool ats = false);
67  static SMMUTranslRequest prefetch(Addr addr, uint32_t sid, uint32_t ssid);
68 };
69 
71 {
72  private:
74  {
78  uint16_t asid;
79  uint16_t vmid;
82  uint8_t t0sz;
83  uint8_t s2t0sz;
84  };
85 
86  enum FaultType
87  {
89  FAULT_TRANSLATION, // F_TRANSLATION
90  FAULT_PERMISSION, // F_PERMISSION
91  };
92 
93  struct TranslResult
94  {
98  bool writable;
99  };
100 
102 
105 
108 
109  virtual void main(Yield &yield);
110 
111  TranslResult bypass(Addr addr) const;
113 
114  bool microTLBLookup(Yield &yield, TranslResult &tr);
115  bool ifcTLBLookup(Yield &yield, TranslResult &tr, bool &wasPrefetched);
116  bool smmuTLBLookup(Yield &yield, TranslResult &tr);
117 
118  void microTLBUpdate(Yield &yield, const TranslResult &tr);
119  void ifcTLBUpdate(Yield &yield, const TranslResult &tr);
120  void smmuTLBUpdate(Yield &yield, const TranslResult &tr);
121 
122  bool configCacheLookup(Yield &yield, TranslContext &tc);
123  void configCacheUpdate(Yield &yield, const TranslContext &tc);
124  bool findConfig(Yield &yield, TranslContext &tc, TranslResult &tr);
125 
126  void walkCacheLookup(Yield &yield,
127  const WalkCache::Entry *&walkEntry,
128  Addr addr, uint16_t asid, uint16_t vmid,
129  unsigned stage, unsigned level);
130 
131  void walkCacheUpdate(Yield &yield, Addr va, Addr vaMask, Addr pa,
132  unsigned stage, unsigned level,
133  bool leaf, uint8_t permissions);
134 
136  const ArmISA::PageTableOps *pt_ops,
137  unsigned level, Addr walkPtr);
138 
139  TranslResult walkStage2(Yield &yield, Addr addr, bool final_tr,
140  const ArmISA::PageTableOps *pt_ops,
141  unsigned level, Addr walkPtr);
142 
144  TranslResult translateStage2(Yield &yield, Addr addr, bool final_tr);
145 
147  const TranslResult &s2tr) const;
148 
154  bool hazard4kCheck();
155  void hazard4kRegister();
156  void hazard4kHold(Yield &yield);
157  void hazard4kRelease();
158 
163  void hazardIdRegister();
164  void hazardIdHold(Yield &yield);
165  void hazardIdRelease();
166 
167  void issuePrefetch(Addr addr);
168 
169  void completeTransaction(Yield &yield, const TranslResult &tr);
170  void completePrefetch(Yield &yield);
171 
172  void sendEvent(Yield &yield, const SMMUEvent &ev);
173 
174  void doReadSTE(Yield &yield, StreamTableEntry &ste, uint32_t sid);
175  void doReadCD(Yield &yield, ContextDescriptor &cd,
176  const StreamTableEntry &ste, uint32_t sid, uint32_t ssid);
177  void doReadConfig(Yield &yield, Addr addr, void *ptr, size_t size,
178  uint32_t sid, uint32_t ssid);
179  void doReadPTE(Yield &yield, Addr va, Addr addr, void *ptr,
180  unsigned stage, unsigned level);
181 
182  public:
183  SMMUTranslationProcess(const std::string &name, SMMUv3 &_smmu,
184  SMMUv3DeviceInterface &_ifc);
185 
186  virtual ~SMMUTranslationProcess();
187 
188  void beginTransaction(const SMMUTranslRequest &req);
189  void resumeTransaction();
190 };
191 
192 } // namespace gem5
193 
194 #endif /* __DEV_ARM_SMMU_V3_TRANSL_HH__ */
CallerType: A reference to an object of this class will be passed to the coroutine task.
Definition: coroutine.hh:86
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition: packet.hh:294
const std::string name() const
bool ifcTLBLookup(Yield &yield, TranslResult &tr, bool &wasPrefetched)
void configCacheUpdate(Yield &yield, const TranslContext &tc)
TranslResult translateStage1And2(Yield &yield, Addr addr)
void smmuTLBUpdate(Yield &yield, const TranslResult &tr)
SMMUTranslationProcess(const std::string &name, SMMUv3 &_smmu, SMMUv3DeviceInterface &_ifc)
TranslResult smmuTranslation(Yield &yield)
TranslResult bypass(Addr addr) const
void beginTransaction(const SMMUTranslRequest &req)
void doReadCD(Yield &yield, ContextDescriptor &cd, const StreamTableEntry &ste, uint32_t sid, uint32_t ssid)
bool findConfig(Yield &yield, TranslContext &tc, TranslResult &tr)
void walkCacheLookup(Yield &yield, const WalkCache::Entry *&walkEntry, Addr addr, uint16_t asid, uint16_t vmid, unsigned stage, unsigned level)
bool smmuTLBLookup(Yield &yield, TranslResult &tr)
virtual void main(Yield &yield)
void hazardIdRegister()
Used to force ordering on transactions with the same orderId.
TranslResult walkStage2(Yield &yield, Addr addr, bool final_tr, const ArmISA::PageTableOps *pt_ops, unsigned level, Addr walkPtr)
TranslResult translateStage2(Yield &yield, Addr addr, bool final_tr)
void doReadConfig(Yield &yield, Addr addr, void *ptr, size_t size, uint32_t sid, uint32_t ssid)
void hazard4kHold(Yield &yield)
void doReadSTE(Yield &yield, StreamTableEntry &ste, uint32_t sid)
void hazardIdHold(Yield &yield)
SMMUv3DeviceInterface & ifc
bool microTLBLookup(Yield &yield, TranslResult &tr)
bool configCacheLookup(Yield &yield, TranslContext &tc)
bool hazard4kCheck()
Used to force ordering on transactions with same (SID, SSID, 4k page) to avoid multiple identical pag...
void ifcTLBUpdate(Yield &yield, const TranslResult &tr)
TranslResult walkStage1And2(Yield &yield, Addr addr, const ArmISA::PageTableOps *pt_ops, unsigned level, Addr walkPtr)
void sendEvent(Yield &yield, const SMMUEvent &ev)
void microTLBUpdate(Yield &yield, const TranslResult &tr)
void doReadPTE(Yield &yield, Addr va, Addr addr, void *ptr, unsigned stage, unsigned level)
void walkCacheUpdate(Yield &yield, Addr va, Addr vaMask, Addr pa, unsigned stage, unsigned level, bool leaf, uint8_t permissions)
void completePrefetch(Yield &yield)
GEM5_CLASS_VAR_USED Tick faultTick
TranslResult combineTranslations(const TranslResult &s1tr, const TranslResult &s2tr) const
void completeTransaction(Yield &yield, const TranslResult &tr)
#define GEM5_CLASS_VAR_USED
Definition: compiler.hh:141
Bitfield< 32 > cd
Definition: misc_types.hh:258
Bitfield< 39, 12 > pa
Definition: misc_types.hh:663
Bitfield< 8 > va
Definition: misc_types.hh:282
Bitfield< 20 > level
Definition: intmessage.hh:51
Bitfield< 3 > addr
Definition: types.hh:84
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:147
uint64_t Tick
Tick count type.
Definition: types.hh:58
Declaration of the Packet class.
static SMMUTranslRequest fromPacket(PacketPtr pkt, bool ats=false)
static SMMUTranslRequest prefetch(Addr addr, uint32_t sid, uint32_t ssid)

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