omega-mcp
aien-dev/omega-mcp
Brought by drakestapleton
omega-mcp / data / examples / vfio.om
| 1 | note VFIO words with fd -1, so no device is opened: the ioctl and both region mappings return -9 (EBADF); |
| 2 | note an eventfd holds a counter that read returns as eight little-endian bytes |
| 3 | global buf uchar 8 |
| 4 | global ri uchar 32 |
| 5 | fn ck yes bool to void |
| 6 | if not yes |
| 7 | exit 80 |
| 8 | end |
| 9 | end |
| 10 | fn main to int |
| 11 | ck eq vfioctl neg int 1 uint 15204 buf 0 0 neg long 9 |
| 12 | put ri 4 5 |
| 13 | put ri 16 16 |
| 14 | ck eq vfiomap neg int 1 ri 0 32 neg long 9 |
| 15 | put ri 4 7 |
| 16 | ck eq vfiomapw neg int 1 ri 0 32 neg long 9 |
| 17 | e = int eventfd uint 3 |
| 18 | ck ge e 0 |
| 19 | ck eq read e buf 0 8 8 |
| 20 | ck eq get buf 0 3 |
| 21 | ck eq fclose e 0 |
| 22 | ret 0 |
| 23 | end |