]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/i386/linux/linux.h
This commit was generated by cvs2svn to compensate for changes in r54820,
[FreeBSD/FreeBSD.git] / sys / i386 / linux / linux.h
1 /*-
2  * Copyright (c) 1994-1996 Søren Schmidt
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer 
10  *    in this position and unchanged.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  *    notice, this list of conditions and the following disclaimer in the
13  *    documentation and/or other materials provided with the distribution.
14  * 3. The name of the author may not be used to endorse or promote products
15  *    derived from this software without specific prior written permission
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  *
28  * $FreeBSD$
29  */
30
31 #ifndef _I386_LINUX_LINUX_H_
32 #define _I386_LINUX_LINUX_H_
33
34 #include <i386/linux/linux_syscall.h>
35
36 #ifdef MALLOC_DECLARE
37 MALLOC_DECLARE(M_LINUX);
38 #endif
39
40 /*
41  * Miscellaneous
42  */
43 #define LINUX_NAME_MAX          255
44 #define LINUX_MAX_UTSNAME       65
45
46 /* Scheduling policies */
47 #define LINUX_SCHED_OTHER       0
48 #define LINUX_SCHED_FIFO        1
49 #define LINUX_SCHED_RR          2
50
51 /* Resource limits */
52 #define LINUX_RLIMIT_CPU        0
53 #define LINUX_RLIMIT_FSIZE      1
54 #define LINUX_RLIMIT_DATA       2
55 #define LINUX_RLIMIT_STACK      3
56 #define LINUX_RLIMIT_CORE       4
57 #define LINUX_RLIMIT_RSS        5
58 #define LINUX_RLIMIT_NPROC      6
59 #define LINUX_RLIMIT_NOFILE     7
60 #define LINUX_RLIMIT_MEMLOCK    8
61 #define LINUX_RLIMIT_AS         9       /* address space limit */
62
63 #define LINUX_RLIM_NLIMITS      10
64
65 /* mmap options */
66 #define LINUX_MAP_SHARED        0x0001
67 #define LINUX_MAP_PRIVATE       0x0002
68 #define LINUX_MAP_FIXED         0x0010
69 #define LINUX_MAP_ANON          0x0020
70 #define LINUX_MAP_GROWSDOWN     0x0100
71
72 typedef char *  linux_caddr_t;
73 typedef long    linux_clock_t;
74 typedef u_short linux_dev_t;
75 typedef u_short linux_gid_t;
76 typedef u_long  linux_ino_t;
77 typedef int     linux_key_t;    /* XXX */
78 typedef u_short linux_mode_t;
79 typedef u_short linux_nlink_t;
80 typedef long    linux_off_t;
81 typedef int     linux_pid_t;
82 typedef u_int   linux_size_t;
83 typedef long    linux_time_t;
84 typedef u_short linux_uid_t;
85
86 typedef struct {
87         long    val[2];
88 } linux_fsid_t;
89
90 struct linux_new_utsname {
91         char    sysname[LINUX_MAX_UTSNAME];
92         char    nodename[LINUX_MAX_UTSNAME];
93         char    release[LINUX_MAX_UTSNAME];
94         char    version[LINUX_MAX_UTSNAME];
95         char    machine[LINUX_MAX_UTSNAME];
96         char    domainname[LINUX_MAX_UTSNAME];
97 };
98
99 /*
100  * Signalling
101  */
102 #define LINUX_SIGHUP            1
103 #define LINUX_SIGINT            2
104 #define LINUX_SIGQUIT           3
105 #define LINUX_SIGILL            4
106 #define LINUX_SIGTRAP           5
107 #define LINUX_SIGABRT           6
108 #define LINUX_SIGIOT            LINUX_SIGABRT
109 #define LINUX_SIGBUS            7
110 #define LINUX_SIGFPE            8
111 #define LINUX_SIGKILL           9
112 #define LINUX_SIGUSR1           10
113 #define LINUX_SIGSEGV           11
114 #define LINUX_SIGUSR2           12
115 #define LINUX_SIGPIPE           13
116 #define LINUX_SIGALRM           14
117 #define LINUX_SIGTERM           15
118 #define LINUX_SIGSTKFLT         16
119 #define LINUX_SIGCHLD           17
120 #define LINUX_SIGCONT           18
121 #define LINUX_SIGSTOP           19
122 #define LINUX_SIGTSTP           20
123 #define LINUX_SIGTTIN           21
124 #define LINUX_SIGTTOU           22
125 #define LINUX_SIGURG            23
126 #define LINUX_SIGXCPU           24
127 #define LINUX_SIGXFSZ           25
128 #define LINUX_SIGVTALRM         26
129 #define LINUX_SIGPROF           27
130 #define LINUX_SIGWINCH          28
131 #define LINUX_SIGIO             29
132 #define LINUX_SIGPOLL           LINUX_SIGIO
133 #define LINUX_SIGPWR            30
134 #define LINUX_SIGUNUSED         31
135
136 #define LINUX_NSIG              64
137 #define LINUX_SIGTBLSZ          31
138
139 /* sigaction flags */
140 #define LINUX_SA_NOCLDSTOP      0x00000001
141 #define LINUX_SA_NOCLDWAIT      0x00000002
142 #define LINUX_SA_SIGINFO        0x00000004
143 #define LINUX_SA_RESTORER       0x04000000
144 #define LINUX_SA_ONSTACK        0x08000000
145 #define LINUX_SA_RESTART        0x10000000
146 #define LINUX_SA_INTERRUPT      0x20000000
147 #define LINUX_SA_NOMASK         0x40000000
148 #define LINUX_SA_ONESHOT        0x80000000
149
150 /* sigprocmask actions */
151 #define LINUX_SIG_BLOCK         0
152 #define LINUX_SIG_UNBLOCK       1
153 #define LINUX_SIG_SETMASK       2
154
155 /* sigset_t macros */
156 #define LINUX_SIGEMPTYSET(set)          (set).__bits[0] = (set).__bits[1] = 0
157 #define LINUX_SIGISMEMBER(set, sig)     SIGISMEMBER(set, sig)
158 #define LINUX_SIGADDSET(set, sig)       SIGADDSET(set, sig)
159
160 typedef void    (*linux_handler_t)(int);
161 typedef u_long  linux_osigset_t;
162
163 typedef struct {
164         u_int   __bits[2];
165 } linux_sigset_t;
166
167 typedef struct {
168         linux_handler_t lsa_handler;
169         linux_osigset_t lsa_mask;
170         u_long  lsa_flags;
171         void    (*lsa_restorer)(void);
172 } linux_osigaction_t;
173
174 typedef struct {
175         linux_handler_t lsa_handler;
176         u_long  lsa_flags;
177         void    (*lsa_restorer)(void);
178         linux_sigset_t  lsa_mask;
179 } linux_sigaction_t;
180
181 typedef struct {
182         void    *ss_sp;
183         int     ss_flags;
184         linux_size_t ss_size;
185 } linux_stack_t;
186
187 /* The Linux sigcontext, pretty much a standard 386 trapframe. */
188 struct linux_sigcontext {
189         int     sc_gs;
190         int     sc_fs;
191         int     sc_es;
192         int     sc_ds;
193         int     sc_edi;
194         int     sc_esi;
195         int     sc_ebp;
196         int     sc_esp;
197         int     sc_ebx;
198         int     sc_edx;
199         int     sc_ecx;
200         int     sc_eax;
201         int     sc_trapno;
202         int     sc_err;
203         int     sc_eip;
204         int     sc_cs;
205         int     sc_eflags;
206         int     sc_esp_at_signal;
207         int     sc_ss;
208         int     sc_387;
209         int     sc_mask;
210         int     sc_cr2;
211 };
212
213 /*
214  * We make the stack look like Linux expects it when calling a signal
215  * handler, but use the BSD way of calling the handler and sigreturn().
216  * This means that we need to pass the pointer to the handler too.
217  * It is appended to the frame to not interfere with the rest of it.
218  */
219 struct linux_sigframe {
220         int     sf_sig;
221         struct  linux_sigcontext sf_sc;
222         linux_handler_t sf_handler;
223 };
224
225 extern int bsd_to_linux_signal[];
226 extern int linux_to_bsd_signal[];
227
228 /*
229  * Pluggable ioctl handlers
230  */
231 struct linker_set;
232 struct linux_ioctl_args;
233 struct proc;
234
235 typedef int linux_ioctl_function_t(struct proc *, struct linux_ioctl_args *);
236
237 struct linux_ioctl_handler {
238         linux_ioctl_function_t *func;
239         int     low, high;
240 };
241
242 int     linux_ioctl_register_handler(struct linux_ioctl_handler *h);
243 int     linux_ioctl_register_handlers(struct linker_set *s);
244 int     linux_ioctl_unregister_handler(struct linux_ioctl_handler *h);
245 int     linux_ioctl_unregister_handlers(struct linker_set *s);
246
247 /*
248  * open/fcntl flags
249  */
250 #define LINUX_O_RDONLY          00
251 #define LINUX_O_WRONLY          01
252 #define LINUX_O_RDWR            02
253 #define LINUX_O_CREAT           0100
254 #define LINUX_O_EXCL            0200
255 #define LINUX_O_NOCTTY          0400
256 #define LINUX_O_TRUNC           01000
257 #define LINUX_O_APPEND          02000
258 #define LINUX_O_NONBLOCK        04000
259 #define LINUX_O_NDELAY          LINUX_O_NONBLOCK
260 #define LINUX_O_SYNC            010000
261 #define LINUX_FASYNC            020000
262
263 #define LINUX_F_DUPFD           0
264 #define LINUX_F_GETFD           1
265 #define LINUX_F_SETFD           2
266 #define LINUX_F_GETFL           3
267 #define LINUX_F_SETFL           4
268 #define LINUX_F_GETLK           5
269 #define LINUX_F_SETLK           6
270 #define LINUX_F_SETLKW          7
271 #define LINUX_F_SETOWN          8
272 #define LINUX_F_GETOWN          9
273
274 #define LINUX_F_RDLCK           0
275 #define LINUX_F_WRLCK           1
276 #define LINUX_F_UNLCK           2
277
278 /*
279  * SystemV IPC defines
280  */
281 #define LINUX_SEMOP             1
282 #define LINUX_SEMGET            2
283 #define LINUX_SEMCTL            3
284 #define LINUX_MSGSND            11
285 #define LINUX_MSGRCV            12
286 #define LINUX_MSGGET            13
287 #define LINUX_MSGCTL            14
288 #define LINUX_SHMAT             21
289 #define LINUX_SHMDT             22
290 #define LINUX_SHMGET            23
291 #define LINUX_SHMCTL            24
292
293 #define LINUX_IPC_RMID          0
294 #define LINUX_IPC_SET           1
295 #define LINUX_IPC_STAT          2
296 #define LINUX_IPC_INFO          3
297
298 #define LINUX_SHM_LOCK          11
299 #define LINUX_SHM_UNLOCK        12
300 #define LINUX_SHM_STAT          13
301 #define LINUX_SHM_INFO          14
302
303 #define LINUX_SHM_RDONLY        0x1000
304 #define LINUX_SHM_RND           0x2000
305 #define LINUX_SHM_REMAP         0x4000
306
307 /* semctl commands */
308 #define LINUX_GETPID            11
309 #define LINUX_GETVAL            12
310 #define LINUX_GETALL            13
311 #define LINUX_GETNCNT           14
312 #define LINUX_GETZCNT           15
313 #define LINUX_SETVAL            16
314 #define LINUX_SETALL            17
315
316 /*
317  * Socket defines
318  */
319 #define LINUX_SOCKET            1
320 #define LINUX_BIND              2
321 #define LINUX_CONNECT           3
322 #define LINUX_LISTEN            4
323 #define LINUX_ACCEPT            5
324 #define LINUX_GETSOCKNAME       6
325 #define LINUX_GETPEERNAME       7
326 #define LINUX_SOCKETPAIR        8
327 #define LINUX_SEND              9
328 #define LINUX_RECV              10
329 #define LINUX_SENDTO            11
330 #define LINUX_RECVFROM          12
331 #define LINUX_SHUTDOWN          13
332 #define LINUX_SETSOCKOPT        14
333 #define LINUX_GETSOCKOPT        15
334 #define LINUX_SENDMSG           16
335 #define LINUX_RECVMSG           17
336
337 #define LINUX_AF_UNSPEC         0
338 #define LINUX_AF_UNIX           1
339 #define LINUX_AF_INET           2
340 #define LINUX_AF_AX25           3
341 #define LINUX_AF_IPX            4
342 #define LINUX_AF_APPLETALK      5
343
344 #define LINUX_SOL_SOCKET        1
345 #define LINUX_SOL_IP            0
346 #define LINUX_SOL_IPX           256
347 #define LINUX_SOL_AX25          257
348 #define LINUX_SOL_TCP           6
349 #define LINUX_SOL_UDP           17
350
351 #define LINUX_SO_DEBUG          1
352 #define LINUX_SO_REUSEADDR      2
353 #define LINUX_SO_TYPE           3
354 #define LINUX_SO_ERROR          4
355 #define LINUX_SO_DONTROUTE      5
356 #define LINUX_SO_BROADCAST      6
357 #define LINUX_SO_SNDBUF         7
358 #define LINUX_SO_RCVBUF         8
359 #define LINUX_SO_KEEPALIVE      9
360 #define LINUX_SO_OOBINLINE      10
361 #define LINUX_SO_NO_CHECK       11
362 #define LINUX_SO_PRIORITY       12
363 #define LINUX_SO_LINGER         13
364
365 #define LINUX_IP_TOS            1
366 #define LINUX_IP_TTL            2
367 #define LINUX_IP_HDRINCL        3
368 #define LINUX_IP_OPTIONS        4
369
370 #define LINUX_IP_MULTICAST_IF           32
371 #define LINUX_IP_MULTICAST_TTL          33
372 #define LINUX_IP_MULTICAST_LOOP         34
373 #define LINUX_IP_ADD_MEMBERSHIP         35
374 #define LINUX_IP_DROP_MEMBERSHIP        36
375
376 struct linux_sockaddr {
377         u_short sa_family;
378         char    sa_data[14];
379 };
380
381 struct linux_ifmap {
382         u_long  mem_start;
383         u_long  mem_end;
384         u_short base_addr; 
385         u_char  irq;
386         u_char  dma;
387         u_char  port;
388 };
389
390 #define LINUX_IFHWADDRLEN       6
391 #define LINUX_IFNAMSIZ          16
392
393 struct linux_ifreq {
394         union {
395                 char    ifrn_name[LINUX_IFNAMSIZ];
396         } ifr_ifrn;
397
398         union {
399                 struct  linux_sockaddr ifru_addr;
400                 struct  linux_sockaddr ifru_dstaddr;
401                 struct  linux_sockaddr ifru_broadaddr;
402                 struct  linux_sockaddr ifru_netmask;
403                 struct  linux_sockaddr ifru_hwaddr;
404                 short   ifru_flags;
405                 int     ifru_metric;
406                 int     ifru_mtu;
407                 struct  linux_ifmap ifru_map;
408                 char    ifru_slave[LINUX_IFNAMSIZ]; /* Just fits the size */
409                 linux_caddr_t ifru_data;
410         } ifr_ifru;
411 };
412
413 #define ifr_name        ifr_ifrn.ifrn_name      /* interface name */
414 #define ifr_hwaddr      ifr_ifru.ifru_hwaddr    /* MAC address */
415
416 #endif /* !_I386_LINUX_LINUX_H_ */