SystemC Library API Reference Manual
Reference documentation for the Simics SystemC Library.
 
Loading...
Searching...
No Matches
extension.h
Go to the documentation of this file.
1// -*- mode: C++; c-file-style: "virtutech-c++" -*-
2
3/*
4 © 2015 Intel Corporation
5
6 This software and the related documents are Intel copyrighted materials, and
7 your use of them is governed by the express license under which they were
8 provided to you ("License"). Unless the License provides otherwise, you may
9 not use, modify, copy, publish, distribute, disclose or transmit this software
10 or the related documents without Intel's prior written permission.
11
12 This software and the related documents are provided as is, with no express or
13 implied warranties, other than those that are expressly stated in the License.
14*/
15
16#ifndef SIMICS_SYSTEMC_IFACE_EXTENSION_H
17#define SIMICS_SYSTEMC_IFACE_EXTENSION_H
18
19#include <tlm>
20
27#include <vector>
28
29namespace simics {
30namespace systemc {
31namespace iface {
32
39template<typename TExtension, typename TInterface>
40class Extension : public tlm::tlm_extension<TExtension>, public TInterface {
41 public:
43 suppress_error_(false), valid_(false) {}
46 tlm::tlm_generic_payload *payload) {
47 sender_ = sender;
48 }
50 sender_ = sender;
51 }
52 void send() {
53 // Clear returns from former call.
56 suppress_error_ = false;
57 // Copy method, method_input and method_return_error into new
58 // extension object.
59 Extension *e = static_cast<Extension*>(clone());
60 // Clear method, method_input and method_return_error for reenter
61 // from send_extension.
62 method_input_.clear();
65 e->valid_ = true;
67 t->set_extension(e);
68 /* During send_extension, the extension is dispatched to an
69 * ExtensionReceiver or an ExtensionIgnoreReceiver. The receiver
70 * invokes either method_call or method_call_ignore.*/
72 // Copy method_return back.
73 if (e->method_call_count_ != 1) {
75 if (!method_return_.isSet())
77 if (!e->suppress_error_)
79 } else {
81 }
82 t->clear_extension(e);
83 e->free();
84 }
85 void method_call(TInterface *device) {
87 if (device)
88 call(device);
89 }
91 suppress_error_ = true;
92 }
94 return method_;
95 }
96 bool valid() {
97 return valid_;
98 }
99 virtual tlm::tlm_extension_base *clone() const {
100 return new TExtension(*static_cast<const TExtension *>(this));
101 }
102 virtual void copy_from(tlm::tlm_extension_base const &extension) {
103 *this = static_cast<const TExtension &>(extension);
104 }
105 static ReceiverInterface *createReceiver(TInterface *device) {
107 }
110 }
111 virtual ~Extension() {}
112
113 protected:
114 virtual void call(TInterface *device) = 0;
115
118 std::vector<types::AnyType> method_input_;
123 bool valid_;
124};
125
126} // namespace iface
127} // namespace systemc
128} // namespace simics
129
130#endif
Definition: extension_ignore_receiver.h:29
Receiver of protocol specific extensions.
Definition: extension_receiver.h:37
Interface used by Extension class to send the extension.
Definition: extension_sender_interface.h:26
virtual void send_failed(Transaction *transaction)=0
Called by extension if method_call invocation was missing.
virtual Transaction transaction()=0
Called by extension to get a new Transaction.
virtual void send_extension(Transaction *transaction)=0
Called by extension after the extension is set on the payload.
Base class for TLM2 extension, responsible for marshal/unmarshal of a Simics interface.
Definition: extension.h:40
bool valid_
Definition: extension.h:123
types::AnyType method_type()
Definition: extension.h:93
void method_call_ignore()
Definition: extension.h:90
int method_call_count_
Definition: extension.h:121
void method_call(TInterface *device)
Definition: extension.h:85
virtual void copy_from(tlm::tlm_extension_base const &extension)
Definition: extension.h:102
static ReceiverInterface * createIgnoreReceiver()
Definition: extension.h:108
ExtensionSenderInterface * sender_
Definition: extension.h:116
types::AnyType method_return_error_
Definition: extension.h:120
static ReceiverInterface * createReceiver(TInterface *device)
Definition: extension.h:105
void init(ExtensionSenderInterface *sender, tlm::tlm_generic_payload *payload)
Deprecated, use the init(ExtensionSenderInterface *sender) instead.
Definition: extension.h:45
virtual ~Extension()
Definition: extension.h:111
types::AnyType method_return_
Definition: extension.h:119
bool suppress_error_
Definition: extension.h:122
virtual void call(TInterface *device)=0
bool valid()
Definition: extension.h:96
virtual tlm::tlm_extension_base * clone() const
Definition: extension.h:99
void send()
Definition: extension.h:52
std::vector< types::AnyType > method_input_
Definition: extension.h:118
types::AnyType method_
Definition: extension.h:117
void init(ExtensionSenderInterface *sender)
Definition: extension.h:49
Extension()
Definition: extension.h:42
Interface implemented by the ExtensionReceiver class, used by the ExtensionDispatcher.
Definition: receiver_interface.h:29
Class that encapsulates a generic_payload and returns it to the TransactionPool when the Transaction ...
Definition: transaction.h:31
Generic type class.
Definition: any_type.h:25
bool isSet()
Definition: any_type.h:87
Definition: pci_bus_interface.h:24