ia64/xen-unstable

view xenolinux-2.4.22-sparse/arch/xeno/drivers/dom0/dom0_core.c @ 926:0a901de56d7c

bitkeeper revision 1.588 (3fafd2ccYgSbWe9z2kLiH-DeviUaIA)

Merge labyrinth.cl.cam.ac.uk:/auto/groups/xeno/BK/xeno.bk
into labyrinth.cl.cam.ac.uk:/local/scratch/smh22/xeno.bk
author smh22@labyrinth.cl.cam.ac.uk
date Mon Nov 10 18:02:52 2003 +0000 (2003-11-10)
parents 92d4612dd1bc 4aba3a48d64f
children
line source
1 /******************************************************************************
2 * dom0_core.c
3 *
4 * Interface to privileged domain-0 commands.
5 *
6 * Copyright (c) 2002-2003, K A Fraser, B Dragovic
7 */
9 #include <linux/config.h>
10 #include <linux/module.h>
11 #include <linux/kernel.h>
12 #include <linux/sched.h>
13 #include <linux/slab.h>
14 #include <linux/string.h>
15 #include <linux/errno.h>
16 #include <linux/mm.h>
17 #include <linux/mman.h>
18 #include <linux/swap.h>
19 #include <linux/smp_lock.h>
20 #include <linux/swapctl.h>
21 #include <linux/iobuf.h>
22 #include <linux/highmem.h>
23 #include <linux/pagemap.h>
24 #include <linux/seq_file.h>
26 #include <asm/pgalloc.h>
27 #include <asm/pgtable.h>
28 #include <asm/uaccess.h>
29 #include <asm/tlb.h>
30 #include <asm/proc_cmd.h>
31 #include <asm/hypervisor-ifs/dom0_ops.h>
32 #include <asm/xeno_proc.h>
34 #include "../block/xl_block.h"
36 static struct proc_dir_entry *privcmd_intf;
39 static int privcmd_ioctl(struct inode *inode, struct file *file,
40 unsigned int cmd, unsigned long data)
41 {
42 int ret = 0;
44 switch ( cmd )
45 {
46 case IOCTL_PRIVCMD_HYPERCALL:
47 {
48 privcmd_hypercall_t hypercall;
50 if ( copy_from_user(&hypercall, (void *)data, sizeof(hypercall)) )
51 return -EFAULT;
53 __asm__ __volatile__ (
54 "pushl %%ebx; pushl %%ecx; pushl %%edx; pushl %%esi; pushl %%edi; "
55 "movl 4(%%eax),%%ebx ;"
56 "movl 8(%%eax),%%ecx ;"
57 "movl 12(%%eax),%%edx ;"
58 "movl 16(%%eax),%%esi ;"
59 "movl 20(%%eax),%%edi ;"
60 "movl (%%eax),%%eax ;"
61 TRAP_INSTR "; "
62 "popl %%edi; popl %%esi; popl %%edx; popl %%ecx; popl %%ebx"
63 : "=a" (ret) : "0" (&hypercall) : "memory" );
65 }
66 break;
68 default:
69 ret = -EINVAL;
70 break;
71 }
72 return ret;
73 }
76 static struct file_operations privcmd_file_ops = {
77 ioctl : privcmd_ioctl
78 };
81 static int __init init_module(void)
82 {
83 if ( !(start_info.flags & SIF_PRIVILEGED) )
84 return 0;
86 /* xeno control interface */
87 privcmd_intf = create_xeno_proc_entry("privcmd", 0400);
88 if ( privcmd_intf != NULL )
89 {
90 privcmd_intf->owner = THIS_MODULE;
91 privcmd_intf->nlink = 1;
92 privcmd_intf->proc_fops = &privcmd_file_ops;
93 }
95 return 0;
96 }
99 static void __exit cleanup_module(void)
100 {
101 if ( privcmd_intf == NULL ) return;
102 remove_xeno_proc_entry("privcmd");
103 privcmd_intf = NULL;
104 }
107 module_init(init_module);
108 module_exit(cleanup_module);