syscall.c 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /*
  2. * libc/sysdeps/linux/microblaze/syscall.c -- generic syscall function for linux/microblaze
  3. *
  4. * Copyright (C) 2003 John Williams <jwilliams@itee.uq.edu.au>
  5. * Copyright (C) 2002 NEC Corporation
  6. * Copyright (C) 2002 Miles Bader <miles@gnu.org>
  7. *
  8. * This file is subject to the terms and conditions of the GNU Lesser
  9. * General Public License. See the file COPYING.LIB in the main
  10. * directory of this archive for more details.
  11. *
  12. * Written by Miles Bader <miles@gnu.org>
  13. */
  14. #include <errno.h>
  15. #include <sys/syscall.h>
  16. typedef unsigned long arg_t;
  17. /* Invoke `system call' NUM, passing it the remaining arguments.
  18. This is completely system-dependent, and not often useful. */
  19. long
  20. syscall (long num, arg_t a1, arg_t a2, arg_t a3, arg_t a4, arg_t a5, arg_t a6)
  21. {
  22. /* We don't know how many arguments are valid, so A5 and A6 are fetched
  23. off the stack even for (the majority of) system calls with fewer
  24. arguments; hopefully this won't cause any problems. A1-A4 are in
  25. registers, so they're OK. */
  26. register arg_t a asm (SYSCALL_ARG0) = a1;
  27. register arg_t b asm (SYSCALL_ARG1) = a2;
  28. register arg_t c asm (SYSCALL_ARG2) = a3;
  29. register arg_t d asm (SYSCALL_ARG3) = a4;
  30. register arg_t e asm (SYSCALL_ARG4) = a5;
  31. register arg_t f asm (SYSCALL_ARG5) = a6;
  32. register unsigned long syscall asm (SYSCALL_NUM) = num;
  33. register unsigned long ret asm (SYSCALL_RET);
  34. unsigned long ret_sav;
  35. *((unsigned long *)0xFFFF4004) = (unsigned int)('+');
  36. asm ("brlid r17, 08x; nop;"
  37. : "=r" (ret)
  38. : "r" (syscall), "r" (a), "r" (b), "r" (c), "r" (d), "r" (e), "r" (f)
  39. : SYSCALL_CLOBBERS);
  40. ret_sav=ret;
  41. *((unsigned long *)0xFFFF4004) = (unsigned int)('-');
  42. __syscall_return (long, ret);
  43. }