compat.h 4.7 KB

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