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 / irqcc.om
| 1 | note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 2 | note gpu/driver/gsp/irqcc.om: Pure-Omega (OM-1) HALT IRQ -> CrashCat V1 integration unit. |
| 3 | note Links gpu/driver/gsp/logdec.om + an IRQ peer (irqsim.om or irqctl.om) + gpu/driver/gsp/irq.om. |
| 4 | note Preserves irq.om HALT quarantine semantics (iqmask, iqstate=2, pending HALT retained, returns -13) |
| 5 | note while draining and optionally formatting bound CrashCat V1 packets via logdec.om on HALT. |
| 6 | note Host-only model integration; never opens devices, maps MMIO, or performs DMA. |
| 7 | note Prefix iqcc. Library unit: no fn main. |
| 8 | |
| 9 | const IQCCLIM ulong 256 |
| 10 | |
| 11 | note Bind CrashCat queue from GspFwWprMeta (lgwpr) via logdec.om lgwprparse. |
| 12 | note mode: 1 = linear ccbuf[0..sz), 2 = paged LibosLog ring lgbuf[0..sz). |
| 13 | note Returns 1 if bound, 0 if WPR meta has no CrashCat queue, or negative error. |
| 14 | fn iqccbindwpr mode ulong to long |
| 15 | r = lgwprparse |
| 16 | if le r 0 |
| 17 | z = iqccbind 0 0 0 |
| 18 | ret r |
| 19 | end |
| 20 | b = iqccbind mode get lgccqpa 0 get lgccqsz 0 |
| 21 | if lt b 0 |
| 22 | ret b |
| 23 | end |
| 24 | ret 1 |
| 25 | end |
| 26 | |
| 27 | note Drain linear CrashCat V1 packets from ccbuf[0..iqccsz) via ccinit/ccnext/lgfmtcc. |
| 28 | fn iqccdrainlin fmtfd int maxpkts ulong to long |
| 29 | r = ccinit get iqccsz 0 |
| 30 | if lt r 0 |
| 31 | put iqccerr 0 r |
| 32 | ret r |
| 33 | end |
| 34 | cnt = ulong 0 |
| 35 | while lt cnt maxpkts bound 256 |
| 36 | r = ccnext |
| 37 | if eq r 0 |
| 38 | break |
| 39 | end |
| 40 | if lt r 0 |
| 41 | put iqccpkts 0 cnt |
| 42 | put iqccerr 0 r |
| 43 | if ge fmtfd 0 |
| 44 | z = lgoflush |
| 45 | end |
| 46 | ret r |
| 47 | end |
| 48 | cnt = add cnt 1 |
| 49 | if ge fmtfd 0 |
| 50 | lgfmtcc |
| 51 | end |
| 52 | end |
| 53 | if ge fmtfd 0 |
| 54 | z = lgoflush |
| 55 | end |
| 56 | put iqccpkts 0 cnt |
| 57 | put iqccerr 0 0 |
| 58 | ret long cnt |
| 59 | end |
| 60 | |
| 61 | note Drain paged LibosLog ring CrashCat V1 packets from lgbuf[0..iqccsz) via lgrinit/ccnextring/lgfmtcc. |
| 62 | fn iqccdrainring fmtfd int maxpkts ulong to long |
| 63 | r = lgrinit get iqccsz 0 LGPAGE |
| 64 | if lt r 0 |
| 65 | put iqccerr 0 r |
| 66 | ret r |
| 67 | end |
| 68 | cnt = ulong 0 |
| 69 | while lt cnt maxpkts bound 256 |
| 70 | r = ccnextring |
| 71 | if eq r 0 |
| 72 | break |
| 73 | end |
| 74 | if lt r 0 |
| 75 | put iqccpkts 0 cnt |
| 76 | put iqccerr 0 r |
| 77 | if ge fmtfd 0 |
| 78 | z = lgoflush |
| 79 | end |
| 80 | ret r |
| 81 | end |
| 82 | cnt = add cnt 1 |
| 83 | if ge fmtfd 0 |
| 84 | lgfmtcc |
| 85 | end |
| 86 | end |
| 87 | if ge fmtfd 0 |
| 88 | z = lgoflush |
| 89 | end |
| 90 | put iqccpkts 0 cnt |
| 91 | put iqccerr 0 0 |
| 92 | ret long cnt |
| 93 | end |
| 94 | |
| 95 | note Drain bound CrashCat V1 queue buffer; fmtfd < 0 skips formatting, fmtfd >= 0 formats via lgfmtcc. |
| 96 | note Returns decoded packet count (>= 0) on success, or negative decoder error. |
| 97 | fn iqccdrain fmtfd int maxpkts ulong to long |
| 98 | put iqccpkts 0 0 |
| 99 | put iqccerr 0 0 |
| 100 | m = get iqccbound 0 |
| 101 | if eq m 0 |
| 102 | ret 0 |
| 103 | end |
| 104 | if or eq maxpkts 0 gt maxpkts IQCCLIM |
| 105 | put iqccerr 0 -1 |
| 106 | ret -1 |
| 107 | end |
| 108 | if ge fmtfd 0 |
| 109 | lgoinit fmtfd |
| 110 | end |
| 111 | if eq m 1 |
| 112 | ret iqccdrainlin fmtfd maxpkts |
| 113 | end |
| 114 | if eq m 2 |
| 115 | ret iqccdrainring fmtfd maxpkts |
| 116 | end |
| 117 | put iqccerr 0 -1 |
| 118 | ret -1 |
| 119 | end |
| 120 | |
| 121 | note Service GSP IRQ and, on HALT quarantine (-13 with iqhalt=1), decode bound CrashCat V1 queue. |
| 122 | note Returns exact iqservice status (-13 on HALT quarantine; CrashCat results in iqccpkts/iqccerr/cc*). |
| 123 | fn iqservicecc gen ulong budget ulong fmtfd int maxpkts ulong to long |
| 124 | r = iqservice gen budget |
| 125 | if and eq r -13 eq get iqhalt 0 1 |
| 126 | if ne get iqccbound 0 0 |
| 127 | d = iqccdrain fmtfd maxpkts |
| 128 | end |
| 129 | end |
| 130 | ret r |
| 131 | end |