[SPARC64]: Add .gitignore file for sparc64 boot images.
[linux-2.6] / arch / um / sys-x86_64 / syscalls.c
1 /*
2  * Copyright 2003 PathScale, Inc.
3  *
4  * Licensed under the GPL
5  */
6
7 #include "linux/linkage.h"
8 #include "linux/slab.h"
9 #include "linux/shm.h"
10 #include "linux/utsname.h"
11 #include "linux/personality.h"
12 #include "asm/uaccess.h"
13 #define __FRAME_OFFSETS
14 #include "asm/ptrace.h"
15 #include "asm/unistd.h"
16 #include "asm/prctl.h" /* XXX This should get the constants from libc */
17 #include "choose-mode.h"
18 #include "kern.h"
19
20 asmlinkage long sys_uname64(struct new_utsname __user * name)
21 {
22         int err;
23         down_read(&uts_sem);
24         err = copy_to_user(name, &system_utsname, sizeof (*name));
25         up_read(&uts_sem);
26         if (personality(current->personality) == PER_LINUX32)
27                 err |= copy_to_user(&name->machine, "i686", 5);
28         return err ? -EFAULT : 0;
29 }
30
31 #ifdef CONFIG_MODE_TT
32 extern long arch_prctl(int code, unsigned long addr);
33
34 static long arch_prctl_tt(int code, unsigned long addr)
35 {
36         unsigned long tmp;
37         long ret;
38
39         switch(code){
40         case ARCH_SET_GS:
41         case ARCH_SET_FS:
42                 ret = arch_prctl(code, addr);
43                 break;
44         case ARCH_GET_FS:
45         case ARCH_GET_GS:
46                 ret = arch_prctl(code, (unsigned long) &tmp);
47                 if(!ret)
48                         ret = put_user(tmp, &addr);
49                 break;
50         default:
51                 ret = -EINVAL;
52                 break;
53         }
54
55         return(ret);
56 }
57 #endif
58
59 #ifdef CONFIG_MODE_SKAS
60
61 /* XXX: Must also call arch_prctl in the host, beside saving the segment bases! */
62 static long arch_prctl_skas(int code, unsigned long addr)
63 {
64         long ret = 0;
65
66         switch(code){
67         case ARCH_SET_FS:
68                 current->thread.regs.regs.skas.regs[FS_BASE / sizeof(unsigned long)] = addr;
69                 break;
70         case ARCH_SET_GS:
71                 current->thread.regs.regs.skas.regs[GS_BASE / sizeof(unsigned long)] = addr;
72                 break;
73         case ARCH_GET_FS:
74                 ret = put_user(current->thread.regs.regs.skas.
75                                 regs[FS_BASE / sizeof(unsigned long)],
76                                 (unsigned long __user *)addr);
77                 break;
78         case ARCH_GET_GS:
79                 ret = put_user(current->thread.regs.regs.skas.
80                                 regs[GS_BASE / sizeof(unsigned long)],
81                                 (unsigned long __user *)addr);
82                 break;
83         default:
84                 ret = -EINVAL;
85                 break;
86         }
87
88         return(ret);
89 }
90 #endif
91
92 long sys_arch_prctl(int code, unsigned long addr)
93 {
94         return(CHOOSE_MODE_PROC(arch_prctl_tt, arch_prctl_skas, code, addr));
95 }
96
97 long sys_clone(unsigned long clone_flags, unsigned long newsp,
98                void __user *parent_tid, void __user *child_tid)
99 {
100         long ret;
101
102         if (!newsp)
103                 newsp = UPT_SP(&current->thread.regs.regs);
104         current->thread.forking = 1;
105         ret = do_fork(clone_flags, newsp, &current->thread.regs, 0, parent_tid,
106                       child_tid);
107         current->thread.forking = 0;
108         return(ret);
109 }