tools/ocaml: Add OCaml binding of virq bind
PATCH 1/1 tools/ocaml: Add OCaml binding of virq bind
1. Add a common bind virq function
2. Reduce the stub code of bind_dom_exc_virq
--- tools/ocaml/libs/eventchn/xeneventchn.ml | 19 ++++++++++++++++++- tools/ocaml/libs/eventchn/xeneventchn.mli | 21 +++++++++++++++++++++ tools/ocaml/libs/eventchn/xeneventchn_stubs.c | 8 ++++---- 3 files changed, 43 insertions(+), 5 deletions(-)
tools/ocaml/libs/eventchn/xeneventchn.ml +18 -1
@@ -21,9 +21,26 @@ external fd: handle -> Unix.file_descr = "stub_eventchn_fd" type t = int +type virq_t = + | Timer (* #define VIRQ_TIMER 0 *) + | Debug (* #define VIRQ_DEBUG 1 *) + | Console (* #define VIRQ_CONSOLE 2 *) + | Dom_exc (* #define VIRQ_DOM_EXC 3 *) + | Tbuf (* #define VIRQ_TBUF 4 *) + | Reserved_5 (* Do not use this value as it's not defined *) + | Debugger (* #define VIRQ_DEBUGGER 6 *) + | Xenoprof (* #define VIRQ_XENOPROF 7 *) + | Con_ring (* #define VIRQ_CON_RING 8 *) + | Pcpu_state (* #define VIRQ_PCPU_STATE 9 *) + | Mem_event (* #define VIRQ_MEM_EVENT 10 *) + | Xc_reserved (* #define VIRQ_XC_RESERVED 11 *) + | Enomem (* #define VIRQ_ENOMEM 12 *) + | Xenpmu (* #define VIRQ_XENPMU 13 *) + external notify: handle -> int -> unit = "stub_eventchn_notify" external bind_interdomain: handle -> int -> int -> int = "stub_eventchn_bind_interdomain" -external bind_dom_exc_virq: handle -> int = "stub_eventchn_bind_dom_exc_virq" +external bind_virq: handle -> virq_t -> int = "stub_eventchn_bind_virq" +let bind_dom_exc_virq handle = bind_virq handle Dom_exc external unbind: handle -> int -> unit = "stub_eventchn_unbind" external pending: handle -> int = "stub_eventchn_pending" external unmask: handle -> int -> unit = "stub_eventchn_unmask"
tools/ocaml/libs/eventchn/xeneventchn.mli +21 -0
@@ -22,6 +22,23 @@ type handle type t (** A local event channel. *) +type virq_t = + | Timer (* #define VIRQ_TIMER 0 *) + | Debug (* #define VIRQ_DEBUG 1 *) + | Console (* #define VIRQ_CONSOLE 2 *) + | Dom_exc (* #define VIRQ_DOM_EXC 3 *) + | Tbuf (* #define VIRQ_TBUF 4 *) + | Reserved_5 (* Do not use this value as it's not defined *) + | Debugger (* #define VIRQ_DEBUGGER 6 *) + | Xenoprof (* #define VIRQ_XENOPROF 7 *) + | Con_ring (* #define VIRQ_CON_RING 8 *) + | Pcpu_state (* #define VIRQ_PCPU_STATE 9 *) + | Mem_event (* #define VIRQ_MEM_EVENT 10 *) + | Xc_reserved (* #define VIRQ_XC_RESERVED 11 *) + | Enomem (* #define VIRQ_ENOMEM 12 *) + | Xenpmu (* #define VIRQ_XENPMU 13 *) + + val to_int: t -> int val of_int: int -> t
@@ -49,6 +66,10 @@ val bind_dom_exc_virq : handle -> t (domain exception VIRQ). On error it will throw a Failure exception. *) +val bind_virq: handle -> virq_t -> t +(** Binds a local event channel to the specific VIRQ type. + On error it will throw a Failure exception. *) + val unbind : handle -> t -> unit (** Unbinds the given event channel. On error it will throw a Failure exception. *)
tools/ocaml/libs/eventchn/xeneventchn_stubs.c +4 -4
@@ -90,15 +90,15 @@ CAMLprim value stub_eventchn_bind_interdomain(value xce, value domid,CAMLreturn (port); } -CAMLprim value stub_eventchn_bind_dom_exc_virq(value xce) +CAMLprim value stub_eventchn_bind_virq(value xce, value virq_type) { -CAMLparam1 (xce); +CAMLparam2 (xce, virq_type);CAMLlocal1 (port);xenevtchn_port_or_error_t rc; - rc =xenevtchn_bind_virq (_H (xce),VIRQ_DOM_EXC ); + rc =xenevtchn_bind_virq (_H (xce),Int_val (virq_type));if (rc ==-1 ) -caml_failwith ("evtchn bind_dom_exc_virq failed" ); +caml_failwith ("evtchn bind_virq failed" ); port =Val_int (rc);CAMLreturn (port);
Signature · 7 lines
2.9.5 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 4 lines · Yang Qian
1. Add a common bind virq function
2. Reduce the stub code ofbind_dom_exc_virqSigned-off-by Yang Qian <[email protected]>
CC'ing the relevant maintainers.
internal review of this patch)
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Christian Lindig
Acked-byQuoted 8 lines · Andrew Cooper
Quoted 3 lines · Yang Qian
1. Add a common bind virq function
2. Reduce the stub code ofbind_dom_exc_virq
Quoted 6 lines
Quoted 1 line
Signed-off-by Yang Qian <[email protected]>CC'ing the relevant maintainers.
Reviewed-by Andrew Cooper <[email protected]> (forwarding myinternal review of this patch)
There is a discussion about caml_{leave,enter}_blocking_section required for this to work in a thread context that is not yet addressed in the patch.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 7 lines · Christian Lindig
Quoted 7 lines · Andrew Cooper
Quoted 3 lines · Yang Qian
1. Add a common bind virq function
2. Reduce the stub code ofbind_dom_exc_virq
Quoted 6 lines
Quoted 5 lines
Quoted 1 line
Signed-off-by Yang Qian <[email protected]>CC'ing the relevant maintainers.
Reviewed-by Andrew Cooper <[email protected]> (forwarding myinternal review of this patch)
There is a discussion about caml_{leave,enter}_blocking_section required for this to work in a thread context that is not yet addressed in the patch.
Right, but that is just a performance issue is it not? We hold the GC lock longer than we need to.
i.e. AFACIT, that is a good followup patch, but doesn't invalidate this one?
~Andrew
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 17 lines · Andrew Cooper
Quoted 12 lines · Christian Lindig
Quoted 12 lines · Andrew Cooper
Quoted 4 lines · Yang Qian
1. Add a common bind virq function
2. Reduce the stub code ofbind_dom_exc_virqSigned-off-by Yang Qian <[email protected]>CC'ing the relevant maintainers.
Reviewed-by Andrew Cooper <[email protected]> (forwarding myinternal review of this patch)
Quoted 8 lines
Quoted 1 line
There is a discussion about caml_{leave,enter}_blocking_section required for this to work in a thread context that is not yet addressed in the patch.
Right, but that is just a performance issue is it not? We hold the GC lock longer than we need to.
i.e. AFACIT, that is a good followup patch, but doesn't invalidate this one?
~Andrew
You are correct. It does not invalidate this patch.
— Christian
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel