F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
WasmSequencerHost.cpp
Go to the documentation of this file.
1 // ======================================================================
2 // \title WasmSequencerHost.cpp
3 // \author tumbar
4 // \brief cpp file for WasmSequencer Wasm Host functions
5 // ======================================================================
6 
7 #include <limits>
8 
9 #include "Fw/Types/Assert.hpp"
18 #include "spacewasm.h"
19 
20 namespace Svc {
21 
23 using HostFn = spacewasm_hostcall_result_t (WasmSequencer::*)(struct spacewasm_caller_t*,
24  const struct spacewasm_value_t*,
25  size_t,
27 
29 template <HostFn Handler>
31  void* userdata,
32  const struct spacewasm_value_t* params,
33  size_t n_params,
34  struct spacewasm_value_t* out_result) {
35  FW_ASSERT(userdata != nullptr);
36  return (static_cast<WasmSequencer*>(userdata)->*Handler)(caller, params, n_params, out_result);
37 }
38 
39 void WasmSequencer ::hostFprimeV1(spacewasm_host_t* host) {
40  spacewasm_status_t status;
41  U32 module_idx;
42  status = spacewasm_add_host_module(host, "fprime_v1", 12, 0, &module_idx);
43  FW_ASSERT(status == SPACEWASM_OK, status);
44 
45  status = spacewasm_add_host_function(host, module_idx, "exit", "i", "",
46  &hostFunctionTrampoline<&WasmSequencer::wasmExit>, this);
47  FW_ASSERT(status == SPACEWASM_OK, status);
48 
49  status = spacewasm_add_host_function(host, module_idx, "panic", "i", "",
50  &hostFunctionTrampoline<&WasmSequencer::wasmPanic>, this);
51  FW_ASSERT(status == SPACEWASM_OK, status);
52 
53  status = spacewasm_add_host_function(host, module_idx, "args", "ii", "i",
54  &hostFunctionTrampoline<&WasmSequencer::wasmArgs>, this);
55  FW_ASSERT(status == SPACEWASM_OK, status);
56 
57  status = spacewasm_add_host_function(host, module_idx, "time", "ii", "",
58  &hostFunctionTrampoline<&WasmSequencer::wasmTime>, this);
59  FW_ASSERT(status == SPACEWASM_OK, status);
60 
61  status = spacewasm_add_host_function(host, module_idx, "tlm", "Iiiii", "i",
62  &hostFunctionTrampoline<&WasmSequencer::wasmReadTelemetry>, this);
63  FW_ASSERT(status == SPACEWASM_OK, status);
64 
65  status = spacewasm_add_host_function(host, module_idx, "prm", "Iii", "i",
66  &hostFunctionTrampoline<&WasmSequencer::wasmReadParameter>, this);
67  FW_ASSERT(status == SPACEWASM_OK, status);
68 
69  status = spacewasm_add_host_function(host, module_idx, "cmd", "ii", "i",
70  &hostFunctionTrampoline<&WasmSequencer::wasmCommand>, this);
71  FW_ASSERT(status == SPACEWASM_OK, status);
72 
73  status = spacewasm_add_host_function(host, module_idx, "event", "iii", "",
74  &hostFunctionTrampoline<&WasmSequencer::wasmEvent>, this);
75  FW_ASSERT(status == SPACEWASM_OK, status);
76 
77  status = spacewasm_add_host_function(host, module_idx, "rsleep", "I", "",
78  &hostFunctionTrampoline<&WasmSequencer::wasmRsleep>, this);
79  FW_ASSERT(status == SPACEWASM_OK, status);
80 
81  status = spacewasm_add_host_function(host, module_idx, "asleep", "I", "",
82  &hostFunctionTrampoline<&WasmSequencer::wasmAsleep>, this);
83  FW_ASSERT(status == SPACEWASM_OK, status);
84 
85  status = spacewasm_add_host_function(host, module_idx, "serial_send", "iii", "",
86  &hostFunctionTrampoline<&WasmSequencer::wasmSerialOut>, this);
87  FW_ASSERT(status == SPACEWASM_OK, status);
88 
89  status = spacewasm_add_host_function(host, module_idx, "serial_recv", "iiiii", "i",
90  &hostFunctionTrampoline<&WasmSequencer::wasmSerialRecv>, this);
91  FW_ASSERT(status == SPACEWASM_OK, status);
92 }
93 
94 spacewasm_hostcall_result_t WasmSequencer::wasmExit(spacewasm_caller_t* caller,
95  const spacewasm_value_t* params,
96  size_t n_params,
98  FW_ASSERT(!this->m_pendingHostFunction.isPending());
99  FW_ASSERT(params != nullptr);
100  FW_ASSERT(n_params == 1, static_cast<FwAssertArgType>(n_params));
101 
102  FW_ASSERT(params[0].tag == spacewasm_valtype_t::SPACEWASM_I32, params[0].tag);
103 
104  this->m_exit.reason = WasmSequencer_ExitReason::HOST_EXIT;
105  this->m_exit.code = params[0].u.i32_;
106 
107  return SPACEWASM_TRAP;
108 }
109 
110 spacewasm_hostcall_result_t WasmSequencer::wasmPanic(spacewasm_caller_t* caller,
111  const spacewasm_value_t* params,
112  size_t n_params,
114  FW_ASSERT(!this->m_pendingHostFunction.isPending());
115  FW_ASSERT(params != nullptr);
116  FW_ASSERT(n_params == 1, static_cast<FwAssertArgType>(n_params));
117 
118  FW_ASSERT(params[0].tag == spacewasm_valtype_t::SPACEWASM_I32, params[0].tag);
119 
120  this->m_exit.reason = WasmSequencer_ExitReason::HOST_PANIC;
121  this->m_exit.code = params[0].u.i32_;
122 
123  return SPACEWASM_TRAP;
124 }
125 
126 spacewasm_hostcall_result_t WasmSequencer::wasmArgs(spacewasm_caller_t* caller,
127  const spacewasm_value_t* params,
128  size_t n_params,
130  FW_ASSERT(!this->m_pendingHostFunction.isPending());
131  FW_ASSERT(params != nullptr);
132  FW_ASSERT(n_params == 2, static_cast<FwAssertArgType>(n_params));
133 
134  FW_ASSERT(params[0].tag == spacewasm_valtype_t::SPACEWASM_I32, params[0].tag);
135  FW_ASSERT(params[1].tag == spacewasm_valtype_t::SPACEWASM_I32, params[1].tag);
136 
137  const U32 ptr = static_cast<U32>(params[0].u.i32_);
138  const U32 size = static_cast<U32>(params[1].u.i32_);
139 
140  this->m_pendingHostFunction.kind = WasmSequencer_HostFunction::ARGS;
141  this->m_pendingHostFunction.caller = caller;
142  this->m_pendingHostFunction.u.args.ptr = ptr;
143  this->m_pendingHostFunction.u.args.len = size;
144 
145  return SPACEWASM_PAUSE;
146 }
147 
148 spacewasm_hostcall_result_t WasmSequencer::wasmTime(spacewasm_caller_t* caller,
149  const spacewasm_value_t* params,
150  size_t n_params,
152  FW_ASSERT(!this->m_pendingHostFunction.isPending());
153  FW_ASSERT(params != nullptr);
154  FW_ASSERT(n_params == 2, static_cast<FwAssertArgType>(n_params));
155  FW_ASSERT(params[0].tag == spacewasm_valtype_t::SPACEWASM_I32, params[0].tag);
156  FW_ASSERT(params[1].tag == spacewasm_valtype_t::SPACEWASM_I32, params[1].tag);
157 
158  const U32 time_ptr = static_cast<U32>(params[0].u.i32_);
159  const U32 time_size = static_cast<U32>(params[1].u.i32_);
160 
161  spacewasm_hostcall_result_t return_status;
162  if (time_size < Fw::Time::SERIALIZED_SIZE) {
163  // We expect an exact match for serialized time
165  return_status = SPACEWASM_TRAP;
166  } else if (time_size > Fw::Time::SERIALIZED_SIZE) {
167  // We expect an exact match for serialized time
169  return_status = SPACEWASM_TRAP;
170  } else {
171  this->m_pendingHostFunction.kind = WasmSequencer_HostFunction::TIME;
172  this->m_pendingHostFunction.caller = caller;
173  this->m_pendingHostFunction.u.time.ptr = time_ptr;
174  this->m_pendingHostFunction.u.time.len = time_size;
175 
176  // Always pause the interpreter to allow the state machine to process this request
177  return_status = SPACEWASM_PAUSE;
178  }
179 
180  return return_status;
181 }
182 
183 spacewasm_hostcall_result_t WasmSequencer::wasmReadTelemetry(spacewasm_caller_t* caller,
184  const spacewasm_value_t* params,
185  size_t n_params,
187  FW_ASSERT(!this->m_pendingHostFunction.isPending());
188  // These are automatically validated by spacewasm so it should be safe to assert them
189  FW_ASSERT(params != nullptr);
190  FW_ASSERT(n_params == 5, static_cast<FwAssertArgType>(n_params));
191 
192  // FwChanIdType always in 64-bits
193  FW_ASSERT(params[0].tag == spacewasm_valtype_t::SPACEWASM_I64, params[0].tag);
194  FW_ASSERT(params[1].tag == spacewasm_valtype_t::SPACEWASM_I32, params[1].tag);
195  FW_ASSERT(params[2].tag == spacewasm_valtype_t::SPACEWASM_I32, params[2].tag);
196  FW_ASSERT(params[3].tag == spacewasm_valtype_t::SPACEWASM_I32, params[3].tag);
197  FW_ASSERT(params[4].tag == spacewasm_valtype_t::SPACEWASM_I32, params[4].tag);
198 
199  I64 id = params[0].u.i64_;
200  const U32 time_ptr = static_cast<U32>(params[1].u.i32_);
201  const U32 time_size = static_cast<U32>(params[2].u.i32_);
202  const U32 value_ptr = static_cast<U32>(params[3].u.i32_);
203  const U32 value_size = static_cast<U32>(params[4].u.i32_);
204 
205  // The telemetry port is a plain (not required) output port, so guard against an
206  // unconnected deployment before dispatching; the generated invoker would FW_ASSERT.
207  if (!this->isConnected_getTlmChan_OutputPort(0)) {
209  return SPACEWASM_TRAP;
210  }
211 
212  spacewasm_hostcall_result_t return_status;
213  if (time_size < Fw::Time::SERIALIZED_SIZE) {
214  // We expect an exact match for serialized time
217  return_status = SPACEWASM_TRAP;
218  } else if (time_size > Fw::Time::SERIALIZED_SIZE) {
219  // We expect an exact match for serialized time
222  return_status = SPACEWASM_TRAP;
223  } else if (id < 0 || static_cast<U64>(id) > static_cast<U64>(std::numeric_limits<FwChanIdType>::max())) {
224  // A guest id that does not fit FwChanIdType would silently alias a different,
225  // valid channel if cast directly. Reject it instead of truncating.
227  return_status = SPACEWASM_TRAP;
228  } else {
229  this->m_pendingHostFunction.kind = WasmSequencer_HostFunction::TELEMETRY;
230  this->m_pendingHostFunction.caller = caller;
231  this->m_pendingHostFunction.u.telemetry.chanId = static_cast<FwChanIdType>(id);
232  this->m_pendingHostFunction.u.telemetry.timePtr = time_ptr;
233  this->m_pendingHostFunction.u.telemetry.timeLen = time_size;
234  this->m_pendingHostFunction.u.telemetry.valuePtr = value_ptr;
235  this->m_pendingHostFunction.u.telemetry.valueLen = value_size;
236 
237  // Always pause the interpreter to allow the state machine to process this request
238  return_status = SPACEWASM_PAUSE;
239  }
240 
241  return return_status;
242 }
243 
244 spacewasm_hostcall_result_t WasmSequencer::wasmReadParameter(spacewasm_caller_t* caller,
245  const spacewasm_value_t* params,
246  size_t n_params,
248  FW_ASSERT(!this->m_pendingHostFunction.isPending());
249  // These are automatically validated by spacewasm so it should be safe to assert them
250  FW_ASSERT(params != nullptr);
251  FW_ASSERT(n_params == 3, static_cast<FwAssertArgType>(n_params));
252 
253  // FwPrmIdType always in 64-bits
254  FW_ASSERT(params[0].tag == spacewasm_valtype_t::SPACEWASM_I64, params[0].tag);
255  FW_ASSERT(params[1].tag == spacewasm_valtype_t::SPACEWASM_I32, params[1].tag);
256  FW_ASSERT(params[2].tag == spacewasm_valtype_t::SPACEWASM_I32, params[2].tag);
257 
258  I64 id = params[0].u.i64_;
259  const U32 ptr = static_cast<U32>(params[1].u.i32_);
260  const U32 len = static_cast<U32>(params[2].u.i32_);
261 
262  // The parameter port is a plain (not required) output port, so guard against an
263  // unconnected deployment before dispatching; the generated invoker would FW_ASSERT.
264  if (!this->isConnected_getParam_OutputPort(0)) {
266  return SPACEWASM_TRAP;
267  }
268 
269  if (id < 0 || static_cast<U64>(id) > static_cast<U64>(std::numeric_limits<FwPrmIdType>::max())) {
270  // A guest id that does not fit FwPrmIdType would silently alias a different,
271  // valid parameter if cast directly. Reject it instead of truncating. Compare in U64 so the
272  // bound holds even if FwPrmIdType is configured wider than I64's positive range.
274  return SPACEWASM_TRAP;
275  }
276 
277  this->m_pendingHostFunction.kind = WasmSequencer_HostFunction::PARAMETER;
278  this->m_pendingHostFunction.caller = caller;
279  this->m_pendingHostFunction.u.parameter.prmId = static_cast<FwPrmIdType>(id);
280  this->m_pendingHostFunction.u.parameter.ptr = ptr;
281  this->m_pendingHostFunction.u.parameter.len = len;
282 
283  // Always pause the interpreter to allow the state machine to process this request
284  return SPACEWASM_PAUSE;
285 }
286 
287 spacewasm_hostcall_result_t WasmSequencer::wasmCommand(struct spacewasm_caller_t* caller,
288  const struct spacewasm_value_t* params,
289  size_t n_params,
290  struct spacewasm_value_t* out_result) {
291  FW_ASSERT(!this->m_pendingHostFunction.isPending());
292  // These are automatically validated by spacewasm so it should be safe to assert them
293  FW_ASSERT(params != nullptr);
294  FW_ASSERT(n_params == 2, static_cast<FwAssertArgType>(n_params));
295  FW_ASSERT(params[0].tag == spacewasm_valtype_t::SPACEWASM_I32, params[0].tag);
296  FW_ASSERT(params[1].tag == spacewasm_valtype_t::SPACEWASM_I32, params[1].tag);
297 
298  const U32 ptr = static_cast<U32>(params[0].u.i32_);
299  const U32 len = static_cast<U32>(params[1].u.i32_);
300 
301  // cmdOut is a plain (not required) output port, so guard against an unconnected
302  // deployment before dispatching; the generated invoker would FW_ASSERT.
303  if (!this->isConnected_cmdOut_OutputPort(0)) {
305  return SPACEWASM_TRAP;
306  }
307 
308  constexpr const U32 maxPayload = FW_COM_BUFFER_MAX_SIZE - sizeof(FwPacketDescriptorType);
309  spacewasm_hostcall_result_t return_status;
310  if (len > maxPayload) {
312  return_status = SPACEWASM_TRAP;
313  } else {
314  this->m_pendingHostFunction.kind = WasmSequencer_HostFunction::COMMAND;
315  this->m_pendingHostFunction.caller = caller;
316  this->m_pendingHostFunction.u.command.ptr = ptr;
317  this->m_pendingHostFunction.u.command.len = len;
318 
319  // Always pause the interpreter to allow the state machine to process this request
320  return_status = SPACEWASM_PAUSE;
321  }
322 
323  return return_status;
324 }
325 
326 spacewasm_hostcall_result_t WasmSequencer::wasmEvent(spacewasm_caller_t* caller,
327  const spacewasm_value_t* params,
328  size_t n_params,
330  FW_ASSERT(!this->m_pendingHostFunction.isPending());
331  // These are automatically validated by spacewasm so it should be safe to assert them
332  FW_ASSERT(params != nullptr);
333  FW_ASSERT(n_params == 3, static_cast<FwAssertArgType>(n_params));
334  FW_ASSERT(params[0].tag == spacewasm_valtype_t::SPACEWASM_I32, params[0].tag);
335  FW_ASSERT(params[1].tag == spacewasm_valtype_t::SPACEWASM_I32, params[1].tag);
336  FW_ASSERT(params[2].tag == spacewasm_valtype_t::SPACEWASM_I32, params[2].tag);
337 
338  // The requested severity is validated when the event is dispatched (see the
339  // EVENT case in dispatchPendingHostFunction). A forbidden or out-of-range
340  // severity is reported (with the guest message) rather than trapping, so we
341  // read the message here in all cases and stash the raw id.
342  U32 ptr = static_cast<U32>(params[1].u.i32_);
343  U32 len = static_cast<U32>(params[2].u.i32_);
344  if (len > FW_LOG_STRING_MAX_SIZE) {
346  }
347 
348  // Pend this event dispatch to be executed by the sequencer state machine
349  this->m_pendingHostFunction.kind = WasmSequencer_HostFunction::EVENT;
350  this->m_pendingHostFunction.caller = caller;
351  this->m_pendingHostFunction.u.event.rawSeverity = static_cast<U32>(params[0].u.i32_);
352  this->m_pendingHostFunction.u.event.msgPtr = ptr;
353  this->m_pendingHostFunction.u.event.msgLen = len;
354 
355  return SPACEWASM_PAUSE;
356 }
357 
358 spacewasm_hostcall_result_t WasmSequencer::wasmRsleep(spacewasm_caller_t* caller,
359  const spacewasm_value_t* params,
360  size_t n_params,
362  FW_ASSERT(!this->m_pendingHostFunction.isPending());
363  FW_ASSERT(params != nullptr);
364  FW_ASSERT(n_params == 1, static_cast<FwAssertArgType>(n_params));
365  FW_ASSERT(params[0].tag == spacewasm_valtype_t::SPACEWASM_I64, params[0].tag);
366 
367  const U64 us = static_cast<U64>(params[0].u.i64_);
368 
369  // The seconds part of the duration must fit the U32 fields of Fw::Time; a
370  // guest value large enough to overflow it would silently truncate. Reject it.
371  if ((us / 1000000u) > static_cast<U64>(std::numeric_limits<U32>::max())) {
373  return SPACEWASM_TRAP;
374  }
375 
376  this->m_pendingHostFunction.kind = WasmSequencer_HostFunction::RSLEEP;
377  this->m_pendingHostFunction.caller = caller;
378  this->m_pendingHostFunction.u.rsleep.us = us;
379 
380  return SPACEWASM_PAUSE;
381 }
382 
383 spacewasm_hostcall_result_t WasmSequencer::wasmAsleep(spacewasm_caller_t* caller,
384  const spacewasm_value_t* params,
385  size_t n_params,
387  FW_ASSERT(!this->m_pendingHostFunction.isPending());
388  FW_ASSERT(params != nullptr);
389  FW_ASSERT(n_params == 1, static_cast<FwAssertArgType>(n_params));
390  FW_ASSERT(params[0].tag == spacewasm_valtype_t::SPACEWASM_I64, params[0].tag);
391 
392  const U64 us = static_cast<U64>(params[0].u.i64_);
393 
394  // The seconds part of the duration must fit the U32 fields of Fw::Time; a
395  // guest value large enough to overflow it would silently truncate. Reject it.
396  if ((us / 1000000u) > static_cast<U64>(std::numeric_limits<U32>::max())) {
398  return SPACEWASM_TRAP;
399  }
400 
401  this->m_pendingHostFunction.kind = WasmSequencer_HostFunction::ASLEEP;
402  this->m_pendingHostFunction.caller = caller;
403  this->m_pendingHostFunction.u.asleep.us = us;
404 
405  return SPACEWASM_PAUSE;
406 }
407 
408 spacewasm_hostcall_result_t WasmSequencer::wasmSerialOut(spacewasm_caller_t* caller,
409  const spacewasm_value_t* params,
410  size_t n_params,
412  FW_ASSERT(!this->m_pendingHostFunction.isPending());
413  // These are automatically validated by spacewasm so it should be safe to assert them
414  FW_ASSERT(params != nullptr);
415  FW_ASSERT(n_params == 3, static_cast<FwAssertArgType>(n_params));
416  FW_ASSERT(params[0].tag == spacewasm_valtype_t::SPACEWASM_I32, params[0].tag);
417  FW_ASSERT(params[1].tag == spacewasm_valtype_t::SPACEWASM_I32, params[1].tag);
418  FW_ASSERT(params[2].tag == spacewasm_valtype_t::SPACEWASM_I32, params[2].tag);
419 
420  const I32 index = params[0].u.i32_;
421  const U32 ptr = static_cast<U32>(params[1].u.i32_);
422  const U32 len = static_cast<U32>(params[2].u.i32_);
423 
424  // Reject if the payload does not fit the copy-out buffer. A serialOut buffer that was never
425  // configured (serialOutMaxSize == 0 in configure()) is null-backed with capacity 0; trap even a
426  // zero-length send in that case rather than forwarding a null-backed buffer to serialOut_out.
427  if (len > this->m_serialOutBuffer.getCapacity() || this->m_serialOutBuffer.getBuffAddr() == nullptr) {
429  static_cast<U32>(this->m_serialOutBuffer.getCapacity()));
430  return SPACEWASM_TRAP;
431  }
432 
433  if (index < 0 || index >= this->getNum_serialOut_OutputPorts() ||
434  !this->isConnected_serialOut_OutputPort(static_cast<FwIndexType>(index))) {
436  static_cast<U32>(this->getNum_serialOut_OutputPorts()));
437  return SPACEWASM_TRAP;
438  }
439 
440  this->m_pendingHostFunction.kind = WasmSequencer_HostFunction::SERIAL_OUT;
441  this->m_pendingHostFunction.caller = caller;
442  this->m_pendingHostFunction.u.serialOut.index = static_cast<U32>(index);
443  this->m_pendingHostFunction.u.serialOut.ptr = ptr;
444  this->m_pendingHostFunction.u.serialOut.len = len;
445 
446  // Always pause the interpreter to allow the state machine to process this request
447  return SPACEWASM_PAUSE;
448 }
449 
450 spacewasm_hostcall_result_t WasmSequencer::wasmSerialRecv(spacewasm_caller_t* caller,
451  const spacewasm_value_t* params,
452  size_t n_params,
454  FW_ASSERT(!this->m_pendingHostFunction.isPending());
455  // These are automatically validated by spacewasm so it should be safe to assert them
456  FW_ASSERT(params != nullptr);
457  FW_ASSERT(n_params == 5, static_cast<FwAssertArgType>(n_params));
458  FW_ASSERT(params[0].tag == spacewasm_valtype_t::SPACEWASM_I32, params[0].tag);
459  FW_ASSERT(params[1].tag == spacewasm_valtype_t::SPACEWASM_I32, params[1].tag);
460  FW_ASSERT(params[2].tag == spacewasm_valtype_t::SPACEWASM_I32, params[2].tag);
461  FW_ASSERT(params[3].tag == spacewasm_valtype_t::SPACEWASM_I32, params[3].tag);
462  FW_ASSERT(params[4].tag == spacewasm_valtype_t::SPACEWASM_I32, params[4].tag);
463 
464  const I32 index = params[0].u.i32_;
465  const U32 data_ptr = static_cast<U32>(params[1].u.i32_);
466  const U32 data_len = static_cast<U32>(params[2].u.i32_);
467  const U32 actual_size_ptr = static_cast<U32>(params[3].u.i32_);
468  const I32 block_type = params[4].u.i32_;
469 
470  if (index < 0 || index >= NUM_SERIALIN_INPUT_PORTS) {
473  return SPACEWASM_TRAP;
474  }
475 
476  if (block_type < 0 || block_type > static_cast<I32>(std::numeric_limits<Svc::BlockState::SerialType>::max()) ||
477  !Svc::BlockState::isValid(static_cast<Svc::BlockState::SerialType>(block_type))) {
478  this->log_WARNING_HI_InvalidBlockingTypeValue(block_type);
479  return SPACEWASM_TRAP;
480  }
481 
482  this->m_pendingHostFunction.kind = WasmSequencer_HostFunction::SERIAL_RECV;
483  this->m_pendingHostFunction.caller = caller;
484  this->m_pendingHostFunction.u.serialRecv.index = static_cast<U32>(index);
485  this->m_pendingHostFunction.u.serialRecv.dataPtr = data_ptr;
486  this->m_pendingHostFunction.u.serialRecv.dataSize = data_len;
487  this->m_pendingHostFunction.u.serialRecv.actualSizePtr = actual_size_ptr;
488  this->m_pendingHostFunction.u.serialRecv.blockingType = static_cast<Svc::BlockState::T>(block_type);
489 
490  // Always pause the interpreter to allow the state machine to process this request
491  return SPACEWASM_PAUSE;
492 }
493 
494 } // namespace Svc
union spacewasm_value_payload_t u
Definition: spacewasm.h:412
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
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.
FwIdType FwPrmIdType
The type of a parameter identifier.
bool isConnected_getTlmChan_OutputPort(FwIndexType portNum) const
struct spacewasm_caller_t spacewasm_caller_t
Definition: spacewasm.h:369
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
T
The raw enum type.
Serializable::SizeType getCapacity() const override
Get buffer capacity.
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&#39;s C host-function ABI to a member handler.
void log_WARNING_HI_HostFunctionInvalidPort(const Svc::WasmSequencer_HostFunction &host_function, I32 index, U32 numPorts) const
U8 * getBuffAddr()
Get buffer address for data filling (non-const version)
bool isConnected_serialOut_OutputPort(FwIndexType portNum) const
FwIdType FwChanIdType
The type of a telemetry channel identifier.
spacewasm_valtype_t tag
Definition: spacewasm.h:411
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
Definition: spacewasm.h:160
void log_WARNING_HI_BufferTooLarge(const Svc::WasmSequencer_HostFunction &host_function, U32 size, U32 maxSize) const
static constexpr FwIndexType getNum_serialOut_OutputPorts()
spacewasm_status_t
Definition: spacewasm.h:37
RateGroupDivider component implementation.
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
#define FW_ASSERT(...)
Definition: Assert.hpp:14
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