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