compat.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  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. typedef u32 compat_uptr_t;
  39. struct compat_timespec {
  40. compat_time_t tv_sec;
  41. s32 tv_nsec;
  42. };
  43. struct compat_timeval {
  44. compat_time_t tv_sec;
  45. s32 tv_usec;
  46. };
  47. struct compat_stat {
  48. compat_dev_t st_dev;
  49. compat_ino_t st_ino;
  50. compat_mode_t st_mode;
  51. compat_nlink_t st_nlink;
  52. __compat_uid32_t st_uid;
  53. __compat_gid32_t st_gid;
  54. compat_dev_t st_rdev;
  55. compat_off_t st_size;
  56. compat_off_t st_blksize;
  57. compat_off_t st_blocks;
  58. compat_time_t st_atime;
  59. u32 st_atime_nsec;
  60. compat_time_t st_mtime;
  61. u32 st_mtime_nsec;
  62. compat_time_t st_ctime;
  63. u32 st_ctime_nsec;
  64. u32 __unused4[2];
  65. };
  66. struct compat_flock {
  67. short l_type;
  68. short l_whence;
  69. compat_off_t l_start;
  70. compat_off_t l_len;
  71. compat_pid_t l_pid;
  72. };
  73. #define F_GETLK64 12 /* using 'struct flock64' */
  74. #define F_SETLK64 13
  75. #define F_SETLKW64 14
  76. struct compat_flock64 {
  77. short l_type;
  78. short l_whence;
  79. compat_loff_t l_start;
  80. compat_loff_t l_len;
  81. compat_pid_t l_pid;
  82. };
  83. struct compat_statfs {
  84. int f_type;
  85. int f_bsize;
  86. int f_blocks;
  87. int f_bfree;
  88. int f_bavail;
  89. int f_files;
  90. int f_ffree;
  91. compat_fsid_t f_fsid;
  92. int f_namelen; /* SunOS ignores this field. */
  93. int f_frsize;
  94. int f_flags;
  95. int f_spare[4];
  96. };
  97. #define COMPAT_RLIM_OLD_INFINITY 0x7fffffff
  98. #define COMPAT_RLIM_INFINITY 0xffffffff
  99. typedef u32 compat_old_sigset_t;
  100. #define _COMPAT_NSIG 64
  101. #define _COMPAT_NSIG_BPW 32
  102. typedef u32 compat_sigset_word;
  103. typedef union compat_sigval {
  104. compat_int_t sival_int;
  105. compat_uptr_t sival_ptr;
  106. } compat_sigval_t;
  107. #define SI_PAD_SIZE32 (128/sizeof(int) - 3)
  108. typedef struct compat_siginfo {
  109. int si_signo;
  110. int si_errno;
  111. int si_code;
  112. union {
  113. int _pad[SI_PAD_SIZE32];
  114. /* kill() */
  115. struct {
  116. compat_pid_t _pid; /* sender's pid */
  117. __compat_uid_t _uid; /* sender's uid */
  118. } _kill;
  119. /* POSIX.1b timers */
  120. struct {
  121. compat_timer_t _tid; /* timer id */
  122. int _overrun; /* overrun count */
  123. compat_sigval_t _sigval; /* same as below */
  124. int _sys_private; /* not to be passed to user */
  125. } _timer;
  126. /* POSIX.1b signals */
  127. struct {
  128. compat_pid_t _pid; /* sender's pid */
  129. __compat_uid_t _uid; /* sender's uid */
  130. compat_sigval_t _sigval;
  131. } _rt;
  132. /* SIGCHLD */
  133. struct {
  134. compat_pid_t _pid; /* which child */
  135. __compat_uid_t _uid; /* sender's uid */
  136. int _status; /* exit code */
  137. compat_clock_t _utime;
  138. compat_clock_t _stime;
  139. } _sigchld;
  140. /* SIGILL, SIGFPE, SIGSEGV, SIGBUS, SIGEMT */
  141. struct {
  142. unsigned int _addr; /* faulting insn/memory ref. */
  143. } _sigfault;
  144. /* SIGPOLL */
  145. struct {
  146. int _band; /* POLL_IN, POLL_OUT, POLL_MSG */
  147. int _fd;
  148. } _sigpoll;
  149. } _sifields;
  150. } compat_siginfo_t;
  151. #define COMPAT_OFF_T_MAX 0x7fffffff
  152. #define COMPAT_LOFF_T_MAX 0x7fffffffffffffffL
  153. /*
  154. * A pointer passed in from user mode. This should not
  155. * be used for syscall parameters, just declare them
  156. * as pointers because the syscall entry code will have
  157. * appropriately converted them already.
  158. */
  159. static inline void __user *compat_ptr(compat_uptr_t uptr)
  160. {
  161. return (void __user *)(unsigned long)uptr;
  162. }
  163. static inline compat_uptr_t ptr_to_compat(void __user *uptr)
  164. {
  165. return (u32)(unsigned long)uptr;
  166. }
  167. static inline void __user *arch_compat_alloc_user_space(long len)
  168. {
  169. struct pt_regs *regs = current->thread.regs;
  170. unsigned long usp = regs->gpr[1];
  171. /*
  172. * We can't access below the stack pointer in the 32bit ABI and
  173. * can access 288 bytes in the 64bit ABI
  174. */
  175. if (!is_32bit_task())
  176. usp -= 288;
  177. return (void __user *) (usp - len);
  178. }
  179. /*
  180. * ipc64_perm is actually 32/64bit clean but since the compat layer refers to
  181. * it we may as well define it.
  182. */
  183. struct compat_ipc64_perm {
  184. compat_key_t key;
  185. __compat_uid_t uid;
  186. __compat_gid_t gid;
  187. __compat_uid_t cuid;
  188. __compat_gid_t cgid;
  189. compat_mode_t mode;
  190. unsigned int seq;
  191. unsigned int __pad2;
  192. unsigned long __unused1; /* yes they really are 64bit pads */
  193. unsigned long __unused2;
  194. };
  195. struct compat_semid64_ds {
  196. struct compat_ipc64_perm sem_perm;
  197. unsigned int __unused1;
  198. compat_time_t sem_otime;
  199. unsigned int __unused2;
  200. compat_time_t sem_ctime;
  201. compat_ulong_t sem_nsems;
  202. compat_ulong_t __unused3;
  203. compat_ulong_t __unused4;
  204. };
  205. struct compat_msqid64_ds {
  206. struct compat_ipc64_perm msg_perm;
  207. unsigned int __unused1;
  208. compat_time_t msg_stime;
  209. unsigned int __unused2;
  210. compat_time_t msg_rtime;
  211. unsigned int __unused3;
  212. compat_time_t msg_ctime;
  213. compat_ulong_t msg_cbytes;
  214. compat_ulong_t msg_qnum;
  215. compat_ulong_t msg_qbytes;
  216. compat_pid_t msg_lspid;
  217. compat_pid_t msg_lrpid;
  218. compat_ulong_t __unused4;
  219. compat_ulong_t __unused5;
  220. };
  221. struct compat_shmid64_ds {
  222. struct compat_ipc64_perm shm_perm;
  223. unsigned int __unused1;
  224. compat_time_t shm_atime;
  225. unsigned int __unused2;
  226. compat_time_t shm_dtime;
  227. unsigned int __unused3;
  228. compat_time_t shm_ctime;
  229. unsigned int __unused4;
  230. compat_size_t shm_segsz;
  231. compat_pid_t shm_cpid;
  232. compat_pid_t shm_lpid;
  233. compat_ulong_t shm_nattch;
  234. compat_ulong_t __unused5;
  235. compat_ulong_t __unused6;
  236. };
  237. static inline int is_compat_task(void)
  238. {
  239. return is_32bit_task();
  240. }
  241. #endif /* __KERNEL__ */
  242. #endif /* _ASM_POWERPC_COMPAT_H */