sys_avr32.c 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. asmlinkage long sys_mmap2(unsigned long addr, unsigned long len,
  16. unsigned long prot, unsigned long flags,
  17. unsigned long fd, off_t offset)
  18. {
  19. int error = -EBADF;
  20. struct file *file = NULL;
  21. flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
  22. if (!(flags & MAP_ANONYMOUS)) {
  23. file = fget(fd);
  24. if (!file)
  25. return error;
  26. }
  27. down_write(&current->mm->mmap_sem);
  28. error = do_mmap_pgoff(file, addr, len, prot, flags, offset);
  29. up_write(&current->mm->mmap_sem);
  30. if (file)
  31. fput(file);
  32. return error;
  33. }
  34. int kernel_execve(const char *file, char **argv, char **envp)
  35. {
  36. register long scno asm("r8") = __NR_execve;
  37. register long sc1 asm("r12") = (long)file;
  38. register long sc2 asm("r11") = (long)argv;
  39. register long sc3 asm("r10") = (long)envp;
  40. asm volatile("scall"
  41. : "=r"(sc1)
  42. : "r"(scno), "0"(sc1), "r"(sc2), "r"(sc3)
  43. : "cc", "memory");
  44. return sc1;
  45. }