compat.h 4.3 KB

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