SystemC Library API Reference Manual
Reference documentation for the Simics SystemC Library.
 
Loading...
Searching...
No Matches
pci_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_COMPOSITE_PCI_GASKET_CLASS_H
15#define SIMICS_SYSTEMC_COMPOSITE_PCI_GASKET_CLASS_H
16
17#if defined SIMICS_6_API || defined SHOW_OBSOLETE_API
18
19#include <systemc>
20
21#include <simics/simulator/sim-get-class.h>
27
28#include <string>
29
30namespace simics {
31namespace systemc {
32namespace composite {
33
34template<unsigned int BUSWIDTH = 32,
35 typename TYPES = tlm::tlm_base_protocol_types>
36class PciGasketClass
37 : public ConfObject, public PciGasket<BUSWIDTH, TYPES>,
38 public GasketClassInterface, public Version,
39 public SimulationInterfaceProxy {
40 public:
41 explicit PciGasketClass(ConfObjectRef o)
42 : ConfObject(o), PciGasket<BUSWIDTH, TYPES>(this) {}
43 virtual void finalize() {
44 // Avoid recursive calls to finalize_instance
45 SIM_set_object_configured(obj());
46
47 // Make sure the Adapter is configured
48 simulation_ref_.require();
49 }
50
51 // GasketClassInterface
52 iface::ScVersionInterface *version() override {
53 return this;
54 }
55 void createGasket(iface::SimulationInterface *simulation) override {
56 setSimulation(simulation);
57 sc_core::sc_object *obj = sc_core::sc_find_object(
58 sc_pci_device_name_.c_str());
59 if (!obj) {
60 SIM_LOG_ERROR(simulation->simics_object(), Log_Configuration,
61 "Invalid SystemC object name for "
62 "PciDeviceQueryInterface and "
63 "BaseAddressRegisterQueryInterface implementor");
64 return;
65 }
66
67 iface::PciDeviceQueryInterface *pci =
68 dynamic_cast<iface::PciDeviceQueryInterface *>(obj);
69 iface::BaseAddressRegisterQueryInterface *bar =
70 dynamic_cast<iface::BaseAddressRegisterQueryInterface *>(obj);
71 this->connect(pci, bar, this->obj());
72 }
73 static conf_class_t *registerGasketClass(const char* class_name) {
74 conf_class_t *cls = SIM_get_class(class_name);
75 if (SIM_clear_exception() == SimExc_No_Exception) {
76 return cls;
77 }
78
79 auto new_cls = make_class<PciGasketClass>(
80 class_name,
81 "model of SystemC compsite pci gasket class",
82 "Class for binding Simics interface to SystemC Pci Gasket.",
83 Sim_Class_Kind_Pseudo);
84
85 new_cls->add(Attribute("device", "s",
86 "Name of the SystemC object that implements the"
87 " PciDeviceQueryInterface and"
88 " BaseAddressRegisterQueryInterface."
89 "All TLM2 sockets returned by the object must"
90 " have BUSWIDTH = 32 and TYPES ="
91 " tlm::tlm_base_protocol_types",
92 ATTR_CLS_VAR(PciGasketClass,
93 sc_pci_device_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(PciGasketClass, simulation_ref_),
99 Sim_Attr_Required));
100 PciGasketBase::initClassInternal<PciGasketClass>(new_cls.get());
101
102 return *new_cls.get();
103 }
104
105 private:
106 std::string sc_pci_device_name_;
107 ConfObjectRef simulation_ref_;
108};
109} // namespace composite
110} // namespace systemc // NOLINT
111} // namespace simics // NOLINT
112
113#endif
114#endif
conf_class_t * SIM_get_class(const char *NOTNULL name)
Definition: adapter.h:79