compat.h 4.7 KB

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