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