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: releng/11.0/sys/xen/evtchn/evtchnvar.h 255040 2013-08-29 19:52:18Z gibbs $ 32 */ 33 34#ifndef __XEN_EVTCHN_EVTCHNVAR_H__ 35#define __XEN_EVTCHN_EVTCHNVAR_H__ 36 37#include <xen/hypervisor.h> 38#include <xen/interface/event_channel.h> 39 40enum evtchn_type { 41 EVTCHN_TYPE_UNBOUND, 42 EVTCHN_TYPE_PIRQ, 43 EVTCHN_TYPE_VIRQ, 44 EVTCHN_TYPE_IPI, 45 EVTCHN_TYPE_PORT, 46 EVTCHN_TYPE_COUNT 47}; 48 49/** Submit a port notification for delivery to a userland evtchn consumer */ 50void evtchn_device_upcall(evtchn_port_t port); 51 52/** 53 * Disable signal delivery for an event channel port, returning its 54 * previous mask state. 55 * 56 * \param port The event channel port to query and mask. 57 * 58 * \returns 1 if event delivery was previously disabled. Otherwise 0. 59 */ 60static inline int 61evtchn_test_and_set_mask(evtchn_port_t port) 62{ 63 shared_info_t *s = HYPERVISOR_shared_info; 64 return synch_test_and_set_bit(port, s->evtchn_mask); 65} 66 67/** 68 * Clear any pending event for the given event channel port. 69 * 70 * \param port The event channel port to clear. 71 */ 72static inline void 73evtchn_clear_port(evtchn_port_t port) 74{ 75 shared_info_t *s = HYPERVISOR_shared_info; 76 synch_clear_bit(port, &s->evtchn_pending[0]); 77} 78 79/** 80 * Disable signal delivery for an event channel port. 81 * 82 * \param port The event channel port to mask. 83 */ 84static inline void 85evtchn_mask_port(evtchn_port_t port) 86{ 87 shared_info_t *s = HYPERVISOR_shared_info; 88 89 synch_set_bit(port, &s->evtchn_mask[0]); 90} 91 92/** 93 * Enable signal delivery for an event channel port. 94 * 95 * \param port The event channel port to enable. 96 */ 97static inline void 98evtchn_unmask_port(evtchn_port_t port) 99{ 100 evtchn_unmask_t op = { .port = port }; 101 102 HYPERVISOR_event_channel_op(EVTCHNOP_unmask, &op); 103} 104 105#endif /* __XEN_EVTCHN_EVTCHNVAR_H__ */ 106