gem5 v24.0.0.0
Loading...
Searching...
No Matches
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
36#include <optional>
37
41
42using namespace gem5;
43
44namespace Gem5SystemC
45{
46namespace
47{
48
49struct ControlConversionRegister
50{
51 ControlConversionRegister()
52 {
54 [] (PacketPtr pkt, tlm::tlm_generic_payload &trans)
55 {
56 ControlExtension *control_ex = nullptr;
57 trans.get_extension(control_ex);
58 if (!control_ex) {
59 return;
60 }
61
62 if (control_ex->isPrivileged()) {
63 pkt->req->setFlags(Request::PRIVILEGED);
64 } else {
65 pkt->req->clearFlags(Request::PRIVILEGED);
66 }
67
68 if (control_ex->isSecure()) {
69 pkt->req->setFlags(Request::SECURE);
70 } else {
71 pkt->req->clearFlags(Request::SECURE);
72 }
73
74 if (control_ex->isInstruction()) {
75 pkt->req->setFlags(Request::INST_FETCH);
76 } else {
77 pkt->req->clearFlags(Request::INST_FETCH);
78 }
79
80 pkt->qosValue(control_ex->getQos());
81
82 if (control_ex->hasStreamId()) {
83 pkt->req->setStreamId(control_ex->getStreamId().value());
84 }
85 if (control_ex->hasSubstreamId()) {
86 pkt->req->setSubstreamId(
87 control_ex->getSubstreamId().value());
88 }
89 });
91 [] (PacketPtr pkt, tlm::tlm_generic_payload &trans)
92 {
93 ControlExtension *control_ex = nullptr;
94 trans.get_extension(control_ex);
95 if (!control_ex) {
96 return;
97 }
98
99 control_ex->setPrivileged(pkt->req->isPriv());
100 control_ex->setSecure(pkt->req->isSecure());
101 control_ex->setInstruction(pkt->req->isInstFetch());
102 control_ex->setQos(pkt->qosValue());
103 if (pkt->req->hasStreamId()) {
104 control_ex->setStreamId(pkt->req->streamId());
105 }
106 if (pkt->req->hasSubstreamId()) {
107 control_ex->setSubstreamId(pkt->req->substreamId());
108 }
109 });
110 }
111};
112
113} // namespace
114
118
121{
122 Gem5Extension *result = nullptr;
123 payload->get_extension(result);
124 sc_assert(result != nullptr);
125 return *result;
126}
127
133
136{
137 return packet;
138}
139
142{
143 return new Gem5Extension(packet);
144}
145
146void
148{
149 const Gem5Extension &from = static_cast<const Gem5Extension &>(ext);
150 packet = from.packet;
151}
152
154 std::shared_ptr<gem5::AtomicOpFunctor> o, bool r)
155 : op(o), returnRequired(r)
156{
157}
158
161{
162 return new AtomicExtension(*this);
163}
164
165void
167{
168 const AtomicExtension &from = static_cast<const AtomicExtension &>(ext);
169 *this = from;
170}
171
177
180{
181 AtomicExtension *result = nullptr;
182 payload->get_extension(result);
183 sc_assert(result);
184 return *result;
185}
186
187bool
192
195{
196 return op.get();
197}
198
200 : privileged(false), secure(false), instruction(false), qos(0)
201{
202 [[maybe_unused]] static ControlConversionRegister *conversion_register =
203 new ControlConversionRegister();
204}
205
208{
209 return new ControlExtension(*this);
210}
211
212void
214{
215 const ControlExtension &from = static_cast<const ControlExtension &>(ext);
216 *this = from;
217}
218
224
227{
228 ControlExtension *result = nullptr;
229 payload->get_extension(result);
230 sc_assert(result);
231 return *result;
232}
233
234bool
236{
237 return privileged;
238}
239
240void
245
246bool
248{
249 return secure;
250}
251
252void
254{
255 secure = s;
256}
257
258bool
260{
261 return instruction;
262}
263
264void
269
270uint8_t
272{
273 return qos;
274}
275
276void
278{
279 qos = q;
280}
281
282bool
284{
285 return stream_id.has_value();
286}
287
288std::optional<uint32_t>
290{
291 return stream_id;
292}
293
294void
295ControlExtension::setStreamId(std::optional<uint32_t> s)
296{
297 stream_id = std::move(s);
298}
299
300bool
302{
303 return substream_id.has_value();
304}
305
306std::optional<uint32_t>
308{
309 return substream_id;
310}
311
312void
313ControlExtension::setSubstreamId(std::optional<uint32_t> s)
314{
315 substream_id = std::move(s);
316}
317
318} // namespace Gem5SystemC
tlm_extension_base * clone() const override
Definition sc_ext.cc:160
void copy_from(const tlm_extension_base &ext) override
Definition sc_ext.cc:166
static AtomicExtension & getExtension(const tlm::tlm_generic_payload *payload)
Definition sc_ext.cc:179
AtomicExtension(std::shared_ptr< gem5::AtomicOpFunctor > o, bool r)
Definition sc_ext.cc:153
std::shared_ptr< gem5::AtomicOpFunctor > op
Definition sc_ext.hh:90
bool isReturnRequired() const
Definition sc_ext.cc:188
gem5::AtomicOpFunctor * getAtomicOpFunctor() const
Definition sc_ext.cc:194
static ControlExtension & getExtension(const tlm::tlm_generic_payload *payload)
Definition sc_ext.cc:226
tlm_extension_base * clone() const override
Definition sc_ext.cc:207
std::optional< uint32_t > getSubstreamId() const
Definition sc_ext.cc:307
void setSubstreamId(std::optional< uint32_t > s)
Definition sc_ext.cc:313
std::optional< uint32_t > substream_id
Definition sc_ext.hh:138
void setStreamId(std::optional< uint32_t > s)
Definition sc_ext.cc:295
std::optional< uint32_t > stream_id
Definition sc_ext.hh:137
void copy_from(const tlm_extension_base &ext) override
Definition sc_ext.cc:213
std::optional< uint32_t > getStreamId() const
Definition sc_ext.cc:289
static Gem5Extension & getExtension(const tlm::tlm_generic_payload *payload)
Definition sc_ext.cc:120
Gem5Extension(gem5::PacketPtr p)
Definition sc_ext.cc:115
tlm_extension_base * clone() const override
Definition sc_ext.cc:141
gem5::PacketPtr getPacket()
Definition sc_ext.cc:135
gem5::PacketPtr packet
Definition sc_ext.hh:69
void copy_from(const tlm_extension_base &ext) override
Definition sc_ext.cc:147
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition packet.hh:295
uint8_t qosValue() const
QoS Value getter Returns 0 if QoS value was never set (constructor default).
Definition packet.hh:769
RequestPtr req
A pointer to the original request.
Definition packet.hh:377
void get_extension(T *&ext) const
Definition gp.hh:364
Bitfield< 4 > s
Bitfield< 27 > q
Definition misc_types.hh:55
Bitfield< 7 > i
Definition misc_types.hh:67
Bitfield< 12 > ext
Bitfield< 0 > p
Bitfield< 4 > op
Definition types.hh:83
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
Definition binary32.hh:36
void addPayloadToPacketConversionStep(PayloadToPacketConversionStep step)
Notify the Tlm2Gem5 bridge that we need an extra step to properly convert a tlm payload to gem5 packe...
void addPacketToPayloadConversionStep(PacketToPayloadConversionStep step)
Notify the Gem5ToTlm bridge that we need an extra step to properly convert a gem5 packet to tlm paylo...
#define sc_assert(expr)

Generated on Tue Jun 18 2024 16:24:07 for gem5 by doxygen 1.11.0