syscall_defs.h 92 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777
  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. struct target_rtc_pll_info {
  667. int pll_ctrl;
  668. int pll_value;
  669. int pll_max;
  670. int pll_min;
  671. int pll_posmult;
  672. int pll_negmult;
  673. abi_long pll_clock;
  674. };
  675. /* real time clock ioctls */
  676. #define TARGET_RTC_AIE_ON TARGET_IO('p', 0x01)
  677. #define TARGET_RTC_AIE_OFF TARGET_IO('p', 0x02)
  678. #define TARGET_RTC_UIE_ON TARGET_IO('p', 0x03)
  679. #define TARGET_RTC_UIE_OFF TARGET_IO('p', 0x04)
  680. #define TARGET_RTC_PIE_ON TARGET_IO('p', 0x05)
  681. #define TARGET_RTC_PIE_OFF TARGET_IO('p', 0x06)
  682. #define TARGET_RTC_WIE_ON TARGET_IO('p', 0x0f)
  683. #define TARGET_RTC_WIE_OFF TARGET_IO('p', 0x10)
  684. #define TARGET_RTC_ALM_READ TARGET_IOR('p', 0x08, struct rtc_time)
  685. #define TARGET_RTC_ALM_SET TARGET_IOW('p', 0x07, struct rtc_time)
  686. #define TARGET_RTC_RD_TIME TARGET_IOR('p', 0x09, struct rtc_time)
  687. #define TARGET_RTC_SET_TIME TARGET_IOW('p', 0x0a, struct rtc_time)
  688. #define TARGET_RTC_IRQP_READ TARGET_IOR('p', 0x0b, abi_ulong)
  689. #define TARGET_RTC_IRQP_SET TARGET_IOW('p', 0x0c, abi_ulong)
  690. #define TARGET_RTC_EPOCH_READ TARGET_IOR('p', 0x0d, abi_ulong)
  691. #define TARGET_RTC_EPOCH_SET TARGET_IOW('p', 0x0e, abi_ulong)
  692. #define TARGET_RTC_WKALM_RD TARGET_IOR('p', 0x10, struct rtc_wkalrm)
  693. #define TARGET_RTC_WKALM_SET TARGET_IOW('p', 0x0f, struct rtc_wkalrm)
  694. #define TARGET_RTC_PLL_GET TARGET_IOR('p', 0x11, \
  695. struct target_rtc_pll_info)
  696. #define TARGET_RTC_PLL_SET TARGET_IOW('p', 0x12, \
  697. struct target_rtc_pll_info)
  698. #define TARGET_RTC_VL_READ TARGET_IOR('p', 0x13, int)
  699. #define TARGET_RTC_VL_CLR TARGET_IO('p', 0x14)
  700. #if defined(TARGET_ALPHA) || defined(TARGET_MIPS) || defined(TARGET_SH4) || \
  701. defined(TARGET_XTENSA)
  702. #define TARGET_FIOGETOWN TARGET_IOR('f', 123, int)
  703. #define TARGET_FIOSETOWN TARGET_IOW('f', 124, int)
  704. #define TARGET_SIOCATMARK TARGET_IOR('s', 7, int)
  705. #define TARGET_SIOCSPGRP TARGET_IOW('s', 8, pid_t)
  706. #define TARGET_SIOCGPGRP TARGET_IOR('s', 9, pid_t)
  707. #else
  708. #define TARGET_FIOGETOWN 0x8903
  709. #define TARGET_FIOSETOWN 0x8901
  710. #define TARGET_SIOCATMARK 0x8905
  711. #define TARGET_SIOCSPGRP 0x8902
  712. #define TARGET_SIOCGPGRP 0x8904
  713. #endif
  714. #if defined(TARGET_SH4)
  715. #define TARGET_SIOCGSTAMP_OLD TARGET_IOR('s', 100, struct target_timeval)
  716. #define TARGET_SIOCGSTAMPNS_OLD TARGET_IOR('s', 101, struct target_timespec)
  717. #else
  718. #define TARGET_SIOCGSTAMP_OLD 0x8906
  719. #define TARGET_SIOCGSTAMPNS_OLD 0x8907
  720. #endif
  721. #define TARGET_SIOCGSTAMP_NEW TARGET_IOR(0x89, 0x06, abi_llong[2])
  722. #define TARGET_SIOCGSTAMPNS_NEW TARGET_IOR(0x89, 0x07, abi_llong[2])
  723. /* Networking ioctls */
  724. #define TARGET_SIOCADDRT 0x890B /* add routing table entry */
  725. #define TARGET_SIOCDELRT 0x890C /* delete routing table entry */
  726. #define TARGET_SIOCGIFNAME 0x8910 /* get iface name */
  727. #define TARGET_SIOCSIFLINK 0x8911 /* set iface channel */
  728. #define TARGET_SIOCGIFCONF 0x8912 /* get iface list */
  729. #define TARGET_SIOCGIFFLAGS 0x8913 /* get flags */
  730. #define TARGET_SIOCSIFFLAGS 0x8914 /* set flags */
  731. #define TARGET_SIOCGIFADDR 0x8915 /* get PA address */
  732. #define TARGET_SIOCSIFADDR 0x8916 /* set PA address */
  733. #define TARGET_SIOCGIFDSTADDR 0x8917 /* get remote PA address */
  734. #define TARGET_SIOCSIFDSTADDR 0x8918 /* set remote PA address */
  735. #define TARGET_SIOCGIFBRDADDR 0x8919 /* get broadcast PA address */
  736. #define TARGET_SIOCSIFBRDADDR 0x891a /* set broadcast PA address */
  737. #define TARGET_SIOCGIFNETMASK 0x891b /* get network PA mask */
  738. #define TARGET_SIOCSIFNETMASK 0x891c /* set network PA mask */
  739. #define TARGET_SIOCGIFMETRIC 0x891d /* get metric */
  740. #define TARGET_SIOCSIFMETRIC 0x891e /* set metric */
  741. #define TARGET_SIOCGIFMEM 0x891f /* get memory address (BSD) */
  742. #define TARGET_SIOCSIFMEM 0x8920 /* set memory address (BSD) */
  743. #define TARGET_SIOCGIFMTU 0x8921 /* get MTU size */
  744. #define TARGET_SIOCSIFMTU 0x8922 /* set MTU size */
  745. #define TARGET_SIOCSIFHWADDR 0x8924 /* set hardware address (NI) */
  746. #define TARGET_SIOCGIFENCAP 0x8925 /* get/set slip encapsulation */
  747. #define TARGET_SIOCSIFENCAP 0x8926
  748. #define TARGET_SIOCGIFHWADDR 0x8927 /* Get hardware address */
  749. #define TARGET_SIOCGIFSLAVE 0x8929 /* Driver slaving support */
  750. #define TARGET_SIOCSIFSLAVE 0x8930
  751. #define TARGET_SIOCADDMULTI 0x8931 /* Multicast address lists */
  752. #define TARGET_SIOCDELMULTI 0x8932
  753. #define TARGET_SIOCGIFINDEX 0x8933
  754. #define TARGET_SIOCSIFPFLAGS 0x8934 /* set extended flags */
  755. #define TARGET_SIOCGIFPFLAGS 0x8935 /* get extended flags */
  756. /* Bridging control calls */
  757. #define TARGET_SIOCGIFBR 0x8940 /* Bridging support */
  758. #define TARGET_SIOCSIFBR 0x8941 /* Set bridging options */
  759. #define TARGET_SIOCGIFTXQLEN 0x8942 /* Get the tx queue length */
  760. #define TARGET_SIOCSIFTXQLEN 0x8943 /* Set the tx queue length */
  761. /* ARP cache control calls. */
  762. #define TARGET_OLD_SIOCDARP 0x8950 /* old delete ARP table entry */
  763. #define TARGET_OLD_SIOCGARP 0x8951 /* old get ARP table entry */
  764. #define TARGET_OLD_SIOCSARP 0x8952 /* old set ARP table entry */
  765. #define TARGET_SIOCDARP 0x8953 /* delete ARP table entry */
  766. #define TARGET_SIOCGARP 0x8954 /* get ARP table entry */
  767. #define TARGET_SIOCSARP 0x8955 /* set ARP table entry */
  768. /* RARP cache control calls. */
  769. #define TARGET_SIOCDRARP 0x8960 /* delete RARP table entry */
  770. #define TARGET_SIOCGRARP 0x8961 /* get RARP table entry */
  771. #define TARGET_SIOCSRARP 0x8962 /* set RARP table entry */
  772. /* Driver configuration calls */
  773. #define TARGET_SIOCGIFMAP 0x8970 /* Get device parameters */
  774. #define TARGET_SIOCSIFMAP 0x8971 /* Set device parameters */
  775. /* DLCI configuration calls */
  776. #define TARGET_SIOCADDDLCI 0x8980 /* Create new DLCI device */
  777. #define TARGET_SIOCDELDLCI 0x8981 /* Delete DLCI device */
  778. /* From <linux/wireless.h> */
  779. #define TARGET_SIOCGIWNAME 0x8B01 /* get name == wireless protocol */
  780. /* From <linux/random.h> */
  781. #define TARGET_RNDGETENTCNT TARGET_IOR('R', 0x00, int)
  782. #define TARGET_RNDADDTOENTCNT TARGET_IOW('R', 0x01, int)
  783. #define TARGET_RNDZAPENTCNT TARGET_IO('R', 0x04)
  784. #define TARGET_RNDCLEARPOOL TARGET_IO('R', 0x06)
  785. #define TARGET_RNDRESEEDCRNG TARGET_IO('R', 0x07)
  786. /* From <linux/fs.h> */
  787. #define TARGET_BLKROSET TARGET_IO(0x12,93) /* set device read-only (0 = read-write) */
  788. #define TARGET_BLKROGET TARGET_IO(0x12,94) /* get read-only status (0 = read_write) */
  789. #define TARGET_BLKRRPART TARGET_IO(0x12,95) /* re-read partition table */
  790. #define TARGET_BLKGETSIZE TARGET_IO(0x12,96) /* return device size /512 (long *arg) */
  791. #define TARGET_BLKFLSBUF TARGET_IO(0x12,97) /* flush buffer cache */
  792. #define TARGET_BLKRASET TARGET_IO(0x12,98) /* Set read ahead for block device */
  793. #define TARGET_BLKRAGET TARGET_IO(0x12,99) /* get current read ahead setting */
  794. #define TARGET_BLKFRASET TARGET_IO(0x12,100)/* set filesystem (mm/filemap.c) read-ahead */
  795. #define TARGET_BLKFRAGET TARGET_IO(0x12,101)/* get filesystem (mm/filemap.c) read-ahead */
  796. #define TARGET_BLKSECTSET TARGET_IO(0x12,102)/* set max sectors per request (ll_rw_blk.c) */
  797. #define TARGET_BLKSECTGET TARGET_IO(0x12,103)/* get max sectors per request (ll_rw_blk.c) */
  798. #define TARGET_BLKSSZGET TARGET_IO(0x12,104)/* get block device sector size */
  799. #define TARGET_BLKPG TARGET_IO(0x12,105)/* Partition table and disk geometry handling */
  800. /* A jump here: 108-111 have been used for various private purposes. */
  801. #define TARGET_BLKBSZGET TARGET_IOR(0x12, 112, abi_ulong)
  802. #define TARGET_BLKBSZSET TARGET_IOW(0x12, 113, abi_ulong)
  803. #define TARGET_BLKGETSIZE64 TARGET_IOR(0x12,114,abi_ulong)
  804. /* return device size in bytes
  805. (u64 *arg) */
  806. #define TARGET_BLKDISCARD TARGET_IO(0x12, 119)
  807. #define TARGET_BLKIOMIN TARGET_IO(0x12, 120)
  808. #define TARGET_BLKIOOPT TARGET_IO(0x12, 121)
  809. #define TARGET_BLKALIGNOFF TARGET_IO(0x12, 122)
  810. #define TARGET_BLKPBSZGET TARGET_IO(0x12, 123)
  811. #define TARGET_BLKDISCARDZEROES TARGET_IO(0x12, 124)
  812. #define TARGET_BLKSECDISCARD TARGET_IO(0x12, 125)
  813. #define TARGET_BLKROTATIONAL TARGET_IO(0x12, 126)
  814. #define TARGET_BLKZEROOUT TARGET_IO(0x12, 127)
  815. /* From <linux/fd.h> */
  816. #define TARGET_FDMSGON TARGET_IO(2, 0x45)
  817. #define TARGET_FDMSGOFF TARGET_IO(2, 0x46)
  818. #define TARGET_FDFMTBEG TARGET_IO(2, 0x47)
  819. #define TARGET_FDFMTTRK TARGET_IOW(2, 0x48, struct format_descr)
  820. #define TARGET_FDFMTEND TARGET_IO(2, 0x49)
  821. #define TARGET_FDSETEMSGTRESH TARGET_IO(2, 0x4a)
  822. #define TARGET_FDFLUSH TARGET_IO(2, 0x4b)
  823. #define TARGET_FDSETMAXERRS TARGET_IOW(2, 0x4c, struct floppy_max_errors)
  824. #define TARGET_FDGETMAXERRS TARGET_IOR(2, 0x0e, struct floppy_max_errors)
  825. #define TARGET_FDRESET TARGET_IO(2, 0x54)
  826. #define TARGET_FDRAWCMD TARGET_IO(2, 0x58)
  827. #define TARGET_FDTWADDLE TARGET_IO(2, 0x59)
  828. #define TARGET_FDEJECT TARGET_IO(2, 0x5a)
  829. #define TARGET_FIBMAP TARGET_IO(0x00,1) /* bmap access */
  830. #define TARGET_FIGETBSZ TARGET_IO(0x00,2) /* get the block size used for bmap */
  831. #define TARGET_FICLONE TARGET_IOW(0x94, 9, int)
  832. #define TARGET_FICLONERANGE TARGET_IOW(0x94, 13, struct file_clone_range)
  833. /*
  834. * Note that the ioctl numbers for FS_IOC_<GET|SET><FLAGS|VERSION>
  835. * claim type "long" but the actual type used by the kernel is "int".
  836. */
  837. #define TARGET_FS_IOC_GETFLAGS TARGET_IOR('f', 1, abi_long)
  838. #define TARGET_FS_IOC_SETFLAGS TARGET_IOW('f', 2, abi_long)
  839. #define TARGET_FS_IOC_GETVERSION TARGET_IOR('v', 1, abi_long)
  840. #define TARGET_FS_IOC_SETVERSION TARGET_IOW('v', 2, abi_long)
  841. #define TARGET_FS_IOC_FIEMAP TARGET_IOWR('f',11,struct fiemap)
  842. #define TARGET_FS_IOC32_GETFLAGS TARGET_IOR('f', 1, int)
  843. #define TARGET_FS_IOC32_SETFLAGS TARGET_IOW('f', 2, int)
  844. #define TARGET_FS_IOC32_GETVERSION TARGET_IOR('v', 1, int)
  845. #define TARGET_FS_IOC32_SETVERSION TARGET_IOW('v', 2, int)
  846. /* usb ioctls */
  847. #define TARGET_USBDEVFS_CONTROL TARGET_IOWRU('U', 0)
  848. #define TARGET_USBDEVFS_BULK TARGET_IOWRU('U', 2)
  849. #define TARGET_USBDEVFS_RESETEP TARGET_IORU('U', 3)
  850. #define TARGET_USBDEVFS_SETINTERFACE TARGET_IORU('U', 4)
  851. #define TARGET_USBDEVFS_SETCONFIGURATION TARGET_IORU('U', 5)
  852. #define TARGET_USBDEVFS_GETDRIVER TARGET_IOWU('U', 8)
  853. #define TARGET_USBDEVFS_SUBMITURB TARGET_IORU('U', 10)
  854. #define TARGET_USBDEVFS_DISCARDURB TARGET_IO('U', 11)
  855. #define TARGET_USBDEVFS_REAPURB TARGET_IOWU('U', 12)
  856. #define TARGET_USBDEVFS_REAPURBNDELAY TARGET_IOWU('U', 13)
  857. #define TARGET_USBDEVFS_DISCSIGNAL TARGET_IORU('U', 14)
  858. #define TARGET_USBDEVFS_CLAIMINTERFACE TARGET_IORU('U', 15)
  859. #define TARGET_USBDEVFS_RELEASEINTERFACE TARGET_IORU('U', 16)
  860. #define TARGET_USBDEVFS_CONNECTINFO TARGET_IOWU('U', 17)
  861. #define TARGET_USBDEVFS_IOCTL TARGET_IOWRU('U', 18)
  862. #define TARGET_USBDEVFS_HUB_PORTINFO TARGET_IORU('U', 19)
  863. #define TARGET_USBDEVFS_RESET TARGET_IO('U', 20)
  864. #define TARGET_USBDEVFS_CLEAR_HALT TARGET_IORU('U', 21)
  865. #define TARGET_USBDEVFS_DISCONNECT TARGET_IO('U', 22)
  866. #define TARGET_USBDEVFS_CONNECT TARGET_IO('U', 23)
  867. #define TARGET_USBDEVFS_CLAIM_PORT TARGET_IORU('U', 24)
  868. #define TARGET_USBDEVFS_RELEASE_PORT TARGET_IORU('U', 25)
  869. #define TARGET_USBDEVFS_GET_CAPABILITIES TARGET_IORU('U', 26)
  870. #define TARGET_USBDEVFS_DISCONNECT_CLAIM TARGET_IORU('U', 27)
  871. #define TARGET_USBDEVFS_DROP_PRIVILEGES TARGET_IOWU('U', 30)
  872. #define TARGET_USBDEVFS_GET_SPEED TARGET_IO('U', 31)
  873. /* cdrom commands */
  874. #define TARGET_CDROMPAUSE 0x5301 /* Pause Audio Operation */
  875. #define TARGET_CDROMRESUME 0x5302 /* Resume paused Audio Operation */
  876. #define TARGET_CDROMPLAYMSF 0x5303 /* Play Audio MSF (struct cdrom_msf) */
  877. #define TARGET_CDROMPLAYTRKIND 0x5304 /* Play Audio Track/index
  878. (struct cdrom_ti) */
  879. #define TARGET_CDROMREADTOCHDR 0x5305 /* Read TOC header
  880. (struct cdrom_tochdr) */
  881. #define TARGET_CDROMREADTOCENTRY 0x5306 /* Read TOC entry
  882. (struct cdrom_tocentry) */
  883. #define TARGET_CDROMSTOP 0x5307 /* Stop the cdrom drive */
  884. #define TARGET_CDROMSTART 0x5308 /* Start the cdrom drive */
  885. #define TARGET_CDROMEJECT 0x5309 /* Ejects the cdrom media */
  886. #define TARGET_CDROMVOLCTRL 0x530a /* Control output volume
  887. (struct cdrom_volctrl) */
  888. #define TARGET_CDROMSUBCHNL 0x530b /* Read subchannel data
  889. (struct cdrom_subchnl) */
  890. #define TARGET_CDROMREADMODE2 0x530c /* Read TARGET_CDROM mode 2 data (2336 Bytes)
  891. (struct cdrom_read) */
  892. #define TARGET_CDROMREADMODE1 0x530d /* Read TARGET_CDROM mode 1 data (2048 Bytes)
  893. (struct cdrom_read) */
  894. #define TARGET_CDROMREADAUDIO 0x530e /* (struct cdrom_read_audio) */
  895. #define TARGET_CDROMEJECT_SW 0x530f /* enable(1)/disable(0) auto-ejecting */
  896. #define TARGET_CDROMMULTISESSION 0x5310 /* Obtain the start-of-last-session
  897. address of multi session disks
  898. (struct cdrom_multisession) */
  899. #define TARGET_CDROM_GET_MCN 0x5311 /* Obtain the "Universal Product Code"
  900. if available (struct cdrom_mcn) */
  901. #define TARGET_CDROM_GET_UPC TARGET_CDROM_GET_MCN /* This one is deprecated,
  902. but here anyway for compatibility */
  903. #define TARGET_CDROMRESET 0x5312 /* hard-reset the drive */
  904. #define TARGET_CDROMVOLREAD 0x5313 /* Get the drive's volume setting
  905. (struct cdrom_volctrl) */
  906. #define TARGET_CDROMREADRAW 0x5314 /* read data in raw mode (2352 Bytes)
  907. (struct cdrom_read) */
  908. /*
  909. * These ioctls are used only used in aztcd.c and optcd.c
  910. */
  911. #define TARGET_CDROMREADCOOKED 0x5315 /* read data in cooked mode */
  912. #define TARGET_CDROMSEEK 0x5316 /* seek msf address */
  913. /*
  914. * This ioctl is only used by the scsi-cd driver.
  915. It is for playing audio in logical block addressing mode.
  916. */
  917. #define TARGET_CDROMPLAYBLK 0x5317 /* (struct cdrom_blk) */
  918. /*
  919. * These ioctls are only used in optcd.c
  920. */
  921. #define TARGET_CDROMREADALL 0x5318 /* read all 2646 bytes */
  922. /*
  923. * These ioctls are (now) only in ide-cd.c for controlling
  924. * drive spindown time. They should be implemented in the
  925. * Uniform driver, via generic packet commands, GPCMD_MODE_SELECT_10,
  926. * GPCMD_MODE_SENSE_10 and the GPMODE_POWER_PAGE...
  927. * -Erik
  928. */
  929. #define TARGET_CDROMGETSPINDOWN 0x531d
  930. #define TARGET_CDROMSETSPINDOWN 0x531e
  931. /*
  932. * These ioctls are implemented through the uniform CD-ROM driver
  933. * They _will_ be adopted by all CD-ROM drivers, when all the CD-ROM
  934. * drivers are eventually ported to the uniform CD-ROM driver interface.
  935. */
  936. #define TARGET_CDROMCLOSETRAY 0x5319 /* pendant of CDROMEJECT */
  937. #define TARGET_CDROM_SET_OPTIONS 0x5320 /* Set behavior options */
  938. #define TARGET_CDROM_CLEAR_OPTIONS 0x5321 /* Clear behavior options */
  939. #define TARGET_CDROM_SELECT_SPEED 0x5322 /* Set the CD-ROM speed */
  940. #define TARGET_CDROM_SELECT_DISC 0x5323 /* Select disc (for juke-boxes) */
  941. #define TARGET_CDROM_MEDIA_CHANGED 0x5325 /* Check is media changed */
  942. #define TARGET_CDROM_DRIVE_STATUS 0x5326 /* Get tray position, etc. */
  943. #define TARGET_CDROM_DISC_STATUS 0x5327 /* Get disc type, etc. */
  944. #define TARGET_CDROM_CHANGER_NSLOTS 0x5328 /* Get number of slots */
  945. #define TARGET_CDROM_LOCKDOOR 0x5329 /* lock or unlock door */
  946. #define TARGET_CDROM_DEBUG 0x5330 /* Turn debug messages on/off */
  947. #define TARGET_CDROM_GET_CAPABILITY 0x5331 /* get capabilities */
  948. /* Note that scsi/scsi_ioctl.h also uses 0x5382 - 0x5386.
  949. * Future CDROM ioctls should be kept below 0x537F
  950. */
  951. /* This ioctl is only used by sbpcd at the moment */
  952. #define TARGET_CDROMAUDIOBUFSIZ 0x5382 /* set the audio buffer size */
  953. /* conflict with SCSI_IOCTL_GET_IDLUN */
  954. /* DVD-ROM Specific ioctls */
  955. #define TARGET_DVD_READ_STRUCT 0x5390 /* Read structure */
  956. #define TARGET_DVD_WRITE_STRUCT 0x5391 /* Write structure */
  957. #define TARGET_DVD_AUTH 0x5392 /* Authentication */
  958. #define TARGET_CDROM_SEND_PACKET 0x5393 /* send a packet to the drive */
  959. #define TARGET_CDROM_NEXT_WRITABLE 0x5394 /* get next writable block */
  960. #define TARGET_CDROM_LAST_WRITTEN 0x5395 /* get last block written on disc */
  961. /* HD commands */
  962. /* hd/ide ctl's that pass (arg) ptrs to user space are numbered 0x030n/0x031n */
  963. #define TARGET_HDIO_GETGEO 0x0301 /* get device geometry */
  964. #define TARGET_HDIO_GET_UNMASKINTR 0x0302 /* get current unmask setting */
  965. #define TARGET_HDIO_GET_MULTCOUNT 0x0304 /* get current IDE blockmode setting */
  966. #define TARGET_HDIO_GET_KEEPSETTINGS 0x0308 /* get keep-settings-on-reset flag */
  967. #define TARGET_HDIO_GET_32BIT 0x0309 /* get current io_32bit setting */
  968. #define TARGET_HDIO_GET_NOWERR 0x030a /* get ignore-write-error flag */
  969. #define TARGET_HDIO_GET_DMA 0x030b /* get use-dma flag */
  970. #define TARGET_HDIO_GET_IDENTITY 0x030d /* get IDE identification info */
  971. #define TARGET_HDIO_DRIVE_CMD 0x031f /* execute a special drive command */
  972. /* hd/ide ctl's that pass (arg) non-ptr values are numbered 0x032n/0x033n */
  973. #define TARGET_HDIO_SET_MULTCOUNT 0x0321 /* change IDE blockmode */
  974. #define TARGET_HDIO_SET_UNMASKINTR 0x0322 /* permit other irqs during I/O */
  975. #define TARGET_HDIO_SET_KEEPSETTINGS 0x0323 /* keep ioctl settings on reset */
  976. #define TARGET_HDIO_SET_32BIT 0x0324 /* change io_32bit flags */
  977. #define TARGET_HDIO_SET_NOWERR 0x0325 /* change ignore-write-error flag */
  978. #define TARGET_HDIO_SET_DMA 0x0326 /* change use-dma flag */
  979. #define TARGET_HDIO_SET_PIO_MODE 0x0327 /* reconfig interface to new speed */
  980. /* loop ioctls */
  981. #define TARGET_LOOP_SET_FD 0x4C00
  982. #define TARGET_LOOP_CLR_FD 0x4C01
  983. #define TARGET_LOOP_SET_STATUS 0x4C02
  984. #define TARGET_LOOP_GET_STATUS 0x4C03
  985. #define TARGET_LOOP_SET_STATUS64 0x4C04
  986. #define TARGET_LOOP_GET_STATUS64 0x4C05
  987. #define TARGET_LOOP_CHANGE_FD 0x4C06
  988. #define TARGET_LOOP_CTL_ADD 0x4C80
  989. #define TARGET_LOOP_CTL_REMOVE 0x4C81
  990. #define TARGET_LOOP_CTL_GET_FREE 0x4C82
  991. /* fb ioctls */
  992. #define TARGET_FBIOGET_VSCREENINFO 0x4600
  993. #define TARGET_FBIOPUT_VSCREENINFO 0x4601
  994. #define TARGET_FBIOGET_FSCREENINFO 0x4602
  995. #define TARGET_FBIOGETCMAP 0x4604
  996. #define TARGET_FBIOPUTCMAP 0x4605
  997. #define TARGET_FBIOPAN_DISPLAY 0x4606
  998. #define TARGET_FBIOGET_CON2FBMAP 0x460F
  999. #define TARGET_FBIOPUT_CON2FBMAP 0x4610
  1000. /* vt ioctls */
  1001. #define TARGET_VT_OPENQRY 0x5600
  1002. #define TARGET_VT_GETSTATE 0x5603
  1003. #define TARGET_VT_ACTIVATE 0x5606
  1004. #define TARGET_VT_WAITACTIVE 0x5607
  1005. #define TARGET_VT_LOCKSWITCH 0x560b
  1006. #define TARGET_VT_UNLOCKSWITCH 0x560c
  1007. #define TARGET_VT_GETMODE 0x5601
  1008. #define TARGET_VT_SETMODE 0x5602
  1009. #define TARGET_VT_RELDISP 0x5605
  1010. #define TARGET_VT_DISALLOCATE 0x5608
  1011. /* device mapper */
  1012. #define TARGET_DM_VERSION TARGET_IOWRU(0xfd, 0x00)
  1013. #define TARGET_DM_REMOVE_ALL TARGET_IOWRU(0xfd, 0x01)
  1014. #define TARGET_DM_LIST_DEVICES TARGET_IOWRU(0xfd, 0x02)
  1015. #define TARGET_DM_DEV_CREATE TARGET_IOWRU(0xfd, 0x03)
  1016. #define TARGET_DM_DEV_REMOVE TARGET_IOWRU(0xfd, 0x04)
  1017. #define TARGET_DM_DEV_RENAME TARGET_IOWRU(0xfd, 0x05)
  1018. #define TARGET_DM_DEV_SUSPEND TARGET_IOWRU(0xfd, 0x06)
  1019. #define TARGET_DM_DEV_STATUS TARGET_IOWRU(0xfd, 0x07)
  1020. #define TARGET_DM_DEV_WAIT TARGET_IOWRU(0xfd, 0x08)
  1021. #define TARGET_DM_TABLE_LOAD TARGET_IOWRU(0xfd, 0x09)
  1022. #define TARGET_DM_TABLE_CLEAR TARGET_IOWRU(0xfd, 0x0a)
  1023. #define TARGET_DM_TABLE_DEPS TARGET_IOWRU(0xfd, 0x0b)
  1024. #define TARGET_DM_TABLE_STATUS TARGET_IOWRU(0xfd, 0x0c)
  1025. #define TARGET_DM_LIST_VERSIONS TARGET_IOWRU(0xfd, 0x0d)
  1026. #define TARGET_DM_TARGET_MSG TARGET_IOWRU(0xfd, 0x0e)
  1027. #define TARGET_DM_DEV_SET_GEOMETRY TARGET_IOWRU(0xfd, 0x0f)
  1028. /* drm ioctls */
  1029. #define TARGET_DRM_IOCTL_VERSION TARGET_IOWRU('d', 0x00)
  1030. /* from asm/termbits.h */
  1031. #define TARGET_NCC 8
  1032. struct target_termio {
  1033. unsigned short c_iflag; /* input mode flags */
  1034. unsigned short c_oflag; /* output mode flags */
  1035. unsigned short c_cflag; /* control mode flags */
  1036. unsigned short c_lflag; /* local mode flags */
  1037. unsigned char c_line; /* line discipline */
  1038. unsigned char c_cc[TARGET_NCC]; /* control characters */
  1039. };
  1040. struct target_winsize {
  1041. unsigned short ws_row;
  1042. unsigned short ws_col;
  1043. unsigned short ws_xpixel;
  1044. unsigned short ws_ypixel;
  1045. };
  1046. #include "termbits.h"
  1047. #if defined(TARGET_MIPS)
  1048. #define TARGET_PROT_SEM 0x10
  1049. #else
  1050. #define TARGET_PROT_SEM 0x08
  1051. #endif
  1052. /* Common */
  1053. #define TARGET_MAP_SHARED 0x01 /* Share changes */
  1054. #define TARGET_MAP_PRIVATE 0x02 /* Changes are private */
  1055. #if defined(TARGET_HPPA)
  1056. #define TARGET_MAP_TYPE 0x03 /* Mask for type of mapping */
  1057. #else
  1058. #define TARGET_MAP_TYPE 0x0f /* Mask for type of mapping */
  1059. #endif
  1060. /* Target specific */
  1061. #if defined(TARGET_MIPS)
  1062. #define TARGET_MAP_FIXED 0x10 /* Interpret addr exactly */
  1063. #define TARGET_MAP_ANONYMOUS 0x0800 /* don't use a file */
  1064. #define TARGET_MAP_GROWSDOWN 0x1000 /* stack-like segment */
  1065. #define TARGET_MAP_DENYWRITE 0x2000 /* ETXTBSY */
  1066. #define TARGET_MAP_EXECUTABLE 0x4000 /* mark it as an executable */
  1067. #define TARGET_MAP_LOCKED 0x8000 /* pages are locked */
  1068. #define TARGET_MAP_NORESERVE 0x0400 /* don't check for reservations */
  1069. #define TARGET_MAP_POPULATE 0x10000 /* populate (prefault) pagetables */
  1070. #define TARGET_MAP_NONBLOCK 0x20000 /* do not block on IO */
  1071. #define TARGET_MAP_STACK 0x40000 /* ignored */
  1072. #define TARGET_MAP_HUGETLB 0x80000 /* create a huge page mapping */
  1073. #elif defined(TARGET_PPC)
  1074. #define TARGET_MAP_FIXED 0x10 /* Interpret addr exactly */
  1075. #define TARGET_MAP_ANONYMOUS 0x20 /* don't use a file */
  1076. #define TARGET_MAP_GROWSDOWN 0x0100 /* stack-like segment */
  1077. #define TARGET_MAP_DENYWRITE 0x0800 /* ETXTBSY */
  1078. #define TARGET_MAP_EXECUTABLE 0x1000 /* mark it as an executable */
  1079. #define TARGET_MAP_LOCKED 0x0080 /* pages are locked */
  1080. #define TARGET_MAP_NORESERVE 0x0040 /* don't check for reservations */
  1081. #define TARGET_MAP_POPULATE 0x8000 /* populate (prefault) pagetables */
  1082. #define TARGET_MAP_NONBLOCK 0x10000 /* do not block on IO */
  1083. #define TARGET_MAP_STACK 0x20000 /* ignored */
  1084. #define TARGET_MAP_HUGETLB 0x40000 /* create a huge page mapping */
  1085. #elif defined(TARGET_ALPHA)
  1086. #define TARGET_MAP_ANONYMOUS 0x10 /* don't use a file */
  1087. #define TARGET_MAP_FIXED 0x100 /* Interpret addr exactly */
  1088. #define TARGET_MAP_GROWSDOWN 0x01000 /* stack-like segment */
  1089. #define TARGET_MAP_DENYWRITE 0x02000 /* ETXTBSY */
  1090. #define TARGET_MAP_EXECUTABLE 0x04000 /* mark it as an executable */
  1091. #define TARGET_MAP_LOCKED 0x08000 /* lock the mapping */
  1092. #define TARGET_MAP_NORESERVE 0x10000 /* no check for reservations */
  1093. #define TARGET_MAP_POPULATE 0x20000 /* pop (prefault) pagetables */
  1094. #define TARGET_MAP_NONBLOCK 0x40000 /* do not block on IO */
  1095. #define TARGET_MAP_STACK 0x80000 /* ignored */
  1096. #define TARGET_MAP_HUGETLB 0x100000 /* create a huge page mapping */
  1097. #elif defined(TARGET_HPPA)
  1098. #define TARGET_MAP_ANONYMOUS 0x10 /* don't use a file */
  1099. #define TARGET_MAP_FIXED 0x04 /* Interpret addr exactly */
  1100. #define TARGET_MAP_GROWSDOWN 0x08000 /* stack-like segment */
  1101. #define TARGET_MAP_DENYWRITE 0x00800 /* ETXTBSY */
  1102. #define TARGET_MAP_EXECUTABLE 0x01000 /* mark it as an executable */
  1103. #define TARGET_MAP_LOCKED 0x02000 /* lock the mapping */
  1104. #define TARGET_MAP_NORESERVE 0x04000 /* no check for reservations */
  1105. #define TARGET_MAP_POPULATE 0x10000 /* pop (prefault) pagetables */
  1106. #define TARGET_MAP_NONBLOCK 0x20000 /* do not block on IO */
  1107. #define TARGET_MAP_STACK 0x40000 /* ignored */
  1108. #define TARGET_MAP_HUGETLB 0x80000 /* create a huge page mapping */
  1109. #elif defined(TARGET_XTENSA)
  1110. #define TARGET_MAP_FIXED 0x10 /* Interpret addr exactly */
  1111. #define TARGET_MAP_ANONYMOUS 0x0800 /* don't use a file */
  1112. #define TARGET_MAP_GROWSDOWN 0x1000 /* stack-like segment */
  1113. #define TARGET_MAP_DENYWRITE 0x2000 /* ETXTBSY */
  1114. #define TARGET_MAP_EXECUTABLE 0x4000 /* mark it as an executable */
  1115. #define TARGET_MAP_LOCKED 0x8000 /* pages are locked */
  1116. #define TARGET_MAP_NORESERVE 0x0400 /* don't check for reservations */
  1117. #define TARGET_MAP_POPULATE 0x10000 /* populate (prefault) pagetables */
  1118. #define TARGET_MAP_NONBLOCK 0x20000 /* do not block on IO */
  1119. #define TARGET_MAP_STACK 0x40000
  1120. #define TARGET_MAP_HUGETLB 0x80000 /* create a huge page mapping */
  1121. #else
  1122. #define TARGET_MAP_FIXED 0x10 /* Interpret addr exactly */
  1123. #define TARGET_MAP_ANONYMOUS 0x20 /* don't use a file */
  1124. #define TARGET_MAP_GROWSDOWN 0x0100 /* stack-like segment */
  1125. #define TARGET_MAP_DENYWRITE 0x0800 /* ETXTBSY */
  1126. #define TARGET_MAP_EXECUTABLE 0x1000 /* mark it as an executable */
  1127. #define TARGET_MAP_LOCKED 0x2000 /* pages are locked */
  1128. #define TARGET_MAP_NORESERVE 0x4000 /* don't check for reservations */
  1129. #define TARGET_MAP_POPULATE 0x8000 /* populate (prefault) pagetables */
  1130. #define TARGET_MAP_NONBLOCK 0x10000 /* do not block on IO */
  1131. #define TARGET_MAP_STACK 0x20000 /* ignored */
  1132. #define TARGET_MAP_HUGETLB 0x40000 /* create a huge page mapping */
  1133. #define TARGET_MAP_UNINITIALIZED 0x4000000 /* for anonymous mmap, memory could be uninitialized */
  1134. #endif
  1135. #if (defined(TARGET_I386) && defined(TARGET_ABI32)) \
  1136. || (defined(TARGET_ARM) && defined(TARGET_ABI32)) \
  1137. || defined(TARGET_CRIS)
  1138. #define TARGET_STAT_HAVE_NSEC
  1139. struct target_stat {
  1140. unsigned short st_dev;
  1141. unsigned short __pad1;
  1142. abi_ulong st_ino;
  1143. unsigned short st_mode;
  1144. unsigned short st_nlink;
  1145. unsigned short st_uid;
  1146. unsigned short st_gid;
  1147. unsigned short st_rdev;
  1148. unsigned short __pad2;
  1149. abi_ulong st_size;
  1150. abi_ulong st_blksize;
  1151. abi_ulong st_blocks;
  1152. abi_ulong target_st_atime;
  1153. abi_ulong target_st_atime_nsec;
  1154. abi_ulong target_st_mtime;
  1155. abi_ulong target_st_mtime_nsec;
  1156. abi_ulong target_st_ctime;
  1157. abi_ulong target_st_ctime_nsec;
  1158. abi_ulong __unused4;
  1159. abi_ulong __unused5;
  1160. };
  1161. /* This matches struct stat64 in glibc2.1, hence the absolutely
  1162. * insane amounts of padding around dev_t's.
  1163. */
  1164. #define TARGET_HAS_STRUCT_STAT64
  1165. struct target_stat64 {
  1166. unsigned short st_dev;
  1167. unsigned char __pad0[10];
  1168. #define TARGET_STAT64_HAS_BROKEN_ST_INO 1
  1169. abi_ulong __st_ino;
  1170. unsigned int st_mode;
  1171. unsigned int st_nlink;
  1172. abi_ulong st_uid;
  1173. abi_ulong st_gid;
  1174. unsigned short st_rdev;
  1175. unsigned char __pad3[10];
  1176. long long st_size;
  1177. abi_ulong st_blksize;
  1178. abi_ulong st_blocks; /* Number 512-byte blocks allocated. */
  1179. abi_ulong __pad4; /* future possible st_blocks high bits */
  1180. abi_ulong target_st_atime;
  1181. abi_ulong target_st_atime_nsec;
  1182. abi_ulong target_st_mtime;
  1183. abi_ulong target_st_mtime_nsec;
  1184. abi_ulong target_st_ctime;
  1185. abi_ulong target_st_ctime_nsec;
  1186. unsigned long long st_ino;
  1187. } QEMU_PACKED;
  1188. #ifdef TARGET_ARM
  1189. #define TARGET_HAS_STRUCT_STAT64
  1190. struct target_eabi_stat64 {
  1191. unsigned long long st_dev;
  1192. unsigned int __pad1;
  1193. abi_ulong __st_ino;
  1194. unsigned int st_mode;
  1195. unsigned int st_nlink;
  1196. abi_ulong st_uid;
  1197. abi_ulong st_gid;
  1198. unsigned long long st_rdev;
  1199. unsigned int __pad2[2];
  1200. long long st_size;
  1201. abi_ulong st_blksize;
  1202. unsigned int __pad3;
  1203. unsigned long long st_blocks;
  1204. abi_ulong target_st_atime;
  1205. abi_ulong target_st_atime_nsec;
  1206. abi_ulong target_st_mtime;
  1207. abi_ulong target_st_mtime_nsec;
  1208. abi_ulong target_st_ctime;
  1209. abi_ulong target_st_ctime_nsec;
  1210. unsigned long long st_ino;
  1211. } QEMU_PACKED;
  1212. #endif
  1213. #elif defined(TARGET_SPARC64) && !defined(TARGET_ABI32)
  1214. struct target_stat {
  1215. unsigned int st_dev;
  1216. abi_ulong st_ino;
  1217. unsigned int st_mode;
  1218. unsigned int st_nlink;
  1219. unsigned int st_uid;
  1220. unsigned int st_gid;
  1221. unsigned int st_rdev;
  1222. abi_long st_size;
  1223. abi_long target_st_atime;
  1224. abi_long target_st_mtime;
  1225. abi_long target_st_ctime;
  1226. abi_long st_blksize;
  1227. abi_long st_blocks;
  1228. abi_ulong __unused4[2];
  1229. };
  1230. #define TARGET_HAS_STRUCT_STAT64
  1231. struct target_stat64 {
  1232. unsigned char __pad0[6];
  1233. unsigned short st_dev;
  1234. uint64_t st_ino;
  1235. uint64_t st_nlink;
  1236. unsigned int st_mode;
  1237. unsigned int st_uid;
  1238. unsigned int st_gid;
  1239. unsigned char __pad2[6];
  1240. unsigned short st_rdev;
  1241. int64_t st_size;
  1242. int64_t st_blksize;
  1243. unsigned char __pad4[4];
  1244. unsigned int st_blocks;
  1245. abi_ulong target_st_atime;
  1246. abi_ulong target_st_atime_nsec;
  1247. abi_ulong target_st_mtime;
  1248. abi_ulong target_st_mtime_nsec;
  1249. abi_ulong target_st_ctime;
  1250. abi_ulong target_st_ctime_nsec;
  1251. abi_ulong __unused4[3];
  1252. };
  1253. #elif defined(TARGET_SPARC)
  1254. #define TARGET_STAT_HAVE_NSEC
  1255. struct target_stat {
  1256. unsigned short st_dev;
  1257. abi_ulong st_ino;
  1258. unsigned short st_mode;
  1259. short st_nlink;
  1260. unsigned short st_uid;
  1261. unsigned short st_gid;
  1262. unsigned short st_rdev;
  1263. abi_long st_size;
  1264. abi_long target_st_atime;
  1265. abi_ulong target_st_atime_nsec;
  1266. abi_long target_st_mtime;
  1267. abi_ulong target_st_mtime_nsec;
  1268. abi_long target_st_ctime;
  1269. abi_ulong target_st_ctime_nsec;
  1270. abi_long st_blksize;
  1271. abi_long st_blocks;
  1272. abi_ulong __unused1[2];
  1273. };
  1274. #define TARGET_HAS_STRUCT_STAT64
  1275. struct target_stat64 {
  1276. unsigned char __pad0[6];
  1277. unsigned short st_dev;
  1278. uint64_t st_ino;
  1279. unsigned int st_mode;
  1280. unsigned int st_nlink;
  1281. unsigned int st_uid;
  1282. unsigned int st_gid;
  1283. unsigned char __pad2[6];
  1284. unsigned short st_rdev;
  1285. unsigned char __pad3[8];
  1286. int64_t st_size;
  1287. unsigned int st_blksize;
  1288. unsigned char __pad4[8];
  1289. unsigned int st_blocks;
  1290. unsigned int target_st_atime;
  1291. unsigned int target_st_atime_nsec;
  1292. unsigned int target_st_mtime;
  1293. unsigned int target_st_mtime_nsec;
  1294. unsigned int target_st_ctime;
  1295. unsigned int target_st_ctime_nsec;
  1296. unsigned int __unused1;
  1297. unsigned int __unused2;
  1298. };
  1299. #elif defined(TARGET_PPC)
  1300. #define TARGET_STAT_HAVE_NSEC
  1301. struct target_stat {
  1302. abi_ulong st_dev;
  1303. abi_ulong st_ino;
  1304. #if defined(TARGET_PPC64) && !defined(TARGET_ABI32)
  1305. abi_ulong st_nlink;
  1306. unsigned int st_mode;
  1307. #else
  1308. unsigned int st_mode;
  1309. unsigned short st_nlink;
  1310. #endif
  1311. unsigned int st_uid;
  1312. unsigned int st_gid;
  1313. abi_ulong st_rdev;
  1314. abi_ulong st_size;
  1315. abi_ulong st_blksize;
  1316. abi_ulong st_blocks;
  1317. abi_ulong target_st_atime;
  1318. abi_ulong target_st_atime_nsec;
  1319. abi_ulong target_st_mtime;
  1320. abi_ulong target_st_mtime_nsec;
  1321. abi_ulong target_st_ctime;
  1322. abi_ulong target_st_ctime_nsec;
  1323. abi_ulong __unused4;
  1324. abi_ulong __unused5;
  1325. #if defined(TARGET_PPC64) && !defined(TARGET_ABI32)
  1326. abi_ulong __unused6;
  1327. #endif
  1328. };
  1329. #if !defined(TARGET_PPC64) || defined(TARGET_ABI32)
  1330. #define TARGET_HAS_STRUCT_STAT64
  1331. struct QEMU_PACKED target_stat64 {
  1332. unsigned long long st_dev;
  1333. unsigned long long st_ino;
  1334. unsigned int st_mode;
  1335. unsigned int st_nlink;
  1336. unsigned int st_uid;
  1337. unsigned int st_gid;
  1338. unsigned long long st_rdev;
  1339. unsigned long long __pad0;
  1340. long long st_size;
  1341. int st_blksize;
  1342. unsigned int __pad1;
  1343. long long 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. unsigned int __unused4;
  1351. unsigned int __unused5;
  1352. };
  1353. #endif
  1354. #elif defined(TARGET_MICROBLAZE)
  1355. #define TARGET_STAT_HAVE_NSEC
  1356. struct target_stat {
  1357. abi_ulong st_dev;
  1358. abi_ulong st_ino;
  1359. unsigned int st_mode;
  1360. unsigned short st_nlink;
  1361. unsigned int st_uid;
  1362. unsigned int st_gid;
  1363. abi_ulong st_rdev;
  1364. abi_ulong st_size;
  1365. abi_ulong st_blksize;
  1366. abi_ulong st_blocks;
  1367. abi_ulong target_st_atime;
  1368. abi_ulong target_st_atime_nsec;
  1369. abi_ulong target_st_mtime;
  1370. abi_ulong target_st_mtime_nsec;
  1371. abi_ulong target_st_ctime;
  1372. abi_ulong target_st_ctime_nsec;
  1373. abi_ulong __unused4;
  1374. abi_ulong __unused5;
  1375. };
  1376. /* FIXME: Microblaze no-mmu user-space has a difference stat64 layout... */
  1377. #define TARGET_HAS_STRUCT_STAT64
  1378. struct QEMU_PACKED target_stat64 {
  1379. uint64_t st_dev;
  1380. #define TARGET_STAT64_HAS_BROKEN_ST_INO 1
  1381. uint32_t pad0;
  1382. uint32_t __st_ino;
  1383. uint32_t st_mode;
  1384. uint32_t st_nlink;
  1385. uint32_t st_uid;
  1386. uint32_t st_gid;
  1387. uint64_t st_rdev;
  1388. uint64_t __pad1;
  1389. int64_t st_size;
  1390. int32_t st_blksize;
  1391. uint32_t __pad2;
  1392. int64_t st_blocks; /* Number 512-byte blocks allocated. */
  1393. int target_st_atime;
  1394. unsigned int target_st_atime_nsec;
  1395. int target_st_mtime;
  1396. unsigned int target_st_mtime_nsec;
  1397. int target_st_ctime;
  1398. unsigned int target_st_ctime_nsec;
  1399. uint64_t st_ino;
  1400. };
  1401. #elif defined(TARGET_M68K)
  1402. struct target_stat {
  1403. unsigned short st_dev;
  1404. unsigned short __pad1;
  1405. abi_ulong st_ino;
  1406. unsigned short st_mode;
  1407. unsigned short st_nlink;
  1408. unsigned short st_uid;
  1409. unsigned short st_gid;
  1410. unsigned short st_rdev;
  1411. unsigned short __pad2;
  1412. abi_ulong st_size;
  1413. abi_ulong st_blksize;
  1414. abi_ulong st_blocks;
  1415. abi_ulong target_st_atime;
  1416. abi_ulong __unused1;
  1417. abi_ulong target_st_mtime;
  1418. abi_ulong __unused2;
  1419. abi_ulong target_st_ctime;
  1420. abi_ulong __unused3;
  1421. abi_ulong __unused4;
  1422. abi_ulong __unused5;
  1423. };
  1424. /* This matches struct stat64 in glibc2.1, hence the absolutely
  1425. * insane amounts of padding around dev_t's.
  1426. */
  1427. #define TARGET_HAS_STRUCT_STAT64
  1428. struct target_stat64 {
  1429. unsigned long long st_dev;
  1430. unsigned char __pad1[2];
  1431. #define TARGET_STAT64_HAS_BROKEN_ST_INO 1
  1432. abi_ulong __st_ino;
  1433. unsigned int st_mode;
  1434. unsigned int st_nlink;
  1435. abi_ulong st_uid;
  1436. abi_ulong st_gid;
  1437. unsigned long long st_rdev;
  1438. unsigned char __pad3[2];
  1439. long long st_size;
  1440. abi_ulong st_blksize;
  1441. abi_ulong __pad4; /* future possible st_blocks high bits */
  1442. abi_ulong st_blocks; /* Number 512-byte blocks allocated. */
  1443. abi_ulong target_st_atime;
  1444. abi_ulong target_st_atime_nsec;
  1445. abi_ulong target_st_mtime;
  1446. abi_ulong target_st_mtime_nsec;
  1447. abi_ulong target_st_ctime;
  1448. abi_ulong target_st_ctime_nsec;
  1449. unsigned long long st_ino;
  1450. } QEMU_PACKED;
  1451. #elif defined(TARGET_ABI_MIPSN64)
  1452. #define TARGET_STAT_HAVE_NSEC
  1453. /* The memory layout is the same as of struct stat64 of the 32-bit kernel. */
  1454. struct target_stat {
  1455. unsigned int st_dev;
  1456. unsigned int st_pad0[3]; /* Reserved for st_dev expansion */
  1457. abi_ulong st_ino;
  1458. unsigned int st_mode;
  1459. unsigned int st_nlink;
  1460. int st_uid;
  1461. int st_gid;
  1462. unsigned int st_rdev;
  1463. unsigned int st_pad1[3]; /* Reserved for st_rdev expansion */
  1464. abi_ulong st_size;
  1465. /*
  1466. * Actually this should be timestruc_t st_atime, st_mtime and st_ctime
  1467. * but we don't have it under Linux.
  1468. */
  1469. unsigned int target_st_atime;
  1470. unsigned int target_st_atime_nsec;
  1471. unsigned int target_st_mtime;
  1472. unsigned int target_st_mtime_nsec;
  1473. unsigned int target_st_ctime;
  1474. unsigned int target_st_ctime_nsec;
  1475. unsigned int st_blksize;
  1476. unsigned int st_pad2;
  1477. abi_ulong st_blocks;
  1478. };
  1479. #elif defined(TARGET_ABI_MIPSN32)
  1480. #define TARGET_STAT_HAVE_NSEC
  1481. struct target_stat {
  1482. abi_ulong st_dev;
  1483. abi_ulong st_pad0[3]; /* Reserved for st_dev expansion */
  1484. uint64_t st_ino;
  1485. unsigned int st_mode;
  1486. unsigned int st_nlink;
  1487. int st_uid;
  1488. int st_gid;
  1489. abi_ulong st_rdev;
  1490. abi_ulong st_pad1[3]; /* Reserved for st_rdev expansion */
  1491. int64_t st_size;
  1492. abi_long target_st_atime;
  1493. abi_ulong target_st_atime_nsec; /* Reserved for st_atime expansion */
  1494. abi_long target_st_mtime;
  1495. abi_ulong target_st_mtime_nsec; /* Reserved for st_mtime expansion */
  1496. abi_long target_st_ctime;
  1497. abi_ulong target_st_ctime_nsec; /* Reserved for st_ctime expansion */
  1498. abi_ulong st_blksize;
  1499. abi_ulong st_pad2;
  1500. int64_t st_blocks;
  1501. };
  1502. #elif defined(TARGET_ABI_MIPSO32)
  1503. #define TARGET_STAT_HAVE_NSEC
  1504. struct target_stat {
  1505. unsigned st_dev;
  1506. abi_long st_pad1[3]; /* Reserved for network id */
  1507. abi_ulong st_ino;
  1508. unsigned int st_mode;
  1509. unsigned int st_nlink;
  1510. int st_uid;
  1511. int st_gid;
  1512. unsigned st_rdev;
  1513. abi_long st_pad2[2];
  1514. abi_long st_size;
  1515. abi_long st_pad3;
  1516. /*
  1517. * Actually this should be timestruc_t st_atime, st_mtime and st_ctime
  1518. * but we don't have it under Linux.
  1519. */
  1520. abi_long target_st_atime;
  1521. abi_long target_st_atime_nsec;
  1522. abi_long target_st_mtime;
  1523. abi_long target_st_mtime_nsec;
  1524. abi_long target_st_ctime;
  1525. abi_long target_st_ctime_nsec;
  1526. abi_long st_blksize;
  1527. abi_long st_blocks;
  1528. abi_long st_pad4[14];
  1529. };
  1530. /*
  1531. * This matches struct stat64 in glibc2.1, hence the absolutely insane
  1532. * amounts of padding around dev_t's. The memory layout is the same as of
  1533. * struct stat of the 64-bit kernel.
  1534. */
  1535. #define TARGET_HAS_STRUCT_STAT64
  1536. struct target_stat64 {
  1537. abi_ulong st_dev;
  1538. abi_ulong st_pad0[3]; /* Reserved for st_dev expansion */
  1539. uint64_t st_ino;
  1540. unsigned int st_mode;
  1541. unsigned int st_nlink;
  1542. int st_uid;
  1543. int st_gid;
  1544. abi_ulong st_rdev;
  1545. abi_ulong st_pad1[3]; /* Reserved for st_rdev expansion */
  1546. int64_t st_size;
  1547. /*
  1548. * Actually this should be timestruc_t st_atime, st_mtime and st_ctime
  1549. * but we don't have it under Linux.
  1550. */
  1551. abi_long target_st_atime;
  1552. abi_ulong target_st_atime_nsec; /* Reserved for st_atime expansion */
  1553. abi_long target_st_mtime;
  1554. abi_ulong target_st_mtime_nsec; /* Reserved for st_mtime expansion */
  1555. abi_long target_st_ctime;
  1556. abi_ulong target_st_ctime_nsec; /* Reserved for st_ctime expansion */
  1557. abi_ulong st_blksize;
  1558. abi_ulong st_pad2;
  1559. int64_t st_blocks;
  1560. };
  1561. #elif defined(TARGET_ALPHA)
  1562. struct target_stat {
  1563. unsigned int st_dev;
  1564. unsigned int st_ino;
  1565. unsigned int st_mode;
  1566. unsigned int st_nlink;
  1567. unsigned int st_uid;
  1568. unsigned int st_gid;
  1569. unsigned int st_rdev;
  1570. abi_long st_size;
  1571. abi_ulong target_st_atime;
  1572. abi_ulong target_st_mtime;
  1573. abi_ulong target_st_ctime;
  1574. unsigned int st_blksize;
  1575. unsigned int st_blocks;
  1576. unsigned int st_flags;
  1577. unsigned int st_gen;
  1578. };
  1579. #define TARGET_HAS_STRUCT_STAT64
  1580. struct target_stat64 {
  1581. abi_ulong st_dev;
  1582. abi_ulong st_ino;
  1583. abi_ulong st_rdev;
  1584. abi_long st_size;
  1585. abi_ulong st_blocks;
  1586. unsigned int st_mode;
  1587. unsigned int st_uid;
  1588. unsigned int st_gid;
  1589. unsigned int st_blksize;
  1590. unsigned int st_nlink;
  1591. unsigned int __pad0;
  1592. abi_ulong target_st_atime;
  1593. abi_ulong target_st_atime_nsec;
  1594. abi_ulong target_st_mtime;
  1595. abi_ulong target_st_mtime_nsec;
  1596. abi_ulong target_st_ctime;
  1597. abi_ulong target_st_ctime_nsec;
  1598. abi_long __unused[3];
  1599. };
  1600. #elif defined(TARGET_SH4)
  1601. #define TARGET_STAT_HAVE_NSEC
  1602. struct target_stat {
  1603. abi_ulong st_dev;
  1604. abi_ulong st_ino;
  1605. unsigned short st_mode;
  1606. unsigned short st_nlink;
  1607. unsigned short st_uid;
  1608. unsigned short st_gid;
  1609. abi_ulong st_rdev;
  1610. abi_ulong st_size;
  1611. abi_ulong st_blksize;
  1612. abi_ulong st_blocks;
  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_ulong __unused4;
  1620. abi_ulong __unused5;
  1621. };
  1622. /* This matches struct stat64 in glibc2.1, hence the absolutely
  1623. * insane amounts of padding around dev_t's.
  1624. */
  1625. #define TARGET_HAS_STRUCT_STAT64
  1626. struct QEMU_PACKED target_stat64 {
  1627. unsigned long long st_dev;
  1628. unsigned char __pad0[4];
  1629. #define TARGET_STAT64_HAS_BROKEN_ST_INO 1
  1630. abi_ulong __st_ino;
  1631. unsigned int st_mode;
  1632. unsigned int st_nlink;
  1633. abi_ulong st_uid;
  1634. abi_ulong st_gid;
  1635. unsigned long long st_rdev;
  1636. unsigned char __pad3[4];
  1637. long long st_size;
  1638. abi_ulong st_blksize;
  1639. unsigned long long st_blocks; /* Number 512-byte blocks allocated. */
  1640. abi_ulong target_st_atime;
  1641. abi_ulong target_st_atime_nsec;
  1642. abi_ulong target_st_mtime;
  1643. abi_ulong target_st_mtime_nsec;
  1644. abi_ulong target_st_ctime;
  1645. abi_ulong target_st_ctime_nsec;
  1646. unsigned long long st_ino;
  1647. };
  1648. #elif defined(TARGET_I386) && !defined(TARGET_ABI32)
  1649. #define TARGET_STAT_HAVE_NSEC
  1650. struct target_stat {
  1651. abi_ulong st_dev;
  1652. abi_ulong st_ino;
  1653. abi_ulong st_nlink;
  1654. unsigned int st_mode;
  1655. unsigned int st_uid;
  1656. unsigned int st_gid;
  1657. unsigned int __pad0;
  1658. abi_ulong st_rdev;
  1659. abi_long st_size;
  1660. abi_long st_blksize;
  1661. abi_long st_blocks; /* Number 512-byte blocks allocated. */
  1662. abi_ulong target_st_atime;
  1663. abi_ulong target_st_atime_nsec;
  1664. abi_ulong target_st_mtime;
  1665. abi_ulong target_st_mtime_nsec;
  1666. abi_ulong target_st_ctime;
  1667. abi_ulong target_st_ctime_nsec;
  1668. abi_long __unused[3];
  1669. };
  1670. #elif defined(TARGET_S390X)
  1671. struct target_stat {
  1672. abi_ulong st_dev;
  1673. abi_ulong st_ino;
  1674. abi_ulong st_nlink;
  1675. unsigned int st_mode;
  1676. unsigned int st_uid;
  1677. unsigned int st_gid;
  1678. unsigned int __pad1;
  1679. abi_ulong st_rdev;
  1680. abi_ulong st_size;
  1681. abi_ulong target_st_atime;
  1682. abi_ulong target_st_atime_nsec;
  1683. abi_ulong target_st_mtime;
  1684. abi_ulong target_st_mtime_nsec;
  1685. abi_ulong target_st_ctime;
  1686. abi_ulong target_st_ctime_nsec;
  1687. abi_ulong st_blksize;
  1688. abi_long st_blocks;
  1689. abi_ulong __unused[3];
  1690. };
  1691. #elif defined(TARGET_AARCH64)
  1692. #define TARGET_STAT_HAVE_NSEC
  1693. struct target_stat {
  1694. abi_ulong st_dev;
  1695. abi_ulong st_ino;
  1696. unsigned int st_mode;
  1697. unsigned int st_nlink;
  1698. unsigned int st_uid;
  1699. unsigned int st_gid;
  1700. abi_ulong st_rdev;
  1701. abi_ulong _pad1;
  1702. abi_long st_size;
  1703. int st_blksize;
  1704. int __pad2;
  1705. abi_long st_blocks;
  1706. abi_long target_st_atime;
  1707. abi_ulong target_st_atime_nsec;
  1708. abi_long target_st_mtime;
  1709. abi_ulong target_st_mtime_nsec;
  1710. abi_long target_st_ctime;
  1711. abi_ulong target_st_ctime_nsec;
  1712. unsigned int __unused[2];
  1713. };
  1714. #elif defined(TARGET_XTENSA)
  1715. #define TARGET_STAT_HAVE_NSEC
  1716. struct target_stat {
  1717. abi_ulong st_dev;
  1718. abi_ulong st_ino;
  1719. unsigned int st_mode;
  1720. unsigned int st_nlink;
  1721. unsigned int st_uid;
  1722. unsigned int st_gid;
  1723. abi_ulong st_rdev;
  1724. abi_long st_size;
  1725. abi_ulong st_blksize;
  1726. abi_ulong st_blocks;
  1727. abi_ulong target_st_atime;
  1728. abi_ulong target_st_atime_nsec;
  1729. abi_ulong target_st_mtime;
  1730. abi_ulong target_st_mtime_nsec;
  1731. abi_ulong target_st_ctime;
  1732. abi_ulong target_st_ctime_nsec;
  1733. abi_ulong __unused4;
  1734. abi_ulong __unused5;
  1735. };
  1736. #define TARGET_HAS_STRUCT_STAT64
  1737. struct target_stat64 {
  1738. uint64_t st_dev; /* Device */
  1739. uint64_t st_ino; /* File serial number */
  1740. unsigned int st_mode; /* File mode. */
  1741. unsigned int st_nlink; /* Link count. */
  1742. unsigned int st_uid; /* User ID of the file's owner. */
  1743. unsigned int st_gid; /* Group ID of the file's group. */
  1744. uint64_t st_rdev; /* Device number, if device. */
  1745. int64_t st_size; /* Size of file, in bytes. */
  1746. abi_ulong st_blksize; /* Optimal block size for I/O. */
  1747. abi_ulong __unused2;
  1748. uint64_t st_blocks; /* Number 512-byte blocks allocated. */
  1749. abi_ulong target_st_atime; /* Time of last access. */
  1750. abi_ulong target_st_atime_nsec;
  1751. abi_ulong target_st_mtime; /* Time of last modification. */
  1752. abi_ulong target_st_mtime_nsec;
  1753. abi_ulong target_st_ctime; /* Time of last status change. */
  1754. abi_ulong target_st_ctime_nsec;
  1755. abi_ulong __unused4;
  1756. abi_ulong __unused5;
  1757. };
  1758. #elif defined(TARGET_OPENRISC) || defined(TARGET_TILEGX) || \
  1759. defined(TARGET_NIOS2) || defined(TARGET_RISCV)
  1760. /* These are the asm-generic versions of the stat and stat64 structures */
  1761. #define TARGET_STAT_HAVE_NSEC
  1762. struct target_stat {
  1763. abi_ulong st_dev;
  1764. abi_ulong st_ino;
  1765. unsigned int st_mode;
  1766. unsigned int st_nlink;
  1767. unsigned int st_uid;
  1768. unsigned int st_gid;
  1769. abi_ulong st_rdev;
  1770. abi_ulong __pad1;
  1771. abi_long st_size;
  1772. int st_blksize;
  1773. int __pad2;
  1774. abi_long st_blocks;
  1775. abi_long target_st_atime;
  1776. abi_ulong target_st_atime_nsec;
  1777. abi_long target_st_mtime;
  1778. abi_ulong target_st_mtime_nsec;
  1779. abi_long target_st_ctime;
  1780. abi_ulong target_st_ctime_nsec;
  1781. unsigned int __unused4;
  1782. unsigned int __unused5;
  1783. };
  1784. #if !defined(TARGET_RISCV64)
  1785. #define TARGET_HAS_STRUCT_STAT64
  1786. struct target_stat64 {
  1787. uint64_t st_dev;
  1788. uint64_t st_ino;
  1789. unsigned int st_mode;
  1790. unsigned int st_nlink;
  1791. unsigned int st_uid;
  1792. unsigned int st_gid;
  1793. uint64_t st_rdev;
  1794. uint64_t __pad1;
  1795. int64_t st_size;
  1796. int st_blksize;
  1797. int __pad2;
  1798. int64_t st_blocks;
  1799. int target_st_atime;
  1800. unsigned int target_st_atime_nsec;
  1801. int target_st_mtime;
  1802. unsigned int target_st_mtime_nsec;
  1803. int target_st_ctime;
  1804. unsigned int target_st_ctime_nsec;
  1805. unsigned int __unused4;
  1806. unsigned int __unused5;
  1807. };
  1808. #endif
  1809. #elif defined(TARGET_HPPA)
  1810. #define TARGET_STAT_HAVE_NSEC
  1811. struct target_stat {
  1812. abi_uint st_dev;
  1813. abi_uint st_ino;
  1814. abi_ushort st_mode;
  1815. abi_ushort st_nlink;
  1816. abi_ushort _res1;
  1817. abi_ushort _res2;
  1818. abi_uint st_rdev;
  1819. abi_int st_size;
  1820. abi_int target_st_atime;
  1821. abi_uint target_st_atime_nsec;
  1822. abi_int target_st_mtime;
  1823. abi_uint target_st_mtime_nsec;
  1824. abi_int target_st_ctime;
  1825. abi_uint target_st_ctime_nsec;
  1826. abi_int st_blksize;
  1827. abi_int st_blocks;
  1828. abi_uint _unused1;
  1829. abi_uint _unused2;
  1830. abi_uint _unused3;
  1831. abi_uint _unused4;
  1832. abi_ushort _unused5;
  1833. abi_short st_fstype;
  1834. abi_uint st_realdev;
  1835. abi_ushort st_basemode;
  1836. abi_ushort _unused6;
  1837. abi_uint st_uid;
  1838. abi_uint st_gid;
  1839. abi_uint _unused7[3];
  1840. };
  1841. #define TARGET_HAS_STRUCT_STAT64
  1842. struct target_stat64 {
  1843. uint64_t st_dev;
  1844. abi_uint _pad1;
  1845. abi_uint _res1;
  1846. abi_uint st_mode;
  1847. abi_uint st_nlink;
  1848. abi_uint st_uid;
  1849. abi_uint st_gid;
  1850. uint64_t st_rdev;
  1851. abi_uint _pad2;
  1852. int64_t st_size;
  1853. abi_int st_blksize;
  1854. int64_t st_blocks;
  1855. abi_int target_st_atime;
  1856. abi_uint target_st_atime_nsec;
  1857. abi_int target_st_mtime;
  1858. abi_uint target_st_mtime_nsec;
  1859. abi_int target_st_ctime;
  1860. abi_uint target_st_ctime_nsec;
  1861. uint64_t st_ino;
  1862. };
  1863. #else
  1864. #error unsupported CPU
  1865. #endif
  1866. typedef struct {
  1867. int val[2];
  1868. } target_fsid_t;
  1869. #ifdef TARGET_MIPS
  1870. #ifdef TARGET_ABI_MIPSN32
  1871. struct target_statfs {
  1872. int32_t f_type;
  1873. int32_t f_bsize;
  1874. int32_t f_frsize; /* Fragment size - unsupported */
  1875. int32_t f_blocks;
  1876. int32_t f_bfree;
  1877. int32_t f_files;
  1878. int32_t f_ffree;
  1879. int32_t f_bavail;
  1880. /* Linux specials */
  1881. target_fsid_t f_fsid;
  1882. int32_t f_namelen;
  1883. int32_t f_flags;
  1884. int32_t f_spare[5];
  1885. };
  1886. #else
  1887. struct target_statfs {
  1888. abi_long f_type;
  1889. abi_long f_bsize;
  1890. abi_long f_frsize; /* Fragment size - unsupported */
  1891. abi_long f_blocks;
  1892. abi_long f_bfree;
  1893. abi_long f_files;
  1894. abi_long f_ffree;
  1895. abi_long f_bavail;
  1896. /* Linux specials */
  1897. target_fsid_t f_fsid;
  1898. abi_long f_namelen;
  1899. abi_long f_flags;
  1900. abi_long f_spare[5];
  1901. };
  1902. #endif
  1903. struct target_statfs64 {
  1904. uint32_t f_type;
  1905. uint32_t f_bsize;
  1906. uint32_t f_frsize; /* Fragment size - unsupported */
  1907. uint32_t __pad;
  1908. uint64_t f_blocks;
  1909. uint64_t f_bfree;
  1910. uint64_t f_files;
  1911. uint64_t f_ffree;
  1912. uint64_t f_bavail;
  1913. target_fsid_t f_fsid;
  1914. uint32_t f_namelen;
  1915. uint32_t f_flags;
  1916. uint32_t f_spare[5];
  1917. };
  1918. #elif (defined(TARGET_PPC64) || defined(TARGET_X86_64) || \
  1919. defined(TARGET_SPARC64) || defined(TARGET_AARCH64) || \
  1920. defined(TARGET_RISCV)) && !defined(TARGET_ABI32)
  1921. struct target_statfs {
  1922. abi_long f_type;
  1923. abi_long f_bsize;
  1924. abi_long f_blocks;
  1925. abi_long f_bfree;
  1926. abi_long f_bavail;
  1927. abi_long f_files;
  1928. abi_long f_ffree;
  1929. target_fsid_t f_fsid;
  1930. abi_long f_namelen;
  1931. abi_long f_frsize;
  1932. abi_long f_flags;
  1933. abi_long f_spare[4];
  1934. };
  1935. struct target_statfs64 {
  1936. abi_long f_type;
  1937. abi_long f_bsize;
  1938. abi_long f_blocks;
  1939. abi_long f_bfree;
  1940. abi_long f_bavail;
  1941. abi_long f_files;
  1942. abi_long f_ffree;
  1943. target_fsid_t f_fsid;
  1944. abi_long f_namelen;
  1945. abi_long f_frsize;
  1946. abi_long f_flags;
  1947. abi_long f_spare[4];
  1948. };
  1949. #elif defined(TARGET_S390X)
  1950. struct target_statfs {
  1951. int32_t f_type;
  1952. int32_t f_bsize;
  1953. abi_long f_blocks;
  1954. abi_long f_bfree;
  1955. abi_long f_bavail;
  1956. abi_long f_files;
  1957. abi_long f_ffree;
  1958. kernel_fsid_t f_fsid;
  1959. int32_t f_namelen;
  1960. int32_t f_frsize;
  1961. int32_t f_flags;
  1962. int32_t f_spare[4];
  1963. };
  1964. struct target_statfs64 {
  1965. int32_t f_type;
  1966. int32_t f_bsize;
  1967. abi_long f_blocks;
  1968. abi_long f_bfree;
  1969. abi_long f_bavail;
  1970. abi_long f_files;
  1971. abi_long f_ffree;
  1972. kernel_fsid_t f_fsid;
  1973. int32_t f_namelen;
  1974. int32_t f_frsize;
  1975. int32_t f_flags;
  1976. int32_t f_spare[4];
  1977. };
  1978. #else
  1979. struct target_statfs {
  1980. uint32_t f_type;
  1981. uint32_t f_bsize;
  1982. uint32_t f_blocks;
  1983. uint32_t f_bfree;
  1984. uint32_t f_bavail;
  1985. uint32_t f_files;
  1986. uint32_t f_ffree;
  1987. target_fsid_t f_fsid;
  1988. uint32_t f_namelen;
  1989. uint32_t f_frsize;
  1990. uint32_t f_flags;
  1991. uint32_t f_spare[4];
  1992. };
  1993. struct target_statfs64 {
  1994. uint32_t f_type;
  1995. uint32_t f_bsize;
  1996. uint64_t f_blocks;
  1997. uint64_t f_bfree;
  1998. uint64_t f_bavail;
  1999. uint64_t f_files;
  2000. uint64_t f_ffree;
  2001. target_fsid_t f_fsid;
  2002. uint32_t f_namelen;
  2003. uint32_t f_frsize;
  2004. uint32_t f_flags;
  2005. uint32_t f_spare[4];
  2006. };
  2007. #endif
  2008. #define TARGET_F_LINUX_SPECIFIC_BASE 1024
  2009. #define TARGET_F_SETLEASE (TARGET_F_LINUX_SPECIFIC_BASE + 0)
  2010. #define TARGET_F_GETLEASE (TARGET_F_LINUX_SPECIFIC_BASE + 1)
  2011. #define TARGET_F_DUPFD_CLOEXEC (TARGET_F_LINUX_SPECIFIC_BASE + 6)
  2012. #define TARGET_F_SETPIPE_SZ (TARGET_F_LINUX_SPECIFIC_BASE + 7)
  2013. #define TARGET_F_GETPIPE_SZ (TARGET_F_LINUX_SPECIFIC_BASE + 8)
  2014. #define TARGET_F_NOTIFY (TARGET_F_LINUX_SPECIFIC_BASE+2)
  2015. #include "target_fcntl.h"
  2016. /* soundcard defines */
  2017. /* XXX: convert them all to arch independent entries */
  2018. #define TARGET_SNDCTL_COPR_HALT TARGET_IOWR('C', 7, int);
  2019. #define TARGET_SNDCTL_COPR_LOAD 0xcfb04301
  2020. #define TARGET_SNDCTL_COPR_RCODE 0xc0144303
  2021. #define TARGET_SNDCTL_COPR_RCVMSG 0x8fa44309
  2022. #define TARGET_SNDCTL_COPR_RDATA 0xc0144302
  2023. #define TARGET_SNDCTL_COPR_RESET 0x00004300
  2024. #define TARGET_SNDCTL_COPR_RUN 0xc0144306
  2025. #define TARGET_SNDCTL_COPR_SENDMSG 0xcfa44308
  2026. #define TARGET_SNDCTL_COPR_WCODE 0x40144305
  2027. #define TARGET_SNDCTL_COPR_WDATA 0x40144304
  2028. #define TARGET_SNDCTL_DSP_RESET TARGET_IO('P', 0)
  2029. #define TARGET_SNDCTL_DSP_SYNC TARGET_IO('P', 1)
  2030. #define TARGET_SNDCTL_DSP_SPEED TARGET_IOWR('P', 2, int)
  2031. #define TARGET_SNDCTL_DSP_STEREO TARGET_IOWR('P', 3, int)
  2032. #define TARGET_SNDCTL_DSP_GETBLKSIZE TARGET_IOWR('P', 4, int)
  2033. #define TARGET_SNDCTL_DSP_SETFMT TARGET_IOWR('P', 5, int)
  2034. #define TARGET_SNDCTL_DSP_CHANNELS TARGET_IOWR('P', 6, int)
  2035. #define TARGET_SOUND_PCM_WRITE_FILTER TARGET_IOWR('P', 7, int)
  2036. #define TARGET_SNDCTL_DSP_POST TARGET_IO('P', 8)
  2037. #define TARGET_SNDCTL_DSP_SUBDIVIDE TARGET_IOWR('P', 9, int)
  2038. #define TARGET_SNDCTL_DSP_SETFRAGMENT TARGET_IOWR('P',10, int)
  2039. #define TARGET_SNDCTL_DSP_GETFMTS TARGET_IOR('P', 11, int)
  2040. #define TARGET_SNDCTL_DSP_GETOSPACE TARGET_IORU('P',12)
  2041. #define TARGET_SNDCTL_DSP_GETISPACE TARGET_IORU('P',13)
  2042. #define TARGET_SNDCTL_DSP_GETCAPS TARGET_IOR('P', 15, int)
  2043. #define TARGET_SNDCTL_DSP_GETTRIGGER TARGET_IOR('P',16, int)
  2044. #define TARGET_SNDCTL_DSP_GETIPTR TARGET_IORU('P',17)
  2045. #define TARGET_SNDCTL_DSP_GETOPTR TARGET_IORU('P',18)
  2046. #define TARGET_SNDCTL_DSP_MAPINBUF TARGET_IORU('P', 19)
  2047. #define TARGET_SNDCTL_DSP_MAPOUTBUF TARGET_IORU('P', 20)
  2048. #define TARGET_SNDCTL_DSP_NONBLOCK 0x0000500e
  2049. #define TARGET_SNDCTL_DSP_SAMPLESIZE 0xc0045005
  2050. #define TARGET_SNDCTL_DSP_SETDUPLEX 0x00005016
  2051. #define TARGET_SNDCTL_DSP_SETSYNCRO 0x00005015
  2052. #define TARGET_SNDCTL_DSP_SETTRIGGER 0x40045010
  2053. #define TARGET_SNDCTL_FM_4OP_ENABLE 0x4004510f
  2054. #define TARGET_SNDCTL_FM_LOAD_INSTR 0x40285107
  2055. #define TARGET_SNDCTL_MIDI_INFO 0xc074510c
  2056. #define TARGET_SNDCTL_MIDI_MPUCMD 0xc0216d02
  2057. #define TARGET_SNDCTL_MIDI_MPUMODE 0xc0046d01
  2058. #define TARGET_SNDCTL_MIDI_PRETIME 0xc0046d00
  2059. #define TARGET_SNDCTL_PMGR_ACCESS 0xcfb85110
  2060. #define TARGET_SNDCTL_PMGR_IFACE 0xcfb85001
  2061. #define TARGET_SNDCTL_SEQ_CTRLRATE 0xc0045103
  2062. #define TARGET_SNDCTL_SEQ_GETINCOUNT 0x80045105
  2063. #define TARGET_SNDCTL_SEQ_GETOUTCOUNT 0x80045104
  2064. #define TARGET_SNDCTL_SEQ_NRMIDIS 0x8004510b
  2065. #define TARGET_SNDCTL_SEQ_NRSYNTHS 0x8004510a
  2066. #define TARGET_SNDCTL_SEQ_OUTOFBAND 0x40085112
  2067. #define TARGET_SNDCTL_SEQ_PANIC 0x00005111
  2068. #define TARGET_SNDCTL_SEQ_PERCMODE 0x40045106
  2069. #define TARGET_SNDCTL_SEQ_RESET 0x00005100
  2070. #define TARGET_SNDCTL_SEQ_RESETSAMPLES 0x40045109
  2071. #define TARGET_SNDCTL_SEQ_SYNC 0x00005101
  2072. #define TARGET_SNDCTL_SEQ_TESTMIDI 0x40045108
  2073. #define TARGET_SNDCTL_SEQ_THRESHOLD 0x4004510d
  2074. #define TARGET_SNDCTL_SEQ_TRESHOLD 0x4004510d
  2075. #define TARGET_SNDCTL_SYNTH_INFO 0xc08c5102
  2076. #define TARGET_SNDCTL_SYNTH_MEMAVL 0xc004510e
  2077. #define TARGET_SNDCTL_TMR_CONTINUE 0x00005404
  2078. #define TARGET_SNDCTL_TMR_METRONOME 0x40045407
  2079. #define TARGET_SNDCTL_TMR_SELECT 0x40045408
  2080. #define TARGET_SNDCTL_TMR_SOURCE 0xc0045406
  2081. #define TARGET_SNDCTL_TMR_START 0x00005402
  2082. #define TARGET_SNDCTL_TMR_STOP 0x00005403
  2083. #define TARGET_SNDCTL_TMR_TEMPO 0xc0045405
  2084. #define TARGET_SNDCTL_TMR_TIMEBASE 0xc0045401
  2085. #define TARGET_SOUND_PCM_READ_RATE 0x80045002
  2086. #define TARGET_SOUND_PCM_READ_CHANNELS 0x80045006
  2087. #define TARGET_SOUND_PCM_READ_BITS 0x80045005
  2088. #define TARGET_SOUND_PCM_READ_FILTER 0x80045007
  2089. #define TARGET_SOUND_MIXER_INFO TARGET_IOR ('M', 101, mixer_info)
  2090. #define TARGET_SOUND_MIXER_ACCESS 0xc0804d66
  2091. #define TARGET_SOUND_MIXER_PRIVATE1 TARGET_IOWR('M', 111, int)
  2092. #define TARGET_SOUND_MIXER_PRIVATE2 TARGET_IOWR('M', 112, int)
  2093. #define TARGET_SOUND_MIXER_PRIVATE3 TARGET_IOWR('M', 113, int)
  2094. #define TARGET_SOUND_MIXER_PRIVATE4 TARGET_IOWR('M', 114, int)
  2095. #define TARGET_SOUND_MIXER_PRIVATE5 TARGET_IOWR('M', 115, int)
  2096. #define TARGET_MIXER_READ(dev) TARGET_IOR('M', dev, int)
  2097. #define TARGET_SOUND_MIXER_READ_VOLUME TARGET_MIXER_READ(SOUND_MIXER_VOLUME)
  2098. #define TARGET_SOUND_MIXER_READ_BASS TARGET_MIXER_READ(SOUND_MIXER_BASS)
  2099. #define TARGET_SOUND_MIXER_READ_TREBLE TARGET_MIXER_READ(SOUND_MIXER_TREBLE)
  2100. #define TARGET_SOUND_MIXER_READ_SYNTH TARGET_MIXER_READ(SOUND_MIXER_SYNTH)
  2101. #define TARGET_SOUND_MIXER_READ_PCM TARGET_MIXER_READ(SOUND_MIXER_PCM)
  2102. #define TARGET_SOUND_MIXER_READ_SPEAKER TARGET_MIXER_READ(SOUND_MIXER_SPEAKER)
  2103. #define TARGET_SOUND_MIXER_READ_LINE TARGET_MIXER_READ(SOUND_MIXER_LINE)
  2104. #define TARGET_SOUND_MIXER_READ_MIC TARGET_MIXER_READ(SOUND_MIXER_MIC)
  2105. #define TARGET_SOUND_MIXER_READ_CD TARGET_MIXER_READ(SOUND_MIXER_CD)
  2106. #define TARGET_SOUND_MIXER_READ_IMIX TARGET_MIXER_READ(SOUND_MIXER_IMIX)
  2107. #define TARGET_SOUND_MIXER_READ_ALTPCM TARGET_MIXER_READ(SOUND_MIXER_ALTPCM)
  2108. #define TARGET_SOUND_MIXER_READ_RECLEV TARGET_MIXER_READ(SOUND_MIXER_RECLEV)
  2109. #define TARGET_SOUND_MIXER_READ_IGAIN TARGET_MIXER_READ(SOUND_MIXER_IGAIN)
  2110. #define TARGET_SOUND_MIXER_READ_OGAIN TARGET_MIXER_READ(SOUND_MIXER_OGAIN)
  2111. #define TARGET_SOUND_MIXER_READ_LINE1 TARGET_MIXER_READ(SOUND_MIXER_LINE1)
  2112. #define TARGET_SOUND_MIXER_READ_LINE2 TARGET_MIXER_READ(SOUND_MIXER_LINE2)
  2113. #define TARGET_SOUND_MIXER_READ_LINE3 TARGET_MIXER_READ(SOUND_MIXER_LINE3)
  2114. /* Obsolete macros */
  2115. #define TARGET_SOUND_MIXER_READ_MUTE TARGET_MIXER_READ(SOUND_MIXER_MUTE)
  2116. #define TARGET_SOUND_MIXER_READ_ENHANCE TARGET_MIXER_READ(SOUND_MIXER_ENHANCE)
  2117. #define TARGET_SOUND_MIXER_READ_LOUD TARGET_MIXER_READ(SOUND_MIXER_LOUD)
  2118. #define TARGET_SOUND_MIXER_READ_RECSRC TARGET_MIXER_READ(SOUND_MIXER_RECSRC)
  2119. #define TARGET_SOUND_MIXER_READ_DEVMASK TARGET_MIXER_READ(SOUND_MIXER_DEVMASK)
  2120. #define TARGET_SOUND_MIXER_READ_RECMASK TARGET_MIXER_READ(SOUND_MIXER_RECMASK)
  2121. #define TARGET_SOUND_MIXER_READ_STEREODEVS TARGET_MIXER_READ(SOUND_MIXER_STEREODEVS)
  2122. #define TARGET_SOUND_MIXER_READ_CAPS TARGET_MIXER_READ(SOUND_MIXER_CAPS)
  2123. #define TARGET_MIXER_WRITE(dev) TARGET_IOWR('M', dev, int)
  2124. #define TARGET_SOUND_MIXER_WRITE_VOLUME TARGET_MIXER_WRITE(SOUND_MIXER_VOLUME)
  2125. #define TARGET_SOUND_MIXER_WRITE_BASS TARGET_MIXER_WRITE(SOUND_MIXER_BASS)
  2126. #define TARGET_SOUND_MIXER_WRITE_TREBLE TARGET_MIXER_WRITE(SOUND_MIXER_TREBLE)
  2127. #define TARGET_SOUND_MIXER_WRITE_SYNTH TARGET_MIXER_WRITE(SOUND_MIXER_SYNTH)
  2128. #define TARGET_SOUND_MIXER_WRITE_PCM TARGET_MIXER_WRITE(SOUND_MIXER_PCM)
  2129. #define TARGET_SOUND_MIXER_WRITE_SPEAKER TARGET_MIXER_WRITE(SOUND_MIXER_SPEAKER)
  2130. #define TARGET_SOUND_MIXER_WRITE_LINE TARGET_MIXER_WRITE(SOUND_MIXER_LINE)
  2131. #define TARGET_SOUND_MIXER_WRITE_MIC TARGET_MIXER_WRITE(SOUND_MIXER_MIC)
  2132. #define TARGET_SOUND_MIXER_WRITE_CD TARGET_MIXER_WRITE(SOUND_MIXER_CD)
  2133. #define TARGET_SOUND_MIXER_WRITE_IMIX TARGET_MIXER_WRITE(SOUND_MIXER_IMIX)
  2134. #define TARGET_SOUND_MIXER_WRITE_ALTPCM TARGET_MIXER_WRITE(SOUND_MIXER_ALTPCM)
  2135. #define TARGET_SOUND_MIXER_WRITE_RECLEV TARGET_MIXER_WRITE(SOUND_MIXER_RECLEV)
  2136. #define TARGET_SOUND_MIXER_WRITE_IGAIN TARGET_MIXER_WRITE(SOUND_MIXER_IGAIN)
  2137. #define TARGET_SOUND_MIXER_WRITE_OGAIN TARGET_MIXER_WRITE(SOUND_MIXER_OGAIN)
  2138. #define TARGET_SOUND_MIXER_WRITE_LINE1 TARGET_MIXER_WRITE(SOUND_MIXER_LINE1)
  2139. #define TARGET_SOUND_MIXER_WRITE_LINE2 TARGET_MIXER_WRITE(SOUND_MIXER_LINE2)
  2140. #define TARGET_SOUND_MIXER_WRITE_LINE3 TARGET_MIXER_WRITE(SOUND_MIXER_LINE3)
  2141. /* Obsolete macros */
  2142. #define TARGET_SOUND_MIXER_WRITE_MUTE TARGET_MIXER_WRITE(SOUND_MIXER_MUTE)
  2143. #define TARGET_SOUND_MIXER_WRITE_ENHANCE TARGET_MIXER_WRITE(SOUND_MIXER_ENHANCE)
  2144. #define TARGET_SOUND_MIXER_WRITE_LOUD TARGET_MIXER_WRITE(SOUND_MIXER_LOUD)
  2145. #define TARGET_SOUND_MIXER_WRITE_RECSRC TARGET_MIXER_WRITE(SOUND_MIXER_RECSRC)
  2146. struct target_snd_timer_id {
  2147. int dev_class;
  2148. int dev_sclass;
  2149. int card;
  2150. int device;
  2151. int subdevice;
  2152. };
  2153. struct target_snd_timer_ginfo {
  2154. struct target_snd_timer_id tid;
  2155. unsigned int flags;
  2156. int card;
  2157. unsigned char id[64];
  2158. unsigned char name[80];
  2159. abi_ulong reserved0;
  2160. abi_ulong resolution;
  2161. abi_ulong resolution_min;
  2162. abi_ulong resolution_max;
  2163. unsigned int clients;
  2164. unsigned char reserved[32];
  2165. };
  2166. struct target_snd_timer_gparams {
  2167. struct target_snd_timer_id tid;
  2168. abi_ulong period_num;
  2169. abi_ulong period_den;
  2170. unsigned char reserved[32];
  2171. };
  2172. struct target_snd_timer_gstatus {
  2173. struct target_snd_timer_id tid;
  2174. abi_ulong resolution;
  2175. abi_ulong resolution_num;
  2176. abi_ulong resolution_den;
  2177. unsigned char reserved[32];
  2178. };
  2179. struct target_snd_timer_select {
  2180. struct target_snd_timer_id id;
  2181. unsigned char reserved[32];
  2182. };
  2183. struct target_snd_timer_info {
  2184. unsigned int flags;
  2185. int card;
  2186. unsigned char id[64];
  2187. unsigned char name[80];
  2188. abi_ulong reserved0;
  2189. abi_ulong resolution;
  2190. unsigned char reserved[64];
  2191. };
  2192. struct target_snd_timer_status {
  2193. struct target_timespec tstamp;
  2194. unsigned int resolution;
  2195. unsigned int lost;
  2196. unsigned int overrun;
  2197. unsigned int queue;
  2198. unsigned char reserved[64];
  2199. };
  2200. /* alsa timer ioctls */
  2201. #define TARGET_SNDRV_TIMER_IOCTL_PVERSION TARGET_IOR('T', 0x00, int)
  2202. #define TARGET_SNDRV_TIMER_IOCTL_NEXT_DEVICE TARGET_IOWR('T', 0x01, \
  2203. struct snd_timer_id)
  2204. #define TARGET_SNDRV_TIMER_IOCTL_GINFO TARGET_IOWR('T', 0x03, \
  2205. struct target_snd_timer_ginfo)
  2206. #define TARGET_SNDRV_TIMER_IOCTL_GPARAMS TARGET_IOW('T', 0x04, \
  2207. struct target_snd_timer_gparams)
  2208. #define TARGET_SNDRV_TIMER_IOCTL_GSTATUS TARGET_IOWR('T', 0x05, \
  2209. struct target_snd_timer_gstatus)
  2210. #define TARGET_SNDRV_TIMER_IOCTL_SELECT TARGET_IOW('T', 0x10, \
  2211. struct target_snd_timer_select)
  2212. #define TARGET_SNDRV_TIMER_IOCTL_INFO TARGET_IOR('T', 0x11, \
  2213. struct target_snd_timer_info)
  2214. #define TARGET_SNDRV_TIMER_IOCTL_PARAMS TARGET_IOW('T', 0x12, \
  2215. struct snd_timer_params)
  2216. #define TARGET_SNDRV_TIMER_IOCTL_STATUS TARGET_IOR('T', 0x14, \
  2217. struct target_snd_timer_status)
  2218. #define TARGET_SNDRV_TIMER_IOCTL_START TARGET_IO('T', 0xa0)
  2219. #define TARGET_SNDRV_TIMER_IOCTL_STOP TARGET_IO('T', 0xa1)
  2220. #define TARGET_SNDRV_TIMER_IOCTL_CONTINUE TARGET_IO('T', 0xa2)
  2221. #define TARGET_SNDRV_TIMER_IOCTL_PAUSE TARGET_IO('T', 0xa3)
  2222. /* vfat ioctls */
  2223. #define TARGET_VFAT_IOCTL_READDIR_BOTH TARGET_IORU('r', 1)
  2224. #define TARGET_VFAT_IOCTL_READDIR_SHORT TARGET_IORU('r', 2)
  2225. struct target_mtop {
  2226. abi_short mt_op;
  2227. abi_int mt_count;
  2228. };
  2229. #if defined(TARGET_SPARC) || defined(TARGET_MIPS)
  2230. typedef abi_long target_kernel_daddr_t;
  2231. #else
  2232. typedef abi_int target_kernel_daddr_t;
  2233. #endif
  2234. struct target_mtget {
  2235. abi_long mt_type;
  2236. abi_long mt_resid;
  2237. abi_long mt_dsreg;
  2238. abi_long mt_gstat;
  2239. abi_long mt_erreg;
  2240. target_kernel_daddr_t mt_fileno;
  2241. target_kernel_daddr_t mt_blkno;
  2242. };
  2243. struct target_mtpos {
  2244. abi_long mt_blkno;
  2245. };
  2246. #define TARGET_MTIOCTOP TARGET_IOW('m', 1, struct target_mtop)
  2247. #define TARGET_MTIOCGET TARGET_IOR('m', 2, struct target_mtget)
  2248. #define TARGET_MTIOCPOS TARGET_IOR('m', 3, struct target_mtpos)
  2249. /* kcov ioctls */
  2250. #define TARGET_KCOV_ENABLE TARGET_IO('c', 100)
  2251. #define TARGET_KCOV_DISABLE TARGET_IO('c', 101)
  2252. #define TARGET_KCOV_INIT_TRACE TARGET_IOR('c', 1, abi_ulong)
  2253. struct target_sysinfo {
  2254. abi_long uptime; /* Seconds since boot */
  2255. abi_ulong loads[3]; /* 1, 5, and 15 minute load averages */
  2256. abi_ulong totalram; /* Total usable main memory size */
  2257. abi_ulong freeram; /* Available memory size */
  2258. abi_ulong sharedram; /* Amount of shared memory */
  2259. abi_ulong bufferram; /* Memory used by buffers */
  2260. abi_ulong totalswap; /* Total swap space size */
  2261. abi_ulong freeswap; /* swap space still available */
  2262. unsigned short procs; /* Number of current processes */
  2263. unsigned short pad; /* explicit padding for m68k */
  2264. abi_ulong totalhigh; /* Total high memory size */
  2265. abi_ulong freehigh; /* Available high memory size */
  2266. unsigned int mem_unit; /* Memory unit size in bytes */
  2267. char _f[20-2*sizeof(abi_long)-sizeof(int)]; /* Padding: libc5 uses this.. */
  2268. };
  2269. struct linux_dirent {
  2270. long d_ino;
  2271. unsigned long d_off;
  2272. unsigned short d_reclen;
  2273. char d_name[256]; /* We must not include limits.h! */
  2274. };
  2275. struct linux_dirent64 {
  2276. uint64_t d_ino;
  2277. int64_t d_off;
  2278. unsigned short d_reclen;
  2279. unsigned char d_type;
  2280. char d_name[256];
  2281. };
  2282. struct target_mq_attr {
  2283. abi_long mq_flags;
  2284. abi_long mq_maxmsg;
  2285. abi_long mq_msgsize;
  2286. abi_long mq_curmsgs;
  2287. };
  2288. struct target_drm_version {
  2289. int version_major;
  2290. int version_minor;
  2291. int version_patchlevel;
  2292. abi_ulong name_len;
  2293. abi_ulong name;
  2294. abi_ulong date_len;
  2295. abi_ulong date;
  2296. abi_ulong desc_len;
  2297. abi_ulong desc;
  2298. };
  2299. #include "socket.h"
  2300. #include "errno_defs.h"
  2301. #define FUTEX_WAIT 0
  2302. #define FUTEX_WAKE 1
  2303. #define FUTEX_FD 2
  2304. #define FUTEX_REQUEUE 3
  2305. #define FUTEX_CMP_REQUEUE 4
  2306. #define FUTEX_WAKE_OP 5
  2307. #define FUTEX_LOCK_PI 6
  2308. #define FUTEX_UNLOCK_PI 7
  2309. #define FUTEX_TRYLOCK_PI 8
  2310. #define FUTEX_WAIT_BITSET 9
  2311. #define FUTEX_WAKE_BITSET 10
  2312. #define FUTEX_PRIVATE_FLAG 128
  2313. #define FUTEX_CLOCK_REALTIME 256
  2314. #define FUTEX_CMD_MASK ~(FUTEX_PRIVATE_FLAG | FUTEX_CLOCK_REALTIME)
  2315. #ifdef CONFIG_EPOLL
  2316. #if defined(TARGET_X86_64)
  2317. #define TARGET_EPOLL_PACKED QEMU_PACKED
  2318. #else
  2319. #define TARGET_EPOLL_PACKED
  2320. #endif
  2321. typedef union target_epoll_data {
  2322. abi_ulong ptr;
  2323. abi_int fd;
  2324. abi_uint u32;
  2325. abi_ullong u64;
  2326. } target_epoll_data_t;
  2327. struct target_epoll_event {
  2328. abi_uint events;
  2329. target_epoll_data_t data;
  2330. } TARGET_EPOLL_PACKED;
  2331. #define TARGET_EP_MAX_EVENTS (INT_MAX / sizeof(struct target_epoll_event))
  2332. #endif
  2333. struct target_rlimit64 {
  2334. uint64_t rlim_cur;
  2335. uint64_t rlim_max;
  2336. };
  2337. struct target_ucred {
  2338. uint32_t pid;
  2339. uint32_t uid;
  2340. uint32_t gid;
  2341. };
  2342. typedef int32_t target_timer_t;
  2343. #define TARGET_SIGEV_MAX_SIZE 64
  2344. /* This is architecture-specific but most architectures use the default */
  2345. #ifdef TARGET_MIPS
  2346. #define TARGET_SIGEV_PREAMBLE_SIZE (sizeof(int32_t) * 2 + sizeof(abi_long))
  2347. #else
  2348. #define TARGET_SIGEV_PREAMBLE_SIZE (sizeof(int32_t) * 2 \
  2349. + sizeof(target_sigval_t))
  2350. #endif
  2351. #define TARGET_SIGEV_PAD_SIZE ((TARGET_SIGEV_MAX_SIZE \
  2352. - TARGET_SIGEV_PREAMBLE_SIZE) \
  2353. / sizeof(int32_t))
  2354. struct target_sigevent {
  2355. target_sigval_t sigev_value;
  2356. abi_int sigev_signo;
  2357. abi_int sigev_notify;
  2358. union {
  2359. abi_int _pad[TARGET_SIGEV_PAD_SIZE];
  2360. abi_int _tid;
  2361. /* The kernel (and thus QEMU) never looks at these;
  2362. * they're only used as part of the ABI between a
  2363. * userspace program and libc.
  2364. */
  2365. struct {
  2366. abi_ulong _function;
  2367. abi_ulong _attribute;
  2368. } _sigev_thread;
  2369. } _sigev_un;
  2370. };
  2371. struct target_user_cap_header {
  2372. uint32_t version;
  2373. int pid;
  2374. };
  2375. struct target_user_cap_data {
  2376. uint32_t effective;
  2377. uint32_t permitted;
  2378. uint32_t inheritable;
  2379. };
  2380. /* from kernel's include/linux/syslog.h */
  2381. /* Close the log. Currently a NOP. */
  2382. #define TARGET_SYSLOG_ACTION_CLOSE 0
  2383. /* Open the log. Currently a NOP. */
  2384. #define TARGET_SYSLOG_ACTION_OPEN 1
  2385. /* Read from the log. */
  2386. #define TARGET_SYSLOG_ACTION_READ 2
  2387. /* Read all messages remaining in the ring buffer. */
  2388. #define TARGET_SYSLOG_ACTION_READ_ALL 3
  2389. /* Read and clear all messages remaining in the ring buffer */
  2390. #define TARGET_SYSLOG_ACTION_READ_CLEAR 4
  2391. /* Clear ring buffer. */
  2392. #define TARGET_SYSLOG_ACTION_CLEAR 5
  2393. /* Disable printk's to console */
  2394. #define TARGET_SYSLOG_ACTION_CONSOLE_OFF 6
  2395. /* Enable printk's to console */
  2396. #define TARGET_SYSLOG_ACTION_CONSOLE_ON 7
  2397. /* Set level of messages printed to console */
  2398. #define TARGET_SYSLOG_ACTION_CONSOLE_LEVEL 8
  2399. /* Return number of unread characters in the log buffer */
  2400. #define TARGET_SYSLOG_ACTION_SIZE_UNREAD 9
  2401. /* Return size of the log buffer */
  2402. #define TARGET_SYSLOG_ACTION_SIZE_BUFFER 10
  2403. struct target_statx_timestamp {
  2404. int64_t tv_sec;
  2405. uint32_t tv_nsec;
  2406. int32_t __reserved;
  2407. };
  2408. struct target_statx {
  2409. /* 0x00 */
  2410. uint32_t stx_mask; /* What results were written [uncond] */
  2411. uint32_t stx_blksize; /* Preferred general I/O size [uncond] */
  2412. uint64_t stx_attributes; /* Flags conveying information about the file */
  2413. /* 0x10 */
  2414. uint32_t stx_nlink; /* Number of hard links */
  2415. uint32_t stx_uid; /* User ID of owner */
  2416. uint32_t stx_gid; /* Group ID of owner */
  2417. uint16_t stx_mode; /* File mode */
  2418. uint16_t __spare0[1];
  2419. /* 0x20 */
  2420. uint64_t stx_ino; /* Inode number */
  2421. uint64_t stx_size; /* File size */
  2422. uint64_t stx_blocks; /* Number of 512-byte blocks allocated */
  2423. uint64_t stx_attributes_mask; /* Mask to show what is supported */
  2424. /* 0x40 */
  2425. struct target_statx_timestamp stx_atime; /* Last access time */
  2426. struct target_statx_timestamp stx_btime; /* File creation time */
  2427. struct target_statx_timestamp stx_ctime; /* Last attribute change time */
  2428. struct target_statx_timestamp stx_mtime; /* Last data modification time */
  2429. /* 0x80 */
  2430. uint32_t stx_rdev_major; /* Device ID of special file [if bdev/cdev] */
  2431. uint32_t stx_rdev_minor;
  2432. uint32_t stx_dev_major; /* ID of device containing file [uncond] */
  2433. uint32_t stx_dev_minor;
  2434. /* 0x90 */
  2435. uint64_t __spare2[14]; /* Spare space for future expansion */
  2436. /* 0x100 */
  2437. };
  2438. #endif