ia64/xen-unstable

view xen/arch/x86/physdev.c @ 16409:00fec8212ae6

Remove unused smpboot.h header file.
Signed-off-by: Keir Fraser <keir.fraser@eu.citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Wed Nov 21 09:45:22 2007 +0000 (2007-11-21)
parents 96f64f4c42f0
children 6ecbb00e58cd
line source
2 #include <xen/config.h>
3 #include <xen/init.h>
4 #include <xen/lib.h>
5 #include <xen/types.h>
6 #include <xen/sched.h>
7 #include <xen/irq.h>
8 #include <xen/event.h>
9 #include <xen/guest_access.h>
10 #include <asm/current.h>
11 #include <asm/hypercall.h>
12 #include <public/xen.h>
13 #include <public/physdev.h>
14 #include <xsm/xsm.h>
16 #ifndef COMPAT
17 typedef long ret_t;
18 #endif
20 int
21 ioapic_guest_read(
22 unsigned long physbase, unsigned int reg, u32 *pval);
23 int
24 ioapic_guest_write(
25 unsigned long physbase, unsigned int reg, u32 pval);
27 ret_t do_physdev_op(int cmd, XEN_GUEST_HANDLE(void) arg)
28 {
29 int irq;
30 ret_t ret;
31 struct vcpu *v = current;
33 switch ( cmd )
34 {
35 case PHYSDEVOP_eoi: {
36 struct physdev_eoi eoi;
37 ret = -EFAULT;
38 if ( copy_from_guest(&eoi, arg, 1) != 0 )
39 break;
40 ret = pirq_guest_eoi(v->domain, eoi.irq);
41 break;
42 }
44 /* Legacy since 0x00030202. */
45 case PHYSDEVOP_IRQ_UNMASK_NOTIFY: {
46 ret = pirq_guest_unmask(v->domain);
47 break;
48 }
50 case PHYSDEVOP_irq_status_query: {
51 struct physdev_irq_status_query irq_status_query;
52 ret = -EFAULT;
53 if ( copy_from_guest(&irq_status_query, arg, 1) != 0 )
54 break;
55 irq = irq_status_query.irq;
56 ret = -EINVAL;
57 if ( (irq < 0) || (irq >= NR_IRQS) )
58 break;
59 irq_status_query.flags = 0;
60 if ( pirq_acktype(irq) != 0 )
61 irq_status_query.flags |= XENIRQSTAT_needs_eoi;
62 if ( pirq_shared(irq) )
63 irq_status_query.flags |= XENIRQSTAT_shared;
64 ret = copy_to_guest(arg, &irq_status_query, 1) ? -EFAULT : 0;
65 break;
66 }
68 case PHYSDEVOP_apic_read: {
69 struct physdev_apic apic;
70 ret = -EFAULT;
71 if ( copy_from_guest(&apic, arg, 1) != 0 )
72 break;
73 ret = -EPERM;
74 if ( !IS_PRIV(v->domain) )
75 break;
76 ret = xsm_apic(v->domain, cmd);
77 if ( ret )
78 break;
79 ret = ioapic_guest_read(apic.apic_physbase, apic.reg, &apic.value);
80 if ( copy_to_guest(arg, &apic, 1) != 0 )
81 ret = -EFAULT;
82 break;
83 }
85 case PHYSDEVOP_apic_write: {
86 struct physdev_apic apic;
87 ret = -EFAULT;
88 if ( copy_from_guest(&apic, arg, 1) != 0 )
89 break;
90 ret = -EPERM;
91 if ( !IS_PRIV(v->domain) )
92 break;
93 ret = xsm_apic(v->domain, cmd);
94 if ( ret )
95 break;
96 ret = ioapic_guest_write(apic.apic_physbase, apic.reg, apic.value);
97 break;
98 }
100 case PHYSDEVOP_alloc_irq_vector: {
101 struct physdev_irq irq_op;
103 ret = -EFAULT;
104 if ( copy_from_guest(&irq_op, arg, 1) != 0 )
105 break;
107 ret = -EPERM;
108 if ( !IS_PRIV(v->domain) )
109 break;
111 ret = xsm_assign_vector(v->domain, irq_op.irq);
112 if ( ret )
113 break;
115 irq = irq_op.irq;
116 ret = -EINVAL;
117 if ( (irq < 0) || (irq >= NR_IRQS) )
118 break;
120 irq_op.vector = assign_irq_vector(irq);
121 ret = copy_to_guest(arg, &irq_op, 1) ? -EFAULT : 0;
122 break;
123 }
125 case PHYSDEVOP_set_iopl: {
126 struct physdev_set_iopl set_iopl;
127 ret = -EFAULT;
128 if ( copy_from_guest(&set_iopl, arg, 1) != 0 )
129 break;
130 ret = -EINVAL;
131 if ( set_iopl.iopl > 3 )
132 break;
133 ret = 0;
134 v->arch.iopl = set_iopl.iopl;
135 break;
136 }
138 case PHYSDEVOP_set_iobitmap: {
139 struct physdev_set_iobitmap set_iobitmap;
140 ret = -EFAULT;
141 if ( copy_from_guest(&set_iobitmap, arg, 1) != 0 )
142 break;
143 ret = -EINVAL;
144 if ( !guest_handle_okay(set_iobitmap.bitmap, IOBMP_BYTES) ||
145 (set_iobitmap.nr_ports > 65536) )
146 break;
147 ret = 0;
148 #ifndef COMPAT
149 v->arch.iobmp = set_iobitmap.bitmap;
150 #else
151 guest_from_compat_handle(v->arch.iobmp, set_iobitmap.bitmap);
152 #endif
153 v->arch.iobmp_limit = set_iobitmap.nr_ports;
154 break;
155 }
157 default:
158 ret = -ENOSYS;
159 break;
160 }
162 return ret;
163 }
165 /*
166 * Local variables:
167 * mode: C
168 * c-set-style: "BSD"
169 * c-basic-offset: 4
170 * tab-width: 4
171 * indent-tabs-mode: nil
172 * End:
173 */