SystemC Library API Reference Manual
Reference documentation for the Simics SystemC Library.
 
Loading...
Searching...
No Matches
gasket_class.h
Go to the documentation of this file.
1/*
2 © 2017 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_SIMICS2TLM_GASKET_CLASS_H
15#define SIMICS_SYSTEMC_SIMICS2TLM_GASKET_CLASS_H
16
17#include <systemc>
18
19
20#include <simics/simulator/sim-get-class.h>
28
29#include <string>
30
31namespace simics {
32namespace systemc {
33namespace simics2tlm {
34
35template<class TGasket,
36 class TGasketAdapter,
37 template<class, class> class TSimicsAdapter,
38 class TGasketInterface>
40 : public ConfObject, public TGasketAdapter, public GasketClassInterface,
43 public:
44 explicit GasketClass(ConfObjectRef o)
45 : ConfObject(o), TGasketAdapter(&gasket_, this) {}
46 void finalize() override {
47 // Avoid recursive calls to finalize_instance
48 SIM_set_object_configured(obj());
49
50 // Make sure the Adapter is configured
51 simulation_ref_.require();
52 }
53
54 // GasketClassInterface
56 return this;
57 }
58 void createGasket(iface::SimulationInterface *simulation) override {
59 setSimulation(simulation);
60 gasket_.set_gasket(createGasketByName(socket_name_, simics_object()));
61 }
62
63 // ScInitiatorGasketInterface
64 void set_dmi(bool enable) override {
65 gasket_.gasket()->set_dmi(enable);
66 }
67 bool is_dmi_enabled() override {
68 return gasket_.gasket()->is_dmi_enabled();
69 }
70 char *print_dmi_table() override {
71 return MM_STRDUP(
72 gasket_.gasket()->get_dmi_data_table()->print().c_str());
73 }
74
75 static conf_class_t *registerGasketClass(const char* class_name) {
76 conf_class_t *cls = SIM_get_class(class_name);
77 if (SIM_clear_exception() == SimExc_No_Exception) {
78 return cls;
79 }
80
81 auto new_cls = make_class<GasketClass>(
82 class_name,
83 "model of SystemC simics2tlm gasket class",
84 "Class for binding Simics interface to SystemC Gasket.");
85
86 new_cls->add(iface::createAdapter<
87 TSimicsAdapter<GasketClass, TGasketInterface>>());
88 new_cls->add(iface::createAdapter<
90 new_cls->add(Attribute("target", "s",
91 "Name of the target socket the gasket is"
92 " connected to.",
93 ATTR_CLS_VAR(GasketClass, socket_name_),
94 Sim_Attr_Required));
95 new_cls->add(Attribute("simulation", "o",
96 "Simics object implementing the SystemC"
97 " Simulation interface.",
98 ATTR_CLS_VAR(GasketClass, simulation_ref_),
99 Sim_Attr_Required));
100
101 // Bind all currently unmapped adapters (i.e. the ones just created
102 // above) to this gasket class before a subsequent device class's
103 // initClassInternal calls bindUnmappedSimicsAdapters for the device
104 // class.
106 return *new_cls.get();
107 }
108
109 private:
110 std::string socket_name_;
111 ConfObjectRef simulation_ref_;
112 TGasket gasket_;
113};
114} // namespace simics2tlm
115} // namespace systemc // NOLINT
116} // namespace simics // NOLINT
117
118#endif
Definition: gasket_class_interface.h:26
Interface to the SystemC simulation.
Definition: simulation_interface_proxy.h:25
void setSimulation(iface::SimulationInterface *simulation)
Definition: simulation_interface_proxy.h:30
ConfObjectRef simics_object() const override
Definition: simulation_interface_proxy.h:47
Definition: version.h:41
Definition: sc_initiator_gasket_interface.h:22
Definition: sc_initiator_gasket_simics_adapter.h:33
Definition: sc_version_interface.h:25
Interface to the SystemC simulation.
Definition: simulation_interface.h:25
Definition: gasket_class.h:42
void set_dmi(bool enable) override
Definition: gasket_class.h:64
void createGasket(iface::SimulationInterface *simulation) override
Definition: gasket_class.h:58
static conf_class_t * registerGasketClass(const char *class_name)
Definition: gasket_class.h:75
GasketClass(ConfObjectRef o)
Definition: gasket_class.h:44
bool is_dmi_enabled() override
Definition: gasket_class.h:67
void finalize() override
Definition: gasket_class.h:46
char * print_dmi_table() override
Definition: gasket_class.h:70
iface::ScVersionInterface * version() override
Definition: gasket_class.h:55
GasketInterface::Ptr createGasketByName(std::string socket_name, const simics::ConfObjectRef &simics_obj)
Factory for creating a Gasket and bind it to a target socket.
void bindUnmappedSimicsAdapters(conf_class_t *conf_class)
Bind all adapters that are still pending mapping to a conf_class.
Definition: simics_adapter.h:184
InterfaceSimicsAdapter & createAdapter()
Create a SimicsAdapter that can be registered with a ConfClass.
Definition: simics_adapter.h:172
conf_class_t * SIM_get_class(const char *NOTNULL name)
Definition: adapter.h:79