ia64/xen-unstable

view xen/include/xen/event.h @ 6552:a9873d384da4

Merge.
author adsharma@los-vmm.sc.intel.com
date Thu Aug 25 12:24:48 2005 -0700 (2005-08-25)
parents 112d44270733 fa0754a9f64f
children dfaf788ab18c
line source
1 /******************************************************************************
2 * event.h
3 *
4 * A nice interface for passing asynchronous events to guest OSes.
5 *
6 * Copyright (c) 2002, K A Fraser
7 */
9 #ifndef __XEN_EVENT_H__
10 #define __XEN_EVENT_H__
12 #include <xen/config.h>
13 #include <xen/sched.h>
14 #include <xen/smp.h>
15 #include <asm/bitops.h>
16 #include <asm/event.h>
18 /*
19 * EVENT-CHANNEL NOTIFICATIONS
20 * NB. On x86, the atomic bit operations also act as memory barriers. There
21 * is therefore sufficiently strict ordering for this architecture -- others
22 * may require explicit memory barriers.
23 */
25 static inline void evtchn_set_pending(struct vcpu *v, int port)
26 {
27 struct domain *d = v->domain;
28 shared_info_t *s = d->shared_info;
30 /* These four operations must happen in strict order. */
31 if ( !test_and_set_bit(port, &s->evtchn_pending[0]) &&
32 !test_bit (port, &s->evtchn_mask[0]) &&
33 !test_and_set_bit(port>>5, &v->vcpu_info->evtchn_pending_sel) &&
34 !test_and_set_bit(0, &v->vcpu_info->evtchn_upcall_pending) )
35 {
36 evtchn_notify(v);
37 }
38 }
40 /*
41 * send_guest_virq:
42 * @v: VCPU to which virtual IRQ should be sent
43 * @virq: Virtual IRQ number (VIRQ_*)
44 */
45 static inline void send_guest_virq(struct vcpu *v, int virq)
46 {
47 int port = v->virq_to_evtchn[virq];
49 if ( likely(port != 0) )
50 evtchn_set_pending(v, port);
51 }
53 /*
54 * send_guest_pirq:
55 * @d: Domain to which physical IRQ should be sent
56 * @pirq: Physical IRQ number
57 */
58 extern void send_guest_pirq(struct domain *d, int pirq);
60 /* Note: Bitwise operations result in fast code with no branches. */
61 #define event_pending(v) \
62 ((v)->vcpu_info->evtchn_upcall_pending & \
63 ~(v)->vcpu_info->evtchn_upcall_mask)
65 #endif /* __XEN_EVENT_H__ */