Skip to main content

vyre_runtime/megakernel/protocol/
control.rs

1/// Non-zero signals the kernel to exit on the next iteration.
2pub const SHUTDOWN: u32 = 0;
3/// Kernel atomic-adds 1 here every time it drains a slot.
4pub const DONE_COUNT: u32 = 1;
5/// Word index in `control` where the tenant-mask table begins.
6pub const TENANT_BASE: u32 = 2;
7/// Word index in `control` where the tenant quota table begins.
8pub const TENANT_QUOTA_BASE: u32 = 32;
9/// Word index in `control` where the tenant fairness counters begin.
10pub const TENANT_FAIRNESS_BASE: u32 = 64;
11/// Number of tenant fairness counters reserved in the control buffer.
12pub const TENANT_FAIRNESS_SLOTS: u32 = 32;
13/// Metrics region start. Per-opcode execution counters live here.
14pub const METRICS_BASE: u32 = TENANT_FAIRNESS_BASE + TENANT_FAIRNESS_SLOTS;
15/// Total number of tracked opcode metric slots.
16pub const METRICS_SLOTS: u32 = 32;
17/// Epoch counter; host increments on each publish batch.
18pub const EPOCH: u32 = METRICS_BASE + METRICS_SLOTS;
19/// Word index in `control` where priority partition offsets begin.
20pub const PRIORITY_OFFSETS_BASE: u32 = EPOCH + 1;
21/// Number of priority partition offset words, including sentinel.
22pub const PRIORITY_OFFSETS_SLOTS: u32 = 6;
23/// Starvation counter word used by the priority scheduler.
24pub const PRIORITY_STARVATION_COUNTER: u32 = PRIORITY_OFFSETS_BASE + PRIORITY_OFFSETS_SLOTS;
25/// Word index in `control` where per-priority fairness counters begin.
26pub const PRIORITY_FAIRNESS_BASE: u32 = PRIORITY_STARVATION_COUNTER + 1;
27/// Number of priority fairness counters reserved in the control buffer.
28pub const PRIORITY_FAIRNESS_SLOTS: u32 = 5;
29/// First observable result word; opcodes write user-visible results here.
30pub const OBSERVABLE_BASE: u32 = 160;
31
32const _: () = {
33    assert!(TENANT_BASE > DONE_COUNT);
34    assert!(TENANT_QUOTA_BASE > TENANT_BASE);
35    assert!(TENANT_FAIRNESS_BASE > TENANT_QUOTA_BASE);
36    assert!(METRICS_BASE >= TENANT_FAIRNESS_BASE + TENANT_FAIRNESS_SLOTS);
37    assert!(EPOCH >= METRICS_BASE + METRICS_SLOTS);
38    assert!(PRIORITY_OFFSETS_BASE > EPOCH);
39    assert!(PRIORITY_STARVATION_COUNTER >= PRIORITY_OFFSETS_BASE + PRIORITY_OFFSETS_SLOTS);
40    assert!(PRIORITY_FAIRNESS_BASE > PRIORITY_STARVATION_COUNTER);
41    assert!(OBSERVABLE_BASE > PRIORITY_FAIRNESS_BASE + PRIORITY_FAIRNESS_SLOTS);
42};