omega-mv
Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.
Brought by drakestapleton
omega-mv / gpu / driver / gsp / irq.om
| 1 | note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 2 | note GSP host interrupt service policy. Host model ONLY; no physical IRQ/MMIO admission. |
| 3 | note Source: NVIDIA open-gpu-kernel-modules 580.173.02 @20e4e6e19cc26ba47b5cbe23130a396be100c427 |
| 4 | note kernel_gsp_tu102.c:1188-1203: clear edge SWGEN0 BEFORE draining RPC, stop register access on lockdown. |
| 5 | note kernel_falcon_ga102.c:318-320: pending = FALCON_IRQSTAT & RISCV_IRQMASK & RISCV_IRQDEST. |
| 6 | note dev_falcon_v4.h:26-35: IRQSCLR=4, IRQSTAT=8, SWGEN0 bit6, HALT bit4. |
| 7 | note WolframLanguageEvaluator {2^6,2^4,BitOr[2^6,2^4]} -> {64,16,80}. |
| 8 | note HALT (bit4=16) sets iqhalt=1 and quarantines (-13) with pending bit retained; link irqcc.om + logdec.om for CrashCat V1 decoding. |
| 9 | note Unknown non-HALT routed sources retain pending bits and quarantine (-13) with iqhalt=0. |
| 10 | note iqinit admits one nonzero generation exactly once. No reset/rearm/reclaim or idle claim exists. |
| 11 | note iqservice gen budget returns serviced events, or -1 args, -4 lifecycle, -9 non-model/inactive, |
| 12 | note -10 generation, -11 budget exhausted, -12 quarantined, -13 unsupported IRQ, -14 lockdown, |
| 13 | note -15 peer service failure. iqdone is progress before an error, never completion/idle authority. |
| 14 | note Link irqsim.om explicitly. Its seam iqread/iqclear/iqready/iqrecv/iqmask/iqpm has no device effects. |
| 15 | const IQSW uint 64 |
| 16 | const IQHALT uint 16 |
| 17 | const IQMAX ulong 64 |
| 18 | const IQCCMAX ulong 65536 |
| 19 | global iqmode ulong 1 |
| 20 | global iqstate ulong 1 |
| 21 | global iqgen ulong 1 |
| 22 | global iqdone ulong 1 |
| 23 | global iqpend uint 1 |
| 24 | global iqhalt ulong 1 |
| 25 | global iqccbound ulong 1 |
| 26 | global iqccpa ulong 1 |
| 27 | global iqccsz ulong 1 |
| 28 | global iqccpkts ulong 1 |
| 29 | global iqccerr long 1 |
| 30 | note iqccbind registers or clears a CrashCat queue buffer for HALT IRQ decoding (used by irqcc.om): |
| 31 | note mode=0 unbind, mode=1 linear ccbuf[0..sz), mode=2 paged LibosLog ring lgbuf[0..sz). |
| 32 | fn iqccbind mode ulong pa ulong sz ulong to long |
| 33 | if eq mode 0 |
| 34 | put iqccbound 0 0 |
| 35 | put iqccpa 0 0 |
| 36 | put iqccsz 0 0 |
| 37 | put iqccpkts 0 0 |
| 38 | put iqccerr 0 0 |
| 39 | ret 0 |
| 40 | end |
| 41 | if eq mode 1 |
| 42 | if or eq sz 0 gt sz IQCCMAX |
| 43 | ret -1 |
| 44 | end |
| 45 | put iqccbound 0 1 |
| 46 | put iqccpa 0 pa |
| 47 | put iqccsz 0 sz |
| 48 | put iqccpkts 0 0 |
| 49 | put iqccerr 0 0 |
| 50 | ret 0 |
| 51 | end |
| 52 | if eq mode 2 |
| 53 | if or lt sz 4096 gt sz IQCCMAX |
| 54 | ret -1 |
| 55 | end |
| 56 | if ne and sz 4095 0 |
| 57 | ret -1 |
| 58 | end |
| 59 | put iqccbound 0 2 |
| 60 | put iqccpa 0 pa |
| 61 | put iqccsz 0 sz |
| 62 | put iqccpkts 0 0 |
| 63 | put iqccerr 0 0 |
| 64 | ret 0 |
| 65 | end |
| 66 | ret -1 |
| 67 | end |
| 68 | fn iqinit gen ulong to long |
| 69 | if eq gen 0 |
| 70 | ret -1 |
| 71 | end |
| 72 | if ne get iqstate 0 0 |
| 73 | ret -4 |
| 74 | end |
| 75 | put iqgen 0 gen |
| 76 | put iqstate 0 1 |
| 77 | ret 0 |
| 78 | end |
| 79 | fn iqstop err long to long |
| 80 | iqmask |
| 81 | put iqstate 0 2 |
| 82 | ret err |
| 83 | end |
| 84 | fn iqpump budget ulong to long |
| 85 | note At most IQMAX messages plus one readiness check; never consumes beyond caller budget. |
| 86 | for i ulong IQMAX |
| 87 | if not iqready |
| 88 | ret long get iqdone 0 |
| 89 | end |
| 90 | if ge get iqdone 0 budget |
| 91 | ret iqstop -11 |
| 92 | end |
| 93 | r = iqrecv |
| 94 | if lt r 0 |
| 95 | ret iqstop -15 |
| 96 | end |
| 97 | if or eq r 1 eq r 2 |
| 98 | put iqdone 0 add get iqdone 0 1 |
| 99 | else |
| 100 | ret iqstop -15 |
| 101 | end |
| 102 | if eq r 2 |
| 103 | note Lockdown notification forbids ALL subsequent register accesses, including status/masking. |
| 104 | put iqstate 0 3 |
| 105 | ret long get iqdone 0 |
| 106 | end |
| 107 | end |
| 108 | if iqready |
| 109 | ret iqstop -11 |
| 110 | end |
| 111 | ret long get iqdone 0 |
| 112 | end |
| 113 | fn iqservice gen ulong budget ulong to long |
| 114 | if or eq budget 0 gt budget IQMAX |
| 115 | ret -1 |
| 116 | end |
| 117 | if ne gen get iqgen 0 |
| 118 | ret -10 |
| 119 | end |
| 120 | if eq get iqstate 0 2 |
| 121 | ret -12 |
| 122 | end |
| 123 | if eq get iqstate 0 3 |
| 124 | ret -14 |
| 125 | end |
| 126 | if ne get iqstate 0 1 |
| 127 | ret -4 |
| 128 | end |
| 129 | if and ne get iqmode 0 0 ne get iqmode 0 2 |
| 130 | ret -9 |
| 131 | end |
| 132 | if not iqpm |
| 133 | ret -9 |
| 134 | end |
| 135 | put iqdone 0 0 |
| 136 | put iqhalt 0 0 |
| 137 | p = iqread |
| 138 | put iqpend 0 p |
| 139 | if eq p 0 |
| 140 | ret 0 |
| 141 | end |
| 142 | if ne and p not IQSW 0 |
| 143 | if ne and p IQHALT 0 |
| 144 | put iqhalt 0 1 |
| 145 | end |
| 146 | ret iqstop -13 |
| 147 | end |
| 148 | note This acknowledgement must precede the first RPC readiness/service access. |
| 149 | iqclear IQSW |
| 150 | r = iqpump budget |
| 151 | if lt r 0 |
| 152 | ret r |
| 153 | end |
| 154 | if eq get iqstate 0 3 |
| 155 | ret r |
| 156 | end |
| 157 | note Preserve a new edge raised during or after draining. Never clear status after service. |
| 158 | put iqpend 0 iqread |
| 159 | ret r |
| 160 | end |