diff --git a/sys/dev/xen/bus/intr-internal.h b/sys/dev/xen/bus/intr-internal.h index 222e0665b14d..18f148bcb45f 100644 --- a/sys/dev/xen/bus/intr-internal.h +++ b/sys/dev/xen/bus/intr-internal.h @@ -1,54 +1,63 @@ /*- * SPDX-License-Identifier: MIT OR GPL-2.0-only * * Copyright © 2002-2005 K A Fraser * Copyright © 2005 Intel Corporation + * Copyright © 2005-2006 Kip Macy * Copyright © 2013 Spectra Logic Corporation * Copyright © 2015 Julien Grall * Copyright © 2021,2022 Elliott Mitchell * * This file may be distributed separately from the Linux kernel, or * incorporated into other software packages, subject to the following license: * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this source file (the "Software"), to deal in the Software without * restriction, including without limitation the rights to use, copy, modify, * merge, publish, distribute, sublicense, and/or sell copies of the Software, * and to permit persons to whom the Software is furnished to do so, subject to * the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS * IN THE SOFTWARE. */ #ifndef _XEN_INTR_INTERNAL_H_ #define _XEN_INTR_INTERNAL_H_ #ifndef _MACHINE__XEN_ARCH_INTR_H_ #error "do not #include intr-internal.h, #include machine/arch-intr.h instead" #endif /* Current implementation only supports 2L event channels. */ #define NR_EVENT_CHANNELS EVTCHN_2L_NR_CHANNELS +enum evtchn_type { + EVTCHN_TYPE_UNBOUND, + EVTCHN_TYPE_VIRQ, + EVTCHN_TYPE_IPI, + EVTCHN_TYPE_PORT, + EVTCHN_TYPE_COUNT +}; + struct xenisrc { xen_arch_isrc_t xi_arch; /* @TOP -> *xi_arch=*xenisrc */ enum evtchn_type xi_type; u_int xi_cpu; /* VCPU for delivery */ evtchn_port_t xi_port; u_int xi_virq; void *xi_cookie; bool xi_close:1; /* close on unbind? */ bool xi_masked:1; volatile u_int xi_refcount; }; #endif /* _XEN_INTR_INTERNAL_H_ */ diff --git a/sys/xen/evtchn/evtchnvar.h b/sys/xen/evtchn/evtchnvar.h index d1438846594f..448800be18a8 100644 --- a/sys/xen/evtchn/evtchnvar.h +++ b/sys/xen/evtchn/evtchnvar.h @@ -1,111 +1,103 @@ /****************************************************************************** * evtchn.h * * Data structures and definitions private to the FreeBSD implementation * of the Xen event channel API. * * Copyright (c) 2004, K A Fraser * Copyright (c) 2012, Spectra Logic Corporation * Copyright © 2022, Elliott Mitchell * * This file may be distributed separately from the Linux kernel, or * incorporated into other software packages, subject to the following license: * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this source file (the "Software"), to deal in the Software without * restriction, including without limitation the rights to use, copy, modify, * merge, publish, distribute, sublicense, and/or sell copies of the Software, * and to permit persons to whom the Software is furnished to do so, subject to * the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS * IN THE SOFTWARE. * * $FreeBSD$ */ #ifndef __XEN_EVTCHN_EVTCHNVAR_H__ #define __XEN_EVTCHN_EVTCHNVAR_H__ #include #include -enum evtchn_type { - EVTCHN_TYPE_UNBOUND, - EVTCHN_TYPE_VIRQ, - EVTCHN_TYPE_IPI, - EVTCHN_TYPE_PORT, - EVTCHN_TYPE_COUNT -}; - /** Submit a port notification for delivery to a userland evtchn consumer */ void evtchn_device_upcall(evtchn_port_t port); /* Macros for accessing event channel values */ #define EVTCHN_PTR(type, port) \ (HYPERVISOR_shared_info->evtchn_##type + ((port) / __LONG_BIT)) #define EVTCHN_BIT(port) ((port) & (__LONG_BIT - 1)) #define EVTCHN_MASK(port) (1UL << EVTCHN_BIT(port)) /** * Disable signal delivery for an event channel port, returning its * previous mask state. * * \param port The event channel port to query and mask. * * \returns 1 if event delivery was previously disabled. Otherwise 0. */ static inline int evtchn_test_and_set_mask(evtchn_port_t port) { return (atomic_testandset_long(EVTCHN_PTR(mask, port), EVTCHN_BIT(port))); } /** * Clear any pending event for the given event channel port. * * \param port The event channel port to clear. */ static inline void evtchn_clear_port(evtchn_port_t port) { atomic_clear_long(EVTCHN_PTR(pending, port), EVTCHN_MASK(port)); } /** * Disable signal delivery for an event channel port. * * \param port The event channel port to mask. */ static inline void evtchn_mask_port(evtchn_port_t port) { atomic_set_long(EVTCHN_PTR(mask, port), EVTCHN_MASK(port)); } /** * Enable signal delivery for an event channel port. * * \param port The event channel port to enable. */ static inline void evtchn_unmask_port(evtchn_port_t port) { evtchn_unmask_t op = { .port = port }; HYPERVISOR_event_channel_op(EVTCHNOP_unmask, &op); } #endif /* __XEN_EVTCHN_EVTCHNVAR_H__ */