sys_avr32.c 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*
  2. * Copyright (C) 2004-2006 Atmel Corporation
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License version 2 as
  6. * published by the Free Software Foundation.
  7. */
  8. #include <linux/errno.h>
  9. #include <linux/fs.h>
  10. #include <linux/file.h>
  11. #include <linux/mm.h>
  12. #include <linux/unistd.h>
  13. #include <asm/mman.h>
  14. #include <asm/uaccess.h>
  15. #include <asm/syscalls.h>
  16. asmlinkage long sys_mmap2(unsigned long addr, unsigned long len,
  17. unsigned long prot, unsigned long flags,
  18. unsigned long fd, off_t offset)
  19. {
  20. int error = -EBADF;
  21. struct file *file = NULL;
  22. flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
  23. if (!(flags & MAP_ANONYMOUS)) {
  24. file = fget(fd);
  25. if (!file)
  26. return error;
  27. }
  28. down_write(&current->mm->mmap_sem);
  29. error = do_mmap_pgoff(file, addr, len, prot, flags, offset);
  30. up_write(&current->mm->mmap_sem);
  31. if (file)
  32. fput(file);
  33. return error;
  34. }
  35. int kernel_execve(const char *file, char **argv, char **envp)
  36. {
  37. register long scno asm("r8") = __NR_execve;
  38. register long sc1 asm("r12") = (long)file;
  39. register long sc2 asm("r11") = (long)argv;
  40. register long sc3 asm("r10") = (long)envp;
  41. asm volatile("scall"
  42. : "=r"(sc1)
  43. : "r"(scno), "0"(sc1), "r"(sc2), "r"(sc3)
  44. : "cc", "memory");
  45. return sc1;
  46. }