unistd.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. #ifndef _ASM_PARISC_UNISTD_H_
  2. #define _ASM_PARISC_UNISTD_H_
  3. #include <uapi/asm/unistd.h>
  4. #ifndef __ASSEMBLY__
  5. #define SYS_ify(syscall_name) __NR_##syscall_name
  6. #ifndef ASM_LINE_SEP
  7. # define ASM_LINE_SEP ;
  8. #endif
  9. /* Definition taken from glibc 2.3.3
  10. * sysdeps/unix/sysv/linux/hppa/sysdep.h
  11. */
  12. #ifdef PIC
  13. /* WARNING: CANNOT BE USED IN A NOP! */
  14. # define K_STW_ASM_PIC " copy %%r19, %%r4\n"
  15. # define K_LDW_ASM_PIC " copy %%r4, %%r19\n"
  16. # define K_USING_GR4 "%r4",
  17. #else
  18. # define K_STW_ASM_PIC " \n"
  19. # define K_LDW_ASM_PIC " \n"
  20. # define K_USING_GR4
  21. #endif
  22. /* GCC has to be warned that a syscall may clobber all the ABI
  23. registers listed as "caller-saves", see page 8, Table 2
  24. in section 2.2.6 of the PA-RISC RUN-TIME architecture
  25. document. However! r28 is the result and will conflict with
  26. the clobber list so it is left out. Also the input arguments
  27. registers r20 -> r26 will conflict with the list so they
  28. are treated specially. Although r19 is clobbered by the syscall
  29. we cannot say this because it would violate ABI, thus we say
  30. r4 is clobbered and use that register to save/restore r19
  31. across the syscall. */
  32. #define K_CALL_CLOB_REGS "%r1", "%r2", K_USING_GR4 \
  33. "%r20", "%r29", "%r31"
  34. #undef K_INLINE_SYSCALL
  35. #define K_INLINE_SYSCALL(name, nr, args...) ({ \
  36. long __sys_res; \
  37. { \
  38. register unsigned long __res __asm__("r28"); \
  39. K_LOAD_ARGS_##nr(args) \
  40. /* FIXME: HACK stw/ldw r19 around syscall */ \
  41. __asm__ volatile( \
  42. K_STW_ASM_PIC \
  43. " ble 0x100(%%sr2, %%r0)\n" \
  44. " ldi %1, %%r20\n" \
  45. K_LDW_ASM_PIC \
  46. : "=r" (__res) \
  47. : "i" (SYS_ify(name)) K_ASM_ARGS_##nr \
  48. : "memory", K_CALL_CLOB_REGS K_CLOB_ARGS_##nr \
  49. ); \
  50. __sys_res = (long)__res; \
  51. } \
  52. if ( (unsigned long)__sys_res >= (unsigned long)-4095 ){ \
  53. errno = -__sys_res; \
  54. __sys_res = -1; \
  55. } \
  56. __sys_res; \
  57. })
  58. #define K_LOAD_ARGS_0()
  59. #define K_LOAD_ARGS_1(r26) \
  60. register unsigned long __r26 __asm__("r26") = (unsigned long)(r26); \
  61. K_LOAD_ARGS_0()
  62. #define K_LOAD_ARGS_2(r26,r25) \
  63. register unsigned long __r25 __asm__("r25") = (unsigned long)(r25); \
  64. K_LOAD_ARGS_1(r26)
  65. #define K_LOAD_ARGS_3(r26,r25,r24) \
  66. register unsigned long __r24 __asm__("r24") = (unsigned long)(r24); \
  67. K_LOAD_ARGS_2(r26,r25)
  68. #define K_LOAD_ARGS_4(r26,r25,r24,r23) \
  69. register unsigned long __r23 __asm__("r23") = (unsigned long)(r23); \
  70. K_LOAD_ARGS_3(r26,r25,r24)
  71. #define K_LOAD_ARGS_5(r26,r25,r24,r23,r22) \
  72. register unsigned long __r22 __asm__("r22") = (unsigned long)(r22); \
  73. K_LOAD_ARGS_4(r26,r25,r24,r23)
  74. #define K_LOAD_ARGS_6(r26,r25,r24,r23,r22,r21) \
  75. register unsigned long __r21 __asm__("r21") = (unsigned long)(r21); \
  76. K_LOAD_ARGS_5(r26,r25,r24,r23,r22)
  77. /* Even with zero args we use r20 for the syscall number */
  78. #define K_ASM_ARGS_0
  79. #define K_ASM_ARGS_1 K_ASM_ARGS_0, "r" (__r26)
  80. #define K_ASM_ARGS_2 K_ASM_ARGS_1, "r" (__r25)
  81. #define K_ASM_ARGS_3 K_ASM_ARGS_2, "r" (__r24)
  82. #define K_ASM_ARGS_4 K_ASM_ARGS_3, "r" (__r23)
  83. #define K_ASM_ARGS_5 K_ASM_ARGS_4, "r" (__r22)
  84. #define K_ASM_ARGS_6 K_ASM_ARGS_5, "r" (__r21)
  85. /* The registers not listed as inputs but clobbered */
  86. #define K_CLOB_ARGS_6
  87. #define K_CLOB_ARGS_5 K_CLOB_ARGS_6, "%r21"
  88. #define K_CLOB_ARGS_4 K_CLOB_ARGS_5, "%r22"
  89. #define K_CLOB_ARGS_3 K_CLOB_ARGS_4, "%r23"
  90. #define K_CLOB_ARGS_2 K_CLOB_ARGS_3, "%r24"
  91. #define K_CLOB_ARGS_1 K_CLOB_ARGS_2, "%r25"
  92. #define K_CLOB_ARGS_0 K_CLOB_ARGS_1, "%r26"
  93. #define _syscall0(type,name) \
  94. type name(void) \
  95. { \
  96. return K_INLINE_SYSCALL(name, 0); \
  97. }
  98. #define _syscall1(type,name,type1,arg1) \
  99. type name(type1 arg1) \
  100. { \
  101. return K_INLINE_SYSCALL(name, 1, arg1); \
  102. }
  103. #define _syscall2(type,name,type1,arg1,type2,arg2) \
  104. type name(type1 arg1, type2 arg2) \
  105. { \
  106. return K_INLINE_SYSCALL(name, 2, arg1, arg2); \
  107. }
  108. #define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
  109. type name(type1 arg1, type2 arg2, type3 arg3) \
  110. { \
  111. return K_INLINE_SYSCALL(name, 3, arg1, arg2, arg3); \
  112. }
  113. #define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
  114. type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4) \
  115. { \
  116. return K_INLINE_SYSCALL(name, 4, arg1, arg2, arg3, arg4); \
  117. }
  118. /* select takes 5 arguments */
  119. #define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5) \
  120. type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5) \
  121. { \
  122. return K_INLINE_SYSCALL(name, 5, arg1, arg2, arg3, arg4, arg5); \
  123. }
  124. #define __ARCH_WANT_OLD_READDIR
  125. #define __ARCH_WANT_STAT64
  126. #define __ARCH_WANT_SYS_ALARM
  127. #define __ARCH_WANT_SYS_GETHOSTNAME
  128. #define __ARCH_WANT_SYS_PAUSE
  129. #define __ARCH_WANT_SYS_SIGNAL
  130. #define __ARCH_WANT_SYS_TIME
  131. #define __ARCH_WANT_COMPAT_SYS_TIME
  132. #define __ARCH_WANT_COMPAT_SYS_SCHED_RR_GET_INTERVAL
  133. #define __ARCH_WANT_SYS_UTIME
  134. #define __ARCH_WANT_SYS_WAITPID
  135. #define __ARCH_WANT_SYS_SOCKETCALL
  136. #define __ARCH_WANT_SYS_FADVISE64
  137. #define __ARCH_WANT_SYS_GETPGRP
  138. #define __ARCH_WANT_SYS_LLSEEK
  139. #define __ARCH_WANT_SYS_NICE
  140. #define __ARCH_WANT_SYS_OLD_GETRLIMIT
  141. #define __ARCH_WANT_SYS_OLDUMOUNT
  142. #define __ARCH_WANT_SYS_SIGPENDING
  143. #define __ARCH_WANT_SYS_SIGPROCMASK
  144. #define __ARCH_WANT_SYS_FORK
  145. #define __ARCH_WANT_SYS_VFORK
  146. #define __ARCH_WANT_SYS_CLONE
  147. #define __ARCH_WANT_COMPAT_SYS_SENDFILE
  148. #endif /* __ASSEMBLY__ */
  149. #undef STR
  150. #endif /* _ASM_PARISC_UNISTD_H_ */