]> CyberLeo.Net >> Repos - FreeBSD/releng/9.2.git/blob - sys/xen/evtchn.h
- Copy stable/9 to releng/9.2 as part of the 9.2-RELEASE cycle.
[FreeBSD/releng/9.2.git] / sys / xen / evtchn.h
1 /******************************************************************************
2  * evtchn.h
3  * 
4  * Communication via Xen event channels.
5  * Also definitions for the device that demuxes notifications to userspace.
6  * 
7  * Copyright (c) 2004, K A Fraser
8  *
9  * $FreeBSD$
10  */
11
12 #ifndef __ASM_EVTCHN_H__
13 #define __ASM_EVTCHN_H__
14 #include <machine/pcpu.h>
15 #include <xen/hypervisor.h>
16 #include <machine/xen/synch_bitops.h>
17 #include <machine/frame.h>
18
19 /*
20  * LOW-LEVEL DEFINITIONS
21  */
22
23 /*
24  * Unlike notify_remote_via_evtchn(), this is safe to use across
25  * save/restore. Notifications on a broken connection are silently dropped.
26  */
27 void notify_remote_via_irq(int irq);
28
29
30 /* Entry point for notifications into Linux subsystems. */
31 void evtchn_do_upcall(struct trapframe *frame);
32
33 /* Entry point for notifications into the userland character device. */
34 void evtchn_device_upcall(int port);
35
36 void mask_evtchn(int port);
37
38 void unmask_evtchn(int port);
39
40 #ifdef SMP
41 void rebind_evtchn_to_cpu(int port, unsigned int cpu);
42 #else
43 #define rebind_evtchn_to_cpu(port, cpu) ((void)0)
44 #endif
45
46 static inline
47 int test_and_set_evtchn_mask(int port)
48 {
49         shared_info_t *s = HYPERVISOR_shared_info;
50         return synch_test_and_set_bit(port, s->evtchn_mask);
51 }
52
53 static inline void 
54 clear_evtchn(int port)
55 {
56         shared_info_t *s = HYPERVISOR_shared_info;
57         synch_clear_bit(port, &s->evtchn_pending[0]);
58 }
59
60 static inline void 
61 notify_remote_via_evtchn(int port)
62 {
63         struct evtchn_send send = { .port = port };
64         (void)HYPERVISOR_event_channel_op(EVTCHNOP_send, &send);
65 }
66
67 /*
68  * Use these to access the event channel underlying the IRQ handle returned
69  * by bind_*_to_irqhandler().
70  */
71 int irq_to_evtchn_port(int irq);
72
73 void ipi_pcpu(unsigned int cpu, int vector);
74
75 /*
76  * CHARACTER-DEVICE DEFINITIONS
77  */
78
79 #define PORT_NORMAL    0x0000
80 #define PORT_EXCEPTION 0x8000
81 #define PORTIDX_MASK   0x7fff
82
83 /* /dev/xen/evtchn resides at device number major=10, minor=200 */
84 #define EVTCHN_MINOR 200
85
86 /* /dev/xen/evtchn ioctls: */
87 /* EVTCHN_RESET: Clear and reinit the event buffer. Clear error condition. */
88 #define EVTCHN_RESET  _IO('E', 1)
89 /* EVTCHN_BIND: Bind to the specified event-channel port. */
90 #define EVTCHN_BIND   _IO('E', 2)
91 /* EVTCHN_UNBIND: Unbind from the specified event-channel port. */
92 #define EVTCHN_UNBIND _IO('E', 3)
93
94 #endif /* __ASM_EVTCHN_H__ */