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

328 lines · 6208 bytes Raw Blame History
1note Linux-process checked-mapping mechanism, NOT kernel transport or a hardware admission resolver.
2note Link instead of replay.om; no implicit simulator fallback, no device opens or automatic retries.
3note Coherent or explicitly cache-maintained queue memory is a mandatory external platform prerequisite.
4note Compiler397e6704 mapget/mapset use one aligned access with DSB SY before/after; bulk copies do not.
5note Legitimate pointer operations order payload stores before producer publish, acquire before capture,
6note and captured loads before consumer acknowledgement. DSB does not establish cache coherency.
7note Vendor msgq.c:411-420 SWAP_RX; message_queue_cpu.c:568-578; kernel_gsp.c:411-425.
8note Notify chain kgspSetCmdQueueHead_TU102 writes PGSP_QUEUE_HEAD(0)=0, NOT a ring cursor/SEC2 queue.
9note Caller owns validated mapping views; process-fatal mapping faults are NOT crash-safe DMA containment.
10global qtstate ulong 1
11global qtepoch ulong 1
12global qtboot ulong 1
13global qtcmd ulong 1
14global qtstat ulong 1
15global qtbar long 1
16global qttok ulong 1
17global qtpend uchar 1
18global qtrd ulong 1
19note Deferred receive: state2 retains an immutable validated frame until explicit semantic completion.
20global qthand ulong 1
21global qthold ulong 1
22fn qtcheck to bool
23if ne get qtstate 0 1
24ret false
25end
26if not mmwepoch get qtepoch 0
27ret false
28end
29if ne get mmwst 0 MMWPUB
30ret false
31end
32ret eq get qtboot 0 get bgen 0
33end
34fn qtlose to void
35if and mmwepoch get qtepoch 0 eq get mmwst 0 MMWPUB
36r = mmwquar get qtepoch 0
37end
38put qtstate 0 2
39put rqdead 0 1
40put bstate 0 12
41end
42note Explicit mechanism attachment; success means bound spans, never qualified/coherent/hardware-ready.
43fn qtattach gen ulong bar long barsz ulong boot42 uint to long
44if ne get qtstate 0 0
45ret -6
46end
47cls = gpclass boot42
48if and ne cls 1 ne cls 2
49ret -95
50end
51if or not mmwepoch gen ne get mmwst 0 MMWPUB
52ret -6
53end
54if or ne gen get arsepoch 0 ne get bgen 0 get arsboot 0
55ret -6
56end
57if ne get bstate 0 4
58ret -6
59end
60if or lt barsz add GPNOTIF 4 le bar 0
61ret -1
62end
63if lt get mmws 0 RQQSZ
64ret -1
65end
66c = get arcmd 0
67s = get arstat 0
68if gt c sub get mmws 0 RQQSZ
69ret -1
70end
71if gt s sub get mmws 0 RQQSZ
72ret -1
73end
74if ne rem c RQSLOT 0
75ret -1
76end
77if ne rem s RQSLOT 0
78ret -1
79end
80if lt c s
81if gt add c RQQSZ s
82ret -1
83end
84else
85if gt add s RQQSZ c
86ret -1
87end
88end
89if not rqshape 0
90ret -1
91end
92h = get mmwh 0
93v = mapget h add c 16 4
94if ne v rqget32 0 16
95ret -1
96end
97v = mapget h add c 32 4
98if ne v rqget32 0 32
99ret -1
100end
101put qtepoch 0 gen
102put qtboot 0 get bgen 0
103put qtcmd 0 c
104put qtstat 0 s
105put qtbar 0 bar
106put qtpend 0 0
107put qtstate 0 1
108ret 0
109end
110fn qtxcopy wr ulong e ulong to long
111h = get mmwh 0
112for i ulong e
113slot = rem add wr i RQCOUNT
114o = add get qtcmd 0 mul add slot 1 RQSLOT
115r = mapwrite h o rqtmp mul i RQSLOT RQSLOT
116if ne r long RQSLOT
117ret -6
118end
119end
120ret 0
121end
122fn qtpub wr ulong e ulong to long
123p = rem add wr e RQCOUNT
124ret mapset get mmwh 0 add get qtcmd 0 16 4 p
125end
126fn qtsend f ulong n ulong p ulong sync bool to long
127if not qtcheck
128ret -6
129end
130if ne get qtpend 0 0
131ret -6
132end
133h = get mmwh 0
134rd = mapget h add get qtstat 0 32 4
135if ge rd RQCOUNT
136qtlose
137ret -1
138end
139r = mapread h get qtstat 0 rqstat 0 32
140if ne r 32
141qtlose
142ret -6
143end
144if and ne get rqlink 0 0 not rqshape 1
145qtlose
146ret -1
147end
148rqput32 1 32 rd
149r = rqprep f n p sync
150if ne r 0
151if ne r -2
152qtlose
153end
154ret r
155end
156wr = get rqpwr 0
157e = get rqpcnt 0
158token = get rqptok 0
159r = qtxcopy wr e
160if ne r 0
161qtlose
162ret r
163end
164note Leading DSB SY of this exact aligned store orders copied slot bytes before pointer publication.
165r = qtpub wr e
166if ne r 0
167qtlose
168ret -6
169end
170r = rqcommit token
171if ne r 0
172qtlose
173ret r
174end
175note Pointer was published: any later failure is uncertain, never unsent/retryable.
176r = qtbell get qtbar 0
177if ne r 0
178qtlose
179ret -6
180end
181ret 0
182end
183note Capture a bounded immutable prefix under one acquired producer cursor. No live reread while validating.
184fn qtsnap to long
185if not qtcheck
186ret -6
187end
188if ne get qtpend 0 0
189ret -6
190end
191if eq add get qttok 0 1 0
192ret -6
193end
194h = get mmwh 0
195s = get qtstat 0
196wr = mapget h add s 16 4
197r = mapread h s rqstat 0 32
198if ne r 32
199qtlose
200ret -6
201end
202rqput32 1 16 wr
203rd = rqget32 0 32
204put qtrd 0 rd
205put qttok 0 add get qttok 0 1
206put qtpend 0 1
207if or ge wr RQCOUNT ge rd RQCOUNT
208ret 0
209end
210avail = rem sub add wr RQCOUNT rd RQCOUNT
211if eq avail 0
212ret 0
213end
214o = add RQSLOT mul rd RQSLOT
215r = mapread h add s o rqstat o RQSLOT
216if ne r long RQSLOT
217qtlose
218ret -6
219end
220e = rqget32 1 add o 40
221if or eq e 0 or gt e 16 gt e avail
222ret 0
223end
224for i ulong sub e 1
225slot = rem add add rd i 1 RQCOUNT
226o = mul add slot 1 RQSLOT
227r = mapread h add s o rqstat o RQSLOT
228if ne r long RQSLOT
229qtlose
230ret -6
231end
232end
233ret 0
234end
235fn qtstage token ulong to long
236if not qtcheck
237ret -6
238end
239if or ne get qtpend 0 1 ne token get qttok 0
240ret -6
241end
242if ne rqget32 0 32 get qtrd 0
243qtlose
244ret -6
245end
246put qtpend 0 2
247put qthand 0 0
248r = rqrecv
249if lt r 0
250qtlose
251ret r
252end
253if eq r 0
254put qtpend 0 0
255ret 0
256end
257ret 1
258end
259fn qthandled token ulong to long
260if not qtcheck
261ret -6
262end
263if or ne get qtpend 0 2 ne token get qttok 0
264ret -6
265end
266if ne get qthand 0 0
267ret -6
268end
269put qthand 0 1
270ret 0
271end
272fn qtfinish token ulong to long
273if not qtcheck
274ret -6
275end
276if or ne get qtpend 0 2 ne token get qttok 0
277ret -6
278end
279if ne get qthand 0 1
280ret -6
281end
282note From here a failed publication is uncertain: quarantine, never restore/retry the local cursor.
283put qtpend 0 0
284put qthand 0 0
285note Leading DSB SY is FULL: capture loads complete before the consumer store permits peer slot reuse.
286x = mapset get mmwh 0 add get qtcmd 0 32 4 rqget32 0 32
287if ne x 0
288qtlose
289ret -6
290end
291ret 1
292end
293note Existing pull API preserves its validated-capture completion boundary.
294note IRQ callers instead stage, execute semantic handling, mark handled, then finish.
295fn qtaccept token ulong to long
296r = qtstage token
297if ne r 1
298ret r
299end
300r = qthandled token
301if ne r 0
302qtlose
303ret r
304end
305ret qtfinish token
306end
307fn bcanrst to bool
308ret eq get qtstate 0 0
309end
310fn blost to void
311qtlose
312end
313fn bemit f ulong n ulong p ulong sync bool to long
314ret qtsend f n p sync
315end
316fn bpull to long
317if ne get qthold 0 0
318if and qtcheck and eq get qtpend 0 2 eq get qthand 0 0
319ret 1
320end
321ret -6
322end
323r = qtsnap
324if ne r 0
325ret r
326end
327ret qtaccept get qttok 0
328end