6 #ifndef SSTIOIMP_HPP_INCLUDE
7 #define SSTIOIMP_HPP_INCLUDE
14 #include <type_traits>
21 struct sst_mbox_interface_batch_s;
22 struct sst_mmio_interface_batch_s;
33 SSTIOImp(uint32_t max_cpus, std::shared_ptr<SSTIoctl> ioctl_interface);
39 uint16_t subcommand, uint32_t subcommand_arg)
override;
41 uint16_t subcommand, uint32_t interface_parameter,
42 uint16_t read_subcommand,
43 uint32_t read_interface_parameter,
44 uint32_t read_mask)
override;
45 int add_mmio_read(uint32_t cpu_index, uint16_t register_offset)
override;
47 uint32_t register_value, uint32_t read_mask)
override;
52 uint64_t
sample(
int batch_idx)
const override;
55 uint16_t subcommand, uint32_t subcommand_arg)
override;
57 uint16_t subcommand, uint32_t interface_parameter,
58 uint16_t read_subcommand,
59 uint32_t read_interface_parameter,
60 uint32_t read_mask, uint64_t write_value,
61 uint64_t write_mask)
override;
62 uint32_t
read_mmio_once(uint32_t cpu_index, uint16_t register_offset)
override;
64 uint32_t register_value, uint32_t read_mask,
65 uint64_t write_value, uint64_t write_mask)
override;
66 void adjust(
int batch_idx, uint64_t write_value, uint64_t write_mask)
override;
76 template<
typename OuterStruct>
78 typename std::remove_all_extents<decltype(OuterStruct::interfaces)>::type;
84 template<
typename OuterStruct>
85 std::vector<std::unique_ptr<OuterStruct, void (*)(OuterStruct *)> >
86 ioctl_structs_from_vector(
const std::vector<InnerStruct<OuterStruct> > &commands)
89 std::vector<std::unique_ptr<OuterStruct, void (*)(OuterStruct *)> > outer_structs;
91 size_t handled_commands = 0;
92 while (handled_commands < commands.size())
94 size_t batch_size = std::min(
95 static_cast<size_t>(m_batch_command_limit),
96 commands.size() - handled_commands);
102 outer_structs.emplace_back(
reinterpret_cast<OuterStruct *
>(
103 new char[
sizeof(OuterStruct::num_entries) +
104 sizeof(InnerStruct<OuterStruct>) * commands.size()]),
105 [](OuterStruct *outer_struct) {
106 delete[] reinterpret_cast<char *>(outer_struct);
108 outer_structs.back()->num_entries = batch_size;
109 std::copy(commands.data() + handled_commands,
110 commands.data() + handled_commands + batch_size,
111 outer_structs.back()->interfaces);
113 handled_commands += batch_size;
116 return outer_structs;
119 std::shared_ptr<SSTIoctl> m_ioctl;
120 int m_batch_command_limit;
121 std::vector<struct sst_mbox_interface_s> m_mbox_read_interfaces;
122 std::vector<struct sst_mbox_interface_s> m_mbox_write_interfaces;
123 std::vector<struct sst_mbox_interface_s> m_mbox_rmw_interfaces;
124 std::vector<uint32_t> m_mbox_rmw_read_masks;
125 std::vector<uint32_t> m_mbox_rmw_write_masks;
126 std::vector<struct sst_mmio_interface_s> m_mmio_read_interfaces;
127 std::vector<struct sst_mmio_interface_s> m_mmio_write_interfaces;
128 std::vector<struct sst_mmio_interface_s> m_mmio_rmw_interfaces;
129 std::vector<uint32_t> m_mmio_rmw_read_masks;
130 std::vector<uint32_t> m_mmio_rmw_write_masks;
131 std::vector<std::pair<message_type_e, size_t> > m_added_interfaces;
132 std::vector<std::unique_ptr<sst_mbox_interface_batch_s, void(*)(sst_mbox_interface_batch_s*)> > m_mbox_read_batch;
133 std::vector<std::unique_ptr<sst_mbox_interface_batch_s, void(*)(sst_mbox_interface_batch_s*)> > m_mbox_write_batch;
134 std::vector<std::unique_ptr<sst_mmio_interface_batch_s, void(*)(sst_mmio_interface_batch_s*)> > m_mmio_read_batch;
135 std::vector<std::unique_ptr<sst_mmio_interface_batch_s, void(*)(sst_mmio_interface_batch_s*)> > m_mmio_write_batch;
136 std::map<uint32_t, uint32_t> m_cpu_punit_core_map;
Definition: SSTIOImp.hpp:24
void write_mmio_once(uint32_t cpu_index, uint16_t register_offset, uint32_t register_value, uint32_t read_mask, uint64_t write_value, uint64_t write_mask) override
Immediately write a value to the SST MMIO interface.
Definition: SSTIO.cpp:476
void write_batch(void) override
Issue a batch write.
Definition: SSTIO.cpp:296
uint32_t read_mbox_once(uint32_t cpu_index, uint16_t command, uint16_t subcommand, uint32_t subcommand_arg) override
Immediately query the SST mailbox for a read operation.
Definition: SSTIO.cpp:387
SSTIOImp(uint32_t max_cpus)
Main constructor for the SST ioctl interface.
Definition: SSTIO.cpp:26
uint64_t sample(int batch_idx) const override
Sample a value from the most recent batch read.
Definition: SSTIO.cpp:270
int add_mbox_write(uint32_t cpu_index, uint16_t command, uint16_t subcommand, uint32_t interface_parameter, uint16_t read_subcommand, uint32_t read_interface_parameter, uint32_t read_mask) override
Interact with the mailbox on commands that are not expected to return data.
Definition: SSTIO.cpp:137
int add_mbox_read(uint32_t cpu_index, uint16_t command, uint16_t subcommand, uint32_t subcommand_arg) override
Interact with the mailbox on commands that are expected to return data.
Definition: SSTIO.cpp:80
int add_mmio_read(uint32_t cpu_index, uint16_t register_offset) override
Interact with the mmio interface on commands that are expected to return data.
Definition: SSTIO.cpp:199
virtual ~SSTIOImp()=default
int add_mmio_write(uint32_t cpu_index, uint16_t register_offset, uint32_t register_value, uint32_t read_mask) override
Interact with the mmio interface on commands that are not expected to return data.
Definition: SSTIO.cpp:215
void write_mbox_once(uint32_t cpu_index, uint16_t command, uint16_t subcommand, uint32_t interface_parameter, uint16_t read_subcommand, uint32_t read_interface_parameter, uint32_t read_mask, uint64_t write_value, uint64_t write_mask) override
Immediately query the SST mailbox for a write operation.
Definition: SSTIO.cpp:414
void read_batch(void) override
Issue a batch read.
Definition: SSTIO.cpp:237
uint32_t read_mmio_once(uint32_t cpu_index, uint16_t register_offset) override
Immediately read a value from the SST MMIO interface.
Definition: SSTIO.cpp:457
void adjust(int batch_idx, uint64_t write_value, uint64_t write_mask) override
Adjust a value for the next batch write.
Definition: SSTIO.cpp:505
uint32_t get_punit_from_cpu(uint32_t cpu_index) override
Get the punit index associated with a CPU index.
Definition: SSTIO.cpp:525