]> git.proxmox.com Git - qemu.git/blame - linux-user/syscall_defs.h
added vm86.c
[qemu.git] / linux-user / syscall_defs.h
CommitLineData
31e31b8a
FB
1
2/* common syscall defines for all architectures */
3
4#define SOCKOP_socket 1
5#define SOCKOP_bind 2
6#define SOCKOP_connect 3
7#define SOCKOP_listen 4
8#define SOCKOP_accept 5
9#define SOCKOP_getsockname 6
10#define SOCKOP_getpeername 7
11#define SOCKOP_socketpair 8
12#define SOCKOP_send 9
13#define SOCKOP_recv 10
14#define SOCKOP_sendto 11
15#define SOCKOP_recvfrom 12
16#define SOCKOP_shutdown 13
17#define SOCKOP_setsockopt 14
18#define SOCKOP_getsockopt 15
19#define SOCKOP_sendmsg 16
20#define SOCKOP_recvmsg 17
21
7854b056
FB
22struct target_sockaddr {
23 uint16_t sa_family;
24 uint8_t sa_data[14];
25};
26
31e31b8a
FB
27struct target_timeval {
28 target_long tv_sec;
29 target_long tv_usec;
30};
31
1b6b029e
FB
32struct target_timespec {
33 target_long tv_sec;
34 target_long tv_nsec;
35};
36
66fb9763
FB
37struct target_itimerval {
38 struct target_timeval it_interval;
39 struct target_timeval it_value;
40};
41
32f36bce
FB
42typedef target_long target_clock_t;
43
44struct target_tms {
45 target_clock_t tms_utime;
46 target_clock_t tms_stime;
47 target_clock_t tms_cutime;
48 target_clock_t tms_cstime;
49};
50
31e31b8a
FB
51struct target_iovec {
52 target_long iov_base; /* Starting address */
53 target_long iov_len; /* Number of bytes */
54};
55
1a9353d2
FB
56struct target_msghdr {
57 target_long msg_name; /* Socket name */
58 int msg_namelen; /* Length of name */
59 target_long msg_iov; /* Data blocks */
60 target_long msg_iovlen; /* Number of blocks */
61 target_long msg_control; /* Per protocol magic (eg BSD file descriptor passing) */
62 target_long msg_controllen; /* Length of cmsg list */
63 unsigned int msg_flags;
64};
65
7854b056
FB
66struct target_cmsghdr {
67 target_long cmsg_len;
68 int cmsg_level;
69 int cmsg_type;
70};
71
72#define TARGET_CMSG_DATA(cmsg) ((unsigned char *) ((struct target_cmsghdr *) (cmsg) + 1))
73#define TARGET_CMSG_NXTHDR(mhdr, cmsg) __target_cmsg_nxthdr (mhdr, cmsg)
74#define TARGET_CMSG_FIRSTHDR(mhdr) \
75 ((size_t) tswapl((mhdr)->msg_controllen) >= sizeof (struct target_cmsghdr) \
76 ? (struct target_cmsghdr *) tswapl((mhdr)->msg_control) : (struct target_cmsghdr *) NULL)
77#define TARGET_CMSG_ALIGN(len) (((len) + sizeof (target_long) - 1) \
78 & (size_t) ~(sizeof (target_long) - 1))
79#define TARGET_CMSG_SPACE(len) (TARGET_CMSG_ALIGN (len) \
80 + TARGET_CMSG_ALIGN (sizeof (struct target_cmsghdr)))
81#define TARGET_CMSG_LEN(len) (TARGET_CMSG_ALIGN (sizeof (struct target_cmsghdr)) + (len))
82
83static __inline__ struct target_cmsghdr *
84__target_cmsg_nxthdr (struct target_msghdr *__mhdr, struct target_cmsghdr *__cmsg)
85{
86 if (tswapl(__cmsg->cmsg_len) < sizeof (struct target_cmsghdr))
87 /* The kernel header does this so there may be a reason. */
88 return 0;
89
90 __cmsg = (struct target_cmsghdr *) ((unsigned char *) __cmsg
91 + TARGET_CMSG_ALIGN (tswapl(__cmsg->cmsg_len)));
92 if ((unsigned char *) (__cmsg + 1) > ((unsigned char *) tswapl(__mhdr->msg_control)
93 + tswapl(__mhdr->msg_controllen))
94 || ((unsigned char *) __cmsg + TARGET_CMSG_ALIGN (tswapl(__cmsg->cmsg_len))
95 > ((unsigned char *) tswapl(__mhdr->msg_control)
96 + tswapl(__mhdr->msg_controllen))))
97 /* No more entries. */
98 return 0;
99 return __cmsg;
100}
101
102
31e31b8a
FB
103struct target_rusage {
104 struct target_timeval ru_utime; /* user time used */
105 struct target_timeval ru_stime; /* system time used */
106 target_long ru_maxrss; /* maximum resident set size */
107 target_long ru_ixrss; /* integral shared memory size */
108 target_long ru_idrss; /* integral unshared data size */
109 target_long ru_isrss; /* integral unshared stack size */
110 target_long ru_minflt; /* page reclaims */
111 target_long ru_majflt; /* page faults */
112 target_long ru_nswap; /* swaps */
113 target_long ru_inblock; /* block input operations */
114 target_long ru_oublock; /* block output operations */
115 target_long ru_msgsnd; /* messages sent */
116 target_long ru_msgrcv; /* messages received */
117 target_long ru_nsignals; /* signals received */
118 target_long ru_nvcsw; /* voluntary context switches */
119 target_long ru_nivcsw; /* involuntary " */
120};
121
122typedef struct {
123 int val[2];
124} kernel_fsid_t;
125
72f03900 126struct kernel_statfs {
31e31b8a
FB
127 int f_type;
128 int f_bsize;
129 int f_blocks;
130 int f_bfree;
131 int f_bavail;
132 int f_files;
133 int f_ffree;
134 kernel_fsid_t f_fsid;
135 int f_namelen;
136 int f_spare[6];
137};
138
dab2ed99
FB
139struct target_dirent {
140 target_long d_ino;
141 target_long d_off;
142 unsigned short d_reclen;
143 char d_name[256]; /* We must not include limits.h! */
144};
145
146struct target_dirent64 {
147 uint64_t d_ino;
148 int64_t d_off;
149 unsigned short d_reclen;
150 unsigned char d_type;
151 char d_name[256];
152};
153
154
31e31b8a
FB
155/* mostly generic signal stuff */
156#define TARGET_SIG_DFL ((target_long)0) /* default signal handling */
157#define TARGET_SIG_IGN ((target_long)1) /* ignore signal */
158#define TARGET_SIG_ERR ((target_long)-1) /* error return from signal */
159
160#ifdef TARGET_MIPS
161#define TARGET_NSIG 128
162#else
163#define TARGET_NSIG 64
164#endif
165#define TARGET_NSIG_BPW TARGET_LONG_BITS
166#define TARGET_NSIG_WORDS (TARGET_NSIG / TARGET_NSIG_BPW)
167
168typedef struct {
169 target_ulong sig[TARGET_NSIG_WORDS];
170} target_sigset_t;
171
66fb9763
FB
172#ifdef BSWAP_NEEDED
173static inline void tswap_sigset(target_sigset_t *d, const target_sigset_t *s)
174{
175 int i;
176 for(i = 0;i < TARGET_NSIG_WORDS; i++)
177 d->sig[i] = tswapl(s->sig[i]);
178}
179#else
180static inline void tswap_sigset(target_sigset_t *d, const target_sigset_t *s)
181{
182 *d = *s;
183}
184#endif
185
186static inline void target_siginitset(target_sigset_t *d, target_ulong set)
187{
188 int i;
189 d->sig[0] = set;
190 for(i = 1;i < TARGET_NSIG_WORDS; i++)
191 d->sig[i] = 0;
192}
193
194void host_to_target_sigset(target_sigset_t *d, sigset_t *s);
195void target_to_host_sigset(sigset_t *d, target_sigset_t *s);
196void host_to_target_old_sigset(target_ulong *old_sigset,
197 const sigset_t *sigset);
198void target_to_host_old_sigset(sigset_t *sigset,
199 const target_ulong *old_sigset);
200struct target_sigaction;
201int do_sigaction(int sig, const struct target_sigaction *act,
202 struct target_sigaction *oact);
203
9de5e440
FB
204struct target_rlimit {
205 target_ulong rlim_cur;
206 target_ulong rlim_max;
207};
208
209struct target_pollfd {
210 int fd; /* file descriptor */
211 short events; /* requested events */
212 short revents; /* returned events */
213};
214
8e5a0667 215/* virtual terminal ioctls */
0221cfcd
FB
216#define TARGET_KIOCSOUND 0x4B2F /* start sound generation (0 for off) */
217#define TARGET_KDMKTONE 0x4B30 /* generate tone */
8e5a0667 218#define TARGET_KDGKBTYPE 0x4b33
0221cfcd
FB
219#define TARGET_KDGKBENT 0x4B46 /* gets one entry in translation table */
220#define TARGET_KDGKBSENT 0x4B48 /* gets one function key string entry */
8e5a0667 221
31e31b8a
FB
222/* Networking ioctls */
223#define TARGET_SIOCADDRT 0x890B /* add routing table entry */
224#define TARGET_SIOCDELRT 0x890C /* delete routing table entry */
225#define TARGET_SIOCGIFNAME 0x8910 /* get iface name */
226#define TARGET_SIOCSIFLINK 0x8911 /* set iface channel */
227#define TARGET_SIOCGIFCONF 0x8912 /* get iface list */
228#define TARGET_SIOCGIFFLAGS 0x8913 /* get flags */
229#define TARGET_SIOCSIFFLAGS 0x8914 /* set flags */
230#define TARGET_SIOCGIFADDR 0x8915 /* get PA address */
231#define TARGET_SIOCSIFADDR 0x8916 /* set PA address */
232#define TARGET_SIOCGIFDSTADDR 0x8917 /* get remote PA address */
233#define TARGET_SIOCSIFDSTADDR 0x8918 /* set remote PA address */
234#define TARGET_SIOCGIFBRDADDR 0x8919 /* get broadcast PA address */
235#define TARGET_SIOCSIFBRDADDR 0x891a /* set broadcast PA address */
236#define TARGET_SIOCGIFNETMASK 0x891b /* get network PA mask */
237#define TARGET_SIOCSIFNETMASK 0x891c /* set network PA mask */
238#define TARGET_SIOCGIFMETRIC 0x891d /* get metric */
239#define TARGET_SIOCSIFMETRIC 0x891e /* set metric */
240#define TARGET_SIOCGIFMEM 0x891f /* get memory address (BSD) */
241#define TARGET_SIOCSIFMEM 0x8920 /* set memory address (BSD) */
242#define TARGET_SIOCGIFMTU 0x8921 /* get MTU size */
243#define TARGET_SIOCSIFMTU 0x8922 /* set MTU size */
244#define TARGET_SIOCSIFHWADDR 0x8924 /* set hardware address (NI) */
245#define TARGET_SIOCGIFENCAP 0x8925 /* get/set slip encapsulation */
246#define TARGET_SIOCSIFENCAP 0x8926
247#define TARGET_SIOCGIFHWADDR 0x8927 /* Get hardware address */
248#define TARGET_SIOCGIFSLAVE 0x8929 /* Driver slaving support */
249#define TARGET_SIOCSIFSLAVE 0x8930
250#define TARGET_SIOCADDMULTI 0x8931 /* Multicast address lists */
251#define TARGET_SIOCDELMULTI 0x8932
252
253/* Bridging control calls */
254#define TARGET_SIOCGIFBR 0x8940 /* Bridging support */
255#define TARGET_SIOCSIFBR 0x8941 /* Set bridging options */
256
257#define TARGET_SIOCGIFTXQLEN 0x8942 /* Get the tx queue length */
258#define TARGET_SIOCSIFTXQLEN 0x8943 /* Set the tx queue length */
259
260/* ARP cache control calls. */
261#define TARGET_OLD_SIOCDARP 0x8950 /* old delete ARP table entry */
262#define TARGET_OLD_SIOCGARP 0x8951 /* old get ARP table entry */
263#define TARGET_OLD_SIOCSARP 0x8952 /* old set ARP table entry */
264#define TARGET_SIOCDARP 0x8953 /* delete ARP table entry */
265#define TARGET_SIOCGARP 0x8954 /* get ARP table entry */
266#define TARGET_SIOCSARP 0x8955 /* set ARP table entry */
267
268/* RARP cache control calls. */
269#define TARGET_SIOCDRARP 0x8960 /* delete RARP table entry */
270#define TARGET_SIOCGRARP 0x8961 /* get RARP table entry */
271#define TARGET_SIOCSRARP 0x8962 /* set RARP table entry */
272
273/* Driver configuration calls */
274#define TARGET_SIOCGIFMAP 0x8970 /* Get device parameters */
275#define TARGET_SIOCSIFMAP 0x8971 /* Set device parameters */
276
277/* DLCI configuration calls */
278#define TARGET_SIOCADDDLCI 0x8980 /* Create new DLCI device */
279#define TARGET_SIOCDELDLCI 0x8981 /* Delete DLCI device */
280
281
282/* From <linux/fs.h> */
283
284#define TARGET_BLKROSET TARGET_IO(0x12,93) /* set device read-only (0 = read-write) */
285#define TARGET_BLKROGET TARGET_IO(0x12,94) /* get read-only status (0 = read_write) */
286#define TARGET_BLKRRPART TARGET_IO(0x12,95) /* re-read partition table */
287#define TARGET_BLKGETSIZE TARGET_IO(0x12,96) /* return device size /512 (long *arg) */
288#define TARGET_BLKFLSBUF TARGET_IO(0x12,97) /* flush buffer cache */
289#define TARGET_BLKRASET TARGET_IO(0x12,98) /* Set read ahead for block device */
290#define TARGET_BLKRAGET TARGET_IO(0x12,99) /* get current read ahead setting */
291#define TARGET_BLKFRASET TARGET_IO(0x12,100)/* set filesystem (mm/filemap.c) read-ahead */
292#define TARGET_BLKFRAGET TARGET_IO(0x12,101)/* get filesystem (mm/filemap.c) read-ahead */
293#define TARGET_BLKSECTSET TARGET_IO(0x12,102)/* set max sectors per request (ll_rw_blk.c) */
294#define TARGET_BLKSECTGET TARGET_IO(0x12,103)/* get max sectors per request (ll_rw_blk.c) */
295#define TARGET_BLKSSZGET TARGET_IO(0x12,104)/* get block device sector size */
296/* A jump here: 108-111 have been used for various private purposes. */
297#define TARGET_BLKBSZGET TARGET_IOR(0x12,112,sizeof(int))
298#define TARGET_BLKBSZSET TARGET_IOW(0x12,113,sizeof(int))
299#define TARGET_BLKGETSIZE64 TARGET_IOR(0x12,114,sizeof(uint64_t)) /* return device size in bytes (u64 *arg) */
300#define TARGET_FIBMAP TARGET_IO(0x00,1) /* bmap access */
301#define TARGET_FIGETBSZ TARGET_IO(0x00,2) /* get the block size used for bmap */
302
303/* cdrom commands */
304#define TARGET_CDROMPAUSE 0x5301 /* Pause Audio Operation */
305#define TARGET_CDROMRESUME 0x5302 /* Resume paused Audio Operation */
306#define TARGET_CDROMPLAYMSF 0x5303 /* Play Audio MSF (struct cdrom_msf) */
307#define TARGET_CDROMPLAYTRKIND 0x5304 /* Play Audio Track/index
308 (struct cdrom_ti) */
309#define TARGET_CDROMREADTOCHDR 0x5305 /* Read TOC header
310 (struct cdrom_tochdr) */
311#define TARGET_CDROMREADTOCENTRY 0x5306 /* Read TOC entry
312 (struct cdrom_tocentry) */
313#define TARGET_CDROMSTOP 0x5307 /* Stop the cdrom drive */
314#define TARGET_CDROMSTART 0x5308 /* Start the cdrom drive */
315#define TARGET_CDROMEJECT 0x5309 /* Ejects the cdrom media */
316#define TARGET_CDROMVOLCTRL 0x530a /* Control output volume
317 (struct cdrom_volctrl) */
318#define TARGET_CDROMSUBCHNL 0x530b /* Read subchannel data
319 (struct cdrom_subchnl) */
320#define TARGET_CDROMREADMODE2 0x530c /* Read TARGET_CDROM mode 2 data (2336 Bytes)
321 (struct cdrom_read) */
322#define TARGET_CDROMREADMODE1 0x530d /* Read TARGET_CDROM mode 1 data (2048 Bytes)
323 (struct cdrom_read) */
324#define TARGET_CDROMREADAUDIO 0x530e /* (struct cdrom_read_audio) */
325#define TARGET_CDROMEJECT_SW 0x530f /* enable(1)/disable(0) auto-ejecting */
326#define TARGET_CDROMMULTISESSION 0x5310 /* Obtain the start-of-last-session
327 address of multi session disks
328 (struct cdrom_multisession) */
329#define TARGET_CDROM_GET_MCN 0x5311 /* Obtain the "Universal Product Code"
330 if available (struct cdrom_mcn) */
331#define TARGET_CDROM_GET_UPC TARGET_CDROM_GET_MCN /* This one is depricated,
332 but here anyway for compatability */
333#define TARGET_CDROMRESET 0x5312 /* hard-reset the drive */
334#define TARGET_CDROMVOLREAD 0x5313 /* Get the drive's volume setting
335 (struct cdrom_volctrl) */
336#define TARGET_CDROMREADRAW 0x5314 /* read data in raw mode (2352 Bytes)
337 (struct cdrom_read) */
338/*
339 * These ioctls are used only used in aztcd.c and optcd.c
340 */
341#define TARGET_CDROMREADCOOKED 0x5315 /* read data in cooked mode */
342#define TARGET_CDROMSEEK 0x5316 /* seek msf address */
343
344/*
345 * This ioctl is only used by the scsi-cd driver.
346 It is for playing audio in logical block addressing mode.
347 */
348#define TARGET_CDROMPLAYBLK 0x5317 /* (struct cdrom_blk) */
349
350/*
351 * These ioctls are only used in optcd.c
352 */
353#define TARGET_CDROMREADALL 0x5318 /* read all 2646 bytes */
354
355/*
356 * These ioctls are (now) only in ide-cd.c for controlling
357 * drive spindown time. They should be implemented in the
358 * Uniform driver, via generic packet commands, GPCMD_MODE_SELECT_10,
359 * GPCMD_MODE_SENSE_10 and the GPMODE_POWER_PAGE...
360 * -Erik
361 */
362#define TARGET_CDROMGETSPINDOWN 0x531d
363#define TARGET_CDROMSETSPINDOWN 0x531e
364
365/*
366 * These ioctls are implemented through the uniform CD-ROM driver
367 * They _will_ be adopted by all CD-ROM drivers, when all the CD-ROM
368 * drivers are eventually ported to the uniform CD-ROM driver interface.
369 */
370#define TARGET_CDROMCLOSETRAY 0x5319 /* pendant of CDROMEJECT */
371#define TARGET_CDROM_SET_OPTIONS 0x5320 /* Set behavior options */
372#define TARGET_CDROM_CLEAR_OPTIONS 0x5321 /* Clear behavior options */
373#define TARGET_CDROM_SELECT_SPEED 0x5322 /* Set the CD-ROM speed */
374#define TARGET_CDROM_SELECT_DISC 0x5323 /* Select disc (for juke-boxes) */
375#define TARGET_CDROM_MEDIA_CHANGED 0x5325 /* Check is media changed */
376#define TARGET_CDROM_DRIVE_STATUS 0x5326 /* Get tray position, etc. */
377#define TARGET_CDROM_DISC_STATUS 0x5327 /* Get disc type, etc. */
378#define TARGET_CDROM_CHANGER_NSLOTS 0x5328 /* Get number of slots */
379#define TARGET_CDROM_LOCKDOOR 0x5329 /* lock or unlock door */
380#define TARGET_CDROM_DEBUG 0x5330 /* Turn debug messages on/off */
381#define TARGET_CDROM_GET_CAPABILITY 0x5331 /* get capabilities */
382
383/* Note that scsi/scsi_ioctl.h also uses 0x5382 - 0x5386.
384 * Future CDROM ioctls should be kept below 0x537F
385 */
386
387/* This ioctl is only used by sbpcd at the moment */
388#define TARGET_CDROMAUDIOBUFSIZ 0x5382 /* set the audio buffer size */
389 /* conflict with SCSI_IOCTL_GET_IDLUN */
390
391/* DVD-ROM Specific ioctls */
392#define TARGET_DVD_READ_STRUCT 0x5390 /* Read structure */
393#define TARGET_DVD_WRITE_STRUCT 0x5391 /* Write structure */
394#define TARGET_DVD_AUTH 0x5392 /* Authentication */
395
396#define TARGET_CDROM_SEND_PACKET 0x5393 /* send a packet to the drive */
397#define TARGET_CDROM_NEXT_WRITABLE 0x5394 /* get next writable block */
398#define TARGET_CDROM_LAST_WRITTEN 0x5395 /* get last block written on disc */
399
400/* HD commands */
401
402/* hd/ide ctl's that pass (arg) ptrs to user space are numbered 0x030n/0x031n */
403#define TARGET_HDIO_GETGEO 0x0301 /* get device geometry */
404#define TARGET_HDIO_GET_UNMASKINTR 0x0302 /* get current unmask setting */
405#define TARGET_HDIO_GET_MULTCOUNT 0x0304 /* get current IDE blockmode setting */
406#define TARGET_HDIO_GET_IDENTITY 0x0307 /* get IDE identification info */
407#define TARGET_HDIO_GET_KEEPSETTINGS 0x0308 /* get keep-settings-on-reset flag */
408#define TARGET_HDIO_GET_32BIT 0x0309 /* get current io_32bit setting */
409#define TARGET_HDIO_GET_NOWERR 0x030a /* get ignore-write-error flag */
410#define TARGET_HDIO_GET_DMA 0x030b /* get use-dma flag */
411#define TARGET_HDIO_DRIVE_CMD 0x031f /* execute a special drive command */
412
413/* hd/ide ctl's that pass (arg) non-ptr values are numbered 0x032n/0x033n */
414#define TARGET_HDIO_SET_MULTCOUNT 0x0321 /* change IDE blockmode */
415#define TARGET_HDIO_SET_UNMASKINTR 0x0322 /* permit other irqs during I/O */
416#define TARGET_HDIO_SET_KEEPSETTINGS 0x0323 /* keep ioctl settings on reset */
417#define TARGET_HDIO_SET_32BIT 0x0324 /* change io_32bit flags */
418#define TARGET_HDIO_SET_NOWERR 0x0325 /* change ignore-write-error flag */
419#define TARGET_HDIO_SET_DMA 0x0326 /* change use-dma flag */
420#define TARGET_HDIO_SET_PIO_MODE 0x0327 /* reconfig interface to new speed */