30 template <
typename GuestEnum,
typename FrameworkEnum>
31 constexpr
bool sameOrdinal(GuestEnum guest, FrameworkEnum framework) {
32 return static_cast<I32
>(guest) == static_cast<I32>(framework);
40 "guest FPRIME_PARAM_* must match Fw::ParamValid");
43 "guest FPRIME_PARAM_* must match Fw::ParamValid");
45 "guest FPRIME_PARAM_* must match Fw::ParamValid");
49 "guest FPRIME_CMD_* must match Fw::CmdResponse");
51 "guest FPRIME_CMD_* must match Fw::CmdResponse");
53 "guest FPRIME_CMD_* must match Fw::CmdResponse");
55 "guest FPRIME_CMD_* must match Fw::CmdResponse");
58 "guest FPRIME_CMD_* must match Fw::CmdResponse");
61 "guest FPRIME_EVENT_* must match Fw::LogSeverity");
63 "guest FPRIME_EVENT_* must match Fw::LogSeverity");
65 "guest FPRIME_EVENT_* must match Fw::LogSeverity");
67 "guest FPRIME_EVENT_* must match Fw::LogSeverity");
69 "guest FPRIME_EVENT_* must match Fw::LogSeverity");
71 "guest FPRIME_EVENT_* must match Fw::LogSeverity");
73 "guest FPRIME_EVENT_* must match Fw::LogSeverity");
84 template <HostFn Handler>
91 return (static_cast<WasmSequencer*>(userdata)->*Handler)(caller, params, n_params, out_result);
101 &hostFunctionTrampoline<&WasmSequencer::wasmExit>,
this);
105 &hostFunctionTrampoline<&WasmSequencer::wasmPanic>,
this);
109 &hostFunctionTrampoline<&WasmSequencer::wasmArgs>,
this);
113 &hostFunctionTrampoline<&WasmSequencer::wasmTime>,
this);
117 &hostFunctionTrampoline<&WasmSequencer::wasmReadTelemetry>,
this);
121 &hostFunctionTrampoline<&WasmSequencer::wasmReadParameter>,
this);
125 &hostFunctionTrampoline<&WasmSequencer::wasmCommand>,
this);
129 &hostFunctionTrampoline<&WasmSequencer::wasmEvent>,
this);
133 &hostFunctionTrampoline<&WasmSequencer::wasmRsleep>,
this);
137 &hostFunctionTrampoline<&WasmSequencer::wasmAsleep>,
this);
141 &hostFunctionTrampoline<&WasmSequencer::wasmSerialOut>,
this);
145 &hostFunctionTrampoline<&WasmSequencer::wasmSerialRecv>,
this);
153 FW_ASSERT(!this->m_pendingHostFunction.isPending());
155 FW_ASSERT(n_params == 1, static_cast<FwAssertArgType>(n_params));
160 this->m_exit.code = params[0].
u.
i32_;
169 FW_ASSERT(!this->m_pendingHostFunction.isPending());
171 FW_ASSERT(n_params == 1, static_cast<FwAssertArgType>(n_params));
176 this->m_exit.code = params[0].
u.
i32_;
185 FW_ASSERT(!this->m_pendingHostFunction.isPending());
187 FW_ASSERT(n_params == 2, static_cast<FwAssertArgType>(n_params));
204 FW_ASSERT(!this->m_pendingHostFunction.isPending());
206 FW_ASSERT(n_params == 2, static_cast<FwAssertArgType>(n_params));
210 const U32 time_ptr =
static_cast<U32
>(params[0].
u.
i32_);
211 const U32 time_size =
static_cast<U32
>(params[1].
u.
i32_);
224 this->m_pendingHostFunction.caller = caller;
225 this->m_pendingHostFunction.u.time.ptr = time_ptr;
226 this->m_pendingHostFunction.u.time.len = time_size;
232 return return_status;
239 FW_ASSERT(!this->m_pendingHostFunction.isPending());
242 FW_ASSERT(n_params == 5, static_cast<FwAssertArgType>(n_params));
251 I64
id = params[0].
u.
i64_;
252 const U32 time_ptr =
static_cast<U32
>(params[1].
u.
i32_);
253 const U32 time_size =
static_cast<U32
>(params[2].
u.
i32_);
254 const U32 value_ptr =
static_cast<U32
>(params[3].
u.
i32_);
255 const U32 value_size =
static_cast<U32
>(params[4].
u.
i32_);
275 }
else if (
id < 0 || static_cast<U64>(
id) > static_cast<U64>(std::numeric_limits<FwChanIdType>::max())) {
282 this->m_pendingHostFunction.caller = caller;
283 this->m_pendingHostFunction.u.telemetry.chanId =
static_cast<FwChanIdType>(id);
284 this->m_pendingHostFunction.u.telemetry.timePtr = time_ptr;
285 this->m_pendingHostFunction.u.telemetry.timeLen = time_size;
286 this->m_pendingHostFunction.u.telemetry.valuePtr = value_ptr;
287 this->m_pendingHostFunction.u.telemetry.valueLen = value_size;
293 return return_status;
300 FW_ASSERT(!this->m_pendingHostFunction.isPending());
303 FW_ASSERT(n_params == 3, static_cast<FwAssertArgType>(n_params));
310 I64
id = params[0].
u.
i64_;
311 const U32 ptr =
static_cast<U32
>(params[1].
u.
i32_);
312 const U32 len =
static_cast<U32
>(params[2].
u.
i32_);
321 if (
id < 0 || static_cast<U64>(
id) > static_cast<U64>(std::numeric_limits<FwPrmIdType>::max())) {
330 this->m_pendingHostFunction.caller = caller;
331 this->m_pendingHostFunction.u.parameter.prmId =
static_cast<FwPrmIdType>(id);
332 this->m_pendingHostFunction.u.parameter.ptr = ptr;
333 this->m_pendingHostFunction.u.parameter.len = len;
343 FW_ASSERT(!this->m_pendingHostFunction.isPending());
346 FW_ASSERT(n_params == 2, static_cast<FwAssertArgType>(n_params));
350 const U32 ptr =
static_cast<U32
>(params[0].
u.
i32_);
351 const U32 len =
static_cast<U32
>(params[1].
u.
i32_);
362 if (len > maxPayload) {
367 this->m_pendingHostFunction.caller = caller;
368 this->m_pendingHostFunction.u.command.ptr = ptr;
369 this->m_pendingHostFunction.u.command.len = len;
375 return return_status;
382 FW_ASSERT(!this->m_pendingHostFunction.isPending());
385 FW_ASSERT(n_params == 3, static_cast<FwAssertArgType>(n_params));
394 U32 ptr =
static_cast<U32
>(params[1].
u.
i32_);
395 U32 len =
static_cast<U32
>(params[2].
u.
i32_);
402 this->m_pendingHostFunction.caller = caller;
403 this->m_pendingHostFunction.u.event.rawSeverity =
static_cast<U32
>(params[0].
u.
i32_);
404 this->m_pendingHostFunction.u.event.msgPtr = ptr;
405 this->m_pendingHostFunction.u.event.msgLen = len;
414 FW_ASSERT(!this->m_pendingHostFunction.isPending());
416 FW_ASSERT(n_params == 1, static_cast<FwAssertArgType>(n_params));
419 const U64 us =
static_cast<U64
>(params[0].
u.
i64_);
423 if ((us / 1000000
u) >
static_cast<U64
>(std::numeric_limits<U32>::max())) {
429 this->m_pendingHostFunction.caller = caller;
430 this->m_pendingHostFunction.u.rsleep.us = us;
439 FW_ASSERT(!this->m_pendingHostFunction.isPending());
441 FW_ASSERT(n_params == 1, static_cast<FwAssertArgType>(n_params));
444 const U64 us =
static_cast<U64
>(params[0].
u.
i64_);
448 if ((us / 1000000
u) >
static_cast<U64
>(std::numeric_limits<U32>::max())) {
454 this->m_pendingHostFunction.caller = caller;
455 this->m_pendingHostFunction.u.asleep.us = us;
464 FW_ASSERT(!this->m_pendingHostFunction.isPending());
467 FW_ASSERT(n_params == 3, static_cast<FwAssertArgType>(n_params));
472 const I32 index = params[0].
u.
i32_;
473 const U32 ptr =
static_cast<U32
>(params[1].
u.
i32_);
474 const U32 len =
static_cast<U32
>(params[2].
u.
i32_);
481 static_cast<U32>(this->m_serialOutBuffer.
getCapacity()));
493 this->m_pendingHostFunction.caller = caller;
494 this->m_pendingHostFunction.u.serialOut.index =
static_cast<U32
>(index);
495 this->m_pendingHostFunction.u.serialOut.ptr = ptr;
496 this->m_pendingHostFunction.u.serialOut.len = len;
506 FW_ASSERT(!this->m_pendingHostFunction.isPending());
509 FW_ASSERT(n_params == 5, static_cast<FwAssertArgType>(n_params));
516 const I32 index = params[0].
u.
i32_;
517 const U32 data_ptr =
static_cast<U32
>(params[1].
u.
i32_);
518 const U32 data_len =
static_cast<U32
>(params[2].
u.
i32_);
519 const U32 actual_size_ptr =
static_cast<U32
>(params[3].
u.
i32_);
520 const I32 block_type = params[4].
u.
i32_;
528 if (block_type < 0 || block_type > static_cast<I32>(std::numeric_limits<Svc::BlockState::SerialType>::max()) ||
535 this->m_pendingHostFunction.caller = caller;
536 this->m_pendingHostFunction.u.serialRecv.index =
static_cast<U32
>(index);
537 this->m_pendingHostFunction.u.serialRecv.dataPtr = data_ptr;
538 this->m_pendingHostFunction.u.serialRecv.dataSize = data_len;
539 this->m_pendingHostFunction.u.serialRecv.actualSizePtr = actual_size_ptr;
540 this->m_pendingHostFunction.u.serialRecv.blockingType =
static_cast<Svc::BlockState::T>(block_type);
union spacewasm_value_payload_t u
U16 FwPacketDescriptorType
The width of packet descriptors when they are serialized by the framework.
void log_WARNING_HI_HostFunctionInvalidId(const Svc::WasmSequencer_HostFunction &host_function, I64 id) const
Command had execution error.
The interpreter exited via HOST_TRAP and we indicated HOST_PANIC in the host function.
void log_WARNING_HI_InvalidBlockingTypeValue(I32 invalidValue) const
Log event InvalidBlockingTypeValue.
Parameter has a valid value from the parameter database.
Invalid opcode dispatched.
A less serious but recoverable event.
FwIdType FwPrmIdType
The type of a parameter identifier.
Parameter is serving its compiled-in default value.
bool isConnected_getTlmChan_OutputPort(FwIndexType portNum) const
struct spacewasm_caller_t spacewasm_caller_t
spacewasm_status_t spacewasm_add_host_function(struct spacewasm_host_t *host, uint32_t module_idx, const char *name, const char *params_sig, const char *returns_sig, spacewasm_host_fn_t f, void *userdata)
bool isConnected_getParam_OutputPort(FwIndexType portNum) const
Serializable::SizeType getCapacity() const override
Get buffer capacity.
Invalid opcode dispatched.
Software diagnostic events.
Command tracking was cleared before the command completed.
Command failed validation.
Important informational events.
static spacewasm_hostcall_result_t hostFunctionTrampoline(struct spacewasm_caller_t *caller, void *userdata, const struct spacewasm_value_t *params, size_t n_params, struct spacewasm_value_t *out_result)
Named trampoline adapting spacewasm's C host-function ABI to a member handler.
Parameter storage has not been initialized.
void log_WARNING_HI_HostFunctionInvalidPort(const Svc::WasmSequencer_HostFunction &host_function, I32 index, U32 numPorts) const
Less important informational events.
U8 * getBuffAddr()
Get buffer address for data filling (non-const version)
Less important informational events.
An activity related to commanding.
A less serious but recoverable event.
bool isConnected_serialOut_OutputPort(FwIndexType portNum) const
A fatal non-recoverable event.
FwIdType FwChanIdType
The type of a telemetry channel identifier.
An activity related to commanding.
Parameter value is invalid (e.g. not found)
Software diagnostic events.
A serious but recoverable event.
A serious but recoverable event.
Command tracking was cleared before the command completed.
spacewasm_status_t spacewasm_add_host_module(struct spacewasm_host_t *host, const char *name, size_t max_functions, size_t max_globals, uint32_t *out_idx)
The interpreter exited via HOST_TRAP but a host function indicated it was a standard exit() ...
spacewasm_hostcall_result_t
Command successfully executed.
void log_WARNING_HI_BufferTooLarge(const Svc::WasmSequencer_HostFunction &host_function, U32 size, U32 maxSize) const
Command failed to deserialize.
static constexpr FwIndexType getNum_serialOut_OutputPorts()
Command had execution error.
Important informational events.
A fatal non-recoverable event.
Command failed to deserialize.
Command failed validation.
RateGroupDivider component implementation.
Command successfully executed.
spacewasm_hostcall_result_t(WasmSequencer::*)(struct spacewasm_caller_t *, const struct spacewasm_value_t *, size_t, struct spacewasm_value_t *) HostFn
Member-function signature of a spacewasm host-function handler.
void log_WARNING_HI_SleepDurationTooLarge(const Svc::WasmSequencer_HostFunction &host_function, U64 micros) const
bool isConnected_cmdOut_OutputPort(FwIndexType portNum) const
bool isValid() const
Check raw enum value for validity.
void log_WARNING_HI_BufferTooSmall(const Svc::WasmSequencer_HostFunction &host_function, U32 size, U32 valueSize) const