SystemC Library API Reference Manual
Reference documentation for the Simics SystemC Library.
 
Loading...
Searching...
No Matches
sc_tlm_fw_transport_simics_adapter.h
Go to the documentation of this file.
1// -*- mode: C++; c-file-style: "virtutech-c++" -*-
2
3/*
4 © 2017 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_INJECTION_SC_TLM_FW_TRANSPORT_SIMICS_ADAPTER_H
17#define SIMICS_SYSTEMC_IFACE_INJECTION_SC_TLM_FW_TRANSPORT_SIMICS_ADAPTER_H
18
23
24#include <systemc-interfaces.h>
25
26#include <tlm>
27
28#include <string>
29#include <vector>
30
31namespace simics {
32namespace systemc {
33namespace iface {
34namespace injection {
35
36template<typename TBase,
37 typename TYPES = tlm::tlm_base_protocol_types,
38 typename TInterface = tlm::tlm_fw_transport_if<TYPES> >
40 : public SimicsAdapter<sc_tlm_fw_transport_interface_t> {
41 public:
42 typedef typename TYPES::tlm_payload_type transaction_type;
44 : SimicsAdapter<sc_tlm_fw_transport_interface_t>(
45 SC_TLM_FW_TRANSPORT_INTERFACE, init_iface()) {
46 }
47
48 static sc_tlm_sync_enum_t nb_transport_fw(conf_object_t *obj,
49 attr_value_t trans,
50 ::uint64 phase, ::uint64 t) {
51 transaction_type *payload = NULL;
52 typename TYPES::tlm_phase_type p;
53 p = static_cast<typename TYPES::tlm_phase_type>(phase);
54 sc_core::sc_time t2 = sc_core::sc_time::from_value(t);
56 payload = registry.attrToPayload(obj, &trans);
57 if (!payload)
58 return SC_TLM_ATTR_ERROR;
59
60 tlm::tlm_sync_enum ret =
61 adapter<TBase, TInterface>(obj)->nb_transport_fw(*payload, p, t2);
62 payload->release();
63 return static_cast<sc_tlm_sync_enum_t>(ret);
64 }
65 static void b_transport(conf_object_t *obj, attr_value_t trans,
66 ::uint64 t) {
67 transaction_type *payload = NULL;
68 sc_core::sc_time t2 = sc_core::sc_time::from_value(t);
70 registry;
71 payload = registry.attrToPayload(obj, &trans);
72 if (!payload)
73 return;
74
75 adapter<TBase, TInterface>(obj)->b_transport(*payload, t2);
76 // No payload->release() in this b_transport.
77 // ScTlmBTransportInvoker is invoking release later.
78 }
79 static bool get_direct_mem_ptr(conf_object_t *obj, attr_value_t trans,
80 attr_value_t dmi_data) {
81 tlm::tlm_dmi dmi;
84 p.parse(&attr_dmi);
85
86 if (!p.reportInvalidAttrs())
87 return false;
88
89 transaction_type *payload = NULL;
91 payload = registry.attrToPayload(obj, &trans);
92 if (!payload)
93 return false;
94
95 bool ret = adapter<TBase, TInterface>(obj)->get_direct_mem_ptr(*payload,
96 dmi);
97 payload->release();
98 return ret;
99 }
100 static ::uint64 transport_dbg(conf_object_t *obj, attr_value_t trans) {
101 transaction_type *payload = NULL;
103 payload = registry.attrToPayload(obj, &trans);
104 if (!payload)
105 return 0;
106
107 ::uint64 ret = adapter<TBase, TInterface>(obj)->transport_dbg(*payload);
108 payload->release();
109 return ret;
110 }
111
112 private:
113 std::vector<std::string> description(conf_object_t *obj,
114 DescriptionType type) {
115 return descriptionBase<TBase, TInterface>(obj, type);
116 }
117 sc_tlm_fw_transport_interface_t init_iface() {
118 sc_tlm_fw_transport_interface_t iface = {};
119 iface.nb_transport_fw = nb_transport_fw;
120 iface.b_transport = b_transport;
121 iface.get_direct_mem_ptr = get_direct_mem_ptr;
122 iface.transport_dbg = transport_dbg;
123 return iface;
124 }
125};
126
127} // namespace injection
128} // namespace iface
129} // namespace systemc
130} // namespace simics
131
132#endif
Base class for mapping Simics interface to a C++ interface.
Definition: simics_adapter.h:47
Definition: sc_tlm_fw_transport_simics_adapter.h:40
static void b_transport(conf_object_t *obj, attr_value_t trans, ::uint64 t)
Definition: sc_tlm_fw_transport_simics_adapter.h:65
::uint64 transport_dbg(conf_object_t *obj, attr_value_t trans)
Definition: sc_tlm_fw_transport_simics_adapter.h:100
static bool get_direct_mem_ptr(conf_object_t *obj, attr_value_t trans, attr_value_t dmi_data)
Definition: sc_tlm_fw_transport_simics_adapter.h:79
static sc_tlm_sync_enum_t nb_transport_fw(conf_object_t *obj, attr_value_t trans, ::uint64 phase, ::uint64 t)
Definition: sc_tlm_fw_transport_simics_adapter.h:48
ScTlmFwTransportSimicsAdapter()
Definition: sc_tlm_fw_transport_simics_adapter.h:43
TYPES::tlm_payload_type transaction_type
Definition: sc_tlm_fw_transport_simics_adapter.h:42
Definition: attr_dict_parser.h:40
bool parse(ParserInterface *parser)
Definition: attr_dmi.h:32
Definition: inject_registry.h:37
TPAYLOAD * attrToPayload(conf_object_t *obj, attr_value_t *attr)
Definition: inject_registry.h:39
DescriptionType
Definition: description_interface.h:25
Definition: pci_bus_interface.h:24