1 /******************************************************************************
4 * Communication via Xen event channels.
5 * Also definitions for the device that demuxes notifications to userspace.
7 * Copyright (c) 2004, K A Fraser
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>
20 * LOW-LEVEL DEFINITIONS
24 * Unlike notify_remote_via_evtchn(), this is safe to use across
25 * save/restore. Notifications on a broken connection are silently dropped.
27 void notify_remote_via_irq(int irq);
30 /* Entry point for notifications into Linux subsystems. */
31 void evtchn_do_upcall(struct trapframe *frame);
33 /* Entry point for notifications into the userland character device. */
34 void evtchn_device_upcall(int port);
36 void mask_evtchn(int port);
38 void unmask_evtchn(int port);
41 void rebind_evtchn_to_cpu(int port, unsigned int cpu);
43 #define rebind_evtchn_to_cpu(port, cpu) ((void)0)
47 int test_and_set_evtchn_mask(int port)
49 shared_info_t *s = HYPERVISOR_shared_info;
50 return synch_test_and_set_bit(port, s->evtchn_mask);
54 clear_evtchn(int port)
56 shared_info_t *s = HYPERVISOR_shared_info;
57 synch_clear_bit(port, &s->evtchn_pending[0]);
61 notify_remote_via_evtchn(int port)
63 struct evtchn_send send = { .port = port };
64 (void)HYPERVISOR_event_channel_op(EVTCHNOP_send, &send);
68 * Use these to access the event channel underlying the IRQ handle returned
69 * by bind_*_to_irqhandler().
71 int irq_to_evtchn_port(int irq);
73 void ipi_pcpu(unsigned int cpu, int vector);
76 * CHARACTER-DEVICE DEFINITIONS
79 #define PORT_NORMAL 0x0000
80 #define PORT_EXCEPTION 0x8000
81 #define PORTIDX_MASK 0x7fff
83 /* /dev/xen/evtchn resides at device number major=10, minor=200 */
84 #define EVTCHN_MINOR 200
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)
94 #endif /* __ASM_EVTCHN_H__ */