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
omega-mv / gpu / nvidia / om / components / artifact_admit.om
| 1 | note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 2 | note Admission is an effect protocol. C supplies retained file bytes and digest results. |
| 3 | note stage0 layout,1 identity digest,2 file digests,3 ELF match,4 final policy,5 done. |
| 4 | fn aa_literal which ulong p ulong to ulong |
| 5 | if eq which 0 |
| 6 | if eq p 0 |
| 7 | ret 115 |
| 8 | end |
| 9 | if eq p 1 |
| 10 | ret 109 |
| 11 | end |
| 12 | if eq p 2 |
| 13 | ret 95 |
| 14 | end |
| 15 | if eq p 3 |
| 16 | ret 49 |
| 17 | end |
| 18 | if eq p 4 |
| 19 | ret 50 |
| 20 | end |
| 21 | if eq p 5 |
| 22 | ret 49 |
| 23 | end |
| 24 | ret 0 |
| 25 | end |
| 26 | if eq which 1 |
| 27 | if eq p 0 |
| 28 | ret 110 |
| 29 | end |
| 30 | if eq p 1 |
| 31 | ret 118 |
| 32 | end |
| 33 | if eq p 2 |
| 34 | ret 105 |
| 35 | end |
| 36 | if eq p 3 |
| 37 | ret 100 |
| 38 | end |
| 39 | if eq p 4 |
| 40 | ret 105 |
| 41 | end |
| 42 | if eq p 5 |
| 43 | ret 97 |
| 44 | end |
| 45 | if eq p 6 |
| 46 | ret 45 |
| 47 | end |
| 48 | if eq p 7 |
| 49 | ret 99 |
| 50 | end |
| 51 | if eq p 8 |
| 52 | ret 117 |
| 53 | end |
| 54 | if eq p 9 |
| 55 | ret 98 |
| 56 | end |
| 57 | if eq p 10 |
| 58 | ret 105 |
| 59 | end |
| 60 | if eq p 11 |
| 61 | ret 110 |
| 62 | end |
| 63 | if eq p 12 |
| 64 | ret 45 |
| 65 | end |
| 66 | if eq p 13 |
| 67 | ret 101 |
| 68 | end |
| 69 | if eq p 14 |
| 70 | ret 108 |
| 71 | end |
| 72 | if eq p 15 |
| 73 | ret 102 |
| 74 | end |
| 75 | if eq p 16 |
| 76 | ret 54 |
| 77 | end |
| 78 | if eq p 17 |
| 79 | ret 52 |
| 80 | end |
| 81 | ret 0 |
| 82 | end |
| 83 | if eq which 2 |
| 84 | if eq p 0 |
| 85 | ret 122 |
| 86 | end |
| 87 | if eq p 1 |
| 88 | ret 101 |
| 89 | end |
| 90 | if eq p 2 |
| 91 | ret 114 |
| 92 | end |
| 93 | if eq p 3 |
| 94 | ret 111 |
| 95 | end |
| 96 | if eq p 4 |
| 97 | ret 45 |
| 98 | end |
| 99 | if eq p 5 |
| 100 | ret 118 |
| 101 | end |
| 102 | if eq p 6 |
| 103 | ret 97 |
| 104 | end |
| 105 | if eq p 7 |
| 106 | ret 45 |
| 107 | end |
| 108 | if eq p 8 |
| 109 | ret 118 |
| 110 | end |
| 111 | if eq p 9 |
| 112 | ret 49 |
| 113 | end |
| 114 | ret 0 |
| 115 | end |
| 116 | ret 0 |
| 117 | end |
| 118 | fn aa_hex b view uchar 65536 s view ulong 128 k ulong to bool |
| 119 | if ne get s add k 48 64 |
| 120 | ret false |
| 121 | end |
| 122 | off = get s add k 8 |
| 123 | for i ulong 64 |
| 124 | ch = get b add off i |
| 125 | if not or and ge ch 48 le ch 57 and ge ch 97 le ch 102 |
| 126 | ret false |
| 127 | end |
| 128 | end |
| 129 | ret true |
| 130 | end |
| 131 | fn aa_digest b view uchar 65536 s view ulong 128 k ulong to bool |
| 132 | off = get s add k 8 |
| 133 | for i ulong 64 |
| 134 | if ne get b add off i get b add 26000 i |
| 135 | ret false |
| 136 | end |
| 137 | end |
| 138 | ret true |
| 139 | end |
| 140 | fn aa_emit s edit ulong 128 st view ulong 8 rc ulong to void |
| 141 | if or eq rc 1 eq rc 3 |
| 142 | j = get st 2 |
| 143 | if eq rc 3 |
| 144 | j = sub j 1 |
| 145 | end |
| 146 | put s add 110 j get st 4 |
| 147 | end |
| 148 | end |
| 149 | fn aa_parse b view uchar 65536 s edit ulong 128 k ulong count ulong mode ulong to bool |
| 150 | st = new ulong 8 0 |
| 151 | put st 3 count |
| 152 | n = get s add k 48 |
| 153 | if and eq mode 2 ge n 64 |
| 154 | ret false |
| 155 | end |
| 156 | off = get s add k 8 |
| 157 | for i ulong add n 1 |
| 158 | ch = ulong 0 |
| 159 | if lt i n |
| 160 | ch = ulong get b add off i |
| 161 | end |
| 162 | rc = artifact_parse mode ch st |
| 163 | if eq rc 2 |
| 164 | ret false |
| 165 | end |
| 166 | aa_emit s st rc |
| 167 | end |
| 168 | ret true |
| 169 | end |
| 170 | fn aa_eq b view uchar 65536 s view ulong 128 k ulong which ulong to bool |
| 171 | off = get s add k 8 |
| 172 | n = get s add k 48 |
| 173 | for i ulong n |
| 174 | if ne ulong get b add off i aa_literal which i |
| 175 | ret false |
| 176 | end |
| 177 | end |
| 178 | ret eq aa_literal which n 0 |
| 179 | end |
| 180 | fn aa_field b view uchar 65536 s view ulong 128 k ulong cap ulong empty ulong to bool |
| 181 | n = get s add k 48 |
| 182 | if ge n cap |
| 183 | ret false |
| 184 | end |
| 185 | if and eq empty 0 eq n 0 |
| 186 | ret false |
| 187 | end |
| 188 | ret true |
| 189 | end |
| 190 | fn aa_driver b view uchar 65536 s edit ulong 128 to ulong |
| 191 | st = new ulong 8 0 |
| 192 | if ne get s 106 0 |
| 193 | put st 3 3 |
| 194 | n = get s 107 |
| 195 | for i ulong add n 1 |
| 196 | ch = ulong 0 |
| 197 | if lt i n |
| 198 | ch = ulong get b add 25088 i |
| 199 | end |
| 200 | rc = artifact_parse 3 ch st |
| 201 | if eq rc 2 |
| 202 | ret 1 |
| 203 | end |
| 204 | if or eq rc 1 eq rc 3 |
| 205 | j = get st 2 |
| 206 | if eq rc 3 |
| 207 | j = sub j 1 |
| 208 | end |
| 209 | put s add 120 j get st 4 |
| 210 | end |
| 211 | end |
| 212 | for i ulong 3 |
| 213 | have = get s add 120 i |
| 214 | need = get s add 110 i |
| 215 | if gt have need |
| 216 | ret 0 |
| 217 | end |
| 218 | if lt have need |
| 219 | ret 8 |
| 220 | end |
| 221 | end |
| 222 | end |
| 223 | ret 0 |
| 224 | end |
| 225 | fn aa_final b view uchar 65536 s edit ulong 128 to ulong |
| 226 | q0 = new uchar 256 0 |
| 227 | q1 = new uchar 256 0 |
| 228 | shape = new ulong 7 0 |
| 229 | for i ulong 256 |
| 230 | put q0 i get b add 24576 i |
| 231 | put q1 i get b add 24832 i |
| 232 | end |
| 233 | if eq art_template q0 q1 0 |
| 234 | ret 7 |
| 235 | end |
| 236 | if not aa_field b s 22 64 1 |
| 237 | ret 2 |
| 238 | end |
| 239 | if not aa_parse b s 22 3 2 |
| 240 | ret 2 |
| 241 | end |
| 242 | put shape 0 get s 110 |
| 243 | put shape 1 get s 111 |
| 244 | if ne get s 112 1 |
| 245 | ret 2 |
| 246 | end |
| 247 | if not aa_field b s 23 64 1 |
| 248 | ret 2 |
| 249 | end |
| 250 | if not aa_parse b s 23 3 2 |
| 251 | ret 2 |
| 252 | end |
| 253 | put shape 2 get s 110 |
| 254 | put shape 3 get s 111 |
| 255 | put shape 4 get s 112 |
| 256 | if not aa_field b s 24 64 1 |
| 257 | ret 2 |
| 258 | end |
| 259 | if not aa_parse b s 24 1 2 |
| 260 | ret 2 |
| 261 | end |
| 262 | put shape 5 get s 110 |
| 263 | if not aa_field b s 25 64 1 |
| 264 | ret 2 |
| 265 | end |
| 266 | if not aa_parse b s 25 1 2 |
| 267 | ret 2 |
| 268 | end |
| 269 | put shape 6 get s 110 |
| 270 | if eq art_launch q1 shape 0 |
| 271 | ret 3 |
| 272 | end |
| 273 | if not aa_field b s 19 64 1 |
| 274 | ret 2 |
| 275 | end |
| 276 | if not aa_parse b s 19 1 2 |
| 277 | ret 2 |
| 278 | end |
| 279 | w = get s 110 |
| 280 | if or eq w 0 or gt w 32 ne get s 105 mul w 4 |
| 281 | ret 2 |
| 282 | end |
| 283 | if not aa_field b s 2 128 0 |
| 284 | ret 2 |
| 285 | end |
| 286 | if not aa_field b s 3 128 0 |
| 287 | ret 2 |
| 288 | end |
| 289 | if not aa_field b s 7 128 1 |
| 290 | ret 4 |
| 291 | end |
| 292 | if not aa_eq b s 7 0 |
| 293 | ret 4 |
| 294 | end |
| 295 | if not aa_field b s 9 128 1 |
| 296 | ret 2 |
| 297 | end |
| 298 | if not aa_eq b s 9 1 |
| 299 | ret 2 |
| 300 | end |
| 301 | if not aa_field b s 17 128 1 |
| 302 | ret 7 |
| 303 | end |
| 304 | if not aa_eq b s 17 2 |
| 305 | ret 7 |
| 306 | end |
| 307 | if not aa_field b s 5 128 1 |
| 308 | ret 3 |
| 309 | end |
| 310 | if not aa_hex b s 5 |
| 311 | ret 3 |
| 312 | end |
| 313 | if not aa_field b s 29 128 1 |
| 314 | ret 2 |
| 315 | end |
| 316 | if not aa_parse b s 29 3 3 |
| 317 | ret 2 |
| 318 | end |
| 319 | ret aa_driver b s |
| 320 | end |
| 321 | fn aa_opchar n ulong i ulong to ulong |
| 322 | if eq n 6 |
| 323 | if eq i 0 |
| 324 | ret 109 |
| 325 | end |
| 326 | if eq i 1 |
| 327 | ret 97 |
| 328 | end |
| 329 | if eq i 2 |
| 330 | ret 116 |
| 331 | end |
| 332 | if eq i 3 |
| 333 | ret 109 |
| 334 | end |
| 335 | if eq i 4 |
| 336 | ret 117 |
| 337 | end |
| 338 | if eq i 5 |
| 339 | ret 108 |
| 340 | end |
| 341 | end |
| 342 | if eq n 20 |
| 343 | if eq i 0 |
| 344 | ret 103 |
| 345 | end |
| 346 | if eq i 1 |
| 347 | ret 113 |
| 348 | end |
| 349 | if eq i 2 |
| 350 | ret 97 |
| 351 | end |
| 352 | if eq i 3 |
| 353 | ret 45 |
| 354 | end |
| 355 | if eq i 4 |
| 356 | ret 99 |
| 357 | end |
| 358 | if eq i 5 |
| 359 | ret 97 |
| 360 | end |
| 361 | if eq i 6 |
| 362 | ret 117 |
| 363 | end |
| 364 | if eq i 7 |
| 365 | ret 115 |
| 366 | end |
| 367 | if eq i 8 |
| 368 | ret 97 |
| 369 | end |
| 370 | if eq i 9 |
| 371 | ret 108 |
| 372 | end |
| 373 | if eq i 10 |
| 374 | ret 45 |
| 375 | end |
| 376 | if eq i 11 |
| 377 | ret 97 |
| 378 | end |
| 379 | if eq i 12 |
| 380 | ret 116 |
| 381 | end |
| 382 | if eq i 13 |
| 383 | ret 116 |
| 384 | end |
| 385 | if eq i 14 |
| 386 | ret 101 |
| 387 | end |
| 388 | if eq i 15 |
| 389 | ret 110 |
| 390 | end |
| 391 | if eq i 16 |
| 392 | ret 116 |
| 393 | end |
| 394 | if eq i 17 |
| 395 | ret 105 |
| 396 | end |
| 397 | if eq i 18 |
| 398 | ret 111 |
| 399 | end |
| 400 | if eq i 19 |
| 401 | ret 110 |
| 402 | end |
| 403 | end |
| 404 | ret 0 |
| 405 | end |
| 406 | fn aa_op b view uchar 65536 s view ulong 128 to bool |
| 407 | p = get s 9 |
| 408 | n = get s 49 |
| 409 | if not or eq n 6 eq n 20 |
| 410 | ret false |
| 411 | end |
| 412 | for i ulong n |
| 413 | if ne ulong get b add p i aa_opchar n i |
| 414 | ret false |
| 415 | end |
| 416 | end |
| 417 | ret true |
| 418 | end |
| 419 | fn aa_exptext b view uchar 65536 s edit ulong 128 to ulong |
| 420 | for k ulong 34 |
| 421 | if not or and ge k 1 le k 4 or eq k 10 and ge k 26 le k 33 |
| 422 | continue |
| 423 | end |
| 424 | off = get s add k 8 |
| 425 | for i ulong get s add k 48 |
| 426 | ch = get b add off i |
| 427 | if or lt ch 32 eq ch 127 |
| 428 | ret 1 |
| 429 | end |
| 430 | end |
| 431 | end |
| 432 | if not aa_parse b s 29 3 3 |
| 433 | ret 1 |
| 434 | end |
| 435 | ret 0 |
| 436 | end |
| 437 | fn aa_export b view uchar 65536 s edit ulong 128 to ulong |
| 438 | q0 = new uchar 256 0 |
| 439 | q1 = new uchar 256 0 |
| 440 | shape = new ulong 7 0 |
| 441 | if or not aa_hex b s 5 not aa_hex b s 6 |
| 442 | ret 3 |
| 443 | end |
| 444 | if not aa_op b s |
| 445 | ret 9 |
| 446 | end |
| 447 | for i ulong 256 |
| 448 | put q0 i get b add 24576 i |
| 449 | put q1 i get b add 24832 i |
| 450 | end |
| 451 | if eq art_template q0 q1 0 |
| 452 | ret 7 |
| 453 | end |
| 454 | put shape 0 get s 92 |
| 455 | put shape 1 get s 93 |
| 456 | put shape 2 get s 94 |
| 457 | put shape 3 get s 95 |
| 458 | put shape 4 get s 96 |
| 459 | put shape 5 get s 97 |
| 460 | put shape 6 get s 98 |
| 461 | if eq art_launch q1 shape 0 |
| 462 | ret 3 |
| 463 | end |
| 464 | ret 0 |
| 465 | end |
| 466 | fn artifact_admit b edit uchar 65536 s edit ulong 128 to ulong |
| 467 | if eq get s 0 10 |
| 468 | ret aa_exptext b s |
| 469 | end |
| 470 | if eq get s 0 12 |
| 471 | ret aa_export b s |
| 472 | end |
| 473 | if eq get s 0 13 |
| 474 | if eq get s 5 7 |
| 475 | ret 10 |
| 476 | end |
| 477 | if ne get s 5 0 |
| 478 | ret 9 |
| 479 | end |
| 480 | ret 0 |
| 481 | end |
| 482 | if eq get s 0 14 |
| 483 | v = and add get s 113 get s 114 4294967295 |
| 484 | if gt v get s 115 |
| 485 | put s 115 v |
| 486 | end |
| 487 | ret 0 |
| 488 | end |
| 489 | if eq get s 0 11 |
| 490 | if or ne get s 90 896 or eq get s 91 0 gt get s 91 32 |
| 491 | ret 9 |
| 492 | end |
| 493 | ret 0 |
| 494 | end |
| 495 | if eq get s 0 0 |
| 496 | if eq af_layout b s 0 |
| 497 | ret 2 |
| 498 | end |
| 499 | if not aa_hex b s 0 |
| 500 | ret 2 |
| 501 | end |
| 502 | put s 108 sub get s 9 3 |
| 503 | put s 109 sub get s 41 16 |
| 504 | put s 0 1 |
| 505 | ret 0 |
| 506 | end |
| 507 | if eq get s 0 1 |
| 508 | if not aa_digest b s 0 |
| 509 | ret 5 |
| 510 | end |
| 511 | put s 0 2 |
| 512 | put s 6 1 |
| 513 | put s 7 11 |
| 514 | ret 0 |
| 515 | end |
| 516 | if eq get s 0 2 |
| 517 | k = get s 7 |
| 518 | if not aa_hex b s k |
| 519 | ret 2 |
| 520 | end |
| 521 | if eq get s 5 0 |
| 522 | ret 6 |
| 523 | end |
| 524 | f = get s 6 |
| 525 | if or eq f 3 eq f 4 |
| 526 | if ne get s add 100 f 384 |
| 527 | ret 5 |
| 528 | end |
| 529 | end |
| 530 | if not aa_digest b s k |
| 531 | ret 5 |
| 532 | end |
| 533 | if eq f 5 |
| 534 | if not aa_field b s 10 64 0 |
| 535 | ret 2 |
| 536 | end |
| 537 | put s 0 3 |
| 538 | else |
| 539 | put s 6 add f 1 |
| 540 | if eq f 1 |
| 541 | put s 7 13 |
| 542 | else |
| 543 | if eq f 2 |
| 544 | put s 7 15 |
| 545 | else |
| 546 | if eq f 3 |
| 547 | put s 7 16 |
| 548 | else |
| 549 | put s 7 21 |
| 550 | end |
| 551 | end |
| 552 | end |
| 553 | end |
| 554 | ret 0 |
| 555 | end |
| 556 | if eq get s 0 3 |
| 557 | if eq get s 5 0 |
| 558 | ret 5 |
| 559 | end |
| 560 | rc = aa_final b s |
| 561 | if ne rc 0 |
| 562 | ret rc |
| 563 | end |
| 564 | put s 0 5 |
| 565 | ret 0 |
| 566 | end |
| 567 | ret 0 |
| 568 | end |