omega-gpu-driver
aien-dev/omega-gpu-driver
Brought by drakestapleton
omega-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), or dirty high output bytes (2). |
| 3 | global alchunk uchar 65536 |
| 4 | fn alread n ulong to bool |
| 5 | p = ulong 0 |
| 6 | while lt p n bound 65536 |
| 7 | r = read 0 alchunk p sub n p |
| 8 | if lt r 1 |
| 9 | ret false |
| 10 | end |
| 11 | p = add p ulong r |
| 12 | end |
| 13 | ret true |
| 14 | end |
| 15 | fn alwrite n ulong to bool |
| 16 | p = ulong 0 |
| 17 | while lt p n bound 65536 |
| 18 | r = write 1 alchunk p sub n p |
| 19 | if lt r 1 |
| 20 | ret false |
| 21 | end |
| 22 | p = add p ulong r |
| 23 | end |
| 24 | ret true |
| 25 | end |
| 26 | fn alspan pos ulong n ulong to bool |
| 27 | while gt n 0 bound 2048 |
| 28 | k = n |
| 29 | if gt k 65536 |
| 30 | k = ulong 65536 |
| 31 | end |
| 32 | if not alread k |
| 33 | ret false |
| 34 | end |
| 35 | for i ulong k |
| 36 | arinput add pos i get alchunk i |
| 37 | end |
| 38 | pos = add pos k |
| 39 | n = sub n k |
| 40 | end |
| 41 | ret true |
| 42 | end |
| 43 | fn main to int |
| 44 | if not alread 1 |
| 45 | ret 1 |
| 46 | end |
| 47 | mode = get alchunk 0 |
| 48 | if gt mode 3 |
| 49 | ret 1 |
| 50 | end |
| 51 | put arcfg 0 2 |
| 52 | put arcfg 1 40 |
| 53 | put arcfg 2 268435456 |
| 54 | put arcfg 3 8192 |
| 55 | put arcfg 6 61440 |
| 56 | put arcfg 7 2560 |
| 57 | for i ulong 3 |
| 58 | put arpkg i 2 |
| 59 | end |
| 60 | put arbase 0 1048576 |
| 61 | put arcap 0 ARMAX |
| 62 | if eq mode 1 |
| 63 | put arcap 0 ARLOW |
| 64 | end |
| 65 | put arslen 0 74969088 |
| 66 | put arslen 1 4096 |
| 67 | put arslen 2 212992 |
| 68 | put arslen 3 212296 |
| 69 | put arslen 4 48 |
| 70 | put arslen 5 384 |
| 71 | put arslen 6 384 |
| 72 | note Skew the input three bytes so the packed word boundary differs from the output. |
| 73 | pos = ulong 3 |
| 74 | if eq mode 3 |
| 75 | pos = ulong 0 |
| 76 | end |
| 77 | for i ulong 7 |
| 78 | put arsrc i pos |
| 79 | if not alspan pos get arslen i |
| 80 | ret 2 |
| 81 | end |
| 82 | pos = add pos get arslen i |
| 83 | end |
| 84 | if ne read 0 alchunk 0 1 0 |
| 85 | ret 2 |
| 86 | end |
| 87 | if eq mode 2 |
| 88 | for page ulong 16384 |
| 89 | put aroword mul page 512 not ulong 0 |
| 90 | end |
| 91 | end |
| 92 | rc = arbuild |
| 93 | if ne rc 0 |
| 94 | if eq rc -3 |
| 95 | ret 3 |
| 96 | end |
| 97 | ret 4 |
| 98 | end |
| 99 | used = get arused 0 |
| 100 | h = mapnew -1 0 used 3 33 |
| 101 | if lt h 0 |
| 102 | ret 5 |
| 103 | end |
| 104 | if not arstdata h used |
| 105 | ret 6 |
| 106 | end |
| 107 | o = ulong 0 |
| 108 | while lt o used bound 2048 |
| 109 | k = sub used o |
| 110 | if gt k 65536 |
| 111 | k = ulong 65536 |
| 112 | end |
| 113 | if ne mapread h o alchunk 0 k long k |
| 114 | ret 7 |
| 115 | end |
| 116 | if not alwrite k |
| 117 | ret 8 |
| 118 | end |
| 119 | o = add o k |
| 120 | end |
| 121 | if ne mapdrop h 0 |
| 122 | ret 9 |
| 123 | end |
| 124 | for i ulong get arclen 0 |
| 125 | put alchunk i get arcot i |
| 126 | end |
| 127 | if not alwrite get arclen 0 |
| 128 | ret 8 |
| 129 | end |
| 130 | ret 0 |
| 131 | end |