Matthias Jung | 8723b08 | 2015-08-03 23:08:40 -0500 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2015, University of Kaiserslautern |
Christian Menard | b25ea09 | 2017-02-09 19:15:30 -0500 | [diff] [blame] | 3 | * Copyright (c) 2016, Dresden University of Technology (TU Dresden) |
Matthias Jung | 8723b08 | 2015-08-03 23:08:40 -0500 | [diff] [blame] | 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. |
Matthias Jung | 8723b08 | 2015-08-03 23:08:40 -0500 | [diff] [blame] | 32 | */ |
| 33 | |
| 34 | #include "sc_ext.hh" |
| 35 | |
| 36 | using namespace tlm; |
| 37 | |
Christian Menard | b25ea09 | 2017-02-09 19:15:30 -0500 | [diff] [blame] | 38 | namespace Gem5SystemC |
| 39 | { |
| 40 | |
| 41 | Gem5Extension::Gem5Extension(PacketPtr packet) |
Matthias Jung | 8723b08 | 2015-08-03 23:08:40 -0500 | [diff] [blame] | 42 | { |
| 43 | Packet = packet; |
Christian Menard | b504500 | 2017-02-09 19:15:43 -0500 | [diff] [blame] | 44 | pipeThrough = false; |
Matthias Jung | 8723b08 | 2015-08-03 23:08:40 -0500 | [diff] [blame] | 45 | } |
| 46 | |
Christian Menard | b25ea09 | 2017-02-09 19:15:30 -0500 | [diff] [blame] | 47 | Gem5Extension& Gem5Extension::getExtension(const tlm_generic_payload *payload) |
Matthias Jung | 8723b08 | 2015-08-03 23:08:40 -0500 | [diff] [blame] | 48 | { |
Christian Menard | b25ea09 | 2017-02-09 19:15:30 -0500 | [diff] [blame] | 49 | Gem5Extension *result = NULL; |
Matthias Jung | 8723b08 | 2015-08-03 23:08:40 -0500 | [diff] [blame] | 50 | payload->get_extension(result); |
| 51 | sc_assert(result!=NULL); |
| 52 | return *result; |
| 53 | } |
| 54 | |
Christian Menard | b25ea09 | 2017-02-09 19:15:30 -0500 | [diff] [blame] | 55 | Gem5Extension& Gem5Extension::getExtension(const tlm_generic_payload &payload) |
Matthias Jung | 8723b08 | 2015-08-03 23:08:40 -0500 | [diff] [blame] | 56 | { |
Christian Menard | b25ea09 | 2017-02-09 19:15:30 -0500 | [diff] [blame] | 57 | return Gem5Extension::getExtension(&payload); |
Matthias Jung | 8723b08 | 2015-08-03 23:08:40 -0500 | [diff] [blame] | 58 | } |
| 59 | |
Christian Menard | b25ea09 | 2017-02-09 19:15:30 -0500 | [diff] [blame] | 60 | PacketPtr Gem5Extension::getPacket() |
Matthias Jung | 8723b08 | 2015-08-03 23:08:40 -0500 | [diff] [blame] | 61 | { |
| 62 | return Packet; |
| 63 | } |
| 64 | |
Christian Menard | b25ea09 | 2017-02-09 19:15:30 -0500 | [diff] [blame] | 65 | tlm_extension_base* Gem5Extension::clone() const |
Matthias Jung | 8723b08 | 2015-08-03 23:08:40 -0500 | [diff] [blame] | 66 | { |
Christian Menard | b25ea09 | 2017-02-09 19:15:30 -0500 | [diff] [blame] | 67 | return new Gem5Extension(Packet); |
Matthias Jung | 8723b08 | 2015-08-03 23:08:40 -0500 | [diff] [blame] | 68 | } |
| 69 | |
Christian Menard | b25ea09 | 2017-02-09 19:15:30 -0500 | [diff] [blame] | 70 | void Gem5Extension::copy_from(const tlm_extension_base& ext) |
Matthias Jung | 8723b08 | 2015-08-03 23:08:40 -0500 | [diff] [blame] | 71 | { |
Christian Menard | b25ea09 | 2017-02-09 19:15:30 -0500 | [diff] [blame] | 72 | const Gem5Extension& cpyFrom = static_cast<const Gem5Extension&>(ext); |
Matthias Jung | 8723b08 | 2015-08-03 23:08:40 -0500 | [diff] [blame] | 73 | Packet = cpyFrom.Packet; |
| 74 | } |
Christian Menard | b25ea09 | 2017-02-09 19:15:30 -0500 | [diff] [blame] | 75 | |
| 76 | } |