vki-ppc64-linux.h 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815
  1. /*--------------------------------------------------------------------*/
  2. /*--- PPC64/Linux-specific kernel interface. vki-ppc64-linux.h ---*/
  3. /*--------------------------------------------------------------------*/
  4. /*
  5. This file is part of Valgrind, a dynamic binary instrumentation
  6. framework.
  7. Copyright (C) 2005-2017 Julian Seward
  8. jseward@acm.org
  9. This program is free software; you can redistribute it and/or
  10. modify it under the terms of the GNU General Public License as
  11. published by the Free Software Foundation; either version 2 of the
  12. License, or (at your option) any later version.
  13. This program is distributed in the hope that it will be useful, but
  14. WITHOUT ANY WARRANTY; without even the implied warranty of
  15. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. General Public License for more details.
  17. You should have received a copy of the GNU General Public License
  18. along with this program; if not, write to the Free Software
  19. Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  20. 02111-1307, USA.
  21. The GNU General Public License is contained in the file COPYING.
  22. */
  23. #ifndef __VKI_PPC64_LINUX_H
  24. #define __VKI_PPC64_LINUX_H
  25. #if defined(VGP_ppc32_linux) || defined(VGP_ppc64be_linux)
  26. #define VKI_BIG_ENDIAN 1
  27. #elif defined(VGP_ppc64le_linux)
  28. #define VKI_LITTLE_ENDIAN 1
  29. #endif
  30. //----------------------------------------------------------------------
  31. // From linux-2.6.13/include/asm-ppc64/types.h
  32. //----------------------------------------------------------------------
  33. typedef __signed__ char __vki_s8;
  34. typedef unsigned char __vki_u8;
  35. typedef __signed__ short __vki_s16;
  36. typedef unsigned short __vki_u16;
  37. typedef __signed__ int __vki_s32;
  38. typedef unsigned int __vki_u32;
  39. typedef __signed__ long __vki_s64;
  40. typedef unsigned long __vki_u64;
  41. typedef struct {
  42. __vki_u32 u[4];
  43. } __attribute((aligned(16))) __vki_vector128;
  44. typedef unsigned short vki_u16;
  45. typedef unsigned int vki_u32;
  46. //----------------------------------------------------------------------
  47. // From linux-2.6.13/include/asm-ppc64/page.h
  48. //----------------------------------------------------------------------
  49. /* PAGE_SHIFT determines the page size, unfortunately
  50. page size might vary between 32-bit and 64-bit ppc kernels */
  51. extern UWord VKI_PAGE_SHIFT;
  52. extern UWord VKI_PAGE_SIZE;
  53. #define VKI_MAX_PAGE_SHIFT 16
  54. #define VKI_MAX_PAGE_SIZE (1UL << VKI_MAX_PAGE_SHIFT)
  55. //----------------------------------------------------------------------
  56. // From linux-2.6.35.4/arch/powerpc/include/asm/shmparam.h
  57. //----------------------------------------------------------------------
  58. #define VKI_SHMLBA VKI_PAGE_SIZE
  59. //----------------------------------------------------------------------
  60. // From linux-2.6.13/include/asm-ppc64/signal.h
  61. //----------------------------------------------------------------------
  62. #define VKI_MINSIGSTKSZ 2048
  63. /* Next 9 non-blank lines asm-generic/signal.h */
  64. #define VKI_SIG_BLOCK 0 /* for blocking signals */
  65. #define VKI_SIG_UNBLOCK 1 /* for unblocking signals */
  66. #define VKI_SIG_SETMASK 2 /* for setting the signal mask */
  67. typedef void __vki_signalfn_t(int);
  68. typedef __vki_signalfn_t __user *__vki_sighandler_t;
  69. typedef void __vki_restorefn_t(void);
  70. typedef __vki_restorefn_t __user *__vki_sigrestore_t;
  71. #define VKI_SIG_DFL ((__vki_sighandler_t)0) /* default signal handling */
  72. #define VKI_SIG_IGN ((__vki_sighandler_t)1) /* ignore signal */
  73. /* Back in asm-ppc64/signal.h */
  74. #define _VKI_NSIG 64
  75. #define _VKI_NSIG_BPW 64
  76. #define _VKI_NSIG_WORDS (_VKI_NSIG / _VKI_NSIG_BPW)
  77. typedef unsigned long vki_old_sigset_t; /* at least 32 bits */
  78. typedef struct {
  79. unsigned long sig[_VKI_NSIG_WORDS];
  80. } vki_sigset_t;
  81. #define VKI_SIGHUP 1
  82. #define VKI_SIGINT 2
  83. #define VKI_SIGQUIT 3
  84. #define VKI_SIGILL 4
  85. #define VKI_SIGTRAP 5
  86. #define VKI_SIGABRT 6
  87. #define VKI_SIGIOT 6
  88. #define VKI_SIGBUS 7
  89. #define VKI_SIGFPE 8
  90. #define VKI_SIGKILL 9
  91. #define VKI_SIGUSR1 10
  92. #define VKI_SIGSEGV 11
  93. #define VKI_SIGUSR2 12
  94. #define VKI_SIGPIPE 13
  95. #define VKI_SIGALRM 14
  96. #define VKI_SIGTERM 15
  97. #define VKI_SIGSTKFLT 16
  98. #define VKI_SIGCHLD 17
  99. #define VKI_SIGCONT 18
  100. #define VKI_SIGSTOP 19
  101. #define VKI_SIGTSTP 20
  102. #define VKI_SIGTTIN 21
  103. #define VKI_SIGTTOU 22
  104. #define VKI_SIGURG 23
  105. #define VKI_SIGXCPU 24
  106. #define VKI_SIGXFSZ 25
  107. #define VKI_SIGVTALRM 26
  108. #define VKI_SIGPROF 27
  109. #define VKI_SIGWINCH 28
  110. #define VKI_SIGIO 29
  111. #define VKI_SIGPOLL VKI_SIGIO
  112. #define VKI_SIGPWR 30
  113. #define VKI_SIGSYS 31
  114. #define VKI_SIGUNUSED 31
  115. /* These should not be considered constants from userland. */
  116. #define VKI_SIGRTMIN 32
  117. #define VKI_SIGRTMAX _VKI_NSIG
  118. #define VKI_SA_NOCLDSTOP 0x00000001u
  119. #define VKI_SA_NOCLDWAIT 0x00000002u
  120. #define VKI_SA_SIGINFO 0x00000004u
  121. #define VKI_SA_ONSTACK 0x08000000u
  122. #define VKI_SA_RESTART 0x10000000u
  123. #define VKI_SA_NODEFER 0x40000000u
  124. #define VKI_SA_RESETHAND 0x80000000u
  125. #define VKI_SA_NOMASK VKI_SA_NODEFER
  126. #define VKI_SA_ONESHOT VKI_SA_RESETHAND
  127. //#define VKI_SA_INTERRUPT 0x20000000u /* dummy -- ignored */
  128. #define VKI_SA_RESTORER 0x04000000u
  129. #define VKI_SS_ONSTACK 1
  130. #define VKI_SS_DISABLE 2
  131. // See comments on corresponding decls in vki-x86-linux.h re ksa_handler
  132. struct vki_old_sigaction {
  133. __vki_sighandler_t ksa_handler;
  134. vki_old_sigset_t sa_mask;
  135. unsigned long sa_flags;
  136. __vki_sigrestore_t sa_restorer;
  137. };
  138. struct vki_sigaction_base {
  139. __vki_sighandler_t ksa_handler;
  140. unsigned long sa_flags;
  141. __vki_sigrestore_t sa_restorer;
  142. vki_sigset_t sa_mask; /* mask last for extensibility */
  143. };
  144. /* On Linux we use the same type for passing sigactions to
  145. and from the kernel. Hence: */
  146. typedef struct vki_sigaction_base vki_sigaction_toK_t;
  147. typedef struct vki_sigaction_base vki_sigaction_fromK_t;
  148. typedef struct vki_sigaltstack {
  149. void __user *ss_sp;
  150. int ss_flags;
  151. vki_size_t ss_size;
  152. } vki_stack_t;
  153. //----------------------------------------------------------------------
  154. // From linux-2.6.13/include/asm-ppc64/ptrace.h
  155. //----------------------------------------------------------------------
  156. #define VKI_PPC_REG unsigned long
  157. struct vki_pt_regs {
  158. VKI_PPC_REG gpr[32];
  159. VKI_PPC_REG nip;
  160. VKI_PPC_REG msr;
  161. VKI_PPC_REG orig_gpr3; /* Used for restarting system calls */
  162. VKI_PPC_REG ctr;
  163. VKI_PPC_REG link;
  164. VKI_PPC_REG xer;
  165. VKI_PPC_REG ccr;
  166. VKI_PPC_REG softe; /* Soft enabled/disabled */
  167. VKI_PPC_REG trap; /* Reason for being here */
  168. VKI_PPC_REG dar; /* Fault registers */
  169. VKI_PPC_REG dsisr;
  170. VKI_PPC_REG result; /* Result of a system call */
  171. /* Not in kernel's definition, but apparently needed to stop
  172. assertion at coredump-elf.c:267 firing. These padding words make
  173. the struct have the same size as a 'vki_elf_greg_t'. See message
  174. from Ghassan Hammouri on valgrind-developers on 6 April 06, and
  175. also the analogous kludge for ppc32-linux (svn r5852 and bug
  176. #121617). */
  177. unsigned long pad[4];
  178. };
  179. /* Kludge? I don't know where this came from or if it is right. */
  180. #define vki_user_regs_struct vki_pt_regs
  181. #define VKI_PT_R0 0
  182. #define VKI_PT_R1 1
  183. #define VKI_PT_R2 2
  184. #define VKI_PT_R3 3
  185. #define VKI_PT_R4 4
  186. #define VKI_PT_R5 5
  187. #define VKI_PT_R6 6
  188. #define VKI_PT_R7 7
  189. #define VKI_PT_R8 8
  190. #define VKI_PT_R9 9
  191. #define VKI_PT_R10 10
  192. #define VKI_PT_R11 11
  193. #define VKI_PT_R12 12
  194. #define VKI_PT_R13 13
  195. #define VKI_PT_R14 14
  196. #define VKI_PT_R15 15
  197. #define VKI_PT_R16 16
  198. #define VKI_PT_R17 17
  199. #define VKI_PT_R18 18
  200. #define VKI_PT_R19 19
  201. #define VKI_PT_R20 20
  202. #define VKI_PT_R21 21
  203. #define VKI_PT_R22 22
  204. #define VKI_PT_R23 23
  205. #define VKI_PT_R24 24
  206. #define VKI_PT_R25 25
  207. #define VKI_PT_R26 26
  208. #define VKI_PT_R27 27
  209. #define VKI_PT_R28 28
  210. #define VKI_PT_R29 29
  211. #define VKI_PT_R30 30
  212. #define VKI_PT_R31 31
  213. #define VKI_PT_NIP 32
  214. #define VKI_PT_MSR 33
  215. #define VKI_PT_ORIG_R3 34
  216. #define VKI_PT_CTR 35
  217. #define VKI_PT_LNK 36
  218. #define VKI_PT_XER 37
  219. #define VKI_PT_CCR 38
  220. #define VKI_PT_SOFTE 39
  221. #define VKI_PT_RESULT 43
  222. //----------------------------------------------------------------------
  223. // From linux-2.6.13/include/asm-ppc64/elf.h
  224. //----------------------------------------------------------------------
  225. #define VKI_ELF_NGREG 48 /* includes nip, msr, lr, etc. */
  226. #define VKI_ELF_NFPREG 33 /* includes fpscr */
  227. #define VKI_ELF_NVRREG 34 /* includes vscr & vrsave in split vectors */
  228. typedef unsigned long vki_elf_greg_t64;
  229. typedef vki_elf_greg_t64 vki_elf_gregset_t64[VKI_ELF_NGREG];
  230. typedef vki_elf_gregset_t64 vki_elf_gregset_t;
  231. typedef double vki_elf_fpreg_t;
  232. typedef vki_elf_fpreg_t vki_elf_fpregset_t[VKI_ELF_NFPREG];
  233. /* Altivec registers */
  234. /*
  235. * The entries with indexes 0-31 contain the corresponding vector registers.
  236. * The entry with index 32 contains the vscr as the last word (offset 12)
  237. * within the quadword. This allows the vscr to be stored as either a
  238. * quadword (since it must be copied via a vector register to/from storage)
  239. * or as a word. The entry with index 33 contains the vrsave as the first
  240. * word (offset 0) within the quadword.
  241. *
  242. * This definition of the VMX state is compatible with the current PPC32
  243. * ptrace interface. This allows signal handling and ptrace to use the same
  244. * structures. This also simplifies the implementation of a bi-arch
  245. * (combined (32- and 64-bit) gdb.
  246. *
  247. * Note that it's _not_ compatible with 32 bits ucontext which stuffs the
  248. * vrsave along with vscr and so only uses 33 vectors for the register set
  249. */
  250. typedef __vki_vector128 vki_elf_vrreg_t;
  251. typedef vki_elf_vrreg_t vki_elf_vrregset_t[VKI_ELF_NVRREG];
  252. //----------------------------------------------------------------------
  253. // From linux-2.6.13/include/asm-ppc64/sigcontext.h
  254. //----------------------------------------------------------------------
  255. struct vki_sigcontext {
  256. unsigned long _unused[4];
  257. int signal;
  258. int _pad0;
  259. unsigned long handler;
  260. unsigned long oldmask;
  261. struct vki_pt_regs __user *regs;
  262. vki_elf_gregset_t gp_regs;
  263. vki_elf_fpregset_t fp_regs;
  264. /*
  265. * To maintain compatibility with current implementations the sigcontext is
  266. * extended by appending a pointer (v_regs) to a quadword type (elf_vrreg_t)
  267. * followed by an unstructured (vmx_reserve) field of 69 doublewords. This
  268. * allows the array of vector registers to be quadword aligned independent of
  269. * the alignment of the containing sigcontext or ucontext. It is the
  270. * responsibility of the code setting the sigcontext to set this pointer to
  271. * either NULL (if this processor does not support the VMX feature) or the
  272. * address of the first quadword within the allocated (vmx_reserve) area.
  273. *
  274. * The pointer (v_regs) of vector type (elf_vrreg_t) is type compatible with
  275. * an array of 34 quadword entries (elf_vrregset_t). The entries with
  276. * indexes 0-31 contain the corresponding vector registers. The entry with
  277. * index 32 contains the vscr as the last word (offset 12) within the
  278. * quadword. This allows the vscr to be stored as either a quadword (since
  279. * it must be copied via a vector register to/from storage) or as a word.
  280. * The entry with index 33 contains the vrsave as the first word (offset 0)
  281. * within the quadword.
  282. */
  283. vki_elf_vrreg_t __user *v_regs;
  284. long vmx_reserve[VKI_ELF_NVRREG+VKI_ELF_NVRREG+1];
  285. };
  286. //----------------------------------------------------------------------
  287. // From linux-2.6.13/include/asm-ppc64/mman.h
  288. //----------------------------------------------------------------------
  289. #define VKI_PROT_NONE 0x0 /* page can not be accessed */
  290. #define VKI_PROT_READ 0x1 /* page can be read */
  291. #define VKI_PROT_WRITE 0x2 /* page can be written */
  292. #define VKI_PROT_EXEC 0x4 /* page can be executed */
  293. #define VKI_PROT_GROWSDOWN 0x01000000 /* mprotect flag: extend
  294. change to start of
  295. growsdown vma */
  296. #define VKI_PROT_GROWSUP 0x02000000 /* mprotect flag: extend
  297. change to end of
  298. growsup vma */
  299. #define VKI_MAP_SHARED 0x01 /* Share changes */
  300. #define VKI_MAP_PRIVATE 0x02 /* Changes are private */
  301. #define VKI_MAP_FIXED 0x10 /* Interpret addr exactly */
  302. #define VKI_MAP_ANONYMOUS 0x20 /* don't use a file */
  303. #define VKI_MAP_NORESERVE 0x40 /* don't reserve swap pages */
  304. //----------------------------------------------------------------------
  305. // From linux-2.6.13/include/asm-ppc64/fcntl.h
  306. //----------------------------------------------------------------------
  307. #define VKI_O_ACCMODE 03
  308. #define VKI_O_RDONLY 00
  309. #define VKI_O_WRONLY 01
  310. #define VKI_O_RDWR 02
  311. #define VKI_O_CREAT 0100 /* not fcntl */
  312. #define VKI_O_EXCL 0200 /* not fcntl */
  313. #define VKI_O_TRUNC 01000 /* not fcntl */
  314. #define VKI_O_APPEND 02000
  315. #define VKI_O_NONBLOCK 04000
  316. #define VKI_O_LARGEFILE 0200000
  317. #define VKI_AT_FDCWD -100
  318. #define VKI_F_DUPFD 0 /* dup */
  319. #define VKI_F_GETFD 1 /* get close_on_exec */
  320. #define VKI_F_SETFD 2 /* set/clear close_on_exec */
  321. #define VKI_F_GETFL 3 /* get file->f_flags */
  322. #define VKI_F_SETFL 4 /* set file->f_flags */
  323. #define VKI_F_GETLK 5
  324. #define VKI_F_SETLK 6
  325. #define VKI_F_SETLKW 7
  326. #define VKI_F_SETOWN 8 /* for sockets. */
  327. #define VKI_F_GETOWN 9 /* for sockets. */
  328. #define VKI_F_SETSIG 10 /* for sockets. */
  329. #define VKI_F_GETSIG 11 /* for sockets. */
  330. #define VKI_F_SETOWN_EX 15
  331. #define VKI_F_GETOWN_EX 16
  332. #define VKI_F_OFD_GETLK 36
  333. #define VKI_F_OFD_SETLK 37
  334. #define VKI_F_OFD_SETLKW 38
  335. #define VKI_F_OWNER_TID 0
  336. #define VKI_F_OWNER_PID 1
  337. #define VKI_F_OWNER_PGRP 2
  338. struct vki_f_owner_ex {
  339. int type;
  340. __vki_kernel_pid_t pid;
  341. };
  342. /* for F_[GET|SET]FL */
  343. #define VKI_FD_CLOEXEC 1 /* actually anything with low bit set goes */
  344. #define VKI_F_LINUX_SPECIFIC_BASE 1024
  345. //----------------------------------------------------------------------
  346. // From linux-2.6.13/include/asm-ppc64/resource.h
  347. //----------------------------------------------------------------------
  348. // which just does #include <asm-generic/resource.h>
  349. #define VKI_RLIMIT_DATA 2 /* max data size */
  350. #define VKI_RLIMIT_STACK 3 /* max stack size */
  351. #define VKI_RLIMIT_CORE 4 /* max core file size */
  352. #define VKI_RLIMIT_NOFILE 7 /* max number of open files */
  353. //----------------------------------------------------------------------
  354. // From linux-2.6.13/include/asm-ppc64/socket.h
  355. //----------------------------------------------------------------------
  356. #define VKI_SOL_SOCKET 1
  357. #define VKI_SO_TYPE 3
  358. #define VKI_SO_ATTACH_FILTER 26
  359. //----------------------------------------------------------------------
  360. // From linux-2.6.13/include/asm-ppc64/sockios.h
  361. //----------------------------------------------------------------------
  362. #define VKI_SIOCSPGRP 0x8902
  363. #define VKI_SIOCGPGRP 0x8904
  364. #define VKI_SIOCATMARK 0x8905
  365. #define VKI_SIOCGSTAMP 0x8906 /* Get stamp (timeval) */
  366. #define VKI_SIOCGSTAMPNS 0x8907 /* Get stamp (timespec) */
  367. //----------------------------------------------------------------------
  368. // From linux-2.6.13/include/asm-ppc64/stat.h
  369. //----------------------------------------------------------------------
  370. struct vki_stat {
  371. unsigned long st_dev;
  372. unsigned long st_ino;
  373. unsigned long st_nlink;
  374. unsigned int st_mode;
  375. unsigned int st_uid;
  376. unsigned int st_gid;
  377. unsigned long st_rdev;
  378. long st_size;
  379. unsigned long st_blksize;
  380. unsigned long st_blocks;
  381. unsigned long st_atime;
  382. unsigned long st_atime_nsec;
  383. unsigned long st_mtime;
  384. unsigned long st_mtime_nsec;
  385. unsigned long st_ctime;
  386. unsigned long st_ctime_nsec;
  387. unsigned long __unused4;
  388. unsigned long __unused5;
  389. unsigned long __unused6;
  390. };
  391. #define VKI_STAT_HAVE_NSEC 1
  392. /* This matches struct stat64 in glibc2.1. Only used for 32 bit. */
  393. struct vki_stat64 {
  394. unsigned long st_dev; /* Device. */
  395. unsigned long st_ino; /* File serial number. */
  396. unsigned int st_mode; /* File mode. */
  397. unsigned int st_nlink; /* Link count. */
  398. unsigned int st_uid; /* User ID of the file's owner. */
  399. unsigned int st_gid; /* Group ID of the file's group. */
  400. unsigned long st_rdev; /* Device number, if device. */
  401. unsigned short __pad2;
  402. long st_size; /* Size of file, in bytes. */
  403. int st_blksize; /* Optimal block size for I/O. */
  404. long st_blocks; /* Number 512-byte blocks allocated. */
  405. int st_atime; /* Time of last access. */
  406. int st_atime_nsec;
  407. int st_mtime; /* Time of last modification. */
  408. int st_mtime_nsec;
  409. int st_ctime; /* Time of last status change. */
  410. int st_ctime_nsec;
  411. unsigned int __unused4;
  412. unsigned int __unused5;
  413. };
  414. //----------------------------------------------------------------------
  415. // From linux-2.6.13/include/asm-ppc64/statfs.h
  416. //----------------------------------------------------------------------
  417. struct vki_statfs {
  418. long f_type;
  419. long f_bsize;
  420. long f_blocks;
  421. long f_bfree;
  422. long f_bavail;
  423. long f_files;
  424. long f_ffree;
  425. __vki_kernel_fsid_t f_fsid;
  426. long f_namelen;
  427. long f_frsize;
  428. long f_spare[5];
  429. };
  430. //----------------------------------------------------------------------
  431. // From linux-2.6.13/include/asm-ppc64/termios.h
  432. //----------------------------------------------------------------------
  433. struct vki_winsize {
  434. unsigned short ws_row;
  435. unsigned short ws_col;
  436. unsigned short ws_xpixel;
  437. unsigned short ws_ypixel;
  438. };
  439. #define VKI_NCC 10
  440. struct vki_termio {
  441. unsigned short c_iflag; /* input mode flags */
  442. unsigned short c_oflag; /* output mode flags */
  443. unsigned short c_cflag; /* control mode flags */
  444. unsigned short c_lflag; /* local mode flags */
  445. unsigned char c_line; /* line discipline */
  446. unsigned char c_cc[VKI_NCC]; /* control characters */
  447. };
  448. //----------------------------------------------------------------------
  449. // From linux-2.6.13/include/asm-ppc64/termbits.h
  450. //----------------------------------------------------------------------
  451. typedef unsigned char vki_cc_t;
  452. typedef unsigned int vki_speed_t;
  453. typedef unsigned int vki_tcflag_t;
  454. #define VKI_NCCS 19
  455. struct vki_termios {
  456. vki_tcflag_t c_iflag; /* input mode flags */
  457. vki_tcflag_t c_oflag; /* output mode flags */
  458. vki_tcflag_t c_cflag; /* control mode flags */
  459. vki_tcflag_t c_lflag; /* local mode flags */
  460. vki_cc_t c_cc[VKI_NCCS]; /* control characters */
  461. vki_cc_t c_line; /* line discipline (== c_cc[19]) */
  462. vki_speed_t c_ispeed; /* input speed */
  463. vki_speed_t c_ospeed; /* output speed */
  464. };
  465. //----------------------------------------------------------------------
  466. // From linux-2.6.13/include/asm-ppc64/ioctl.h
  467. //----------------------------------------------------------------------
  468. #define _VKI_IOC_NRBITS 8
  469. #define _VKI_IOC_TYPEBITS 8
  470. #define _VKI_IOC_SIZEBITS 13
  471. #define _VKI_IOC_DIRBITS 3
  472. #define _VKI_IOC_NRMASK ((1 << _VKI_IOC_NRBITS)-1)
  473. #define _VKI_IOC_TYPEMASK ((1 << _VKI_IOC_TYPEBITS)-1)
  474. #define _VKI_IOC_SIZEMASK ((1 << _VKI_IOC_SIZEBITS)-1)
  475. #define _VKI_IOC_DIRMASK ((1 << _VKI_IOC_DIRBITS)-1)
  476. #define _VKI_IOC_NRSHIFT 0
  477. #define _VKI_IOC_TYPESHIFT (_VKI_IOC_NRSHIFT+_VKI_IOC_NRBITS)
  478. #define _VKI_IOC_SIZESHIFT (_VKI_IOC_TYPESHIFT+_VKI_IOC_TYPEBITS)
  479. #define _VKI_IOC_DIRSHIFT (_VKI_IOC_SIZESHIFT+_VKI_IOC_SIZEBITS)
  480. /*
  481. * Direction bits _IOC_NONE could be 0, but OSF/1 gives it a bit.
  482. * And this turns out useful to catch old ioctl numbers in header
  483. * files for us.
  484. */
  485. #define _VKI_IOC_NONE 1U
  486. #define _VKI_IOC_READ 2U
  487. #define _VKI_IOC_WRITE 4U
  488. #define _VKI_IOC(dir,type,nr,size) \
  489. (((dir) << _VKI_IOC_DIRSHIFT) | \
  490. ((type) << _VKI_IOC_TYPESHIFT) | \
  491. ((nr) << _VKI_IOC_NRSHIFT) | \
  492. ((size) << _VKI_IOC_SIZESHIFT))
  493. /* used to create numbers */
  494. #define _VKI_IO(type,nr) _VKI_IOC(_VKI_IOC_NONE,(type),(nr),0)
  495. #define _VKI_IOR(type,nr,size) _VKI_IOC(_VKI_IOC_READ,(type),(nr), \
  496. (_VKI_IOC_TYPECHECK(size)))
  497. #define _VKI_IOW(type,nr,size) _VKI_IOC(_VKI_IOC_WRITE,(type),(nr), \
  498. (_VKI_IOC_TYPECHECK(size)))
  499. #define _VKI_IOWR(type,nr,size) _VKI_IOC(_VKI_IOC_READ|_VKI_IOC_WRITE, \
  500. (type),(nr),(_VKI_IOC_TYPECHECK(size)))
  501. #define _VKI_IOR_BAD(type,nr,size) _VKI_IOC(_VKI_IOC_READ,(type),(nr), \
  502. sizeof(size))
  503. #define _VKI_IOW_BAD(type,nr,size) _VKI_IOC(_VKI_IOC_WRITE,(type),(nr), \
  504. sizeof(size))
  505. #define _VKI_IOWR_BAD(type,nr,size) _VKI_IOC(_VKI_IOC_READ|_VKI_IOC_WRITE, \
  506. (type),(nr),sizeof(size))
  507. /* used to decode them.. */
  508. #define _VKI_IOC_DIR(nr) (((nr) >> _VKI_IOC_DIRSHIFT) & _VKI_IOC_DIRMASK)
  509. #define _VKI_IOC_TYPE(nr) (((nr) >> _VKI_IOC_TYPESHIFT) & _VKI_IOC_TYPEMASK)
  510. #define _VKI_IOC_NR(nr) (((nr) >> _VKI_IOC_NRSHIFT) & _VKI_IOC_NRMASK)
  511. #define _VKI_IOC_SIZE(nr) (((nr) >> _VKI_IOC_SIZESHIFT) & _VKI_IOC_SIZEMASK)
  512. //----------------------------------------------------------------------
  513. // From linux-2.6.13/include/asm-ppc64/ioctls.h
  514. //----------------------------------------------------------------------
  515. #define VKI_FIOCLEX _VKI_IO('f', 1)
  516. #define VKI_FIONCLEX _VKI_IO('f', 2)
  517. #define VKI_TCGETS _VKI_IOR('t', 19, struct vki_termios)
  518. #define VKI_TCSETS _VKI_IOW('t', 20, struct vki_termios)
  519. #define VKI_TCSETSW _VKI_IOW('t', 21, struct vki_termios)
  520. #define VKI_TCSETSF _VKI_IOW('t', 22, struct vki_termios)
  521. #define VKI_TCGETA _VKI_IOR('t', 23, struct vki_termio)
  522. #define VKI_TCSETA _VKI_IOW('t', 24, struct vki_termio)
  523. #define VKI_TCSETAW _VKI_IOW('t', 25, struct vki_termio)
  524. #define VKI_TCSETAF _VKI_IOW('t', 28, struct vki_termio)
  525. #define VKI_TCSBRK _VKI_IO('t', 29)
  526. #define VKI_TCXONC _VKI_IO('t', 30)
  527. #define VKI_TCFLSH _VKI_IO('t', 31)
  528. #define VKI_TIOCSCTTY 0x540E
  529. #define VKI_TIOCGPGRP _VKI_IOR('t', 119, int)
  530. #define VKI_TIOCSPGRP _VKI_IOW('t', 118, int)
  531. #define VKI_TIOCOUTQ _VKI_IOR('t', 115, int) /* output queue size */
  532. #define VKI_TIOCGWINSZ _VKI_IOR('t', 104, struct vki_winsize)
  533. #define VKI_TIOCSWINSZ _VKI_IOW('t', 103, struct vki_winsize)
  534. #define VKI_TIOCMGET 0x5415
  535. #define VKI_TIOCMBIS 0x5416
  536. #define VKI_TIOCMBIC 0x5417
  537. #define VKI_TIOCMSET 0x5418
  538. #define VKI_FIONREAD _VKI_IOR('f', 127, int)
  539. #define VKI_TIOCLINUX 0x541C
  540. #define VKI_FIONBIO _VKI_IOW('f', 126, int)
  541. #define VKI_TIOCNOTTY 0x5422
  542. #define VKI_TCSBRKP 0x5425 /* Needed for POSIX tcsendbreak() */
  543. #define VKI_TIOCGPTN _VKI_IOR('T',0x30, unsigned int)
  544. /* Get Pty Number (of pty-mux device) */
  545. #define VKI_TIOCSPTLCK _VKI_IOW('T',0x31, int) /* Lock/unlock Pty */
  546. #define VKI_FIOASYNC _VKI_IOW('f', 125, int)
  547. #define VKI_TIOCSERGETLSR 0x5459 /* Get line status register */
  548. #define VKI_TIOCGICOUNT 0x545D /* read serial port inline interrupt counts */
  549. #define VKI_FIOQSIZE _VKI_IOR('f', 128, vki_loff_t)
  550. //----------------------------------------------------------------------
  551. // From linux-2.6.13/include/asm-ppc64/poll.h
  552. //----------------------------------------------------------------------
  553. #define VKI_POLLIN 0x0001
  554. struct vki_pollfd {
  555. int fd;
  556. short events;
  557. short revents;
  558. };
  559. //----------------------------------------------------------------------
  560. // From linux-2.6.13/include/asm-ppc64/user.h
  561. //----------------------------------------------------------------------
  562. // Not sure what's needed from here
  563. //----------------------------------------------------------------------
  564. // From linux-2.6.13/include/asm-ppc64/elf.h
  565. //----------------------------------------------------------------------
  566. // Not sure what's needed from here
  567. //----------------------------------------------------------------------
  568. // From linux-2.6.13/include/asm-ppc64/ucontext.h
  569. //----------------------------------------------------------------------
  570. struct vki_ucontext {
  571. unsigned long uc_flags;
  572. struct vki_ucontext *uc_link;
  573. vki_stack_t uc_stack;
  574. vki_sigset_t uc_sigmask;
  575. vki_sigset_t __unused0[15]; /* Allow for uc_sigmask growth */
  576. struct vki_sigcontext uc_mcontext; /* last for extensibility */
  577. };
  578. // CAB: TODO
  579. typedef char vki_modify_ldt_t;
  580. //----------------------------------------------------------------------
  581. // From linux-2.6.13/include/asm-ppc64/ipcbuf.h
  582. //----------------------------------------------------------------------
  583. struct vki_ipc64_perm
  584. {
  585. __vki_kernel_key_t key;
  586. __vki_kernel_uid_t uid;
  587. __vki_kernel_gid_t gid;
  588. __vki_kernel_uid_t cuid;
  589. __vki_kernel_gid_t cgid;
  590. __vki_kernel_mode_t mode;
  591. unsigned int seq;
  592. unsigned int __pad1;
  593. unsigned long __unused1;
  594. unsigned long __unused2;
  595. };
  596. //----------------------------------------------------------------------
  597. // From linux-2.6.13/include/asm-ppc64/sembuf.h
  598. //----------------------------------------------------------------------
  599. struct vki_semid64_ds {
  600. struct vki_ipc64_perm sem_perm; /* permissions .. see ipc.h */
  601. __vki_kernel_time_t sem_otime; /* last semop time */
  602. __vki_kernel_time_t sem_ctime; /* last change time */
  603. unsigned long sem_nsems; /* no. of semaphores in array */
  604. unsigned long __unused1;
  605. unsigned long __unused2;
  606. };
  607. //----------------------------------------------------------------------
  608. // From linux-2.6.13/include/asm-ppc64/msgbuf.h
  609. //----------------------------------------------------------------------
  610. struct vki_msqid64_ds {
  611. struct vki_ipc64_perm msg_perm;
  612. __vki_kernel_time_t msg_stime; /* last msgsnd time */
  613. __vki_kernel_time_t msg_rtime; /* last msgrcv time */
  614. __vki_kernel_time_t msg_ctime; /* last change time */
  615. unsigned long msg_cbytes; /* current number of bytes on queue */
  616. unsigned long msg_qnum; /* number of messages in queue */
  617. unsigned long msg_qbytes; /* max number of bytes on queue */
  618. __vki_kernel_pid_t msg_lspid; /* pid of last msgsnd */
  619. __vki_kernel_pid_t msg_lrpid; /* last receive pid */
  620. unsigned long __unused1;
  621. unsigned long __unused2;
  622. };
  623. //----------------------------------------------------------------------
  624. // From linux-2.6.13/include/asm-ppc64/ipc.h
  625. //----------------------------------------------------------------------
  626. // this just does #include <asm-generic/ipc.h>
  627. struct vki_ipc_kludge {
  628. struct vki_msgbuf __user *msgp;
  629. long msgtyp;
  630. };
  631. #define VKI_SEMOP 1
  632. #define VKI_SEMGET 2
  633. #define VKI_SEMCTL 3
  634. #define VKI_SEMTIMEDOP 4
  635. #define VKI_MSGSND 11
  636. #define VKI_MSGRCV 12
  637. #define VKI_MSGGET 13
  638. #define VKI_MSGCTL 14
  639. #define VKI_SHMAT 21
  640. #define VKI_SHMDT 22
  641. #define VKI_SHMGET 23
  642. #define VKI_SHMCTL 24
  643. //----------------------------------------------------------------------
  644. // From linux-2.6.13/include/asm-ppc64/shmbuf.h
  645. //----------------------------------------------------------------------
  646. struct vki_shmid64_ds {
  647. struct vki_ipc64_perm shm_perm; /* operation perms */
  648. __vki_kernel_time_t shm_atime; /* last attach time */
  649. __vki_kernel_time_t shm_dtime; /* last detach time */
  650. __vki_kernel_time_t shm_ctime; /* last change time */
  651. vki_size_t shm_segsz; /* size of segment (bytes) */
  652. __vki_kernel_pid_t shm_cpid; /* pid of creator */
  653. __vki_kernel_pid_t shm_lpid; /* pid of last operator */
  654. unsigned long shm_nattch; /* no. of current attaches */
  655. unsigned long __unused1;
  656. unsigned long __unused2;
  657. };
  658. struct vki_shminfo64 {
  659. unsigned long shmmax;
  660. unsigned long shmmin;
  661. unsigned long shmmni;
  662. unsigned long shmseg;
  663. unsigned long shmall;
  664. unsigned long __unused1;
  665. unsigned long __unused2;
  666. unsigned long __unused3;
  667. unsigned long __unused4;
  668. };
  669. //----------------------------------------------------------------------
  670. // From linux-2.6.8.1/include/asm-generic/errno.h
  671. //----------------------------------------------------------------------
  672. #define VKI_ENOSYS 38 /* Function not implemented */
  673. #define VKI_EOVERFLOW 75 /* Value too large for defined data type */
  674. //----------------------------------------------------------------------
  675. // From linux-3.19.0/arch/powerpc/include/uapi/asm/ioctls.h
  676. //----------------------------------------------------------------------
  677. #define VKI_TIOCGSERIAL 0x541E
  678. #define VKI_TIOCSSERIAL 0x541F
  679. //----------------------------------------------------------------------
  680. // end
  681. //----------------------------------------------------------------------
  682. #endif // __VKI_PPC64_LINUX_H
  683. /*--------------------------------------------------------------------*/
  684. /*--- end ---*/
  685. /*--------------------------------------------------------------------*/