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 / uvms_trace.om
| 1 | note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 2 | note Test-only framed stdin driver. Header eight u64 LE: op,a,b,c,d,e,f,payload-size. |
| 3 | global stin uchar 64 |
| 4 | global stout uchar 32768 |
| 5 | global stlen ulong 1 |
| 6 | fn starg n ulong to ulong |
| 7 | v = ulong 0 |
| 8 | for j ulong 8 |
| 9 | v = or v shl ulong get stin add mul n 8 j mul j 8 |
| 10 | end |
| 11 | ret v |
| 12 | end |
| 13 | fn stword v ulong to void |
| 14 | for j ulong 8 |
| 15 | put stout get stlen 0 uchar and shr v mul j 8 255 |
| 16 | put stlen 0 add get stlen 0 1 |
| 17 | end |
| 18 | end |
| 19 | fn staction to ulong |
| 20 | op = starg 0 |
| 21 | if eq op 1 |
| 22 | ret screate |
| 23 | end |
| 24 | if eq op 2 |
| 25 | ret sdestroy |
| 26 | end |
| 27 | if eq op 3 |
| 28 | ret sadd starg 1 starg 2 starg 3 starg 4 |
| 29 | end |
| 30 | if eq op 4 |
| 31 | ret ssplit starg 1 |
| 32 | end |
| 33 | if eq op 5 |
| 34 | ret smerge starg 1 |
| 35 | end |
| 36 | if eq op 6 |
| 37 | ret sremove starg 1 starg 2 |
| 38 | end |
| 39 | if eq op 7 |
| 40 | ret fbpush |
| 41 | end |
| 42 | if eq op 8 |
| 43 | ret fbbatch |
| 44 | end |
| 45 | if eq op 9 |
| 46 | ret fbrecover |
| 47 | end |
| 48 | if eq op 10 |
| 49 | ret scnotify starg 1 |
| 50 | end |
| 51 | if eq op 11 |
| 52 | ret sidispatch starg 1 starg 2 |
| 53 | end |
| 54 | if eq op 12 |
| 55 | ret siobject starg 1 starg 2 starg 3 |
| 56 | end |
| 57 | if eq op 13 |
| 58 | for j ulong 8 |
| 59 | r = iqctake |
| 60 | if ne r 1 |
| 61 | break |
| 62 | end |
| 63 | r = iqcack iqcget 1 |
| 64 | if ne r 0 |
| 65 | ret UVFATAL |
| 66 | end |
| 67 | end |
| 68 | ret UVOK |
| 69 | end |
| 70 | if eq op 14 |
| 71 | if eq get fbget 0 get fbput 0 |
| 72 | ret UVENOENT |
| 73 | end |
| 74 | o = add mul rem get fbget 0 16 32 31 |
| 75 | put fbring o or get fbring o uchar 128 |
| 76 | ret UVOK |
| 77 | end |
| 78 | if eq op 15 |
| 79 | put iqcmode 0 starg 1 |
| 80 | put iqcstate 0 starg 2 |
| 81 | ret UVOK |
| 82 | end |
| 83 | if eq op 16 |
| 84 | r = iqcommand 1 add get iqcseq 0 1 0 0 0 |
| 85 | if ne r 0 |
| 86 | ret UVEINVAL |
| 87 | end |
| 88 | ret UVOK |
| 89 | end |
| 90 | ret UVEINVAL |
| 91 | end |
| 92 | fn stsnapshot status ulong to void |
| 93 | put stlen 0 0 |
| 94 | stword status |
| 95 | stword get slive 0 |
| 96 | stword get sn 0 |
| 97 | stword get sen 0 |
| 98 | stword get fbget 0 |
| 99 | stword get fbput 0 |
| 100 | stword get fbov 0 |
| 101 | stword get siolen 0 |
| 102 | for j ulong mul get sn 0 8 |
| 103 | stword get sr j |
| 104 | end |
| 105 | for j ulong mul get sen 0 6 |
| 106 | stword get sev j |
| 107 | end |
| 108 | stword get iqcmode 0 |
| 109 | stword get iqcstate 0 |
| 110 | stword get iqcseq 0 |
| 111 | stword get iqcprod 0 |
| 112 | stword get iqccons 0 |
| 113 | stword get sqbad 0 |
| 114 | for j ulong 320 |
| 115 | put stout get stlen 0 get iqcmd j |
| 116 | put stlen 0 add get stlen 0 1 |
| 117 | end |
| 118 | for j ulong 512 |
| 119 | put stout get stlen 0 get fbring j |
| 120 | put stlen 0 add get stlen 0 1 |
| 121 | end |
| 122 | for j ulong 384 |
| 123 | stword get spage j |
| 124 | end |
| 125 | stword get scva 0 |
| 126 | stword get scval 0 |
| 127 | stword get sctyp 0 |
| 128 | stword get sctag 0 |
| 129 | for j ulong get siolen 0 |
| 130 | put stout get stlen 0 get siob j |
| 131 | put stlen 0 add get stlen 0 1 |
| 132 | end |
| 133 | end |
| 134 | fn strequest to long |
| 135 | off = ulong 0 |
| 136 | while lt off 64 bound 64 |
| 137 | r = read 0 stin off sub 64 off |
| 138 | if lt r 0 |
| 139 | ret -1 |
| 140 | end |
| 141 | if eq r 0 |
| 142 | if eq off 0 |
| 143 | ret 0 |
| 144 | end |
| 145 | ret -1 |
| 146 | end |
| 147 | off = add off ulong r |
| 148 | end |
| 149 | size = starg 7 |
| 150 | if gt size 9264 |
| 151 | ret -1 |
| 152 | end |
| 153 | off = 0 |
| 154 | while lt off size bound 9264 |
| 155 | r = read 0 siab off sub size off |
| 156 | if le r 0 |
| 157 | ret -1 |
| 158 | end |
| 159 | off = add off ulong r |
| 160 | end |
| 161 | for j ulong 32 |
| 162 | put uvpkt j get siab j |
| 163 | end |
| 164 | put sen 0 0 |
| 165 | put siolen 0 0 |
| 166 | r2 = staction |
| 167 | stsnapshot r2 |
| 168 | off = 0 |
| 169 | while lt off get stlen 0 bound 32768 |
| 170 | w = write 1 stout off sub get stlen 0 off |
| 171 | if le w 0 |
| 172 | ret -1 |
| 173 | end |
| 174 | off = add off ulong w |
| 175 | end |
| 176 | ret 1 |
| 177 | end |
| 178 | fn main to int |
| 179 | put iqcmode 0 1 |
| 180 | put iqcstate 0 1 |
| 181 | for j ulong 100000 |
| 182 | r = strequest |
| 183 | if lt r 0 |
| 184 | ret 70 |
| 185 | end |
| 186 | if eq r 0 |
| 187 | ret 0 |
| 188 | end |
| 189 | end |
| 190 | ret 71 |
| 191 | end |