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 / driver / tests / arena_large.om
| 1 | note Device-free caller. Read the seven verified firmware spans; emit the anonymous staged bytes and COT. |
| 2 | note The first byte selects a normal cap (0), a 16 MiB cap (1), dirty high output bytes (2), |
| 3 | note unskewed input (3), or Profile 2 size/offset negative controls (4..9). |
| 4 | global alchunk uchar 65536 |
| 5 | fn alread n ulong to bool |
| 6 | p = ulong 0 |
| 7 | while lt p n bound 65536 |
| 8 | r = read 0 alchunk p sub n p |
| 9 | if lt r 1 |
| 10 | ret false |
| 11 | end |
| 12 | p = add p ulong r |
| 13 | end |
| 14 | ret true |
| 15 | end |
| 16 | fn alwrite n ulong to bool |
| 17 | p = ulong 0 |
| 18 | while lt p n bound 65536 |
| 19 | r = write 1 alchunk p sub n p |
| 20 | if lt r 1 |
| 21 | ret false |
| 22 | end |
| 23 | p = add p ulong r |
| 24 | end |
| 25 | ret true |
| 26 | end |
| 27 | fn alspan pos ulong n ulong to bool |
| 28 | while gt n 0 bound 2048 |
| 29 | k = n |
| 30 | if gt k 65536 |
| 31 | k = ulong 65536 |
| 32 | end |
| 33 | if not alread k |
| 34 | ret false |
| 35 | end |
| 36 | for i ulong k |
| 37 | arinput add pos i get alchunk i |
| 38 | end |
| 39 | pos = add pos k |
| 40 | n = sub n k |
| 41 | end |
| 42 | ret true |
| 43 | end |
| 44 | fn alu64 o ulong to ulong |
| 45 | v = ulong 0 |
| 46 | for i ulong 8 |
| 47 | v = or v shl ulong aroutput add o i mul i 8 |
| 48 | end |
| 49 | ret v |
| 50 | end |
| 51 | fn alcrashok to bool |
| 52 | if ne get arsize 17 4096 |
| 53 | ret false |
| 54 | end |
| 55 | o = get aroff 17 |
| 56 | if or eq o 0 ne and o 4095 0 |
| 57 | ret false |
| 58 | end |
| 59 | w = get aroff 0 |
| 60 | if ne alu64 add w 224 araddr 17 |
| 61 | ret false |
| 62 | end |
| 63 | if ne alu64 add w 232 4096 |
| 64 | ret false |
| 65 | end |
| 66 | for i ulong 4096 |
| 67 | if ne aroutput add o i 0 |
| 68 | ret false |
| 69 | end |
| 70 | end |
| 71 | ret true |
| 72 | end |
| 73 | fn alneg mode uchar to int |
| 74 | pos = ulong 0 |
| 75 | for i ulong 7 |
| 76 | put arsrc i pos |
| 77 | pos = add pos get arslen i |
| 78 | end |
| 79 | expected = long -2 |
| 80 | if eq mode 4 |
| 81 | put arslen 1 4095 |
| 82 | end |
| 83 | if eq mode 5 |
| 84 | put arslen 2 196608 |
| 85 | end |
| 86 | if eq mode 6 |
| 87 | put arslen 3 195912 |
| 88 | end |
| 89 | if eq mode 7 |
| 90 | put arcfg 6 45056 |
| 91 | expected = -1 |
| 92 | end |
| 93 | if eq mode 8 |
| 94 | put arcfg 7 2561 |
| 95 | expected = -1 |
| 96 | end |
| 97 | if eq mode 9 |
| 98 | put arcfg 8 1 |
| 99 | expected = -1 |
| 100 | end |
| 101 | rc = arbuild |
| 102 | if ne rc expected |
| 103 | ret 11 |
| 104 | end |
| 105 | ret 0 |
| 106 | end |
| 107 | fn main to int |
| 108 | if not alread 1 |
| 109 | ret 1 |
| 110 | end |
| 111 | mode = get alchunk 0 |
| 112 | if gt mode 9 |
| 113 | ret 1 |
| 114 | end |
| 115 | put arcfg 0 2 |
| 116 | put arcfg 1 40 |
| 117 | put arcfg 2 268435456 |
| 118 | put arcfg 3 8192 |
| 119 | put arcfg 6 61440 |
| 120 | put arcfg 7 2560 |
| 121 | put arcfg 8 0 |
| 122 | for i ulong 3 |
| 123 | put arpkg i 2 |
| 124 | end |
| 125 | put arbase 0 1048576 |
| 126 | put arcap 0 ARMAX |
| 127 | if eq mode 1 |
| 128 | put arcap 0 ARLOW |
| 129 | end |
| 130 | put arslen 0 74969088 |
| 131 | put arslen 1 4096 |
| 132 | put arslen 2 212992 |
| 133 | put arslen 3 212296 |
| 134 | put arslen 4 48 |
| 135 | put arslen 5 384 |
| 136 | put arslen 6 384 |
| 137 | if ge mode 4 |
| 138 | ret alneg mode |
| 139 | end |
| 140 | note Skew the input three bytes so the packed word boundary differs from the output. |
| 141 | pos = ulong 3 |
| 142 | if eq mode 3 |
| 143 | pos = ulong 0 |
| 144 | end |
| 145 | for i ulong 7 |
| 146 | put arsrc i pos |
| 147 | if not alspan pos get arslen i |
| 148 | ret 2 |
| 149 | end |
| 150 | pos = add pos get arslen i |
| 151 | end |
| 152 | if ne read 0 alchunk 0 1 0 |
| 153 | ret 2 |
| 154 | end |
| 155 | if eq mode 2 |
| 156 | for page ulong 16384 |
| 157 | put aroword mul page 512 not ulong 0 |
| 158 | end |
| 159 | end |
| 160 | rc = arbuild |
| 161 | if ne rc 0 |
| 162 | if eq rc -3 |
| 163 | ret 3 |
| 164 | end |
| 165 | ret 4 |
| 166 | end |
| 167 | if not alcrashok |
| 168 | ret 10 |
| 169 | end |
| 170 | used = get arused 0 |
| 171 | h = mapnew -1 0 used 3 33 |
| 172 | if lt h 0 |
| 173 | ret 5 |
| 174 | end |
| 175 | if not arstdata h used |
| 176 | ret 6 |
| 177 | end |
| 178 | o = ulong 0 |
| 179 | while lt o used bound 2048 |
| 180 | k = sub used o |
| 181 | if gt k 65536 |
| 182 | k = ulong 65536 |
| 183 | end |
| 184 | if ne mapread h o alchunk 0 k long k |
| 185 | ret 7 |
| 186 | end |
| 187 | if not alwrite k |
| 188 | ret 8 |
| 189 | end |
| 190 | o = add o k |
| 191 | end |
| 192 | if ne mapdrop h 0 |
| 193 | ret 9 |
| 194 | end |
| 195 | for i ulong get arclen 0 |
| 196 | put alchunk i get arcot i |
| 197 | end |
| 198 | if not alwrite get arclen 0 |
| 199 | ret 8 |
| 200 | end |
| 201 | ret 0 |
| 202 | end |