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

97 lines · 3250 bytes Raw Blame History
1note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
2note gpu/nvidia/driver/nvrm.om: decisions of CUDApp nvrm/nvrm.c (84b524ca) that were still C: which channel a
3note put or retire names, the checks before a copy, before an allocation and on the framebuffer heap answer.
4note The ioctl, the mapping and the byte copy that follow each check stay with the device shell.
5
6note nvrm_chan_put and nvrm_chan_retire: 0 when ch is the main channel (0), 1 when it is extra channel ch
7note (1 to nextra; the table entry is ch - 1), 2 when it names no channel: nvrm_chan_put then answers 0 and
8note nvrm_chan_retire does nothing. On 1, nvrm_chan_retire moves the entry's retired count with drv_retire.
9fn drv_chan ch ulong nextra ulong to ulong
10if eq ch 0
11ret 0
12end
13if le ch nextra
14ret 1
15end
16ret 2
17end
18
19note copy_live span: bytes [off, off + bytes) is non-empty and inside an allocation of size bytes
20fn drv_span off ulong bytes ulong size ulong to bool
21if eq bytes 0
22ret false
23end
24if gt off size
25ret false
26end
27ret le bytes sub size off
28end
29
30note copy_live row: live row a (handle, va, size, cpu, cpu_live, rm_live, quarantined) is the allocation m
31note (handle, va, size, cpu) with its CPU and RM mappings live and not quarantined
32fn drv_lrow a view ulong 7 m view ulong 4 to bool
33for i ulong 4
34if ne get a i get m i
35ret false
36end
37end
38if or eq get a 4 0 eq get a 5 0
39ret false
40end
41ret eq get a 6 0
42end
43
44note nvrm_copy_to and nvrm_copy_from before the byte copy: 0 copy; 1 refuse without a message (no caller
45note buffer, the client faulted, or the span is empty or outside the allocation); 2 refuse with the message
46note "copy requires a live allocation and an in-bounds span" (no live row is the allocation, see drv_lrow)
47fn drv_copy buf bool faulted bool off ulong bytes ulong size ulong live bool to ulong
48if or not buf faulted
49ret 1
50end
51if not drv_span off bytes size
52ret 1
53end
54if not live
55ret 2
56end
57ret 0
58end
59
60note nvrm_alloc_vram: local framebuffer memory is asked for only on a discrete SM86 board
61fn drv_vramok discrete bool sm ulong to bool
62ret and discrete eq sm 86
63end
64
65note alloc_with_cacheability size check: 0 refuses ("invalid or overflowed allocation size": the client
66note faulted, size is 0, or rounding it up to 4 KiB passes 2^64 - 1); otherwise the size rounded up to 4 KiB.
67note WolframLanguageEvaluator: 2^64 - 1 - 4095 -> 18446744073709547520; BitAnd[BitNot[4095], 2^64-1] -> 18446744073709547520.
68fn drv_asize faulted bool size ulong to ulong
69if or faulted eq size 0
70ret 0
71end
72if gt size 18446744073709547520
73ret 0
74end
75ret and add size 4095 18446744073709547520
76end
77
78note alloc_with_cacheability: the live allocation table of cap rows holding count rows is full
79fn drv_livefull count ulong cap ulong to bool
80ret ge count cap
81end
82
83note nvrm_vram_info on the VID_HEAP_INFO answer: 0 the heap numbers stand; 1 "VID_HEAP_INFO errno" (the
84note ioctl failed or RM returned a status); 2 "invalid framebuffer heap information" (total 0 or more free
85note than total); 3 refused before the ioctl without a message (not a discrete board)
86fn drv_vinfo discrete bool iorc ulong status ulong total ulong avail ulong to ulong
87if not discrete
88ret 3
89end
90if or ne iorc 0 ne status 0
91ret 1
92end
93if or eq total 0 gt avail total
94ret 2
95end
96ret 0
97end