| 1 | (* |
| 2 | * Copyright (C) 2006-2007 XenSource Ltd. |
| 3 | * Copyright (C) 2008 Citrix Ltd. |
| 4 | * Author Vincent Hanquez <[email protected]> |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU Lesser General Public License as published |
| 8 | * by the Free Software Foundation; version 2.1 only. with the special |
| 9 | * exception on linking described in file LICENSE. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU Lesser General Public License for more details. |
| 15 | *) |
| 16 | |
| 17 | type handle |
| 18 | |
| 19 | external _init: bool -> handle = "stub_eventchn_init" |
| 20 | |
| 21 | let init ?(cloexec=true) () = _init cloexec |
| 22 | |
| 23 | external fdopen: Unix.file_descr -> handle = "stub_eventchn_fdopen" |
| 24 | external fd: handle -> Unix.file_descr = "stub_eventchn_fd" |
| 25 | |
| 26 | type t = int |
| 27 | |
| 28 | type virq_t = |
| 29 | | Timer (* #define VIRQ_TIMER 0 *) |
| 30 | | Debug (* #define VIRQ_DEBUG 1 *) |
| 31 | | Console (* #define VIRQ_CONSOLE 2 *) |
| 32 | | Dom_exc (* #define VIRQ_DOM_EXC 3 *) |
| 33 | | Tbuf (* #define VIRQ_TBUF 4 *) |
| 34 | | Reserved_5 (* Do not use this value as it's not defined *) |
| 35 | | Debugger (* #define VIRQ_DEBUGGER 6 *) |
| 36 | | Xenoprof (* #define VIRQ_XENOPROF 7 *) |
| 37 | | Con_ring (* #define VIRQ_CON_RING 8 *) |
| 38 | | Pcpu_state (* #define VIRQ_PCPU_STATE 9 *) |
| 39 | | Mem_event (* #define VIRQ_MEM_EVENT 10 *) |
| 40 | | Xc_reserved (* #define VIRQ_XC_RESERVED 11 *) |
| 41 | | Enomem (* #define VIRQ_ENOMEM 12 *) |
| 42 | | Xenpmu (* #define VIRQ_XENPMU 13 *) |
| 43 | |
| 44 | external notify: handle -> int -> unit = "stub_eventchn_notify" |
| 45 | external bind_interdomain: handle -> int -> int -> int = "stub_eventchn_bind_interdomain" |
| 46 | external bind_virq: handle -> virq_t -> int = "stub_eventchn_bind_virq" |
| 47 | let bind_dom_exc_virq handle = bind_virq handle Dom_exc |
| 48 | external unbind: handle -> int -> unit = "stub_eventchn_unbind" |
| 49 | external pending: handle -> int = "stub_eventchn_pending" |
| 50 | external unmask: handle -> int -> unit = "stub_eventchn_unmask" |
| 51 | |
| 52 | let to_int x = x |
| 53 | let of_int x = x |