interplane.Get Omega
Read in your language

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

branch main Branches Tags History

omega-mv / gpu / driver / gsp / irqcc.om

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