Path: blob/master/arch/microblaze/kernel/sys_microblaze.c
10817 views
/*1* Copyright (C) 2007-2009 Michal Simek <[email protected]>2* Copyright (C) 2007-2009 PetaLogix3* Copyright (C) 2007 John Williams <[email protected]>4*5* Copyright (C) 2006 Atmark Techno, Inc.6* Yasushi SHOJI <[email protected]>7* Tetsuya OHKAWA <[email protected]>8*9* This file is subject to the terms and conditions of the GNU General Public10* License. See the file "COPYING" in the main directory of this archive11* for more details.12*/1314#include <linux/errno.h>15#include <linux/mm.h>16#include <linux/smp.h>17#include <linux/syscalls.h>18#include <linux/sem.h>19#include <linux/msg.h>20#include <linux/shm.h>21#include <linux/stat.h>22#include <linux/mman.h>23#include <linux/sys.h>24#include <linux/ipc.h>25#include <linux/file.h>26#include <linux/module.h>27#include <linux/err.h>28#include <linux/fs.h>29#include <linux/semaphore.h>30#include <linux/uaccess.h>31#include <linux/unistd.h>32#include <linux/slab.h>3334#include <asm/syscalls.h>3536asmlinkage long microblaze_vfork(struct pt_regs *regs)37{38return do_fork(CLONE_VFORK | CLONE_VM | SIGCHLD, regs->r1,39regs, 0, NULL, NULL);40}4142asmlinkage long microblaze_clone(int flags, unsigned long stack,43struct pt_regs *regs)44{45if (!stack)46stack = regs->r1;47return do_fork(flags, stack, regs, 0, NULL, NULL);48}4950asmlinkage long microblaze_execve(const char __user *filenamei,51const char __user *const __user *argv,52const char __user *const __user *envp,53struct pt_regs *regs)54{55int error;56char *filename;5758filename = getname(filenamei);59error = PTR_ERR(filename);60if (IS_ERR(filename))61goto out;62error = do_execve(filename, argv, envp, regs);63putname(filename);64out:65return error;66}6768asmlinkage long sys_mmap(unsigned long addr, unsigned long len,69unsigned long prot, unsigned long flags,70unsigned long fd, off_t pgoff)71{72if (pgoff & ~PAGE_MASK)73return -EINVAL;7475return sys_mmap_pgoff(addr, len, prot, flags, fd, pgoff >> PAGE_SHIFT);76}7778/*79* Do a system call from kernel instead of calling sys_execve so we80* end up with proper pt_regs.81*/82int kernel_execve(const char *filename,83const char *const argv[],84const char *const envp[])85{86register const char *__a __asm__("r5") = filename;87register const void *__b __asm__("r6") = argv;88register const void *__c __asm__("r7") = envp;89register unsigned long __syscall __asm__("r12") = __NR_execve;90register unsigned long __ret __asm__("r3");91__asm__ __volatile__ ("brki r14, 0x8"92: "=r" (__ret), "=r" (__syscall)93: "1" (__syscall), "r" (__a), "r" (__b), "r" (__c)94: "r4", "r8", "r9",95"r10", "r11", "r14", "cc", "memory");96return __ret;97}9899100