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 / nvidia / driver / fx.om

584 lines · 9616 bytes Raw Blame History
1note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
2note gpu/nvidia/driver/fx.om: the dx_ effects of client.om answered from a script and recorded, for the host
3note gate (seqgate.om). It is the Omega twin of the recorder in the C oracle (seqoracle.c, outside this tree):
4note the same event per effect, the same answers, the same failure script. Each effect is one event
5note "NAME ARGS =RESULT;" appended to fo; request fields set with dx_fk and dx_fa are printed with the effect
6note that sends them (" kKIND V V ...").
7note
8note Script: the effects are numbered from 1 in the order they happen. Effect K (0: none) and the next effects
9note of the same type, R in all, fail with flavour F, if their type can fail (fx_eff's nfl: how many flavours).
10note Otherwise every effect succeeds with an answer derived from its number n: an RM handle 3238002688 + n
11note (0xc1000000 + n), a GPU VA 137438953472 + n * 2^20, a usermode mapping 5497558138880 + n * 2^16, a file
12note descriptor 10 + n, a work-submit token 4096 + n. A refused effect answers errno 5.
13note Scenario of nvrm_open (fx_scen): the admitted SM, the SM the classes select, discrete, the class count.
14note The card table the CARD_INFO answer fills holds the same record at every index i: PCI 0000:01:00.0,
15note vendor 4318 (0x10de), device 11794 (0x2e12), gpu_id 256 + i, minor i; card_index answers 2.
16
17global fo uchar 65536
18note fz: 0 length of fo, 1 effects so far (n), 2 K, 3 F, 4 failures left (R), 5 type of effect K, 6 admitted SM,
19note 7 selected SM, 8 discrete, 9 class count, 10 pending fill words, 11 fo overflowed, 12 a script the
20note recorder cannot follow (a flavour the effect does not have, an unknown request value)
21global fz ulong 16
22global ff ulong 64
23
24fn fx_c c ulong to void
25l = get fz 0
26if lt l 65536
27put fo l uchar c
28put fz 0 add l 1
29else
30put fz 11 1
31end
32end
33
34fn fx_num v ulong to void
35d = new uchar 20 0
36k = ulong 0
37x = v
38while true bound 20
39put d k uchar add 48 rem x 10
40k = add k 1
41x = div x 10
42if eq x 0
43break
44end
45end
46for j ulong k bound 20
47fx_c ulong get d sub sub k j 1
48end
49end
50
51note " V" unsigned, " V" signed
52fn fx_su v ulong to void
53fx_c 32
54fx_num v
55end
56
57fn fx_sd v long to void
58fx_c 32
59if lt v 0
60fx_c 45
61fx_num ulong sub long 0 v
62else
63fx_num ulong v
64end
65end
66
67fn fx_semi to void
68fx_c 59
69end
70
71note " =V;" unsigned and signed
72fn fx_ru v ulong to void
73fx_c 32
74fx_c 61
75fx_num v
76fx_semi
77end
78
79fn fx_rd v long to void
80fx_c 32
81fx_c 61
82if lt v 0
83fx_c 45
84fx_num ulong sub long 0 v
85else
86fx_num ulong v
87end
88fx_semi
89end
90
91note " =1;" when refused, " =0;" when not
92fn fx_rf f long to void
93if ge f 0
94fx_ru 1
95else
96fx_ru 0
97end
98end
99
100fn fx_reset k ulong f ulong r ulong to void
101for i ulong 16
102put fz i 0
103end
104put fz 2 k
105put fz 3 f
106put fz 4 r
107end
108
109fn fx_scen asm ulong ssm ulong disc ulong ncls ulong to void
110put fz 6 asm
111put fz 7 ssm
112put fz 8 disc
113put fz 9 ncls
114end
115
116note start effect of type t with nfl failure flavours, named c1 c2; the flavour when it fails, else -1
117fn fx_eff t ulong nfl ulong c1 ulong c2 ulong to long
118n = add get fz 1 1
119put fz 1 n
120k = get fz 2
121if and ne k 0 eq n k
122put fz 5 t
123end
124fx_c c1
125fx_c c2
126hit = and gt nfl 0 ne k 0
127hit = and hit ge n k
128hit = and hit gt get fz 4 0
129hit = and hit eq t get fz 5
130if hit
131put fz 4 sub get fz 4 1
132if ge get fz 3 nfl
133put fz 12 1
134end
135ret long get fz 3
136end
137ret -1
138end
139
140fn fx_n to ulong
141ret get fz 1
142end
143
144note the pending request fields, then none
145fn fx_fills to void
146for i ulong get fz 10 bound 64
147v = get ff i
148if ne shr v 63 0
149fx_c 32
150fx_c 107
151fx_num and v 255
152else
153fx_su v
154end
155end
156put fz 10 0
157end
158
159fn dx_fk kind ulong to void
160n = get fz 10
161if lt n 64
162put ff n or 9223372036854775808 kind
163put fz 10 add n 1
164else
165put fz 12 1
166end
167end
168
169fn dx_fa v ulong to void
170n = get fz 10
171if lt n 64
172put ff n v
173put fz 10 add n 1
174else
175put fz 12 1
176end
177end
178
179fn dx_errno to long
180ret 5
181end
182
183fn dx_admit_open to bool
184f = fx_eff 1 1 97 111
185fx_rf f
186ret lt f 0
187end
188
189fn dx_slot to ulong
190f = fx_eff 2 1 118 115
191b = ulong 68719476736
192if ge f 0
193b = ulong 0
194end
195fx_ru b
196ret b
197end
198
199fn dx_recycle base ulong to void
200f = fx_eff 20 0 114 99
201fx_su base
202fx_semi
203end
204
205note path 1 /dev/nvidiactl, 2 /dev/nvidia-uvm
206fn dx_fopen path ulong to long
207f = fx_eff 3 1 111 112
208fd = long add 10 fx_n
209if ge f 0
210fd = long -1
211end
212fx_su path
213fx_rd fd
214ret fd
215end
216
217fn dx_fclose fd long to long
218f = fx_eff 3 1 99 108
219fx_sd fd
220fx_rf f
221if ge f 0
222ret -1
223end
224ret 0
225end
226
227note RM_ALLOC: the new handle, 0 when refused (last_rm_status: flavour 0 status 31, 1 NV_ERR_NO_MEMORY 81, 2 errno)
228fn dx_alloc parent ulong cls ulong to ulong
229f = fx_eff 4 3 97 108
230fx_su parent
231fx_su cls
232fx_fills
233if ge f 0
234st = ulong 0
235if eq f 0
236st = ulong 31
237end
238if eq f 1
239st = ulong 81
240end
241cp CS_LRS st
242fx_ru 0
243ret 0
244end
245cp CS_LRS 0
246h = add 3238002688 fx_n
247fx_ru h
248ret h
249end
250
251fn dx_free parent ulong obj ulong to bool
252f = fx_eff 24 1 102 114
253fx_su parent
254fx_su obj
255fx_rf f
256ret lt f 0
257end
258
259fn dx_ctrl obj ulong cmd ulong to bool
260f = fx_eff 10 1 99 116
261fx_su obj
262fx_su cmd
263fx_fills
264fx_rf f
265ret lt f 0
266end
267
268fn dx_uvm fd long cmd ulong to bool
269f = fx_eff 11 1 117 118
270fx_sd fd
271fx_su cmd
272fx_fills
273fx_rf f
274ret lt f 0
275end
276
277fn dx_uvmraw fd long cmd ulong to void
278f = fx_eff 5 0 117 109
279fx_sd fd
280fx_su cmd
281fx_fills
282fx_semi
283end
284
285fn dx_ioctl fd long nr ulong to bool
286f = fx_eff 6 1 105 111
287fx_sd fd
288fx_su nr
289fx_fills
290fx_rf f
291ret lt f 0
292end
293
294fn dx_cardidx to long
295f = fx_eff 7 1 99 105
296r = long 2
297if ge f 0
298r = long -1
299end
300fx_rd r
301ret r
302end
303
304note admit the card at index i: the admitted SM, -1 when refused
305fn dx_admit_card i ulong to long
306f = fx_eff 8 1 97 99
307fx_su 0
308fx_su 1
309fx_su 0
310fx_su 0
311fx_su 4318
312fx_su 11794
313fx_rf f
314if ge f 0
315ret -1
316end
317ret long get fz 6
318end
319
320note card record i field: 5 gpu_id, 6 minor, 7 vendor, 8 device
321fn dx_cardget i ulong fl ulong to ulong
322if eq fl 5
323ret add 256 i
324end
325if eq fl 6
326ret i
327end
328if eq fl 7
329ret 4318
330end
331if eq fl 8
332ret 11794
333end
334put fz 12 1
335ret 0
336end
337
338fn dx_opendev minor ulong to long
339f = fx_eff 9 1 111 100
340fd = long add 10 fx_n
341if ge f 0
342fd = long -1
343end
344fx_su minor
345fx_rd fd
346ret fd
347end
348
349note a field of the last answer: kind 1 field 1 device instance, 17/1 SM version, 7/0 class count,
350note 14/0 work-submit token, 9/3+i uuid byte i
351fn dx_nsget kind ulong fl ulong to ulong
352if and eq kind 1 eq fl 1
353ret 3
354end
355if and eq kind 17 eq fl 1
356ret 2564
357end
358if and eq kind 7 eq fl 0
359ret get fz 9
360end
361if and eq kind 14 eq fl 0
362ret add 4096 fx_n
363end
364if and and eq kind 9 ge fl 3 lt fl 19
365ret and add mul sub fl 3 37 11 255
366end
367put fz 12 1
368ret 0
369end
370
371note select_classes: on success the target SM, discrete flag and the compute, GPFIFO and usermode classes
372fn dx_select count ulong vendor ulong device ulong to bool
373f = fx_eff 12 1 115 99
374fx_su count
375fx_su vendor
376fx_su device
377fx_rf f
378cp CS_CCLS 0
379cp CS_GCLS 0
380cp CS_UCLS 0
381cp CS_TSM 0
382cp CS_DISC 0
383if ge f 0
384ret false
385end
386d = get fz 8
387cp CS_TSM get fz 7
388cp CS_DISC d
389if ne d 0
390cp CS_CCLS 51136
391cp CS_GCLS 50543
392cp CS_UCLS 50017
393else
394cp CS_CCLS 52928
395cp CS_GCLS 51567
396cp CS_UCLS 50785
397end
398ret true
399end
400
401note map_to_cpu: the CPU address (target, or a new one when target is 0), 2^64 - 1 when refused
402fn dx_map h ulong size ulong target ulong flags ulong system long to ulong
403f = fx_eff 13 1 109 112
404p = target
405if eq target 0
406p = add 5497558138880 shl fx_n 16
407end
408if ge f 0
409p = CN_MAPFAILED
410end
411fx_su h
412fx_su size
413fx_su target
414fx_su flags
415fx_sd system
416fx_ru p
417ret p
418end
419
420note nvrm_cpu_reserve: va; flavour 0 refused (2^64 - 1), flavour 1 another address (va + 4096)
421fn dx_reserve va ulong size ulong to ulong
422f = fx_eff 14 2 114 115
423p = va
424if eq f 0
425p = CN_MAPFAILED
426end
427if eq f 1
428p = add va 4096
429end
430fx_su va
431fx_su size
432fx_ru p
433ret p
434end
435
436fn dx_drop cpu ulong size ulong to bool
437f = fx_eff 15 1 100 112
438fx_su cpu
439fx_su size
440fx_rf f
441ret lt f 0
442end
443
444fn dx_transfer h ulong to void
445f = fx_eff 16 0 116 114
446fx_su h
447fx_semi
448end
449
450fn dx_finish to bool
451f = fx_eff 17 1 102 110
452fx_rf f
453ret lt f 0
454end
455
456fn dx_vatake size ulong align ulong to ulong
457f = fx_eff 18 1 118 116
458va = add 137438953472 shl fx_n 20
459if ge f 0
460va = ulong 0
461end
462fx_su size
463fx_su align
464fx_ru va
465ret va
466end
467
468fn dx_varel va ulong size ulong to bool
469f = fx_eff 19 1 118 114
470fx_su va
471fx_su size
472fx_rf f
473ret lt f 0
474end
475
476note uvm_map: 0 mapped; refused 1 before anything, 2 after the UVM range was created, 3 after the DMA map too
477fn dx_uvmmap va ulong size ulong h ulong to ulong
478f = fx_eff 21 3 117 120
479r = ulong 0
480if ge f 0
481r = add ulong f 1
482end
483fx_su va
484fx_su size
485fx_su h
486fx_ru r
487ret r
488end
489
490fn dx_uvmfree va ulong size ulong to bool
491f = fx_eff 22 1 117 102
492fx_su va
493fx_su size
494fx_rf f
495ret lt f 0
496end
497
498fn dx_dmaunmap h ulong va ulong size ulong to bool
499f = fx_eff 23 1 100 117
500fx_su h
501fx_su va
502fx_su size
503fx_rf f
504ret lt f 0
505end
506
507fn dx_validate off ulong nw ulong to bool
508f = fx_eff 25 1 118 97
509fx_su off
510fx_su nw
511fx_rf f
512ret lt f 0
513end
514
515fn dx_publish fifoh ulong entries ulong putv ulong userd ulong va ulong nw ulong to bool
516f = fx_eff 26 1 112 98
517fx_su fifoh
518fx_su entries
519fx_su putv
520fx_su userd
521fx_su va
522fx_su nw
523fx_rf f
524ret lt f 0
525end
526
527fn dx_doorbell token ulong to bool
528f = fx_eff 27 1 100 98
529fx_su token
530fx_rf f
531ret lt f 0
532end
533
534fn dx_sleep us ulong to void
535f = fx_eff 28 0 115 108
536fx_su us
537fx_semi
538end
539
540fn dx_zero cpu ulong size ulong to void
541f = fx_eff 29 0 122 98
542fx_su cpu
543fx_su size
544fx_semi
545end
546
547note fail(): "ER CODE ARGS;" (string arguments print as s)
548fn dx_er code ulong to void
549fx_c 69
550fx_c 82
551fx_su code
552end
553
554fn dx_eu v ulong to void
555fx_su v
556end
557
558fn dx_ed v long to void
559fx_sd v
560end
561
562fn dx_es to void
563fx_c 32
564fx_c 115
565end
566
567fn dx_ee to void
568fx_semi
569end
570
571fn dx_ea size ulong to void
572fx_c 69
573fx_c 65
574fx_su size
575fx_semi
576end
577
578fn dx_en attempts ulong delay ulong to void
579fx_c 69
580fx_c 78
581fx_su attempts
582fx_su delay
583fx_semi
584end