Import 2.3.9pre5
[davej-history.git] / arch / mips / kernel / sysmips.c
blob99827f61250e7d8667bcea7b845f2eacc53e2a86
1 /*
2 * MIPS specific syscalls
4 * This file is subject to the terms and conditions of the GNU General Public
5 * License. See the file "COPYING" in the main directory of this archive
6 * for more details.
8 * Copyright (C) 1995, 1996, 1997 by Ralf Baechle
10 * $Id: sysmips.c,v 1.6 1998/08/25 09:14:42 ralf Exp $
12 #include <linux/errno.h>
13 #include <linux/linkage.h>
14 #include <linux/mm.h>
15 #include <linux/smp.h>
16 #include <linux/smp_lock.h>
17 #include <linux/sched.h>
18 #include <linux/string.h>
19 #include <linux/utsname.h>
21 #include <asm/cachectl.h>
22 #include <asm/pgtable.h>
23 #include <asm/sysmips.h>
24 #include <asm/uaccess.h>
27 * How long a hostname can we get from user space?
28 * -EFAULT if invalid area or too long
29 * 0 if ok
30 * >0 EFAULT after xx bytes
32 static inline int
33 get_max_hostname(unsigned long address)
35 struct vm_area_struct * vma;
37 vma = find_vma(current->mm, address);
38 if (!vma || vma->vm_start > address || !(vma->vm_flags & VM_READ))
39 return -EFAULT;
40 address = vma->vm_end - address;
41 if (address > PAGE_SIZE)
42 return 0;
43 if (vma->vm_next && vma->vm_next->vm_start == vma->vm_end &&
44 (vma->vm_next->vm_flags & VM_READ))
45 return 0;
46 return address;
49 asmlinkage int
50 sys_sysmips(int cmd, int arg1, int arg2, int arg3)
52 int *p;
53 char *name;
54 int flags, tmp, len, retval;
56 lock_kernel();
57 switch(cmd)
59 case SETNAME:
60 retval = -EPERM;
61 if (!capable(CAP_SYS_ADMIN))
62 goto out;
64 name = (char *) arg1;
65 len = strlen_user(name);
67 retval = len;
68 if (len < 0)
69 goto out;
71 retval = -EINVAL;
72 if (len == 0 || len > __NEW_UTS_LEN)
73 goto out;
75 copy_from_user(system_utsname.nodename, name, len);
76 system_utsname.nodename[len] = '\0';
77 retval = 0;
78 goto out;
80 case MIPS_ATOMIC_SET:
81 /* This is broken in case of page faults and SMP ...
82 Risc/OS fauls after maximum 20 tries with EAGAIN. */
83 p = (int *) arg1;
84 retval = verify_area(VERIFY_WRITE, p, sizeof(*p));
85 if (retval)
86 goto out;
87 save_and_cli(flags);
88 retval = *p;
89 *p = arg2;
90 restore_flags(flags);
91 goto out;
93 case MIPS_FIXADE:
94 tmp = current->tss.mflags & ~3;
95 current->tss.mflags = tmp | (arg1 & 3);
96 retval = 0;
97 goto out;
99 case FLUSH_CACHE:
100 flush_cache_all();
101 retval = 0;
102 goto out;
104 case MIPS_RDNVRAM:
105 retval = -EIO;
106 goto out;
108 default:
109 retval = -EINVAL;
110 goto out;
113 out:
114 unlock_kernel();
115 return retval;
119 * No implemented yet ...
121 asmlinkage int
122 sys_cachectl(char *addr, int nbytes, int op)
124 return -ENOSYS;