40#include "debug/SCMI.hh"
56 vendor(platform.params().base_vendor),
57 subvendor(platform.params().base_subvendor),
58 implementationVersion(platform.params().base_impl_version)
61 "Invalid BASE_PROTOCOL VENDOR size\n");
63 "Invalid BASE_PROTOCOL SUBVENDOR size\n");
71 DPRINTF(SCMI,
"Handling SCMI message:\n");
72 DPRINTF(SCMI,
"# Message Protocol = BASE_PROTOCOL\n");
73 DPRINTF(SCMI,
"# Message ID = %u\n", message_id);
75 switch (
static_cast<Commands>(message_id)) {
106 warn(
"Unimplemented SCMI command: %u\n", message_id);
113 auto& payload = msg.
payload.baseProtocolVersion;
118 msg.
length =
sizeof(uint32_t) * 3;
124 uint32_t _attributes = 0;
129 auto& payload = msg.
payload.baseProtocolAttributes;
131 payload.attributes = _attributes;
134 msg.
length =
sizeof(uint32_t) * 3;
140 switch (message_id) {
158 auto& payload = msg.
payload.baseProtocolMessageAttributes;
159 const auto message_id =
static_cast<Commands>(
169 payload.attributes = 0;
172 msg.
length =
sizeof(uint32_t) * 3;
178 auto& payload = msg.
payload.baseDiscoverVendor;
181 auto vendor_size =
vendor.copy(
185 msg.
length =
sizeof(uint32_t) * 2 + vendor_size;
191 auto& payload = msg.
payload.baseDiscoverSubVendor;
198 msg.
length =
sizeof(uint32_t) * 2 + subvendor_size;
204 auto& payload = msg.
payload.baseDiscoverImplementationVersion;
209 msg.
length =
sizeof(uint32_t) * 3;
215 auto& payload = msg.
payload.baseDiscoverListProtocols;
216 const uint32_t skip = payload.skip;
219 if (skip > num_protocols) {
221 msg.
length =
sizeof(uint32_t) * 2;
225 auto *protocols = (uint8_t*)payload.protocols;
226 uint32_t num_implemented = 0;
228 for (
auto protoc_id =
START + skip; protoc_id <=
END; protoc_id++) {
229 auto it = protocol_list.find(protoc_id);
230 if (it != protocol_list.end()) {
233 *protocols = it->first;
239 payload.numProtocols = num_implemented;
242 msg.
length =
sizeof(uint32_t) * 3;
249 auto& payload = msg.
payload.baseDiscoverAgent;
250 const uint32_t agent_id = payload.agentId;
254 msg.
length =
sizeof(uint32_t) * 2;
258 auto agent_name = std::string();
265 agent_name =
"platform";
268 agent_size = agent_name.length();
270 strncpy((
char *)&payload.name,
271 agent_name.c_str(), agent_size);
275 msg.
length =
sizeof(uint32_t) * 2 + agent_size;
282 auto& payload = msg.
payload.invalidCommand;
284 msg.
length =
sizeof(uint32_t) * 2;
virtual std::string name() const
void discoverImplVersion(Message &msg)
void version(Message &msg) override
void discoverVendor(Message &msg)
void messageAttributes(Message &msg) override
bool implementedProtocol(Commands message_id) const
void discoverListProtocols(Message &msg)
static const uint32_t PROTOCOL_VERSION
void discoverSubVendor(Message &msg)
void invalidCommand(Message &msg)
void discoverAgent(Message &msg)
BaseProtocol(Platform &_platform)
void handleMessage(Message &msg) override
const uint32_t implementationVersion
void attributes(Message &msg) override
@ DISCOVER_LIST_PROTOCOLS
@ RESET_AGENT_CONFIGURATION
@ DISCOVER_IMPLEMENTATION_VERSION
@ SET_PROTOCOL_PERMISSIONS
const std::string subvendor
const std::string name() const
static const uint32_t MAX_STRING_SIZE
constexpr void replaceBits(T &val, unsigned first, unsigned last, B bit_val)
A convenience function to replace bits first to last of val with bit_val in place.
#define fatal_if(cond,...)
Conditional fatal macro that checks the supplied condition and only causes a fatal error if the condi...
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.