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 / aienux / tools / hwgates / hwgates.om
| 1 | note hwgates.om: hardware-gate register check (DRA-19). Seeded Omega, built with the compiler named in |
| 2 | note PIN at the repository root (the newest omega-mv build when this tool last moved). |
| 3 | note usage: hwgates REGISTER ROOT. REGISTER is a tab-separated file with 7 fields per row: |
| 4 | note id component source tier status receipt owner |
| 5 | note tier is HOST, QEMU or PHYSICAL. status is PASS, FAIL, NOT_RUN, BLOCKED_HARDWARE, |
| 6 | note BLOCKED_OPERATOR or MISSING_IMPLEMENTATION. Blank lines and lines starting with # are skipped. |
| 7 | note Rules, each failure prints one line HWGATES FAIL line=N rule=RK: |
| 8 | note R1 exactly 7 non-empty fields |
| 9 | note R2 tier and status are in the vocabulary |
| 10 | note R3 PASS or FAIL needs a receipt file under ROOT that holds the exact line |
| 11 | note HWGATE <id> <tier> <status> (no claim without a receipt) |
| 12 | note R4 a status that is not an observation (NOT_RUN, BLOCKED_*, MISSING_IMPLEMENTATION) has receipt - |
| 13 | note R5 every gate id has exactly one PHYSICAL row (physical rows stay explicit) |
| 14 | note R6 no id appears twice with the same tier |
| 15 | note R7 a receipt path starts with evidence/ and holds no .. and no leading / |
| 16 | note R8 the register has at least one row |
| 17 | note R9 every gate id named by a HWGATE line of a cited receipt has rows in the register, so a whole |
| 18 | note gate cannot leave the register while its receipt still names it |
| 19 | note Exit 0 and HWGATES PASS when no rule fails; exit 1 and HWGATES FAIL otherwise; exit 2 on usage, |
| 20 | note an unreadable register, or a register larger than the checker's tables (CAP bytes, MAXR rows): |
| 21 | note that refusal names its table, and tools/hwgates/gate.sh alarms before the register gets there. |
| 22 | note Every byte loop is bounded: each pass consumes one byte of a buffer of at most CAP bytes. |
| 23 | note CAP and MAXR exist only because omc has no runtime-sized allocation: every global is a |
| 24 | note fixed-size table (no heap by design, omega-mv docs/ROADMAP-1.0.md item 10, Decision 24). |
| 25 | note If omc gains input-sized buffers, size these from the register and receipt lengths and drop |
| 26 | note both constants; until then gate.sh's alarm at three quarters of each is the guard. |
| 27 | |
| 28 | text vocab "HOST\nQEMU\nPHYSICAL\n#PASS\nFAIL\nNOT_RUN\nBLOCKED_HARDWARE\nBLOCKED_OPERATOR\nMISSING_IMPLEMENTATION\n#" |
| 29 | text hwtag "HWGATE " |
| 30 | text evpre "evidence/" |
| 31 | text mfail "HWGATES FAIL line=" |
| 32 | text mrule " rule=R" |
| 33 | text mpass "HWGATES PASS rows=" |
| 34 | text mgates " gates=" |
| 35 | text mphys " physical=" |
| 36 | text mppass " physical_pass=" |
| 37 | text mnrun " physical_not_pass=" |
| 38 | text mfails "HWGATES FAIL failures=" |
| 39 | text mrows " rows=" |
| 40 | text musage "usage: hwgates REGISTER ROOT\n" |
| 41 | text mread "HWGATES ERROR cannot read register or it is larger than CAP bytes\n" |
| 42 | text msize "HWGATES ERROR register has more rows than the row table holds (MAXR)\n" |
| 43 | text nl "\n" |
| 44 | |
| 45 | const CAP ulong 524288 |
| 46 | const MAXR ulong 1024 |
| 47 | |
| 48 | global rb uchar 524288 |
| 49 | global eb uchar 524288 |
| 50 | global pb uchar 4096 |
| 51 | global ab uchar 4096 |
| 52 | global nb uchar 1024 |
| 53 | global fs ulong 8 |
| 54 | global fl ulong 8 |
| 55 | global rid ulong 1024 |
| 56 | global ril ulong 1024 |
| 57 | global rti long 1024 |
| 58 | global rst long 1024 |
| 59 | global rln ulong 1024 |
| 60 | global rrs ulong 1024 |
| 61 | global rrl ulong 1024 |
| 62 | global cnt ulong 8 |
| 63 | |
| 64 | note cnt: 0 rows, 1 failures, 2 register length, 3 root length, 4 physical rows, 5 physical PASS |
| 65 | |
| 66 | fn pnum v ulong to void |
| 67 | b = new uchar 24 0 |
| 68 | i = ulong 24 |
| 69 | x = v |
| 70 | c = true |
| 71 | while c bound 24 |
| 72 | i = sub i 1 |
| 73 | put b i uchar add 48 rem x 10 |
| 74 | x = div x 10 |
| 75 | if eq x 0 |
| 76 | c = false |
| 77 | end |
| 78 | end |
| 79 | k = write 1 b i sub 24 i |
| 80 | end |
| 81 | |
| 82 | fn fail ln ulong rule ulong to void |
| 83 | k = write 1 mfail 0 len mfail |
| 84 | pnum ln |
| 85 | k = write 1 mrule 0 len mrule |
| 86 | pnum rule |
| 87 | k = write 1 nl 0 len nl |
| 88 | put cnt 1 add get cnt 1 1 |
| 89 | end |
| 90 | |
| 91 | note read the file named by pb[0..n) into rb; returns its length, or -1 |
| 92 | fn rdreg n ulong to long |
| 93 | fd = fopen pb 0 n 0 0 |
| 94 | if lt fd 0 |
| 95 | ret -1 |
| 96 | end |
| 97 | tot = ulong 0 |
| 98 | c = true |
| 99 | while c bound 524289 |
| 100 | k = read int fd rb tot sub CAP tot |
| 101 | if lt k 0 |
| 102 | c = false |
| 103 | tot = CAP |
| 104 | else |
| 105 | if eq k 0 |
| 106 | c = false |
| 107 | else |
| 108 | tot = add tot ulong k |
| 109 | if ge tot CAP |
| 110 | c = false |
| 111 | end |
| 112 | end |
| 113 | end |
| 114 | end |
| 115 | r = fclose int fd |
| 116 | if ge tot CAP |
| 117 | ret -1 |
| 118 | end |
| 119 | ret long tot |
| 120 | end |
| 121 | |
| 122 | note same for eb (a receipt) |
| 123 | fn rdrec n ulong to long |
| 124 | fd = fopen pb 0 n 0 0 |
| 125 | if lt fd 0 |
| 126 | ret -1 |
| 127 | end |
| 128 | tot = ulong 0 |
| 129 | c = true |
| 130 | while c bound 524289 |
| 131 | k = read int fd eb tot sub CAP tot |
| 132 | if lt k 0 |
| 133 | c = false |
| 134 | tot = CAP |
| 135 | else |
| 136 | if eq k 0 |
| 137 | c = false |
| 138 | else |
| 139 | tot = add tot ulong k |
| 140 | if ge tot CAP |
| 141 | c = false |
| 142 | end |
| 143 | end |
| 144 | end |
| 145 | end |
| 146 | r = fclose int fd |
| 147 | if ge tot CAP |
| 148 | ret -1 |
| 149 | end |
| 150 | ret long tot |
| 151 | end |
| 152 | |
| 153 | note rb[a..a+l) equals rb[b..b+l) |
| 154 | fn eqrb a ulong b ulong l ulong to bool |
| 155 | i = ulong 0 |
| 156 | while lt i l bound 524289 |
| 157 | if ne get rb add a i get rb add b i |
| 158 | ret false |
| 159 | end |
| 160 | i = add i 1 |
| 161 | end |
| 162 | ret true |
| 163 | end |
| 164 | |
| 165 | note index of rb[s..s+l) inside vocabulary group g, or -1 |
| 166 | fn vidx s ulong l ulong g ulong to long |
| 167 | grp = ulong 0 |
| 168 | e = long 0 |
| 169 | es = ulong 0 |
| 170 | i = ulong 0 |
| 171 | n = len vocab |
| 172 | while lt i n bound 4096 |
| 173 | ch = get vocab i |
| 174 | if eq ch uchar 35 |
| 175 | grp = add grp 1 |
| 176 | e = long 0 |
| 177 | es = add i 1 |
| 178 | else |
| 179 | if eq ch uchar 10 |
| 180 | if eq grp g |
| 181 | if eq sub i es l |
| 182 | hit = vmatch s es l |
| 183 | if hit |
| 184 | ret e |
| 185 | end |
| 186 | end |
| 187 | end |
| 188 | e = add e 1 |
| 189 | es = add i 1 |
| 190 | end |
| 191 | end |
| 192 | i = add i 1 |
| 193 | end |
| 194 | ret -1 |
| 195 | end |
| 196 | |
| 197 | fn vmatch s ulong es ulong l ulong to bool |
| 198 | j = ulong 0 |
| 199 | while lt j l bound 4096 |
| 200 | if ne get rb add s j get vocab add es j |
| 201 | ret false |
| 202 | end |
| 203 | j = add j 1 |
| 204 | end |
| 205 | ret true |
| 206 | end |
| 207 | |
| 208 | note field k is exactly "-" |
| 209 | fn isdash k ulong to bool |
| 210 | if ne get fl k 1 |
| 211 | ret false |
| 212 | end |
| 213 | ret eq get rb get fs k uchar 45 |
| 214 | end |
| 215 | |
| 216 | note R7: receipt field 5 starts with evidence/, has no .., no leading / |
| 217 | fn rpath to bool |
| 218 | s = get fs 5 |
| 219 | l = get fl 5 |
| 220 | p = len evpre |
| 221 | if lt l add p 1 |
| 222 | ret false |
| 223 | end |
| 224 | i = ulong 0 |
| 225 | while lt i p bound 16 |
| 226 | if ne get rb add s i get evpre i |
| 227 | ret false |
| 228 | end |
| 229 | i = add i 1 |
| 230 | end |
| 231 | i = ulong 0 |
| 232 | while lt add i 1 l bound 4096 |
| 233 | if eq get rb add s i uchar 46 |
| 234 | if eq get rb add s add i 1 uchar 46 |
| 235 | ret false |
| 236 | end |
| 237 | end |
| 238 | i = add i 1 |
| 239 | end |
| 240 | ret true |
| 241 | end |
| 242 | |
| 243 | note build ROOT/receipt into pb; returns its length (0 when too long) |
| 244 | fn mkpath to ulong |
| 245 | al = get cnt 3 |
| 246 | s = get fs 5 |
| 247 | l = get fl 5 |
| 248 | if ge add add al l 1 4096 |
| 249 | ret 0 |
| 250 | end |
| 251 | i = ulong 0 |
| 252 | while lt i al bound 4096 |
| 253 | put pb i get ab i |
| 254 | i = add i 1 |
| 255 | end |
| 256 | put pb al uchar 47 |
| 257 | j = ulong 0 |
| 258 | while lt j l bound 4096 |
| 259 | put pb add add al 1 j get rb add s j |
| 260 | j = add j 1 |
| 261 | end |
| 262 | ret add add al 1 l |
| 263 | end |
| 264 | |
| 265 | note copy rb[s..s+l) into nb at o; returns new offset |
| 266 | fn ncopy o ulong s ulong l ulong to ulong |
| 267 | i = ulong 0 |
| 268 | while lt i l bound 1024 |
| 269 | put nb add o i get rb add s i |
| 270 | i = add i 1 |
| 271 | end |
| 272 | ret add o l |
| 273 | end |
| 274 | |
| 275 | note build HWGATE <id> <tier> <status> into nb; returns its length (0 when too long) |
| 276 | fn mkneed to ulong |
| 277 | t = add add add get fl 0 get fl 3 get fl 4 10 |
| 278 | if ge t 1024 |
| 279 | ret 0 |
| 280 | end |
| 281 | i = ulong 0 |
| 282 | p = len hwtag |
| 283 | while lt i p bound 16 |
| 284 | put nb i get hwtag i |
| 285 | i = add i 1 |
| 286 | end |
| 287 | o = ncopy p get fs 0 get fl 0 |
| 288 | put nb o uchar 32 |
| 289 | o = ncopy add o 1 get fs 3 get fl 3 |
| 290 | put nb o uchar 32 |
| 291 | o = ncopy add o 1 get fs 4 get fl 4 |
| 292 | ret o |
| 293 | end |
| 294 | |
| 295 | note eb[ls..ls+n) equals nb[0..n) |
| 296 | fn eqneed ls ulong n ulong to bool |
| 297 | i = ulong 0 |
| 298 | while lt i n bound 1024 |
| 299 | if ne get eb add ls i get nb i |
| 300 | ret false |
| 301 | end |
| 302 | i = add i 1 |
| 303 | end |
| 304 | ret true |
| 305 | end |
| 306 | |
| 307 | note the receipt eb[0..el) holds nb[0..n) as a whole line |
| 308 | fn hasline el ulong n ulong to bool |
| 309 | ls = ulong 0 |
| 310 | i = ulong 0 |
| 311 | while le i el bound 524290 |
| 312 | eol = true |
| 313 | if lt i el |
| 314 | eol = eq get eb i uchar 10 |
| 315 | end |
| 316 | if eol |
| 317 | if eq sub i ls n |
| 318 | ok = eqneed ls n |
| 319 | if ok |
| 320 | ret true |
| 321 | end |
| 322 | end |
| 323 | ls = add i 1 |
| 324 | end |
| 325 | i = add i 1 |
| 326 | end |
| 327 | ret false |
| 328 | end |
| 329 | |
| 330 | note R3 for the current row; returns true when the receipt supports the claim |
| 331 | fn receipt ln ulong to bool |
| 332 | okp = rpath |
| 333 | if eq okp false |
| 334 | fail ln 7 |
| 335 | ret false |
| 336 | end |
| 337 | pl = mkpath |
| 338 | if eq pl 0 |
| 339 | fail ln 7 |
| 340 | ret false |
| 341 | end |
| 342 | el = rdrec pl |
| 343 | if lt el 0 |
| 344 | fail ln 3 |
| 345 | ret false |
| 346 | end |
| 347 | n = mkneed |
| 348 | if eq n 0 |
| 349 | fail ln 3 |
| 350 | ret false |
| 351 | end |
| 352 | ok = hasline ulong el n |
| 353 | if eq ok false |
| 354 | fail ln 3 |
| 355 | ret false |
| 356 | end |
| 357 | ret true |
| 358 | end |
| 359 | |
| 360 | note split rb[s..e) on tabs into fs/fl; returns the field count (8 means more than 7) |
| 361 | fn split s ulong e ulong to ulong |
| 362 | k = ulong 0 |
| 363 | fst = s |
| 364 | i = s |
| 365 | while le i e bound 524290 |
| 366 | endf = true |
| 367 | if lt i e |
| 368 | endf = eq get rb i uchar 9 |
| 369 | end |
| 370 | if endf |
| 371 | if lt k 7 |
| 372 | put fs k fst |
| 373 | put fl k sub i fst |
| 374 | end |
| 375 | k = add k 1 |
| 376 | fst = add i 1 |
| 377 | end |
| 378 | i = add i 1 |
| 379 | end |
| 380 | if gt k 7 |
| 381 | ret 8 |
| 382 | end |
| 383 | ret k |
| 384 | end |
| 385 | |
| 386 | note check one non-comment line; ln is its 1-based line number |
| 387 | fn row s ulong e ulong ln ulong to void |
| 388 | k = split s e |
| 389 | if ne k 7 |
| 390 | fail ln 1 |
| 391 | ret |
| 392 | end |
| 393 | f = ulong 0 |
| 394 | while lt f 7 bound 8 |
| 395 | if eq get fl f 0 |
| 396 | fail ln 1 |
| 397 | ret |
| 398 | end |
| 399 | f = add f 1 |
| 400 | end |
| 401 | ti = vidx get fs 3 get fl 3 0 |
| 402 | si = vidx get fs 4 get fl 4 1 |
| 403 | if lt ti 0 |
| 404 | fail ln 2 |
| 405 | ret |
| 406 | end |
| 407 | if lt si 0 |
| 408 | fail ln 2 |
| 409 | ret |
| 410 | end |
| 411 | r = get cnt 0 |
| 412 | if ge r MAXR |
| 413 | w = write 2 msize 0 len msize |
| 414 | exit 2 |
| 415 | end |
| 416 | dup = isdup r ti |
| 417 | if dup |
| 418 | fail ln 6 |
| 419 | end |
| 420 | put rid r get fs 0 |
| 421 | put ril r get fl 0 |
| 422 | put rti r ti |
| 423 | put rst r si |
| 424 | put rln r ln |
| 425 | put rrs r get fs 5 |
| 426 | put rrl r get fl 5 |
| 427 | put cnt 0 add r 1 |
| 428 | dash = isdash 5 |
| 429 | if le si 1 |
| 430 | if dash |
| 431 | fail ln 3 |
| 432 | ret |
| 433 | end |
| 434 | ok = receipt ln |
| 435 | else |
| 436 | if eq dash false |
| 437 | fail ln 4 |
| 438 | end |
| 439 | end |
| 440 | end |
| 441 | |
| 442 | note an earlier row j < r has tier ti and the id in field 0 |
| 443 | fn isdup r ulong ti long to bool |
| 444 | j = ulong 0 |
| 445 | s = get fs 0 |
| 446 | l = get fl 0 |
| 447 | while lt j r bound 1025 |
| 448 | if eq get rti j ti |
| 449 | if eq get ril j l |
| 450 | same = eqrb get rid j s l |
| 451 | if same |
| 452 | ret true |
| 453 | end |
| 454 | end |
| 455 | end |
| 456 | j = add j 1 |
| 457 | end |
| 458 | ret false |
| 459 | end |
| 460 | |
| 461 | note R5: every distinct id has exactly one PHYSICAL row; returns the number of distinct ids |
| 462 | fn pairs to ulong |
| 463 | r = get cnt 0 |
| 464 | g = ulong 0 |
| 465 | i = ulong 0 |
| 466 | while lt i r bound 1025 |
| 467 | first = true |
| 468 | j = ulong 0 |
| 469 | while lt j i bound 1025 |
| 470 | if eq get ril j get ril i |
| 471 | same = eqrb get rid j get rid i get ril i |
| 472 | if same |
| 473 | first = false |
| 474 | end |
| 475 | end |
| 476 | j = add j 1 |
| 477 | end |
| 478 | if first |
| 479 | g = add g 1 |
| 480 | np = ulong 0 |
| 481 | j = ulong 0 |
| 482 | while lt j r bound 1025 |
| 483 | if eq get rti j 2 |
| 484 | if eq get ril j get ril i |
| 485 | same = eqrb get rid j get rid i get ril i |
| 486 | if same |
| 487 | np = add np 1 |
| 488 | end |
| 489 | end |
| 490 | end |
| 491 | j = add j 1 |
| 492 | end |
| 493 | if ne np 1 |
| 494 | fail get rln i 5 |
| 495 | end |
| 496 | end |
| 497 | i = add i 1 |
| 498 | end |
| 499 | ret g |
| 500 | end |
| 501 | |
| 502 | note an earlier PASS/FAIL row i < j cites the same receipt path as row j |
| 503 | fn samerec j ulong to bool |
| 504 | i = ulong 0 |
| 505 | while lt i j bound 1025 |
| 506 | if le get rst i 1 |
| 507 | if eq get rrl i get rrl j |
| 508 | same = eqrb get rrs i get rrs j get rrl j |
| 509 | if same |
| 510 | ret true |
| 511 | end |
| 512 | end |
| 513 | end |
| 514 | i = add i 1 |
| 515 | end |
| 516 | ret false |
| 517 | end |
| 518 | |
| 519 | note rb[a..a+l) equals eb[b..b+l) |
| 520 | fn eqid a ulong b ulong l ulong to bool |
| 521 | i = ulong 0 |
| 522 | while lt i l bound 524289 |
| 523 | if ne get rb add a i get eb add b i |
| 524 | ret false |
| 525 | end |
| 526 | i = add i 1 |
| 527 | end |
| 528 | ret true |
| 529 | end |
| 530 | |
| 531 | note the gate id eb[s..s+l) has a row in the register |
| 532 | fn idknown s ulong l ulong to bool |
| 533 | r = get cnt 0 |
| 534 | j = ulong 0 |
| 535 | while lt j r bound 1025 |
| 536 | if eq get ril j l |
| 537 | same = eqid get rid j s l |
| 538 | if same |
| 539 | ret true |
| 540 | end |
| 541 | end |
| 542 | j = add j 1 |
| 543 | end |
| 544 | ret false |
| 545 | end |
| 546 | |
| 547 | note eb[ls..) starts with the HWGATE tag |
| 548 | fn eqtag ls ulong to bool |
| 549 | p = len hwtag |
| 550 | k = ulong 0 |
| 551 | while lt k p bound 16 |
| 552 | if ne get eb add ls k get hwtag k |
| 553 | ret false |
| 554 | end |
| 555 | k = add k 1 |
| 556 | end |
| 557 | ret true |
| 558 | end |
| 559 | |
| 560 | note first space in eb[s..e), or e |
| 561 | fn idend s ulong e ulong to ulong |
| 562 | i = s |
| 563 | while lt i e bound 524290 |
| 564 | if eq get eb i uchar 32 |
| 565 | ret i |
| 566 | end |
| 567 | i = add i 1 |
| 568 | end |
| 569 | ret e |
| 570 | end |
| 571 | |
| 572 | note R9 for one receipt eb[0..el): every HWGATE line names a register id; ln is the citing row |
| 573 | fn scanids el ulong ln ulong to void |
| 574 | p = len hwtag |
| 575 | ls = ulong 0 |
| 576 | i = ulong 0 |
| 577 | while le i el bound 524290 |
| 578 | eol = true |
| 579 | if lt i el |
| 580 | eol = eq get eb i uchar 10 |
| 581 | end |
| 582 | if eol |
| 583 | if gt sub i ls p |
| 584 | hit = eqtag ls |
| 585 | if hit |
| 586 | s = add ls p |
| 587 | e = idend s i |
| 588 | known = idknown s sub e s |
| 589 | if eq known false |
| 590 | fail ln 9 |
| 591 | end |
| 592 | end |
| 593 | end |
| 594 | ls = add i 1 |
| 595 | end |
| 596 | i = add i 1 |
| 597 | end |
| 598 | end |
| 599 | |
| 600 | note R9: read each distinct receipt cited by a PASS/FAIL row once and check its HWGATE ids |
| 601 | fn receiptids to void |
| 602 | r = get cnt 0 |
| 603 | j = ulong 0 |
| 604 | while lt j r bound 1025 |
| 605 | if le get rst j 1 |
| 606 | seen = samerec j |
| 607 | if eq seen false |
| 608 | put fs 5 get rrs j |
| 609 | put fl 5 get rrl j |
| 610 | okp = rpath |
| 611 | pl = ulong 0 |
| 612 | if okp |
| 613 | pl = mkpath |
| 614 | end |
| 615 | if gt pl 0 |
| 616 | el = rdrec pl |
| 617 | if ge el 0 |
| 618 | scanids ulong el get rln j |
| 619 | end |
| 620 | end |
| 621 | end |
| 622 | end |
| 623 | j = add j 1 |
| 624 | end |
| 625 | end |
| 626 | |
| 627 | fn main to int |
| 628 | if ne argcnt 3 |
| 629 | k = write 2 musage 0 len musage |
| 630 | ret 2 |
| 631 | end |
| 632 | n = argread 1 pb 0 4096 |
| 633 | if le n 0 |
| 634 | k = write 2 musage 0 len musage |
| 635 | ret 2 |
| 636 | end |
| 637 | rl = rdreg ulong n |
| 638 | if lt rl 0 |
| 639 | k = write 2 mread 0 len mread |
| 640 | ret 2 |
| 641 | end |
| 642 | put cnt 2 ulong rl |
| 643 | m = argread 2 ab 0 4096 |
| 644 | if le m 0 |
| 645 | k = write 2 musage 0 len musage |
| 646 | ret 2 |
| 647 | end |
| 648 | put cnt 3 ulong m |
| 649 | total = ulong rl |
| 650 | pos = ulong 0 |
| 651 | ln = ulong 1 |
| 652 | i = ulong 0 |
| 653 | while le i total bound 524290 |
| 654 | eol = true |
| 655 | if lt i total |
| 656 | eol = eq get rb i uchar 10 |
| 657 | end |
| 658 | if eol |
| 659 | if gt i pos |
| 660 | if ne get rb pos uchar 35 |
| 661 | row pos i ln |
| 662 | end |
| 663 | end |
| 664 | pos = add i 1 |
| 665 | ln = add ln 1 |
| 666 | end |
| 667 | i = add i 1 |
| 668 | end |
| 669 | if eq get cnt 0 0 |
| 670 | fail 0 8 |
| 671 | end |
| 672 | g = pairs |
| 673 | receiptids |
| 674 | r = get cnt 0 |
| 675 | np = ulong 0 |
| 676 | pp = ulong 0 |
| 677 | j = ulong 0 |
| 678 | while lt j r bound 1025 |
| 679 | if eq get rti j 2 |
| 680 | np = add np 1 |
| 681 | if eq get rst j 0 |
| 682 | pp = add pp 1 |
| 683 | end |
| 684 | end |
| 685 | j = add j 1 |
| 686 | end |
| 687 | if gt get cnt 1 0 |
| 688 | k = write 1 mfails 0 len mfails |
| 689 | pnum get cnt 1 |
| 690 | k = write 1 mrows 0 len mrows |
| 691 | pnum r |
| 692 | k = write 1 nl 0 len nl |
| 693 | ret 1 |
| 694 | end |
| 695 | k = write 1 mpass 0 len mpass |
| 696 | pnum r |
| 697 | k = write 1 mgates 0 len mgates |
| 698 | pnum g |
| 699 | k = write 1 mphys 0 len mphys |
| 700 | pnum np |
| 701 | k = write 1 mppass 0 len mppass |
| 702 | pnum pp |
| 703 | k = write 1 mnrun 0 len mnrun |
| 704 | pnum sub np pp |
| 705 | k = write 1 nl 0 len nl |
| 706 | ret 0 |
| 707 | end |