ia64/xen-unstable

view xenolinux-2.4.21-pre4-sparse/arch/xeno/kernel/hypervisor.c @ 235:d7d0a23b2e07

bitkeeper revision 1.93 (3e5a4e6bkPheUp3x1uufN2MS3LAB7A)

Latest and Greatest version of XenoLinux based on the Linux-2.4.21-pre4
kernel.
author iap10@labyrinth.cl.cam.ac.uk
date Mon Feb 24 16:55:07 2003 +0000 (2003-02-24)
parents
children 75d5c2fc3073
line source
1 /******************************************************************************
2 * hypervisor.c
3 *
4 * Communication to/from hypervisor.
5 *
6 * Copyright (c) 2002, K A Fraser
7 */
9 #include <linux/config.h>
10 #include <asm/atomic.h>
11 #include <linux/irq.h>
12 #include <asm/hypervisor.h>
13 #include <asm/system.h>
14 #include <asm/ptrace.h>
16 static unsigned long event_mask = 0;
18 void frobb(void) {}
20 void do_hypervisor_callback(struct pt_regs *regs)
21 {
22 unsigned long events, flags;
23 shared_info_t *shared = HYPERVISOR_shared_info;
25 do {
26 /* Specialised local_irq_save(). */
27 flags = shared->events_enable;
28 shared->events_enable = 0;
29 barrier();
31 events = xchg(&shared->events, 0);
32 events &= event_mask;
34 __asm__ __volatile__ (
35 " push %1 ;"
36 " sub $4,%%esp ;"
37 " jmp 2f ;"
38 "1: btrl %%eax,%0 ;" /* clear bit */
39 " mov %%eax,(%%esp) ;"
40 " call do_IRQ ;" /* do_IRQ(event) */
41 "2: bsfl %0,%%eax ;" /* %eax == bit # */
42 " jnz 1b ;"
43 " add $8,%%esp ;"
44 /* we use %ebx because it is callee-saved */
45 : : "b" (events), "r" (regs)
46 /* clobbered by callback function calls */
47 : "eax", "ecx", "edx", "memory" );
49 /* Specialised local_irq_restore(). */
50 shared->events_enable = flags;
51 barrier();
52 }
53 while ( shared->events );
54 }
58 /*
59 * Define interface to generic handling in irq.c
60 */
62 static unsigned int startup_hypervisor_event(unsigned int irq)
63 {
64 set_bit(irq, &event_mask);
65 return 0;
66 }
68 static void shutdown_hypervisor_event(unsigned int irq)
69 {
70 clear_bit(irq, &event_mask);
71 }
73 static void enable_hypervisor_event(unsigned int irq)
74 {
75 set_bit(irq, &event_mask);
76 }
78 static void disable_hypervisor_event(unsigned int irq)
79 {
80 clear_bit(irq, &event_mask);
81 }
83 static void ack_hypervisor_event(unsigned int irq)
84 {
85 if ( !(event_mask & (1<<irq)) )
86 {
87 printk("Unexpected hypervisor event %d\n", irq);
88 atomic_inc(&irq_err_count);
89 }
90 }
92 static void end_hypervisor_event(unsigned int irq)
93 {
94 }
96 static struct hw_interrupt_type hypervisor_irq_type = {
97 "Hypervisor-event",
98 startup_hypervisor_event,
99 shutdown_hypervisor_event,
100 enable_hypervisor_event,
101 disable_hypervisor_event,
102 ack_hypervisor_event,
103 end_hypervisor_event,
104 NULL
105 };
107 void __init init_IRQ(void)
108 {
109 int i;
111 for ( i = 0; i < NR_IRQS; i++ )
112 {
113 irq_desc[i].status = IRQ_DISABLED;
114 irq_desc[i].action = 0;
115 irq_desc[i].depth = 1;
116 irq_desc[i].handler = &hypervisor_irq_type;
117 }
118 }