SystemC Library API Reference Manual
Reference documentation for the Simics SystemC Library.
 
Loading...
Searching...
No Matches
spi_slave_gasket_adapter.h
Go to the documentation of this file.
1/*
2 © 2025 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_SPI_SLAVE_GASKET_ADAPTER_H
15#define SIMICS_SYSTEMC_SIMICS2TLM_SPI_SLAVE_GASKET_ADAPTER_H
16
21
22namespace simics {
23namespace systemc {
24namespace simics2tlm {
25
31 public GasketAdapter<iface::SpiSlaveInterface> {
32 public:
33 SpiSlaveGasketAdapter(SpiSlaveInterface *spi_slave,
35 ConnectBase *spi_master)
36 : spi_slave_(spi_slave), simulation_(simulation),
37 spi_master_(spi_master) {
38 assert(spi_master_);
39 }
40 // iface::SpiSlaveInterface
41 void spi_request(int first, int last, const uint8 *data_ptr,
42 size_t data_length) override {
43 Context context(simulation_);
44 spi_slave_->spi_request(first, last, data_ptr, data_length);
45 }
46 void connect_master(conf_object_t *master, const char *port,
47 serial_peripheral_interface_flags_t flags) override {
48 auto *prev_master = spi_master_->get().object();
49 if (prev_master) {
50 SIM_LOG_INFO(3, simulation_->simics_object(), 0,
51 "disconnected from master %s",
52 SIM_object_name(prev_master));
53 }
54
55 ConfObjectRef obj {master};
56 if (port) {
57 obj.set_port_name(port);
58 }
59 spi_master_->set(obj);
60 SIM_LOG_INFO(3, simulation_->simics_object(), 0,
61 "connected to master %s", obj.name().c_str());
62
63 flags_ = flags;
64 }
65 void disconnect_master(conf_object_t *master) override {
66 if (spi_master_->get().object() != master) {
67 SIM_LOG_ERROR(simulation_->simics_object(), 0,
68 "can not be disconnected from master device %s",
69 SIM_object_name(master));
70 } else {
71 spi_master_->set(nullptr);
72 flags_ = -1;
73 SIM_LOG_INFO(3, simulation_->simics_object(), 0,
74 "disconnected from master %s",
75 SIM_object_name(master));
76 }
77 }
79 return dynamic_cast<simics2tlm::GasketOwner *>(spi_slave_);
80 }
81
84 int flags() {
85 if (spi_master_->get().object() == nullptr) {
86 return -1;
87 }
88 return flags_;
89 }
90
91 private:
92 SpiSlaveInterface *spi_slave_;
93 iface::SimulationInterface *simulation_;
94 ConnectBase *spi_master_;
95 int flags_ {-1};
96};
97
98} // namespace simics2tlm
99} // namespace systemc
100} // namespace simics
101
102#endif
Utility class that handles the context switching, using RAII methodology.
Definition: context.h:31
Interface to the SystemC simulation.
Definition: simulation_interface.h:25
virtual ConfObjectRef simics_object() const =0
Simics serial_peripheral_interface_slave interface.
Definition: spi_slave_interface.h:27
Definition: gasket_adapter.h:43
Base class, responsible for handling a gasket.
Definition: gasket_owner.h:30
Adapter for SpiSlave gasket.
Definition: spi_slave_gasket_adapter.h:31
void spi_request(int first, int last, const uint8 *data_ptr, size_t data_length) override
Definition: spi_slave_gasket_adapter.h:41
void disconnect_master(conf_object_t *master) override
Definition: spi_slave_gasket_adapter.h:65
simics2tlm::GasketOwner * gasket_owner() const override
Definition: spi_slave_gasket_adapter.h:78
int flags()
Return the flags used when connecting the master in integer, returns -1 for invalid value.
Definition: spi_slave_gasket_adapter.h:84
SpiSlaveGasketAdapter(SpiSlaveInterface *spi_slave, iface::SimulationInterface *simulation, ConnectBase *spi_master)
Definition: spi_slave_gasket_adapter.h:33
void connect_master(conf_object_t *master, const char *port, serial_peripheral_interface_flags_t flags) override
Definition: spi_slave_gasket_adapter.h:46
Definition: adapter.h:79