ia64/xen-unstable

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