FreeBSD xen subsystem code
evtchnvar.h
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
40enum evtchn_type {
41 EVTCHN_TYPE_UNBOUND,
42 EVTCHN_TYPE_VIRQ,
43 EVTCHN_TYPE_IPI,
44 EVTCHN_TYPE_PORT,
45 EVTCHN_TYPE_COUNT
46};
47
49void evtchn_device_upcall(evtchn_port_t port);
50
59static inline int
60evtchn_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
71static inline void
72evtchn_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
83static inline void
84evtchn_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
96static inline void
97evtchn_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__ */