113820Sgabeblack@google.com/*
213820Sgabeblack@google.com * Copyright (c) 2015, University of Kaiserslautern
313820Sgabeblack@google.com * Copyright (c) 2016, Dresden University of Technology (TU Dresden)
413820Sgabeblack@google.com * All rights reserved.
513820Sgabeblack@google.com *
613820Sgabeblack@google.com * Redistribution and use in source and binary forms, with or without
713820Sgabeblack@google.com * modification, are permitted provided that the following conditions are
813820Sgabeblack@google.com * met:
913820Sgabeblack@google.com *
1013820Sgabeblack@google.com * 1. Redistributions of source code must retain the above copyright notice,
1113820Sgabeblack@google.com *    this list of conditions and the following disclaimer.
1213820Sgabeblack@google.com *
1313820Sgabeblack@google.com * 2. Redistributions in binary form must reproduce the above copyright
1413820Sgabeblack@google.com *    notice, this list of conditions and the following disclaimer in the
1513820Sgabeblack@google.com *    documentation and/or other materials provided with the distribution.
1613820Sgabeblack@google.com *
1713820Sgabeblack@google.com * 3. Neither the name of the copyright holder nor the names of its
1813820Sgabeblack@google.com *    contributors may be used to endorse or promote products derived from
1913820Sgabeblack@google.com *    this software without specific prior written permission.
2013820Sgabeblack@google.com *
2113820Sgabeblack@google.com * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
2213820Sgabeblack@google.com * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
2313820Sgabeblack@google.com * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
2413820Sgabeblack@google.com * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER
2513820Sgabeblack@google.com * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
2613820Sgabeblack@google.com * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
2713820Sgabeblack@google.com * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
2813820Sgabeblack@google.com * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
2913820Sgabeblack@google.com * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
3013820Sgabeblack@google.com * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
3113820Sgabeblack@google.com * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3213820Sgabeblack@google.com *
3313820Sgabeblack@google.com * Authors:
3413820Sgabeblack@google.com *    Matthias Jung
3513820Sgabeblack@google.com *    Christian Menard
3613820Sgabeblack@google.com */
3713820Sgabeblack@google.com
3813820Sgabeblack@google.com#include "systemc/tlm_bridge/sc_ext.hh"
3913820Sgabeblack@google.com
4013820Sgabeblack@google.com#include "systemc/ext/utils/sc_report_handler.hh"
4113820Sgabeblack@google.com
4213820Sgabeblack@google.comnamespace Gem5SystemC
4313820Sgabeblack@google.com{
4413820Sgabeblack@google.com
4513820Sgabeblack@google.comGem5Extension::Gem5Extension(PacketPtr _packet)
4613820Sgabeblack@google.com{
4713820Sgabeblack@google.com    packet = _packet;
4813820Sgabeblack@google.com    pipeThrough = false;
4913820Sgabeblack@google.com}
5013820Sgabeblack@google.com
5113820Sgabeblack@google.comGem5Extension &
5213820Sgabeblack@google.comGem5Extension::getExtension(const tlm::tlm_generic_payload *payload)
5313820Sgabeblack@google.com{
5413820Sgabeblack@google.com    Gem5Extension *result = NULL;
5513820Sgabeblack@google.com    payload->get_extension(result);
5613820Sgabeblack@google.com    sc_assert(result != NULL);
5713820Sgabeblack@google.com    return *result;
5813820Sgabeblack@google.com}
5913820Sgabeblack@google.com
6013820Sgabeblack@google.comGem5Extension &
6113820Sgabeblack@google.comGem5Extension::getExtension(const tlm::tlm_generic_payload &payload)
6213820Sgabeblack@google.com{
6313820Sgabeblack@google.com    return Gem5Extension::getExtension(&payload);
6413820Sgabeblack@google.com}
6513820Sgabeblack@google.com
6613820Sgabeblack@google.comPacketPtr
6713820Sgabeblack@google.comGem5Extension::getPacket()
6813820Sgabeblack@google.com{
6913820Sgabeblack@google.com    return packet;
7013820Sgabeblack@google.com}
7113820Sgabeblack@google.com
7213820Sgabeblack@google.comtlm::tlm_extension_base *
7313820Sgabeblack@google.comGem5Extension::clone() const
7413820Sgabeblack@google.com{
7513820Sgabeblack@google.com    return new Gem5Extension(packet);
7613820Sgabeblack@google.com}
7713820Sgabeblack@google.com
7813820Sgabeblack@google.comvoid
7913820Sgabeblack@google.comGem5Extension::copy_from(const tlm::tlm_extension_base &ext)
8013820Sgabeblack@google.com{
8113820Sgabeblack@google.com    const Gem5Extension &cpyFrom = static_cast<const Gem5Extension &>(ext);
8213820Sgabeblack@google.com    packet = cpyFrom.packet;
8313820Sgabeblack@google.com}
8413820Sgabeblack@google.com
8513820Sgabeblack@google.com} // namespace Gem5SystemC
86