summaryrefslogtreecommitdiffstats
path: root/sys/xen/evtchn/evtchnvar.h
blob: 8008d23297d3f8a4976bbc9a90f90c7b64b82d18 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
/******************************************************************************
 * 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
 *
 * 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 <xen/hypervisor.h>
#include <xen/interface/event_channel.h>

enum evtchn_type {
	EVTCHN_TYPE_UNBOUND,
	EVTCHN_TYPE_PIRQ,
	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);

/**
 * 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)
{
	shared_info_t *s = HYPERVISOR_shared_info;
	return synch_test_and_set_bit(port, s->evtchn_mask);
}

/**
 * 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)
{
	shared_info_t *s = HYPERVISOR_shared_info;
	synch_clear_bit(port, &s->evtchn_pending[0]);
}

/**
 * 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)
{
	shared_info_t *s = HYPERVISOR_shared_info;

	synch_set_bit(port, &s->evtchn_mask[0]);
}

/**
 * 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__ */
OpenPOWER on IntegriCloud