omega-gpu-driver
aien-dev/omega-gpu-driver
Brought by drakestapleton
omega-gpu-driver / rm / ioctl.om
| 1 | note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 2 | note NVIDIA580.173.02 nvos.h, nv-ioctl.h, nv_escape.h; measured by rme_offsets.c. |
| 3 | note No globals: caller owns the byte image and the 64-slot object namespace. |
| 4 | fn rmget b view uchar 16384 off ulong n ulong to ulong |
| 5 | v = ulong 0 |
| 6 | for j ulong n |
| 7 | v = or v shl ulong get b add off j mul j 8 |
| 8 | end |
| 9 | ret v |
| 10 | end |
| 11 | fn rmput b edit uchar 16384 off ulong n ulong v ulong to void |
| 12 | for j ulong n |
| 13 | put b add off j uchar and shr v mul j 8 255 |
| 14 | end |
| 15 | end |
| 16 | fn rmsize nr ulong to ulong |
| 17 | if or eq nr 43 eq nr 42 |
| 18 | ret 32 |
| 19 | end |
| 20 | if or eq nr 41 or eq nr 206 eq nr 207 |
| 21 | ret 16 |
| 22 | end |
| 23 | if eq nr 78 |
| 24 | ret 56 |
| 25 | end |
| 26 | if eq nr 79 |
| 27 | ret 32 |
| 28 | end |
| 29 | if eq nr 87 |
| 30 | ret 64 |
| 31 | end |
| 32 | if eq nr 88 |
| 33 | ret 48 |
| 34 | end |
| 35 | if eq nr 201 |
| 36 | ret 4 |
| 37 | end |
| 38 | if eq nr 200 |
| 39 | ret 4608 |
| 40 | end |
| 41 | if eq nr 210 |
| 42 | ret 72 |
| 43 | end |
| 44 | if eq nr 74 |
| 45 | ret 184 |
| 46 | end |
| 47 | ret 0 |
| 48 | end |
| 49 | fn rmdecode cmd ulong to ulong |
| 50 | nr = and cmd 255 |
| 51 | n = rmsize nr |
| 52 | if eq n 0 |
| 53 | ret 0 |
| 54 | end |
| 55 | if ne cmd or or ulong 3221225472 shl n 16 or ulong 17920 nr |
| 56 | ret 0 |
| 57 | end |
| 58 | ret n |
| 59 | end |
| 60 | fn rmstoff nr ulong to ulong |
| 61 | if or eq nr 43 eq nr 42 |
| 62 | ret 28 |
| 63 | end |
| 64 | if or eq nr 41 or eq nr 206 eq nr 207 |
| 65 | ret 12 |
| 66 | end |
| 67 | if eq nr 78 |
| 68 | ret 40 |
| 69 | end |
| 70 | if eq nr 79 |
| 71 | ret 24 |
| 72 | end |
| 73 | if eq nr 87 |
| 74 | ret 56 |
| 75 | end |
| 76 | if eq nr 88 |
| 77 | ret 40 |
| 78 | end |
| 79 | if eq nr 74 |
| 80 | ret 20 |
| 81 | end |
| 82 | ret 0 |
| 83 | end |
| 84 | note Local categories: invalid argument, stale object, wrong parent, duplicate, capacity, unsupported. |
| 85 | fn rmstatus code ulong to ulong |
| 86 | if eq code 0 |
| 87 | ret 0 |
| 88 | end |
| 89 | if eq code 1 |
| 90 | ret 31 |
| 91 | end |
| 92 | if eq code 2 |
| 93 | ret 51 |
| 94 | end |
| 95 | if eq code 3 |
| 96 | ret 54 |
| 97 | end |
| 98 | if eq code 4 |
| 99 | ret 52 |
| 100 | end |
| 101 | if eq code 5 |
| 102 | ret 81 |
| 103 | end |
| 104 | ret 86 |
| 105 | end |
| 106 | fn rmptr addr ulong n ulong to bool |
| 107 | if or eq addr 0 ge addr ulong 281474976710656 |
| 108 | ret false |
| 109 | end |
| 110 | ret le n sub ulong 281474976710656 addr |
| 111 | end |