syscall.c 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /*
  2. * arch/xtensa/kernel/syscall.c
  3. *
  4. * This file is subject to the terms and conditions of the GNU General Public
  5. * License. See the file "COPYING" in the main directory of this archive
  6. * for more details.
  7. *
  8. * Copyright (C) 2001 - 2005 Tensilica Inc.
  9. * Copyright (C) 2000 Silicon Graphics, Inc.
  10. * Copyright (C) 1995 - 2000 by Ralf Baechle
  11. *
  12. * Joe Taylor <joe@tensilica.com, joetylr@yahoo.com>
  13. * Marc Gauthier <marc@tensilica.com, marc@alumni.uwaterloo.ca>
  14. * Chris Zankel <chris@zankel.net>
  15. * Kevin Chea
  16. *
  17. */
  18. #include <asm/uaccess.h>
  19. #include <asm/syscall.h>
  20. #include <asm/unistd.h>
  21. #include <linux/linkage.h>
  22. #include <linux/stringify.h>
  23. #include <linux/errno.h>
  24. #include <linux/syscalls.h>
  25. #include <linux/file.h>
  26. #include <linux/fs.h>
  27. #include <linux/mman.h>
  28. #include <linux/shm.h>
  29. typedef void (*syscall_t)(void);
  30. syscall_t sys_call_table[__NR_syscall_count] /* FIXME __cacheline_aligned */= {
  31. [0 ... __NR_syscall_count - 1] = (syscall_t)&sys_ni_syscall,
  32. #undef __SYSCALL
  33. #define __SYSCALL(nr,symbol,nargs) [ nr ] = (syscall_t)symbol,
  34. #undef _XTENSA_UNISTD_H
  35. #undef __KERNEL_SYSCALLS__
  36. #include <asm/unistd.h>
  37. };
  38. /*
  39. * xtensa_pipe() is the normal C calling standard for creating a pipe. It's not
  40. * the way unix traditional does this, though.
  41. */
  42. asmlinkage long xtensa_pipe(int __user *userfds)
  43. {
  44. int fd[2];
  45. int error;
  46. error = do_pipe_flags(fd, 0);
  47. if (!error) {
  48. if (copy_to_user(userfds, fd, 2 * sizeof(int)))
  49. error = -EFAULT;
  50. }
  51. return error;
  52. }
  53. asmlinkage long xtensa_mmap2(unsigned long addr, unsigned long len,
  54. unsigned long prot, unsigned long flags,
  55. unsigned long fd, unsigned long pgoff)
  56. {
  57. int error = -EBADF;
  58. struct file * file = NULL;
  59. flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
  60. if (!(flags & MAP_ANONYMOUS)) {
  61. file = fget(fd);
  62. if (!file)
  63. goto out;
  64. }
  65. down_write(&current->mm->mmap_sem);
  66. error = do_mmap_pgoff(file, addr, len, prot, flags, pgoff);
  67. up_write(&current->mm->mmap_sem);
  68. if (file)
  69. fput(file);
  70. out:
  71. return error;
  72. }
  73. asmlinkage long xtensa_shmat(int shmid, char __user *shmaddr, int shmflg)
  74. {
  75. unsigned long ret;
  76. long err;
  77. err = do_shmat(shmid, shmaddr, shmflg, &ret);
  78. if (err)
  79. return err;
  80. return (long)ret;
  81. }
  82. asmlinkage long xtensa_fadvise64_64(int fd, int advice, unsigned long long offset, unsigned long long len)
  83. {
  84. return sys_fadvise64_64(fd, offset, len, advice);
  85. }