1/* @ajax/mesh-abi-ops: Task ops (task, init, req, follow, job) and their reserved results.
2 *
3 * Part of alpha-c-mesh, a C port of alpha-rust-mesh (README.md says from where). */
4#ifndef MESH_ABI_OPS_H
5#define MESH_ABI_OPS_H
67#include <stdbool.h>
8#include <stddef.h>
9#include <stdint.h>
1011/* Ops: 0 the program's task, 1 init (once, on a fresh load or `reset`),
12 * 2 a byte request through the window, 3.. program-defined. */
13#define MESH_OP_TASK 0u
14#define MESH_OP_INIT 1u
15#define MESH_OP_REQ 2u
16/* Reserved for placement (manifest `place = "split"`): render part `arg` of a
17 * frame from the shared state meshd wrote into the view (the owner's, mirrored
18 * over the peer link), consuming no input and advancing nothing. Ops
19 * 3..OP_FOLLOW are program-defined. */
20#define MESH_OP_FOLLOW 0xffu
21/* Reserved for jobs (plan F5; `policy = "job"`): process item
22 * `base + arg` of a job, where `base` is the u64 meshd wrote at the view's
23 * `job_base` offset (the item's high 32 bits: base = item & !0xffff_ffff,
24 * arg = item as u32) before the item's ticket was published. The result is
25 * the item's u32 result (R_JOB_FAIL: the item failed); a program with
26 * `job_out = "off:rec"` writes `rec` more bytes of result at view
27 * `off + rec * (ticket % PROG_RESULTS)` before it returns (meshd reads them
28 * when it collects the completion). A job may name another op. With
29 * `job_payload = "off:len"` an item also writes `len` bytes of payload at view
30 * `off + len * (ticket % PROG_RESULTS)`: meshd keeps them as the item's blob
31 * (content-addressed, off the job log; the result carries its sha256, length
32 * and holders: mesh-host blobs.rs, blobd.rs). */
33#define MESH_OP_JOB 0xfeu
34/* An item's task result that fails the item (it is retried, up to the job's
35 * attempts, then recorded failed with the reason). */
36#define MESH_R_JOB_FAIL 0xffffffffu
37/* The result of op OP_INIT, and of any op a program does not define. */
38#define MESH_R_NONE 0u
39#define MESH_R_BAD_OP 0xffffffffu
4041/* The Rust const asserts that only involve this package. */
42_Static_assert(MESH_OP_JOB > MESH_OP_REQ, "OP_JOB > OP_REQ");
43_Static_assert(MESH_OP_JOB < MESH_OP_FOLLOW, "OP_JOB < OP_FOLLOW");
44_Static_assert(MESH_R_JOB_FAIL == MESH_R_BAD_OP, "R_JOB_FAIL == R_BAD_OP");
45_Static_assert(MESH_OP_FOLLOW > MESH_OP_REQ, "OP_FOLLOW > OP_REQ");
4647#endif