2
0

syscall_defs.h 86 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625
  1. /* common syscall defines for all architectures */
  2. /* Note: although the syscall numbers change between architectures,
  3. most of them stay the same, so we handle it by putting ifdefs if
  4. necessary */
  5. #ifndef SYSCALL_DEFS_H
  6. #define SYSCALL_DEFS_H
  7. #include "syscall_nr.h"
  8. /* socket operations for socketcall() */
  9. #define TARGET_SYS_SOCKET 1 /* socket() */
  10. #define TARGET_SYS_BIND 2 /* bind() */
  11. #define TARGET_SYS_CONNECT 3 /* connect() */
  12. #define TARGET_SYS_LISTEN 4 /* listen() */
  13. #define TARGET_SYS_ACCEPT 5 /* accept() */
  14. #define TARGET_SYS_GETSOCKNAME 6 /* getsockname() */
  15. #define TARGET_SYS_GETPEERNAME 7 /* getpeername() */
  16. #define TARGET_SYS_SOCKETPAIR 8 /* socketpair() */
  17. #define TARGET_SYS_SEND 9 /* send() */
  18. #define TARGET_SYS_RECV 10 /* recv() */
  19. #define TARGET_SYS_SENDTO 11 /* sendto() */
  20. #define TARGET_SYS_RECVFROM 12 /* recvfrom() */
  21. #define TARGET_SYS_SHUTDOWN 13 /* shutdown() */
  22. #define TARGET_SYS_SETSOCKOPT 14 /* setsockopt() */
  23. #define TARGET_SYS_GETSOCKOPT 15 /* getsockopt() */
  24. #define TARGET_SYS_SENDMSG 16 /* sendmsg() */
  25. #define TARGET_SYS_RECVMSG 17 /* recvmsg() */
  26. #define TARGET_SYS_ACCEPT4 18 /* accept4() */
  27. #define TARGET_SYS_RECVMMSG 19 /* recvmmsg() */
  28. #define TARGET_SYS_SENDMMSG 20 /* sendmmsg() */
  29. #define IPCOP_CALL(VERSION, OP) ((VERSION) << 16 | (OP))
  30. #define IPCOP_semop 1
  31. #define IPCOP_semget 2
  32. #define IPCOP_semctl 3
  33. #define IPCOP_semtimedop 4
  34. #define IPCOP_msgsnd 11
  35. #define IPCOP_msgrcv 12
  36. #define IPCOP_msgget 13
  37. #define IPCOP_msgctl 14
  38. #define IPCOP_shmat 21
  39. #define IPCOP_shmdt 22
  40. #define IPCOP_shmget 23
  41. #define IPCOP_shmctl 24
  42. /*
  43. * The following is for compatibility across the various Linux
  44. * platforms. The i386 ioctl numbering scheme doesn't really enforce
  45. * a type field. De facto, however, the top 8 bits of the lower 16
  46. * bits are indeed used as a type field, so we might just as well make
  47. * this explicit here. Please be sure to use the decoding macros
  48. * below from now on.
  49. */
  50. #define TARGET_IOC_NRBITS 8
  51. #define TARGET_IOC_TYPEBITS 8
  52. #if (defined(TARGET_I386) && defined(TARGET_ABI32)) \
  53. || (defined(TARGET_ARM) && defined(TARGET_ABI32)) \
  54. || defined(TARGET_SPARC) \
  55. || defined(TARGET_M68K) || defined(TARGET_SH4) || defined(TARGET_CRIS)
  56. /* 16 bit uid wrappers emulation */
  57. #define USE_UID16
  58. #define target_id uint16_t
  59. #else
  60. #define target_id uint32_t
  61. #endif
  62. #if defined(TARGET_I386) || defined(TARGET_ARM) || defined(TARGET_SH4) \
  63. || defined(TARGET_M68K) || defined(TARGET_CRIS) \
  64. || defined(TARGET_S390X) \
  65. || defined(TARGET_OPENRISC) || defined(TARGET_TILEGX) \
  66. || defined(TARGET_NIOS2) || defined(TARGET_RISCV) \
  67. || defined(TARGET_XTENSA)
  68. #define TARGET_IOC_SIZEBITS 14
  69. #define TARGET_IOC_DIRBITS 2
  70. #define TARGET_IOC_NONE 0U
  71. #define TARGET_IOC_WRITE 1U
  72. #define TARGET_IOC_READ 2U
  73. #elif defined(TARGET_PPC) || defined(TARGET_ALPHA) || \
  74. defined(TARGET_SPARC) || defined(TARGET_MICROBLAZE) || \
  75. defined(TARGET_MIPS)
  76. #define TARGET_IOC_SIZEBITS 13
  77. #define TARGET_IOC_DIRBITS 3
  78. #define TARGET_IOC_NONE 1U
  79. #define TARGET_IOC_READ 2U
  80. #define TARGET_IOC_WRITE 4U
  81. #elif defined(TARGET_HPPA)
  82. #define TARGET_IOC_SIZEBITS 14
  83. #define TARGET_IOC_DIRBITS 2
  84. #define TARGET_IOC_NONE 0U
  85. #define TARGET_IOC_WRITE 2U
  86. #define TARGET_IOC_READ 1U
  87. #else
  88. #error unsupported CPU
  89. #endif
  90. #define TARGET_IOC_NRMASK ((1 << TARGET_IOC_NRBITS)-1)
  91. #define TARGET_IOC_TYPEMASK ((1 << TARGET_IOC_TYPEBITS)-1)
  92. #define TARGET_IOC_SIZEMASK ((1 << TARGET_IOC_SIZEBITS)-1)
  93. #define TARGET_IOC_DIRMASK ((1 << TARGET_IOC_DIRBITS)-1)
  94. #define TARGET_IOC_NRSHIFT 0
  95. #define TARGET_IOC_TYPESHIFT (TARGET_IOC_NRSHIFT+TARGET_IOC_NRBITS)
  96. #define TARGET_IOC_SIZESHIFT (TARGET_IOC_TYPESHIFT+TARGET_IOC_TYPEBITS)
  97. #define TARGET_IOC_DIRSHIFT (TARGET_IOC_SIZESHIFT+TARGET_IOC_SIZEBITS)
  98. #define TARGET_IOC(dir,type,nr,size) \
  99. (((dir) << TARGET_IOC_DIRSHIFT) | \
  100. ((type) << TARGET_IOC_TYPESHIFT) | \
  101. ((nr) << TARGET_IOC_NRSHIFT) | \
  102. ((size) << TARGET_IOC_SIZESHIFT))
  103. /* used to create numbers */
  104. #define TARGET_IO(type,nr) TARGET_IOC(TARGET_IOC_NONE,(type),(nr),0)
  105. #define TARGET_IOR(type,nr,size) TARGET_IOC(TARGET_IOC_READ,(type),(nr),sizeof(size))
  106. #define TARGET_IOW(type,nr,size) TARGET_IOC(TARGET_IOC_WRITE,(type),(nr),sizeof(size))
  107. #define TARGET_IOWR(type,nr,size) TARGET_IOC(TARGET_IOC_READ|TARGET_IOC_WRITE,(type),(nr),sizeof(size))
  108. /* the size is automatically computed for these defines */
  109. #define TARGET_IORU(type,nr) TARGET_IOC(TARGET_IOC_READ,(type),(nr),TARGET_IOC_SIZEMASK)
  110. #define TARGET_IOWU(type,nr) TARGET_IOC(TARGET_IOC_WRITE,(type),(nr),TARGET_IOC_SIZEMASK)
  111. #define TARGET_IOWRU(type,nr) TARGET_IOC(TARGET_IOC_READ|TARGET_IOC_WRITE,(type),(nr),TARGET_IOC_SIZEMASK)
  112. struct target_sockaddr {
  113. abi_ushort sa_family;
  114. uint8_t sa_data[14];
  115. };
  116. struct target_sockaddr_ll {
  117. abi_ushort sll_family; /* Always AF_PACKET */
  118. abi_ushort sll_protocol; /* Physical layer protocol */
  119. abi_int sll_ifindex; /* Interface number */
  120. abi_ushort sll_hatype; /* ARP hardware type */
  121. uint8_t sll_pkttype; /* Packet type */
  122. uint8_t sll_halen; /* Length of address */
  123. uint8_t sll_addr[8]; /* Physical layer address */
  124. };
  125. struct target_sockaddr_un {
  126. abi_ushort su_family;
  127. uint8_t sun_path[108];
  128. };
  129. struct target_sockaddr_nl {
  130. abi_ushort nl_family; /* AF_NETLINK */
  131. abi_ushort __pad;
  132. abi_uint nl_pid;
  133. abi_uint nl_groups;
  134. };
  135. struct target_in_addr {
  136. abi_uint s_addr; /* big endian */
  137. };
  138. struct target_sockaddr_in {
  139. abi_ushort sin_family;
  140. abi_short sin_port; /* big endian */
  141. struct target_in_addr sin_addr;
  142. uint8_t __pad[sizeof(struct target_sockaddr) -
  143. sizeof(abi_ushort) - sizeof(abi_short) -
  144. sizeof(struct target_in_addr)];
  145. };
  146. struct target_sockaddr_in6 {
  147. abi_ushort sin6_family;
  148. abi_ushort sin6_port; /* big endian */
  149. abi_uint sin6_flowinfo; /* big endian */
  150. struct in6_addr sin6_addr; /* IPv6 address, big endian */
  151. abi_uint sin6_scope_id;
  152. };
  153. struct target_sock_filter {
  154. abi_ushort code;
  155. uint8_t jt;
  156. uint8_t jf;
  157. abi_uint k;
  158. };
  159. struct target_sock_fprog {
  160. abi_ushort len;
  161. abi_ulong filter;
  162. };
  163. struct target_ip_mreq {
  164. struct target_in_addr imr_multiaddr;
  165. struct target_in_addr imr_address;
  166. };
  167. struct target_ip_mreqn {
  168. struct target_in_addr imr_multiaddr;
  169. struct target_in_addr imr_address;
  170. abi_long imr_ifindex;
  171. };
  172. struct target_ip_mreq_source {
  173. /* big endian */
  174. uint32_t imr_multiaddr;
  175. uint32_t imr_interface;
  176. uint32_t imr_sourceaddr;
  177. };
  178. struct target_linger {
  179. abi_int l_onoff; /* Linger active */
  180. abi_int l_linger; /* How long to linger for */
  181. };
  182. #if defined(TARGET_SPARC64) && !defined(TARGET_ABI32)
  183. struct target_timeval {
  184. abi_long tv_sec;
  185. abi_int tv_usec;
  186. };
  187. #define target__kernel_sock_timeval target_timeval
  188. #else
  189. struct target_timeval {
  190. abi_long tv_sec;
  191. abi_long tv_usec;
  192. };
  193. struct target__kernel_sock_timeval {
  194. abi_llong tv_sec;
  195. abi_llong tv_usec;
  196. };
  197. #endif
  198. struct target_timespec {
  199. abi_long tv_sec;
  200. abi_long tv_nsec;
  201. };
  202. struct target__kernel_timespec {
  203. abi_llong tv_sec;
  204. abi_llong tv_nsec;
  205. };
  206. struct target_timezone {
  207. abi_int tz_minuteswest;
  208. abi_int tz_dsttime;
  209. };
  210. struct target_itimerval {
  211. struct target_timeval it_interval;
  212. struct target_timeval it_value;
  213. };
  214. struct target_itimerspec {
  215. struct target_timespec it_interval;
  216. struct target_timespec it_value;
  217. };
  218. struct target_timex {
  219. abi_uint modes; /* Mode selector */
  220. abi_long offset; /* Time offset */
  221. abi_long freq; /* Frequency offset */
  222. abi_long maxerror; /* Maximum error (microseconds) */
  223. abi_long esterror; /* Estimated error (microseconds) */
  224. abi_int status; /* Clock command/status */
  225. abi_long constant; /* PLL (phase-locked loop) time constant */
  226. abi_long precision; /* Clock precision (microseconds, ro) */
  227. abi_long tolerance; /* Clock freq. tolerance (ppm, ro) */
  228. struct target_timeval time; /* Current time */
  229. abi_long tick; /* Microseconds between clock ticks */
  230. abi_long ppsfreq; /* PPS (pulse per second) frequency */
  231. abi_long jitter; /* PPS jitter (ro); nanoseconds */
  232. abi_int shift; /* PPS interval duration (seconds) */
  233. abi_long stabil; /* PPS stability */
  234. abi_long jitcnt; /* PPS jitter limit exceeded (ro) */
  235. abi_long calcnt; /* PPS calibration intervals */
  236. abi_long errcnt; /* PPS calibration errors */
  237. abi_long stbcnt; /* PPS stability limit exceeded */
  238. abi_int tai; /* TAI offset */
  239. /* Further padding bytes to allow for future expansion */
  240. abi_int:32; abi_int:32; abi_int:32; abi_int:32;
  241. abi_int:32; abi_int:32; abi_int:32; abi_int:32;
  242. abi_int:32; abi_int:32; abi_int:32;
  243. };
  244. typedef abi_long target_clock_t;
  245. #define TARGET_HZ 100
  246. struct target_tms {
  247. target_clock_t tms_utime;
  248. target_clock_t tms_stime;
  249. target_clock_t tms_cutime;
  250. target_clock_t tms_cstime;
  251. };
  252. struct target_utimbuf {
  253. abi_long actime;
  254. abi_long modtime;
  255. };
  256. struct target_sel_arg_struct {
  257. abi_long n;
  258. abi_long inp, outp, exp;
  259. abi_long tvp;
  260. };
  261. struct target_iovec {
  262. abi_long iov_base; /* Starting address */
  263. abi_long iov_len; /* Number of bytes */
  264. };
  265. struct target_msghdr {
  266. abi_long msg_name; /* Socket name */
  267. int msg_namelen; /* Length of name */
  268. abi_long msg_iov; /* Data blocks */
  269. abi_long msg_iovlen; /* Number of blocks */
  270. abi_long msg_control; /* Per protocol magic (eg BSD file descriptor passing) */
  271. abi_long msg_controllen; /* Length of cmsg list */
  272. unsigned int msg_flags;
  273. };
  274. struct target_cmsghdr {
  275. abi_long cmsg_len;
  276. int cmsg_level;
  277. int cmsg_type;
  278. };
  279. #define TARGET_CMSG_DATA(cmsg) ((unsigned char *) ((struct target_cmsghdr *) (cmsg) + 1))
  280. #define TARGET_CMSG_NXTHDR(mhdr, cmsg, cmsg_start) \
  281. __target_cmsg_nxthdr(mhdr, cmsg, cmsg_start)
  282. #define TARGET_CMSG_ALIGN(len) (((len) + sizeof (abi_long) - 1) \
  283. & (size_t) ~(sizeof (abi_long) - 1))
  284. #define TARGET_CMSG_SPACE(len) (sizeof(struct target_cmsghdr) + \
  285. TARGET_CMSG_ALIGN(len))
  286. #define TARGET_CMSG_LEN(len) (sizeof(struct target_cmsghdr) + (len))
  287. static __inline__ struct target_cmsghdr *
  288. __target_cmsg_nxthdr(struct target_msghdr *__mhdr,
  289. struct target_cmsghdr *__cmsg,
  290. struct target_cmsghdr *__cmsg_start)
  291. {
  292. struct target_cmsghdr *__ptr;
  293. __ptr = (struct target_cmsghdr *)((unsigned char *) __cmsg
  294. + TARGET_CMSG_ALIGN (tswapal(__cmsg->cmsg_len)));
  295. if ((unsigned long)((char *)(__ptr+1) - (char *)__cmsg_start)
  296. > tswapal(__mhdr->msg_controllen)) {
  297. /* No more entries. */
  298. return (struct target_cmsghdr *)0;
  299. }
  300. return __ptr;
  301. }
  302. struct target_mmsghdr {
  303. struct target_msghdr msg_hdr; /* Message header */
  304. unsigned int msg_len; /* Number of bytes transmitted */
  305. };
  306. struct target_rusage {
  307. struct target_timeval ru_utime; /* user time used */
  308. struct target_timeval ru_stime; /* system time used */
  309. abi_long ru_maxrss; /* maximum resident set size */
  310. abi_long ru_ixrss; /* integral shared memory size */
  311. abi_long ru_idrss; /* integral unshared data size */
  312. abi_long ru_isrss; /* integral unshared stack size */
  313. abi_long ru_minflt; /* page reclaims */
  314. abi_long ru_majflt; /* page faults */
  315. abi_long ru_nswap; /* swaps */
  316. abi_long ru_inblock; /* block input operations */
  317. abi_long ru_oublock; /* block output operations */
  318. abi_long ru_msgsnd; /* messages sent */
  319. abi_long ru_msgrcv; /* messages received */
  320. abi_long ru_nsignals; /* signals received */
  321. abi_long ru_nvcsw; /* voluntary context switches */
  322. abi_long ru_nivcsw; /* involuntary " */
  323. };
  324. typedef struct {
  325. int val[2];
  326. } kernel_fsid_t;
  327. struct target_dirent {
  328. abi_long d_ino;
  329. abi_long d_off;
  330. unsigned short d_reclen;
  331. char d_name[];
  332. };
  333. struct target_dirent64 {
  334. uint64_t d_ino;
  335. int64_t d_off;
  336. unsigned short d_reclen;
  337. unsigned char d_type;
  338. char d_name[256];
  339. };
  340. /* mostly generic signal stuff */
  341. #define TARGET_SIG_DFL ((abi_long)0) /* default signal handling */
  342. #define TARGET_SIG_IGN ((abi_long)1) /* ignore signal */
  343. #define TARGET_SIG_ERR ((abi_long)-1) /* error return from signal */
  344. #ifdef TARGET_MIPS
  345. #define TARGET_NSIG 128
  346. #else
  347. #define TARGET_NSIG 64
  348. #endif
  349. #define TARGET_NSIG_BPW TARGET_ABI_BITS
  350. #define TARGET_NSIG_WORDS (TARGET_NSIG / TARGET_NSIG_BPW)
  351. typedef struct {
  352. abi_ulong sig[TARGET_NSIG_WORDS];
  353. } target_sigset_t;
  354. #ifdef BSWAP_NEEDED
  355. static inline void tswap_sigset(target_sigset_t *d, const target_sigset_t *s)
  356. {
  357. int i;
  358. for(i = 0;i < TARGET_NSIG_WORDS; i++)
  359. d->sig[i] = tswapal(s->sig[i]);
  360. }
  361. #else
  362. static inline void tswap_sigset(target_sigset_t *d, const target_sigset_t *s)
  363. {
  364. *d = *s;
  365. }
  366. #endif
  367. static inline void target_siginitset(target_sigset_t *d, abi_ulong set)
  368. {
  369. int i;
  370. d->sig[0] = set;
  371. for(i = 1;i < TARGET_NSIG_WORDS; i++)
  372. d->sig[i] = 0;
  373. }
  374. void host_to_target_sigset(target_sigset_t *d, const sigset_t *s);
  375. void target_to_host_sigset(sigset_t *d, const target_sigset_t *s);
  376. void host_to_target_old_sigset(abi_ulong *old_sigset,
  377. const sigset_t *sigset);
  378. void target_to_host_old_sigset(sigset_t *sigset,
  379. const abi_ulong *old_sigset);
  380. struct target_sigaction;
  381. int do_sigaction(int sig, const struct target_sigaction *act,
  382. struct target_sigaction *oact);
  383. #include "target_signal.h"
  384. #ifdef TARGET_SA_RESTORER
  385. #define TARGET_ARCH_HAS_SA_RESTORER 1
  386. #endif
  387. #if defined(TARGET_ALPHA)
  388. struct target_old_sigaction {
  389. abi_ulong _sa_handler;
  390. abi_ulong sa_mask;
  391. int32_t sa_flags;
  392. };
  393. struct target_rt_sigaction {
  394. abi_ulong _sa_handler;
  395. abi_ulong sa_flags;
  396. target_sigset_t sa_mask;
  397. };
  398. /* This is the struct used inside the kernel. The ka_restorer
  399. field comes from the 5th argument to sys_rt_sigaction. */
  400. struct target_sigaction {
  401. abi_ulong _sa_handler;
  402. abi_ulong sa_flags;
  403. target_sigset_t sa_mask;
  404. abi_ulong sa_restorer;
  405. };
  406. #elif defined(TARGET_MIPS)
  407. struct target_sigaction {
  408. uint32_t sa_flags;
  409. #if defined(TARGET_ABI_MIPSN32)
  410. uint32_t _sa_handler;
  411. #else
  412. abi_ulong _sa_handler;
  413. #endif
  414. target_sigset_t sa_mask;
  415. #ifdef TARGET_ARCH_HAS_SA_RESTORER
  416. /* ??? This is always present, but ignored unless O32. */
  417. abi_ulong sa_restorer;
  418. #endif
  419. };
  420. #else
  421. struct target_old_sigaction {
  422. abi_ulong _sa_handler;
  423. abi_ulong sa_mask;
  424. abi_ulong sa_flags;
  425. #ifdef TARGET_ARCH_HAS_SA_RESTORER
  426. abi_ulong sa_restorer;
  427. #endif
  428. };
  429. struct target_sigaction {
  430. abi_ulong _sa_handler;
  431. abi_ulong sa_flags;
  432. #ifdef TARGET_ARCH_HAS_SA_RESTORER
  433. abi_ulong sa_restorer;
  434. #endif
  435. target_sigset_t sa_mask;
  436. #ifdef TARGET_ARCH_HAS_KA_RESTORER
  437. abi_ulong ka_restorer;
  438. #endif
  439. };
  440. #endif
  441. typedef union target_sigval {
  442. int sival_int;
  443. abi_ulong sival_ptr;
  444. } target_sigval_t;
  445. #if 0
  446. #if defined (TARGET_SPARC)
  447. typedef struct {
  448. struct {
  449. abi_ulong psr;
  450. abi_ulong pc;
  451. abi_ulong npc;
  452. abi_ulong y;
  453. abi_ulong u_regs[16]; /* globals and ins */
  454. } si_regs;
  455. int si_mask;
  456. } __siginfo_t;
  457. typedef struct {
  458. unsigned long si_float_regs [32];
  459. unsigned long si_fsr;
  460. unsigned long si_fpqdepth;
  461. struct {
  462. unsigned long *insn_addr;
  463. unsigned long insn;
  464. } si_fpqueue [16];
  465. } __siginfo_fpu_t;
  466. #endif
  467. #endif
  468. #define TARGET_SI_MAX_SIZE 128
  469. #if TARGET_ABI_BITS == 32
  470. #define TARGET_SI_PREAMBLE_SIZE (3 * sizeof(int))
  471. #else
  472. #define TARGET_SI_PREAMBLE_SIZE (4 * sizeof(int))
  473. #endif
  474. #define TARGET_SI_PAD_SIZE ((TARGET_SI_MAX_SIZE - TARGET_SI_PREAMBLE_SIZE) / sizeof(int))
  475. /* Within QEMU the top 16 bits of si_code indicate which of the parts of
  476. * the union in target_siginfo is valid. This only applies between
  477. * host_to_target_siginfo_noswap() and tswap_siginfo(); it does not
  478. * appear either within host siginfo_t or in target_siginfo structures
  479. * which we get from the guest userspace program. (The Linux kernel
  480. * does a similar thing with using the top bits for its own internal
  481. * purposes but not letting them be visible to userspace.)
  482. */
  483. #define QEMU_SI_KILL 0
  484. #define QEMU_SI_TIMER 1
  485. #define QEMU_SI_POLL 2
  486. #define QEMU_SI_FAULT 3
  487. #define QEMU_SI_CHLD 4
  488. #define QEMU_SI_RT 5
  489. typedef struct target_siginfo {
  490. #ifdef TARGET_MIPS
  491. int si_signo;
  492. int si_code;
  493. int si_errno;
  494. #else
  495. int si_signo;
  496. int si_errno;
  497. int si_code;
  498. #endif
  499. union {
  500. int _pad[TARGET_SI_PAD_SIZE];
  501. /* kill() */
  502. struct {
  503. pid_t _pid; /* sender's pid */
  504. uid_t _uid; /* sender's uid */
  505. } _kill;
  506. /* POSIX.1b timers */
  507. struct {
  508. unsigned int _timer1;
  509. unsigned int _timer2;
  510. } _timer;
  511. /* POSIX.1b signals */
  512. struct {
  513. pid_t _pid; /* sender's pid */
  514. uid_t _uid; /* sender's uid */
  515. target_sigval_t _sigval;
  516. } _rt;
  517. /* SIGCHLD */
  518. struct {
  519. pid_t _pid; /* which child */
  520. uid_t _uid; /* sender's uid */
  521. int _status; /* exit code */
  522. target_clock_t _utime;
  523. target_clock_t _stime;
  524. } _sigchld;
  525. /* SIGILL, SIGFPE, SIGSEGV, SIGBUS */
  526. struct {
  527. abi_ulong _addr; /* faulting insn/memory ref. */
  528. } _sigfault;
  529. /* SIGPOLL */
  530. struct {
  531. int _band; /* POLL_IN, POLL_OUT, POLL_MSG */
  532. int _fd;
  533. } _sigpoll;
  534. } _sifields;
  535. } target_siginfo_t;
  536. /*
  537. * si_code values
  538. * Digital reserves positive values for kernel-generated signals.
  539. */
  540. #define TARGET_SI_USER 0 /* sent by kill, sigsend, raise */
  541. #define TARGET_SI_KERNEL 0x80 /* sent by the kernel from somewhere */
  542. #define TARGET_SI_QUEUE -1 /* sent by sigqueue */
  543. #define TARGET_SI_TIMER -2 /* sent by timer expiration */
  544. #define TARGET_SI_MESGQ -3 /* sent by real time mesq state change */
  545. #define TARGET_SI_ASYNCIO -4 /* sent by AIO completion */
  546. #define TARGET_SI_SIGIO -5 /* sent by queued SIGIO */
  547. /*
  548. * SIGILL si_codes
  549. */
  550. #define TARGET_ILL_ILLOPC (1) /* illegal opcode */
  551. #define TARGET_ILL_ILLOPN (2) /* illegal operand */
  552. #define TARGET_ILL_ILLADR (3) /* illegal addressing mode */
  553. #define TARGET_ILL_ILLTRP (4) /* illegal trap */
  554. #define TARGET_ILL_PRVOPC (5) /* privileged opcode */
  555. #define TARGET_ILL_PRVREG (6) /* privileged register */
  556. #define TARGET_ILL_COPROC (7) /* coprocessor error */
  557. #define TARGET_ILL_BADSTK (8) /* internal stack error */
  558. #ifdef TARGET_TILEGX
  559. #define TARGET_ILL_DBLFLT (9) /* double fault */
  560. #define TARGET_ILL_HARDWALL (10) /* user networks hardwall violation */
  561. #endif
  562. /*
  563. * SIGFPE si_codes
  564. */
  565. #define TARGET_FPE_INTDIV (1) /* integer divide by zero */
  566. #define TARGET_FPE_INTOVF (2) /* integer overflow */
  567. #define TARGET_FPE_FLTDIV (3) /* floating point divide by zero */
  568. #define TARGET_FPE_FLTOVF (4) /* floating point overflow */
  569. #define TARGET_FPE_FLTUND (5) /* floating point underflow */
  570. #define TARGET_FPE_FLTRES (6) /* floating point inexact result */
  571. #define TARGET_FPE_FLTINV (7) /* floating point invalid operation */
  572. #define TARGET_FPE_FLTSUB (8) /* subscript out of range */
  573. #define TARGET_FPE_FLTUNK (14) /* undiagnosed fp exception */
  574. #define TARGET_NSIGFPE 15
  575. /*
  576. * SIGSEGV si_codes
  577. */
  578. #define TARGET_SEGV_MAPERR (1) /* address not mapped to object */
  579. #define TARGET_SEGV_ACCERR (2) /* invalid permissions for mapped object */
  580. #define TARGET_SEGV_BNDERR (3) /* failed address bound checks */
  581. /*
  582. * SIGBUS si_codes
  583. */
  584. #define TARGET_BUS_ADRALN (1) /* invalid address alignment */
  585. #define TARGET_BUS_ADRERR (2) /* non-existent physical address */
  586. #define TARGET_BUS_OBJERR (3) /* object specific hardware error */
  587. /* hardware memory error consumed on a machine check: action required */
  588. #define TARGET_BUS_MCEERR_AR (4)
  589. /* hardware memory error detected in process but not consumed: action optional*/
  590. #define TARGET_BUS_MCEERR_AO (5)
  591. /*
  592. * SIGTRAP si_codes
  593. */
  594. #define TARGET_TRAP_BRKPT (1) /* process breakpoint */
  595. #define TARGET_TRAP_TRACE (2) /* process trace trap */
  596. #define TARGET_TRAP_BRANCH (3) /* process taken branch trap */
  597. #define TARGET_TRAP_HWBKPT (4) /* hardware breakpoint/watchpoint */
  598. struct target_rlimit {
  599. abi_ulong rlim_cur;
  600. abi_ulong rlim_max;
  601. };
  602. #if defined(TARGET_ALPHA)
  603. #define TARGET_RLIM_INFINITY 0x7fffffffffffffffull
  604. #elif defined(TARGET_MIPS) || (defined(TARGET_SPARC) && TARGET_ABI_BITS == 32)
  605. #define TARGET_RLIM_INFINITY 0x7fffffffUL
  606. #else
  607. #define TARGET_RLIM_INFINITY ((abi_ulong)-1)
  608. #endif
  609. #if defined(TARGET_MIPS)
  610. #define TARGET_RLIMIT_CPU 0
  611. #define TARGET_RLIMIT_FSIZE 1
  612. #define TARGET_RLIMIT_DATA 2
  613. #define TARGET_RLIMIT_STACK 3
  614. #define TARGET_RLIMIT_CORE 4
  615. #define TARGET_RLIMIT_RSS 7
  616. #define TARGET_RLIMIT_NPROC 8
  617. #define TARGET_RLIMIT_NOFILE 5
  618. #define TARGET_RLIMIT_MEMLOCK 9
  619. #define TARGET_RLIMIT_AS 6
  620. #define TARGET_RLIMIT_LOCKS 10
  621. #define TARGET_RLIMIT_SIGPENDING 11
  622. #define TARGET_RLIMIT_MSGQUEUE 12
  623. #define TARGET_RLIMIT_NICE 13
  624. #define TARGET_RLIMIT_RTPRIO 14
  625. #else
  626. #define TARGET_RLIMIT_CPU 0
  627. #define TARGET_RLIMIT_FSIZE 1
  628. #define TARGET_RLIMIT_DATA 2
  629. #define TARGET_RLIMIT_STACK 3
  630. #define TARGET_RLIMIT_CORE 4
  631. #define TARGET_RLIMIT_RSS 5
  632. #if defined(TARGET_SPARC)
  633. #define TARGET_RLIMIT_NOFILE 6
  634. #define TARGET_RLIMIT_NPROC 7
  635. #else
  636. #define TARGET_RLIMIT_NPROC 6
  637. #define TARGET_RLIMIT_NOFILE 7
  638. #endif
  639. #define TARGET_RLIMIT_MEMLOCK 8
  640. #define TARGET_RLIMIT_AS 9
  641. #define TARGET_RLIMIT_LOCKS 10
  642. #define TARGET_RLIMIT_SIGPENDING 11
  643. #define TARGET_RLIMIT_MSGQUEUE 12
  644. #define TARGET_RLIMIT_NICE 13
  645. #define TARGET_RLIMIT_RTPRIO 14
  646. #endif
  647. struct target_pollfd {
  648. int fd; /* file descriptor */
  649. short events; /* requested events */
  650. short revents; /* returned events */
  651. };
  652. /* virtual terminal ioctls */
  653. #define TARGET_KIOCSOUND 0x4B2F /* start sound generation (0 for off) */
  654. #define TARGET_KDMKTONE 0x4B30 /* generate tone */
  655. #define TARGET_KDGKBTYPE 0x4b33
  656. #define TARGET_KDSETMODE 0x4b3a
  657. #define TARGET_KDGKBMODE 0x4b44
  658. #define TARGET_KDSKBMODE 0x4b45
  659. #define TARGET_KDGKBENT 0x4B46 /* gets one entry in translation table */
  660. #define TARGET_KDGKBSENT 0x4B48 /* gets one function key string entry */
  661. #define TARGET_KDGKBLED 0x4B64 /* get led flags (not lights) */
  662. #define TARGET_KDSKBLED 0x4B65 /* set led flags (not lights) */
  663. #define TARGET_KDGETLED 0x4B31 /* return current led state */
  664. #define TARGET_KDSETLED 0x4B32 /* set led state [lights, not flags] */
  665. #define TARGET_KDSIGACCEPT 0x4B4E
  666. #if defined(TARGET_ALPHA) || defined(TARGET_MIPS) || defined(TARGET_SH4) || \
  667. defined(TARGET_XTENSA)
  668. #define TARGET_FIOGETOWN TARGET_IOR('f', 123, int)
  669. #define TARGET_FIOSETOWN TARGET_IOW('f', 124, int)
  670. #define TARGET_SIOCATMARK TARGET_IOR('s', 7, int)
  671. #define TARGET_SIOCSPGRP TARGET_IOW('s', 8, pid_t)
  672. #define TARGET_SIOCGPGRP TARGET_IOR('s', 9, pid_t)
  673. #else
  674. #define TARGET_FIOGETOWN 0x8903
  675. #define TARGET_FIOSETOWN 0x8901
  676. #define TARGET_SIOCATMARK 0x8905
  677. #define TARGET_SIOCSPGRP 0x8902
  678. #define TARGET_SIOCGPGRP 0x8904
  679. #endif
  680. #if defined(TARGET_SH4)
  681. #define TARGET_SIOCGSTAMP_OLD TARGET_IOR('s', 100, struct target_timeval)
  682. #define TARGET_SIOCGSTAMPNS_OLD TARGET_IOR('s', 101, struct target_timespec)
  683. #else
  684. #define TARGET_SIOCGSTAMP_OLD 0x8906
  685. #define TARGET_SIOCGSTAMPNS_OLD 0x8907
  686. #endif
  687. #define TARGET_SIOCGSTAMP_NEW TARGET_IOR(0x89, 0x06, abi_llong[2])
  688. #define TARGET_SIOCGSTAMPNS_NEW TARGET_IOR(0x89, 0x07, abi_llong[2])
  689. /* Networking ioctls */
  690. #define TARGET_SIOCADDRT 0x890B /* add routing table entry */
  691. #define TARGET_SIOCDELRT 0x890C /* delete routing table entry */
  692. #define TARGET_SIOCGIFNAME 0x8910 /* get iface name */
  693. #define TARGET_SIOCSIFLINK 0x8911 /* set iface channel */
  694. #define TARGET_SIOCGIFCONF 0x8912 /* get iface list */
  695. #define TARGET_SIOCGIFFLAGS 0x8913 /* get flags */
  696. #define TARGET_SIOCSIFFLAGS 0x8914 /* set flags */
  697. #define TARGET_SIOCGIFADDR 0x8915 /* get PA address */
  698. #define TARGET_SIOCSIFADDR 0x8916 /* set PA address */
  699. #define TARGET_SIOCGIFDSTADDR 0x8917 /* get remote PA address */
  700. #define TARGET_SIOCSIFDSTADDR 0x8918 /* set remote PA address */
  701. #define TARGET_SIOCGIFBRDADDR 0x8919 /* get broadcast PA address */
  702. #define TARGET_SIOCSIFBRDADDR 0x891a /* set broadcast PA address */
  703. #define TARGET_SIOCGIFNETMASK 0x891b /* get network PA mask */
  704. #define TARGET_SIOCSIFNETMASK 0x891c /* set network PA mask */
  705. #define TARGET_SIOCGIFMETRIC 0x891d /* get metric */
  706. #define TARGET_SIOCSIFMETRIC 0x891e /* set metric */
  707. #define TARGET_SIOCGIFMEM 0x891f /* get memory address (BSD) */
  708. #define TARGET_SIOCSIFMEM 0x8920 /* set memory address (BSD) */
  709. #define TARGET_SIOCGIFMTU 0x8921 /* get MTU size */
  710. #define TARGET_SIOCSIFMTU 0x8922 /* set MTU size */
  711. #define TARGET_SIOCSIFHWADDR 0x8924 /* set hardware address (NI) */
  712. #define TARGET_SIOCGIFENCAP 0x8925 /* get/set slip encapsulation */
  713. #define TARGET_SIOCSIFENCAP 0x8926
  714. #define TARGET_SIOCGIFHWADDR 0x8927 /* Get hardware address */
  715. #define TARGET_SIOCGIFSLAVE 0x8929 /* Driver slaving support */
  716. #define TARGET_SIOCSIFSLAVE 0x8930
  717. #define TARGET_SIOCADDMULTI 0x8931 /* Multicast address lists */
  718. #define TARGET_SIOCDELMULTI 0x8932
  719. #define TARGET_SIOCGIFINDEX 0x8933
  720. #define TARGET_SIOCSIFPFLAGS 0x8934 /* set extended flags */
  721. #define TARGET_SIOCGIFPFLAGS 0x8935 /* get extended flags */
  722. /* Bridging control calls */
  723. #define TARGET_SIOCGIFBR 0x8940 /* Bridging support */
  724. #define TARGET_SIOCSIFBR 0x8941 /* Set bridging options */
  725. #define TARGET_SIOCGIFTXQLEN 0x8942 /* Get the tx queue length */
  726. #define TARGET_SIOCSIFTXQLEN 0x8943 /* Set the tx queue length */
  727. /* ARP cache control calls. */
  728. #define TARGET_OLD_SIOCDARP 0x8950 /* old delete ARP table entry */
  729. #define TARGET_OLD_SIOCGARP 0x8951 /* old get ARP table entry */
  730. #define TARGET_OLD_SIOCSARP 0x8952 /* old set ARP table entry */
  731. #define TARGET_SIOCDARP 0x8953 /* delete ARP table entry */
  732. #define TARGET_SIOCGARP 0x8954 /* get ARP table entry */
  733. #define TARGET_SIOCSARP 0x8955 /* set ARP table entry */
  734. /* RARP cache control calls. */
  735. #define TARGET_SIOCDRARP 0x8960 /* delete RARP table entry */
  736. #define TARGET_SIOCGRARP 0x8961 /* get RARP table entry */
  737. #define TARGET_SIOCSRARP 0x8962 /* set RARP table entry */
  738. /* Driver configuration calls */
  739. #define TARGET_SIOCGIFMAP 0x8970 /* Get device parameters */
  740. #define TARGET_SIOCSIFMAP 0x8971 /* Set device parameters */
  741. /* DLCI configuration calls */
  742. #define TARGET_SIOCADDDLCI 0x8980 /* Create new DLCI device */
  743. #define TARGET_SIOCDELDLCI 0x8981 /* Delete DLCI device */
  744. /* From <linux/wireless.h> */
  745. #define TARGET_SIOCGIWNAME 0x8B01 /* get name == wireless protocol */
  746. /* From <linux/random.h> */
  747. #define TARGET_RNDGETENTCNT TARGET_IOR('R', 0x00, int)
  748. #define TARGET_RNDADDTOENTCNT TARGET_IOW('R', 0x01, int)
  749. #define TARGET_RNDZAPENTCNT TARGET_IO('R', 0x04)
  750. #define TARGET_RNDCLEARPOOL TARGET_IO('R', 0x06)
  751. #define TARGET_RNDRESEEDCRNG TARGET_IO('R', 0x07)
  752. /* From <linux/fs.h> */
  753. #define TARGET_BLKROSET TARGET_IO(0x12,93) /* set device read-only (0 = read-write) */
  754. #define TARGET_BLKROGET TARGET_IO(0x12,94) /* get read-only status (0 = read_write) */
  755. #define TARGET_BLKRRPART TARGET_IO(0x12,95) /* re-read partition table */
  756. #define TARGET_BLKGETSIZE TARGET_IO(0x12,96) /* return device size /512 (long *arg) */
  757. #define TARGET_BLKFLSBUF TARGET_IO(0x12,97) /* flush buffer cache */
  758. #define TARGET_BLKRASET TARGET_IO(0x12,98) /* Set read ahead for block device */
  759. #define TARGET_BLKRAGET TARGET_IO(0x12,99) /* get current read ahead setting */
  760. #define TARGET_BLKFRASET TARGET_IO(0x12,100)/* set filesystem (mm/filemap.c) read-ahead */
  761. #define TARGET_BLKFRAGET TARGET_IO(0x12,101)/* get filesystem (mm/filemap.c) read-ahead */
  762. #define TARGET_BLKSECTSET TARGET_IO(0x12,102)/* set max sectors per request (ll_rw_blk.c) */
  763. #define TARGET_BLKSECTGET TARGET_IO(0x12,103)/* get max sectors per request (ll_rw_blk.c) */
  764. #define TARGET_BLKSSZGET TARGET_IO(0x12,104)/* get block device sector size */
  765. #define TARGET_BLKPG TARGET_IO(0x12,105)/* Partition table and disk geometry handling */
  766. /* A jump here: 108-111 have been used for various private purposes. */
  767. #define TARGET_BLKBSZGET TARGET_IOR(0x12, 112, abi_ulong)
  768. #define TARGET_BLKBSZSET TARGET_IOW(0x12, 113, abi_ulong)
  769. #define TARGET_BLKGETSIZE64 TARGET_IOR(0x12,114,abi_ulong)
  770. /* return device size in bytes
  771. (u64 *arg) */
  772. #define TARGET_BLKDISCARD TARGET_IO(0x12, 119)
  773. #define TARGET_BLKIOMIN TARGET_IO(0x12, 120)
  774. #define TARGET_BLKIOOPT TARGET_IO(0x12, 121)
  775. #define TARGET_BLKALIGNOFF TARGET_IO(0x12, 122)
  776. #define TARGET_BLKPBSZGET TARGET_IO(0x12, 123)
  777. #define TARGET_BLKDISCARDZEROES TARGET_IO(0x12, 124)
  778. #define TARGET_BLKSECDISCARD TARGET_IO(0x12, 125)
  779. #define TARGET_BLKROTATIONAL TARGET_IO(0x12, 126)
  780. #define TARGET_BLKZEROOUT TARGET_IO(0x12, 127)
  781. /* From <linux/fd.h> */
  782. #define TARGET_FDMSGON TARGET_IO(2, 0x45)
  783. #define TARGET_FDMSGOFF TARGET_IO(2, 0x46)
  784. #define TARGET_FDFLUSH TARGET_IO(2, 0x4b)
  785. #define TARGET_FDRESET TARGET_IO(2, 0x54)
  786. #define TARGET_FDRAWCMD TARGET_IO(2, 0x58)
  787. #define TARGET_FDTWADDLE TARGET_IO(2, 0x59)
  788. #define TARGET_FDEJECT TARGET_IO(2, 0x5a)
  789. #define TARGET_FIBMAP TARGET_IO(0x00,1) /* bmap access */
  790. #define TARGET_FIGETBSZ TARGET_IO(0x00,2) /* get the block size used for bmap */
  791. #define TARGET_FICLONE TARGET_IOW(0x94, 9, int)
  792. #define TARGET_FICLONERANGE TARGET_IOW(0x94, 13, struct file_clone_range)
  793. /* Note that the ioctl numbers claim type "long" but the actual type
  794. * used by the kernel is "int".
  795. */
  796. #define TARGET_FS_IOC_GETFLAGS TARGET_IOR('f', 1, abi_long)
  797. #define TARGET_FS_IOC_SETFLAGS TARGET_IOW('f', 2, abi_long)
  798. #define TARGET_FS_IOC_FIEMAP TARGET_IOWR('f',11,struct fiemap)
  799. /* usb ioctls */
  800. #define TARGET_USBDEVFS_CONTROL TARGET_IOWRU('U', 0)
  801. #define TARGET_USBDEVFS_BULK TARGET_IOWRU('U', 2)
  802. #define TARGET_USBDEVFS_RESETEP TARGET_IORU('U', 3)
  803. #define TARGET_USBDEVFS_SETINTERFACE TARGET_IORU('U', 4)
  804. #define TARGET_USBDEVFS_SETCONFIGURATION TARGET_IORU('U', 5)
  805. #define TARGET_USBDEVFS_GETDRIVER TARGET_IOWU('U', 8)
  806. #define TARGET_USBDEVFS_SUBMITURB TARGET_IORU('U', 10)
  807. #define TARGET_USBDEVFS_DISCARDURB TARGET_IO('U', 11)
  808. #define TARGET_USBDEVFS_REAPURB TARGET_IOWU('U', 12)
  809. #define TARGET_USBDEVFS_REAPURBNDELAY TARGET_IOWU('U', 13)
  810. #define TARGET_USBDEVFS_DISCSIGNAL TARGET_IORU('U', 14)
  811. #define TARGET_USBDEVFS_CLAIMINTERFACE TARGET_IORU('U', 15)
  812. #define TARGET_USBDEVFS_RELEASEINTERFACE TARGET_IORU('U', 16)
  813. #define TARGET_USBDEVFS_CONNECTINFO TARGET_IOWU('U', 17)
  814. #define TARGET_USBDEVFS_IOCTL TARGET_IOWRU('U', 18)
  815. #define TARGET_USBDEVFS_HUB_PORTINFO TARGET_IORU('U', 19)
  816. #define TARGET_USBDEVFS_RESET TARGET_IO('U', 20)
  817. #define TARGET_USBDEVFS_CLEAR_HALT TARGET_IORU('U', 21)
  818. #define TARGET_USBDEVFS_DISCONNECT TARGET_IO('U', 22)
  819. #define TARGET_USBDEVFS_CONNECT TARGET_IO('U', 23)
  820. #define TARGET_USBDEVFS_CLAIM_PORT TARGET_IORU('U', 24)
  821. #define TARGET_USBDEVFS_RELEASE_PORT TARGET_IORU('U', 25)
  822. #define TARGET_USBDEVFS_GET_CAPABILITIES TARGET_IORU('U', 26)
  823. #define TARGET_USBDEVFS_DISCONNECT_CLAIM TARGET_IORU('U', 27)
  824. #define TARGET_USBDEVFS_DROP_PRIVILEGES TARGET_IOWU('U', 30)
  825. #define TARGET_USBDEVFS_GET_SPEED TARGET_IO('U', 31)
  826. /* cdrom commands */
  827. #define TARGET_CDROMPAUSE 0x5301 /* Pause Audio Operation */
  828. #define TARGET_CDROMRESUME 0x5302 /* Resume paused Audio Operation */
  829. #define TARGET_CDROMPLAYMSF 0x5303 /* Play Audio MSF (struct cdrom_msf) */
  830. #define TARGET_CDROMPLAYTRKIND 0x5304 /* Play Audio Track/index
  831. (struct cdrom_ti) */
  832. #define TARGET_CDROMREADTOCHDR 0x5305 /* Read TOC header
  833. (struct cdrom_tochdr) */
  834. #define TARGET_CDROMREADTOCENTRY 0x5306 /* Read TOC entry
  835. (struct cdrom_tocentry) */
  836. #define TARGET_CDROMSTOP 0x5307 /* Stop the cdrom drive */
  837. #define TARGET_CDROMSTART 0x5308 /* Start the cdrom drive */
  838. #define TARGET_CDROMEJECT 0x5309 /* Ejects the cdrom media */
  839. #define TARGET_CDROMVOLCTRL 0x530a /* Control output volume
  840. (struct cdrom_volctrl) */
  841. #define TARGET_CDROMSUBCHNL 0x530b /* Read subchannel data
  842. (struct cdrom_subchnl) */
  843. #define TARGET_CDROMREADMODE2 0x530c /* Read TARGET_CDROM mode 2 data (2336 Bytes)
  844. (struct cdrom_read) */
  845. #define TARGET_CDROMREADMODE1 0x530d /* Read TARGET_CDROM mode 1 data (2048 Bytes)
  846. (struct cdrom_read) */
  847. #define TARGET_CDROMREADAUDIO 0x530e /* (struct cdrom_read_audio) */
  848. #define TARGET_CDROMEJECT_SW 0x530f /* enable(1)/disable(0) auto-ejecting */
  849. #define TARGET_CDROMMULTISESSION 0x5310 /* Obtain the start-of-last-session
  850. address of multi session disks
  851. (struct cdrom_multisession) */
  852. #define TARGET_CDROM_GET_MCN 0x5311 /* Obtain the "Universal Product Code"
  853. if available (struct cdrom_mcn) */
  854. #define TARGET_CDROM_GET_UPC TARGET_CDROM_GET_MCN /* This one is deprecated,
  855. but here anyway for compatibility */
  856. #define TARGET_CDROMRESET 0x5312 /* hard-reset the drive */
  857. #define TARGET_CDROMVOLREAD 0x5313 /* Get the drive's volume setting
  858. (struct cdrom_volctrl) */
  859. #define TARGET_CDROMREADRAW 0x5314 /* read data in raw mode (2352 Bytes)
  860. (struct cdrom_read) */
  861. /*
  862. * These ioctls are used only used in aztcd.c and optcd.c
  863. */
  864. #define TARGET_CDROMREADCOOKED 0x5315 /* read data in cooked mode */
  865. #define TARGET_CDROMSEEK 0x5316 /* seek msf address */
  866. /*
  867. * This ioctl is only used by the scsi-cd driver.
  868. It is for playing audio in logical block addressing mode.
  869. */
  870. #define TARGET_CDROMPLAYBLK 0x5317 /* (struct cdrom_blk) */
  871. /*
  872. * These ioctls are only used in optcd.c
  873. */
  874. #define TARGET_CDROMREADALL 0x5318 /* read all 2646 bytes */
  875. /*
  876. * These ioctls are (now) only in ide-cd.c for controlling
  877. * drive spindown time. They should be implemented in the
  878. * Uniform driver, via generic packet commands, GPCMD_MODE_SELECT_10,
  879. * GPCMD_MODE_SENSE_10 and the GPMODE_POWER_PAGE...
  880. * -Erik
  881. */
  882. #define TARGET_CDROMGETSPINDOWN 0x531d
  883. #define TARGET_CDROMSETSPINDOWN 0x531e
  884. /*
  885. * These ioctls are implemented through the uniform CD-ROM driver
  886. * They _will_ be adopted by all CD-ROM drivers, when all the CD-ROM
  887. * drivers are eventually ported to the uniform CD-ROM driver interface.
  888. */
  889. #define TARGET_CDROMCLOSETRAY 0x5319 /* pendant of CDROMEJECT */
  890. #define TARGET_CDROM_SET_OPTIONS 0x5320 /* Set behavior options */
  891. #define TARGET_CDROM_CLEAR_OPTIONS 0x5321 /* Clear behavior options */
  892. #define TARGET_CDROM_SELECT_SPEED 0x5322 /* Set the CD-ROM speed */
  893. #define TARGET_CDROM_SELECT_DISC 0x5323 /* Select disc (for juke-boxes) */
  894. #define TARGET_CDROM_MEDIA_CHANGED 0x5325 /* Check is media changed */
  895. #define TARGET_CDROM_DRIVE_STATUS 0x5326 /* Get tray position, etc. */
  896. #define TARGET_CDROM_DISC_STATUS 0x5327 /* Get disc type, etc. */
  897. #define TARGET_CDROM_CHANGER_NSLOTS 0x5328 /* Get number of slots */
  898. #define TARGET_CDROM_LOCKDOOR 0x5329 /* lock or unlock door */
  899. #define TARGET_CDROM_DEBUG 0x5330 /* Turn debug messages on/off */
  900. #define TARGET_CDROM_GET_CAPABILITY 0x5331 /* get capabilities */
  901. /* Note that scsi/scsi_ioctl.h also uses 0x5382 - 0x5386.
  902. * Future CDROM ioctls should be kept below 0x537F
  903. */
  904. /* This ioctl is only used by sbpcd at the moment */
  905. #define TARGET_CDROMAUDIOBUFSIZ 0x5382 /* set the audio buffer size */
  906. /* conflict with SCSI_IOCTL_GET_IDLUN */
  907. /* DVD-ROM Specific ioctls */
  908. #define TARGET_DVD_READ_STRUCT 0x5390 /* Read structure */
  909. #define TARGET_DVD_WRITE_STRUCT 0x5391 /* Write structure */
  910. #define TARGET_DVD_AUTH 0x5392 /* Authentication */
  911. #define TARGET_CDROM_SEND_PACKET 0x5393 /* send a packet to the drive */
  912. #define TARGET_CDROM_NEXT_WRITABLE 0x5394 /* get next writable block */
  913. #define TARGET_CDROM_LAST_WRITTEN 0x5395 /* get last block written on disc */
  914. /* HD commands */
  915. /* hd/ide ctl's that pass (arg) ptrs to user space are numbered 0x030n/0x031n */
  916. #define TARGET_HDIO_GETGEO 0x0301 /* get device geometry */
  917. #define TARGET_HDIO_GET_UNMASKINTR 0x0302 /* get current unmask setting */
  918. #define TARGET_HDIO_GET_MULTCOUNT 0x0304 /* get current IDE blockmode setting */
  919. #define TARGET_HDIO_GET_KEEPSETTINGS 0x0308 /* get keep-settings-on-reset flag */
  920. #define TARGET_HDIO_GET_32BIT 0x0309 /* get current io_32bit setting */
  921. #define TARGET_HDIO_GET_NOWERR 0x030a /* get ignore-write-error flag */
  922. #define TARGET_HDIO_GET_DMA 0x030b /* get use-dma flag */
  923. #define TARGET_HDIO_GET_IDENTITY 0x030d /* get IDE identification info */
  924. #define TARGET_HDIO_DRIVE_CMD 0x031f /* execute a special drive command */
  925. /* hd/ide ctl's that pass (arg) non-ptr values are numbered 0x032n/0x033n */
  926. #define TARGET_HDIO_SET_MULTCOUNT 0x0321 /* change IDE blockmode */
  927. #define TARGET_HDIO_SET_UNMASKINTR 0x0322 /* permit other irqs during I/O */
  928. #define TARGET_HDIO_SET_KEEPSETTINGS 0x0323 /* keep ioctl settings on reset */
  929. #define TARGET_HDIO_SET_32BIT 0x0324 /* change io_32bit flags */
  930. #define TARGET_HDIO_SET_NOWERR 0x0325 /* change ignore-write-error flag */
  931. #define TARGET_HDIO_SET_DMA 0x0326 /* change use-dma flag */
  932. #define TARGET_HDIO_SET_PIO_MODE 0x0327 /* reconfig interface to new speed */
  933. /* loop ioctls */
  934. #define TARGET_LOOP_SET_FD 0x4C00
  935. #define TARGET_LOOP_CLR_FD 0x4C01
  936. #define TARGET_LOOP_SET_STATUS 0x4C02
  937. #define TARGET_LOOP_GET_STATUS 0x4C03
  938. #define TARGET_LOOP_SET_STATUS64 0x4C04
  939. #define TARGET_LOOP_GET_STATUS64 0x4C05
  940. #define TARGET_LOOP_CHANGE_FD 0x4C06
  941. #define TARGET_LOOP_CTL_ADD 0x4C80
  942. #define TARGET_LOOP_CTL_REMOVE 0x4C81
  943. #define TARGET_LOOP_CTL_GET_FREE 0x4C82
  944. /* fb ioctls */
  945. #define TARGET_FBIOGET_VSCREENINFO 0x4600
  946. #define TARGET_FBIOPUT_VSCREENINFO 0x4601
  947. #define TARGET_FBIOGET_FSCREENINFO 0x4602
  948. #define TARGET_FBIOGETCMAP 0x4604
  949. #define TARGET_FBIOPUTCMAP 0x4605
  950. #define TARGET_FBIOPAN_DISPLAY 0x4606
  951. #define TARGET_FBIOGET_CON2FBMAP 0x460F
  952. #define TARGET_FBIOPUT_CON2FBMAP 0x4610
  953. /* vt ioctls */
  954. #define TARGET_VT_OPENQRY 0x5600
  955. #define TARGET_VT_GETSTATE 0x5603
  956. #define TARGET_VT_ACTIVATE 0x5606
  957. #define TARGET_VT_WAITACTIVE 0x5607
  958. #define TARGET_VT_LOCKSWITCH 0x560b
  959. #define TARGET_VT_UNLOCKSWITCH 0x560c
  960. #define TARGET_VT_GETMODE 0x5601
  961. #define TARGET_VT_SETMODE 0x5602
  962. #define TARGET_VT_RELDISP 0x5605
  963. #define TARGET_VT_DISALLOCATE 0x5608
  964. /* device mapper */
  965. #define TARGET_DM_VERSION TARGET_IOWRU(0xfd, 0x00)
  966. #define TARGET_DM_REMOVE_ALL TARGET_IOWRU(0xfd, 0x01)
  967. #define TARGET_DM_LIST_DEVICES TARGET_IOWRU(0xfd, 0x02)
  968. #define TARGET_DM_DEV_CREATE TARGET_IOWRU(0xfd, 0x03)
  969. #define TARGET_DM_DEV_REMOVE TARGET_IOWRU(0xfd, 0x04)
  970. #define TARGET_DM_DEV_RENAME TARGET_IOWRU(0xfd, 0x05)
  971. #define TARGET_DM_DEV_SUSPEND TARGET_IOWRU(0xfd, 0x06)
  972. #define TARGET_DM_DEV_STATUS TARGET_IOWRU(0xfd, 0x07)
  973. #define TARGET_DM_DEV_WAIT TARGET_IOWRU(0xfd, 0x08)
  974. #define TARGET_DM_TABLE_LOAD TARGET_IOWRU(0xfd, 0x09)
  975. #define TARGET_DM_TABLE_CLEAR TARGET_IOWRU(0xfd, 0x0a)
  976. #define TARGET_DM_TABLE_DEPS TARGET_IOWRU(0xfd, 0x0b)
  977. #define TARGET_DM_TABLE_STATUS TARGET_IOWRU(0xfd, 0x0c)
  978. #define TARGET_DM_LIST_VERSIONS TARGET_IOWRU(0xfd, 0x0d)
  979. #define TARGET_DM_TARGET_MSG TARGET_IOWRU(0xfd, 0x0e)
  980. #define TARGET_DM_DEV_SET_GEOMETRY TARGET_IOWRU(0xfd, 0x0f)
  981. /* from asm/termbits.h */
  982. #define TARGET_NCC 8
  983. struct target_termio {
  984. unsigned short c_iflag; /* input mode flags */
  985. unsigned short c_oflag; /* output mode flags */
  986. unsigned short c_cflag; /* control mode flags */
  987. unsigned short c_lflag; /* local mode flags */
  988. unsigned char c_line; /* line discipline */
  989. unsigned char c_cc[TARGET_NCC]; /* control characters */
  990. };
  991. struct target_winsize {
  992. unsigned short ws_row;
  993. unsigned short ws_col;
  994. unsigned short ws_xpixel;
  995. unsigned short ws_ypixel;
  996. };
  997. #include "termbits.h"
  998. #if defined(TARGET_MIPS)
  999. #define TARGET_PROT_SEM 0x10
  1000. #else
  1001. #define TARGET_PROT_SEM 0x08
  1002. #endif
  1003. /* Common */
  1004. #define TARGET_MAP_SHARED 0x01 /* Share changes */
  1005. #define TARGET_MAP_PRIVATE 0x02 /* Changes are private */
  1006. #if defined(TARGET_HPPA)
  1007. #define TARGET_MAP_TYPE 0x03 /* Mask for type of mapping */
  1008. #else
  1009. #define TARGET_MAP_TYPE 0x0f /* Mask for type of mapping */
  1010. #endif
  1011. /* Target specific */
  1012. #if defined(TARGET_MIPS)
  1013. #define TARGET_MAP_FIXED 0x10 /* Interpret addr exactly */
  1014. #define TARGET_MAP_ANONYMOUS 0x0800 /* don't use a file */
  1015. #define TARGET_MAP_GROWSDOWN 0x1000 /* stack-like segment */
  1016. #define TARGET_MAP_DENYWRITE 0x2000 /* ETXTBSY */
  1017. #define TARGET_MAP_EXECUTABLE 0x4000 /* mark it as an executable */
  1018. #define TARGET_MAP_LOCKED 0x8000 /* pages are locked */
  1019. #define TARGET_MAP_NORESERVE 0x0400 /* don't check for reservations */
  1020. #define TARGET_MAP_POPULATE 0x10000 /* populate (prefault) pagetables */
  1021. #define TARGET_MAP_NONBLOCK 0x20000 /* do not block on IO */
  1022. #define TARGET_MAP_STACK 0x40000 /* ignored */
  1023. #define TARGET_MAP_HUGETLB 0x80000 /* create a huge page mapping */
  1024. #elif defined(TARGET_PPC)
  1025. #define TARGET_MAP_FIXED 0x10 /* Interpret addr exactly */
  1026. #define TARGET_MAP_ANONYMOUS 0x20 /* don't use a file */
  1027. #define TARGET_MAP_GROWSDOWN 0x0100 /* stack-like segment */
  1028. #define TARGET_MAP_DENYWRITE 0x0800 /* ETXTBSY */
  1029. #define TARGET_MAP_EXECUTABLE 0x1000 /* mark it as an executable */
  1030. #define TARGET_MAP_LOCKED 0x0080 /* pages are locked */
  1031. #define TARGET_MAP_NORESERVE 0x0040 /* don't check for reservations */
  1032. #define TARGET_MAP_POPULATE 0x8000 /* populate (prefault) pagetables */
  1033. #define TARGET_MAP_NONBLOCK 0x10000 /* do not block on IO */
  1034. #define TARGET_MAP_STACK 0x20000 /* ignored */
  1035. #define TARGET_MAP_HUGETLB 0x40000 /* create a huge page mapping */
  1036. #elif defined(TARGET_ALPHA)
  1037. #define TARGET_MAP_ANONYMOUS 0x10 /* don't use a file */
  1038. #define TARGET_MAP_FIXED 0x100 /* Interpret addr exactly */
  1039. #define TARGET_MAP_GROWSDOWN 0x01000 /* stack-like segment */
  1040. #define TARGET_MAP_DENYWRITE 0x02000 /* ETXTBSY */
  1041. #define TARGET_MAP_EXECUTABLE 0x04000 /* mark it as an executable */
  1042. #define TARGET_MAP_LOCKED 0x08000 /* lock the mapping */
  1043. #define TARGET_MAP_NORESERVE 0x10000 /* no check for reservations */
  1044. #define TARGET_MAP_POPULATE 0x20000 /* pop (prefault) pagetables */
  1045. #define TARGET_MAP_NONBLOCK 0x40000 /* do not block on IO */
  1046. #define TARGET_MAP_STACK 0x80000 /* ignored */
  1047. #define TARGET_MAP_HUGETLB 0x100000 /* create a huge page mapping */
  1048. #elif defined(TARGET_HPPA)
  1049. #define TARGET_MAP_ANONYMOUS 0x10 /* don't use a file */
  1050. #define TARGET_MAP_FIXED 0x04 /* Interpret addr exactly */
  1051. #define TARGET_MAP_GROWSDOWN 0x08000 /* stack-like segment */
  1052. #define TARGET_MAP_DENYWRITE 0x00800 /* ETXTBSY */
  1053. #define TARGET_MAP_EXECUTABLE 0x01000 /* mark it as an executable */
  1054. #define TARGET_MAP_LOCKED 0x02000 /* lock the mapping */
  1055. #define TARGET_MAP_NORESERVE 0x04000 /* no check for reservations */
  1056. #define TARGET_MAP_POPULATE 0x10000 /* pop (prefault) pagetables */
  1057. #define TARGET_MAP_NONBLOCK 0x20000 /* do not block on IO */
  1058. #define TARGET_MAP_STACK 0x40000 /* ignored */
  1059. #define TARGET_MAP_HUGETLB 0x80000 /* create a huge page mapping */
  1060. #elif defined(TARGET_XTENSA)
  1061. #define TARGET_MAP_FIXED 0x10 /* Interpret addr exactly */
  1062. #define TARGET_MAP_ANONYMOUS 0x0800 /* don't use a file */
  1063. #define TARGET_MAP_GROWSDOWN 0x1000 /* stack-like segment */
  1064. #define TARGET_MAP_DENYWRITE 0x2000 /* ETXTBSY */
  1065. #define TARGET_MAP_EXECUTABLE 0x4000 /* mark it as an executable */
  1066. #define TARGET_MAP_LOCKED 0x8000 /* pages are locked */
  1067. #define TARGET_MAP_NORESERVE 0x0400 /* don't check for reservations */
  1068. #define TARGET_MAP_POPULATE 0x10000 /* populate (prefault) pagetables */
  1069. #define TARGET_MAP_NONBLOCK 0x20000 /* do not block on IO */
  1070. #define TARGET_MAP_STACK 0x40000
  1071. #define TARGET_MAP_HUGETLB 0x80000 /* create a huge page mapping */
  1072. #else
  1073. #define TARGET_MAP_FIXED 0x10 /* Interpret addr exactly */
  1074. #define TARGET_MAP_ANONYMOUS 0x20 /* don't use a file */
  1075. #define TARGET_MAP_GROWSDOWN 0x0100 /* stack-like segment */
  1076. #define TARGET_MAP_DENYWRITE 0x0800 /* ETXTBSY */
  1077. #define TARGET_MAP_EXECUTABLE 0x1000 /* mark it as an executable */
  1078. #define TARGET_MAP_LOCKED 0x2000 /* pages are locked */
  1079. #define TARGET_MAP_NORESERVE 0x4000 /* don't check for reservations */
  1080. #define TARGET_MAP_POPULATE 0x8000 /* populate (prefault) pagetables */
  1081. #define TARGET_MAP_NONBLOCK 0x10000 /* do not block on IO */
  1082. #define TARGET_MAP_STACK 0x20000 /* ignored */
  1083. #define TARGET_MAP_HUGETLB 0x40000 /* create a huge page mapping */
  1084. #define TARGET_MAP_UNINITIALIZED 0x4000000 /* for anonymous mmap, memory could be uninitialized */
  1085. #endif
  1086. #if (defined(TARGET_I386) && defined(TARGET_ABI32)) \
  1087. || (defined(TARGET_ARM) && defined(TARGET_ABI32)) \
  1088. || defined(TARGET_CRIS)
  1089. #define TARGET_STAT_HAVE_NSEC
  1090. struct target_stat {
  1091. unsigned short st_dev;
  1092. unsigned short __pad1;
  1093. abi_ulong st_ino;
  1094. unsigned short st_mode;
  1095. unsigned short st_nlink;
  1096. unsigned short st_uid;
  1097. unsigned short st_gid;
  1098. unsigned short st_rdev;
  1099. unsigned short __pad2;
  1100. abi_ulong st_size;
  1101. abi_ulong st_blksize;
  1102. abi_ulong st_blocks;
  1103. abi_ulong target_st_atime;
  1104. abi_ulong target_st_atime_nsec;
  1105. abi_ulong target_st_mtime;
  1106. abi_ulong target_st_mtime_nsec;
  1107. abi_ulong target_st_ctime;
  1108. abi_ulong target_st_ctime_nsec;
  1109. abi_ulong __unused4;
  1110. abi_ulong __unused5;
  1111. };
  1112. /* This matches struct stat64 in glibc2.1, hence the absolutely
  1113. * insane amounts of padding around dev_t's.
  1114. */
  1115. #define TARGET_HAS_STRUCT_STAT64
  1116. struct target_stat64 {
  1117. unsigned short st_dev;
  1118. unsigned char __pad0[10];
  1119. #define TARGET_STAT64_HAS_BROKEN_ST_INO 1
  1120. abi_ulong __st_ino;
  1121. unsigned int st_mode;
  1122. unsigned int st_nlink;
  1123. abi_ulong st_uid;
  1124. abi_ulong st_gid;
  1125. unsigned short st_rdev;
  1126. unsigned char __pad3[10];
  1127. long long st_size;
  1128. abi_ulong st_blksize;
  1129. abi_ulong st_blocks; /* Number 512-byte blocks allocated. */
  1130. abi_ulong __pad4; /* future possible st_blocks high bits */
  1131. abi_ulong target_st_atime;
  1132. abi_ulong target_st_atime_nsec;
  1133. abi_ulong target_st_mtime;
  1134. abi_ulong target_st_mtime_nsec;
  1135. abi_ulong target_st_ctime;
  1136. abi_ulong target_st_ctime_nsec;
  1137. unsigned long long st_ino;
  1138. } QEMU_PACKED;
  1139. #ifdef TARGET_ARM
  1140. #define TARGET_HAS_STRUCT_STAT64
  1141. struct target_eabi_stat64 {
  1142. unsigned long long st_dev;
  1143. unsigned int __pad1;
  1144. abi_ulong __st_ino;
  1145. unsigned int st_mode;
  1146. unsigned int st_nlink;
  1147. abi_ulong st_uid;
  1148. abi_ulong st_gid;
  1149. unsigned long long st_rdev;
  1150. unsigned int __pad2[2];
  1151. long long st_size;
  1152. abi_ulong st_blksize;
  1153. unsigned int __pad3;
  1154. unsigned long long st_blocks;
  1155. abi_ulong target_st_atime;
  1156. abi_ulong target_st_atime_nsec;
  1157. abi_ulong target_st_mtime;
  1158. abi_ulong target_st_mtime_nsec;
  1159. abi_ulong target_st_ctime;
  1160. abi_ulong target_st_ctime_nsec;
  1161. unsigned long long st_ino;
  1162. } QEMU_PACKED;
  1163. #endif
  1164. #elif defined(TARGET_SPARC64) && !defined(TARGET_ABI32)
  1165. struct target_stat {
  1166. unsigned int st_dev;
  1167. abi_ulong st_ino;
  1168. unsigned int st_mode;
  1169. unsigned int st_nlink;
  1170. unsigned int st_uid;
  1171. unsigned int st_gid;
  1172. unsigned int st_rdev;
  1173. abi_long st_size;
  1174. abi_long target_st_atime;
  1175. abi_long target_st_mtime;
  1176. abi_long target_st_ctime;
  1177. abi_long st_blksize;
  1178. abi_long st_blocks;
  1179. abi_ulong __unused4[2];
  1180. };
  1181. #define TARGET_HAS_STRUCT_STAT64
  1182. struct target_stat64 {
  1183. unsigned char __pad0[6];
  1184. unsigned short st_dev;
  1185. uint64_t st_ino;
  1186. uint64_t st_nlink;
  1187. unsigned int st_mode;
  1188. unsigned int st_uid;
  1189. unsigned int st_gid;
  1190. unsigned char __pad2[6];
  1191. unsigned short st_rdev;
  1192. int64_t st_size;
  1193. int64_t st_blksize;
  1194. unsigned char __pad4[4];
  1195. unsigned int st_blocks;
  1196. abi_ulong target_st_atime;
  1197. abi_ulong target_st_atime_nsec;
  1198. abi_ulong target_st_mtime;
  1199. abi_ulong target_st_mtime_nsec;
  1200. abi_ulong target_st_ctime;
  1201. abi_ulong target_st_ctime_nsec;
  1202. abi_ulong __unused4[3];
  1203. };
  1204. #elif defined(TARGET_SPARC)
  1205. #define TARGET_STAT_HAVE_NSEC
  1206. struct target_stat {
  1207. unsigned short st_dev;
  1208. abi_ulong st_ino;
  1209. unsigned short st_mode;
  1210. short st_nlink;
  1211. unsigned short st_uid;
  1212. unsigned short st_gid;
  1213. unsigned short st_rdev;
  1214. abi_long st_size;
  1215. abi_long target_st_atime;
  1216. abi_ulong target_st_atime_nsec;
  1217. abi_long target_st_mtime;
  1218. abi_ulong target_st_mtime_nsec;
  1219. abi_long target_st_ctime;
  1220. abi_ulong target_st_ctime_nsec;
  1221. abi_long st_blksize;
  1222. abi_long st_blocks;
  1223. abi_ulong __unused1[2];
  1224. };
  1225. #define TARGET_HAS_STRUCT_STAT64
  1226. struct target_stat64 {
  1227. unsigned char __pad0[6];
  1228. unsigned short st_dev;
  1229. uint64_t st_ino;
  1230. unsigned int st_mode;
  1231. unsigned int st_nlink;
  1232. unsigned int st_uid;
  1233. unsigned int st_gid;
  1234. unsigned char __pad2[6];
  1235. unsigned short st_rdev;
  1236. unsigned char __pad3[8];
  1237. int64_t st_size;
  1238. unsigned int st_blksize;
  1239. unsigned char __pad4[8];
  1240. unsigned int st_blocks;
  1241. unsigned int target_st_atime;
  1242. unsigned int target_st_atime_nsec;
  1243. unsigned int target_st_mtime;
  1244. unsigned int target_st_mtime_nsec;
  1245. unsigned int target_st_ctime;
  1246. unsigned int target_st_ctime_nsec;
  1247. unsigned int __unused1;
  1248. unsigned int __unused2;
  1249. };
  1250. #elif defined(TARGET_PPC)
  1251. #define TARGET_STAT_HAVE_NSEC
  1252. struct target_stat {
  1253. abi_ulong st_dev;
  1254. abi_ulong st_ino;
  1255. #if defined(TARGET_PPC64) && !defined(TARGET_ABI32)
  1256. abi_ulong st_nlink;
  1257. unsigned int st_mode;
  1258. #else
  1259. unsigned int st_mode;
  1260. unsigned short st_nlink;
  1261. #endif
  1262. unsigned int st_uid;
  1263. unsigned int st_gid;
  1264. abi_ulong st_rdev;
  1265. abi_ulong st_size;
  1266. abi_ulong st_blksize;
  1267. abi_ulong st_blocks;
  1268. abi_ulong target_st_atime;
  1269. abi_ulong target_st_atime_nsec;
  1270. abi_ulong target_st_mtime;
  1271. abi_ulong target_st_mtime_nsec;
  1272. abi_ulong target_st_ctime;
  1273. abi_ulong target_st_ctime_nsec;
  1274. abi_ulong __unused4;
  1275. abi_ulong __unused5;
  1276. #if defined(TARGET_PPC64) && !defined(TARGET_ABI32)
  1277. abi_ulong __unused6;
  1278. #endif
  1279. };
  1280. #if !defined(TARGET_PPC64) || defined(TARGET_ABI32)
  1281. #define TARGET_HAS_STRUCT_STAT64
  1282. struct QEMU_PACKED target_stat64 {
  1283. unsigned long long st_dev;
  1284. unsigned long long st_ino;
  1285. unsigned int st_mode;
  1286. unsigned int st_nlink;
  1287. unsigned int st_uid;
  1288. unsigned int st_gid;
  1289. unsigned long long st_rdev;
  1290. unsigned long long __pad0;
  1291. long long st_size;
  1292. int st_blksize;
  1293. unsigned int __pad1;
  1294. long long st_blocks; /* Number 512-byte blocks allocated. */
  1295. int target_st_atime;
  1296. unsigned int target_st_atime_nsec;
  1297. int target_st_mtime;
  1298. unsigned int target_st_mtime_nsec;
  1299. int target_st_ctime;
  1300. unsigned int target_st_ctime_nsec;
  1301. unsigned int __unused4;
  1302. unsigned int __unused5;
  1303. };
  1304. #endif
  1305. #elif defined(TARGET_MICROBLAZE)
  1306. #define TARGET_STAT_HAVE_NSEC
  1307. struct target_stat {
  1308. abi_ulong st_dev;
  1309. abi_ulong st_ino;
  1310. unsigned int st_mode;
  1311. unsigned short st_nlink;
  1312. unsigned int st_uid;
  1313. unsigned int st_gid;
  1314. abi_ulong st_rdev;
  1315. abi_ulong st_size;
  1316. abi_ulong st_blksize;
  1317. abi_ulong st_blocks;
  1318. abi_ulong target_st_atime;
  1319. abi_ulong target_st_atime_nsec;
  1320. abi_ulong target_st_mtime;
  1321. abi_ulong target_st_mtime_nsec;
  1322. abi_ulong target_st_ctime;
  1323. abi_ulong target_st_ctime_nsec;
  1324. abi_ulong __unused4;
  1325. abi_ulong __unused5;
  1326. };
  1327. /* FIXME: Microblaze no-mmu user-space has a difference stat64 layout... */
  1328. #define TARGET_HAS_STRUCT_STAT64
  1329. struct QEMU_PACKED target_stat64 {
  1330. uint64_t st_dev;
  1331. #define TARGET_STAT64_HAS_BROKEN_ST_INO 1
  1332. uint32_t pad0;
  1333. uint32_t __st_ino;
  1334. uint32_t st_mode;
  1335. uint32_t st_nlink;
  1336. uint32_t st_uid;
  1337. uint32_t st_gid;
  1338. uint64_t st_rdev;
  1339. uint64_t __pad1;
  1340. int64_t st_size;
  1341. int32_t st_blksize;
  1342. uint32_t __pad2;
  1343. int64_t st_blocks; /* Number 512-byte blocks allocated. */
  1344. int target_st_atime;
  1345. unsigned int target_st_atime_nsec;
  1346. int target_st_mtime;
  1347. unsigned int target_st_mtime_nsec;
  1348. int target_st_ctime;
  1349. unsigned int target_st_ctime_nsec;
  1350. uint64_t st_ino;
  1351. };
  1352. #elif defined(TARGET_M68K)
  1353. struct target_stat {
  1354. unsigned short st_dev;
  1355. unsigned short __pad1;
  1356. abi_ulong st_ino;
  1357. unsigned short st_mode;
  1358. unsigned short st_nlink;
  1359. unsigned short st_uid;
  1360. unsigned short st_gid;
  1361. unsigned short st_rdev;
  1362. unsigned short __pad2;
  1363. abi_ulong st_size;
  1364. abi_ulong st_blksize;
  1365. abi_ulong st_blocks;
  1366. abi_ulong target_st_atime;
  1367. abi_ulong __unused1;
  1368. abi_ulong target_st_mtime;
  1369. abi_ulong __unused2;
  1370. abi_ulong target_st_ctime;
  1371. abi_ulong __unused3;
  1372. abi_ulong __unused4;
  1373. abi_ulong __unused5;
  1374. };
  1375. /* This matches struct stat64 in glibc2.1, hence the absolutely
  1376. * insane amounts of padding around dev_t's.
  1377. */
  1378. #define TARGET_HAS_STRUCT_STAT64
  1379. struct target_stat64 {
  1380. unsigned long long st_dev;
  1381. unsigned char __pad1[2];
  1382. #define TARGET_STAT64_HAS_BROKEN_ST_INO 1
  1383. abi_ulong __st_ino;
  1384. unsigned int st_mode;
  1385. unsigned int st_nlink;
  1386. abi_ulong st_uid;
  1387. abi_ulong st_gid;
  1388. unsigned long long st_rdev;
  1389. unsigned char __pad3[2];
  1390. long long st_size;
  1391. abi_ulong st_blksize;
  1392. abi_ulong __pad4; /* future possible st_blocks high bits */
  1393. abi_ulong st_blocks; /* Number 512-byte blocks allocated. */
  1394. abi_ulong target_st_atime;
  1395. abi_ulong target_st_atime_nsec;
  1396. abi_ulong target_st_mtime;
  1397. abi_ulong target_st_mtime_nsec;
  1398. abi_ulong target_st_ctime;
  1399. abi_ulong target_st_ctime_nsec;
  1400. unsigned long long st_ino;
  1401. } QEMU_PACKED;
  1402. #elif defined(TARGET_ABI_MIPSN64)
  1403. #define TARGET_STAT_HAVE_NSEC
  1404. /* The memory layout is the same as of struct stat64 of the 32-bit kernel. */
  1405. struct target_stat {
  1406. unsigned int st_dev;
  1407. unsigned int st_pad0[3]; /* Reserved for st_dev expansion */
  1408. abi_ulong st_ino;
  1409. unsigned int st_mode;
  1410. unsigned int st_nlink;
  1411. int st_uid;
  1412. int st_gid;
  1413. unsigned int st_rdev;
  1414. unsigned int st_pad1[3]; /* Reserved for st_rdev expansion */
  1415. abi_ulong st_size;
  1416. /*
  1417. * Actually this should be timestruc_t st_atime, st_mtime and st_ctime
  1418. * but we don't have it under Linux.
  1419. */
  1420. unsigned int target_st_atime;
  1421. unsigned int target_st_atime_nsec;
  1422. unsigned int target_st_mtime;
  1423. unsigned int target_st_mtime_nsec;
  1424. unsigned int target_st_ctime;
  1425. unsigned int target_st_ctime_nsec;
  1426. unsigned int st_blksize;
  1427. unsigned int st_pad2;
  1428. abi_ulong st_blocks;
  1429. };
  1430. #elif defined(TARGET_ABI_MIPSN32)
  1431. #define TARGET_STAT_HAVE_NSEC
  1432. struct target_stat {
  1433. abi_ulong st_dev;
  1434. abi_ulong st_pad0[3]; /* Reserved for st_dev expansion */
  1435. uint64_t st_ino;
  1436. unsigned int st_mode;
  1437. unsigned int st_nlink;
  1438. int st_uid;
  1439. int st_gid;
  1440. abi_ulong st_rdev;
  1441. abi_ulong st_pad1[3]; /* Reserved for st_rdev expansion */
  1442. int64_t st_size;
  1443. abi_long target_st_atime;
  1444. abi_ulong target_st_atime_nsec; /* Reserved for st_atime expansion */
  1445. abi_long target_st_mtime;
  1446. abi_ulong target_st_mtime_nsec; /* Reserved for st_mtime expansion */
  1447. abi_long target_st_ctime;
  1448. abi_ulong target_st_ctime_nsec; /* Reserved for st_ctime expansion */
  1449. abi_ulong st_blksize;
  1450. abi_ulong st_pad2;
  1451. int64_t st_blocks;
  1452. };
  1453. #elif defined(TARGET_ABI_MIPSO32)
  1454. #define TARGET_STAT_HAVE_NSEC
  1455. struct target_stat {
  1456. unsigned st_dev;
  1457. abi_long st_pad1[3]; /* Reserved for network id */
  1458. abi_ulong st_ino;
  1459. unsigned int st_mode;
  1460. unsigned int st_nlink;
  1461. int st_uid;
  1462. int st_gid;
  1463. unsigned st_rdev;
  1464. abi_long st_pad2[2];
  1465. abi_long st_size;
  1466. abi_long st_pad3;
  1467. /*
  1468. * Actually this should be timestruc_t st_atime, st_mtime and st_ctime
  1469. * but we don't have it under Linux.
  1470. */
  1471. abi_long target_st_atime;
  1472. abi_long target_st_atime_nsec;
  1473. abi_long target_st_mtime;
  1474. abi_long target_st_mtime_nsec;
  1475. abi_long target_st_ctime;
  1476. abi_long target_st_ctime_nsec;
  1477. abi_long st_blksize;
  1478. abi_long st_blocks;
  1479. abi_long st_pad4[14];
  1480. };
  1481. /*
  1482. * This matches struct stat64 in glibc2.1, hence the absolutely insane
  1483. * amounts of padding around dev_t's. The memory layout is the same as of
  1484. * struct stat of the 64-bit kernel.
  1485. */
  1486. #define TARGET_HAS_STRUCT_STAT64
  1487. struct target_stat64 {
  1488. abi_ulong st_dev;
  1489. abi_ulong st_pad0[3]; /* Reserved for st_dev expansion */
  1490. uint64_t st_ino;
  1491. unsigned int st_mode;
  1492. unsigned int st_nlink;
  1493. int st_uid;
  1494. int st_gid;
  1495. abi_ulong st_rdev;
  1496. abi_ulong st_pad1[3]; /* Reserved for st_rdev expansion */
  1497. int64_t st_size;
  1498. /*
  1499. * Actually this should be timestruc_t st_atime, st_mtime and st_ctime
  1500. * but we don't have it under Linux.
  1501. */
  1502. abi_long target_st_atime;
  1503. abi_ulong target_st_atime_nsec; /* Reserved for st_atime expansion */
  1504. abi_long target_st_mtime;
  1505. abi_ulong target_st_mtime_nsec; /* Reserved for st_mtime expansion */
  1506. abi_long target_st_ctime;
  1507. abi_ulong target_st_ctime_nsec; /* Reserved for st_ctime expansion */
  1508. abi_ulong st_blksize;
  1509. abi_ulong st_pad2;
  1510. int64_t st_blocks;
  1511. };
  1512. #elif defined(TARGET_ALPHA)
  1513. struct target_stat {
  1514. unsigned int st_dev;
  1515. unsigned int st_ino;
  1516. unsigned int st_mode;
  1517. unsigned int st_nlink;
  1518. unsigned int st_uid;
  1519. unsigned int st_gid;
  1520. unsigned int st_rdev;
  1521. abi_long st_size;
  1522. abi_ulong target_st_atime;
  1523. abi_ulong target_st_mtime;
  1524. abi_ulong target_st_ctime;
  1525. unsigned int st_blksize;
  1526. unsigned int st_blocks;
  1527. unsigned int st_flags;
  1528. unsigned int st_gen;
  1529. };
  1530. #define TARGET_HAS_STRUCT_STAT64
  1531. struct target_stat64 {
  1532. abi_ulong st_dev;
  1533. abi_ulong st_ino;
  1534. abi_ulong st_rdev;
  1535. abi_long st_size;
  1536. abi_ulong st_blocks;
  1537. unsigned int st_mode;
  1538. unsigned int st_uid;
  1539. unsigned int st_gid;
  1540. unsigned int st_blksize;
  1541. unsigned int st_nlink;
  1542. unsigned int __pad0;
  1543. abi_ulong target_st_atime;
  1544. abi_ulong target_st_atime_nsec;
  1545. abi_ulong target_st_mtime;
  1546. abi_ulong target_st_mtime_nsec;
  1547. abi_ulong target_st_ctime;
  1548. abi_ulong target_st_ctime_nsec;
  1549. abi_long __unused[3];
  1550. };
  1551. #elif defined(TARGET_SH4)
  1552. #define TARGET_STAT_HAVE_NSEC
  1553. struct target_stat {
  1554. abi_ulong st_dev;
  1555. abi_ulong st_ino;
  1556. unsigned short st_mode;
  1557. unsigned short st_nlink;
  1558. unsigned short st_uid;
  1559. unsigned short st_gid;
  1560. abi_ulong st_rdev;
  1561. abi_ulong st_size;
  1562. abi_ulong st_blksize;
  1563. abi_ulong st_blocks;
  1564. abi_ulong target_st_atime;
  1565. abi_ulong target_st_atime_nsec;
  1566. abi_ulong target_st_mtime;
  1567. abi_ulong target_st_mtime_nsec;
  1568. abi_ulong target_st_ctime;
  1569. abi_ulong target_st_ctime_nsec;
  1570. abi_ulong __unused4;
  1571. abi_ulong __unused5;
  1572. };
  1573. /* This matches struct stat64 in glibc2.1, hence the absolutely
  1574. * insane amounts of padding around dev_t's.
  1575. */
  1576. #define TARGET_HAS_STRUCT_STAT64
  1577. struct QEMU_PACKED target_stat64 {
  1578. unsigned long long st_dev;
  1579. unsigned char __pad0[4];
  1580. #define TARGET_STAT64_HAS_BROKEN_ST_INO 1
  1581. abi_ulong __st_ino;
  1582. unsigned int st_mode;
  1583. unsigned int st_nlink;
  1584. abi_ulong st_uid;
  1585. abi_ulong st_gid;
  1586. unsigned long long st_rdev;
  1587. unsigned char __pad3[4];
  1588. long long st_size;
  1589. abi_ulong st_blksize;
  1590. unsigned long long st_blocks; /* Number 512-byte blocks allocated. */
  1591. abi_ulong target_st_atime;
  1592. abi_ulong target_st_atime_nsec;
  1593. abi_ulong target_st_mtime;
  1594. abi_ulong target_st_mtime_nsec;
  1595. abi_ulong target_st_ctime;
  1596. abi_ulong target_st_ctime_nsec;
  1597. unsigned long long st_ino;
  1598. };
  1599. #elif defined(TARGET_I386) && !defined(TARGET_ABI32)
  1600. #define TARGET_STAT_HAVE_NSEC
  1601. struct target_stat {
  1602. abi_ulong st_dev;
  1603. abi_ulong st_ino;
  1604. abi_ulong st_nlink;
  1605. unsigned int st_mode;
  1606. unsigned int st_uid;
  1607. unsigned int st_gid;
  1608. unsigned int __pad0;
  1609. abi_ulong st_rdev;
  1610. abi_long st_size;
  1611. abi_long st_blksize;
  1612. abi_long st_blocks; /* Number 512-byte blocks allocated. */
  1613. abi_ulong target_st_atime;
  1614. abi_ulong target_st_atime_nsec;
  1615. abi_ulong target_st_mtime;
  1616. abi_ulong target_st_mtime_nsec;
  1617. abi_ulong target_st_ctime;
  1618. abi_ulong target_st_ctime_nsec;
  1619. abi_long __unused[3];
  1620. };
  1621. #elif defined(TARGET_S390X)
  1622. struct target_stat {
  1623. abi_ulong st_dev;
  1624. abi_ulong st_ino;
  1625. abi_ulong st_nlink;
  1626. unsigned int st_mode;
  1627. unsigned int st_uid;
  1628. unsigned int st_gid;
  1629. unsigned int __pad1;
  1630. abi_ulong st_rdev;
  1631. abi_ulong st_size;
  1632. abi_ulong target_st_atime;
  1633. abi_ulong target_st_atime_nsec;
  1634. abi_ulong target_st_mtime;
  1635. abi_ulong target_st_mtime_nsec;
  1636. abi_ulong target_st_ctime;
  1637. abi_ulong target_st_ctime_nsec;
  1638. abi_ulong st_blksize;
  1639. abi_long st_blocks;
  1640. abi_ulong __unused[3];
  1641. };
  1642. #elif defined(TARGET_AARCH64)
  1643. #define TARGET_STAT_HAVE_NSEC
  1644. struct target_stat {
  1645. abi_ulong st_dev;
  1646. abi_ulong st_ino;
  1647. unsigned int st_mode;
  1648. unsigned int st_nlink;
  1649. unsigned int st_uid;
  1650. unsigned int st_gid;
  1651. abi_ulong st_rdev;
  1652. abi_ulong _pad1;
  1653. abi_long st_size;
  1654. int st_blksize;
  1655. int __pad2;
  1656. abi_long st_blocks;
  1657. abi_long target_st_atime;
  1658. abi_ulong target_st_atime_nsec;
  1659. abi_long target_st_mtime;
  1660. abi_ulong target_st_mtime_nsec;
  1661. abi_long target_st_ctime;
  1662. abi_ulong target_st_ctime_nsec;
  1663. unsigned int __unused[2];
  1664. };
  1665. #elif defined(TARGET_XTENSA)
  1666. #define TARGET_STAT_HAVE_NSEC
  1667. struct target_stat {
  1668. abi_ulong st_dev;
  1669. abi_ulong st_ino;
  1670. unsigned int st_mode;
  1671. unsigned int st_nlink;
  1672. unsigned int st_uid;
  1673. unsigned int st_gid;
  1674. abi_ulong st_rdev;
  1675. abi_long st_size;
  1676. abi_ulong st_blksize;
  1677. abi_ulong st_blocks;
  1678. abi_ulong target_st_atime;
  1679. abi_ulong target_st_atime_nsec;
  1680. abi_ulong target_st_mtime;
  1681. abi_ulong target_st_mtime_nsec;
  1682. abi_ulong target_st_ctime;
  1683. abi_ulong target_st_ctime_nsec;
  1684. abi_ulong __unused4;
  1685. abi_ulong __unused5;
  1686. };
  1687. #define TARGET_HAS_STRUCT_STAT64
  1688. struct target_stat64 {
  1689. uint64_t st_dev; /* Device */
  1690. uint64_t st_ino; /* File serial number */
  1691. unsigned int st_mode; /* File mode. */
  1692. unsigned int st_nlink; /* Link count. */
  1693. unsigned int st_uid; /* User ID of the file's owner. */
  1694. unsigned int st_gid; /* Group ID of the file's group. */
  1695. uint64_t st_rdev; /* Device number, if device. */
  1696. int64_t st_size; /* Size of file, in bytes. */
  1697. abi_ulong st_blksize; /* Optimal block size for I/O. */
  1698. abi_ulong __unused2;
  1699. uint64_t st_blocks; /* Number 512-byte blocks allocated. */
  1700. abi_ulong target_st_atime; /* Time of last access. */
  1701. abi_ulong target_st_atime_nsec;
  1702. abi_ulong target_st_mtime; /* Time of last modification. */
  1703. abi_ulong target_st_mtime_nsec;
  1704. abi_ulong target_st_ctime; /* Time of last status change. */
  1705. abi_ulong target_st_ctime_nsec;
  1706. abi_ulong __unused4;
  1707. abi_ulong __unused5;
  1708. };
  1709. #elif defined(TARGET_OPENRISC) || defined(TARGET_TILEGX) || \
  1710. defined(TARGET_NIOS2) || defined(TARGET_RISCV)
  1711. /* These are the asm-generic versions of the stat and stat64 structures */
  1712. #define TARGET_STAT_HAVE_NSEC
  1713. struct target_stat {
  1714. abi_ulong st_dev;
  1715. abi_ulong st_ino;
  1716. unsigned int st_mode;
  1717. unsigned int st_nlink;
  1718. unsigned int st_uid;
  1719. unsigned int st_gid;
  1720. abi_ulong st_rdev;
  1721. abi_ulong __pad1;
  1722. abi_long st_size;
  1723. int st_blksize;
  1724. int __pad2;
  1725. abi_long st_blocks;
  1726. abi_long target_st_atime;
  1727. abi_ulong target_st_atime_nsec;
  1728. abi_long target_st_mtime;
  1729. abi_ulong target_st_mtime_nsec;
  1730. abi_long target_st_ctime;
  1731. abi_ulong target_st_ctime_nsec;
  1732. unsigned int __unused4;
  1733. unsigned int __unused5;
  1734. };
  1735. #if !defined(TARGET_RISCV64)
  1736. #define TARGET_HAS_STRUCT_STAT64
  1737. struct target_stat64 {
  1738. uint64_t st_dev;
  1739. uint64_t st_ino;
  1740. unsigned int st_mode;
  1741. unsigned int st_nlink;
  1742. unsigned int st_uid;
  1743. unsigned int st_gid;
  1744. uint64_t st_rdev;
  1745. uint64_t __pad1;
  1746. int64_t st_size;
  1747. int st_blksize;
  1748. int __pad2;
  1749. int64_t st_blocks;
  1750. int target_st_atime;
  1751. unsigned int target_st_atime_nsec;
  1752. int target_st_mtime;
  1753. unsigned int target_st_mtime_nsec;
  1754. int target_st_ctime;
  1755. unsigned int target_st_ctime_nsec;
  1756. unsigned int __unused4;
  1757. unsigned int __unused5;
  1758. };
  1759. #endif
  1760. #elif defined(TARGET_HPPA)
  1761. #define TARGET_STAT_HAVE_NSEC
  1762. struct target_stat {
  1763. abi_uint st_dev;
  1764. abi_uint st_ino;
  1765. abi_ushort st_mode;
  1766. abi_ushort st_nlink;
  1767. abi_ushort _res1;
  1768. abi_ushort _res2;
  1769. abi_uint st_rdev;
  1770. abi_int st_size;
  1771. abi_int target_st_atime;
  1772. abi_uint target_st_atime_nsec;
  1773. abi_int target_st_mtime;
  1774. abi_uint target_st_mtime_nsec;
  1775. abi_int target_st_ctime;
  1776. abi_uint target_st_ctime_nsec;
  1777. abi_int st_blksize;
  1778. abi_int st_blocks;
  1779. abi_uint _unused1;
  1780. abi_uint _unused2;
  1781. abi_uint _unused3;
  1782. abi_uint _unused4;
  1783. abi_ushort _unused5;
  1784. abi_short st_fstype;
  1785. abi_uint st_realdev;
  1786. abi_ushort st_basemode;
  1787. abi_ushort _unused6;
  1788. abi_uint st_uid;
  1789. abi_uint st_gid;
  1790. abi_uint _unused7[3];
  1791. };
  1792. #define TARGET_HAS_STRUCT_STAT64
  1793. struct target_stat64 {
  1794. uint64_t st_dev;
  1795. abi_uint _pad1;
  1796. abi_uint _res1;
  1797. abi_uint st_mode;
  1798. abi_uint st_nlink;
  1799. abi_uint st_uid;
  1800. abi_uint st_gid;
  1801. uint64_t st_rdev;
  1802. abi_uint _pad2;
  1803. int64_t st_size;
  1804. abi_int st_blksize;
  1805. int64_t st_blocks;
  1806. abi_int target_st_atime;
  1807. abi_uint target_st_atime_nsec;
  1808. abi_int target_st_mtime;
  1809. abi_uint target_st_mtime_nsec;
  1810. abi_int target_st_ctime;
  1811. abi_uint target_st_ctime_nsec;
  1812. uint64_t st_ino;
  1813. };
  1814. #else
  1815. #error unsupported CPU
  1816. #endif
  1817. typedef struct {
  1818. int val[2];
  1819. } target_fsid_t;
  1820. #ifdef TARGET_MIPS
  1821. #ifdef TARGET_ABI_MIPSN32
  1822. struct target_statfs {
  1823. int32_t f_type;
  1824. int32_t f_bsize;
  1825. int32_t f_frsize; /* Fragment size - unsupported */
  1826. int32_t f_blocks;
  1827. int32_t f_bfree;
  1828. int32_t f_files;
  1829. int32_t f_ffree;
  1830. int32_t f_bavail;
  1831. /* Linux specials */
  1832. target_fsid_t f_fsid;
  1833. int32_t f_namelen;
  1834. int32_t f_flags;
  1835. int32_t f_spare[5];
  1836. };
  1837. #else
  1838. struct target_statfs {
  1839. abi_long f_type;
  1840. abi_long f_bsize;
  1841. abi_long f_frsize; /* Fragment size - unsupported */
  1842. abi_long f_blocks;
  1843. abi_long f_bfree;
  1844. abi_long f_files;
  1845. abi_long f_ffree;
  1846. abi_long f_bavail;
  1847. /* Linux specials */
  1848. target_fsid_t f_fsid;
  1849. abi_long f_namelen;
  1850. abi_long f_flags;
  1851. abi_long f_spare[5];
  1852. };
  1853. #endif
  1854. struct target_statfs64 {
  1855. uint32_t f_type;
  1856. uint32_t f_bsize;
  1857. uint32_t f_frsize; /* Fragment size - unsupported */
  1858. uint32_t __pad;
  1859. uint64_t f_blocks;
  1860. uint64_t f_bfree;
  1861. uint64_t f_files;
  1862. uint64_t f_ffree;
  1863. uint64_t f_bavail;
  1864. target_fsid_t f_fsid;
  1865. uint32_t f_namelen;
  1866. uint32_t f_flags;
  1867. uint32_t f_spare[5];
  1868. };
  1869. #elif (defined(TARGET_PPC64) || defined(TARGET_X86_64) || \
  1870. defined(TARGET_SPARC64) || defined(TARGET_AARCH64) || \
  1871. defined(TARGET_RISCV)) && !defined(TARGET_ABI32)
  1872. struct target_statfs {
  1873. abi_long f_type;
  1874. abi_long f_bsize;
  1875. abi_long f_blocks;
  1876. abi_long f_bfree;
  1877. abi_long f_bavail;
  1878. abi_long f_files;
  1879. abi_long f_ffree;
  1880. target_fsid_t f_fsid;
  1881. abi_long f_namelen;
  1882. abi_long f_frsize;
  1883. abi_long f_flags;
  1884. abi_long f_spare[4];
  1885. };
  1886. struct target_statfs64 {
  1887. abi_long f_type;
  1888. abi_long f_bsize;
  1889. abi_long f_blocks;
  1890. abi_long f_bfree;
  1891. abi_long f_bavail;
  1892. abi_long f_files;
  1893. abi_long f_ffree;
  1894. target_fsid_t f_fsid;
  1895. abi_long f_namelen;
  1896. abi_long f_frsize;
  1897. abi_long f_flags;
  1898. abi_long f_spare[4];
  1899. };
  1900. #elif defined(TARGET_S390X)
  1901. struct target_statfs {
  1902. int32_t f_type;
  1903. int32_t f_bsize;
  1904. abi_long f_blocks;
  1905. abi_long f_bfree;
  1906. abi_long f_bavail;
  1907. abi_long f_files;
  1908. abi_long f_ffree;
  1909. kernel_fsid_t f_fsid;
  1910. int32_t f_namelen;
  1911. int32_t f_frsize;
  1912. int32_t f_flags;
  1913. int32_t f_spare[4];
  1914. };
  1915. struct target_statfs64 {
  1916. int32_t f_type;
  1917. int32_t f_bsize;
  1918. abi_long f_blocks;
  1919. abi_long f_bfree;
  1920. abi_long f_bavail;
  1921. abi_long f_files;
  1922. abi_long f_ffree;
  1923. kernel_fsid_t f_fsid;
  1924. int32_t f_namelen;
  1925. int32_t f_frsize;
  1926. int32_t f_flags;
  1927. int32_t f_spare[4];
  1928. };
  1929. #else
  1930. struct target_statfs {
  1931. uint32_t f_type;
  1932. uint32_t f_bsize;
  1933. uint32_t f_blocks;
  1934. uint32_t f_bfree;
  1935. uint32_t f_bavail;
  1936. uint32_t f_files;
  1937. uint32_t f_ffree;
  1938. target_fsid_t f_fsid;
  1939. uint32_t f_namelen;
  1940. uint32_t f_frsize;
  1941. uint32_t f_flags;
  1942. uint32_t f_spare[4];
  1943. };
  1944. struct target_statfs64 {
  1945. uint32_t f_type;
  1946. uint32_t f_bsize;
  1947. uint64_t f_blocks;
  1948. uint64_t f_bfree;
  1949. uint64_t f_bavail;
  1950. uint64_t f_files;
  1951. uint64_t f_ffree;
  1952. target_fsid_t f_fsid;
  1953. uint32_t f_namelen;
  1954. uint32_t f_frsize;
  1955. uint32_t f_flags;
  1956. uint32_t f_spare[4];
  1957. };
  1958. #endif
  1959. #define TARGET_F_LINUX_SPECIFIC_BASE 1024
  1960. #define TARGET_F_SETLEASE (TARGET_F_LINUX_SPECIFIC_BASE + 0)
  1961. #define TARGET_F_GETLEASE (TARGET_F_LINUX_SPECIFIC_BASE + 1)
  1962. #define TARGET_F_DUPFD_CLOEXEC (TARGET_F_LINUX_SPECIFIC_BASE + 6)
  1963. #define TARGET_F_SETPIPE_SZ (TARGET_F_LINUX_SPECIFIC_BASE + 7)
  1964. #define TARGET_F_GETPIPE_SZ (TARGET_F_LINUX_SPECIFIC_BASE + 8)
  1965. #define TARGET_F_NOTIFY (TARGET_F_LINUX_SPECIFIC_BASE+2)
  1966. #include "target_fcntl.h"
  1967. /* soundcard defines */
  1968. /* XXX: convert them all to arch independent entries */
  1969. #define TARGET_SNDCTL_COPR_HALT TARGET_IOWR('C', 7, int);
  1970. #define TARGET_SNDCTL_COPR_LOAD 0xcfb04301
  1971. #define TARGET_SNDCTL_COPR_RCODE 0xc0144303
  1972. #define TARGET_SNDCTL_COPR_RCVMSG 0x8fa44309
  1973. #define TARGET_SNDCTL_COPR_RDATA 0xc0144302
  1974. #define TARGET_SNDCTL_COPR_RESET 0x00004300
  1975. #define TARGET_SNDCTL_COPR_RUN 0xc0144306
  1976. #define TARGET_SNDCTL_COPR_SENDMSG 0xcfa44308
  1977. #define TARGET_SNDCTL_COPR_WCODE 0x40144305
  1978. #define TARGET_SNDCTL_COPR_WDATA 0x40144304
  1979. #define TARGET_SNDCTL_DSP_RESET TARGET_IO('P', 0)
  1980. #define TARGET_SNDCTL_DSP_SYNC TARGET_IO('P', 1)
  1981. #define TARGET_SNDCTL_DSP_SPEED TARGET_IOWR('P', 2, int)
  1982. #define TARGET_SNDCTL_DSP_STEREO TARGET_IOWR('P', 3, int)
  1983. #define TARGET_SNDCTL_DSP_GETBLKSIZE TARGET_IOWR('P', 4, int)
  1984. #define TARGET_SNDCTL_DSP_SETFMT TARGET_IOWR('P', 5, int)
  1985. #define TARGET_SNDCTL_DSP_CHANNELS TARGET_IOWR('P', 6, int)
  1986. #define TARGET_SOUND_PCM_WRITE_FILTER TARGET_IOWR('P', 7, int)
  1987. #define TARGET_SNDCTL_DSP_POST TARGET_IO('P', 8)
  1988. #define TARGET_SNDCTL_DSP_SUBDIVIDE TARGET_IOWR('P', 9, int)
  1989. #define TARGET_SNDCTL_DSP_SETFRAGMENT TARGET_IOWR('P',10, int)
  1990. #define TARGET_SNDCTL_DSP_GETFMTS TARGET_IOR('P', 11, int)
  1991. #define TARGET_SNDCTL_DSP_GETOSPACE TARGET_IORU('P',12)
  1992. #define TARGET_SNDCTL_DSP_GETISPACE TARGET_IORU('P',13)
  1993. #define TARGET_SNDCTL_DSP_GETCAPS TARGET_IOR('P', 15, int)
  1994. #define TARGET_SNDCTL_DSP_GETTRIGGER TARGET_IOR('P',16, int)
  1995. #define TARGET_SNDCTL_DSP_GETIPTR TARGET_IORU('P',17)
  1996. #define TARGET_SNDCTL_DSP_GETOPTR TARGET_IORU('P',18)
  1997. #define TARGET_SNDCTL_DSP_MAPINBUF TARGET_IORU('P', 19)
  1998. #define TARGET_SNDCTL_DSP_MAPOUTBUF TARGET_IORU('P', 20)
  1999. #define TARGET_SNDCTL_DSP_NONBLOCK 0x0000500e
  2000. #define TARGET_SNDCTL_DSP_SAMPLESIZE 0xc0045005
  2001. #define TARGET_SNDCTL_DSP_SETDUPLEX 0x00005016
  2002. #define TARGET_SNDCTL_DSP_SETSYNCRO 0x00005015
  2003. #define TARGET_SNDCTL_DSP_SETTRIGGER 0x40045010
  2004. #define TARGET_SNDCTL_FM_4OP_ENABLE 0x4004510f
  2005. #define TARGET_SNDCTL_FM_LOAD_INSTR 0x40285107
  2006. #define TARGET_SNDCTL_MIDI_INFO 0xc074510c
  2007. #define TARGET_SNDCTL_MIDI_MPUCMD 0xc0216d02
  2008. #define TARGET_SNDCTL_MIDI_MPUMODE 0xc0046d01
  2009. #define TARGET_SNDCTL_MIDI_PRETIME 0xc0046d00
  2010. #define TARGET_SNDCTL_PMGR_ACCESS 0xcfb85110
  2011. #define TARGET_SNDCTL_PMGR_IFACE 0xcfb85001
  2012. #define TARGET_SNDCTL_SEQ_CTRLRATE 0xc0045103
  2013. #define TARGET_SNDCTL_SEQ_GETINCOUNT 0x80045105
  2014. #define TARGET_SNDCTL_SEQ_GETOUTCOUNT 0x80045104
  2015. #define TARGET_SNDCTL_SEQ_NRMIDIS 0x8004510b
  2016. #define TARGET_SNDCTL_SEQ_NRSYNTHS 0x8004510a
  2017. #define TARGET_SNDCTL_SEQ_OUTOFBAND 0x40085112
  2018. #define TARGET_SNDCTL_SEQ_PANIC 0x00005111
  2019. #define TARGET_SNDCTL_SEQ_PERCMODE 0x40045106
  2020. #define TARGET_SNDCTL_SEQ_RESET 0x00005100
  2021. #define TARGET_SNDCTL_SEQ_RESETSAMPLES 0x40045109
  2022. #define TARGET_SNDCTL_SEQ_SYNC 0x00005101
  2023. #define TARGET_SNDCTL_SEQ_TESTMIDI 0x40045108
  2024. #define TARGET_SNDCTL_SEQ_THRESHOLD 0x4004510d
  2025. #define TARGET_SNDCTL_SEQ_TRESHOLD 0x4004510d
  2026. #define TARGET_SNDCTL_SYNTH_INFO 0xc08c5102
  2027. #define TARGET_SNDCTL_SYNTH_MEMAVL 0xc004510e
  2028. #define TARGET_SNDCTL_TMR_CONTINUE 0x00005404
  2029. #define TARGET_SNDCTL_TMR_METRONOME 0x40045407
  2030. #define TARGET_SNDCTL_TMR_SELECT 0x40045408
  2031. #define TARGET_SNDCTL_TMR_SOURCE 0xc0045406
  2032. #define TARGET_SNDCTL_TMR_START 0x00005402
  2033. #define TARGET_SNDCTL_TMR_STOP 0x00005403
  2034. #define TARGET_SNDCTL_TMR_TEMPO 0xc0045405
  2035. #define TARGET_SNDCTL_TMR_TIMEBASE 0xc0045401
  2036. #define TARGET_SOUND_PCM_READ_RATE 0x80045002
  2037. #define TARGET_SOUND_PCM_READ_CHANNELS 0x80045006
  2038. #define TARGET_SOUND_PCM_READ_BITS 0x80045005
  2039. #define TARGET_SOUND_PCM_READ_FILTER 0x80045007
  2040. #define TARGET_SOUND_MIXER_INFO TARGET_IOR ('M', 101, mixer_info)
  2041. #define TARGET_SOUND_MIXER_ACCESS 0xc0804d66
  2042. #define TARGET_SOUND_MIXER_PRIVATE1 TARGET_IOWR('M', 111, int)
  2043. #define TARGET_SOUND_MIXER_PRIVATE2 TARGET_IOWR('M', 112, int)
  2044. #define TARGET_SOUND_MIXER_PRIVATE3 TARGET_IOWR('M', 113, int)
  2045. #define TARGET_SOUND_MIXER_PRIVATE4 TARGET_IOWR('M', 114, int)
  2046. #define TARGET_SOUND_MIXER_PRIVATE5 TARGET_IOWR('M', 115, int)
  2047. #define TARGET_MIXER_READ(dev) TARGET_IOR('M', dev, int)
  2048. #define TARGET_SOUND_MIXER_READ_VOLUME TARGET_MIXER_READ(SOUND_MIXER_VOLUME)
  2049. #define TARGET_SOUND_MIXER_READ_BASS TARGET_MIXER_READ(SOUND_MIXER_BASS)
  2050. #define TARGET_SOUND_MIXER_READ_TREBLE TARGET_MIXER_READ(SOUND_MIXER_TREBLE)
  2051. #define TARGET_SOUND_MIXER_READ_SYNTH TARGET_MIXER_READ(SOUND_MIXER_SYNTH)
  2052. #define TARGET_SOUND_MIXER_READ_PCM TARGET_MIXER_READ(SOUND_MIXER_PCM)
  2053. #define TARGET_SOUND_MIXER_READ_SPEAKER TARGET_MIXER_READ(SOUND_MIXER_SPEAKER)
  2054. #define TARGET_SOUND_MIXER_READ_LINE TARGET_MIXER_READ(SOUND_MIXER_LINE)
  2055. #define TARGET_SOUND_MIXER_READ_MIC TARGET_MIXER_READ(SOUND_MIXER_MIC)
  2056. #define TARGET_SOUND_MIXER_READ_CD TARGET_MIXER_READ(SOUND_MIXER_CD)
  2057. #define TARGET_SOUND_MIXER_READ_IMIX TARGET_MIXER_READ(SOUND_MIXER_IMIX)
  2058. #define TARGET_SOUND_MIXER_READ_ALTPCM TARGET_MIXER_READ(SOUND_MIXER_ALTPCM)
  2059. #define TARGET_SOUND_MIXER_READ_RECLEV TARGET_MIXER_READ(SOUND_MIXER_RECLEV)
  2060. #define TARGET_SOUND_MIXER_READ_IGAIN TARGET_MIXER_READ(SOUND_MIXER_IGAIN)
  2061. #define TARGET_SOUND_MIXER_READ_OGAIN TARGET_MIXER_READ(SOUND_MIXER_OGAIN)
  2062. #define TARGET_SOUND_MIXER_READ_LINE1 TARGET_MIXER_READ(SOUND_MIXER_LINE1)
  2063. #define TARGET_SOUND_MIXER_READ_LINE2 TARGET_MIXER_READ(SOUND_MIXER_LINE2)
  2064. #define TARGET_SOUND_MIXER_READ_LINE3 TARGET_MIXER_READ(SOUND_MIXER_LINE3)
  2065. /* Obsolete macros */
  2066. #define TARGET_SOUND_MIXER_READ_MUTE TARGET_MIXER_READ(SOUND_MIXER_MUTE)
  2067. #define TARGET_SOUND_MIXER_READ_ENHANCE TARGET_MIXER_READ(SOUND_MIXER_ENHANCE)
  2068. #define TARGET_SOUND_MIXER_READ_LOUD TARGET_MIXER_READ(SOUND_MIXER_LOUD)
  2069. #define TARGET_SOUND_MIXER_READ_RECSRC TARGET_MIXER_READ(SOUND_MIXER_RECSRC)
  2070. #define TARGET_SOUND_MIXER_READ_DEVMASK TARGET_MIXER_READ(SOUND_MIXER_DEVMASK)
  2071. #define TARGET_SOUND_MIXER_READ_RECMASK TARGET_MIXER_READ(SOUND_MIXER_RECMASK)
  2072. #define TARGET_SOUND_MIXER_READ_STEREODEVS TARGET_MIXER_READ(SOUND_MIXER_STEREODEVS)
  2073. #define TARGET_SOUND_MIXER_READ_CAPS TARGET_MIXER_READ(SOUND_MIXER_CAPS)
  2074. #define TARGET_MIXER_WRITE(dev) TARGET_IOWR('M', dev, int)
  2075. #define TARGET_SOUND_MIXER_WRITE_VOLUME TARGET_MIXER_WRITE(SOUND_MIXER_VOLUME)
  2076. #define TARGET_SOUND_MIXER_WRITE_BASS TARGET_MIXER_WRITE(SOUND_MIXER_BASS)
  2077. #define TARGET_SOUND_MIXER_WRITE_TREBLE TARGET_MIXER_WRITE(SOUND_MIXER_TREBLE)
  2078. #define TARGET_SOUND_MIXER_WRITE_SYNTH TARGET_MIXER_WRITE(SOUND_MIXER_SYNTH)
  2079. #define TARGET_SOUND_MIXER_WRITE_PCM TARGET_MIXER_WRITE(SOUND_MIXER_PCM)
  2080. #define TARGET_SOUND_MIXER_WRITE_SPEAKER TARGET_MIXER_WRITE(SOUND_MIXER_SPEAKER)
  2081. #define TARGET_SOUND_MIXER_WRITE_LINE TARGET_MIXER_WRITE(SOUND_MIXER_LINE)
  2082. #define TARGET_SOUND_MIXER_WRITE_MIC TARGET_MIXER_WRITE(SOUND_MIXER_MIC)
  2083. #define TARGET_SOUND_MIXER_WRITE_CD TARGET_MIXER_WRITE(SOUND_MIXER_CD)
  2084. #define TARGET_SOUND_MIXER_WRITE_IMIX TARGET_MIXER_WRITE(SOUND_MIXER_IMIX)
  2085. #define TARGET_SOUND_MIXER_WRITE_ALTPCM TARGET_MIXER_WRITE(SOUND_MIXER_ALTPCM)
  2086. #define TARGET_SOUND_MIXER_WRITE_RECLEV TARGET_MIXER_WRITE(SOUND_MIXER_RECLEV)
  2087. #define TARGET_SOUND_MIXER_WRITE_IGAIN TARGET_MIXER_WRITE(SOUND_MIXER_IGAIN)
  2088. #define TARGET_SOUND_MIXER_WRITE_OGAIN TARGET_MIXER_WRITE(SOUND_MIXER_OGAIN)
  2089. #define TARGET_SOUND_MIXER_WRITE_LINE1 TARGET_MIXER_WRITE(SOUND_MIXER_LINE1)
  2090. #define TARGET_SOUND_MIXER_WRITE_LINE2 TARGET_MIXER_WRITE(SOUND_MIXER_LINE2)
  2091. #define TARGET_SOUND_MIXER_WRITE_LINE3 TARGET_MIXER_WRITE(SOUND_MIXER_LINE3)
  2092. /* Obsolete macros */
  2093. #define TARGET_SOUND_MIXER_WRITE_MUTE TARGET_MIXER_WRITE(SOUND_MIXER_MUTE)
  2094. #define TARGET_SOUND_MIXER_WRITE_ENHANCE TARGET_MIXER_WRITE(SOUND_MIXER_ENHANCE)
  2095. #define TARGET_SOUND_MIXER_WRITE_LOUD TARGET_MIXER_WRITE(SOUND_MIXER_LOUD)
  2096. #define TARGET_SOUND_MIXER_WRITE_RECSRC TARGET_MIXER_WRITE(SOUND_MIXER_RECSRC)
  2097. /* vfat ioctls */
  2098. #define TARGET_VFAT_IOCTL_READDIR_BOTH TARGET_IORU('r', 1)
  2099. #define TARGET_VFAT_IOCTL_READDIR_SHORT TARGET_IORU('r', 2)
  2100. struct target_mtop {
  2101. abi_short mt_op;
  2102. abi_int mt_count;
  2103. };
  2104. #if defined(TARGET_SPARC) || defined(TARGET_MIPS)
  2105. typedef abi_long target_kernel_daddr_t;
  2106. #else
  2107. typedef abi_int target_kernel_daddr_t;
  2108. #endif
  2109. struct target_mtget {
  2110. abi_long mt_type;
  2111. abi_long mt_resid;
  2112. abi_long mt_dsreg;
  2113. abi_long mt_gstat;
  2114. abi_long mt_erreg;
  2115. target_kernel_daddr_t mt_fileno;
  2116. target_kernel_daddr_t mt_blkno;
  2117. };
  2118. struct target_mtpos {
  2119. abi_long mt_blkno;
  2120. };
  2121. #define TARGET_MTIOCTOP TARGET_IOW('m', 1, struct target_mtop)
  2122. #define TARGET_MTIOCGET TARGET_IOR('m', 2, struct target_mtget)
  2123. #define TARGET_MTIOCPOS TARGET_IOR('m', 3, struct target_mtpos)
  2124. struct target_sysinfo {
  2125. abi_long uptime; /* Seconds since boot */
  2126. abi_ulong loads[3]; /* 1, 5, and 15 minute load averages */
  2127. abi_ulong totalram; /* Total usable main memory size */
  2128. abi_ulong freeram; /* Available memory size */
  2129. abi_ulong sharedram; /* Amount of shared memory */
  2130. abi_ulong bufferram; /* Memory used by buffers */
  2131. abi_ulong totalswap; /* Total swap space size */
  2132. abi_ulong freeswap; /* swap space still available */
  2133. unsigned short procs; /* Number of current processes */
  2134. unsigned short pad; /* explicit padding for m68k */
  2135. abi_ulong totalhigh; /* Total high memory size */
  2136. abi_ulong freehigh; /* Available high memory size */
  2137. unsigned int mem_unit; /* Memory unit size in bytes */
  2138. char _f[20-2*sizeof(abi_long)-sizeof(int)]; /* Padding: libc5 uses this.. */
  2139. };
  2140. struct linux_dirent {
  2141. long d_ino;
  2142. unsigned long d_off;
  2143. unsigned short d_reclen;
  2144. char d_name[256]; /* We must not include limits.h! */
  2145. };
  2146. struct linux_dirent64 {
  2147. uint64_t d_ino;
  2148. int64_t d_off;
  2149. unsigned short d_reclen;
  2150. unsigned char d_type;
  2151. char d_name[256];
  2152. };
  2153. struct target_mq_attr {
  2154. abi_long mq_flags;
  2155. abi_long mq_maxmsg;
  2156. abi_long mq_msgsize;
  2157. abi_long mq_curmsgs;
  2158. };
  2159. #include "socket.h"
  2160. #include "errno_defs.h"
  2161. #define FUTEX_WAIT 0
  2162. #define FUTEX_WAKE 1
  2163. #define FUTEX_FD 2
  2164. #define FUTEX_REQUEUE 3
  2165. #define FUTEX_CMP_REQUEUE 4
  2166. #define FUTEX_WAKE_OP 5
  2167. #define FUTEX_LOCK_PI 6
  2168. #define FUTEX_UNLOCK_PI 7
  2169. #define FUTEX_TRYLOCK_PI 8
  2170. #define FUTEX_WAIT_BITSET 9
  2171. #define FUTEX_WAKE_BITSET 10
  2172. #define FUTEX_PRIVATE_FLAG 128
  2173. #define FUTEX_CLOCK_REALTIME 256
  2174. #define FUTEX_CMD_MASK ~(FUTEX_PRIVATE_FLAG | FUTEX_CLOCK_REALTIME)
  2175. #ifdef CONFIG_EPOLL
  2176. #if defined(TARGET_X86_64)
  2177. #define TARGET_EPOLL_PACKED QEMU_PACKED
  2178. #else
  2179. #define TARGET_EPOLL_PACKED
  2180. #endif
  2181. typedef union target_epoll_data {
  2182. abi_ulong ptr;
  2183. abi_int fd;
  2184. abi_uint u32;
  2185. abi_ullong u64;
  2186. } target_epoll_data_t;
  2187. struct target_epoll_event {
  2188. abi_uint events;
  2189. target_epoll_data_t data;
  2190. } TARGET_EPOLL_PACKED;
  2191. #define TARGET_EP_MAX_EVENTS (INT_MAX / sizeof(struct target_epoll_event))
  2192. #endif
  2193. struct target_rlimit64 {
  2194. uint64_t rlim_cur;
  2195. uint64_t rlim_max;
  2196. };
  2197. struct target_ucred {
  2198. uint32_t pid;
  2199. uint32_t uid;
  2200. uint32_t gid;
  2201. };
  2202. typedef int32_t target_timer_t;
  2203. #define TARGET_SIGEV_MAX_SIZE 64
  2204. /* This is architecture-specific but most architectures use the default */
  2205. #ifdef TARGET_MIPS
  2206. #define TARGET_SIGEV_PREAMBLE_SIZE (sizeof(int32_t) * 2 + sizeof(abi_long))
  2207. #else
  2208. #define TARGET_SIGEV_PREAMBLE_SIZE (sizeof(int32_t) * 2 \
  2209. + sizeof(target_sigval_t))
  2210. #endif
  2211. #define TARGET_SIGEV_PAD_SIZE ((TARGET_SIGEV_MAX_SIZE \
  2212. - TARGET_SIGEV_PREAMBLE_SIZE) \
  2213. / sizeof(int32_t))
  2214. struct target_sigevent {
  2215. target_sigval_t sigev_value;
  2216. abi_int sigev_signo;
  2217. abi_int sigev_notify;
  2218. union {
  2219. abi_int _pad[TARGET_SIGEV_PAD_SIZE];
  2220. abi_int _tid;
  2221. /* The kernel (and thus QEMU) never looks at these;
  2222. * they're only used as part of the ABI between a
  2223. * userspace program and libc.
  2224. */
  2225. struct {
  2226. abi_ulong _function;
  2227. abi_ulong _attribute;
  2228. } _sigev_thread;
  2229. } _sigev_un;
  2230. };
  2231. struct target_user_cap_header {
  2232. uint32_t version;
  2233. int pid;
  2234. };
  2235. struct target_user_cap_data {
  2236. uint32_t effective;
  2237. uint32_t permitted;
  2238. uint32_t inheritable;
  2239. };
  2240. /* from kernel's include/linux/syslog.h */
  2241. /* Close the log. Currently a NOP. */
  2242. #define TARGET_SYSLOG_ACTION_CLOSE 0
  2243. /* Open the log. Currently a NOP. */
  2244. #define TARGET_SYSLOG_ACTION_OPEN 1
  2245. /* Read from the log. */
  2246. #define TARGET_SYSLOG_ACTION_READ 2
  2247. /* Read all messages remaining in the ring buffer. */
  2248. #define TARGET_SYSLOG_ACTION_READ_ALL 3
  2249. /* Read and clear all messages remaining in the ring buffer */
  2250. #define TARGET_SYSLOG_ACTION_READ_CLEAR 4
  2251. /* Clear ring buffer. */
  2252. #define TARGET_SYSLOG_ACTION_CLEAR 5
  2253. /* Disable printk's to console */
  2254. #define TARGET_SYSLOG_ACTION_CONSOLE_OFF 6
  2255. /* Enable printk's to console */
  2256. #define TARGET_SYSLOG_ACTION_CONSOLE_ON 7
  2257. /* Set level of messages printed to console */
  2258. #define TARGET_SYSLOG_ACTION_CONSOLE_LEVEL 8
  2259. /* Return number of unread characters in the log buffer */
  2260. #define TARGET_SYSLOG_ACTION_SIZE_UNREAD 9
  2261. /* Return size of the log buffer */
  2262. #define TARGET_SYSLOG_ACTION_SIZE_BUFFER 10
  2263. struct target_statx_timestamp {
  2264. int64_t tv_sec;
  2265. uint32_t tv_nsec;
  2266. int32_t __reserved;
  2267. };
  2268. struct target_statx {
  2269. /* 0x00 */
  2270. uint32_t stx_mask; /* What results were written [uncond] */
  2271. uint32_t stx_blksize; /* Preferred general I/O size [uncond] */
  2272. uint64_t stx_attributes; /* Flags conveying information about the file */
  2273. /* 0x10 */
  2274. uint32_t stx_nlink; /* Number of hard links */
  2275. uint32_t stx_uid; /* User ID of owner */
  2276. uint32_t stx_gid; /* Group ID of owner */
  2277. uint16_t stx_mode; /* File mode */
  2278. uint16_t __spare0[1];
  2279. /* 0x20 */
  2280. uint64_t stx_ino; /* Inode number */
  2281. uint64_t stx_size; /* File size */
  2282. uint64_t stx_blocks; /* Number of 512-byte blocks allocated */
  2283. uint64_t stx_attributes_mask; /* Mask to show what is supported */
  2284. /* 0x40 */
  2285. struct target_statx_timestamp stx_atime; /* Last access time */
  2286. struct target_statx_timestamp stx_btime; /* File creation time */
  2287. struct target_statx_timestamp stx_ctime; /* Last attribute change time */
  2288. struct target_statx_timestamp stx_mtime; /* Last data modification time */
  2289. /* 0x80 */
  2290. uint32_t stx_rdev_major; /* Device ID of special file [if bdev/cdev] */
  2291. uint32_t stx_rdev_minor;
  2292. uint32_t stx_dev_major; /* ID of device containing file [uncond] */
  2293. uint32_t stx_dev_minor;
  2294. /* 0x90 */
  2295. uint64_t __spare2[14]; /* Spare space for future expansion */
  2296. /* 0x100 */
  2297. };
  2298. #endif