==> include/mesh/abi/node.h <==1/* @ajax/mesh-abi-node: Node records (N_*): a node's SM, heartbeat, tasks and busy time.
2 *
3 * Part of alpha-c-mesh, a C port of alpha-rust-mesh (README.md says from where). */
4#ifndef MESH_ABI_NODE_H
5#define MESH_ABI_NODE_H
6
7#include <stdbool.h>
8#include <stddef.h>
9#include <stdint.h>
10#include "mesh/abi/fields.h"
11
12/* ---------------------------------------------------------------- node records */
13#define MESH_PROG_NODES 0x12000
14#define MESH_PROG_MAX_NODES 32
15#define MESH_NODE_STRIDE 32
16#define MESH_PROG_NODES_BYTES (MESH_PROG_MAX_NODES * MESH_NODE_STRIDE)
17#define MESH_N_SM 0x00 /* u32 %smid */
18#define MESH_N_HEARTBEAT 0x04 /* u32, +1 every loop turn */
19#define MESH_N_TASKS 0x08 /* u32 tasks run */
20#define MESH_N_LAST_OP 0x0c /* u32 the last task's op */
21#define MESH_N_BUSY_NS 0x10 /* u64 nanoseconds spent in tasks (globaltimer) */
22#define MESH_NODE_FIELDS_LEN 5
23extern const mesh_field MESH_NODE_FIELDS[5];
24
25/* Node n of slot s: `node_rec(s, n)`, written by the node's lane 0. */
26static inline size_t mesh_node_rec(uint32_t slot, uint32_t node) {
27 return MESH_PROG_NODES + MESH_PROG_NODES_BYTES * (size_t)slot + MESH_NODE_STRIDE * (size_t)node;
28}
29
30/* The Rust const asserts that only involve this package. */
31_Static_assert(MESH_N_LAST_OP + 4 <= MESH_N_BUSY_NS, "N_LAST_OP + 4 <= N_BUSY_NS");
32_Static_assert(MESH_N_BUSY_NS + 8 <= MESH_NODE_STRIDE, "N_BUSY_NS + 8 <= NODE_STRIDE");
33
34#endif