Merge to Fedora kernel-2.6.18-1.2224_FC5 patched with stable patch-2.6.18.1-vs2.0...
[linux-2.6.git] / include / 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-2005, K A Fraser
8  * 
9  * This program is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License version 2
11  * as published by the Free Software Foundation; or, when distributed
12  * separately from the Linux kernel or incorporated into other
13  * software packages, subject to the following license:
14  * 
15  * Permission is hereby granted, free of charge, to any person obtaining a copy
16  * of this source file (the "Software"), to deal in the Software without
17  * restriction, including without limitation the rights to use, copy, modify,
18  * merge, publish, distribute, sublicense, and/or sell copies of the Software,
19  * and to permit persons to whom the Software is furnished to do so, subject to
20  * the following conditions:
21  * 
22  * The above copyright notice and this permission notice shall be included in
23  * all copies or substantial portions of the Software.
24  * 
25  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
26  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
27  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
28  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
29  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
30  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
31  * IN THE SOFTWARE.
32  */
33
34 #ifndef __ASM_EVTCHN_H__
35 #define __ASM_EVTCHN_H__
36
37 #include <linux/interrupt.h>
38 #include <asm/hypervisor.h>
39 #include <asm/ptrace.h>
40 #include <asm/synch_bitops.h>
41 #include <xen/interface/event_channel.h>
42 #include <linux/smp.h>
43
44 /*
45  * LOW-LEVEL DEFINITIONS
46  */
47
48 /*
49  * Dynamically bind an event source to an IRQ-like callback handler.
50  * On some platforms this may not be implemented via the Linux IRQ subsystem.
51  * The IRQ argument passed to the callback handler is the same as returned
52  * from the bind call. It may not correspond to a Linux IRQ number.
53  * Returns IRQ or negative errno.
54  * UNBIND: Takes IRQ to unbind from; automatically closes the event channel.
55  */
56 extern int bind_evtchn_to_irqhandler(
57         unsigned int evtchn,
58         irqreturn_t (*handler)(int, void *, struct pt_regs *),
59         unsigned long irqflags,
60         const char *devname,
61         void *dev_id);
62 extern int bind_virq_to_irqhandler(
63         unsigned int virq,
64         unsigned int cpu,
65         irqreturn_t (*handler)(int, void *, struct pt_regs *),
66         unsigned long irqflags,
67         const char *devname,
68         void *dev_id);
69 extern int bind_ipi_to_irqhandler(
70         unsigned int ipi,
71         unsigned int cpu,
72         irqreturn_t (*handler)(int, void *, struct pt_regs *),
73         unsigned long irqflags,
74         const char *devname,
75         void *dev_id);
76
77 /*
78  * Common unbind function for all event sources. Takes IRQ to unbind from.
79  * Automatically closes the underlying event channel (even for bindings
80  * made with bind_evtchn_to_irqhandler()).
81  */
82 extern void unbind_from_irqhandler(unsigned int irq, void *dev_id);
83
84 extern void irq_resume(void);
85
86 /* Entry point for notifications into Linux subsystems. */
87 asmlinkage void evtchn_do_upcall(struct pt_regs *regs);
88
89 /* Entry point for notifications into the userland character device. */
90 extern void evtchn_device_upcall(int port);
91
92 extern void mask_evtchn(int port);
93 extern void unmask_evtchn(int port);
94
95 static inline void clear_evtchn(int port)
96 {
97         shared_info_t *s = HYPERVISOR_shared_info;
98         synch_clear_bit(port, &s->evtchn_pending[0]);
99 }
100
101 static inline void notify_remote_via_evtchn(int port)
102 {
103         struct evtchn_send send = { .port = port };
104         (void)HYPERVISOR_event_channel_op(EVTCHNOP_send, &send);
105 }
106
107 /*
108  * Unlike notify_remote_via_evtchn(), this is safe to use across
109  * save/restore. Notifications on a broken connection are silently dropped.
110  */
111 extern void notify_remote_via_irq(int irq);
112
113 #endif /* __ASM_EVTCHN_H__ */