compat.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. #ifndef _ASM_PPC64_COMPAT_H
  2. #define _ASM_PPC64_COMPAT_H
  3. /*
  4. * Architecture specific compatibility types
  5. */
  6. #include <linux/types.h>
  7. #include <linux/sched.h>
  8. #define COMPAT_USER_HZ 100
  9. typedef u32 compat_size_t;
  10. typedef s32 compat_ssize_t;
  11. typedef s32 compat_time_t;
  12. typedef s32 compat_clock_t;
  13. typedef s32 compat_pid_t;
  14. typedef u32 compat_uid_t;
  15. typedef u32 compat_gid_t;
  16. typedef u32 compat_mode_t;
  17. typedef u32 compat_ino_t;
  18. typedef u32 compat_dev_t;
  19. typedef s32 compat_off_t;
  20. typedef s64 compat_loff_t;
  21. typedef s16 compat_nlink_t;
  22. typedef u16 compat_ipc_pid_t;
  23. typedef s32 compat_daddr_t;
  24. typedef u32 compat_caddr_t;
  25. typedef __kernel_fsid_t compat_fsid_t;
  26. typedef s32 compat_key_t;
  27. typedef s32 compat_timer_t;
  28. typedef s32 compat_int_t;
  29. typedef s32 compat_long_t;
  30. typedef u32 compat_uint_t;
  31. typedef u32 compat_ulong_t;
  32. struct compat_timespec {
  33. compat_time_t tv_sec;
  34. s32 tv_nsec;
  35. };
  36. struct compat_timeval {
  37. compat_time_t tv_sec;
  38. s32 tv_usec;
  39. };
  40. struct compat_stat {
  41. compat_dev_t st_dev;
  42. compat_ino_t st_ino;
  43. compat_mode_t st_mode;
  44. compat_nlink_t st_nlink;
  45. compat_uid_t st_uid;
  46. compat_gid_t st_gid;
  47. compat_dev_t st_rdev;
  48. compat_off_t st_size;
  49. compat_off_t st_blksize;
  50. compat_off_t st_blocks;
  51. compat_time_t st_atime;
  52. u32 st_atime_nsec;
  53. compat_time_t st_mtime;
  54. u32 st_mtime_nsec;
  55. compat_time_t st_ctime;
  56. u32 st_ctime_nsec;
  57. u32 __unused4[2];
  58. };
  59. struct compat_flock {
  60. short l_type;
  61. short l_whence;
  62. compat_off_t l_start;
  63. compat_off_t l_len;
  64. compat_pid_t l_pid;
  65. };
  66. #define F_GETLK64 12 /* using 'struct flock64' */
  67. #define F_SETLK64 13
  68. #define F_SETLKW64 14
  69. struct compat_flock64 {
  70. short l_type;
  71. short l_whence;
  72. compat_loff_t l_start;
  73. compat_loff_t l_len;
  74. compat_pid_t l_pid;
  75. };
  76. struct compat_statfs {
  77. int f_type;
  78. int f_bsize;
  79. int f_blocks;
  80. int f_bfree;
  81. int f_bavail;
  82. int f_files;
  83. int f_ffree;
  84. compat_fsid_t f_fsid;
  85. int f_namelen; /* SunOS ignores this field. */
  86. int f_frsize;
  87. int f_spare[5];
  88. };
  89. #define COMPAT_RLIM_OLD_INFINITY 0x7fffffff
  90. #define COMPAT_RLIM_INFINITY 0xffffffff
  91. typedef u32 compat_old_sigset_t;
  92. #define _COMPAT_NSIG 64
  93. #define _COMPAT_NSIG_BPW 32
  94. typedef u32 compat_sigset_word;
  95. #define COMPAT_OFF_T_MAX 0x7fffffff
  96. #define COMPAT_LOFF_T_MAX 0x7fffffffffffffffL
  97. /*
  98. * A pointer passed in from user mode. This should not
  99. * be used for syscall parameters, just declare them
  100. * as pointers because the syscall entry code will have
  101. * appropriately comverted them already.
  102. */
  103. typedef u32 compat_uptr_t;
  104. static inline void __user *compat_ptr(compat_uptr_t uptr)
  105. {
  106. return (void __user *)(unsigned long)uptr;
  107. }
  108. static inline void __user *compat_alloc_user_space(long len)
  109. {
  110. struct pt_regs *regs = current->thread.regs;
  111. unsigned long usp = regs->gpr[1];
  112. /*
  113. * We cant access below the stack pointer in the 32bit ABI and
  114. * can access 288 bytes in the 64bit ABI
  115. */
  116. if (!(test_thread_flag(TIF_32BIT)))
  117. usp -= 288;
  118. return (void __user *) (usp - len);
  119. }
  120. /*
  121. * ipc64_perm is actually 32/64bit clean but since the compat layer refers to
  122. * it we may as well define it.
  123. */
  124. struct compat_ipc64_perm {
  125. compat_key_t key;
  126. compat_uid_t uid;
  127. compat_gid_t gid;
  128. compat_uid_t cuid;
  129. compat_gid_t cgid;
  130. compat_mode_t mode;
  131. unsigned int seq;
  132. unsigned int __pad2;
  133. unsigned long __unused1; /* yes they really are 64bit pads */
  134. unsigned long __unused2;
  135. };
  136. struct compat_semid64_ds {
  137. struct compat_ipc64_perm sem_perm;
  138. unsigned int __unused1;
  139. compat_time_t sem_otime;
  140. unsigned int __unused2;
  141. compat_time_t sem_ctime;
  142. compat_ulong_t sem_nsems;
  143. compat_ulong_t __unused3;
  144. compat_ulong_t __unused4;
  145. };
  146. struct compat_msqid64_ds {
  147. struct compat_ipc64_perm msg_perm;
  148. unsigned int __unused1;
  149. compat_time_t msg_stime;
  150. unsigned int __unused2;
  151. compat_time_t msg_rtime;
  152. unsigned int __unused3;
  153. compat_time_t msg_ctime;
  154. compat_ulong_t msg_cbytes;
  155. compat_ulong_t msg_qnum;
  156. compat_ulong_t msg_qbytes;
  157. compat_pid_t msg_lspid;
  158. compat_pid_t msg_lrpid;
  159. compat_ulong_t __unused4;
  160. compat_ulong_t __unused5;
  161. };
  162. struct compat_shmid64_ds {
  163. struct compat_ipc64_perm shm_perm;
  164. unsigned int __unused1;
  165. compat_time_t shm_atime;
  166. unsigned int __unused2;
  167. compat_time_t shm_dtime;
  168. unsigned int __unused3;
  169. compat_time_t shm_ctime;
  170. unsigned int __unused4;
  171. compat_size_t shm_segsz;
  172. compat_pid_t shm_cpid;
  173. compat_pid_t shm_lpid;
  174. compat_ulong_t shm_nattch;
  175. compat_ulong_t __unused5;
  176. compat_ulong_t __unused6;
  177. };
  178. #endif /* _ASM_PPC64_COMPAT_H */