blob: 5e45ed9f652dce4ea1628e742db8dea86a3a234e [file] [log] [blame]
Matthias Jung8723b082015-08-03 23:08:40 -05001/*
2 * Copyright (c) 2015, University of Kaiserslautern
Christian Menardb25ea092017-02-09 19:15:30 -05003 * Copyright (c) 2016, Dresden University of Technology (TU Dresden)
Matthias Jung8723b082015-08-03 23:08:40 -05004 * 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.
Matthias Jung8723b082015-08-03 23:08:40 -050032 */
33
34#include "sc_ext.hh"
35
36using namespace tlm;
37
Christian Menardb25ea092017-02-09 19:15:30 -050038namespace Gem5SystemC
39{
40
41Gem5Extension::Gem5Extension(PacketPtr packet)
Matthias Jung8723b082015-08-03 23:08:40 -050042{
43 Packet = packet;
Christian Menardb5045002017-02-09 19:15:43 -050044 pipeThrough = false;
Matthias Jung8723b082015-08-03 23:08:40 -050045}
46
Christian Menardb25ea092017-02-09 19:15:30 -050047Gem5Extension& Gem5Extension::getExtension(const tlm_generic_payload *payload)
Matthias Jung8723b082015-08-03 23:08:40 -050048{
Christian Menardb25ea092017-02-09 19:15:30 -050049 Gem5Extension *result = NULL;
Matthias Jung8723b082015-08-03 23:08:40 -050050 payload->get_extension(result);
51 sc_assert(result!=NULL);
52 return *result;
53}
54
Christian Menardb25ea092017-02-09 19:15:30 -050055Gem5Extension& Gem5Extension::getExtension(const tlm_generic_payload &payload)
Matthias Jung8723b082015-08-03 23:08:40 -050056{
Christian Menardb25ea092017-02-09 19:15:30 -050057 return Gem5Extension::getExtension(&payload);
Matthias Jung8723b082015-08-03 23:08:40 -050058}
59
Christian Menardb25ea092017-02-09 19:15:30 -050060PacketPtr Gem5Extension::getPacket()
Matthias Jung8723b082015-08-03 23:08:40 -050061{
62 return Packet;
63}
64
Christian Menardb25ea092017-02-09 19:15:30 -050065tlm_extension_base* Gem5Extension::clone() const
Matthias Jung8723b082015-08-03 23:08:40 -050066{
Christian Menardb25ea092017-02-09 19:15:30 -050067 return new Gem5Extension(Packet);
Matthias Jung8723b082015-08-03 23:08:40 -050068}
69
Christian Menardb25ea092017-02-09 19:15:30 -050070void Gem5Extension::copy_from(const tlm_extension_base& ext)
Matthias Jung8723b082015-08-03 23:08:40 -050071{
Christian Menardb25ea092017-02-09 19:15:30 -050072 const Gem5Extension& cpyFrom = static_cast<const Gem5Extension&>(ext);
Matthias Jung8723b082015-08-03 23:08:40 -050073 Packet = cpyFrom.Packet;
74}
Christian Menardb25ea092017-02-09 19:15:30 -050075
76}