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 / rpc.om

336 lines · 6906 bytes Raw Blame History
1note gsp/rpc.om: bounded non-CC GSP-RM queue codec, host replay ONLY. No DMA/MMIO or hardware readiness.
2note NVIDIA 580.173.02 message_queue_cpu.c:434-585,615-735; msgq.c SWAP_RX; rpc.c:11194-11228.
3note Reference aienux c5bb3a4b native/kernel/dev/gb10_gsp_boot.c:152-361.
4note rqcmd/rqstat are caller-owned replay images, NOT device mappings. No implicit hardware backend.
5note rqsend uses rqpay; logical n may exclude appended RM_ALLOC params, physical p includes them.
6note rqrecv captures full declared slots, validates actual alignment padding (not manufactured zeros).
7note Status: 0 empty/success; 1 received; -1 shape/length; -2 full; -3 checksum; -4 sequence;
8note -5 unsupported version/signature; -6 quarantined. Refusals never advance pointers or counters.
9const RQQSZ ulong 262144
10const RQSLOT ulong 4096
11const RQCOUNT ulong 63
12const RQMAX ulong 65536
13const RQVER ulong 50331648
14const RQSIG ulong 1129337430
15const RQU32 ulong 4294967295
16global rqcmd uchar 262144
17global rqstat uchar 262144
18global rqpay uchar 65536
19global rqout uchar 65536
20global rqtmp uchar 65536
21note counters: tx element, rx element, synchronous RPC; increment only after publication/acceptance.
22global rqtx uint 1
23global rqrx uint 1
24global rqseq uint 1
25global rqsent uint 1
26global rqlen ulong 1
27global rqslots ulong 1
28global rqfun ulong 1
29global rqres ulong 1
30global rqpriv ulong 1
31global rqreply ulong 1
32global rqdead uchar 1
33global rqlink uchar 1
34note Preparation is private; single-use token commits sequences only after the chosen publisher succeeds.
35global rqptok ulong 1
36global rqppend uchar 1
37global rqpwr ulong 1
38global rqpcnt ulong 1
39global rqpseq uint 1
40global rqptx uint 1
41global rqpsync uchar 1
42note Array selectors avoid passing globals (not supported by pinned compiler): 0 cmd,1 stat,2 tmp,3 out,4 pay.
43fn rqbyte a ulong o ulong to uchar
44if eq a 0
45ret get rqcmd o
46end
47if eq a 1
48ret get rqstat o
49end
50if eq a 2
51ret get rqtmp o
52end
53if eq a 3
54ret get rqout o
55end
56ret get rqpay o
57end
58fn rqput a ulong o ulong v uchar to void
59if eq a 0
60put rqcmd o v
61ret
62end
63if eq a 1
64put rqstat o v
65ret
66end
67if eq a 2
68put rqtmp o v
69ret
70end
71if eq a 3
72put rqout o v
73ret
74end
75put rqpay o v
76end
77fn rqget32 a ulong o ulong to ulong
78v = ulong 0
79for i ulong 4
80v = or v shl ulong rqbyte a add o i mul i 8
81end
82ret v
83end
84fn rqput32 a ulong o ulong v ulong to void
85for i ulong 4
86rqput a add o i uchar and shr v mul i 8 255
87end
88end
89fn rqsum a ulong n ulong to ulong
90v = ulong 0
91for i ulong n
92v = xor v shl ulong rqbyte a i mul rem i 4 8
93end
94ret v
95end
96fn rqshape a ulong to bool
97if or ne rqget32 a 0 0 ne rqget32 a 4 RQQSZ
98ret false
99end
100if or ne rqget32 a 8 RQSLOT ne rqget32 a 12 RQCOUNT
101ret false
102end
103if or ne rqget32 a 20 1 ne rqget32 a 24 32
104ret false
105end
106ret eq rqget32 a 28 RQSLOT
107end
108fn rqinit to void
109for i ulong RQQSZ
110put rqcmd i 0
111put rqstat i 0
112end
113rqput32 0 4 RQQSZ
114rqput32 0 8 RQSLOT
115rqput32 0 12 RQCOUNT
116rqput32 0 20 1
117rqput32 0 24 32
118rqput32 0 28 RQSLOT
119put rqtx 0 0
120put rqrx 0 0
121put rqseq 0 0
122put rqsent 0 0
123put rqlen 0 0
124put rqslots 0 0
125put rqdead 0 0
126put rqlink 0 0
127put rqppend 0 0
128end
129note Replay peer queue creation is explicit input, never inferred from a boot command.
130fn rqpeer to void
131for i ulong 32
132put rqstat i get rqcmd i
133end
134rqput32 1 16 0
135put rqlink 0 1
136end
137fn rqclear n ulong to void
138if gt n RQMAX
139trap 3
140end
141for i ulong n
142put rqpay i 0
143end
144end
145fn rqframe f ulong n ulong p ulong seq uint e ulong to void
146for i ulong mul e RQSLOT
147put rqtmp i 0
148end
149rqput32 2 36 ulong get rqtx 0
150rqput32 2 40 e
151rqput32 2 48 RQVER
152rqput32 2 52 RQSIG
153rqput32 2 56 add 32 n
154rqput32 2 60 f
155rqput32 2 64 RQU32
156rqput32 2 68 RQU32
157rqput32 2 72 ulong seq
158for i ulong p
159put rqtmp add 80 i get rqpay i
160end
161note All padding was zeroed above; supported RM_ALLOC fixed32 ends exactly on alignment.
162rqput32 2 32 rqsum 2 mul div add add 80 n 7 8 8
163end
164fn rqcopy wr ulong e ulong to void
165for i ulong mul e RQSLOT
166o = rem add wr div i RQSLOT RQCOUNT
167o = add RQSLOT mul o RQSLOT
168o = add o rem i RQSLOT
169put rqcmd o get rqtmp i
170end
171end
172fn rqprep f ulong n ulong p ulong sync bool to long
173if ne get rqdead 0 0
174ret -6
175end
176if ne get rqppend 0 0
177ret -6
178end
179if eq add get rqptok 0 1 0
180ret -6
181end
182if or gt f RQU32 or gt n 65456 lt p n
183ret -1
184end
185note The sole supported unchecked physical tail is vendor RM_ALLOC's aligned fixed32 body.
186if and gt p n not and eq f 103 eq n 32
187ret -1
188end
189e = div add add 80 n 4095 RQSLOT
190if or gt p sub mul e RQSLOT 80 gt p 65456
191ret -1
192end
193if not rqshape 0
194ret -1
195end
196wr = rqget32 0 16
197rd = rqget32 1 32
198if or ge wr RQCOUNT ge rd RQCOUNT
199ret -1
200end
201if lt rem sub add rd RQCOUNT add wr 1 RQCOUNT e
202ret -2
203end
204seq = uint 0
205if sync
206seq = get rqseq 0
207end
208rqframe f n p seq e
209put rqptok 0 add get rqptok 0 1
210put rqppend 0 1
211put rqpwr 0 wr
212put rqpcnt 0 e
213put rqpseq 0 seq
214put rqptx 0 get rqtx 0
215put rqpsync 0 0
216if sync
217put rqpsync 0 1
218end
219ret 0
220end
221fn rqcommit token ulong to long
222if or ne get rqppend 0 1 ne token get rqptok 0
223ret -6
224end
225if or ne get rqtx 0 get rqptx 0 ne rqget32 0 16 get rqpwr 0
226ret -6
227end
228if and ne get rqpsync 0 0 ne get rqseq 0 get rqpseq 0
229ret -6
230end
231wr = get rqpwr 0
232e = get rqpcnt 0
233seq = get rqpseq 0
234rqput32 0 16 rem add wr e RQCOUNT
235put rqsent 0 seq
236put rqtx 0 add get rqtx 0 uint 1
237if ne get rqpsync 0 0
238put rqseq 0 add seq uint 1
239end
240put rqppend 0 0
241ret 0
242end
243fn rqsend f ulong n ulong p ulong sync bool to long
244r = rqprep f n p sync
245if ne r 0
246ret r
247end
248rqcopy get rqpwr 0 get rqpcnt 0
249ret rqcommit get rqptok 0
250end
251fn rqcapt rd ulong e ulong to void
252for i ulong mul e RQSLOT
253p = rem add rd div i RQSLOT RQCOUNT
254p = add RQSLOT mul p RQSLOT
255p = add p rem i RQSLOT
256put rqtmp i get rqstat p
257end
258end
259fn rqvalid m ulong to long
260aligned = mul div add m 7 8 8
261if ne rqsum 2 aligned 0
262ret -3
263end
264if ne rqget32 2 36 ulong get rqrx 0
265ret -4
266end
267if or ne rqget32 2 48 RQVER ne rqget32 2 52 RQSIG
268ret -5
269end
270note Strict single-client non-CC profile: no authentication metadata or routing union.
271for i ulong 32
272if ne get rqtmp i 0
273ret -5
274end
275end
276if or ne rqget32 2 44 0 ne rqget32 2 76 0
277ret -5
278end
279ret 0
280end
281fn rqaccept n ulong e ulong rd ulong to void
282for i ulong mul e RQSLOT
283put rqout i get rqtmp i
284end
285put rqlen 0 sub n 32
286put rqslots 0 mul e RQSLOT
287put rqfun 0 rqget32 3 60
288put rqres 0 rqget32 3 64
289put rqpriv 0 rqget32 3 68
290put rqreply 0 rqget32 3 72
291rqput32 0 32 rem add rd e RQCOUNT
292put rqrx 0 add get rqrx 0 uint 1
293end
294fn rqrecv to long
295if ne get rqdead 0 0
296ret -6
297end
298if not rqshape 0
299ret -1
300end
301if not rqshape 1
302if eq get rqlink 0 0
303ret 0
304end
305ret -1
306end
307put rqlink 0 1
308wr = rqget32 1 16
309rd = rqget32 0 32
310if or ge wr RQCOUNT ge rd RQCOUNT
311ret -1
312end
313avail = rem sub add wr RQCOUNT rd RQCOUNT
314if eq avail 0
315ret 0
316end
317o = add RQSLOT mul rd RQSLOT
318e = rqget32 1 add o 40
319n = rqget32 1 add o 56
320if or or eq e 0 gt e 16 gt e avail
321ret -1
322end
323if or lt n 32 gt n 65488
324ret -1
325end
326if ne e div add add 48 n 4095 RQSLOT
327ret -1
328end
329rqcapt rd e
330r = rqvalid add 48 n
331if ne r 0
332ret r
333end
334rqaccept n e rd
335ret 1
336end