Pull button into test branch
[pandora-kernel.git] / arch / sh / kernel / sys_sh.c
index b68ff70..e18f183 100644 (file)
@@ -25,6 +25,7 @@
 #include <asm/cacheflush.h>
 #include <asm/uaccess.h>
 #include <asm/ipc.h>
+#include <asm/unistd.h>
 
 /*
  * sys_pipe() is the normal C calling standard for creating
  */
 asmlinkage int sys_pipe(unsigned long r4, unsigned long r5,
        unsigned long r6, unsigned long r7,
-       struct pt_regs regs)
+       struct pt_regs __regs)
 {
+       struct pt_regs *regs = RELOC_HIDE(&__regs, 0);
        int fd[2];
        int error;
 
        error = do_pipe(fd);
        if (!error) {
-               regs.regs[1] = fd[1];
+               regs->regs[1] = fd[1];
                return fd[0];
        }
        return error;
@@ -49,6 +51,7 @@ unsigned long shm_align_mask = PAGE_SIZE - 1; /* Sane caches */
 
 EXPORT_SYMBOL(shm_align_mask);
 
+#ifdef CONFIG_MMU
 /*
  * To avoid cache aliases, we map the shared page with same color.
  */
@@ -134,6 +137,7 @@ full_search:
                        addr = COLOUR_ALIGN(addr, pgoff);
        }
 }
+#endif /* CONFIG_MMU */
 
 static inline long
 do_mmap2(unsigned long addr, unsigned long len, unsigned long prot, 
@@ -281,7 +285,7 @@ asmlinkage int sys_uname(struct old_utsname * name)
        if (!name)
                return -EFAULT;
        down_read(&uts_sem);
-       err=copy_to_user(name, &system_utsname, sizeof (*name));
+       err = copy_to_user(name, utsname(), sizeof (*name));
        up_read(&uts_sem);
        return err?-EFAULT:0;
 }
@@ -309,3 +313,25 @@ asmlinkage int sys_fadvise64_64_wrapper(int fd, u32 offset0, u32 offset1,
                                (u64)len0 << 32 | len1, advice);
 #endif
 }
+
+#if defined(CONFIG_CPU_SH2) || defined(CONFIG_CPU_SH2A)
+#define SYSCALL_ARG3   "trapa #0x23"
+#else
+#define SYSCALL_ARG3   "trapa #0x13"
+#endif
+
+/*
+ * Do a system call from kernel instead of calling sys_execve so we
+ * end up with proper pt_regs.
+ */
+int kernel_execve(const char *filename, char *const argv[], char *const envp[])
+{
+       register long __sc0 __asm__ ("r3") = __NR_execve;
+       register long __sc4 __asm__ ("r4") = (long) filename;
+       register long __sc5 __asm__ ("r5") = (long) argv;
+       register long __sc6 __asm__ ("r6") = (long) envp;
+       __asm__ __volatile__ (SYSCALL_ARG3 : "=z" (__sc0)       
+                       : "0" (__sc0), "r" (__sc4), "r" (__sc5), "r" (__sc6)
+                       : "memory");
+       return __sc0;
+}