CUDApp
CUDA++: AIEN’s GPU machine-code toolchain, runtime and driver client for NVIDIA GPUs without the CUDA toolkit. Hardware coverage and driver replacement limits are explicit.
Brought by drakestapleton
CUDApp / tests / nvml / rmfake.om
| 1 | note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 2 | note rmfake.om: host-only stand-in for the NVIDIA resource manager behind compat/nvml. Pure unit |
| 3 | note nvml_fake, lowered by tests/nvml/gate.om and called by tests/nvml/transport.c in place of |
| 4 | note omega2_nvrm_open_file, omega2_nvrm_close_file and omega2_nvrm_ioctl. No device file is opened. |
| 5 | note Replies imitate a GB10 (one GPU, or two with fault 2); they are synthetic, not a hardware record. |
| 6 | note |
| 7 | note st (ulong 64): 0 kind (1 ioctl, 2 open, 3 close), 1 fd, 2 nr, 3 header bytes, 4 params bytes, |
| 8 | note 5 fault letter, 6 result (signed), 7 path bytes (open; the path is in p). |
| 9 | note Counters: 8 opens, 9 closes, 10 allocs, 11 frees, 12 controls, 13 violations (a request the real |
| 10 | note RM would refuse or a wrong layout), 14 open-fd mask (bit fd-10), 15 live objects, 16 root client. |
| 11 | note Objects: 32..47 live handles, 48+i device and 50+i subdevice of GPU i. |
| 12 | note Faults (st 5, ASCII): o a d control open ENOENT, control open EACCES, device open ENXIO; |
| 13 | note P root alloc EPERM; A device alloc 0x1B; 0 no GPU; 9 nine GPUs; 2 two GPUs; |
| 14 | note c name 0x56; G name 0x0F; n name without zero; E empty name; g GID length 20; |
| 15 | note t thermal not executed; h negative reading; v no GPU-type target; |
| 16 | note z no framebuffer; x FB info 0x56; m free above total; |
| 17 | note w util 0x56; y util 0x1B; e empty ring; r tracker 72; Z newest timestamp 0; X gr.util 10001; |
| 18 | note k no compute class; l no PIDs; p 951 PIDs; b 250 PIDs; i PID 4242 info fails; j wrong pid echoed; |
| 19 | note f subdevice free 0x1F. |
| 20 | note Healthy replies: name NVIDIA GB10, GID fb8e53f0-3207-e89b-d02f-acdfe2695b59 (GPU 1 ends 5a), |
| 21 | note reading 40 (GPU 1 41), total 128000000 KiB, free 100000000 KiB, newest util sample (index 4 of |
| 22 | note tracker 5) gr 4200 fb 1300 while sample k holds gr 100k fb 50k, PIDs 68451 (351272960 bytes) |
| 23 | note and 4242 (pid*65536). Constants: evidence/NVML-2026-11-06/wolfram.txt. |
| 24 | |
| 25 | const HN ulong 4608 |
| 26 | const PN ulong 55888 |
| 27 | const RT ulong 3251634177 |
| 28 | |
| 29 | fn hg h edit uchar HN o ulong to ulong |
| 30 | v = ulong 0 |
| 31 | for i ulong 4 |
| 32 | v = or v shl ulong get h add o i mul i 8 |
| 33 | end |
| 34 | ret v |
| 35 | end |
| 36 | |
| 37 | fn hp h edit uchar HN o ulong v ulong to void |
| 38 | for i ulong 4 |
| 39 | put h add o i uchar and shr v mul i 8 255 |
| 40 | end |
| 41 | end |
| 42 | |
| 43 | fn pn p edit uchar PN o ulong n ulong to ulong |
| 44 | v = ulong 0 |
| 45 | for i ulong n |
| 46 | v = or v shl ulong get p add o i mul i 8 |
| 47 | end |
| 48 | ret v |
| 49 | end |
| 50 | |
| 51 | fn pg p edit uchar PN o ulong to ulong |
| 52 | ret pn p o 4 |
| 53 | end |
| 54 | |
| 55 | fn pp p edit uchar PN o ulong v ulong to void |
| 56 | for i ulong 4 |
| 57 | put p add o i uchar and shr v mul i 8 255 |
| 58 | end |
| 59 | end |
| 60 | |
| 61 | fn pq p edit uchar PN o ulong v ulong to void |
| 62 | for i ulong 8 |
| 63 | put p add o i uchar and shr v mul i 8 255 |
| 64 | end |
| 65 | end |
| 66 | |
| 67 | fn bad st edit ulong 64 to void |
| 68 | put st 13 add get st 13 1 |
| 69 | end |
| 70 | |
| 71 | fn flt st edit ulong 64 c ulong to bool |
| 72 | ret eq get st 5 c |
| 73 | end |
| 74 | |
| 75 | note A request on fd with the given header and params bytes; anything else is a violation. |
| 76 | fn want st edit ulong 64 fd ulong hl ulong pl ulong to bool |
| 77 | if and eq get st 1 fd and eq get st 3 hl eq get st 4 pl |
| 78 | ret true |
| 79 | end |
| 80 | bad st |
| 81 | ret false |
| 82 | end |
| 83 | |
| 84 | note A control with params bytes n on an acceptable object (ok); anything else is a violation. |
| 85 | fn need st edit ulong 64 n ulong ok bool to bool |
| 86 | if and ok eq get st 4 n |
| 87 | ret true |
| 88 | end |
| 89 | bad st |
| 90 | ret false |
| 91 | end |
| 92 | |
| 93 | fn ngpu st edit ulong 64 to ulong |
| 94 | if flt st 50 |
| 95 | ret 2 |
| 96 | end |
| 97 | ret 1 |
| 98 | end |
| 99 | |
| 100 | fn isopen st edit ulong 64 fd ulong to bool |
| 101 | if or lt fd 10 gt fd 12 |
| 102 | ret false |
| 103 | end |
| 104 | ret ne and shr get st 14 sub fd 10 1 0 |
| 105 | end |
| 106 | |
| 107 | fn slot st edit ulong 64 x ulong to ulong |
| 108 | for i ulong 16 |
| 109 | if eq get st add 32 i x |
| 110 | ret add i 1 |
| 111 | end |
| 112 | end |
| 113 | ret 0 |
| 114 | end |
| 115 | |
| 116 | fn keep st edit ulong 64 x ulong to void |
| 117 | i = slot st 0 |
| 118 | if or eq x 0 or eq i 0 ne slot st x 0 |
| 119 | bad st |
| 120 | ret |
| 121 | end |
| 122 | put st add 31 i x |
| 123 | put st 10 add get st 10 1 |
| 124 | put st 15 add get st 15 1 |
| 125 | end |
| 126 | |
| 127 | fn gpu st edit ulong 64 x ulong to ulong |
| 128 | for i ulong 2 |
| 129 | if and ne x 0 or eq get st add 48 i x eq get st add 50 i x |
| 130 | ret i |
| 131 | end |
| 132 | end |
| 133 | ret 9 |
| 134 | end |
| 135 | |
| 136 | fn isdev st edit ulong 64 x ulong to bool |
| 137 | ret and ne x 0 or eq get st 48 x eq get st 49 x |
| 138 | end |
| 139 | |
| 140 | fn issub st edit ulong 64 x ulong to bool |
| 141 | ret and ne x 0 or eq get st 50 x eq get st 51 x |
| 142 | end |
| 143 | |
| 144 | note Open: /dev/nvidiactl is fd 10, /dev/nvidia<m> is fd 11+m. |
| 145 | fn fkopen st edit ulong 64 p edit uchar PN to long |
| 146 | n = get st 7 |
| 147 | fd = long neg long 2 |
| 148 | if and eq n 14 and eq pn p 0 8 7599382571363165231 eq pn p 8 6 119247139334500 |
| 149 | if flt st 111 |
| 150 | ret neg long 2 |
| 151 | end |
| 152 | if flt st 97 |
| 153 | ret neg long 13 |
| 154 | end |
| 155 | fd = long 10 |
| 156 | end |
| 157 | if and eq n 12 and eq pn p 0 8 7599382571363165231 eq pn p 8 3 6383972 |
| 158 | m = ulong get p 11 |
| 159 | if and ge m 48 lt m add 48 ngpu st |
| 160 | if flt st 100 |
| 161 | ret neg long 6 |
| 162 | end |
| 163 | fd = long add 11 sub m 48 |
| 164 | end |
| 165 | end |
| 166 | if lt fd 0 |
| 167 | bad st |
| 168 | ret fd |
| 169 | end |
| 170 | if isopen st ulong fd |
| 171 | bad st |
| 172 | ret neg long 16 |
| 173 | end |
| 174 | put st 14 or get st 14 shl 1 sub ulong fd 10 |
| 175 | put st 8 add get st 8 1 |
| 176 | ret fd |
| 177 | end |
| 178 | |
| 179 | fn fkclose st edit ulong 64 to long |
| 180 | fd = get st 1 |
| 181 | if not isopen st fd |
| 182 | bad st |
| 183 | ret neg long 9 |
| 184 | end |
| 185 | put st 14 and get st 14 not shl 1 sub fd 10 |
| 186 | put st 9 add get st 9 1 |
| 187 | ret 0 |
| 188 | end |
| 189 | |
| 190 | note NV_ESC_CARD_INFO: entries of 72 bytes, valid 0, gpu_id 16 (256+i), minor_number 56 (i). |
| 191 | fn fkcard st edit ulong 64 h edit uchar HN to long |
| 192 | if not want st 10 HN 0 |
| 193 | ret neg long 22 |
| 194 | end |
| 195 | if not isopen st 10 |
| 196 | bad st |
| 197 | ret neg long 22 |
| 198 | end |
| 199 | for i ulong HN |
| 200 | put h i 0 |
| 201 | end |
| 202 | n = ngpu st |
| 203 | if flt st 48 |
| 204 | n = 0 |
| 205 | end |
| 206 | if flt st 57 |
| 207 | n = 9 |
| 208 | end |
| 209 | for i ulong n |
| 210 | o = mul i 72 |
| 211 | put h o 1 |
| 212 | hp h add o 16 add 256 i |
| 213 | hp h add o 56 i |
| 214 | end |
| 215 | ret 0 |
| 216 | end |
| 217 | |
| 218 | fn fkreg st edit ulong 64 h edit uchar HN to long |
| 219 | fd = get st 1 |
| 220 | if not want st fd 4 0 |
| 221 | ret neg long 22 |
| 222 | end |
| 223 | if or lt fd 11 or not isopen st fd ne hg h 0 10 |
| 224 | bad st |
| 225 | ret neg long 22 |
| 226 | end |
| 227 | ret 0 |
| 228 | end |
| 229 | |
| 230 | fn fkdev st edit ulong 64 h edit uchar HN p edit uchar PN to ulong |
| 231 | x = hg h 8 |
| 232 | i = pg p 0 |
| 233 | r = get st 16 |
| 234 | if not need st 56 and eq hg h 4 r and eq pg p 4 r lt i ngpu st |
| 235 | ret 86 |
| 236 | end |
| 237 | if ne get st add 48 i 0 |
| 238 | bad st |
| 239 | ret 86 |
| 240 | end |
| 241 | if flt st 65 |
| 242 | ret 27 |
| 243 | end |
| 244 | keep st x |
| 245 | put st add 48 i x |
| 246 | ret 0 |
| 247 | end |
| 248 | |
| 249 | fn fksub st edit ulong 64 h edit uchar HN to ulong |
| 250 | x = hg h 8 |
| 251 | d = hg h 4 |
| 252 | if not need st 4 isdev st d |
| 253 | ret 86 |
| 254 | end |
| 255 | i = gpu st d |
| 256 | if ne get st add 50 i 0 |
| 257 | bad st |
| 258 | ret 86 |
| 259 | end |
| 260 | keep st x |
| 261 | put st add 50 i x |
| 262 | ret 0 |
| 263 | end |
| 264 | |
| 265 | note NV_ESC_RM_ALLOC: NVOS21 hRoot 0, parent 4, hObjectNew 8, hClass 12, status 28. |
| 266 | fn fkalloc st edit ulong 64 h edit uchar HN p edit uchar PN to long |
| 267 | if or ne get st 1 10 ne get st 3 32 |
| 268 | bad st |
| 269 | ret neg long 22 |
| 270 | end |
| 271 | c = hg h 12 |
| 272 | v = ulong 86 |
| 273 | if eq c 65 |
| 274 | if flt st 80 |
| 275 | ret neg long 1 |
| 276 | end |
| 277 | if or ne get st 4 0 ne get st 16 0 |
| 278 | bad st |
| 279 | else |
| 280 | if or ne hg h 0 0 ne hg h 4 0 |
| 281 | bad st |
| 282 | else |
| 283 | hp h 8 RT |
| 284 | put st 16 RT |
| 285 | keep st RT |
| 286 | v = 0 |
| 287 | end |
| 288 | end |
| 289 | hp h 28 v |
| 290 | ret 0 |
| 291 | end |
| 292 | if ne hg h 0 get st 16 |
| 293 | bad st |
| 294 | v = 86 |
| 295 | else |
| 296 | if eq c 128 |
| 297 | v = fkdev st h p |
| 298 | end |
| 299 | if eq c 8320 |
| 300 | v = fksub st h |
| 301 | end |
| 302 | end |
| 303 | hp h 28 v |
| 304 | ret 0 |
| 305 | end |
| 306 | |
| 307 | fn unmap st edit ulong 64 x ulong to void |
| 308 | for i ulong 4 |
| 309 | if eq get st add 48 i x |
| 310 | put st add 48 i 0 |
| 311 | end |
| 312 | end |
| 313 | end |
| 314 | |
| 315 | note NV_ESC_RM_FREE: NVOS00 hRoot 0, parent 4, hObjectOld 8, status 12. A freed parent must have no |
| 316 | note live child (the caller frees bottom-up). |
| 317 | fn fkfree st edit ulong 64 h edit uchar HN to long |
| 318 | if not want st 10 16 0 |
| 319 | ret neg long 22 |
| 320 | end |
| 321 | r = hg h 0 |
| 322 | q = hg h 4 |
| 323 | x = hg h 8 |
| 324 | i = slot st x |
| 325 | ok = and ne i 0 eq r get st 16 |
| 326 | if eq x r |
| 327 | ok = and ok and eq q r eq get st 15 1 |
| 328 | end |
| 329 | if isdev st x |
| 330 | ok = and ok eq q r |
| 331 | if ne get st add 50 gpu st x 0 |
| 332 | ok = false |
| 333 | end |
| 334 | end |
| 335 | if issub st x |
| 336 | if ne get st add 48 gpu st x q |
| 337 | ok = false |
| 338 | end |
| 339 | end |
| 340 | if not ok |
| 341 | bad st |
| 342 | hp h 12 86 |
| 343 | ret 0 |
| 344 | end |
| 345 | put st add 31 i 0 |
| 346 | put st 11 add get st 11 1 |
| 347 | put st 15 sub get st 15 1 |
| 348 | if eq x r |
| 349 | put st 16 0 |
| 350 | end |
| 351 | f = issub st x |
| 352 | unmap st x |
| 353 | v = ulong 0 |
| 354 | if and f flt st 102 |
| 355 | v = 31 |
| 356 | end |
| 357 | hp h 12 v |
| 358 | ret 0 |
| 359 | end |
| 360 | |
| 361 | fn c517 st edit ulong 64 p edit uchar PN o ulong to ulong |
| 362 | i = sub pg p 0 256 |
| 363 | if not need st 32 and eq o get st 16 lt i ngpu st |
| 364 | ret 86 |
| 365 | end |
| 366 | pp p 8 i |
| 367 | ret 0 |
| 368 | end |
| 369 | |
| 370 | fn cclass st edit ulong 64 p edit uchar PN o ulong to ulong |
| 371 | if not need st 804 isdev st o |
| 372 | ret 86 |
| 373 | end |
| 374 | pp p 0 3 |
| 375 | pp p 4 41141 |
| 376 | if flt st 107 |
| 377 | pp p 8 50880 |
| 378 | else |
| 379 | pp p 8 52928 |
| 380 | end |
| 381 | pp p 12 51311 |
| 382 | ret 0 |
| 383 | end |
| 384 | |
| 385 | fn cname st edit ulong 64 p edit uchar PN o ulong to ulong |
| 386 | if not need st 132 and issub st o eq pg p 0 0 |
| 387 | ret 86 |
| 388 | end |
| 389 | if flt st 99 |
| 390 | ret 86 |
| 391 | end |
| 392 | if flt st 71 |
| 393 | ret 15 |
| 394 | end |
| 395 | if flt st 69 |
| 396 | ret 0 |
| 397 | end |
| 398 | if flt st 110 |
| 399 | for i ulong 128 |
| 400 | put p add 4 i 65 |
| 401 | end |
| 402 | ret 0 |
| 403 | end |
| 404 | pq p 4 5125168158881699406 |
| 405 | pp p 12 3158338 |
| 406 | ret 0 |
| 407 | end |
| 408 | |
| 409 | fn cgid st edit ulong 64 p edit uchar PN o ulong to ulong |
| 410 | if not need st 268 and issub st o eq pg p 4 2 |
| 411 | ret 86 |
| 412 | end |
| 413 | if flt st 103 |
| 414 | pp p 8 20 |
| 415 | else |
| 416 | pp p 8 16 |
| 417 | end |
| 418 | pq p 12 11234237185837469435 |
| 419 | if eq gpu st o 1 |
| 420 | pq p 20 6510914109430312912 |
| 421 | else |
| 422 | pq p 20 6438856515392384976 |
| 423 | end |
| 424 | ret 0 |
| 425 | end |
| 426 | |
| 427 | fn cthop st edit ulong 64 p edit uchar PN o ulong k ulong g ulong to bool |
| 428 | op = pg p add o 8 |
| 429 | a = pg p add o 12 |
| 430 | if or eq op 256 eq op 1280 |
| 431 | pp p add o 12 1 |
| 432 | ret true |
| 433 | end |
| 434 | if ne a 0 |
| 435 | ret false |
| 436 | end |
| 437 | if eq op 257 |
| 438 | if flt st 118 |
| 439 | pp p add o 16 2 |
| 440 | else |
| 441 | pp p add o 16 1 |
| 442 | end |
| 443 | ret true |
| 444 | end |
| 445 | if eq op 1312 |
| 446 | pp p add o 16 0 |
| 447 | ret true |
| 448 | end |
| 449 | if eq op 5376 |
| 450 | if flt st 104 |
| 451 | pp p add o 16 4294967286 |
| 452 | else |
| 453 | pp p add o 16 add 40 g |
| 454 | end |
| 455 | ret true |
| 456 | end |
| 457 | ret false |
| 458 | end |
| 459 | |
| 460 | fn ctherm st edit ulong 64 p edit uchar PN o ulong to ulong |
| 461 | n = pg p 20 |
| 462 | if not need st 1432 issub st o |
| 463 | ret 86 |
| 464 | end |
| 465 | if or ne pg p 0 1 or ne pg p 8 44 gt n 32 |
| 466 | bad st |
| 467 | ret 86 |
| 468 | end |
| 469 | g = gpu st o |
| 470 | for k ulong n |
| 471 | q = add 24 mul k 44 |
| 472 | if not cthop st p q k g |
| 473 | bad st |
| 474 | ret 86 |
| 475 | end |
| 476 | pp p q 0 |
| 477 | if and flt st 116 eq k 0 |
| 478 | pp p add q 4 0 |
| 479 | else |
| 480 | pp p add q 4 1 |
| 481 | end |
| 482 | end |
| 483 | ret 0 |
| 484 | end |
| 485 | |
| 486 | fn cfb st edit ulong 64 p edit uchar PN o ulong to ulong |
| 487 | n = pg p 0 |
| 488 | if not need st 1028 and issub st o le n 128 |
| 489 | ret 86 |
| 490 | end |
| 491 | if flt st 120 |
| 492 | ret 86 |
| 493 | end |
| 494 | for i ulong n |
| 495 | q = add 4 mul i 8 |
| 496 | x = pg p q |
| 497 | v = ulong 0 |
| 498 | if eq x 54 |
| 499 | if flt st 122 |
| 500 | v = 1 |
| 501 | end |
| 502 | else |
| 503 | if eq x 8 |
| 504 | v = 128000000 |
| 505 | else |
| 506 | if eq x 22 |
| 507 | if flt st 109 |
| 508 | v = 200000000 |
| 509 | else |
| 510 | v = 100000000 |
| 511 | end |
| 512 | else |
| 513 | bad st |
| 514 | ret 86 |
| 515 | end |
| 516 | end |
| 517 | end |
| 518 | pp p add q 4 v |
| 519 | end |
| 520 | ret 0 |
| 521 | end |
| 522 | |
| 523 | fn cutil st edit ulong 64 p edit uchar PN o ulong to ulong |
| 524 | if not need st PN issub st o |
| 525 | ret 86 |
| 526 | end |
| 527 | if or ne get p 0 2 ne pg p 4 55872 |
| 528 | bad st |
| 529 | ret 86 |
| 530 | end |
| 531 | if flt st 119 |
| 532 | ret 86 |
| 533 | end |
| 534 | if flt st 121 |
| 535 | ret 27 |
| 536 | end |
| 537 | if flt st 101 |
| 538 | pp p 8 0 |
| 539 | else |
| 540 | pp p 8 72 |
| 541 | end |
| 542 | if flt st 114 |
| 543 | pp p 12 72 |
| 544 | else |
| 545 | pp p 12 5 |
| 546 | end |
| 547 | for k ulong 72 |
| 548 | q = add 16 mul k 776 |
| 549 | f = mul k 50 |
| 550 | g = mul k 100 |
| 551 | t = add 1000 k |
| 552 | if eq k 4 |
| 553 | f = 1300 |
| 554 | g = 4200 |
| 555 | if flt st 88 |
| 556 | g = 10001 |
| 557 | end |
| 558 | if flt st 90 |
| 559 | t = 0 |
| 560 | end |
| 561 | end |
| 562 | pq p q t |
| 563 | pp p add q 8 f |
| 564 | pp p add q 136 g |
| 565 | end |
| 566 | ret 0 |
| 567 | end |
| 568 | |
| 569 | fn cpids st edit ulong 64 p edit uchar PN o ulong to ulong |
| 570 | if not need st 3812 issub st o |
| 571 | ret 86 |
| 572 | end |
| 573 | if or ne pg p 0 0 ne pg p 4 52928 |
| 574 | bad st |
| 575 | ret 86 |
| 576 | end |
| 577 | n = ulong 2 |
| 578 | if flt st 108 |
| 579 | n = 0 |
| 580 | end |
| 581 | if flt st 112 |
| 582 | n = 951 |
| 583 | end |
| 584 | if flt st 98 |
| 585 | n = 250 |
| 586 | end |
| 587 | pp p 8 n |
| 588 | if eq n 2 |
| 589 | pp p 12 68451 |
| 590 | pp p 16 4242 |
| 591 | end |
| 592 | if eq n 250 |
| 593 | for i ulong n |
| 594 | pp p add 12 mul i 4 add 1000 i |
| 595 | end |
| 596 | end |
| 597 | ret 0 |
| 598 | end |
| 599 | |
| 600 | fn cpinfo st edit ulong 64 p edit uchar PN o ulong to ulong |
| 601 | m = pg p 0 |
| 602 | if not need st 14408 and issub st o le m 200 |
| 603 | ret 86 |
| 604 | end |
| 605 | for i ulong m |
| 606 | q = add 8 mul i 72 |
| 607 | d = pg p q |
| 608 | if ne pg p add q 4 0 |
| 609 | bad st |
| 610 | ret 86 |
| 611 | end |
| 612 | r = ulong 0 |
| 613 | v = mul d 65536 |
| 614 | if eq d 68451 |
| 615 | v = 351272960 |
| 616 | end |
| 617 | if and flt st 105 eq d 4242 |
| 618 | r = 1 |
| 619 | v = 0 |
| 620 | end |
| 621 | if and flt st 106 eq i 0 |
| 622 | pp p q add d 1 |
| 623 | end |
| 624 | pp p add q 8 r |
| 625 | pq p add q 16 v |
| 626 | end |
| 627 | ret 0 |
| 628 | end |
| 629 | |
| 630 | fn cdisp st edit ulong 64 p edit uchar PN o ulong c ulong to ulong |
| 631 | if eq c 517 |
| 632 | ret c517 st p o |
| 633 | end |
| 634 | if eq c 8389266 |
| 635 | ret cclass st p o |
| 636 | end |
| 637 | if eq c 545259792 |
| 638 | ret cname st p o |
| 639 | end |
| 640 | if eq c 545259850 |
| 641 | ret cgid st p o |
| 642 | end |
| 643 | if eq c 545260819 |
| 644 | ret ctherm st p o |
| 645 | end |
| 646 | if eq c 545264387 |
| 647 | ret cfb st p o |
| 648 | end |
| 649 | if eq c 545267862 |
| 650 | ret cutil st p o |
| 651 | end |
| 652 | if eq c 545259917 |
| 653 | ret cpids st p o |
| 654 | end |
| 655 | if eq c 545259918 |
| 656 | ret cpinfo st p o |
| 657 | end |
| 658 | bad st |
| 659 | ret 86 |
| 660 | end |
| 661 | |
| 662 | note NV_ESC_RM_CONTROL: NVOS54 hClient 0, hObject 4, cmd 8, status 28. |
| 663 | fn fkctl st edit ulong 64 h edit uchar HN p edit uchar PN to long |
| 664 | if not want st 10 32 get st 4 |
| 665 | ret neg long 22 |
| 666 | end |
| 667 | if ne hg h 0 get st 16 |
| 668 | bad st |
| 669 | ret neg long 22 |
| 670 | end |
| 671 | o = hg h 4 |
| 672 | if eq slot st o 0 |
| 673 | bad st |
| 674 | hp h 28 86 |
| 675 | ret 0 |
| 676 | end |
| 677 | put st 12 add get st 12 1 |
| 678 | hp h 28 cdisp st p o hg h 8 |
| 679 | ret 0 |
| 680 | end |
| 681 | |
| 682 | fn fkioctl st edit ulong 64 h edit uchar HN p edit uchar PN to long |
| 683 | nr = get st 2 |
| 684 | if eq nr 200 |
| 685 | ret fkcard st h |
| 686 | end |
| 687 | if eq nr 201 |
| 688 | ret fkreg st h |
| 689 | end |
| 690 | if eq nr 43 |
| 691 | ret fkalloc st h p |
| 692 | end |
| 693 | if eq nr 41 |
| 694 | ret fkfree st h |
| 695 | end |
| 696 | if eq nr 42 |
| 697 | ret fkctl st h p |
| 698 | end |
| 699 | bad st |
| 700 | ret neg long 22 |
| 701 | end |
| 702 | |
| 703 | fn nvml_fake st edit ulong 64 h edit uchar HN p edit uchar PN to ulong |
| 704 | k = get st 0 |
| 705 | r = neg long 22 |
| 706 | if eq k 1 |
| 707 | r = fkioctl st h p |
| 708 | end |
| 709 | if eq k 2 |
| 710 | r = fkopen st p |
| 711 | end |
| 712 | if eq k 3 |
| 713 | r = fkclose st |
| 714 | end |
| 715 | if or lt k 1 gt k 3 |
| 716 | bad st |
| 717 | end |
| 718 | if lt r 0 |
| 719 | put st 6 sub 18446744073709551615 ulong sub neg r 1 |
| 720 | else |
| 721 | put st 6 ulong r |
| 722 | end |
| 723 | ret 0 |
| 724 | end |