1 #include <linux/module.h>
3 #include <asm/irqflags.h>
4 #include <asm/hypervisor.h>
6 /* interrupt control.. */
9 * The use of 'barrier' in the following reflects their use as local-lock
10 * operations. Reentrancy must be prevented (e.g., __cli()) /before/ following
11 * critical operations are executed. All critical operations must complete
12 * /before/ reentrancy is permitted (e.g., __sti()). Alpha architecture also
13 * includes these barriers, for example.
16 unsigned long __raw_local_save_flags(void)
18 struct vcpu_info *_vcpu;
22 _vcpu = &HYPERVISOR_shared_info->vcpu_info[__vcpu_id];
23 flags = _vcpu->evtchn_upcall_mask;
28 EXPORT_SYMBOL(__raw_local_save_flags);
30 void raw_local_irq_restore(unsigned long flags)
32 struct vcpu_info *_vcpu;
35 _vcpu = &HYPERVISOR_shared_info->vcpu_info[__vcpu_id];
36 if ((_vcpu->evtchn_upcall_mask = flags) == 0) {
37 barrier(); /* unmask then check (avoid races) */
38 if (unlikely(_vcpu->evtchn_upcall_pending))
39 force_evtchn_callback();
42 preempt_enable_no_resched();
45 EXPORT_SYMBOL(raw_local_irq_restore);
47 void raw_local_irq_disable(void)
49 struct vcpu_info *_vcpu;
52 _vcpu = &HYPERVISOR_shared_info->vcpu_info[__vcpu_id];
53 _vcpu->evtchn_upcall_mask = 1;
54 preempt_enable_no_resched();
56 EXPORT_SYMBOL(raw_local_irq_disable);
58 void raw_local_irq_enable(void)
60 struct vcpu_info *_vcpu;
63 _vcpu = &HYPERVISOR_shared_info->vcpu_info[__vcpu_id];
64 _vcpu->evtchn_upcall_mask = 0;
65 barrier(); /* unmask then check (avoid races) */
66 if (unlikely(_vcpu->evtchn_upcall_pending))
67 force_evtchn_callback();
70 EXPORT_SYMBOL(raw_local_irq_enable);
72 /* Cannot use preempt_enable() here as we would recurse in preempt_sched(). */
73 int raw_irqs_disabled(void)
75 struct vcpu_info *_vcpu;
79 _vcpu = &HYPERVISOR_shared_info->vcpu_info[__vcpu_id];
80 disabled = (_vcpu->evtchn_upcall_mask != 0);
81 preempt_enable_no_resched();
84 EXPORT_SYMBOL(raw_irqs_disabled);
86 unsigned long __raw_local_irq_save(void)
88 struct vcpu_info *_vcpu;
92 _vcpu = &HYPERVISOR_shared_info->vcpu_info[__vcpu_id];
93 flags = _vcpu->evtchn_upcall_mask;
94 _vcpu->evtchn_upcall_mask = 1;
95 preempt_enable_no_resched();
99 EXPORT_SYMBOL(__raw_local_irq_save);