mirror of
https://dev.lirent.ru/Vatrog/vm-automation-signaling.git
synced 2026-06-20 19:06:37 +03:00
709f4b586a
An epoll-driven, neutral transfer-event bus that connects sensors and input actuators to one or more controls, bidirectionally. It owns the transfer context and events — delivery order, priority, protocol-level timing, and an interrupt-driven event model over fd sources (eventfd/timerfd/sockets) — and stays agnostic to both the sensor/input drivers and the control. What lives here: - memctx: a coherent address-space context per endpoint — the guest address-space root paired with a pre-opened read-only RAM-region fd, with per-endpoint epoch invalidation and retained replay to late subscribers. Perception lives in out-of-tree sensor libraries that consume this datum read-only. - exclusive-ownership leases for destructive resource classes (input, power, memory-write). - write-signaled memory writes (MEMWRITE): an atomic write to guest memory routed through the seam under an exclusive lease, never a writable mapping. - a host-management seam for VM lifecycle/status and a neutral input-injection command path. - multi-VM endpoints; capability-gated, audited control authorization over an in-process or unix-socket transport. Builds against headers only by default (a stub mode that exercises the seam without a VM); armed builds link the real sensor/input libraries behind flags. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
49 lines
2.1 KiB
C
49 lines
2.1 KiB
C
#ifndef VMSIG_CTX_H
|
|
#define VMSIG_CTX_H
|
|
#include "vmsig_event.h"
|
|
|
|
/* vmsig_ctx.h — the "transfer context": the SISC-critical seam owning PRIORITY,
|
|
* SEQUENCING and PROTOCOL timing of delivery. Behavioral timing does NOT belong
|
|
* here — commands arrive already decided from control; the context merely
|
|
* orders and paces them on the "wire". */
|
|
|
|
typedef struct vmsig_ctx vmsig_ctx; /* opaque: queues, seq, timing */
|
|
|
|
/* Protocol (RS232-like) transmission timings — transport ONLY, not behavior.
|
|
* All zeros = pass-through (no pacing). */
|
|
typedef struct {
|
|
uint32_t min_gap_ns; /* min. gap between channel events (rate-cap) */
|
|
uint32_t coalesce_ns; /* collapse bursts of one kind within a window */
|
|
uint32_t max_inflight; /* backpressure depth on a channel before drop */
|
|
uint8_t drop_policy; /* VMSIG_DROP_* */
|
|
} vmsig_timing;
|
|
|
|
#define VMSIG_DROP_OLDEST 0
|
|
#define VMSIG_DROP_NEWEST 1
|
|
#define VMSIG_DROP_BLOCK 2
|
|
|
|
vmsig_ctx* vmsig_ctx_new(void);
|
|
void vmsig_ctx_free(vmsig_ctx* c);
|
|
|
|
/* Policy per (source,dir): default priority + protocol timing. They live
|
|
* here, NOT in adapters and NOT in control. */
|
|
int vmsig_ctx_set_policy(vmsig_ctx* c, vmsig_source src, vmsig_dir dir,
|
|
vmsig_prio default_prio, const vmsig_timing* t);
|
|
|
|
/* Enqueue an event into the `dir`-direction context (assigns seq, applies
|
|
* priority/timing/coalescing/backpressure). 0 — enqueued, 1 —
|
|
* coalesced/dropped by policy, -1 — error. On success takes ownership of
|
|
* ev->payload. Thread-safe (the UP side is called from worker threads). */
|
|
int vmsig_ctx_submit(vmsig_ctx* c, vmsig_dir dir, vmsig_event* ev);
|
|
|
|
/* Fetch the next event of direction `dir` ready for delivery, honoring
|
|
* priority + protocol timing. 1 — event written to out, 0 — nothing yet
|
|
* (caller arms timing_fd), -1 — error. */
|
|
int vmsig_ctx_next(vmsig_ctx* c, vmsig_dir dir, vmsig_event* out);
|
|
|
|
/* timerfd by which the context wakes the loop when a paced/coalesced event
|
|
* has matured. Registered in the core like any source. -1 if not needed. */
|
|
int vmsig_ctx_timing_fd(vmsig_ctx* c, vmsig_dir dir);
|
|
|
|
#endif /* VMSIG_CTX_H */
|