diff --git a/drivers/xen/events.c b/drivers/xen/events.c index e077b0f6cfa..a16cce8b5c5 100644 --- a/drivers/xen/events.c +++ b/drivers/xen/events.c @@ -47,6 +47,24 @@ int alloc_unbound_event_channel(domid_t remote_dom) return rc; } +#ifdef CONFIG_XEN_DOM0 +int alloc_unbound_event_channel_dom0(domid_t dom, domid_t remote_dom) +{ + int rc; + struct evtchn_alloc_unbound alloc = { + .dom = dom, + .remote_dom = remote_dom, + }; + + rc = HYPERVISOR_event_channel_op(EVTCHNOP_alloc_unbound, &alloc); + if (rc == 0) { + rc = alloc.port; + } + + return rc; +} +#endif /* CONFIG_XEN_DOM0 */ + int bind_interdomain_event_channel(domid_t remote_dom, evtchn_port_t remote_port, evtchn_cb_t cb, void *data) { diff --git a/include/zephyr/xen/events.h b/include/zephyr/xen/events.h index d2a936a59ed..cbad8162cbb 100644 --- a/include/zephyr/xen/events.h +++ b/include/zephyr/xen/events.h @@ -36,6 +36,17 @@ void notify_evtchn(evtchn_port_t port); */ int alloc_unbound_event_channel(domid_t remote_dom); +#ifdef CONFIG_XEN_DOM0 +/* + * Allocate event-channel between remote domains. Can be used only from Dom0. + * + * @param dom - first remote domain domid (may be DOMID_SELF) + * @param remote_dom - second remote domain domid + * @return - local event channel port on success, negative on error + */ +int alloc_unbound_event_channel_dom0(domid_t dom, domid_t remote_dom); +#endif /* CONFIG_XEN_DOM0 */ + /* * Allocate local event channel, binded to remote port and attach specified callback * to it