RPMsg inter-partition messaging
at main 47 lines 1.9 kB view raw view rendered
1# rpmsg 2 3OCaml bindings to the Linux RPMsg character device interface for inter-partition messaging. 4 5RPMsg (Remote Processor Messaging) provides message-based IPC between 6partitions on asymmetric multiprocessing platforms. This library wraps the 7`/dev/rpmsg_ctrl*` and `/dev/rpmsg*` character devices, encoding the 8`rpmsg_endpoint_info` struct via Wire codecs instead of manual C struct packing. 9It is used for communication between the Linux host and co-processor partitions 10via virtio vrings on Jailhouse, Xen, and Zynq UltraScale+ platforms. 11 12Endpoint IO is built on Eio flows, so it integrates directly with the Eio 13event loop. 14 15## Installation 16 17``` 18opam install rpmsg 19``` 20 21## Usage 22 23```ocaml 24(* Create an endpoint and exchange messages *) 25let () = 26 let ctrl = Rpmsg.Ctrl.open_ () in 27 let idx = Rpmsg.Ctrl.create_endpoint ctrl ~name:"my-ep" ~src:1024 ~dst:1025 in 28 let fd = Rpmsg.Endpoint.open_ idx in 29 (* wrap the fd with Eio flows, then: *) 30 (* let ep = Rpmsg.Endpoint.of_source_sink ~source ~sink in *) 31 (* Rpmsg.Endpoint.send ep "hello"; *) 32 Unix.close fd; 33 Rpmsg.Ctrl.close ctrl 34``` 35 36## API 37 38- `Rpmsg.endpoint_info` -- The `rpmsg_endpoint_info` record type matching the Linux kernel struct: a 32-byte name, 32-bit source address, and 32-bit destination address. 39- `Rpmsg.endpoint_info_codec` -- Wire codec for serializing and deserializing the endpoint info struct (40 bytes). 40- `Rpmsg.Ctrl` -- Control device handle (`/dev/rpmsg_ctrl*`). Create and destroy RPMsg endpoints via ioctl. 41- `Rpmsg.Endpoint` -- Message endpoint backed by Eio flows. Send and receive messages up to 496 bytes (512 minus the 16-byte virtio header). 42 43## References 44 45- [Linux RPMsg documentation](https://docs.kernel.org/staging/rpmsg.html) 46- [Jailhouse hypervisor](https://github.com/siemens/jailhouse) 47- [Xilinx OpenAMP / RPMsg on Zynq UltraScale+](https://xilinx-wiki.atlassian.net/wiki/spaces/A/pages/18842073/OpenAMP)