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 / seed / host / tests / devcall.om
| 1 | note Parameter binding checks use invalid descriptors, never a GPU device. |
| 2 | global header uchar 48 |
| 3 | global params uchar 32 |
| 4 | note The parameter pool is image-backed, not a per-call stack allocation. |
| 5 | global large uchar 1048577 |
| 6 | global status uchar 4 |
| 7 | text msg "PASS native device parameter binding\n" |
| 8 | fn ck yes bool to void |
| 9 | if not yes |
| 10 | exit int 80 |
| 11 | end |
| 12 | end |
| 13 | fn fault k int to int |
| 14 | if eq k 0 |
| 15 | r = devcall neg int 1 uint 3223340587 header 0 31 params 0 0 |
| 16 | ret int r |
| 17 | end |
| 18 | if eq k 1 |
| 19 | r = devcall neg int 1 uint 3223340587 header 17 32 params 0 0 |
| 20 | ret int r |
| 21 | end |
| 22 | if eq k 2 |
| 23 | r = devcall neg int 1 uint 3223340587 header 0 32 params 31 2 |
| 24 | ret int r |
| 25 | end |
| 26 | if eq k 3 |
| 27 | put header 16 1 |
| 28 | r = devcall neg int 1 uint 3223340587 header 0 32 params 0 1 |
| 29 | ret int r |
| 30 | end |
| 31 | if eq k 4 |
| 32 | r = devcall neg int 1 uint 3223340587 header 0 32 large 0 1048577 |
| 33 | ret int r |
| 34 | end |
| 35 | if eq k 6 |
| 36 | r = devcall neg int 1 uint 3223340587 header 0 32 large 2 1048576 |
| 37 | ret int r |
| 38 | end |
| 39 | r = devcall neg int 1 uint 3223340587 header 0 32 params 18446744073709551615 1 |
| 40 | ret int r |
| 41 | end |
| 42 | fn main to int |
| 43 | for i ulong 48 |
| 44 | put header i 171 |
| 45 | end |
| 46 | for i ulong 8 |
| 47 | put header add i 24 0 |
| 48 | end |
| 49 | for n ulong 33 |
| 50 | ck eq devcall neg int 1 uint 3223340587 header 8 32 params 0 n neg long 9 |
| 51 | for i ulong 48 |
| 52 | if and ge i 24 lt i 32 |
| 53 | ck eq get header i 0 |
| 54 | else |
| 55 | if eq i 32 |
| 56 | ck eq get header i uchar n |
| 57 | else |
| 58 | if and gt i 32 lt i 36 |
| 59 | ck eq get header i 0 |
| 60 | else |
| 61 | ck eq get header i 171 |
| 62 | end |
| 63 | end |
| 64 | end |
| 65 | end |
| 66 | end |
| 67 | ck eq add devcall neg int 1 uint 3223340586 header 8 32 params 4 12 10 1 |
| 68 | for i ulong 48 |
| 69 | put header i 0 |
| 70 | end |
| 71 | ck eq devcall neg int 1 uint 3223340587 header 0 32 large 1 16383 neg long 9 |
| 72 | note Harmless memfd ioctls must reach Linux and return ENOTTY, not trap. |
| 73 | fd = memfd msg 0 len msg 0 |
| 74 | ck ge fd 0 |
| 75 | ck eq devcall int fd uint 3223340587 header 0 32 large 0 16384 neg long 25 |
| 76 | ck eq devcall int fd uint 3223340587 header 0 32 large 0 32 neg long 25 |
| 77 | ck eq devcall int fd uint 3223340587 header 0 32 large 0 55888 neg long 25 |
| 78 | ck eq devcall int fd uint 3223340587 header 0 32 large 1 1048576 neg long 25 |
| 79 | ck eq devcall int fd uint 3223340586 header 0 32 large 0 1048576 neg long 25 |
| 80 | ck eq fclose int fd 0 |
| 81 | for k int 7 |
| 82 | p = fork |
| 83 | ck ge p 0 |
| 84 | if eq p 0 |
| 85 | exit fault k |
| 86 | end |
| 87 | ck eq waitpid int p status 0 4 0 p |
| 88 | ck eq get status 0 0 |
| 89 | ck eq get status 1 103 |
| 90 | end |
| 91 | ck eq write 1 msg 0 len msg long len msg |
| 92 | ret 0 |
| 93 | end |