sys_microblaze.c 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /*
  2. * Copyright (C) 2007-2009 Michal Simek <monstr@monstr.eu>
  3. * Copyright (C) 2007-2009 PetaLogix
  4. * Copyright (C) 2007 John Williams <john.williams@petalogix.com>
  5. *
  6. * Copyright (C) 2006 Atmark Techno, Inc.
  7. * Yasushi SHOJI <yashi@atmark-techno.com>
  8. * Tetsuya OHKAWA <tetsuya@atmark-techno.com>
  9. *
  10. * This file is subject to the terms and conditions of the GNU General Public
  11. * License. See the file "COPYING" in the main directory of this archive
  12. * for more details.
  13. */
  14. #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>
  33. #include <asm/syscalls.h>
  34. asmlinkage long microblaze_vfork(struct pt_regs *regs)
  35. {
  36. return do_fork(CLONE_VFORK | CLONE_VM | SIGCHLD, regs->r1,
  37. regs, 0, NULL, NULL);
  38. }
  39. asmlinkage long microblaze_clone(int flags, unsigned long stack,
  40. struct pt_regs *regs)
  41. {
  42. if (!stack)
  43. stack = regs->r1;
  44. return do_fork(flags, stack, regs, 0, NULL, NULL);
  45. }
  46. asmlinkage long microblaze_execve(const char __user *filenamei,
  47. const char __user *const __user *argv,
  48. const char __user *const __user *envp,
  49. struct pt_regs *regs)
  50. {
  51. int error;
  52. char *filename;
  53. filename = getname(filenamei);
  54. error = PTR_ERR(filename);
  55. if (IS_ERR(filename))
  56. goto out;
  57. error = do_execve(filename, argv, envp, regs);
  58. putname(filename);
  59. out:
  60. return error;
  61. }
  62. asmlinkage long sys_mmap(unsigned long addr, unsigned long len,
  63. unsigned long prot, unsigned long flags,
  64. unsigned long fd, off_t pgoff)
  65. {
  66. if (pgoff & ~PAGE_MASK)
  67. return -EINVAL;
  68. return sys_mmap_pgoff(addr, len, prot, flags, fd, pgoff >> PAGE_SHIFT);
  69. }
  70. /*
  71. * Do a system call from kernel instead of calling sys_execve so we
  72. * end up with proper pt_regs.
  73. */
  74. int kernel_execve(const char *filename,
  75. const char *const argv[],
  76. const char *const envp[])
  77. {
  78. register const char *__a __asm__("r5") = filename;
  79. register const void *__b __asm__("r6") = argv;
  80. register const void *__c __asm__("r7") = envp;
  81. register unsigned long __syscall __asm__("r12") = __NR_execve;
  82. register unsigned long __ret __asm__("r3");
  83. __asm__ __volatile__ ("brki r14, 0x8"
  84. : "=r" (__ret), "=r" (__syscall)
  85. : "1" (__syscall), "r" (__a), "r" (__b), "r" (__c)
  86. : "r4", "r8", "r9",
  87. "r10", "r11", "r14", "cc", "memory");
  88. return __ret;
  89. }