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 / rm / dispatch.om

263 lines · 4201 bytes Raw Blame History
1note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
2note Explicit replay/model only. Existing params/rpc units own record and frame codecs.
3fn rmpsize cls ulong to long
4if or eq cls 62 eq cls 64
5ret 128
6end
7if eq cls 112
8ret 24
9end
10if or eq cls 50017 eq cls 50785
11ret 0
12end
13if eq cls 65
14ret 0
15end
16if eq cls 128
17ret long PASZDEV
18end
19if eq cls 8320
20ret long PASZSUB
21end
22if eq cls 37105
23ret long PASZVAS
24end
25if eq cls 41068
26ret long PASZTSG
27end
28if eq cls 36967
29ret long PASZCTX
30end
31if eq cls 51567
32ret long PASZCHAN
33end
34if eq cls 52928
35ret 0
36end
37ret -1
38end
39fn rmcsize cmd ulong to long
40if eq cmd 517
41ret 32
42end
43if eq cmd 8389121
44ret 16
45end
46if eq cmd 545264129
47ret 32
48end
49if eq cmd 545259850
50ret 268
51end
52if eq cmd PACMSCH
53ret long PASZSCH
54end
55note ctrlc36f.h NVC36F_CTRL_CMD_GPFIFO_GET_WORK_SUBMIT_TOKEN.
56if eq cmd 3278831880
57ret 4
58end
59ret -1
60end
61fn rmroute t edit ulong 4096 a view ulong 8 f ulong to ulong
62note rqpeer links host memory only; never MMIO, DMA, VFIO or firmware.
63rqinit
64rqpeer
65n = get palen 0
66head = ulong 32
67if eq f 76
68head = 40
69end
70if eq f 10
71head = 16
72n = 0
73end
74rqclear add head n
75rqput32 4 0 get a 0
76if eq f 103
77rqput32 4 4 get a 1
78rqput32 4 8 get a 2
79rqput32 4 12 get a 3
80rqput32 4 20 n
81else
82rqput32 4 4 get a 1
83rqput32 4 8 get a 2
84if eq f 76
85rqput32 4 16 n
86end
87end
88if eq f 10
89rqput32 4 4 0
90end
91for j ulong n
92put rqpay add head j get pabuf j
93end
94logical = add head n
95if eq f 103
96logical = 32
97end
98r = rqsend f logical add head n true
99if ne r 0
100ret 6
101end
102put t 411 f
103put t 412 add get t 412 1
104note This result belongs to the explicit host model, not a fabricated GSP reply.
105ret get t 410
106end
107fn rmarefs t view ulong 4096 b view uchar 16384 cls ulong cli ulong to bool
108if eq cls 36967
109p = rmfind t cli rmget b 76 4
110if eq p 64
111ret false
112end
113ret rmref t cli rmget b 104 4 37105 get t add mul p 5 3
114end
115if eq cls 51567
116if or ne rmget b 104 4 0 ne rmget b 108 4 0
117ret false
118end
119if ne rmget b 136 4 0
120ret false
121end
122ret rmref t cli rmget b 128 4 36967 rmget b 76 4
123end
124ret true
125end
126fn rmpay b view uchar 16384 n ulong to void
127paclr n
128for j ulong n
129put pabuf j get b add 104 j
130end
131end
132fn rmacode b view uchar 16384 a view ulong 8 to void
133if eq get a 3 65
134r = paroot get a 0 0
135else
136rmpay b ulong rmpsize get a 3
137end
138end
139fn rmallocx t edit ulong 4096 b edit uchar 16384 a edit ulong 8 to ulong
140n = rmpsize get a 3
141if lt n 0
142ret 6
143end
144if ne rmget b 96 4 ulong n
145ret 1
146end
147if not rmarefs t b get a 3 get a 0
148ret 3
149end
150r = rmaokay t a
151if ne r 0
152ret r
153end
154if eq get a 3 65
155put a 0 add get t 400 1
156put a 2 get a 0
157end
158rmacode b a
159r = rmroute t a 103
160if ne r 0
161ret r
162end
163r = rmmalloc t b a
164if ne r 0
165ret r
166end
167if eq get a 3 65
168put t 400 get a 0
169put a 1 get a 0
170end
171r = rminsert t get a 0 get a 1 get a 2 get a 3
172rmput b 80 4 get a 2
173ret 0
174end
175fn rmfreex t edit ulong 4096 a edit ulong 8 to ulong
176slot = rmfslot t get a 0 get a 1 get a 2
177if lt slot 64
178ret slot
179end
180r = rmroute t a 10
181if ne r 0
182ret r
183end
184rmkill t get a 0 sub slot 64
185rmmreap t
186ret 0
187end
188fn rmctrlx t edit ulong 4096 b edit uchar 16384 a view ulong 8 to ulong
189idx = rmfind t get a 0 get a 1
190if eq idx 64
191ret 2
192end
193n = rmcsize get a 2
194if lt n 0
195ret 6
196end
197if or ne rmget b 96 4 ulong n ne get a 3 0
198ret 1
199end
200cmd = get a 2
201if or eq cmd 517 or eq cmd 8389121 or eq cmd 545264129 eq cmd 545259850
202ret rmhostct t b a
203end
204cls = get t add mul idx 5 4
205if eq get a 2 PACMSCH
206if ne cls 41068
207ret 3
208end
209end
210if eq get a 2 3278831880
211if ne cls 51567
212ret 3
213end
214end
215rmpay b ulong n
216if eq get a 2 PACMSCH
217r = pasched rmget b 104 1 rmget b 105 1 rmget b 106 1
218if lt r 0
219ret 1
220end
221end
222r = rmroute t a 76
223if ne r 0
224ret r
225end
226if eq get a 2 3278831880
227rmput b 104 4 get a 1
228end
229ret 0
230end
231fn rmaction t edit ulong 4096 b edit uchar 16384 nr ulong to ulong
232a = new ulong 8 0
233for j ulong 4
234put a j rmget b add 72 mul j 4 4
235end
236if eq nr 43
237ret rmallocx t b a
238end
239if eq nr 41
240ret rmfreex t a
241end
242if eq nr 42
243ret rmctrlx t b a
244end
245if or eq nr 78 or eq nr 79 or eq nr 87 eq nr 88
246ret rmmapping t b nr
247end
248if eq nr 74
249ret rmmheap t b
250end
251ret 6
252end
253fn rmdispat t edit ulong 4096 b edit uchar 16384 nr ulong to long
254if or eq nr 200 eq nr 210
255ret rmhostio t b nr
256end
257if eq nr 201
258ret -95
259end
260r = rmaction t b nr
261rmput b add 72 rmstoff nr 4 rmstatus r
262ret 0
263end