gem5  v22.1.0.0
sc_ext.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015, University of Kaiserslautern
3  * Copyright (c) 2016, Dresden University of Technology (TU Dresden)
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions are
8  * met:
9  *
10  * 1. Redistributions of source code must retain the above copyright notice,
11  * this list of conditions and the following disclaimer.
12  *
13  * 2. Redistributions in binary form must reproduce the above copyright
14  * notice, this list of conditions and the following disclaimer in the
15  * documentation and/or other materials provided with the distribution.
16  *
17  * 3. Neither the name of the copyright holder nor the names of its
18  * contributors may be used to endorse or promote products derived from
19  * this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
23  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
24  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER
25  * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
26  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
27  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
28  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
29  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
30  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
31  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32  */
33 
35 
39 
40 using namespace gem5;
41 
42 namespace Gem5SystemC
43 {
44 namespace
45 {
46 
47 struct ControlConversionRegister
48 {
49  ControlConversionRegister()
50  {
52  [] (PacketPtr pkt, tlm::tlm_generic_payload &trans)
53  {
54  ControlExtension *control_ex = nullptr;
55  trans.get_extension(control_ex);
56  if (!control_ex) {
57  return;
58  }
59 
60  if (control_ex->isPrivileged()) {
61  pkt->req->setFlags(Request::PRIVILEGED);
62  } else {
63  pkt->req->clearFlags(Request::PRIVILEGED);
64  }
65 
66  if (control_ex->isSecure()) {
67  pkt->req->setFlags(Request::SECURE);
68  } else {
69  pkt->req->clearFlags(Request::SECURE);
70  }
71 
72  if (control_ex->isInstruction()) {
73  pkt->req->setFlags(Request::INST_FETCH);
74  } else {
75  pkt->req->clearFlags(Request::INST_FETCH);
76  }
77 
78  pkt->qosValue(control_ex->getQos());
79  });
81  [] (PacketPtr pkt, tlm::tlm_generic_payload &trans)
82  {
83  ControlExtension *control_ex = nullptr;
84  trans.get_extension(control_ex);
85  if (!control_ex) {
86  return;
87  }
88 
89  control_ex->setPrivileged(pkt->req->isPriv());
90  control_ex->setSecure(pkt->req->isSecure());
91  control_ex->setInstruction(pkt->req->isInstFetch());
92  control_ex->setQos(pkt->qosValue());
93  });
94  }
95 };
96 
97 } // namespace
98 
99 Gem5Extension::Gem5Extension(PacketPtr p) : packet(p)
100 {
101 }
102 
105 {
106  Gem5Extension *result = nullptr;
107  payload->get_extension(result);
108  sc_assert(result != nullptr);
109  return *result;
110 }
111 
114 {
115  return Gem5Extension::getExtension(&payload);
116 }
117 
118 PacketPtr
120 {
121  return packet;
122 }
123 
126 {
127  return new Gem5Extension(packet);
128 }
129 
130 void
132 {
133  const Gem5Extension &from = static_cast<const Gem5Extension &>(ext);
134  packet = from.packet;
135 }
136 
138  std::shared_ptr<gem5::AtomicOpFunctor> o, bool r)
139  : op(o), returnRequired(r)
140 {
141 }
142 
145 {
146  return new AtomicExtension(*this);
147 }
148 
149 void
151 {
152  const AtomicExtension &from = static_cast<const AtomicExtension &>(ext);
153  *this = from;
154 }
155 
158 {
159  return AtomicExtension::getExtension(&payload);
160 }
161 
164 {
165  AtomicExtension *result = nullptr;
166  payload->get_extension(result);
167  sc_assert(result);
168  return *result;
169 }
170 
171 bool
173 {
174  return returnRequired;
175 }
176 
179 {
180  return op.get();
181 }
182 
184  : privileged(false), secure(false), instruction(false), qos(0)
185 {
186  [[maybe_unused]] static ControlConversionRegister *conversion_register =
187  new ControlConversionRegister();
188 }
189 
192 {
193  return new ControlExtension(*this);
194 }
195 
196 void
198 {
199  const ControlExtension &from = static_cast<const ControlExtension &>(ext);
200  *this = from;
201 }
202 
205 {
206  return ControlExtension::getExtension(&payload);
207 }
208 
211 {
212  ControlExtension *result = nullptr;
213  payload->get_extension(result);
214  sc_assert(result);
215  return *result;
216 }
217 
218 bool
220 {
221  return privileged;
222 }
223 
224 void
226 {
227  privileged = p;
228 }
229 
230 bool
232 {
233  return secure;
234 }
235 
236 void
238 {
239  secure = s;
240 }
241 
242 bool
244 {
245  return instruction;
246 }
247 
248 void
250 {
251  instruction = i;
252 }
253 
254 uint8_t
256 {
257  return qos;
258 }
259 
260 void
262 {
263  qos = q;
264 }
265 
266 } // namespace Gem5SystemC
tlm_extension_base * clone() const override
Definition: sc_ext.cc:144
void copy_from(const tlm_extension_base &ext) override
Definition: sc_ext.cc:150
static AtomicExtension & getExtension(const tlm::tlm_generic_payload *payload)
Definition: sc_ext.cc:163
AtomicExtension(std::shared_ptr< gem5::AtomicOpFunctor > o, bool r)
Definition: sc_ext.cc:137
std::shared_ptr< gem5::AtomicOpFunctor > op
Definition: sc_ext.hh:89
bool isReturnRequired() const
Definition: sc_ext.cc:172
gem5::AtomicOpFunctor * getAtomicOpFunctor() const
Definition: sc_ext.cc:178
static ControlExtension & getExtension(const tlm::tlm_generic_payload *payload)
Definition: sc_ext.cc:210
tlm_extension_base * clone() const override
Definition: sc_ext.cc:191
void setPrivileged(bool p)
Definition: sc_ext.cc:225
bool isInstruction() const
Definition: sc_ext.cc:243
void setQos(uint8_t q)
Definition: sc_ext.cc:261
void setInstruction(bool i)
Definition: sc_ext.cc:249
uint8_t getQos() const
Definition: sc_ext.cc:255
void copy_from(const tlm_extension_base &ext) override
Definition: sc_ext.cc:197
static Gem5Extension & getExtension(const tlm::tlm_generic_payload *payload)
Definition: sc_ext.cc:104
Gem5Extension(gem5::PacketPtr p)
Definition: sc_ext.cc:99
tlm_extension_base * clone() const override
Definition: sc_ext.cc:125
gem5::PacketPtr getPacket()
Definition: sc_ext.cc:119
gem5::PacketPtr packet
Definition: sc_ext.hh:68
void copy_from(const tlm_extension_base &ext) override
Definition: sc_ext.cc:131
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition: packet.hh:294
uint8_t qosValue() const
QoS Value getter Returns 0 if QoS value was never set (constructor default).
Definition: packet.hh:767
RequestPtr req
A pointer to the original request.
Definition: packet.hh:376
void get_extension(T *&ext) const
Definition: gp.hh:364
Bitfield< 27 > q
Definition: misc_types.hh:55
Bitfield< 7 > i
Definition: misc_types.hh:67
Bitfield< 12 > ext
Definition: misc_types.hh:434
constexpr RegId o(int index)
Definition: int.hh:147
Bitfield< 5 > r
Definition: pagetable.hh:60
Bitfield< 1 > s
Definition: pagetable.hh:64
Bitfield< 54 > p
Definition: pagetable.hh:70
Bitfield< 4 > op
Definition: types.hh:83
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
void addPayloadToPacketConversionStep(PayloadToPacketConversionStep step)
Notify the Tlm2Gem5 bridge that we need an extra step to properly convert a tlm payload to gem5 packe...
Definition: tlm_to_gem5.cc:96
void addPacketToPayloadConversionStep(PacketToPayloadConversionStep step)
Notify the Gem5ToTlm bridge that we need an extra step to properly convert a gem5 packet to tlm paylo...
Definition: gem5_to_tlm.cc:119
#define sc_assert(expr)

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