omega-gpu-driver
aien-dev/omega-gpu-driver
Brought by drakestapleton
omega-gpu-driver / rm / uvmclient.om
| 1 | note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 2 | note HOST_MODEL client UVM adapter. Reuses bounded half-open ranges from uvm/range.om; |
| 3 | note no PTE publication or real backing. RM capabilities, not handles-as-physical-addresses. |
| 4 | fn rmusize cmd ulong to ulong |
| 5 | if eq cmd 805306369 |
| 6 | ret 16 |
| 7 | end |
| 8 | if eq cmd 37 |
| 9 | ret 40 |
| 10 | end |
| 11 | if eq cmd 25 |
| 12 | ret 32 |
| 13 | end |
| 14 | if eq cmd 73 |
| 15 | ret 24 |
| 16 | end |
| 17 | if eq cmd 33 |
| 18 | ret 9264 |
| 19 | end |
| 20 | if eq cmd 34 |
| 21 | ret 24 |
| 22 | end |
| 23 | if eq cmd 26 |
| 24 | ret 20 |
| 25 | end |
| 26 | if eq cmd 38 |
| 27 | ret 20 |
| 28 | end |
| 29 | ret 0 |
| 30 | end |
| 31 | fn rmuoff cmd ulong to ulong |
| 32 | if eq cmd 805306369 |
| 33 | ret 8 |
| 34 | end |
| 35 | if eq cmd 37 |
| 36 | ret 36 |
| 37 | end |
| 38 | if eq cmd 25 |
| 39 | ret 28 |
| 40 | end |
| 41 | if eq cmd 33 |
| 42 | ret 9260 |
| 43 | end |
| 44 | ret 16 |
| 45 | end |
| 46 | fn rmuuid t view ulong 4096 b view uchar 16384 off ulong to bool |
| 47 | for j ulong 16 |
| 48 | if ne get b add off j rmfx t add 136 j |
| 49 | ret false |
| 50 | end |
| 51 | end |
| 52 | ret true |
| 53 | end |
| 54 | fn rmucreate t edit ulong 4096 b view uchar 16384 to ulong |
| 55 | va = rmget b 72 8 |
| 56 | n = rmget b 80 8 |
| 57 | if not rmmrange va n |
| 58 | ret 31 |
| 59 | end |
| 60 | empty = ulong 64 |
| 61 | for j ulong 64 |
| 62 | k = add 2600 mul j 4 |
| 63 | if eq get t k 0 |
| 64 | empty = j |
| 65 | else |
| 66 | lo = get t add k 1 |
| 67 | hi = add lo get t add k 2 |
| 68 | if and lt va hi lt lo add va n |
| 69 | ret 52 |
| 70 | end |
| 71 | end |
| 72 | end |
| 73 | if eq empty 64 |
| 74 | ret 81 |
| 75 | end |
| 76 | k = add 2600 mul empty 4 |
| 77 | put t k 1 |
| 78 | put t add k 1 va |
| 79 | put t add k 2 n |
| 80 | ret 0 |
| 81 | end |
| 82 | fn rmumap t edit ulong 4096 b view uchar 16384 to ulong |
| 83 | va = rmget b 72 8 |
| 84 | n = rmget b 80 8 |
| 85 | if or ne rmget b 88 8 0 ne rmget b 9312 8 1 |
| 86 | ret 31 |
| 87 | end |
| 88 | if not rmuuid t b 96 |
| 89 | ret 31 |
| 90 | end |
| 91 | cli = rmget b 9324 4 |
| 92 | slot = rmfind t cli rmget b 9328 4 |
| 93 | if eq slot 64 |
| 94 | ret 51 |
| 95 | end |
| 96 | if gt n get t add 512 mul slot 4 |
| 97 | ret 31 |
| 98 | end |
| 99 | found = false |
| 100 | for j ulong 64 |
| 101 | k = add 2048 mul j 8 |
| 102 | same = eq get t k 1 |
| 103 | same = and same eq get t add k 1 slot |
| 104 | same = and same eq get t add k 2 2 |
| 105 | if same |
| 106 | same = eq get t add k 3 va |
| 107 | same = and same eq get t add k 4 n |
| 108 | if same |
| 109 | found = true |
| 110 | end |
| 111 | end |
| 112 | end |
| 113 | if not found |
| 114 | ret 54 |
| 115 | end |
| 116 | for j ulong 64 |
| 117 | k = add 2600 mul j 4 |
| 118 | same = eq get t k 1 |
| 119 | same = and same eq get t add k 1 va |
| 120 | same = and same eq get t add k 2 n |
| 121 | if same |
| 122 | put t k 2 |
| 123 | put t add k 3 add slot 1 |
| 124 | ret 0 |
| 125 | end |
| 126 | end |
| 127 | ret 51 |
| 128 | end |
| 129 | fn rmufree t edit ulong 4096 b view uchar 16384 to ulong |
| 130 | for j ulong 64 |
| 131 | k = add 2600 mul j 4 |
| 132 | same = ne get t k 0 |
| 133 | same = and same eq get t add k 1 rmget b 72 8 |
| 134 | same = and same eq get t add k 2 rmget b 80 8 |
| 135 | if same |
| 136 | put t k 0 |
| 137 | ret 0 |
| 138 | end |
| 139 | end |
| 140 | ret 51 |
| 141 | end |
| 142 | fn rmuvact t edit ulong 4096 b edit uchar 16384 cmd ulong to ulong |
| 143 | if eq cmd 805306369 |
| 144 | if or ne get t 420 0 ne rmget b 72 8 0 |
| 145 | ret 31 |
| 146 | end |
| 147 | put t 420 1 |
| 148 | ret 0 |
| 149 | end |
| 150 | if eq cmd 25 |
| 151 | if not rmuuid t b 72 |
| 152 | ret 31 |
| 153 | end |
| 154 | cli = rmget b 92 4 |
| 155 | slot = rmfind t cli rmget b 96 4 |
| 156 | if eq slot 64 |
| 157 | ret 51 |
| 158 | end |
| 159 | if ne get t add mul slot 5 4 37105 |
| 160 | ret 54 |
| 161 | end |
| 162 | put t 420 1 |
| 163 | put t 421 1 |
| 164 | put t 422 add slot 1 |
| 165 | ret 0 |
| 166 | end |
| 167 | if eq get t 420 0 |
| 168 | ret 54 |
| 169 | end |
| 170 | if eq cmd 37 |
| 171 | if or ne get t 421 0 not rmuuid t b 72 |
| 172 | ret 31 |
| 173 | end |
| 174 | if ne rmget b 96 4 4294967295 |
| 175 | ret 31 |
| 176 | end |
| 177 | put t 421 1 |
| 178 | rmput b 88 4 0 |
| 179 | rmput b 92 4 4294967295 |
| 180 | ret 0 |
| 181 | end |
| 182 | if eq cmd 38 |
| 183 | if not rmuuid t b 72 |
| 184 | ret 31 |
| 185 | end |
| 186 | if or eq get t 421 0 ne get t 422 0 |
| 187 | ret 54 |
| 188 | end |
| 189 | put t 421 0 |
| 190 | ret 0 |
| 191 | end |
| 192 | if eq cmd 26 |
| 193 | if not rmuuid t b 72 |
| 194 | ret 31 |
| 195 | end |
| 196 | if eq get t 422 0 |
| 197 | ret 51 |
| 198 | end |
| 199 | for j ulong 64 |
| 200 | if ne get t add 2600 mul j 4 0 |
| 201 | ret 52 |
| 202 | end |
| 203 | end |
| 204 | put t 422 0 |
| 205 | ret 0 |
| 206 | end |
| 207 | if eq get t 422 0 |
| 208 | ret 54 |
| 209 | end |
| 210 | if eq cmd 73 |
| 211 | ret rmucreate t b |
| 212 | end |
| 213 | if eq cmd 33 |
| 214 | ret rmumap t b |
| 215 | end |
| 216 | if eq cmd 34 |
| 217 | ret rmufree t b |
| 218 | end |
| 219 | ret 86 |
| 220 | end |
| 221 | fn rmuvcall t edit ulong 4096 b edit uchar 16384 cmd ulong to void |
| 222 | r = rmuvact t b cmd |
| 223 | rmput b add 72 rmuoff cmd 4 r |
| 224 | end |