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 / encoder / mmio_test.om
| 1 | note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 2 | note Concatenate after bw_enc_sm121.om. No arguments emits the production op21. |
| 3 | note One argument emits an EF mutant. Two arguments check nvdisasm stdin. |
| 4 | note The NVIDIA 13.0.85 oracle must decode exactly LDG.E.MMIO.GPU R4, desc[UR2][R8.64]. |
| 5 | note The historical EF cache policy is not an alias for MMIO. |
| 6 | fn mmcheck to int |
| 7 | buf = new uchar 4096 0 |
| 8 | n = ulong 0 |
| 9 | while lt n 4096 |
| 10 | k = read 0 buf n sub 4096 n |
| 11 | if lt k 0 |
| 12 | ret 70 |
| 13 | end |
| 14 | if eq k 0 |
| 15 | break |
| 16 | end |
| 17 | n = add n ulong k |
| 18 | end |
| 19 | if eq n 4096 |
| 20 | ret 71 |
| 21 | end |
| 22 | needle = new uchar 35 0 |
| 23 | put needle 0 76 |
| 24 | put needle 1 68 |
| 25 | put needle 2 71 |
| 26 | put needle 3 46 |
| 27 | put needle 4 69 |
| 28 | put needle 5 46 |
| 29 | put needle 6 77 |
| 30 | put needle 7 77 |
| 31 | put needle 8 73 |
| 32 | put needle 9 79 |
| 33 | put needle 10 46 |
| 34 | put needle 11 71 |
| 35 | put needle 12 80 |
| 36 | put needle 13 85 |
| 37 | put needle 14 32 |
| 38 | put needle 15 82 |
| 39 | put needle 16 52 |
| 40 | put needle 17 44 |
| 41 | put needle 18 32 |
| 42 | put needle 19 100 |
| 43 | put needle 20 101 |
| 44 | put needle 21 115 |
| 45 | put needle 22 99 |
| 46 | put needle 23 91 |
| 47 | put needle 24 85 |
| 48 | put needle 25 82 |
| 49 | put needle 26 50 |
| 50 | put needle 27 93 |
| 51 | put needle 28 91 |
| 52 | put needle 29 82 |
| 53 | put needle 30 56 |
| 54 | put needle 31 46 |
| 55 | put needle 32 54 |
| 56 | put needle 33 52 |
| 57 | put needle 34 93 |
| 58 | i = ulong 0 |
| 59 | while le add i 35 n |
| 60 | same = true |
| 61 | for j ulong 35 |
| 62 | if ne get buf add i j get needle j |
| 63 | same = false |
| 64 | end |
| 65 | end |
| 66 | if same |
| 67 | ret 0 |
| 68 | end |
| 69 | i = add i 1 |
| 70 | end |
| 71 | ret 4 |
| 72 | end |
| 73 | fn main to int |
| 74 | if gt argcnt 3 |
| 75 | ret 64 |
| 76 | end |
| 77 | if eq argcnt 3 |
| 78 | ret mmcheck |
| 79 | end |
| 80 | o = new ulong 16 0 |
| 81 | w = new ulong 4 0 |
| 82 | put o 0 21 |
| 83 | put o 1 4 |
| 84 | put o 2 8 |
| 85 | put o 5 2 |
| 86 | if ne enc1 view o edit w 0 |
| 87 | ret 1 |
| 88 | end |
| 89 | if ne get w 2 203364608 |
| 90 | ret 2 |
| 91 | end |
| 92 | if eq argcnt 2 |
| 93 | put w 2 202250496 |
| 94 | end |
| 95 | code = new uchar 16384 0 |
| 96 | store edit code 0 view w |
| 97 | off = ulong 0 |
| 98 | while lt off 16 |
| 99 | n = write 1 code off sub 16 off |
| 100 | if le n 0 |
| 101 | ret 3 |
| 102 | end |
| 103 | off = add off ulong n |
| 104 | end |
| 105 | ret 0 |
| 106 | end |