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