ia64/xen-unstable

view linux-2.6-xen-sparse/include/asm-xen/evtchn.h @ 6538:84ee014ebd41

Merge xen-vtx-unstable.hg
author adsharma@los-vmm.sc.intel.com
date Wed Aug 17 12:34:38 2005 -0800 (2005-08-17)
parents 23979fb12c49 d9442abaa980
children 99914b54f7bf
line source
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 * This file may be distributed separately from the Linux kernel, or
10 * incorporated into other software packages, subject to the following license:
11 *
12 * Permission is hereby granted, free of charge, to any person obtaining a copy
13 * of this source file (the "Software"), to deal in the Software without
14 * restriction, including without limitation the rights to use, copy, modify,
15 * merge, publish, distribute, sublicense, and/or sell copies of the Software,
16 * and to permit persons to whom the Software is furnished to do so, subject to
17 * the following conditions:
18 *
19 * The above copyright notice and this permission notice shall be included in
20 * all copies or substantial portions of the Software.
21 *
22 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
27 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
28 * IN THE SOFTWARE.
29 */
31 #ifndef __ASM_EVTCHN_H__
32 #define __ASM_EVTCHN_H__
34 #include <linux/config.h>
35 #include <linux/interrupt.h>
36 #include <asm-xen/hypervisor.h>
37 #include <asm/ptrace.h>
38 #include <asm-xen/synch_bitops.h>
39 #include <asm-xen/xen-public/event_channel.h>
40 #include <linux/smp.h>
42 /*
43 * LOW-LEVEL DEFINITIONS
44 */
46 /* Dynamically bind a VIRQ source to Linux IRQ space. */
47 extern int bind_virq_to_irq(int virq);
48 extern void unbind_virq_from_irq(int virq);
50 /* Dynamically bind an IPI source to Linux IRQ space. */
51 extern int bind_ipi_to_irq(int ipi);
52 extern void unbind_ipi_from_irq(int ipi);
54 /* Dynamically bind an event-channel port to Linux IRQ space. */
55 extern int bind_evtchn_to_irq(unsigned int evtchn);
56 extern void unbind_evtchn_from_irq(unsigned int evtchn);
58 /*
59 * Dynamically bind an event-channel port to an IRQ-like callback handler.
60 * On some platforms this may not be implemented via the Linux IRQ subsystem.
61 * You *cannot* trust the irq argument passed to the callback handler.
62 */
63 extern int bind_evtchn_to_irqhandler(
64 unsigned int evtchn,
65 irqreturn_t (*handler)(int, void *, struct pt_regs *),
66 unsigned long irqflags,
67 const char *devname,
68 void *dev_id);
69 extern void unbind_evtchn_from_irqhandler(unsigned int evtchn, void *dev_id);
71 extern void irq_suspend(void);
72 extern void irq_resume(void);
74 /* Entry point for notifications into Linux subsystems. */
75 asmlinkage void evtchn_do_upcall(struct pt_regs *regs);
77 /* Entry point for notifications into the userland character device. */
78 void evtchn_device_upcall(int port);
80 static inline void mask_evtchn(int port)
81 {
82 shared_info_t *s = HYPERVISOR_shared_info;
83 synch_set_bit(port, &s->evtchn_mask[0]);
84 }
86 static inline void unmask_evtchn(int port)
87 {
88 shared_info_t *s = HYPERVISOR_shared_info;
89 vcpu_info_t *vcpu_info = &s->vcpu_data[smp_processor_id()];
91 synch_clear_bit(port, &s->evtchn_mask[0]);
93 /*
94 * The following is basically the equivalent of 'hw_resend_irq'. Just like
95 * a real IO-APIC we 'lose the interrupt edge' if the channel is masked.
96 */
97 if ( synch_test_bit (port, &s->evtchn_pending[0]) &&
98 !synch_test_and_set_bit(port>>5, &vcpu_info->evtchn_pending_sel) )
99 {
100 vcpu_info->evtchn_upcall_pending = 1;
101 if ( !vcpu_info->evtchn_upcall_mask )
102 force_evtchn_callback();
103 }
104 }
106 static inline void clear_evtchn(int port)
107 {
108 shared_info_t *s = HYPERVISOR_shared_info;
109 synch_clear_bit(port, &s->evtchn_pending[0]);
110 }
112 static inline int notify_via_evtchn(int port)
113 {
114 evtchn_op_t op;
115 op.cmd = EVTCHNOP_send;
116 op.u.send.local_port = port;
117 return HYPERVISOR_event_channel_op(&op);
118 }
120 /*
121 * CHARACTER-DEVICE DEFINITIONS
122 */
124 /* /dev/xen/evtchn resides at device number major=10, minor=201 */
125 #define EVTCHN_MINOR 201
127 /* /dev/xen/evtchn ioctls: */
128 /* EVTCHN_RESET: Clear and reinit the event buffer. Clear error condition. */
129 #define EVTCHN_RESET _IO('E', 1)
130 /* EVTCHN_BIND: Bind to teh specified event-channel port. */
131 #define EVTCHN_BIND _IO('E', 2)
132 /* EVTCHN_UNBIND: Unbind from the specified event-channel port. */
133 #define EVTCHN_UNBIND _IO('E', 3)
135 #endif /* __ASM_EVTCHN_H__ */