vki-ppc32-linux.h 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965
  1. /*--------------------------------------------------------------------*/
  2. /*--- PPC32/Linux-specific kernel interface. vki-ppc32-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_PPC32_LINUX_H
  24. #define __VKI_PPC32_LINUX_H
  25. // ppc32 is big-endian.
  26. #define VKI_BIG_ENDIAN 1
  27. //----------------------------------------------------------------------
  28. // From linux-2.6.9/include/asm-ppc/types.h
  29. //----------------------------------------------------------------------
  30. typedef unsigned char __vki_u8;
  31. typedef __signed__ short __vki_s16;
  32. typedef unsigned short __vki_u16;
  33. typedef __signed__ int __vki_s32;
  34. typedef unsigned int __vki_u32;
  35. typedef __signed__ long long __vki_s64;
  36. typedef unsigned long long __vki_u64;
  37. typedef unsigned short vki_u16;
  38. typedef unsigned int vki_u32;
  39. typedef struct {
  40. __vki_u32 u[4];
  41. } __vki_vector128;
  42. //----------------------------------------------------------------------
  43. // From linux-2.6.9/include/asm-ppc/page.h
  44. //----------------------------------------------------------------------
  45. /* PAGE_SHIFT determines the page size, unfortunately
  46. page size might vary between 32-bit and 64-bit ppc kernels */
  47. extern UWord VKI_PAGE_SHIFT;
  48. extern UWord VKI_PAGE_SIZE;
  49. #define VKI_MAX_PAGE_SHIFT 16
  50. #define VKI_MAX_PAGE_SIZE (1UL << VKI_MAX_PAGE_SHIFT)
  51. //----------------------------------------------------------------------
  52. // From linux-2.6.35.4/arch/powerpc/include/asm/shmparam.h
  53. //----------------------------------------------------------------------
  54. #define VKI_SHMLBA VKI_PAGE_SIZE
  55. //----------------------------------------------------------------------
  56. // From linux-2.6.9/include/asm-ppc/signal.h
  57. //----------------------------------------------------------------------
  58. #define VKI_MINSIGSTKSZ 2048
  59. #define VKI_SIG_BLOCK 0 /* for blocking signals */
  60. #define VKI_SIG_UNBLOCK 1 /* for unblocking signals */
  61. #define VKI_SIG_SETMASK 2 /* for setting the signal mask */
  62. /* Type of a signal handler. */
  63. typedef void __vki_signalfn_t(int);
  64. typedef __vki_signalfn_t __user *__vki_sighandler_t;
  65. typedef void __vki_restorefn_t(void);
  66. typedef __vki_restorefn_t __user *__vki_sigrestore_t;
  67. #define VKI_SIG_DFL ((__vki_sighandler_t)0) /* default signal handling */
  68. #define VKI_SIG_IGN ((__vki_sighandler_t)1) /* ignore signal */
  69. #define _VKI_NSIG 64
  70. #define _VKI_NSIG_BPW 32
  71. #define _VKI_NSIG_WORDS (_VKI_NSIG / _VKI_NSIG_BPW)
  72. typedef unsigned long vki_old_sigset_t; /* at least 32 bits */
  73. typedef struct {
  74. unsigned long sig[_VKI_NSIG_WORDS];
  75. } vki_sigset_t;
  76. #define VKI_SIGHUP 1
  77. #define VKI_SIGINT 2
  78. #define VKI_SIGQUIT 3
  79. #define VKI_SIGILL 4
  80. #define VKI_SIGTRAP 5
  81. #define VKI_SIGABRT 6
  82. //#define VKI_SIGIOT 6
  83. #define VKI_SIGBUS 7
  84. #define VKI_SIGFPE 8
  85. #define VKI_SIGKILL 9
  86. #define VKI_SIGUSR1 10
  87. #define VKI_SIGSEGV 11
  88. #define VKI_SIGUSR2 12
  89. #define VKI_SIGPIPE 13
  90. #define VKI_SIGALRM 14
  91. #define VKI_SIGTERM 15
  92. #define VKI_SIGSTKFLT 16
  93. #define VKI_SIGCHLD 17
  94. #define VKI_SIGCONT 18
  95. #define VKI_SIGSTOP 19
  96. #define VKI_SIGTSTP 20
  97. #define VKI_SIGTTIN 21
  98. #define VKI_SIGTTOU 22
  99. #define VKI_SIGURG 23
  100. #define VKI_SIGXCPU 24
  101. #define VKI_SIGXFSZ 25
  102. #define VKI_SIGVTALRM 26
  103. #define VKI_SIGPROF 27
  104. #define VKI_SIGWINCH 28
  105. #define VKI_SIGIO 29
  106. #define VKI_SIGPWR 30
  107. #define VKI_SIGSYS 31
  108. #define VKI_SIGUNUSED 31
  109. /* These should not be considered constants from userland. */
  110. #define VKI_SIGRTMIN 32
  111. // [[This was (_NSIG-1) in 2.4.X... not sure if it matters.]]
  112. #define VKI_SIGRTMAX _VKI_NSIG
  113. #define VKI_SA_NOCLDSTOP 0x00000001
  114. #define VKI_SA_NOCLDWAIT 0x00000002
  115. #define VKI_SA_SIGINFO 0x00000004
  116. #define VKI_SA_ONSTACK 0x08000000
  117. #define VKI_SA_RESTART 0x10000000
  118. #define VKI_SA_NODEFER 0x40000000
  119. #define VKI_SA_RESETHAND 0x80000000
  120. #define VKI_SA_NOMASK VKI_SA_NODEFER
  121. #define VKI_SA_ONESHOT VKI_SA_RESETHAND
  122. //#define VKI_SA_INTERRUPT 0x20000000 /* dummy -- ignored */
  123. #define VKI_SA_RESTORER 0x04000000
  124. #define VKI_SS_ONSTACK 1
  125. #define VKI_SS_DISABLE 2
  126. /* These are 'legacy' sigactions in which the size of sa_mask is fixed
  127. (cannot be expanded at any future point) because it is sandwiched
  128. between two other fields.
  129. (there is identical kludgery in vki-x86-linux.h) */
  130. struct vki_old_sigaction {
  131. // [[Nb: a 'k' prefix is added to "sa_handler" because
  132. // bits/sigaction.h (which gets dragged in somehow via signal.h)
  133. // #defines it as something else. Since that is done for glibc's
  134. // purposes, which we don't care about here, we use our own name.]]
  135. __vki_sighandler_t ksa_handler;
  136. vki_old_sigset_t sa_mask;
  137. unsigned long sa_flags;
  138. __vki_sigrestore_t sa_restorer;
  139. };
  140. struct vki_sigaction_base {
  141. // [[See comment about extra 'k' above]]
  142. __vki_sighandler_t ksa_handler;
  143. unsigned long sa_flags;
  144. __vki_sigrestore_t sa_restorer;
  145. vki_sigset_t sa_mask; /* mask last for extensibility */
  146. };
  147. /* On Linux we use the same type for passing sigactions to
  148. and from the kernel. Hence: */
  149. typedef struct vki_sigaction_base vki_sigaction_toK_t;
  150. typedef struct vki_sigaction_base vki_sigaction_fromK_t;
  151. typedef struct vki_sigaltstack {
  152. void __user *ss_sp;
  153. int ss_flags;
  154. vki_size_t ss_size;
  155. } vki_stack_t;
  156. //----------------------------------------------------------------------
  157. // From linux-2.6.9/include/asm-ppc/ptrace.h
  158. //----------------------------------------------------------------------
  159. struct vki_pt_regs {
  160. unsigned long gpr[32];
  161. unsigned long nip;
  162. unsigned long msr;
  163. unsigned long orig_gpr3; /* Used for restarting system calls */
  164. unsigned long ctr;
  165. unsigned long link;
  166. unsigned long xer;
  167. unsigned long ccr;
  168. unsigned long mq; /* 601 only (not used at present) */
  169. /* Used on APUS to hold IPL value. */
  170. unsigned long trap; /* Reason for being here */
  171. /* N.B. for critical exceptions on 4xx, the dar and dsisr
  172. fields are overloaded to hold srr0 and srr1. */
  173. unsigned long dar; /* Fault registers */
  174. unsigned long dsisr; /* on 4xx/Book-E used for ESR */
  175. unsigned long result; /* Result of a system call */
  176. /* Not in kernel's definition, but apparently needed to stop
  177. assertion at coredump-elf.c:267 firing. These padding
  178. words make the struct have the same size as a
  179. 'vki_elf_greg_t'. See message from Ghassan Hammouri on
  180. valgrind-developers on 6 April 06. */
  181. unsigned long pad[4];
  182. };
  183. #define vki_user_regs_struct vki_pt_regs
  184. #define VKI_PT_R0 0
  185. #define VKI_PT_R1 1
  186. #define VKI_PT_R2 2
  187. #define VKI_PT_R3 3
  188. #define VKI_PT_R4 4
  189. #define VKI_PT_R5 5
  190. #define VKI_PT_R6 6
  191. #define VKI_PT_R7 7
  192. #define VKI_PT_R8 8
  193. #define VKI_PT_R9 9
  194. #define VKI_PT_R10 10
  195. #define VKI_PT_R11 11
  196. #define VKI_PT_R12 12
  197. #define VKI_PT_R13 13
  198. #define VKI_PT_R14 14
  199. #define VKI_PT_R15 15
  200. #define VKI_PT_R16 16
  201. #define VKI_PT_R17 17
  202. #define VKI_PT_R18 18
  203. #define VKI_PT_R19 19
  204. #define VKI_PT_R20 20
  205. #define VKI_PT_R21 21
  206. #define VKI_PT_R22 22
  207. #define VKI_PT_R23 23
  208. #define VKI_PT_R24 24
  209. #define VKI_PT_R25 25
  210. #define VKI_PT_R26 26
  211. #define VKI_PT_R27 27
  212. #define VKI_PT_R28 28
  213. #define VKI_PT_R29 29
  214. #define VKI_PT_R30 30
  215. #define VKI_PT_R31 31
  216. #define VKI_PT_NIP 32
  217. #define VKI_PT_MSR 33
  218. #define VKI_PT_ORIG_R3 34
  219. #define VKI_PT_CTR 35
  220. #define VKI_PT_LNK 36
  221. #define VKI_PT_XER 37
  222. #define VKI_PT_CCR 38
  223. #define VKI_PT_MQ 39
  224. #define VKI_PT_TRAP 40
  225. #define VKI_PT_DAR 41
  226. #define VKI_PT_DSISR 42
  227. #define VKI_PT_RESULT 43
  228. //----------------------------------------------------------------------
  229. // From linux-2.6.9/include/asm-ppc/sigcontext.h
  230. //----------------------------------------------------------------------
  231. struct vki_sigcontext {
  232. unsigned long _unused[4];
  233. int signal;
  234. unsigned long handler;
  235. unsigned long oldmask;
  236. struct vki_pt_regs *regs;
  237. };
  238. //----------------------------------------------------------------------
  239. // From linux-2.6.9/include/asm-ppc/mman.h
  240. //----------------------------------------------------------------------
  241. #define VKI_PROT_NONE 0x0 /* No page permissions */
  242. #define VKI_PROT_READ 0x1 /* page can be read */
  243. #define VKI_PROT_WRITE 0x2 /* page can be written */
  244. #define VKI_PROT_EXEC 0x4 /* page can be executed */
  245. #define VKI_PROT_GROWSDOWN 0x01000000 /* mprotect flag: extend change to start of growsdown vma */
  246. #define VKI_PROT_GROWSUP 0x02000000 /* mprotect flag: extend change to end of growsup vma */
  247. #define VKI_MAP_SHARED 0x01 /* Share changes */
  248. #define VKI_MAP_PRIVATE 0x02 /* Changes are private */
  249. //#define VKI_MAP_TYPE 0x0f /* Mask for type of mapping */
  250. #define VKI_MAP_FIXED 0x10 /* Interpret addr exactly */
  251. #define VKI_MAP_ANONYMOUS 0x20 /* don't use a file */
  252. #define VKI_MAP_NORESERVE 0x40 /* don't reserve swap pages */
  253. //----------------------------------------------------------------------
  254. // From linux-2.6.9/include/asm-ppc/fcntl.h
  255. //----------------------------------------------------------------------
  256. #define VKI_O_ACCMODE 03
  257. #define VKI_O_RDONLY 00
  258. #define VKI_O_WRONLY 01
  259. #define VKI_O_RDWR 02
  260. #define VKI_O_CREAT 0100 /* not fcntl */
  261. #define VKI_O_EXCL 0200 /* not fcntl */
  262. #define VKI_O_TRUNC 01000 /* not fcntl */
  263. #define VKI_O_APPEND 02000
  264. #define VKI_O_NONBLOCK 04000
  265. #define VKI_O_LARGEFILE 0200000
  266. #define VKI_AT_FDCWD -100
  267. #define VKI_F_DUPFD 0 /* dup */
  268. #define VKI_F_GETFD 1 /* get close_on_exec */
  269. #define VKI_F_SETFD 2 /* set/clear close_on_exec */
  270. #define VKI_F_GETFL 3 /* get file->f_flags */
  271. #define VKI_F_SETFL 4 /* set file->f_flags */
  272. #define VKI_F_GETLK 5
  273. #define VKI_F_SETLK 6
  274. #define VKI_F_SETLKW 7
  275. #define VKI_F_SETOWN 8 /* for sockets. */
  276. #define VKI_F_GETOWN 9 /* for sockets. */
  277. #define VKI_F_SETSIG 10 /* for sockets. */
  278. #define VKI_F_GETSIG 11 /* for sockets. */
  279. #define VKI_F_GETLK64 12 /* using 'struct flock64' */
  280. #define VKI_F_SETLK64 13
  281. #define VKI_F_SETLKW64 14
  282. #define VKI_F_SETOWN_EX 15
  283. #define VKI_F_GETOWN_EX 16
  284. #define VKI_F_OFD_GETLK 36
  285. #define VKI_F_OFD_SETLK 37
  286. #define VKI_F_OFD_SETLKW 38
  287. #define VKI_F_OWNER_TID 0
  288. #define VKI_F_OWNER_PID 1
  289. #define VKI_F_OWNER_PGRP 2
  290. struct vki_f_owner_ex {
  291. int type;
  292. __vki_kernel_pid_t pid;
  293. };
  294. /* for F_[GET|SET]FL */
  295. #define VKI_FD_CLOEXEC 1 /* actually anything with low bit set goes */
  296. #define VKI_F_LINUX_SPECIFIC_BASE 1024
  297. //----------------------------------------------------------------------
  298. // From linux-2.6.9/include/asm-ppc/resource.h
  299. //----------------------------------------------------------------------
  300. #define VKI_RLIMIT_DATA 2 /* max data size */
  301. #define VKI_RLIMIT_STACK 3 /* max stack size */
  302. #define VKI_RLIMIT_CORE 4 /* max core file size */
  303. #define VKI_RLIMIT_NOFILE 7 /* max number of open files */
  304. //----------------------------------------------------------------------
  305. // From linux-2.6.9/include/asm-ppc/socket.h
  306. //----------------------------------------------------------------------
  307. #define VKI_SOL_SOCKET 1
  308. #define VKI_SO_TYPE 3
  309. #define VKI_SO_ATTACH_FILTER 26
  310. //----------------------------------------------------------------------
  311. // From linux-2.6.8.1/include/asm-ppc/sockios.h
  312. //----------------------------------------------------------------------
  313. #define VKI_SIOCSPGRP 0x8902
  314. #define VKI_SIOCGPGRP 0x8904
  315. #define VKI_SIOCATMARK 0x8905
  316. #define VKI_SIOCGSTAMP 0x8906 /* Get stamp (timeval) */
  317. #define VKI_SIOCGSTAMPNS 0x8907 /* Get stamp (timespec) */
  318. //----------------------------------------------------------------------
  319. // From linux-2.6.10/include/asm-ppc/stat.h
  320. //----------------------------------------------------------------------
  321. //.. #define VKI_S_IFMT 00170000
  322. //.. #define VKI_S_IFSOCK 0140000
  323. //.. #define VKI_S_IFLNK 0120000
  324. //.. #define VKI_S_IFREG 0100000
  325. //.. #define VKI_S_IFBLK 0060000
  326. //.. #define VKI_S_IFDIR 0040000
  327. //.. #define VKI_S_IFCHR 0020000
  328. //.. #define VKI_S_IFIFO 0010000
  329. //.. #define VKI_S_ISUID 0004000
  330. //.. #define VKI_S_ISGID 0002000
  331. //.. #define VKI_S_ISVTX 0001000
  332. //..
  333. //.. #define VKI_S_ISLNK(m) (((m) & VKI_S_IFMT) == VKI_S_IFLNK)
  334. //.. #define VKI_S_ISREG(m) (((m) & VKI_S_IFMT) == VKI_S_IFREG)
  335. //.. #define VKI_S_ISDIR(m) (((m) & VKI_S_IFMT) == VKI_S_IFDIR)
  336. //.. #define VKI_S_ISCHR(m) (((m) & VKI_S_IFMT) == VKI_S_IFCHR)
  337. //.. #define VKI_S_ISBLK(m) (((m) & VKI_S_IFMT) == VKI_S_IFBLK)
  338. //.. #define VKI_S_ISFIFO(m) (((m) & VKI_S_IFMT) == VKI_S_IFIFO)
  339. //.. #define VKI_S_ISSOCK(m) (((m) & VKI_S_IFMT) == VKI_S_IFSOCK)
  340. struct vki_stat {
  341. unsigned st_dev;
  342. unsigned long st_ino;
  343. unsigned int st_mode;
  344. unsigned short st_nlink;
  345. unsigned int st_uid;
  346. unsigned int st_gid;
  347. unsigned st_rdev;
  348. long st_size;
  349. unsigned long st_blksize;
  350. unsigned long st_blocks;
  351. unsigned long st_atime;
  352. unsigned long st_atime_nsec;
  353. unsigned long st_mtime;
  354. unsigned long st_mtime_nsec;
  355. unsigned long st_ctime;
  356. unsigned long st_ctime_nsec;
  357. unsigned long __unused4;
  358. unsigned long __unused5;
  359. };
  360. struct vki_stat64 {
  361. unsigned long long st_dev;
  362. unsigned long long st_ino;
  363. unsigned int st_mode;
  364. unsigned int st_nlink;
  365. unsigned int st_uid;
  366. unsigned int st_gid;
  367. unsigned long long st_rdev;
  368. unsigned short int __pad2;
  369. long long st_size;
  370. long st_blksize;
  371. long long st_blocks;
  372. long st_atime;
  373. unsigned long st_atime_nsec;
  374. long st_mtime;
  375. unsigned long int st_mtime_nsec;
  376. long st_ctime;
  377. unsigned long int st_ctime_nsec;
  378. unsigned long int __unused4;
  379. unsigned long int __unused5;
  380. };
  381. //----------------------------------------------------------------------
  382. // From linux-2.6.9/include/asm-ppc/statfs.h
  383. //----------------------------------------------------------------------
  384. // [[Nb: asm-ppc/statfs.h just #include asm-generic/statfs.h directly]]
  385. struct vki_statfs {
  386. __vki_u32 f_type;
  387. __vki_u32 f_bsize;
  388. __vki_u32 f_blocks;
  389. __vki_u32 f_bfree;
  390. __vki_u32 f_bavail;
  391. __vki_u32 f_files;
  392. __vki_u32 f_ffree;
  393. __vki_kernel_fsid_t f_fsid;
  394. __vki_u32 f_namelen;
  395. __vki_u32 f_frsize;
  396. __vki_u32 f_spare[5];
  397. };
  398. //----------------------------------------------------------------------
  399. // From linux-2.6.9/include/asm-ppc/termios.h
  400. //----------------------------------------------------------------------
  401. struct vki_winsize {
  402. unsigned short ws_row;
  403. unsigned short ws_col;
  404. unsigned short ws_xpixel;
  405. unsigned short ws_ypixel;
  406. };
  407. #define NCC 10
  408. struct vki_termio {
  409. unsigned short c_iflag; /* input mode flags */
  410. unsigned short c_oflag; /* output mode flags */
  411. unsigned short c_cflag; /* control mode flags */
  412. unsigned short c_lflag; /* local mode flags */
  413. unsigned char c_line; /* line discipline */
  414. unsigned char c_cc[NCC]; /* control characters */
  415. };
  416. //----------------------------------------------------------------------
  417. // From linux-2.6.9/include/asm-ppc/termbits.h
  418. //----------------------------------------------------------------------
  419. typedef unsigned char vki_cc_t;
  420. typedef unsigned int vki_speed_t;
  421. typedef unsigned int vki_tcflag_t;
  422. #define NCCS 19
  423. struct vki_termios {
  424. vki_tcflag_t c_iflag; /* input mode flags */
  425. vki_tcflag_t c_oflag; /* output mode flags */
  426. vki_tcflag_t c_cflag; /* control mode flags */
  427. vki_tcflag_t c_lflag; /* local mode flags */
  428. vki_cc_t c_cc[NCCS]; /* control characters */
  429. vki_cc_t c_line; /* line discipline (== c_cc[19]) */
  430. vki_speed_t c_ispeed; /* input speed */
  431. vki_speed_t c_ospeed; /* output speed */
  432. };
  433. //----------------------------------------------------------------------
  434. // From linux-2.6.9/include/asm-ppc/ioctl.h
  435. //----------------------------------------------------------------------
  436. #define _VKI_IOC_NRBITS 8
  437. #define _VKI_IOC_TYPEBITS 8
  438. #define _VKI_IOC_SIZEBITS 13
  439. #define _VKI_IOC_DIRBITS 3
  440. #define _VKI_IOC_NRMASK ((1 << _VKI_IOC_NRBITS)-1)
  441. #define _VKI_IOC_TYPEMASK ((1 << _VKI_IOC_TYPEBITS)-1)
  442. #define _VKI_IOC_SIZEMASK ((1 << _VKI_IOC_SIZEBITS)-1)
  443. #define _VKI_IOC_DIRMASK ((1 << _VKI_IOC_DIRBITS)-1)
  444. #define _VKI_IOC_NRSHIFT 0
  445. #define _VKI_IOC_TYPESHIFT (_VKI_IOC_NRSHIFT+_VKI_IOC_NRBITS)
  446. #define _VKI_IOC_SIZESHIFT (_VKI_IOC_TYPESHIFT+_VKI_IOC_TYPEBITS)
  447. #define _VKI_IOC_DIRSHIFT (_VKI_IOC_SIZESHIFT+_VKI_IOC_SIZEBITS)
  448. #define _VKI_IOC_NONE 1U
  449. #define _VKI_IOC_READ 2U
  450. #define _VKI_IOC_WRITE 4U
  451. #define _VKI_IOC(dir,type,nr,size) \
  452. (((dir) << _VKI_IOC_DIRSHIFT) | \
  453. ((type) << _VKI_IOC_TYPESHIFT) | \
  454. ((nr) << _VKI_IOC_NRSHIFT) | \
  455. ((size) << _VKI_IOC_SIZESHIFT))
  456. /* used to create numbers */
  457. #define _VKI_IO(type,nr) _VKI_IOC(_VKI_IOC_NONE,(type),(nr),0)
  458. #define _VKI_IOR(type,nr,size) _VKI_IOC(_VKI_IOC_READ,(type),(nr),(_VKI_IOC_TYPECHECK(size)))
  459. #define _VKI_IOW(type,nr,size) _VKI_IOC(_VKI_IOC_WRITE,(type),(nr),(_VKI_IOC_TYPECHECK(size)))
  460. #define _VKI_IOWR(type,nr,size) _VKI_IOC(_VKI_IOC_READ|_VKI_IOC_WRITE,(type),(nr),(_VKI_IOC_TYPECHECK(size)))
  461. /* used to decode them.. */
  462. #define _VKI_IOC_DIR(nr) (((nr) >> _VKI_IOC_DIRSHIFT) & _VKI_IOC_DIRMASK)
  463. //.. #define _VKI_IOC_TYPE(nr) (((nr) >> _VKI_IOC_TYPESHIFT) & _VKI_IOC_TYPEMASK)
  464. //.. #define _VKI_IOC_NR(nr) (((nr) >> _VKI_IOC_NRSHIFT) & _VKI_IOC_NRMASK)
  465. #define _VKI_IOC_SIZE(nr) (((nr) >> _VKI_IOC_SIZESHIFT) & _VKI_IOC_SIZEMASK)
  466. //----------------------------------------------------------------------
  467. // From linux-2.6.9/include/asm-ppc/ioctls.h
  468. //----------------------------------------------------------------------
  469. #define VKI_FIOCLEX _VKI_IO('f', 1)
  470. #define VKI_FIONCLEX _VKI_IO('f', 2)
  471. #define VKI_FIOASYNC _VKI_IOW('f', 125, int)
  472. #define VKI_FIONBIO _VKI_IOW('f', 126, int)
  473. #define VKI_FIONREAD _VKI_IOR('f', 127, int)
  474. //#define VKI_TIOCINQ VKI_FIONREAD
  475. #define VKI_FIOQSIZE _VKI_IOR('f', 128, vki_loff_t)
  476. //#define VKI_TIOCGETP _VKI_IOR('t', 8, struct vki_sgttyb)
  477. //#define VKI_TIOCSETP _VKI_IOW('t', 9, struct vki_sgttyb)
  478. //#define VKI_TIOCSETN _VKI_IOW('t', 10, struct vki_sgttyb) /* TIOCSETP wo flush */
  479. //#define VKI_TIOCSETC _VKI_IOW('t', 17, struct vki_tchars)
  480. //#define VKI_TIOCGETC _VKI_IOR('t', 18, struct vki_tchars)
  481. #define VKI_TCGETS _VKI_IOR('t', 19, struct vki_termios)
  482. #define VKI_TCSETS _VKI_IOW('t', 20, struct vki_termios)
  483. #define VKI_TCSETSW _VKI_IOW('t', 21, struct vki_termios)
  484. #define VKI_TCSETSF _VKI_IOW('t', 22, struct vki_termios)
  485. #define VKI_TCGETA _VKI_IOR('t', 23, struct vki_termio)
  486. #define VKI_TCSETA _VKI_IOW('t', 24, struct vki_termio)
  487. #define VKI_TCSETAW _VKI_IOW('t', 25, struct vki_termio)
  488. #define VKI_TCSETAF _VKI_IOW('t', 28, struct vki_termio)
  489. #define VKI_TCSBRK _VKI_IO('t', 29)
  490. #define VKI_TCXONC _VKI_IO('t', 30)
  491. #define VKI_TCFLSH _VKI_IO('t', 31)
  492. #define VKI_TIOCSWINSZ _VKI_IOW('t', 103, struct vki_winsize)
  493. #define VKI_TIOCGWINSZ _VKI_IOR('t', 104, struct vki_winsize)
  494. //#define VKI_TIOCSTART _VKI_IO('t', 110) /* start output, like ^Q */
  495. //#define VKI_TIOCSTOP _VKI_IO('t', 111) /* stop output, like ^S */
  496. #define VKI_TIOCOUTQ _VKI_IOR('t', 115, int) /* output queue size */
  497. //#define VKI_TIOCGLTC _VKI_IOR('t', 116, struct vki_ltchars)
  498. //#define VKI_TIOCSLTC _VKI_IOW('t', 117, struct vki_ltchars)
  499. #define VKI_TIOCSPGRP _VKI_IOW('t', 118, int)
  500. #define VKI_TIOCGPGRP _VKI_IOR('t', 119, int)
  501. //#define VKI_TIOCEXCL 0x540C
  502. //#define VKI_TIOCNXCL 0x540D
  503. #define VKI_TIOCSCTTY 0x540E
  504. //#define VKI_TIOCSTI 0x5412
  505. #define VKI_TIOCMGET 0x5415
  506. #define VKI_TIOCMBIS 0x5416
  507. #define VKI_TIOCMBIC 0x5417
  508. #define VKI_TIOCMSET 0x5418
  509. //# define VKI_TIOCM_LE 0x001
  510. //# define VKI_TIOCM_DTR 0x002
  511. //# define VKI_TIOCM_RTS 0x004
  512. //# define VKI_TIOCM_ST 0x008
  513. //# define VKI_TIOCM_SR 0x010
  514. //# define VKI_TIOCM_CTS 0x020
  515. //# define VKI_TIOCM_CAR 0x040
  516. //# define VKI_TIOCM_RNG 0x080
  517. //# define VKI_TIOCM_DSR 0x100
  518. //# define VKI_TIOCM_CD VKI_TIOCM_CAR
  519. //# define VKI_TIOCM_RI VKI_TIOCM_RNG
  520. //#define VKI_TIOCGSOFTCAR 0x5419
  521. //#define VKI_TIOCSSOFTCAR 0x541A
  522. #define VKI_TIOCLINUX 0x541C
  523. //#define VKI_TIOCCONS 0x541D
  524. #define VKI_TIOCGSERIAL 0x541E
  525. #define VKI_TIOCSSERIAL 0x541F
  526. //#define VKI_TIOCPKT 0x5420
  527. //# define VKI_TIOCPKT_DATA 0
  528. //# define VKI_TIOCPKT_FLUSHREAD 1
  529. //# define VKI_TIOCPKT_FLUSHWRITE 2
  530. //# define VKI_TIOCPKT_STOP 4
  531. //# define VKI_TIOCPKT_START 8
  532. //# define VKI_TIOCPKT_NOSTOP 16
  533. //# define VKI_TIOCPKT_DOSTOP 32
  534. #define VKI_TIOCNOTTY 0x5422
  535. //#define VKI_TIOCSETD 0x5423
  536. //#define VKI_TIOCGETD 0x5424
  537. #define VKI_TCSBRKP 0x5425 /* Needed for POSIX tcsendbreak() */
  538. //#define VKI_TIOCSBRK 0x5427 /* BSD compatibility */
  539. //#define VKI_TIOCCBRK 0x5428 /* BSD compatibility */
  540. //#define VKI_TIOCGSID 0x5429 /* Return the session ID of FD */
  541. #define VKI_TIOCGPTN _VKI_IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */
  542. #define VKI_TIOCSPTLCK _VKI_IOW('T',0x31, int) /* Lock/unlock Pty */
  543. //#define VKI_TIOCSERCONFIG 0x5453
  544. //#define VKI_TIOCSERGWILD 0x5454
  545. //#define VKI_TIOCSERSWILD 0x5455
  546. //#define VKI_TIOCGLCKTRMIOS 0x5456
  547. //#define VKI_TIOCSLCKTRMIOS 0x5457
  548. //#define VKI_TIOCSERGSTRUCT 0x5458 /* For debugging only */
  549. #define VKI_TIOCSERGETLSR 0x5459 /* Get line status register */
  550. /* ioctl (fd, VKI_TIOCSERGETLSR, &result) where result may be as below */
  551. //# define VKI_TIOCSER_TEMT 0x01 /* Transmitter physically empty */
  552. //#define VKI_TIOCSERGETMULTI 0x545A /* Get multiport config */
  553. //#define VKI_TIOCSERSETMULTI 0x545B /* Set multiport config */
  554. //#define VKI_TIOCMIWAIT 0x545C /* wait for a change on serial input line(s) */
  555. #define VKI_TIOCGICOUNT 0x545D /* read serial port inline interrupt counts */
  556. //----------------------------------------------------------------------
  557. // From linux-2.6.9/include/asm-ppc/poll.h
  558. //----------------------------------------------------------------------
  559. //.. /* These are specified by iBCS2 */
  560. //.. #define VKI_POLLIN 0x0001
  561. struct vki_pollfd {
  562. int fd;
  563. short events;
  564. short revents;
  565. };
  566. //.. //----------------------------------------------------------------------
  567. //.. // From linux-2.6.8.1/include/asm-i386/user.h
  568. //.. //----------------------------------------------------------------------
  569. //..
  570. //.. struct vki_user_i387_struct {
  571. //.. long cwd;
  572. //.. long swd;
  573. //.. long twd;
  574. //.. long fip;
  575. //.. long fcs;
  576. //.. long foo;
  577. //.. long fos;
  578. //.. long st_space[20]; /* 8*10 bytes for each FP-reg = 80 bytes */
  579. //.. };
  580. //..
  581. //.. struct vki_user_fxsr_struct {
  582. //.. unsigned short cwd;
  583. //.. unsigned short swd;
  584. //.. unsigned short twd;
  585. //.. unsigned short fop;
  586. //.. long fip;
  587. //.. long fcs;
  588. //.. long foo;
  589. //.. long fos;
  590. //.. long mxcsr;
  591. //.. long reserved;
  592. //.. long st_space[32]; /* 8*16 bytes for each FP-reg = 128 bytes */
  593. //.. long xmm_space[32]; /* 8*16 bytes for each XMM-reg = 128 bytes */
  594. //.. long padding[56];
  595. //.. };
  596. //..
  597. //.. /*
  598. //.. * This is the old layout of "struct pt_regs", and
  599. //.. * is still the layout used by user mode (the new
  600. //.. * pt_regs doesn't have all registers as the kernel
  601. //.. * doesn't use the extra segment registers)
  602. //.. */
  603. //.. struct vki_user_regs_struct {
  604. //.. long ebx, ecx, edx, esi, edi, ebp, eax;
  605. //.. unsigned short ds, __ds, es, __es;
  606. //.. unsigned short fs, __fs, gs, __gs;
  607. //.. long orig_eax, eip;
  608. //.. unsigned short cs, __cs;
  609. //.. long eflags, esp;
  610. //.. unsigned short ss, __ss;
  611. //.. };
  612. //----------------------------------------------------------------------
  613. // From linux-2.6.9/include/asm-ppc/elf.h
  614. //----------------------------------------------------------------------
  615. #define VKI_ELF_NGREG 48 /* includes nip, msr, lr, etc. */
  616. #define VKI_ELF_NFPREG 33 /* includes fpscr */
  617. #define VKI_ELF_NVRREG 33 /* includes vscr */
  618. /* General registers */
  619. typedef unsigned long vki_elf_greg_t;
  620. typedef vki_elf_greg_t vki_elf_gregset_t[VKI_ELF_NGREG];
  621. /* Floating point registers */
  622. typedef double vki_elf_fpreg_t;
  623. typedef vki_elf_fpreg_t vki_elf_fpregset_t[VKI_ELF_NFPREG];
  624. /* Altivec registers */
  625. typedef __vki_vector128 vki_elf_vrreg_t;
  626. typedef vki_elf_vrreg_t vki_elf_vrregset_t[VKI_ELF_NVRREG];
  627. #define VKI_AT_DCACHEBSIZE 19
  628. #define VKI_AT_ICACHEBSIZE 20
  629. #define VKI_AT_UCACHEBSIZE 21
  630. /* A special ignored type value for PPC, for glibc compatibility. */
  631. #define VKI_AT_IGNOREPPC 22
  632. /* CAB: Do we want these? */
  633. //#define VKI_AT_SYSINFO 32
  634. //#define VKI_AT_SYSINFO_EHDR 33
  635. //----------------------------------------------------------------------
  636. // From linux-2.6.9/include/asm-ppc/ucontext.h
  637. //----------------------------------------------------------------------
  638. struct vki_mcontext {
  639. vki_elf_gregset_t mc_gregs;
  640. vki_elf_fpregset_t mc_fregs;
  641. unsigned long mc_pad[2];
  642. vki_elf_vrregset_t mc_vregs __attribute__((__aligned__(16)));
  643. };
  644. struct vki_ucontext {
  645. unsigned long uc_flags;
  646. struct vki_ucontext __user *uc_link;
  647. vki_stack_t uc_stack;
  648. int uc_pad[7];
  649. struct vki_mcontext __user *uc_regs; /* points to uc_mcontext field */
  650. vki_sigset_t uc_sigmask;
  651. /* glibc has 1024-bit signal masks, ours are 64-bit */
  652. int uc_maskext[30];
  653. int uc_pad2[3];
  654. struct vki_mcontext uc_mcontext;
  655. };
  656. //.. //----------------------------------------------------------------------
  657. //.. // From linux-2.6.8.1/include/asm-i386/segment.h
  658. //.. //----------------------------------------------------------------------
  659. //..
  660. //.. #define VKI_GDT_ENTRY_TLS_ENTRIES 3
  661. //.. #define VKI_GDT_ENTRY_TLS_MIN 6
  662. //.. #define VKI_GDT_ENTRY_TLS_MAX (VKI_GDT_ENTRY_TLS_MIN + VKI_GDT_ENTRY_TLS_ENTRIES - 1)
  663. //----------------------------------------------------------------------
  664. // From linux-2.6.9/include/asm-ppc/ldt.h
  665. //----------------------------------------------------------------------
  666. //.. /* [[Nb: This is the structure passed to the modify_ldt syscall. Just so as
  667. //.. to confuse and annoy everyone, this is _not_ the same as an
  668. //.. VgLdtEntry and has to be translated into such. The logic for doing
  669. //.. so, in vg_ldt.c, is copied from the kernel sources.]] */
  670. //.. struct vki_user_desc {
  671. //.. unsigned int entry_number;
  672. //.. unsigned long base_addr;
  673. //.. unsigned int limit;
  674. //.. unsigned int seg_32bit:1;
  675. //.. unsigned int contents:2;
  676. //.. unsigned int read_exec_only:1;
  677. //.. unsigned int limit_in_pages:1;
  678. //.. unsigned int seg_not_present:1;
  679. //.. unsigned int useable:1;
  680. //.. // [[Nb: this field is not in the kernel sources, but it has always
  681. //.. // been in the Valgrind sources so I will keep it there in case it's
  682. //.. // important... this is an x86-defined data structure so who
  683. //.. // knows; maybe it's important to set this field to zero at some
  684. //.. // point. --njn]]
  685. //.. unsigned int reserved:25;
  686. //.. };
  687. //..
  688. //.. // [[Nb: for our convenience within Valgrind, use a more specific name]]
  689. // CAB: TODO
  690. typedef char vki_modify_ldt_t;
  691. //----------------------------------------------------------------------
  692. // From linux-2.6.9/include/asm-ppc/ipcbuf.h
  693. //----------------------------------------------------------------------
  694. struct vki_ipc64_perm
  695. {
  696. __vki_kernel_key_t key;
  697. __vki_kernel_uid_t uid;
  698. __vki_kernel_gid_t gid;
  699. __vki_kernel_uid_t cuid;
  700. __vki_kernel_gid_t cgid;
  701. __vki_kernel_mode_t mode;
  702. unsigned long seq;
  703. unsigned int __pad2;
  704. unsigned long long __unused1;
  705. unsigned long long __unused2;
  706. };
  707. //----------------------------------------------------------------------
  708. // From linux-2.6.9/include/asm-ppc/sembuf.h
  709. //----------------------------------------------------------------------
  710. struct vki_semid64_ds {
  711. struct vki_ipc64_perm sem_perm; /* permissions .. see ipc.h */
  712. unsigned int __unused1;
  713. __vki_kernel_time_t sem_otime; /* last semop time */
  714. unsigned int __unused2;
  715. __vki_kernel_time_t sem_ctime; /* last change time */
  716. unsigned long sem_nsems; /* no. of semaphores in array */
  717. unsigned long __unused3;
  718. unsigned long __unused4;
  719. };
  720. //----------------------------------------------------------------------
  721. // From linux-2.6.9/include/asm-ppc/msgbuf.h
  722. //----------------------------------------------------------------------
  723. struct vki_msqid64_ds {
  724. struct vki_ipc64_perm msg_perm;
  725. unsigned int __unused1;
  726. __vki_kernel_time_t msg_stime; /* last msgsnd time */
  727. unsigned int __unused2;
  728. __vki_kernel_time_t msg_rtime; /* last msgrcv time */
  729. unsigned int __unused3;
  730. __vki_kernel_time_t msg_ctime; /* last change time */
  731. unsigned long msg_cbytes; /* current number of bytes on queue */
  732. unsigned long msg_qnum; /* number of messages in queue */
  733. unsigned long msg_qbytes; /* max number of bytes on queue */
  734. __vki_kernel_pid_t msg_lspid; /* pid of last msgsnd */
  735. __vki_kernel_pid_t msg_lrpid; /* last receive pid */
  736. unsigned long __unused4;
  737. unsigned long __unused5;
  738. };
  739. //----------------------------------------------------------------------
  740. // From linux-2.6.8.1/include/asm-ppc/ipc.h
  741. //----------------------------------------------------------------------
  742. struct vki_ipc_kludge {
  743. struct vki_msgbuf __user *msgp;
  744. long msgtyp;
  745. };
  746. #define VKI_SEMOP 1
  747. #define VKI_SEMGET 2
  748. #define VKI_SEMCTL 3
  749. #define VKI_SEMTIMEDOP 4
  750. #define VKI_MSGSND 11
  751. #define VKI_MSGRCV 12
  752. #define VKI_MSGGET 13
  753. #define VKI_MSGCTL 14
  754. #define VKI_SHMAT 21
  755. #define VKI_SHMDT 22
  756. #define VKI_SHMGET 23
  757. #define VKI_SHMCTL 24
  758. //----------------------------------------------------------------------
  759. // From linux-2.6.9/include/asm-ppc/shmbuf.h
  760. //----------------------------------------------------------------------
  761. struct vki_shmid64_ds {
  762. struct vki_ipc64_perm shm_perm; /* operation perms */
  763. unsigned int __unused1;
  764. __vki_kernel_time_t shm_atime; /* last attach time */
  765. unsigned int __unused2;
  766. __vki_kernel_time_t shm_dtime; /* last detach time */
  767. unsigned int __unused3;
  768. __vki_kernel_time_t shm_ctime; /* last change time */
  769. unsigned int __unused4;
  770. vki_size_t shm_segsz; /* size of segment (bytes) */
  771. __vki_kernel_pid_t shm_cpid; /* pid of creator */
  772. __vki_kernel_pid_t shm_lpid; /* pid of last operator */
  773. unsigned long shm_nattch; /* no. of current attaches */
  774. unsigned long __unused5;
  775. unsigned long __unused6;
  776. };
  777. struct vki_shminfo64 {
  778. unsigned long shmmax;
  779. unsigned long shmmin;
  780. unsigned long shmmni;
  781. unsigned long shmseg;
  782. unsigned long shmall;
  783. unsigned long __unused1;
  784. unsigned long __unused2;
  785. unsigned long __unused3;
  786. unsigned long __unused4;
  787. };
  788. //----------------------------------------------------------------------
  789. // From linux-2.6.8.1/include/asm-generic/errno.h
  790. //----------------------------------------------------------------------
  791. #define VKI_ENOSYS 38 /* Function not implemented */
  792. #define VKI_EOVERFLOW 75 /* Value too large for defined data type */
  793. //.. //----------------------------------------------------------------------
  794. //.. // DRM ioctls
  795. //.. //----------------------------------------------------------------------
  796. //..
  797. //.. // jrs 20050207: where did all this stuff come from? Is it really
  798. //.. // i386 specific, or should it go into the linux-generic category?
  799. //.. //struct vki_drm_buf_pub {
  800. //.. // Int idx; /**< Index into the master buffer list */
  801. //.. // Int total; /**< Buffer size */
  802. //.. // Int used; /**< Amount of buffer in use (for DMA) */
  803. //.. // void __user *address; /**< Address of buffer */
  804. //.. //};
  805. //.. //
  806. //.. //struct vki_drm_buf_map {
  807. //.. // Int count; /**< Length of the buffer list */
  808. //.. // void __user *virtual; /**< Mmap'd area in user-virtual */
  809. //.. // struct vki_drm_buf_pub __user *list; /**< Buffer information */
  810. //.. //};
  811. //.. //
  812. //.. ///* We need to pay attention to this, because it mmaps memory */
  813. //.. //#define VKI_DRM_IOCTL_MAP_BUFS _VKI_IOWR('d', 0x19, struct vki_drm_buf_map)
  814. //----------------------------------------------------------------------
  815. // And that's it!
  816. //----------------------------------------------------------------------
  817. #endif // __VKI_PPC32_LINUX_H
  818. /*--------------------------------------------------------------------*/
  819. /*--- end ---*/
  820. /*--------------------------------------------------------------------*/