1 /****************************************************************************** 2 * evtchn.h 3 * 4 * Data structures and definitions private to the FreeBSD implementation 5 * of the Xen event channel API. 6 * 7 * Copyright (c) 2004, K A Fraser 8 * Copyright (c) 2012, Spectra Logic Corporation 9 * 10 * This file may be distributed separately from the Linux kernel, or 11 * incorporated into other software packages, subject to the following license: 12 * 13 * Permission is hereby granted, free of charge, to any person obtaining a copy 14 * of this source file (the "Software"), to deal in the Software without 15 * restriction, including without limitation the rights to use, copy, modify, 16 * merge, publish, distribute, sublicense, and/or sell copies of the Software, 17 * and to permit persons to whom the Software is furnished to do so, subject to 18 * the following conditions: 19 * 20 * The above copyright notice and this permission notice shall be included in 21 * all copies or substantial portions of the Software. 22 * 23 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 24 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 25 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 26 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 27 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 28 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 29 * IN THE SOFTWARE. 30 * 31 * $FreeBSD$ 32 */ 33 34 #ifndef __XEN_EVTCHN_EVTCHNVAR_H__ 35 #define __XEN_EVTCHN_EVTCHNVAR_H__ 36 37 #include <xen/hypervisor.h> 38 #include <contrib/xen/event_channel.h> 39 40 enum evtchn_type { 41 EVTCHN_TYPE_UNBOUND, 42 EVTCHN_TYPE_VIRQ, 43 EVTCHN_TYPE_IPI, 44 EVTCHN_TYPE_PORT, 45 EVTCHN_TYPE_COUNT 46 }; 47 48 /** Submit a port notification for delivery to a userland evtchn consumer */ 49 void evtchn_device_upcall(evtchn_port_t port); 50 51 /** 52 * Disable signal delivery for an event channel port, returning its 53 * previous mask state. 54 * 55 * \param port The event channel port to query and mask. 56 * 57 * \returns 1 if event delivery was previously disabled. Otherwise 0. 58 */ 59 static inline int 60 evtchn_test_and_set_mask(evtchn_port_t port) 61 { 62 shared_info_t *s = HYPERVISOR_shared_info; 63 return synch_test_and_set_bit(port, s->evtchn_mask); 64 } 65 66 /** 67 * Clear any pending event for the given event channel port. 68 * 69 * \param port The event channel port to clear. 70 */ 71 static inline void 72 evtchn_clear_port(evtchn_port_t port) 73 { 74 shared_info_t *s = HYPERVISOR_shared_info; 75 synch_clear_bit(port, &s->evtchn_pending[0]); 76 } 77 78 /** 79 * Disable signal delivery for an event channel port. 80 * 81 * \param port The event channel port to mask. 82 */ 83 static inline void 84 evtchn_mask_port(evtchn_port_t port) 85 { 86 shared_info_t *s = HYPERVISOR_shared_info; 87 88 synch_set_bit(port, &s->evtchn_mask[0]); 89 } 90 91 /** 92 * Enable signal delivery for an event channel port. 93 * 94 * \param port The event channel port to enable. 95 */ 96 static inline void 97 evtchn_unmask_port(evtchn_port_t port) 98 { 99 evtchn_unmask_t op = { .port = port }; 100 101 HYPERVISOR_event_channel_op(EVTCHNOP_unmask, &op); 102 } 103 104 #endif /* __XEN_EVTCHN_EVTCHNVAR_H__ */ 105