==> include/mesh/abi/wasm.h <==1/* @ajax/mesh-abi-wasm: The wasm executor's calling contract: module, exports, windows and info codes.
2 *
3 * Part of alpha-c-mesh, a C port of alpha-rust-mesh (README.md says from where). */
4#ifndef MESH_ABI_WASM_H
5#define MESH_ABI_WASM_H
6
7#include <stdbool.h>
8#include <stddef.h>
9#include <stdint.h>
10
11#define MESH_WASM_MODULE "mesh"
12#define MESH_WASM_EXPORT_MEMORY "memory"
13#define MESH_WASM_EXPORT_INIT "mesh_init"
14#define MESH_WASM_EXPORT_TASK "mesh_task"
15#define MESH_WASM_EXPORT_RT_ABI "mesh_rt_abi"
16/* Exported FTZ helpers: the float guard's allow-list. */
17#define MESH_WASM_FTZ_PREFIX "mesh_ftz_"
18/* Windows (handles): the slot's own view; the exchange page (lockstep
19 * programs only: EX_BASE .. + EX_BYTES); another slot's view, resolved by
20 * `peer` for the running task. */
21#define MESH_WASM_W_VIEW 0u
22#define MESH_WASM_W_EXCHANGE 1u
23#define MESH_WASM_W_PEER 0x100u
24/* `info` codes. */
25#define MESH_WASM_I_SLOT 0u
26#define MESH_WASM_I_NODE 1u
27#define MESH_WASM_I_NODES 2u
28#define MESH_WASM_I_TICKET 3u
29/* H_PEER and H_SYSTEMS (read live, as mesh-rt does). */
30#define MESH_WASM_I_SYSTEM 4u
31#define MESH_WASM_I_SYSTEMS 5u
32/* PX_PARAM (read live). */
33#define MESH_WASM_I_PARAM 6u
34#define MESH_WASM_I_SMS 7u
35#define MESH_WASM_I_VIEW_BYTES 8u
36/* P_REQ_LEN clamped to the window's req_max. */
37#define MESH_WASM_I_REQ_LEN 9u
38#define MESH_WASM_I_REQ_OFF 10u
39#define MESH_WASM_I_RESP_OFF 11u
40#define MESH_WASM_I_RESP_MAX 12u
41#define MESH_WASM_I_INPUT_LEN 13u
42/* 1: the program is the lockstep one (window W_EXCHANGE exists). */
43#define MESH_WASM_I_LOCKSTEP 14u
44#define MESH_WASM_I_READS_MASK 15u
45/* H_GROUP_RANK, H_GROUP_N (the lockstep group: `ctx.group()`), read live. (18 is free: it was the F3 partition.) */
46#define MESH_WASM_I_GROUP_RANK 16u
47#define MESH_WASM_I_GROUP_N 17u
48
49/* The window of another slot's view, resolved by `peer`. */
50static inline uint32_t mesh_wasm_w_peer(uint32_t slot) { return MESH_WASM_W_PEER + slot; }
51
52#endif