skip to content
==> include/mesh/abi/trace.h <==
1/* @ajax/mesh-abi-trace: Each program's ring of task trace records.
2 *
3 * Part of alpha-c-mesh, a C port of alpha-rust-mesh (README.md says from where). */
4#ifndef MESH_ABI_TRACE_H
5#define MESH_ABI_TRACE_H
6
7#include <stdbool.h>
8#include <stddef.h>
9#include <stdint.h>
10
11/* ---------------------------------------------------------------- trace */
12/* Program s's last TRACE_PER_PROG task records, record n = atom.add(P_TRACE_N)
13 * at `trace_rec(s, n)`: { slot | node << 8 | op << 16, ticket, start_lo, end_lo }
14 * (globaltimer low words). */
15#define MESH_TRACE_BASE 0x1A000
16#define MESH_TRACE_PER_PROG 128u
17#define MESH_TRACE_BYTES 16
18
19/* Program s's last TRACE_PER_PROG task records, record n = atom.add(P_TRACE_N)
20 * at `trace_rec(s, n)`: { slot | node << 8 | op << 16, ticket, start_lo, end_lo }
21 * (globaltimer low words). */
22static inline size_t mesh_trace_rec(uint32_t slot, uint32_t n) {
23    return MESH_TRACE_BASE + MESH_TRACE_BYTES * ((size_t)MESH_TRACE_PER_PROG * (size_t)slot + (size_t)(n % MESH_TRACE_PER_PROG));
24}
25
26#endif