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 / tests / x86efi / file11 / t1.om
| 1 | target x86efi |
| 2 | note efi 11 with two FAT volumes: the boot stick and a second stick whose \EFI\BOOT\BOOTX64.EFI |
| 3 | note holds the 4 bytes "junk". Count the volumes, read the other volume's file (4 bytes), read |
| 4 | note this image from the boot volume, write it over the other volume's file, read it back and |
| 5 | note compare, then ask for volume 9 (error 19). One character per result: the count, the boot |
| 6 | note index, then 1 for each check that held (0 if not), then the low 6 bits of the volume 9 |
| 7 | note status + 48 (C = 19) and 1 if that status has bit 63 set. |
| 8 | global ms uchar 32 |
| 9 | global Img uchar 2097152 |
| 10 | global Back uchar 2097152 |
| 11 | |
| 12 | fn pr n ulong to void |
| 13 | r = efi 13 0 ms 0 n |
| 14 | end |
| 15 | |
| 16 | fn bit b bool to uchar |
| 17 | if b |
| 18 | ret uchar 49 |
| 19 | end |
| 20 | ret uchar 48 |
| 21 | end |
| 22 | |
| 23 | fn main to ulong |
| 24 | put ms 0 61 |
| 25 | put ms 1 61 |
| 26 | put ms 2 66 |
| 27 | put ms 3 10 |
| 28 | pr 4 |
| 29 | r = efi 11 0 Img 0 0 |
| 30 | n = and r 255 |
| 31 | boot = and shr r 8 255 |
| 32 | tgt = ulong 0 |
| 33 | if eq boot 0 |
| 34 | tgt = 1 |
| 35 | end |
| 36 | junk = efi 11 or 1 shl tgt 8 Back 0 len Back |
| 37 | rd = efi 11 or 1 shl boot 8 Img 0 len Img |
| 38 | wr = efi 11 or 2 shl tgt 8 Img 0 rd |
| 39 | rb = efi 11 or 1 shl tgt 8 Back 0 len Back |
| 40 | same = eq rb rd |
| 41 | if same |
| 42 | j = ulong 0 |
| 43 | while lt j rd |
| 44 | if ne get Img j get Back j |
| 45 | same = false |
| 46 | break |
| 47 | end |
| 48 | j = add j 1 |
| 49 | end |
| 50 | end |
| 51 | e = efi 11 ulong 2305 Back 0 len Back |
| 52 | put ms 0 uchar add 48 and n 63 |
| 53 | put ms 1 uchar add 48 and boot 63 |
| 54 | put ms 2 bit and eq shr r 63 0 eq junk 4 |
| 55 | put ms 3 bit and eq shr rd 63 0 gt rd 4096 |
| 56 | put ms 4 bit eq wr rd |
| 57 | put ms 5 bit same |
| 58 | put ms 6 uchar add 48 and e 63 |
| 59 | put ms 7 bit eq shr e 63 1 |
| 60 | put ms 8 10 |
| 61 | put ms 9 61 |
| 62 | put ms 10 61 |
| 63 | put ms 11 69 |
| 64 | put ms 12 10 |
| 65 | pr 13 |
| 66 | ret 0 |
| 67 | end |