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: releng/5.3/sys/alpha/linux/linux.h 133815 2004-08-16 07:05:44Z tjr $
29 */
30
31 #ifndef _ALPHA_LINUX_LINUX_H_
32 #define _ALPHA_LINUX_LINUX_H_
33
34 #include <alpha/linux/linux_syscall.h>
35
36 /*
37 * debugging support
38 */
39 extern u_char linux_debug_map[];
40 #define ldebug(name) isclr(linux_debug_map, LINUX_SYS_linux_ ## name)
41 #define ARGS(nm, fmt) "linux(%ld): "#nm"("fmt")\n", (long)td->td_proc->p_pid
42 #define LMSG(fmt) "linux(%ld): "fmt"\n", (long)td->td_proc->p_pid
43
44 #ifdef MALLOC_DECLARE
45 MALLOC_DECLARE(M_LINUX);
46 #endif
47
48 #define PTRIN(v) (void *)(v)
49 #define PTROUT(v) (l_uintptr_t)(v)
50
51 typedef int l_int;
52 typedef int64_t l_long;
53 typedef int64_t l_longlong;
54 typedef short l_short;
55 typedef unsigned int l_uint;
56 typedef uint64_t l_ulong;
57 typedef uint64_t l_ulonglong;
58 typedef unsigned short l_ushort;
59
60 typedef char *l_caddr_t;
61 typedef l_ulong l_uintptr_t;
62 typedef l_long l_clock_t;
63 typedef l_int l_daddr_t;
64 typedef l_uint l_dev_t;
65 typedef l_uint l_gid_t;
66 typedef l_ushort l_gid16_t;
67 typedef l_uint l_ino_t;
68 typedef l_int l_key_t;
69 typedef l_long l_loff_t;
70 typedef l_uint l_mode_t;
71 typedef l_long l_off_t;
72 typedef l_int l_pid_t;
73 typedef l_ulong l_size_t;
74 typedef l_long l_suseconds_t;
75 typedef l_long l_time_t;
76 typedef l_uint l_uid_t;
77 typedef l_ushort l_uid16_t;
78
79 typedef struct {
80 l_int val[2];
81 } l_fsid_t;
82
83 typedef struct {
84 l_time_t tv_sec;
85 l_suseconds_t tv_usec;
86 } l_timeval;
87
88 #define l_fd_set fd_set
89
90 /*
91 * Miscellaneous
92 */
93 #define LINUX_NAME_MAX 255
94 #define LINUX_MAX_UTSNAME 65
95
96 #define LINUX_CTL_MAXNAME 10
97
98 struct l___sysctl_args
99 {
100 l_int *name;
101 l_int nlen;
102 void *oldval;
103 l_size_t *oldlenp;
104 void *newval;
105 l_size_t newlen;
106 l_ulong __spare[4];
107 };
108
109 /* Scheduling policies */
110 #define LINUX_SCHED_OTHER 0
111 #define LINUX_SCHED_FIFO 1
112 #define LINUX_SCHED_RR 2
113
114 /* Resource limits */
115 #define LINUX_RLIMIT_CPU 0
116 #define LINUX_RLIMIT_FSIZE 1
117 #define LINUX_RLIMIT_DATA 2
118 #define LINUX_RLIMIT_STACK 3
119 #define LINUX_RLIMIT_CORE 4
120 #define LINUX_RLIMIT_RSS 5
121 #define LINUX_RLIMIT_AS 7 /* address space limit */
122 #define LINUX_RLIMIT_NPROC 8
123 #define LINUX_RLIMIT_NOFILE 6
124 #define LINUX_RLIMIT_MEMLOCK 9
125
126 #define LINUX_RLIM_NLIMITS 10
127
128 /* mmap options */
129 #define LINUX_MAP_SHARED 0x0001
130 #define LINUX_MAP_PRIVATE 0x0002
131 #define LINUX_MAP_ANON 0x0010
132 #define LINUX_MAP_FIXED 0x0100
133 #define LINUX_MAP_GROWSDOWN 0x1000
134
135 /*
136 * stat family of syscalls
137 */
138 struct l_timespec {
139 l_ulong tv_sec;
140 };
141
142 struct l_newstat {
143 l_uint st_dev;
144 l_uint st_ino;
145 l_uint st_mode;
146 l_uint st_nlink;
147 l_uint st_uid;
148 l_uint st_gid;
149 l_uint st_rdev;
150 l_long st_size;
151 struct l_timespec st_atimespec;
152 struct l_timespec st_mtimespec;
153 struct l_timespec st_ctimespec;
154 l_uint st_blksize;
155 l_int st_blocks;
156 l_uint st_flags;
157 l_uint st_gen;
158 };
159
160 struct l_new_utsname {
161 char sysname[LINUX_MAX_UTSNAME];
162 char nodename[LINUX_MAX_UTSNAME];
163 char release[LINUX_MAX_UTSNAME];
164 char version[LINUX_MAX_UTSNAME];
165 char machine[LINUX_MAX_UTSNAME];
166 char domainname[LINUX_MAX_UTSNAME];
167 };
168
169 /*
170 * Signalling
171 */
172 #define LINUX_SIGHUP 1
173 #define LINUX_SIGINT 2
174 #define LINUX_SIGQUIT 3
175 #define LINUX_SIGILL 4
176 #define LINUX_SIGTRAP 5
177 #define LINUX_SIGABRT 6
178 #define LINUX_SIGIOT LINUX_SIGABRT
179 #define LINUX_SIGBUS 7
180 #define LINUX_SIGFPE 8
181 #define LINUX_SIGKILL 9
182 #define LINUX_SIGUSR1 10
183 #define LINUX_SIGSEGV 11
184 #define LINUX_SIGUSR2 12
185 #define LINUX_SIGPIPE 13
186 #define LINUX_SIGALRM 14
187 #define LINUX_SIGTERM 15
188 #define LINUX_SIGSTKFLT 16
189 #define LINUX_SIGCHLD 17
190 #define LINUX_SIGCONT 18
191 #define LINUX_SIGSTOP 19
192 #define LINUX_SIGTSTP 20
193 #define LINUX_SIGTTIN 21
194 #define LINUX_SIGTTOU 22
195 #define LINUX_SIGURG 23
196 #define LINUX_SIGXCPU 24
197 #define LINUX_SIGXFSZ 25
198 #define LINUX_SIGVTALRM 26
199 #define LINUX_SIGPROF 27
200 #define LINUX_SIGWINCH 28
201 #define LINUX_SIGIO 29
202 #define LINUX_SIGPOLL LINUX_SIGIO
203 #define LINUX_SIGPWR 30
204 #define LINUX_SIGUNUSED 31
205
206 #define LINUX_SIGTBLSZ 31
207 #define LINUX_NSIG_WORDS 2
208 #define LINUX_NBPW 32
209 #define LINUX_NSIG (LINUX_NBPW * LINUX_NSIG_WORDS)
210
211 /* sigaction flags */
212 #define LINUX_SA_ONSTACK 0x00000001
213 #define LINUX_SA_RESTART 0x00000002
214 #define LINUX_SA_NOCLDSTOP 0x00000004
215 #define LINUX_SA_NODEFER 0x00000008
216 #define LINUX_SA_RESETHAND 0x00000010
217 #define LINUX_SA_NOCLDWAIT 0x00000020
218 #define LINUX_SA_SIGINFO 0x00000040
219 #define LINUX_SA_RESTORER 0x04000000
220 #define LINUX_SA_INTERRUPT 0x20000000
221 #define LINUX_SA_NOMASK LINUX_SA_NODEFER
222 #define LINUX_SA_ONESHOT LINUX_SA_RESETHAND
223
224 /* sigprocmask actions */
225 #define LINUX_SIG_BLOCK 0
226 #define LINUX_SIG_UNBLOCK 1
227 #define LINUX_SIG_SETMASK 2
228
229 /* sigset_t macros */
230 #define LINUX_SIGEMPTYSET(set) (set).__bits[0] = (set).__bits[1] = 0
231 #define LINUX_SIGISMEMBER(set, sig) SIGISMEMBER(set, sig)
232 #define LINUX_SIGADDSET(set, sig) SIGADDSET(set, sig)
233
234 #define LINUX_MINSIGSTKSZ 4096
235
236 typedef void (*l_handler_t)(l_int);
237 typedef l_ulong l_osigset_t;
238
239 typedef struct {
240 l_uint __bits[LINUX_NSIG_WORDS];
241 } l_sigset_t;
242
243 typedef struct {
244 l_handler_t lsa_handler;
245 l_osigset_t lsa_mask;
246 l_ulong lsa_flags;
247 void (*lsa_restorer)(void);
248 } l_osigaction_t;
249
250 typedef struct {
251 l_handler_t lsa_handler;
252 l_ulong lsa_flags;
253 void (*lsa_restorer)(void);
254 l_sigset_t lsa_mask;
255 } l_sigaction_t;
256
257 /*
258 * The Linux sigcontext
259 */
260 struct l_sigcontext {
261 l_long sc_onstack;
262 l_long sc_mask;
263 l_long sc_pc;
264 l_long sc_ps;
265 l_long sc_regs[32];
266 l_long sc_ownedfp;
267 l_long sc_fpregs[32];
268 l_ulong sc_fpcr;
269 l_ulong sc_fp_control;
270 l_ulong sc_reserved1, sc_reserved2;
271 l_ulong sc_ssize;
272 char *sc_sbase;
273 l_ulong sc_traparg_a0;
274 l_ulong sc_traparg_a1;
275 l_ulong sc_traparg_a2;
276 l_ulong sc_fp_trap_pc;
277 l_ulong sc_fp_trigger_sum;
278 l_ulong sc_fp_trigger_inst;
279 };
280
281 /*
282 * We make the stack look like Linux expects it when calling a signal
283 * handler, but use the BSD way of calling the handler and sigreturn().
284 * This means that we need to pass the pointer to the handler too.
285 * It is appended to the frame to not interfere with the rest of it.
286 */
287 struct l_sigframe {
288 l_int sf_sig;
289 struct l_sigcontext sf_sc;
290 l_handler_t sf_handler;
291 };
292
293 /*
294 * Pluggable ioctl handlers
295 */
296 struct linux_ioctl_args;
297 struct thread;
298
299 typedef int linux_ioctl_function_t(struct thread *, struct linux_ioctl_args *);
300
301 struct linux_ioctl_handler {
302 linux_ioctl_function_t *func;
303 int low, high;
304 };
305
306 int linux_ioctl_register_handler(struct linux_ioctl_handler *h);
307 int linux_ioctl_unregister_handler(struct linux_ioctl_handler *h);
308
309 /*
310 * open/fcntl flags
311 */
312 #define LINUX_O_RDONLY 00
313 #define LINUX_O_WRONLY 01
314 #define LINUX_O_RDWR 02
315 #define LINUX_O_NONBLOCK 04
316 #define LINUX_O_APPEND 010
317 #define LINUX_O_CREAT 01000
318 #define LINUX_O_TRUNC 02000
319 #define LINUX_O_EXCL 04000
320 #define LINUX_O_NOCTTY 010000
321 #define LINUX_O_NDELAY LINUX_O_NONBLOCK
322 #define LINUX_O_SYNC 040000
323
324 #define LINUX_FASYNC 020000
325
326 /* fcntl flags */
327 #define LINUX_F_DUPFD 0
328 #define LINUX_F_GETFD 1
329 #define LINUX_F_SETFD 2
330 #define LINUX_F_GETFL 3
331 #define LINUX_F_SETFL 4
332 #define LINUX_F_SETOWN 5
333 #define LINUX_F_GETOWN 6
334 #define LINUX_F_GETLK 7
335 #define LINUX_F_SETLK 8
336 #define LINUX_F_SETLKW 9
337 #define LINUX_F_SETSIG 10
338 #define LINUX_F_GETSIG 11
339
340 #define LINUX_F_RDLCK 1
341 #define LINUX_F_WRLCK 2
342 #define LINUX_F_UNLCK 8
343
344 /*
345 * mount flags
346 */
347 #define LINUX_MS_RDONLY 0x0001
348 #define LINUX_MS_NOSUID 0x0002
349 #define LINUX_MS_NODEV 0x0004
350 #define LINUX_MS_NOEXEC 0x0008
351 #define LINUX_MS_REMOUNT 0x0020
352
353 /*
354 * SystemV IPC defines
355 */
356 #define LINUX_SEMOP 1
357 #define LINUX_SEMGET 2
358 #define LINUX_SEMCTL 3
359 #define LINUX_MSGSND 11
360 #define LINUX_MSGRCV 12
361 #define LINUX_MSGGET 13
362 #define LINUX_MSGCTL 14
363 #define LINUX_SHMAT 21
364 #define LINUX_SHMDT 22
365 #define LINUX_SHMGET 23
366 #define LINUX_SHMCTL 24
367
368 #define LINUX_IPC_RMID 0
369 #define LINUX_IPC_SET 1
370 #define LINUX_IPC_STAT 2
371 #define LINUX_IPC_INFO 3
372
373 #define LINUX_SHM_LOCK 11
374 #define LINUX_SHM_UNLOCK 12
375 #define LINUX_SHM_STAT 13
376 #define LINUX_SHM_INFO 14
377
378 #define LINUX_SHM_RDONLY 0x1000
379 #define LINUX_SHM_RND 0x2000
380 #define LINUX_SHM_REMAP 0x4000
381
382 /* semctl commands */
383 #define LINUX_GETPID 11
384 #define LINUX_GETVAL 12
385 #define LINUX_GETALL 13
386 #define LINUX_GETNCNT 14
387 #define LINUX_GETZCNT 15
388 #define LINUX_SETVAL 16
389 #define LINUX_SETALL 17
390 #define LINUX_SEM_STAT 18
391 #define LINUX_SEM_INFO 19
392
393 union l_semun {
394 l_int val;
395 struct l_semid_ds *buf;
396 l_ushort *array;
397 struct l_seminfo *__buf;
398 void *__pad;
399 };
400
401 /*
402 * Socket defines
403 */
404 #define LINUX_SOCKET 1
405 #define LINUX_BIND 2
406 #define LINUX_CONNECT 3
407 #define LINUX_LISTEN 4
408 #define LINUX_ACCEPT 5
409 #define LINUX_GETSOCKNAME 6
410 #define LINUX_GETPEERNAME 7
411 #define LINUX_SOCKETPAIR 8
412 #define LINUX_SEND 9
413 #define LINUX_RECV 10
414 #define LINUX_SENDTO 11
415 #define LINUX_RECVFROM 12
416 #define LINUX_SHUTDOWN 13
417 #define LINUX_SETSOCKOPT 14
418 #define LINUX_GETSOCKOPT 15
419 #define LINUX_SENDMSG 16
420 #define LINUX_RECVMSG 17
421
422 #define LINUX_AF_UNSPEC 0
423 #define LINUX_AF_UNIX 1
424 #define LINUX_AF_INET 2
425 #define LINUX_AF_AX25 3
426 #define LINUX_AF_IPX 4
427 #define LINUX_AF_APPLETALK 5
428 #define LINUX_AF_INET6 10
429
430 #define LINUX_SOL_SOCKET 1
431 #define LINUX_SOL_IP 0
432 #define LINUX_SOL_TCP 6
433 #define LINUX_SOL_UDP 17
434 #define LINUX_SOL_IPX 256
435 #define LINUX_SOL_AX25 257
436
437 #define LINUX_SO_DEBUG 1
438 #define LINUX_SO_REUSEADDR 2
439 #define LINUX_SO_TYPE 3
440 #define LINUX_SO_ERROR 4
441 #define LINUX_SO_DONTROUTE 5
442 #define LINUX_SO_BROADCAST 6
443 #define LINUX_SO_SNDBUF 7
444 #define LINUX_SO_RCVBUF 8
445 #define LINUX_SO_KEEPALIVE 9
446 #define LINUX_SO_OOBINLINE 10
447 #define LINUX_SO_NO_CHECK 11
448 #define LINUX_SO_PRIORITY 12
449 #define LINUX_SO_LINGER 13
450
451 #define LINUX_IP_TOS 1
452 #define LINUX_IP_TTL 2
453 #define LINUX_IP_HDRINCL 3
454 #define LINUX_IP_OPTIONS 4
455
456 #define LINUX_IP_MULTICAST_IF 32
457 #define LINUX_IP_MULTICAST_TTL 33
458 #define LINUX_IP_MULTICAST_LOOP 34
459 #define LINUX_IP_ADD_MEMBERSHIP 35
460 #define LINUX_IP_DROP_MEMBERSHIP 36
461
462 struct l_sockaddr {
463 l_ushort sa_family;
464 char sa_data[14];
465 };
466
467 struct l_ifmap {
468 l_ulong mem_start;
469 l_ulong mem_end;
470 l_ushort base_addr;
471 u_char irq;
472 u_char dma;
473 u_char port;
474 };
475
476 #define LINUX_IFHWADDRLEN 6
477 #define LINUX_IFNAMSIZ 16
478
479 struct l_ifreq {
480 union {
481 char ifrn_name[LINUX_IFNAMSIZ]; /* if name, e.g. "en0" */
482 } ifr_ifrn;
483
484 union {
485 struct l_sockaddr ifru_addr;
486 struct l_sockaddr ifru_dstaddr;
487 struct l_sockaddr ifru_broadaddr;
488 struct l_sockaddr ifru_netmask;
489 struct l_sockaddr ifru_hwaddr;
490 l_short ifru_flags[1];
491 l_int ifru_metric;
492 l_int ifru_mtu;
493 struct l_ifmap ifru_map;
494 char ifru_slave[LINUX_IFNAMSIZ];
495 l_caddr_t ifru_data;
496 } ifr_ifru;
497 };
498
499 #define ifr_name ifr_ifrn.ifrn_name /* interface name */
500 #define ifr_hwaddr ifr_ifru.ifru_hwaddr /* MAC address */
501
502
503 extern char linux_sigcode[];
504 extern int linux_szsigcode;
505
506 extern struct sysent linux_sysent[LINUX_SYS_MAXSYSCALL];
507 extern struct sysentvec linux_sysvec;
508 extern struct sysentvec elf_linux_sysvec;
509
510 /* dummy struct definitions */
511 struct image_params;
512 struct trapframe;
513
514 /*
515 * poll()
516 */
517 #define LINUX_POLLIN 0x0001
518 #define LINUX_POLLPRI 0x0002
519 #define LINUX_POLLOUT 0x0004
520 #define LINUX_POLLERR 0x0008
521 #define LINUX_POLLHUP 0x0010
522 #define LINUX_POLLNVAL 0x0020
523 #define LINUX_POLLRDNORM 0x0040
524 #define LINUX_POLLRDBAND 0x0080
525 #define LINUX_POLLWRNORM 0x0100
526 #define LINUX_POLLWRBAND 0x0200
527 #define LINUX_POLLMSG 0x0400
528
529 struct l_pollfd {
530 l_int fd;
531 l_short events;
532 l_short revents;
533 };
534
535 #endif /* !_ALPHA_LINUX_LINUX_H_ */
Cache object: f07a72b7d381131fd661d5993ff58fda
|