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