aienux
Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately.
Brought by drakestapleton
aienux / native / omega / allen / tests / provider-process.om
| 1 | note Native assertions over host-collected process receipts. |
| 2 | note Four decimal lines: mode, exit, stdout bytes, stderr bytes; then stdout+stderr. |
| 3 | global Procbuf uchar 65536 |
| 4 | global Procnum ulong 4 |
| 5 | global Procpos ulong 1 |
| 6 | text Procmag "ALNPRV01" |
| 7 | fn pcheck ok bool to void |
| 8 | check ok add get Checks 0 1 |
| 9 | end |
| 10 | fn pnumber n ulong to bool |
| 11 | v = ulong 0 |
| 12 | digits = ulong 0 |
| 13 | while lt get Procpos 0 n |
| 14 | c = get Procbuf get Procpos 0 |
| 15 | put Procpos 0 add get Procpos 0 1 |
| 16 | if eq c 10 |
| 17 | if eq digits 0 |
| 18 | ret false |
| 19 | end |
| 20 | put Procnum 3 v |
| 21 | ret true |
| 22 | end |
| 23 | if or lt c 48 gt c 57 |
| 24 | ret false |
| 25 | end |
| 26 | if ge digits 8 |
| 27 | ret false |
| 28 | end |
| 29 | v = add mul v 10 sub ulong c 48 |
| 30 | digits = add digits 1 |
| 31 | end |
| 32 | ret false |
| 33 | end |
| 34 | fn pword off ulong to ulong |
| 35 | v = ulong 0 |
| 36 | for i ulong 8 |
| 37 | v = or v shl ulong get Procbuf add off i mul i 8 |
| 38 | end |
| 39 | ret v |
| 40 | end |
| 41 | fn pverify n ulong to int |
| 42 | for i ulong 3 |
| 43 | if not pnumber n |
| 44 | ret 65 |
| 45 | end |
| 46 | put Procnum i get Procnum 3 |
| 47 | end |
| 48 | if not pnumber n |
| 49 | ret 65 |
| 50 | end |
| 51 | mode = get Procnum 0 |
| 52 | rc = get Procnum 1 |
| 53 | size = get Procnum 2 |
| 54 | err = get Procnum 3 |
| 55 | p = get Procpos 0 |
| 56 | pcheck eq n add add p size err |
| 57 | pcheck eq err 0 |
| 58 | if le mode 6 |
| 59 | pcheck ge mode 1 |
| 60 | pcheck eq rc 65 |
| 61 | if eq mode 6 |
| 62 | pcheck eq size 40 |
| 63 | if ge sub n p 40 |
| 64 | for i ulong 8 |
| 65 | pcheck eq get Procbuf add p i get Procmag i |
| 66 | end |
| 67 | pcheck eq pword add p 8 1 |
| 68 | pcheck eq pword add p 16 1 |
| 69 | pcheck eq pword add p 24 0 |
| 70 | pcheck eq pword add p 32 0 |
| 71 | end |
| 72 | else |
| 73 | pcheck eq size 0 |
| 74 | end |
| 75 | else |
| 76 | if eq mode 7 |
| 77 | pcheck eq rc 0 |
| 78 | else |
| 79 | ret 65 |
| 80 | end |
| 81 | end |
| 82 | if ne get Fails 0 0 |
| 83 | ret 1 |
| 84 | end |
| 85 | ret 0 |
| 86 | end |
| 87 | fn main to int |
| 88 | n = ulong 0 |
| 89 | while lt n len Procbuf |
| 90 | r = read 0 Procbuf n sub len Procbuf n |
| 91 | if lt r 0 |
| 92 | ret 74 |
| 93 | end |
| 94 | if eq r 0 |
| 95 | ret pverify n |
| 96 | end |
| 97 | n = add n ulong r |
| 98 | end |
| 99 | ret 65 |
| 100 | end |