aboutsummaryrefslogtreecommitdiffstats
path: root/xenolinux-2.4.24-sparse/arch/xeno/kernel/ioport.c
diff options
context:
space:
mode:
authoriap10@labyrinth.cl.cam.ac.uk <iap10@labyrinth.cl.cam.ac.uk>2004-01-12 08:53:30 +0000
committeriap10@labyrinth.cl.cam.ac.uk <iap10@labyrinth.cl.cam.ac.uk>2004-01-12 08:53:30 +0000
commit6b5b22582f098f13cce9926f03d17092789ffa5e (patch)
treec5d9ac81db9517973b9a74fb017f1c9c90fca012 /xenolinux-2.4.24-sparse/arch/xeno/kernel/ioport.c
parentabc73fe73e5760d1f6836ea098813f4d65d2c097 (diff)
downloadxen-6b5b22582f098f13cce9926f03d17092789ffa5e.tar.gz
xen-6b5b22582f098f13cce9926f03d17092789ffa5e.tar.bz2
xen-6b5b22582f098f13cce9926f03d17092789ffa5e.zip
bitkeeper revision 1.671 (4002608aofyioMya1eWuIFZIJHQO4Q)
Upgrade to Linux version 2.4.24
Diffstat (limited to 'xenolinux-2.4.24-sparse/arch/xeno/kernel/ioport.c')
-rw-r--r--xenolinux-2.4.24-sparse/arch/xeno/kernel/ioport.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/xenolinux-2.4.24-sparse/arch/xeno/kernel/ioport.c b/xenolinux-2.4.24-sparse/arch/xeno/kernel/ioport.c
new file mode 100644
index 0000000000..ed6dbbc3c5
--- /dev/null
+++ b/xenolinux-2.4.24-sparse/arch/xeno/kernel/ioport.c
@@ -0,0 +1,48 @@
+#include <linux/sched.h>
+#include <linux/kernel.h>
+#include <linux/errno.h>
+#include <linux/types.h>
+#include <linux/stddef.h>
+#include <asm/hypervisor-ifs/dom0_ops.h>
+
+
+asmlinkage int sys_iopl(unsigned int new_io_pl)
+{
+ unsigned int old_io_pl = current->thread.io_pl;
+ dom0_op_t op;
+
+ if ( !(start_info.flags & SIF_PRIVILEGED) )
+ return -EPERM;
+
+ if ( new_io_pl > 3 )
+ return -EINVAL;
+
+ /* Need "raw I/O" privileges for direct port access. */
+ if ( (new_io_pl > old_io_pl) && !capable(CAP_SYS_RAWIO) )
+ return -EPERM;
+
+ /* Maintain OS privileges even if user attempts to relinquish them. */
+ if ( (new_io_pl == 0) && (start_info.flags & SIF_PRIVILEGED) )
+ new_io_pl = 1;
+
+ /* Change our version of the privilege levels. */
+ current->thread.io_pl = new_io_pl;
+
+ /* Force the change at ring 0. */
+ op.cmd = DOM0_IOPL;
+ op.u.iopl.domain = start_info.dom_id;
+ op.u.iopl.iopl = new_io_pl;
+ HYPERVISOR_dom0_op(&op);
+
+ return 0;
+}
+
+
+asmlinkage int sys_ioperm(unsigned long from, unsigned long num, int turn_on)
+{
+ printk(KERN_INFO "ioperm not fully supported - %s\n",
+ turn_on ? "set iopl to 3" : "ignore resource release");
+ return turn_on ? sys_iopl(3) : 0;
+}
+
+