2
0

syscall_defs.h 97 KB

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