rpmsg#
OCaml bindings to the Linux RPMsg character device interface for inter-partition messaging.
RPMsg (Remote Processor Messaging) provides message-based IPC between
partitions on asymmetric multiprocessing platforms. This library wraps the
/dev/rpmsg_ctrl* and /dev/rpmsg* character devices, encoding the
rpmsg_endpoint_info struct via Wire codecs instead of manual C struct packing.
It is used for communication between the Linux host and co-processor partitions
via virtio vrings on Jailhouse, Xen, and Zynq UltraScale+ platforms.
Endpoint IO is built on Eio flows, so it integrates directly with the Eio event loop.
Installation#
opam install rpmsg
Usage#
(* Create an endpoint and exchange messages *)
let () =
let ctrl = Rpmsg.Ctrl.open_ () in
let idx = Rpmsg.Ctrl.create_endpoint ctrl ~name:"my-ep" ~src:1024 ~dst:1025 in
let fd = Rpmsg.Endpoint.open_ idx in
(* wrap the fd with Eio flows, then: *)
(* let ep = Rpmsg.Endpoint.of_source_sink ~source ~sink in *)
(* Rpmsg.Endpoint.send ep "hello"; *)
Unix.close fd;
Rpmsg.Ctrl.close ctrl
API#
Rpmsg.endpoint_info-- Therpmsg_endpoint_inforecord type matching the Linux kernel struct: a 32-byte name, 32-bit source address, and 32-bit destination address.Rpmsg.endpoint_info_codec-- Wire codec for serializing and deserializing the endpoint info struct (40 bytes).Rpmsg.Ctrl-- Control device handle (/dev/rpmsg_ctrl*). Create and destroy RPMsg endpoints via ioctl.Rpmsg.Endpoint-- Message endpoint backed by Eio flows. Send and receive messages up to 496 bytes (512 minus the 16-byte virtio header).