diff options
author | marcel <marcel@FreeBSD.org> | 1999-12-04 11:10:22 +0000 |
---|---|---|
committer | marcel <marcel@FreeBSD.org> | 1999-12-04 11:10:22 +0000 |
commit | ab78406859294ed692980f9adcf75ce70f7d9e6d (patch) | |
tree | 8269a72dd31266ff6a3e1a602005fb055f1d1450 /sys | |
parent | 7abb3f060ee61c8619560641712d72752a702cd7 (diff) | |
download | FreeBSD-src-ab78406859294ed692980f9adcf75ce70f7d9e6d.zip FreeBSD-src-ab78406859294ed692980f9adcf75ce70f7d9e6d.tar.gz |
Implement pluggable ioctl handlers.
Other modules can register and unregister ioctl handlers to extend the
ioctls known by the Linuxulator. A recent application is the vmware
port. The Linuxulator itself uses the new interface to register its
handlers as well. Handlers for the following types of ioctls have been
defined:
cdrom
console (=keyboard and VT handling)
socket
sound
termio
All ioctl related defines and declarations have been moved to a new
file (linux_ioctl.h), except for the pluggable ioctl handler interface
definition.
While there, cleanup linux.h some more.
linux.h and linux_ioctl.[ch] have been made to conform to style(9) as
much as possible.
Inspired and reviewed by: Vladimir N. Silyaev
Diffstat (limited to 'sys')
-rw-r--r-- | sys/alpha/linux/linux.h | 950 | ||||
-rw-r--r-- | sys/alpha/linux/linux_ioctl.h | 418 | ||||
-rw-r--r-- | sys/alpha/linux/linux_sysvec.c | 26 | ||||
-rw-r--r-- | sys/compat/linux/linux_ioctl.c | 2370 | ||||
-rw-r--r-- | sys/compat/linux/linux_ioctl.h | 418 | ||||
-rw-r--r-- | sys/compat/linux/linux_util.h | 2 | ||||
-rw-r--r-- | sys/i386/linux/imgact_linux.c | 2 | ||||
-rw-r--r-- | sys/i386/linux/linux.h | 950 | ||||
-rw-r--r-- | sys/i386/linux/linux_ioctl.c | 2370 | ||||
-rw-r--r-- | sys/i386/linux/linux_ioctl.h | 418 | ||||
-rw-r--r-- | sys/i386/linux/linux_sysvec.c | 26 | ||||
-rw-r--r-- | sys/i386/linux/linux_util.h | 2 |
12 files changed, 4486 insertions, 3466 deletions
diff --git a/sys/alpha/linux/linux.h b/sys/alpha/linux/linux.h index d3ba6cc..528a591 100644 --- a/sys/alpha/linux/linux.h +++ b/sys/alpha/linux/linux.h @@ -29,63 +29,162 @@ */ #ifndef _I386_LINUX_LINUX_H_ -#define _I386_LINUX_LINUX_H_ +#define _I386_LINUX_LINUX_H_ #include <i386/linux/linux_syscall.h> -typedef unsigned short linux_uid_t; -typedef unsigned short linux_gid_t; -typedef unsigned short linux_dev_t; -typedef unsigned long linux_ino_t; -typedef unsigned short linux_mode_t; -typedef unsigned short linux_nlink_t; -typedef long linux_time_t; -typedef long linux_clock_t; -typedef char * linux_caddr_t; -typedef long linux_off_t; +#ifdef MALLOC_DECLARE +MALLOC_DECLARE(M_LINUX); +#endif + +/* + * Miscellaneous + */ +#define LINUX_NAME_MAX 255 +#define LINUX_MAX_UTSNAME 65 + +/* Scheduling policies */ +#define LINUX_SCHED_OTHER 0 +#define LINUX_SCHED_FIFO 1 +#define LINUX_SCHED_RR 2 + +/* Resource limits */ +#define LINUX_RLIMIT_CPU 0 +#define LINUX_RLIMIT_FSIZE 1 +#define LINUX_RLIMIT_DATA 2 +#define LINUX_RLIMIT_STACK 3 +#define LINUX_RLIMIT_CORE 4 +#define LINUX_RLIMIT_RSS 5 +#define LINUX_RLIMIT_NPROC 6 +#define LINUX_RLIMIT_NOFILE 7 +#define LINUX_RLIMIT_MEMLOCK 8 +#define LINUX_RLIMIT_AS 9 /* address space limit */ + +#define LINUX_RLIM_NLIMITS 10 + +/* mmap options */ +#define LINUX_MAP_SHARED 0x0001 +#define LINUX_MAP_PRIVATE 0x0002 +#define LINUX_MAP_FIXED 0x0010 +#define LINUX_MAP_ANON 0x0020 +#define LINUX_MAP_GROWSDOWN 0x0100 + +typedef char * linux_caddr_t; +typedef long linux_clock_t; +typedef u_short linux_dev_t; +typedef u_short linux_gid_t; +typedef u_long linux_ino_t; +typedef int linux_key_t; /* XXX */ +typedef u_short linux_mode_t; +typedef u_short linux_nlink_t; +typedef long linux_off_t; +typedef int linux_pid_t; +typedef u_int linux_size_t; +typedef long linux_time_t; +typedef u_short linux_uid_t; + typedef struct { - long val[2]; + long val[2]; } linux_fsid_t; -typedef int linux_pid_t; -typedef int linux_key_t; -typedef unsigned int linux_size_t; + +struct linux_new_utsname { + char sysname[LINUX_MAX_UTSNAME]; + char nodename[LINUX_MAX_UTSNAME]; + char release[LINUX_MAX_UTSNAME]; + char version[LINUX_MAX_UTSNAME]; + char machine[LINUX_MAX_UTSNAME]; + char domainname[LINUX_MAX_UTSNAME]; +}; /* - * Signal stuff... + * Signalling */ -typedef void (*linux_handler_t)(int); +#define LINUX_SIGHUP 1 +#define LINUX_SIGINT 2 +#define LINUX_SIGQUIT 3 +#define LINUX_SIGILL 4 +#define LINUX_SIGTRAP 5 +#define LINUX_SIGABRT 6 +#define LINUX_SIGIOT LINUX_SIGABRT +#define LINUX_SIGBUS 7 +#define LINUX_SIGFPE 8 +#define LINUX_SIGKILL 9 +#define LINUX_SIGUSR1 10 +#define LINUX_SIGSEGV 11 +#define LINUX_SIGUSR2 12 +#define LINUX_SIGPIPE 13 +#define LINUX_SIGALRM 14 +#define LINUX_SIGTERM 15 +#define LINUX_SIGSTKFLT 16 +#define LINUX_SIGCHLD 17 +#define LINUX_SIGCONT 18 +#define LINUX_SIGSTOP 19 +#define LINUX_SIGTSTP 20 +#define LINUX_SIGTTIN 21 +#define LINUX_SIGTTOU 22 +#define LINUX_SIGURG 23 +#define LINUX_SIGXCPU 24 +#define LINUX_SIGXFSZ 25 +#define LINUX_SIGVTALRM 26 +#define LINUX_SIGPROF 27 +#define LINUX_SIGWINCH 28 +#define LINUX_SIGIO 29 +#define LINUX_SIGPOLL LINUX_SIGIO +#define LINUX_SIGPWR 30 +#define LINUX_SIGUNUSED 31 + +#define LINUX_NSIG 64 +#define LINUX_SIGTBLSZ 31 -typedef unsigned long linux_osigset_t; +/* sigaction flags */ +#define LINUX_SA_NOCLDSTOP 0x00000001 +#define LINUX_SA_NOCLDWAIT 0x00000002 +#define LINUX_SA_SIGINFO 0x00000004 +#define LINUX_SA_RESTORER 0x04000000 +#define LINUX_SA_ONSTACK 0x08000000 +#define LINUX_SA_RESTART 0x10000000 +#define LINUX_SA_INTERRUPT 0x20000000 +#define LINUX_SA_NOMASK 0x40000000 +#define LINUX_SA_ONESHOT 0x80000000 + +/* sigprocmask actions */ +#define LINUX_SIG_BLOCK 0 +#define LINUX_SIG_UNBLOCK 1 +#define LINUX_SIG_SETMASK 2 + +/* sigset_t macros */ +#define LINUX_SIGEMPTYSET(set) (set).__bits[0] = (set).__bits[1] = 0 +#define LINUX_SIGISMEMBER(set, sig) SIGISMEMBER(set, sig) +#define LINUX_SIGADDSET(set, sig) SIGADDSET(set, sig) + +typedef void (*linux_handler_t)(int); +typedef u_long linux_osigset_t; typedef struct { - unsigned int __bits[2]; + u_int __bits[2]; } linux_sigset_t; typedef struct { - void (*lsa_handler)(int); + linux_handler_t lsa_handler; linux_osigset_t lsa_mask; - unsigned long lsa_flags; - void (*lsa_restorer)(void); + u_long lsa_flags; + void (*lsa_restorer)(void); } linux_osigaction_t; typedef struct { - void (*lsa_handler)(int); - unsigned long lsa_flags; - void (*lsa_restorer)(void); + linux_handler_t lsa_handler; + u_long lsa_flags; + void (*lsa_restorer)(void); linux_sigset_t lsa_mask; } linux_sigaction_t; -typedef struct -{ - void *ss_sp; - int ss_flags; +typedef struct { + void *ss_sp; + int ss_flags; linux_size_t ss_size; } linux_stack_t; -/* - * The Linux sigcontext, pretty much a standard 386 trapframe. - */ - +/* The Linux sigcontext, pretty much a standard 386 trapframe. */ struct linux_sigcontext { int sc_gs; int sc_fs; @@ -117,400 +216,95 @@ struct linux_sigcontext { * This means that we need to pass the pointer to the handler too. * It is appended to the frame to not interfere with the rest of it. */ - struct linux_sigframe { int sf_sig; struct linux_sigcontext sf_sc; - void (*sf_handler)(int); + linux_handler_t sf_handler; }; extern int bsd_to_linux_signal[]; extern int linux_to_bsd_signal[]; -/* signal numbers */ -#define LINUX_SIGHUP 1 -#define LINUX_SIGINT 2 -#define LINUX_SIGQUIT 3 -#define LINUX_SIGILL 4 -#define LINUX_SIGTRAP 5 -#define LINUX_SIGABRT 6 -#define LINUX_SIGIOT 6 -#define LINUX_SIGBUS 7 -#define LINUX_SIGFPE 8 -#define LINUX_SIGKILL 9 -#define LINUX_SIGUSR1 10 -#define LINUX_SIGSEGV 11 -#define LINUX_SIGUSR2 12 -#define LINUX_SIGPIPE 13 -#define LINUX_SIGALRM 14 -#define LINUX_SIGTERM 15 -#define LINUX_SIGSTKFLT 16 -#define LINUX_SIGCHLD 17 -#define LINUX_SIGCONT 18 -#define LINUX_SIGSTOP 19 -#define LINUX_SIGTSTP 20 -#define LINUX_SIGTTIN 21 -#define LINUX_SIGTTOU 22 -#define LINUX_SIGURG 23 -#define LINUX_SIGXCPU 24 -#define LINUX_SIGXFSZ 25 -#define LINUX_SIGVTALRM 26 -#define LINUX_SIGPROF 27 -#define LINUX_SIGWINCH 28 -#define LINUX_SIGIO 29 -#define LINUX_SIGPOLL LINUX_SIGIO -#define LINUX_SIGPWR 30 -#define LINUX_SIGUNUSED 31 -#define LINUX_NSIG 64 -#define LINUX_SIGTBLSZ 31 - -/* sigaction flags */ -#define LINUX_SA_NOCLDSTOP 0x00000001 -#define LINUX_SA_NOCLDWAIT 0x00000002 -#define LINUX_SA_SIGINFO 0x00000004 -#define LINUX_SA_RESTORER 0x04000000 -#define LINUX_SA_ONSTACK 0x08000000 -#define LINUX_SA_RESTART 0x10000000 -#define LINUX_SA_INTERRUPT 0x20000000 -#define LINUX_SA_NOMASK 0x40000000 -#define LINUX_SA_ONESHOT 0x80000000 - -/* sigprocmask actions */ -#define LINUX_SIG_BLOCK 0 -#define LINUX_SIG_UNBLOCK 1 -#define LINUX_SIG_SETMASK 2 - -#define LINUX_SIGEMPTYSET(set) (set).__bits[0] = (set).__bits[1] = 0 -#define LINUX_SIGISMEMBER(set, sig) SIGISMEMBER(set, sig) -#define LINUX_SIGADDSET(set, sig) SIGADDSET(set, sig) - -extern char linux_sigcode[]; -extern int linux_szsigcode; -extern const char linux_emul_path[]; - -extern struct sysent linux_sysent[LINUX_SYS_MAXSYSCALL]; -extern struct sysentvec linux_sysvec; -extern struct sysentvec elf_linux_sysvec; +/* + * Pluggable ioctl handlers + */ +struct linker_set; +struct linux_ioctl_args; +struct proc; -/* dummy struct definitions */ -struct image_params; -struct trapframe; +typedef int linux_ioctl_function_t(struct proc *, struct linux_ioctl_args *); -#define LINUX_MAX_UTSNAME 65 -struct linux_new_utsname { - char sysname[LINUX_MAX_UTSNAME]; - char nodename[LINUX_MAX_UTSNAME]; - char release[LINUX_MAX_UTSNAME]; - char version[LINUX_MAX_UTSNAME]; - char machine[LINUX_MAX_UTSNAME]; - char domainname[LINUX_MAX_UTSNAME]; +struct linux_ioctl_handler { + linux_ioctl_function_t *func; + int low, high; }; -/* misc defines */ -#define LINUX_NAME_MAX 255 - -/* resource limits */ -#define LINUX_RLIMIT_CPU 0 -#define LINUX_RLIMIT_FSIZE 1 -#define LINUX_RLIMIT_DATA 2 -#define LINUX_RLIMIT_STACK 3 -#define LINUX_RLIMIT_CORE 4 -#define LINUX_RLIMIT_RSS 5 -#define LINUX_RLIMIT_NPROC 6 -#define LINUX_RLIMIT_NOFILE 7 -#define LINUX_RLIMIT_MEMLOCK 8 -#define LINUX_RLIMIT_AS 9 /* address space limit */ - -#define LINUX_RLIM_NLIMITS 10 - -/* keyboard defines */ -#define LINUX_KIOCSOUND 0x4B2F -#define LINUX_KDMKTONE 0x4B30 -#define LINUX_KDGETLED 0x4B31 -#define LINUX_KDSETLED 0x4B32 -#define LINUX_LED_SCR 0x01 -#define LINUX_LED_NUM 0x02 -#define LINUX_LED_CAP 0x04 - -#define LINUX_KDGKBMODE 0x4B44 -#define LINUX_KDSKBMODE 0x4B45 -#define LINUX_KDSETMODE 0x4B3A -#define LINUX_KDGETMODE 0x4B3B -#define LINUX_KD_TEXT 0x0 -#define LINUX_KD_GRAPHICS 0x1 -#define LINUX_KD_TEXT0 0x2 -#define LINUX_KD_TEXT1 0x3 - -#define LINUX_KBD_RAW 0 -#define LINUX_KBD_XLATE 1 -#define LINUX_KBD_MEDIUMRAW 2 - -/* termio commands */ -#define LINUX_TCGETS 0x5401 -#define LINUX_TCSETS 0x5402 -#define LINUX_TCSETSW 0x5403 -#define LINUX_TCSETSF 0x5404 -#define LINUX_TCGETA 0x5405 -#define LINUX_TCSETA 0x5406 -#define LINUX_TCSETAW 0x5407 -#define LINUX_TCSETAF 0x5408 -#define LINUX_TCSBRK 0x5409 -#define LINUX_TCXONC 0x540A -#define LINUX_TCFLSH 0x540B -#define LINUX_TIOCEXCL 0x540C -#define LINUX_TIOCNXCL 0x540D -#define LINUX_TIOCSCTTY 0x540E -#define LINUX_TIOCGPGRP 0x540F -#define LINUX_TIOCSPGRP 0x5410 -#define LINUX_TIOCOUTQ 0x5411 -#define LINUX_TIOCSTI 0x5412 -#define LINUX_TIOCGWINSZ 0x5413 -#define LINUX_TIOCSWINSZ 0x5414 -#define LINUX_TIOCMGET 0x5415 -#define LINUX_TIOCMBIS 0x5416 -#define LINUX_TIOCMBIC 0x5417 -#define LINUX_TIOCMSET 0x5418 -#define LINUX_TIOCGSOFTCAR 0x5419 -#define LINUX_TIOCSSOFTCAR 0x541A -#define LINUX_FIONREAD 0x541B -#define LINUX_TIOCINQ FIONREAD -#define LINUX_TIOCLINUX 0x541C -#define LINUX_TIOCCONS 0x541D -#define LINUX_TIOCGSERIAL 0x541E -#define LINUX_TIOCSSERIAL 0x541F -#define LINUX_TIOCPKT 0x5420 -#define LINUX_FIONBIO 0x5421 -#define LINUX_TIOCNOTTY 0x5422 -#define LINUX_TIOCSETD 0x5423 -#define LINUX_TIOCGETD 0x5424 -#define LINUX_TCSBRKP 0x5425 -#define LINUX_TIOCTTYGSTRUCT 0x5426 -#define LINUX_FIONCLEX 0x5450 -#define LINUX_FIOCLEX 0x5451 -#define LINUX_FIOASYNC 0x5452 -#define LINUX_TIOCSERCONFIG 0x5453 -#define LINUX_TIOCSERGWILD 0x5454 -#define LINUX_TIOCSERSWILD 0x5455 -#define LINUX_TIOCGLCKTRMIOS 0x5456 -#define LINUX_TIOCSLCKTRMIOS 0x5457 -#define LINUX_VT_OPENQRY 0x5600 -#define LINUX_VT_GETMODE 0x5601 -#define LINUX_VT_SETMODE 0x5602 -#define LINUX_VT_GETSTATE 0x5603 -#define LINUX_VT_RELDISP 0x5605 -#define LINUX_VT_ACTIVATE 0x5606 -#define LINUX_VT_WAITACTIVE 0x5607 - -/* arguments for tcflow() and LINUX_TCXONC */ -#define LINUX_TCOOFF 0 -#define LINUX_TCOON 1 -#define LINUX_TCIOFF 2 -#define LINUX_TCION 3 - -/* arguments for tcflush() and LINUX_TCFLSH */ -#define LINUX_TCIFLUSH 0 -#define LINUX_TCOFLUSH 1 -#define LINUX_TCIOFLUSH 2 - -/* line disciplines */ -#define LINUX_N_TTY 0 -#define LINUX_N_SLIP 1 -#define LINUX_N_MOUSE 2 -#define LINUX_N_PPP 3 - -/* Linux termio c_cc values */ -#define LINUX_VINTR 0 -#define LINUX_VQUIT 1 -#define LINUX_VERASE 2 -#define LINUX_VKILL 3 -#define LINUX_VEOF 4 -#define LINUX_VTIME 5 -#define LINUX_VMIN 6 -#define LINUX_VSWTC 7 -#define LINUX_NCC 8 - -/* Linux termios c_cc values */ -#define LINUX_VSTART 8 -#define LINUX_VSTOP 9 -#define LINUX_VSUSP 10 -#define LINUX_VEOL 11 -#define LINUX_VREPRINT 12 -#define LINUX_VDISCARD 13 -#define LINUX_VWERASE 14 -#define LINUX_VLNEXT 15 -#define LINUX_VEOL2 16 -#define LINUX_NCCS 19 - -#define LINUX_POSIX_VDISABLE '\0' - -/* Linux c_iflag masks */ -#define LINUX_IGNBRK 0x0000001 -#define LINUX_BRKINT 0x0000002 -#define LINUX_IGNPAR 0x0000004 -#define LINUX_PARMRK 0x0000008 -#define LINUX_INPCK 0x0000010 -#define LINUX_ISTRIP 0x0000020 -#define LINUX_INLCR 0x0000040 -#define LINUX_IGNCR 0x0000080 -#define LINUX_ICRNL 0x0000100 -#define LINUX_IUCLC 0x0000200 -#define LINUX_IXON 0x0000400 -#define LINUX_IXANY 0x0000800 -#define LINUX_IXOFF 0x0001000 -#define LINUX_IMAXBEL 0x0002000 - -/* Linux c_oflag masks */ -#define LINUX_OPOST 0x0000001 -#define LINUX_OLCUC 0x0000002 -#define LINUX_ONLCR 0x0000004 -#define LINUX_OCRNL 0x0000008 -#define LINUX_ONOCR 0x0000010 -#define LINUX_ONLRET 0x0000020 -#define LINUX_OFILL 0x0000040 -#define LINUX_OFDEL 0x0000080 -#define LINUX_NLDLY 0x0000100 - -#define LINUX_NL0 0x0000000 -#define LINUX_NL1 0x0000100 -#define LINUX_CRDLY 0x0000600 -#define LINUX_CR0 0x0000000 -#define LINUX_CR1 0x0000200 -#define LINUX_CR2 0x0000400 -#define LINUX_CR3 0x0000600 -#define LINUX_TABDLY 0x0001800 -#define LINUX_TAB0 0x0000000 -#define LINUX_TAB1 0x0000800 -#define LINUX_TAB2 0x0001000 -#define LINUX_TAB3 0x0001800 -#define LINUX_XTABS 0x0001800 -#define LINUX_BSDLY 0x0002000 -#define LINUX_BS0 0x0000000 -#define LINUX_BS1 0x0002000 -#define LINUX_VTDLY 0x0004000 -#define LINUX_VT0 0x0000000 -#define LINUX_VT1 0x0004000 -#define LINUX_FFDLY 0x0008000 -#define LINUX_FF0 0x0000000 -#define LINUX_FF1 0x0008000 - -#define LINUX_CBAUD 0x0000100f -#define LINUX_B0 0x00000000 -#define LINUX_B50 0x00000001 -#define LINUX_B75 0x00000002 -#define LINUX_B110 0x00000003 -#define LINUX_B134 0x00000004 -#define LINUX_B150 0x00000005 -#define LINUX_B200 0x00000006 -#define LINUX_B300 0x00000007 -#define LINUX_B600 0x00000008 -#define LINUX_B1200 0x00000009 -#define LINUX_B1800 0x0000000a -#define LINUX_B2400 0x0000000b -#define LINUX_B4800 0x0000000c -#define LINUX_B9600 0x0000000d -#define LINUX_B19200 0x0000000e -#define LINUX_B38400 0x0000000f -#define LINUX_EXTA LINUX_B19200 -#define LINUX_EXTB LINUX_B38400 -#define LINUX_CBAUDEX 0x00001000 -#define LINUX_B57600 0x00001001 -#define LINUX_B115200 0x00001002 - -#define LINUX_CSIZE 0x00000030 -#define LINUX_CS5 0x00000000 -#define LINUX_CS6 0x00000010 -#define LINUX_CS7 0x00000020 -#define LINUX_CS8 0x00000030 -#define LINUX_CSTOPB 0x00000040 -#define LINUX_CREAD 0x00000080 -#define LINUX_PARENB 0x00000100 -#define LINUX_PARODD 0x00000200 -#define LINUX_HUPCL 0x00000400 -#define LINUX_CLOCAL 0x00000800 -#define LINUX_CRTSCTS 0x80000000 - -/* Linux c_lflag masks */ -#define LINUX_ISIG 0x00000001 -#define LINUX_ICANON 0x00000002 -#define LINUX_XCASE 0x00000004 -#define LINUX_ECHO 0x00000008 -#define LINUX_ECHOE 0x00000010 -#define LINUX_ECHOK 0x00000020 -#define LINUX_ECHONL 0x00000040 -#define LINUX_NOFLSH 0x00000080 -#define LINUX_TOSTOP 0x00000100 -#define LINUX_ECHOCTL 0x00000200 -#define LINUX_ECHOPRT 0x00000400 -#define LINUX_ECHOKE 0x00000800 -#define LINUX_FLUSHO 0x00001000 -#define LINUX_PENDIN 0x00002000 -#define LINUX_IEXTEN 0x00008000 - -/* open/fcntl flags */ -#define LINUX_O_RDONLY 00 -#define LINUX_O_WRONLY 01 -#define LINUX_O_RDWR 02 -#define LINUX_O_CREAT 0100 -#define LINUX_O_EXCL 0200 -#define LINUX_O_NOCTTY 0400 -#define LINUX_O_TRUNC 01000 -#define LINUX_O_APPEND 02000 -#define LINUX_O_NONBLOCK 04000 -#define LINUX_O_NDELAY LINUX_O_NONBLOCK -#define LINUX_O_SYNC 010000 -#define LINUX_FASYNC 020000 - -/* fcntl flags */ -#define LINUX_F_DUPFD 0 -#define LINUX_F_GETFD 1 -#define LINUX_F_SETFD 2 -#define LINUX_F_GETFL 3 -#define LINUX_F_SETFL 4 -#define LINUX_F_GETLK 5 -#define LINUX_F_SETLK 6 -#define LINUX_F_SETLKW 7 -#define LINUX_F_SETOWN 8 -#define LINUX_F_GETOWN 9 - -#define LINUX_F_RDLCK 0 -#define LINUX_F_WRLCK 1 -#define LINUX_F_UNLCK 2 +int linux_ioctl_register_handler(struct linux_ioctl_handler *h); +int linux_ioctl_register_handlers(struct linker_set *s); +int linux_ioctl_unregister_handler(struct linux_ioctl_handler *h); +int linux_ioctl_unregister_handlers(struct linker_set *s); -/* mmap options */ -#define LINUX_MAP_SHARED 0x0001 -#define LINUX_MAP_PRIVATE 0x0002 -#define LINUX_MAP_FIXED 0x0010 -#define LINUX_MAP_ANON 0x0020 -#define LINUX_MAP_GROWSDOWN 0x0100 - -/* SystemV ipc defines */ -#define LINUX_SEMOP 1 -#define LINUX_SEMGET 2 -#define LINUX_SEMCTL 3 -#define LINUX_MSGSND 11 -#define LINUX_MSGRCV 12 -#define LINUX_MSGGET 13 -#define LINUX_MSGCTL 14 -#define LINUX_SHMAT 21 -#define LINUX_SHMDT 22 -#define LINUX_SHMGET 23 -#define LINUX_SHMCTL 24 - -#define LINUX_IPC_RMID 0 -#define LINUX_IPC_SET 1 -#define LINUX_IPC_STAT 2 -#define LINUX_IPC_INFO 3 - -#define LINUX_SHM_LOCK 11 -#define LINUX_SHM_UNLOCK 12 -#define LINUX_SHM_STAT 13 -#define LINUX_SHM_INFO 14 - -#define LINUX_SHM_RDONLY 0x1000 -#define LINUX_SHM_RND 0x2000 -#define LINUX_SHM_REMAP 0x4000 - -/* semctl Command Definitions. */ +/* + * open/fcntl flags + */ +#define LINUX_O_RDONLY 00 +#define LINUX_O_WRONLY 01 +#define LINUX_O_RDWR 02 +#define LINUX_O_CREAT 0100 +#define LINUX_O_EXCL 0200 +#define LINUX_O_NOCTTY 0400 +#define LINUX_O_TRUNC 01000 +#define LINUX_O_APPEND 02000 +#define LINUX_O_NONBLOCK 04000 +#define LINUX_O_NDELAY LINUX_O_NONBLOCK +#define LINUX_O_SYNC 010000 +#define LINUX_FASYNC 020000 + +#define LINUX_F_DUPFD 0 +#define LINUX_F_GETFD 1 +#define LINUX_F_SETFD 2 +#define LINUX_F_GETFL 3 +#define LINUX_F_SETFL 4 +#define LINUX_F_GETLK 5 +#define LINUX_F_SETLK 6 +#define LINUX_F_SETLKW 7 +#define LINUX_F_SETOWN 8 +#define LINUX_F_GETOWN 9 + +#define LINUX_F_RDLCK 0 +#define LINUX_F_WRLCK 1 +#define LINUX_F_UNLCK 2 + +/* + * SystemV IPC defines + */ +#define LINUX_SEMOP 1 +#define LINUX_SEMGET 2 +#define LINUX_SEMCTL 3 +#define LINUX_MSGSND 11 +#define LINUX_MSGRCV 12 +#define LINUX_MSGGET 13 +#define LINUX_MSGCTL 14 +#define LINUX_SHMAT 21 +#define LINUX_SHMDT 22 +#define LINUX_SHMGET 23 +#define LINUX_SHMCTL 24 + +#define LINUX_IPC_RMID 0 +#define LINUX_IPC_SET 1 +#define LINUX_IPC_STAT 2 +#define LINUX_IPC_INFO 3 + +#define LINUX_SHM_LOCK 11 +#define LINUX_SHM_UNLOCK 12 +#define LINUX_SHM_STAT 13 +#define LINUX_SHM_INFO 14 + +#define LINUX_SHM_RDONLY 0x1000 +#define LINUX_SHM_RND 0x2000 +#define LINUX_SHM_REMAP 0x4000 + +/* semctl commands */ #define LINUX_GETPID 11 #define LINUX_GETVAL 12 #define LINUX_GETALL 13 @@ -519,246 +313,104 @@ struct linux_new_utsname { #define LINUX_SETVAL 16 #define LINUX_SETALL 17 -/* Socket defines */ -#define LINUX_SOCKET 1 -#define LINUX_BIND 2 -#define LINUX_CONNECT 3 -#define LINUX_LISTEN 4 -#define LINUX_ACCEPT 5 -#define LINUX_GETSOCKNAME 6 -#define LINUX_GETPEERNAME 7 -#define LINUX_SOCKETPAIR 8 -#define LINUX_SEND 9 -#define LINUX_RECV 10 -#define LINUX_SENDTO 11 -#define LINUX_RECVFROM 12 -#define LINUX_SHUTDOWN 13 -#define LINUX_SETSOCKOPT 14 -#define LINUX_GETSOCKOPT 15 -#define LINUX_SENDMSG 16 -#define LINUX_RECVMSG 17 - -#define LINUX_AF_UNSPEC 0 -#define LINUX_AF_UNIX 1 -#define LINUX_AF_INET 2 -#define LINUX_AF_AX25 3 -#define LINUX_AF_IPX 4 -#define LINUX_AF_APPLETALK 5 - -#define LINUX_SOL_SOCKET 1 -#define LINUX_SOL_IP 0 -#define LINUX_SOL_IPX 256 -#define LINUX_SOL_AX25 257 -#define LINUX_SOL_TCP 6 -#define LINUX_SOL_UDP 17 - -#define LINUX_SO_DEBUG 1 -#define LINUX_SO_REUSEADDR 2 -#define LINUX_SO_TYPE 3 -#define LINUX_SO_ERROR 4 -#define LINUX_SO_DONTROUTE 5 -#define LINUX_SO_BROADCAST 6 -#define LINUX_SO_SNDBUF 7 -#define LINUX_SO_RCVBUF 8 -#define LINUX_SO_KEEPALIVE 9 -#define LINUX_SO_OOBINLINE 10 -#define LINUX_SO_NO_CHECK 11 -#define LINUX_SO_PRIORITY 12 -#define LINUX_SO_LINGER 13 - -#define LINUX_IP_TOS 1 -#define LINUX_IP_TTL 2 -#define LINUX_IP_HDRINCL 3 -#define LINUX_IP_OPTIONS 4 - -#define LINUX_IP_MULTICAST_IF 32 -#define LINUX_IP_MULTICAST_TTL 33 -#define LINUX_IP_MULTICAST_LOOP 34 -#define LINUX_IP_ADD_MEMBERSHIP 35 -#define LINUX_IP_DROP_MEMBERSHIP 36 - -/* Sound system defines */ -#define LINUX_SNDCTL_SEQ_RESET 0x5100 -#define LINUX_SNDCTL_SEQ_SYNC 0x5101 -#define LINUX_SNDCTL_SYNTH_INFO 0x5102 -#define LINUX_SNDCTL_SEQ_CTRLRATE 0x5103 -#define LINUX_SNDCTL_SEQ_GETOUTCOUNT 0x5104 -#define LINUX_SNDCTL_SEQ_GETINCOUNT 0x5105 -#define LINUX_SNDCTL_SEQ_PERCMODE 0x5106 -#define LINUX_SNDCTL_FM_LOAD_INSTR 0x5107 -#define LINUX_SNDCTL_SEQ_TESTMIDI 0x5108 -#define LINUX_SNDCTL_SEQ_RESETSAMPLES 0x5109 -#define LINUX_SNDCTL_SEQ_NRSYNTHS 0x510A -#define LINUX_SNDCTL_SEQ_NRMIDIS 0x510B -#define LINUX_SNDCTL_MIDI_INFO 0x510C -#define LINUX_SNDCTL_SEQ_TRESHOLD 0x510D -#define LINUX_SNDCTL_SYNTH_MEMAVL 0x510E -#define LINUX_SNDCTL_DSP_RESET 0x5000 -#define LINUX_SNDCTL_DSP_SYNC 0x5001 -#define LINUX_SNDCTL_DSP_SPEED 0x5002 -#define LINUX_SNDCTL_DSP_STEREO 0x5003 -#define LINUX_SNDCTL_DSP_GETBLKSIZE 0x5004 -#define LINUX_SNDCTL_DSP_SETBLKSIZE 0x5004 -#define LINUX_SNDCTL_DSP_SETFMT 0x5005 -#define LINUX_SOUND_PCM_WRITE_CHANNELS 0x5006 -#define LINUX_SOUND_PCM_WRITE_FILTER 0x5007 -#define LINUX_SNDCTL_DSP_POST 0x5008 -#define LINUX_SNDCTL_DSP_SUBDIVIDE 0x5009 -#define LINUX_SNDCTL_DSP_SETFRAGMENT 0x500A -#define LINUX_SNDCTL_DSP_GETFMTS 0x500B -#define LINUX_SNDCTL_DSP_GETOSPACE 0x500C -#define LINUX_SNDCTL_DSP_GETISPACE 0x500D -#define LINUX_SNDCTL_DSP_NONBLOCK 0x500E -#define LINUX_SNDCTL_DSP_GETCAPS 0x500F -#define LINUX_SNDCTL_DSP_GETTRIGGER 0x5010 -#define LINUX_SNDCTL_DSP_SETTRIGGER 0x5010 -#define LINUX_SNDCTL_DSP_GETIPTR 0x5011 -#define LINUX_SNDCTL_DSP_GETOPTR 0x5012 -#define LINUX_SNDCTL_DSP_GETODELAY 0x5017 -#define LINUX_SOUND_MIXER_WRITE_VOLUME 0x4d00 -#define LINUX_SOUND_MIXER_WRITE_BASS 0x4d01 -#define LINUX_SOUND_MIXER_WRITE_TREBLE 0x4d02 -#define LINUX_SOUND_MIXER_WRITE_SYNTH 0x4d03 -#define LINUX_SOUND_MIXER_WRITE_PCM 0x4d04 -#define LINUX_SOUND_MIXER_WRITE_SPEAKER 0x4d05 -#define LINUX_SOUND_MIXER_WRITE_LINE 0x4d06 -#define LINUX_SOUND_MIXER_WRITE_MIC 0x4d07 -#define LINUX_SOUND_MIXER_WRITE_CD 0x4d08 -#define LINUX_SOUND_MIXER_WRITE_IMIX 0x4d09 -#define LINUX_SOUND_MIXER_WRITE_ALTPCM 0x4d0A -#define LINUX_SOUND_MIXER_WRITE_RECLEV 0x4d0B -#define LINUX_SOUND_MIXER_WRITE_IGAIN 0x4d0C -#define LINUX_SOUND_MIXER_WRITE_OGAIN 0x4d0D -#define LINUX_SOUND_MIXER_WRITE_LINE1 0x4d0E -#define LINUX_SOUND_MIXER_WRITE_LINE2 0x4d0F -#define LINUX_SOUND_MIXER_WRITE_LINE3 0x4d10 -#define LINUX_SOUND_MIXER_READ_DEVMASK 0x4dfe - -#define LINUX_OSS_GETVERSION 0x4d76 - -/* Socket system defines */ -#define LINUX_FIOSETOWN 0x8901 -#define LINUX_SIOCSPGRP 0x8902 -#define LINUX_FIOGETOWN 0x8903 -#define LINUX_SIOCGPGRP 0x8904 -#define LINUX_SIOCATMARK 0x8905 -#define LINUX_SIOCGSTAMP 0x8906 -#define LINUX_SIOCGIFCONF 0x8912 -#define LINUX_SIOCGIFFLAGS 0x8913 -#define LINUX_SIOCGIFADDR 0x8915 -#define LINUX_SIOCGIFDSTADDR 0x8917 -#define LINUX_SIOCGIFBRDADDR 0x8919 -#define LINUX_SIOCGIFNETMASK 0x891b -#define LINUX_SIOCGIFHWADDR 0x8927 -#define LINUX_SIOCADDMULTI 0x8931 -#define LINUX_SIOCDELMULTI 0x8932 - -struct linux_sockaddr -{ - unsigned short sa_family; - char sa_data[14]; +/* + * Socket defines + */ +#define LINUX_SOCKET 1 +#define LINUX_BIND 2 +#define LINUX_CONNECT 3 +#define LINUX_LISTEN 4 +#define LINUX_ACCEPT 5 +#define LINUX_GETSOCKNAME 6 +#define LINUX_GETPEERNAME 7 +#define LINUX_SOCKETPAIR 8 +#define LINUX_SEND 9 +#define LINUX_RECV 10 +#define LINUX_SENDTO 11 +#define LINUX_RECVFROM 12 +#define LINUX_SHUTDOWN 13 +#define LINUX_SETSOCKOPT 14 +#define LINUX_GETSOCKOPT 15 +#define LINUX_SENDMSG 16 +#define LINUX_RECVMSG 17 + +#define LINUX_AF_UNSPEC 0 +#define LINUX_AF_UNIX 1 +#define LINUX_AF_INET 2 +#define LINUX_AF_AX25 3 +#define LINUX_AF_IPX 4 +#define LINUX_AF_APPLETALK 5 + +#define LINUX_SOL_SOCKET 1 +#define LINUX_SOL_IP 0 +#define LINUX_SOL_IPX 256 +#define LINUX_SOL_AX25 257 +#define LINUX_SOL_TCP 6 +#define LINUX_SOL_UDP 17 + +#define LINUX_SO_DEBUG 1 +#define LINUX_SO_REUSEADDR 2 +#define LINUX_SO_TYPE 3 +#define LINUX_SO_ERROR 4 +#define LINUX_SO_DONTROUTE 5 +#define LINUX_SO_BROADCAST 6 +#define LINUX_SO_SNDBUF 7 +#define LINUX_SO_RCVBUF 8 +#define LINUX_SO_KEEPALIVE 9 +#define LINUX_SO_OOBINLINE 10 +#define LINUX_SO_NO_CHECK 11 +#define LINUX_SO_PRIORITY 12 +#define LINUX_SO_LINGER 13 + +#define LINUX_IP_TOS 1 +#define LINUX_IP_TTL 2 +#define LINUX_IP_HDRINCL 3 +#define LINUX_IP_OPTIONS 4 + +#define LINUX_IP_MULTICAST_IF 32 +#define LINUX_IP_MULTICAST_TTL 33 +#define LINUX_IP_MULTICAST_LOOP 34 +#define LINUX_IP_ADD_MEMBERSHIP 35 +#define LINUX_IP_DROP_MEMBERSHIP 36 + +struct linux_sockaddr { + u_short sa_family; + char sa_data[14]; }; -struct linux_ifmap -{ - unsigned long mem_start; - unsigned long mem_end; - unsigned short base_addr; - unsigned char irq; - unsigned char dma; - unsigned char port; +struct linux_ifmap { + u_long mem_start; + u_long mem_end; + u_short base_addr; + u_char irq; + u_char dma; + u_char port; }; -struct linux_ifreq -{ -#define LINUX_IFHWADDRLEN 6 -#define LINUX_IFNAMSIZ 16 - union - { - char ifrn_name[LINUX_IFNAMSIZ]; /* if name, e.g. "en0" */ - } ifr_ifrn; - - union { - struct linux_sockaddr ifru_addr; - struct linux_sockaddr ifru_dstaddr; - struct linux_sockaddr ifru_broadaddr; - struct linux_sockaddr ifru_netmask; - struct linux_sockaddr ifru_hwaddr; - short ifru_flags; - int ifru_metric; - int ifru_mtu; - struct linux_ifmap ifru_map; - char ifru_slave[LINUX_IFNAMSIZ]; /* Just fits the size */ - caddr_t ifru_data; - } ifr_ifru; +#define LINUX_IFHWADDRLEN 6 +#define LINUX_IFNAMSIZ 16 + +struct linux_ifreq { + union { + char ifrn_name[LINUX_IFNAMSIZ]; + } ifr_ifrn; + + union { + struct linux_sockaddr ifru_addr; + struct linux_sockaddr ifru_dstaddr; + struct linux_sockaddr ifru_broadaddr; + struct linux_sockaddr ifru_netmask; + struct linux_sockaddr ifru_hwaddr; + short ifru_flags; + int ifru_metric; + int ifru_mtu; + struct linux_ifmap ifru_map; + char ifru_slave[LINUX_IFNAMSIZ]; /* Just fits the size */ + linux_caddr_t ifru_data; + } ifr_ifru; }; -#define ifr_name ifr_ifrn.ifrn_name /* interface name */ -#define ifr_hwaddr ifr_ifru.ifru_hwaddr /* MAC address */ - - -/* serial_struct values for TIOC[GS]SERIAL ioctls */ -#define LINUX_ASYNC_CLOSING_WAIT_INF 0 -#define LINUX_ASYNC_CLOSING_WAIT_NONE 65535 - -#define LINUX_PORT_UNKNOWN 0 -#define LINUX_PORT_8250 1 -#define LINUX_PORT_16450 2 -#define LINUX_PORT_16550 3 -#define LINUX_PORT_16550A 4 -#define LINUX_PORT_CIRRUS 5 -#define LINUX_PORT_16650 6 -#define LINUX_PORT_MAX 6 - -#define LINUX_ASYNC_HUP_NOTIFY 0x0001 -#define LINUX_ASYNC_FOURPORT 0x0002 -#define LINUX_ASYNC_SAK 0x0004 -#define LINUX_ASYNC_SPLIT_TERMIOS 0x0008 -#define LINUX_ASYNC_SPD_MASK 0x0030 -#define LINUX_ASYNC_SPD_HI 0x0010 -#define LINUX_ASYNC_SPD_VHI 0x0020 -#define LINUX_ASYNC_SPD_CUST 0x0030 -#define LINUX_ASYNC_SKIP_TEST 0x0040 -#define LINUX_ASYNC_AUTO_IRQ 0x0080 -#define LINUX_ASYNC_SESSION_LOCKOUT 0x0100 -#define LINUX_ASYNC_PGRP_LOCKOUT 0x0200 -#define LINUX_ASYNC_CALLOUT_NOHUP 0x0400 -#define LINUX_ASYNC_FLAGS 0x0FFF - -/* cdrom */ -#define LINUX_CDROMPAUSE 0x5301 -#define LINUX_CDROMRESUME 0x5302 -#define LINUX_CDROMPLAYMSF 0x5303 -#define LINUX_CDROMPLAYTRKIND 0x5304 -#define LINUX_CDROMREADTOCHDR 0x5305 -#define LINUX_CDROMREADTOCENTRY 0x5306 -#define LINUX_CDROMSTOP 0x5307 -#define LINUX_CDROMSTART 0x5308 -#define LINUX_CDROMEJECT 0x5309 -#define LINUX_CDROMVOLCTRL 0x530a -#define LINUX_CDROMSUBCHNL 0x530b -#define LINUX_CDROMREADMODE2 0x530c -#define LINUX_CDROMREADMODE1 0x530d -#define LINUX_CDROMREADAUDIO 0x530e -#define LINUX_CDROMEJECT_SW 0x530f -#define LINUX_CDROMMULTISESSION 0x5310 -#define LINUX_CDROM_GET_UPC 0x5311 -#define LINUX_CDROMRESET 0x5312 -#define LINUX_CDROMVOLREAD 0x5313 -#define LINUX_CDROMREADRAW 0x5314 -#define LINUX_CDROMREADCOOKED 0x5315 -#define LINUX_CDROMSEEK 0x5316 -#define LINUX_CDROMPLAYBLK 0x5317 -#define LINUX_CDROMREADALL 0x5318 -#define LINUX_CDROMCLOSETRAY 0x5319 -#define LINUX_CDROMLOADFROMSLOT 0x531a - -#define LINUX_CDROM_LBA 0x01 -#define LINUX_CDROM_MSF 0x02 - -/* Scheduling policies */ -#define LINUX_SCHED_OTHER 0 -#define LINUX_SCHED_FIFO 1 -#define LINUX_SCHED_RR 2 +#define ifr_name ifr_ifrn.ifrn_name /* interface name */ +#define ifr_hwaddr ifr_ifru.ifru_hwaddr /* MAC address */ #endif /* !_I386_LINUX_LINUX_H_ */ diff --git a/sys/alpha/linux/linux_ioctl.h b/sys/alpha/linux/linux_ioctl.h new file mode 100644 index 0000000..fd637b4 --- /dev/null +++ b/sys/alpha/linux/linux_ioctl.h @@ -0,0 +1,418 @@ +/*- + * Copyright (c) 1999 Marcel Moolenaar + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer + * in this position and unchanged. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software withough specific prior written permission + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#ifndef _LINUX_IOCTL_H_ +#define _LINUX_IOCTL_H_ + +/* + * cdrom + */ +#define LINUX_CDROMPAUSE 0x5301 +#define LINUX_CDROMRESUME 0x5302 +#define LINUX_CDROMPLAYMSF 0x5303 +#define LINUX_CDROMPLAYTRKIND 0x5304 +#define LINUX_CDROMREADTOCHDR 0x5305 +#define LINUX_CDROMREADTOCENTRY 0x5306 +#define LINUX_CDROMSTOP 0x5307 +#define LINUX_CDROMSTART 0x5308 +#define LINUX_CDROMEJECT 0x5309 +#define LINUX_CDROMVOLCTRL 0x530a +#define LINUX_CDROMSUBCHNL 0x530b +#define LINUX_CDROMREADMODE2 0x530c +#define LINUX_CDROMREADMODE1 0x530d +#define LINUX_CDROMREADAUDIO 0x530e +#define LINUX_CDROMEJECT_SW 0x530f +#define LINUX_CDROMMULTISESSION 0x5310 +#define LINUX_CDROM_GET_UPC 0x5311 +#define LINUX_CDROMRESET 0x5312 +#define LINUX_CDROMVOLREAD 0x5313 +#define LINUX_CDROMREADRAW 0x5314 +#define LINUX_CDROMREADCOOKED 0x5315 +#define LINUX_CDROMSEEK 0x5316 +#define LINUX_CDROMPLAYBLK 0x5317 +#define LINUX_CDROMREADALL 0x5318 +#define LINUX_CDROMCLOSETRAY 0x5319 +#define LINUX_CDROMLOADFROMSLOT 0x531a + +#define LINUX_IOCTL_CDROM_MIN LINUX_CDROMPAUSE +#define LINUX_IOCTL_CDROM_MAX LINUX_CDROMLOADFROMSLOT + +#define LINUX_CDROM_LBA 0x01 +#define LINUX_CDROM_MSF 0x02 + +/* + * console + */ +#define LINUX_KIOCSOUND 0x4B2F +#define LINUX_KDMKTONE 0x4B30 +#define LINUX_KDGETLED 0x4B31 +#define LINUX_KDSETLED 0x4B32 +#define LINUX_KDSETMODE 0x4B3A +#define LINUX_KDGETMODE 0x4B3B +#define LINUX_KDGKBMODE 0x4B44 +#define LINUX_KDSKBMODE 0x4B45 +#define LINUX_VT_OPENQRY 0x5600 +#define LINUX_VT_GETMODE 0x5601 +#define LINUX_VT_SETMODE 0x5602 +#define LINUX_VT_GETSTATE 0x5603 +#define LINUX_VT_RELDISP 0x5605 +#define LINUX_VT_ACTIVATE 0x5606 +#define LINUX_VT_WAITACTIVE 0x5607 + +#define LINUX_IOCTL_CONSOLE_MIN LINUX_KIOCSOUND +#define LINUX_IOCTL_CONSOLE_MAX LINUX_VT_WAITACTIVE + +#define LINUX_LED_SCR 0x01 +#define LINUX_LED_NUM 0x02 +#define LINUX_LED_CAP 0x04 + +#define LINUX_KD_TEXT 0x0 +#define LINUX_KD_GRAPHICS 0x1 +#define LINUX_KD_TEXT0 0x2 +#define LINUX_KD_TEXT1 0x3 + +#define LINUX_KBD_RAW 0 +#define LINUX_KBD_XLATE 1 +#define LINUX_KBD_MEDIUMRAW 2 + +/* + * socket + */ +#define LINUX_FIOSETOWN 0x8901 +#define LINUX_SIOCSPGRP 0x8902 +#define LINUX_FIOGETOWN 0x8903 +#define LINUX_SIOCGPGRP 0x8904 +#define LINUX_SIOCATMARK 0x8905 +#define LINUX_SIOCGSTAMP 0x8906 +#define LINUX_SIOCGIFCONF 0x8912 +#define LINUX_SIOCGIFFLAGS 0x8913 +#define LINUX_SIOCGIFADDR 0x8915 +#define LINUX_SIOCGIFDSTADDR 0x8917 +#define LINUX_SIOCGIFBRDADDR 0x8919 +#define LINUX_SIOCGIFNETMASK 0x891b +#define LINUX_SIOCGIFHWADDR 0x8927 +#define LINUX_SIOCADDMULTI 0x8931 +#define LINUX_SIOCDELMULTI 0x8932 + +#define LINUX_IOCTL_SOCKET_MIN LINUX_FIOSETOWN +#define LINUX_IOCTL_SOCKET_MAX LINUX_SIOCDELMULTI + +/* + * sound + */ +#define LINUX_SOUND_MIXER_WRITE_VOLUME 0x4d00 +#define LINUX_SOUND_MIXER_WRITE_BASS 0x4d01 +#define LINUX_SOUND_MIXER_WRITE_TREBLE 0x4d02 +#define LINUX_SOUND_MIXER_WRITE_SYNTH 0x4d03 +#define LINUX_SOUND_MIXER_WRITE_PCM 0x4d04 +#define LINUX_SOUND_MIXER_WRITE_SPEAKER 0x4d05 +#define LINUX_SOUND_MIXER_WRITE_LINE 0x4d06 +#define LINUX_SOUND_MIXER_WRITE_MIC 0x4d07 +#define LINUX_SOUND_MIXER_WRITE_CD 0x4d08 +#define LINUX_SOUND_MIXER_WRITE_IMIX 0x4d09 +#define LINUX_SOUND_MIXER_WRITE_ALTPCM 0x4d0A +#define LINUX_SOUND_MIXER_WRITE_RECLEV 0x4d0B +#define LINUX_SOUND_MIXER_WRITE_IGAIN 0x4d0C +#define LINUX_SOUND_MIXER_WRITE_OGAIN 0x4d0D +#define LINUX_SOUND_MIXER_WRITE_LINE1 0x4d0E +#define LINUX_SOUND_MIXER_WRITE_LINE2 0x4d0F +#define LINUX_SOUND_MIXER_WRITE_LINE3 0x4d10 +#define LINUX_OSS_GETVERSION 0x4d76 +#define LINUX_SOUND_MIXER_READ_DEVMASK 0x4dfe +#define LINUX_SNDCTL_DSP_RESET 0x5000 +#define LINUX_SNDCTL_DSP_SYNC 0x5001 +#define LINUX_SNDCTL_DSP_SPEED 0x5002 +#define LINUX_SNDCTL_DSP_STEREO 0x5003 +#define LINUX_SNDCTL_DSP_GETBLKSIZE 0x5004 +#define LINUX_SNDCTL_DSP_SETBLKSIZE LINUX_SNDCTL_DSP_GETBLKSIZE +#define LINUX_SNDCTL_DSP_SETFMT 0x5005 +#define LINUX_SOUND_PCM_WRITE_CHANNELS 0x5006 +#define LINUX_SOUND_PCM_WRITE_FILTER 0x5007 +#define LINUX_SNDCTL_DSP_POST 0x5008 +#define LINUX_SNDCTL_DSP_SUBDIVIDE 0x5009 +#define LINUX_SNDCTL_DSP_SETFRAGMENT 0x500A +#define LINUX_SNDCTL_DSP_GETFMTS 0x500B +#define LINUX_SNDCTL_DSP_GETOSPACE 0x500C +#define LINUX_SNDCTL_DSP_GETISPACE 0x500D +#define LINUX_SNDCTL_DSP_NONBLOCK 0x500E +#define LINUX_SNDCTL_DSP_GETCAPS 0x500F +#define LINUX_SNDCTL_DSP_GETTRIGGER 0x5010 +#define LINUX_SNDCTL_DSP_SETTRIGGER LINUX_SNDCTL_DSP_GETTRIGGER +#define LINUX_SNDCTL_DSP_GETIPTR 0x5011 +#define LINUX_SNDCTL_DSP_GETOPTR 0x5012 +#define LINUX_SNDCTL_DSP_GETODELAY 0x5017 +#define LINUX_SNDCTL_SEQ_RESET 0x5100 +#define LINUX_SNDCTL_SEQ_SYNC 0x5101 +#define LINUX_SNDCTL_SYNTH_INFO 0x5102 +#define LINUX_SNDCTL_SEQ_CTRLRATE 0x5103 +#define LINUX_SNDCTL_SEQ_GETOUTCOUNT 0x5104 +#define LINUX_SNDCTL_SEQ_GETINCOUNT 0x5105 +#define LINUX_SNDCTL_SEQ_PERCMODE 0x5106 +#define LINUX_SNDCTL_FM_LOAD_INSTR 0x5107 +#define LINUX_SNDCTL_SEQ_TESTMIDI 0x5108 +#define LINUX_SNDCTL_SEQ_RESETSAMPLES 0x5109 +#define LINUX_SNDCTL_SEQ_NRSYNTHS 0x510A +#define LINUX_SNDCTL_SEQ_NRMIDIS 0x510B +#define LINUX_SNDCTL_MIDI_INFO 0x510C +#define LINUX_SNDCTL_SEQ_TRESHOLD 0x510D +#define LINUX_SNDCTL_SYNTH_MEMAVL 0x510E + +#define LINUX_IOCTL_SOUND_MIN LINUX_SOUND_MIXER_WRITE_VOLUME +#define LINUX_IOCTL_SOUND_MAX LINUX_SNDCTL_SYNTH_MEMAVL + +/* + * termio + */ +#define LINUX_TCGETS 0x5401 +#define LINUX_TCSETS 0x5402 +#define LINUX_TCSETSW 0x5403 +#define LINUX_TCSETSF 0x5404 +#define LINUX_TCGETA 0x5405 +#define LINUX_TCSETA 0x5406 +#define LINUX_TCSETAW 0x5407 +#define LINUX_TCSETAF 0x5408 +#define LINUX_TCSBRK 0x5409 +#define LINUX_TCXONC 0x540A +#define LINUX_TCFLSH 0x540B +#define LINUX_TIOCEXCL 0x540C +#define LINUX_TIOCNXCL 0x540D +#define LINUX_TIOCSCTTY 0x540E +#define LINUX_TIOCGPGRP 0x540F +#define LINUX_TIOCSPGRP 0x5410 +#define LINUX_TIOCOUTQ 0x5411 +#define LINUX_TIOCSTI 0x5412 +#define LINUX_TIOCGWINSZ 0x5413 +#define LINUX_TIOCSWINSZ 0x5414 +#define LINUX_TIOCMGET 0x5415 +#define LINUX_TIOCMBIS 0x5416 +#define LINUX_TIOCMBIC 0x5417 +#define LINUX_TIOCMSET 0x5418 +#define LINUX_TIOCGSOFTCAR 0x5419 +#define LINUX_TIOCSSOFTCAR 0x541A +#define LINUX_FIONREAD 0x541B +#define LINUX_TIOCINQ FIONREAD +#define LINUX_TIOCLINUX 0x541C +#define LINUX_TIOCCONS 0x541D +#define LINUX_TIOCGSERIAL 0x541E +#define LINUX_TIOCSSERIAL 0x541F +#define LINUX_TIOCPKT 0x5420 +#define LINUX_FIONBIO 0x5421 +#define LINUX_TIOCNOTTY 0x5422 +#define LINUX_TIOCSETD 0x5423 +#define LINUX_TIOCGETD 0x5424 +#define LINUX_TCSBRKP 0x5425 +#define LINUX_TIOCTTYGSTRUCT 0x5426 +#define LINUX_FIONCLEX 0x5450 +#define LINUX_FIOCLEX 0x5451 +#define LINUX_FIOASYNC 0x5452 +#define LINUX_TIOCSERCONFIG 0x5453 +#define LINUX_TIOCSERGWILD 0x5454 +#define LINUX_TIOCSERSWILD 0x5455 +#define LINUX_TIOCGLCKTRMIOS 0x5456 +#define LINUX_TIOCSLCKTRMIOS 0x5457 + +#define LINUX_IOCTL_TERMIO_MIN LINUX_TCGETS +#define LINUX_IOCTL_TERMIO_MAX LINUX_TIOCSLCKTRMIOS + +/* arguments for tcflow() and LINUX_TCXONC */ +#define LINUX_TCOOFF 0 +#define LINUX_TCOON 1 +#define LINUX_TCIOFF 2 +#define LINUX_TCION 3 + +/* arguments for tcflush() and LINUX_TCFLSH */ +#define LINUX_TCIFLUSH 0 +#define LINUX_TCOFLUSH 1 +#define LINUX_TCIOFLUSH 2 + +/* line disciplines */ +#define LINUX_N_TTY 0 +#define LINUX_N_SLIP 1 +#define LINUX_N_MOUSE 2 +#define LINUX_N_PPP 3 + +/* Linux termio c_cc values */ +#define LINUX_VINTR 0 +#define LINUX_VQUIT 1 +#define LINUX_VERASE 2 +#define LINUX_VKILL 3 +#define LINUX_VEOF 4 +#define LINUX_VTIME 5 +#define LINUX_VMIN 6 +#define LINUX_VSWTC 7 +#define LINUX_NCC 8 + +/* Linux termios c_cc values */ +#define LINUX_VSTART 8 +#define LINUX_VSTOP 9 +#define LINUX_VSUSP 10 +#define LINUX_VEOL 11 +#define LINUX_VREPRINT 12 +#define LINUX_VDISCARD 13 +#define LINUX_VWERASE 14 +#define LINUX_VLNEXT 15 +#define LINUX_VEOL2 16 +#define LINUX_NCCS 19 + +#define LINUX_POSIX_VDISABLE '\0' + +/* Linux c_iflag masks */ +#define LINUX_IGNBRK 0x0000001 +#define LINUX_BRKINT 0x0000002 +#define LINUX_IGNPAR 0x0000004 +#define LINUX_PARMRK 0x0000008 +#define LINUX_INPCK 0x0000010 +#define LINUX_ISTRIP 0x0000020 +#define LINUX_INLCR 0x0000040 +#define LINUX_IGNCR 0x0000080 +#define LINUX_ICRNL 0x0000100 +#define LINUX_IUCLC 0x0000200 +#define LINUX_IXON 0x0000400 +#define LINUX_IXANY 0x0000800 +#define LINUX_IXOFF 0x0001000 +#define LINUX_IMAXBEL 0x0002000 + +/* Linux c_oflag masks */ +#define LINUX_OPOST 0x0000001 +#define LINUX_OLCUC 0x0000002 +#define LINUX_ONLCR 0x0000004 +#define LINUX_OCRNL 0x0000008 +#define LINUX_ONOCR 0x0000010 +#define LINUX_ONLRET 0x0000020 +#define LINUX_OFILL 0x0000040 +#define LINUX_OFDEL 0x0000080 +#define LINUX_NLDLY 0x0000100 + +#define LINUX_NL0 0x0000000 +#define LINUX_NL1 0x0000100 +#define LINUX_CRDLY 0x0000600 +#define LINUX_CR0 0x0000000 +#define LINUX_CR1 0x0000200 +#define LINUX_CR2 0x0000400 +#define LINUX_CR3 0x0000600 +#define LINUX_TABDLY 0x0001800 +#define LINUX_TAB0 0x0000000 +#define LINUX_TAB1 0x0000800 +#define LINUX_TAB2 0x0001000 +#define LINUX_TAB3 0x0001800 +#define LINUX_XTABS 0x0001800 +#define LINUX_BSDLY 0x0002000 +#define LINUX_BS0 0x0000000 +#define LINUX_BS1 0x0002000 +#define LINUX_VTDLY 0x0004000 +#define LINUX_VT0 0x0000000 +#define LINUX_VT1 0x0004000 +#define LINUX_FFDLY 0x0008000 +#define LINUX_FF0 0x0000000 +#define LINUX_FF1 0x0008000 + +#define LINUX_CBAUD 0x0000100f +#define LINUX_B0 0x00000000 +#define LINUX_B50 0x00000001 +#define LINUX_B75 0x00000002 +#define LINUX_B110 0x00000003 +#define LINUX_B134 0x00000004 +#define LINUX_B150 0x00000005 +#define LINUX_B200 0x00000006 +#define LINUX_B300 0x00000007 +#define LINUX_B600 0x00000008 +#define LINUX_B1200 0x00000009 +#define LINUX_B1800 0x0000000a +#define LINUX_B2400 0x0000000b +#define LINUX_B4800 0x0000000c +#define LINUX_B9600 0x0000000d +#define LINUX_B19200 0x0000000e +#define LINUX_B38400 0x0000000f +#define LINUX_EXTA LINUX_B19200 +#define LINUX_EXTB LINUX_B38400 +#define LINUX_CBAUDEX 0x00001000 +#define LINUX_B57600 0x00001001 +#define LINUX_B115200 0x00001002 + +#define LINUX_CSIZE 0x00000030 +#define LINUX_CS5 0x00000000 +#define LINUX_CS6 0x00000010 +#define LINUX_CS7 0x00000020 +#define LINUX_CS8 0x00000030 +#define LINUX_CSTOPB 0x00000040 +#define LINUX_CREAD 0x00000080 +#define LINUX_PARENB 0x00000100 +#define LINUX_PARODD 0x00000200 +#define LINUX_HUPCL 0x00000400 +#define LINUX_CLOCAL 0x00000800 +#define LINUX_CRTSCTS 0x80000000 + +/* Linux c_lflag masks */ +#define LINUX_ISIG 0x00000001 +#define LINUX_ICANON 0x00000002 +#define LINUX_XCASE 0x00000004 +#define LINUX_ECHO 0x00000008 +#define LINUX_ECHOE 0x00000010 +#define LINUX_ECHOK 0x00000020 +#define LINUX_ECHONL 0x00000040 +#define LINUX_NOFLSH 0x00000080 +#define LINUX_TOSTOP 0x00000100 +#define LINUX_ECHOCTL 0x00000200 +#define LINUX_ECHOPRT 0x00000400 +#define LINUX_ECHOKE 0x00000800 +#define LINUX_FLUSHO 0x00001000 +#define LINUX_PENDIN 0x00002000 +#define LINUX_IEXTEN 0x00008000 + +/* serial_struct values for TIOC[GS]SERIAL ioctls */ +#define LINUX_ASYNC_CLOSING_WAIT_INF 0 +#define LINUX_ASYNC_CLOSING_WAIT_NONE 65535 + +#define LINUX_PORT_UNKNOWN 0 +#define LINUX_PORT_8250 1 +#define LINUX_PORT_16450 2 +#define LINUX_PORT_16550 3 +#define LINUX_PORT_16550A 4 +#define LINUX_PORT_CIRRUS 5 +#define LINUX_PORT_16650 6 + +#define LINUX_PORT_MAX 6 + +#define LINUX_ASYNC_HUP_NOTIFY 0x0001 +#define LINUX_ASYNC_FOURPORT 0x0002 +#define LINUX_ASYNC_SAK 0x0004 +#define LINUX_ASYNC_SPLIT_TERMIOS 0x0008 +#define LINUX_ASYNC_SPD_MASK 0x0030 +#define LINUX_ASYNC_SPD_HI 0x0010 +#define LINUX_ASYNC_SPD_VHI 0x0020 +#define LINUX_ASYNC_SPD_CUST 0x0030 +#define LINUX_ASYNC_SKIP_TEST 0x0040 +#define LINUX_ASYNC_AUTO_IRQ 0x0080 +#define LINUX_ASYNC_SESSION_LOCKOUT 0x0100 +#define LINUX_ASYNC_PGRP_LOCKOUT 0x0200 +#define LINUX_ASYNC_CALLOUT_NOHUP 0x0400 +#define LINUX_ASYNC_FLAGS 0x0FFF + +#endif /* !_LINUX_IOCTL_H_ */ diff --git a/sys/alpha/linux/linux_sysvec.c b/sys/alpha/linux/linux_sysvec.c index eaf2a04..76be2b4 100644 --- a/sys/alpha/linux/linux_sysvec.c +++ b/sys/alpha/linux/linux_sysvec.c @@ -57,6 +57,15 @@ #include <i386/linux/linux.h> #include <i386/linux/linux_proto.h> +MALLOC_DEFINE(M_LINUX, "linux", "Linux mode structures"); + +extern char linux_sigcode[]; +extern int linux_szsigcode; + +extern struct sysent linux_sysent[LINUX_SYS_MAXSYSCALL]; + +extern struct linker_set linux_ioctl_handler_set; + static int linux_fixup __P((long **stack_base, struct image_params *iparams)); static int elf_linux_fixup __P((long **stack_base, @@ -460,24 +469,27 @@ linux_elf_modevent(module_t mod, int type, void *data) switch(type) { case MOD_LOAD: for (brandinfo = &linux_brandlist[0]; *brandinfo != NULL; - ++brandinfo) + ++brandinfo) if (elf_insert_brand_entry(*brandinfo) < 0) error = EINVAL; if (error) printf("cannot insert Linux elf brand handler\n"); - else if (bootverbose) - printf("Linux-ELF exec handler installed\n"); + else { + linux_ioctl_register_handlers(&linux_ioctl_handler_set); + if (bootverbose) + printf("Linux-ELF exec handler installed\n"); + } break; case MOD_UNLOAD: + linux_ioctl_unregister_handlers(&linux_ioctl_handler_set); for (brandinfo = &linux_brandlist[0]; *brandinfo != NULL; - ++brandinfo) - if (elf_brand_inuse(*brandinfo)) { + ++brandinfo) + if (elf_brand_inuse(*brandinfo)) error = EBUSY; - } if (error == 0) { for (brandinfo = &linux_brandlist[0]; - *brandinfo != NULL; ++brandinfo) + *brandinfo != NULL; ++brandinfo) if (elf_remove_brand_entry(*brandinfo) < 0) error = EINVAL; } diff --git a/sys/compat/linux/linux_ioctl.c b/sys/compat/linux/linux_ioctl.c index 64fa513..bc23d69 100644 --- a/sys/compat/linux/linux_ioctl.c +++ b/sys/compat/linux/linux_ioctl.c @@ -37,6 +37,8 @@ #include <sys/file.h> #include <sys/filedesc.h> #include <sys/filio.h> +#include <sys/linker_set.h> +#include <sys/malloc.h> #include <sys/tty.h> #include <sys/socket.h> #include <net/if.h> @@ -48,1242 +50,1456 @@ #include <machine/console.h> #include <i386/linux/linux.h> +#include <i386/linux/linux_ioctl.h> +#include <i386/linux/linux_mib.h> #include <i386/linux/linux_proto.h> #include <i386/linux/linux_util.h> -#include <i386/linux/linux_mib.h> -#define ISSIGVALID(sig) ((sig) > 0 && (sig) < NSIG) +static linux_ioctl_function_t linux_ioctl_cdrom; +static linux_ioctl_function_t linux_ioctl_console; +static linux_ioctl_function_t linux_ioctl_socket; +static linux_ioctl_function_t linux_ioctl_sound; +static linux_ioctl_function_t linux_ioctl_termio; + +static struct linux_ioctl_handler cdrom_handler = +{ linux_ioctl_cdrom, LINUX_IOCTL_CDROM_MIN, LINUX_IOCTL_CDROM_MAX }; +static struct linux_ioctl_handler console_handler = +{ linux_ioctl_console, LINUX_IOCTL_CONSOLE_MIN, LINUX_IOCTL_CONSOLE_MAX }; +static struct linux_ioctl_handler socket_handler = +{ linux_ioctl_socket, LINUX_IOCTL_SOCKET_MIN, LINUX_IOCTL_SOCKET_MAX }; +static struct linux_ioctl_handler sound_handler = +{ linux_ioctl_sound, LINUX_IOCTL_SOUND_MIN, LINUX_IOCTL_SOUND_MAX }; +static struct linux_ioctl_handler termio_handler = +{ linux_ioctl_termio, LINUX_IOCTL_TERMIO_MIN, LINUX_IOCTL_TERMIO_MAX }; + +DATA_SET(linux_ioctl_handler_set, cdrom_handler); +DATA_SET(linux_ioctl_handler_set, console_handler); +DATA_SET(linux_ioctl_handler_set, socket_handler); +DATA_SET(linux_ioctl_handler_set, sound_handler); +DATA_SET(linux_ioctl_handler_set, termio_handler); + +struct handler_element +{ + TAILQ_ENTRY(handler_element) list; + int (*func)(struct proc *, struct linux_ioctl_args *); + int low, high, span; +}; + +static TAILQ_HEAD(, handler_element) handlers = + TAILQ_HEAD_INITIALIZER(handlers); + +/* + * termio related ioctls + */ struct linux_termio { - unsigned short c_iflag; - unsigned short c_oflag; - unsigned short c_cflag; - unsigned short c_lflag; - unsigned char c_line; - unsigned char c_cc[LINUX_NCC]; + unsigned short c_iflag; + unsigned short c_oflag; + unsigned short c_cflag; + unsigned short c_lflag; + unsigned char c_line; + unsigned char c_cc[LINUX_NCC]; }; - struct linux_termios { - unsigned int c_iflag; - unsigned int c_oflag; - unsigned int c_cflag; - unsigned int c_lflag; - unsigned char c_line; - unsigned char c_cc[LINUX_NCCS]; + unsigned int c_iflag; + unsigned int c_oflag; + unsigned int c_cflag; + unsigned int c_lflag; + unsigned char c_line; + unsigned char c_cc[LINUX_NCCS]; }; struct linux_winsize { - unsigned short ws_row, ws_col; - unsigned short ws_xpixel, ws_ypixel; + unsigned short ws_row, ws_col; + unsigned short ws_xpixel, ws_ypixel; }; static struct speedtab sptab[] = { - { B0, LINUX_B0 }, { B50, LINUX_B50 }, - { B75, LINUX_B75 }, { B110, LINUX_B110 }, - { B134, LINUX_B134 }, { B150, LINUX_B150 }, - { B200, LINUX_B200 }, { B300, LINUX_B300 }, - { B600, LINUX_B600 }, { B1200, LINUX_B1200 }, - { B1800, LINUX_B1800 }, { B2400, LINUX_B2400 }, - { B4800, LINUX_B4800 }, { B9600, LINUX_B9600 }, - { B19200, LINUX_B19200 }, { B38400, LINUX_B38400 }, - { B57600, LINUX_B57600 }, { B115200, LINUX_B115200 }, - {-1, -1 } + { B0, LINUX_B0 }, { B50, LINUX_B50 }, + { B75, LINUX_B75 }, { B110, LINUX_B110 }, + { B134, LINUX_B134 }, { B150, LINUX_B150 }, + { B200, LINUX_B200 }, { B300, LINUX_B300 }, + { B600, LINUX_B600 }, { B1200, LINUX_B1200 }, + { B1800, LINUX_B1800 }, { B2400, LINUX_B2400 }, + { B4800, LINUX_B4800 }, { B9600, LINUX_B9600 }, + { B19200, LINUX_B19200 }, { B38400, LINUX_B38400 }, + { B57600, LINUX_B57600 }, { B115200, LINUX_B115200 }, + {-1, -1 } }; struct linux_serial_struct { - int type; - int line; - int port; - int irq; - int flags; - int xmit_fifo_size; - int custom_divisor; - int baud_base; - unsigned short close_delay; - char reserved_char[2]; - int hub6; - unsigned short closing_wait; - unsigned short closing_wait2; - int reserved[4]; + int type; + int line; + int port; + int irq; + int flags; + int xmit_fifo_size; + int custom_divisor; + int baud_base; + unsigned short close_delay; + char reserved_char[2]; + int hub6; + unsigned short closing_wait; + unsigned short closing_wait2; + int reserved[4]; }; - static int linux_to_bsd_speed(int code, struct speedtab *table) { - for ( ; table->sp_code != -1; table++) - if (table->sp_code == code) - return (table->sp_speed); - return -1; + for ( ; table->sp_code != -1; table++) + if (table->sp_code == code) + return (table->sp_speed); + return -1; } static int bsd_to_linux_speed(int speed, struct speedtab *table) { - for ( ; table->sp_speed != -1; table++) - if (table->sp_speed == speed) - return (table->sp_code); - return -1; + for ( ; table->sp_speed != -1; table++) + if (table->sp_speed == speed) + return (table->sp_code); + return -1; } static void -bsd_to_linux_termios(struct termios *bsd_termios, - struct linux_termios *linux_termios) +bsd_to_linux_termios(struct termios *bios, struct linux_termios *lios) { - int i; + int i; #ifdef DEBUG - printf("LINUX: BSD termios structure (input):\n"); - printf("i=%08x o=%08x c=%08x l=%08x ispeed=%d ospeed=%d\n", - bsd_termios->c_iflag, bsd_termios->c_oflag, - bsd_termios->c_cflag, bsd_termios->c_lflag, - bsd_termios->c_ispeed, bsd_termios->c_ospeed); - printf("c_cc "); - for (i=0; i<NCCS; i++) - printf("%02x ", bsd_termios->c_cc[i]); - printf("\n"); + printf("LINUX: BSD termios structure (input):\n"); + printf("i=%08x o=%08x c=%08x l=%08x ispeed=%d ospeed=%d\n", + bios->c_iflag, bios->c_oflag, bios->c_cflag, bios->c_lflag, + bios->c_ispeed, bios->c_ospeed); + printf("c_cc "); + for (i=0; i<NCCS; i++) + printf("%02x ", bios->c_cc[i]); + printf("\n"); #endif - linux_termios->c_iflag = 0; - if (bsd_termios->c_iflag & IGNBRK) - linux_termios->c_iflag |= LINUX_IGNBRK; - if (bsd_termios->c_iflag & BRKINT) - linux_termios->c_iflag |= LINUX_BRKINT; - if (bsd_termios->c_iflag & IGNPAR) - linux_termios->c_iflag |= LINUX_IGNPAR; - if (bsd_termios->c_iflag & PARMRK) - linux_termios->c_iflag |= LINUX_PARMRK; - if (bsd_termios->c_iflag & INPCK) - linux_termios->c_iflag |= LINUX_INPCK; - if (bsd_termios->c_iflag & ISTRIP) - linux_termios->c_iflag |= LINUX_ISTRIP; - if (bsd_termios->c_iflag & INLCR) - linux_termios->c_iflag |= LINUX_INLCR; - if (bsd_termios->c_iflag & IGNCR) - linux_termios->c_iflag |= LINUX_IGNCR; - if (bsd_termios->c_iflag & ICRNL) - linux_termios->c_iflag |= LINUX_ICRNL; - if (bsd_termios->c_iflag & IXON) - linux_termios->c_iflag |= LINUX_IXON; - if (bsd_termios->c_iflag & IXANY) - linux_termios->c_iflag |= LINUX_IXANY; - if (bsd_termios->c_iflag & IXOFF) - linux_termios->c_iflag |= LINUX_IXOFF; - if (bsd_termios->c_iflag & IMAXBEL) - linux_termios->c_iflag |= LINUX_IMAXBEL; - - linux_termios->c_oflag = 0; - if (bsd_termios->c_oflag & OPOST) - linux_termios->c_oflag |= LINUX_OPOST; - if (bsd_termios->c_oflag & ONLCR) - linux_termios->c_oflag |= LINUX_ONLCR; - if (bsd_termios->c_oflag & OXTABS) - linux_termios->c_oflag |= LINUX_XTABS; - - linux_termios->c_cflag = - bsd_to_linux_speed(bsd_termios->c_ispeed, sptab); - linux_termios->c_cflag |= (bsd_termios->c_cflag & CSIZE) >> 4; - if (bsd_termios->c_cflag & CSTOPB) - linux_termios->c_cflag |= LINUX_CSTOPB; - if (bsd_termios->c_cflag & CREAD) - linux_termios->c_cflag |= LINUX_CREAD; - if (bsd_termios->c_cflag & PARENB) - linux_termios->c_cflag |= LINUX_PARENB; - if (bsd_termios->c_cflag & PARODD) - linux_termios->c_cflag |= LINUX_PARODD; - if (bsd_termios->c_cflag & HUPCL) - linux_termios->c_cflag |= LINUX_HUPCL; - if (bsd_termios->c_cflag & CLOCAL) - linux_termios->c_cflag |= LINUX_CLOCAL; - if (bsd_termios->c_cflag & CRTSCTS) - linux_termios->c_cflag |= LINUX_CRTSCTS; - - linux_termios->c_lflag = 0; - if (bsd_termios->c_lflag & ISIG) - linux_termios->c_lflag |= LINUX_ISIG; - if (bsd_termios->c_lflag & ICANON) - linux_termios->c_lflag |= LINUX_ICANON; - if (bsd_termios->c_lflag & ECHO) - linux_termios->c_lflag |= LINUX_ECHO; - if (bsd_termios->c_lflag & ECHOE) - linux_termios->c_lflag |= LINUX_ECHOE; - if (bsd_termios->c_lflag & ECHOK) - linux_termios->c_lflag |= LINUX_ECHOK; - if (bsd_termios->c_lflag & ECHONL) - linux_termios->c_lflag |= LINUX_ECHONL; - if (bsd_termios->c_lflag & NOFLSH) - linux_termios->c_lflag |= LINUX_NOFLSH; - if (bsd_termios->c_lflag & TOSTOP) - linux_termios->c_lflag |= LINUX_TOSTOP; - if (bsd_termios->c_lflag & ECHOCTL) - linux_termios->c_lflag |= LINUX_ECHOCTL; - if (bsd_termios->c_lflag & ECHOPRT) - linux_termios->c_lflag |= LINUX_ECHOPRT; - if (bsd_termios->c_lflag & ECHOKE) - linux_termios->c_lflag |= LINUX_ECHOKE; - if (bsd_termios->c_lflag & FLUSHO) - linux_termios->c_lflag |= LINUX_FLUSHO; - if (bsd_termios->c_lflag & PENDIN) - linux_termios->c_lflag |= LINUX_PENDIN; - if (bsd_termios->c_lflag & IEXTEN) - linux_termios->c_lflag |= LINUX_IEXTEN; - - for (i=0; i<LINUX_NCCS; i++) - linux_termios->c_cc[i] = LINUX_POSIX_VDISABLE; - linux_termios->c_cc[LINUX_VINTR] = bsd_termios->c_cc[VINTR]; - linux_termios->c_cc[LINUX_VQUIT] = bsd_termios->c_cc[VQUIT]; - linux_termios->c_cc[LINUX_VERASE] = bsd_termios->c_cc[VERASE]; - linux_termios->c_cc[LINUX_VKILL] = bsd_termios->c_cc[VKILL]; - linux_termios->c_cc[LINUX_VEOF] = bsd_termios->c_cc[VEOF]; - linux_termios->c_cc[LINUX_VEOL] = bsd_termios->c_cc[VEOL]; - linux_termios->c_cc[LINUX_VMIN] = bsd_termios->c_cc[VMIN]; - linux_termios->c_cc[LINUX_VTIME] = bsd_termios->c_cc[VTIME]; - linux_termios->c_cc[LINUX_VEOL2] = bsd_termios->c_cc[VEOL2]; - linux_termios->c_cc[LINUX_VSUSP] = bsd_termios->c_cc[VSUSP]; - linux_termios->c_cc[LINUX_VSTART] = bsd_termios->c_cc[VSTART]; - linux_termios->c_cc[LINUX_VSTOP] = bsd_termios->c_cc[VSTOP]; - linux_termios->c_cc[LINUX_VREPRINT] = bsd_termios->c_cc[VREPRINT]; - linux_termios->c_cc[LINUX_VDISCARD] = bsd_termios->c_cc[VDISCARD]; - linux_termios->c_cc[LINUX_VWERASE] = bsd_termios->c_cc[VWERASE]; - linux_termios->c_cc[LINUX_VLNEXT] = bsd_termios->c_cc[VLNEXT]; - - for (i=0; i<LINUX_NCCS; i++) { - if (linux_termios->c_cc[i] == _POSIX_VDISABLE) - linux_termios->c_cc[i] = LINUX_POSIX_VDISABLE; - } - - linux_termios->c_line = 0; + + lios->c_iflag = 0; + if (bios->c_iflag & IGNBRK) + lios->c_iflag |= LINUX_IGNBRK; + if (bios->c_iflag & BRKINT) + lios->c_iflag |= LINUX_BRKINT; + if (bios->c_iflag & IGNPAR) + lios->c_iflag |= LINUX_IGNPAR; + if (bios->c_iflag & PARMRK) + lios->c_iflag |= LINUX_PARMRK; + if (bios->c_iflag & INPCK) + lios->c_iflag |= LINUX_INPCK; + if (bios->c_iflag & ISTRIP) + lios->c_iflag |= LINUX_ISTRIP; + if (bios->c_iflag & INLCR) + lios->c_iflag |= LINUX_INLCR; + if (bios->c_iflag & IGNCR) + lios->c_iflag |= LINUX_IGNCR; + if (bios->c_iflag & ICRNL) + lios->c_iflag |= LINUX_ICRNL; + if (bios->c_iflag & IXON) + lios->c_iflag |= LINUX_IXON; + if (bios->c_iflag & IXANY) + lios->c_iflag |= LINUX_IXANY; + if (bios->c_iflag & IXOFF) + lios->c_iflag |= LINUX_IXOFF; + if (bios->c_iflag & IMAXBEL) + lios->c_iflag |= LINUX_IMAXBEL; + + lios->c_oflag = 0; + if (bios->c_oflag & OPOST) + lios->c_oflag |= LINUX_OPOST; + if (bios->c_oflag & ONLCR) + lios->c_oflag |= LINUX_ONLCR; + if (bios->c_oflag & OXTABS) + lios->c_oflag |= LINUX_XTABS; + + lios->c_cflag = bsd_to_linux_speed(bios->c_ispeed, sptab); + lios->c_cflag |= (bios->c_cflag & CSIZE) >> 4; + if (bios->c_cflag & CSTOPB) + lios->c_cflag |= LINUX_CSTOPB; + if (bios->c_cflag & CREAD) + lios->c_cflag |= LINUX_CREAD; + if (bios->c_cflag & PARENB) + lios->c_cflag |= LINUX_PARENB; + if (bios->c_cflag & PARODD) + lios->c_cflag |= LINUX_PARODD; + if (bios->c_cflag & HUPCL) + lios->c_cflag |= LINUX_HUPCL; + if (bios->c_cflag & CLOCAL) + lios->c_cflag |= LINUX_CLOCAL; + if (bios->c_cflag & CRTSCTS) + lios->c_cflag |= LINUX_CRTSCTS; + + lios->c_lflag = 0; + if (bios->c_lflag & ISIG) + lios->c_lflag |= LINUX_ISIG; + if (bios->c_lflag & ICANON) + lios->c_lflag |= LINUX_ICANON; + if (bios->c_lflag & ECHO) + lios->c_lflag |= LINUX_ECHO; + if (bios->c_lflag & ECHOE) + lios->c_lflag |= LINUX_ECHOE; + if (bios->c_lflag & ECHOK) + lios->c_lflag |= LINUX_ECHOK; + if (bios->c_lflag & ECHONL) + lios->c_lflag |= LINUX_ECHONL; + if (bios->c_lflag & NOFLSH) + lios->c_lflag |= LINUX_NOFLSH; + if (bios->c_lflag & TOSTOP) + lios->c_lflag |= LINUX_TOSTOP; + if (bios->c_lflag & ECHOCTL) + lios->c_lflag |= LINUX_ECHOCTL; + if (bios->c_lflag & ECHOPRT) + lios->c_lflag |= LINUX_ECHOPRT; + if (bios->c_lflag & ECHOKE) + lios->c_lflag |= LINUX_ECHOKE; + if (bios->c_lflag & FLUSHO) + lios->c_lflag |= LINUX_FLUSHO; + if (bios->c_lflag & PENDIN) + lios->c_lflag |= LINUX_PENDIN; + if (bios->c_lflag & IEXTEN) + lios->c_lflag |= LINUX_IEXTEN; + + for (i=0; i<LINUX_NCCS; i++) + lios->c_cc[i] = LINUX_POSIX_VDISABLE; + lios->c_cc[LINUX_VINTR] = bios->c_cc[VINTR]; + lios->c_cc[LINUX_VQUIT] = bios->c_cc[VQUIT]; + lios->c_cc[LINUX_VERASE] = bios->c_cc[VERASE]; + lios->c_cc[LINUX_VKILL] = bios->c_cc[VKILL]; + lios->c_cc[LINUX_VEOF] = bios->c_cc[VEOF]; + lios->c_cc[LINUX_VEOL] = bios->c_cc[VEOL]; + lios->c_cc[LINUX_VMIN] = bios->c_cc[VMIN]; + lios->c_cc[LINUX_VTIME] = bios->c_cc[VTIME]; + lios->c_cc[LINUX_VEOL2] = bios->c_cc[VEOL2]; + lios->c_cc[LINUX_VSUSP] = bios->c_cc[VSUSP]; + lios->c_cc[LINUX_VSTART] = bios->c_cc[VSTART]; + lios->c_cc[LINUX_VSTOP] = bios->c_cc[VSTOP]; + lios->c_cc[LINUX_VREPRINT] = bios->c_cc[VREPRINT]; + lios->c_cc[LINUX_VDISCARD] = bios->c_cc[VDISCARD]; + lios->c_cc[LINUX_VWERASE] = bios->c_cc[VWERASE]; + lios->c_cc[LINUX_VLNEXT] = bios->c_cc[VLNEXT]; + + for (i=0; i<LINUX_NCCS; i++) { + if (lios->c_cc[i] == _POSIX_VDISABLE) + lios->c_cc[i] = LINUX_POSIX_VDISABLE; + } + lios->c_line = 0; + #ifdef DEBUG - printf("LINUX: LINUX termios structure (output):\n"); - printf("i=%08x o=%08x c=%08x l=%08x line=%d\n", - linux_termios->c_iflag, linux_termios->c_oflag, linux_termios->c_cflag, - linux_termios->c_lflag, (int)linux_termios->c_line); - printf("c_cc "); - for (i=0; i<LINUX_NCCS; i++) - printf("%02x ", linux_termios->c_cc[i]); - printf("\n"); + printf("LINUX: LINUX termios structure (output):\n"); + printf("i=%08x o=%08x c=%08x l=%08x line=%d\n", lios->c_iflag, + lios->c_oflag, lios->c_cflag, lios->c_lflag, (int)lios->c_line); + printf("c_cc "); + for (i=0; i<LINUX_NCCS; i++) + printf("%02x ", lios->c_cc[i]); + printf("\n"); #endif } - static void -linux_to_bsd_termios(struct linux_termios *linux_termios, - struct termios *bsd_termios) +linux_to_bsd_termios(struct linux_termios *lios, struct termios *bios) { - int i; + int i; + #ifdef DEBUG - printf("LINUX: LINUX termios structure (input):\n"); - printf("i=%08x o=%08x c=%08x l=%08x line=%d\n", - linux_termios->c_iflag, linux_termios->c_oflag, linux_termios->c_cflag, - linux_termios->c_lflag, (int)linux_termios->c_line); - printf("c_cc "); - for (i=0; i<LINUX_NCCS; i++) - printf("%02x ", linux_termios->c_cc[i]); - printf("\n"); + printf("LINUX: LINUX termios structure (input):\n"); + printf("i=%08x o=%08x c=%08x l=%08x line=%d\n", lios->c_iflag, + lios->c_oflag, lios->c_cflag, lios->c_lflag, (int)lios->c_line); + printf("c_cc "); + for (i=0; i<LINUX_NCCS; i++) + printf("%02x ", lios->c_cc[i]); + printf("\n"); #endif - bsd_termios->c_iflag = 0; - if (linux_termios->c_iflag & LINUX_IGNBRK) - bsd_termios->c_iflag |= IGNBRK; - if (linux_termios->c_iflag & LINUX_BRKINT) - bsd_termios->c_iflag |= BRKINT; - if (linux_termios->c_iflag & LINUX_IGNPAR) - bsd_termios->c_iflag |= IGNPAR; - if (linux_termios->c_iflag & LINUX_PARMRK) - bsd_termios->c_iflag |= PARMRK; - if (linux_termios->c_iflag & LINUX_INPCK) - bsd_termios->c_iflag |= INPCK; - if (linux_termios->c_iflag & LINUX_ISTRIP) - bsd_termios->c_iflag |= ISTRIP; - if (linux_termios->c_iflag & LINUX_INLCR) - bsd_termios->c_iflag |= INLCR; - if (linux_termios->c_iflag & LINUX_IGNCR) - bsd_termios->c_iflag |= IGNCR; - if (linux_termios->c_iflag & LINUX_ICRNL) - bsd_termios->c_iflag |= ICRNL; - if (linux_termios->c_iflag & LINUX_IXON) - bsd_termios->c_iflag |= IXON; - if (linux_termios->c_iflag & LINUX_IXANY) - bsd_termios->c_iflag |= IXANY; - if (linux_termios->c_iflag & LINUX_IXOFF) - bsd_termios->c_iflag |= IXOFF; - if (linux_termios->c_iflag & LINUX_IMAXBEL) - bsd_termios->c_iflag |= IMAXBEL; - - bsd_termios->c_oflag = 0; - if (linux_termios->c_oflag & LINUX_OPOST) - bsd_termios->c_oflag |= OPOST; - if (linux_termios->c_oflag & LINUX_ONLCR) - bsd_termios->c_oflag |= ONLCR; - if (linux_termios->c_oflag & LINUX_XTABS) - bsd_termios->c_oflag |= OXTABS; - - bsd_termios->c_cflag = (linux_termios->c_cflag & LINUX_CSIZE) << 4; - if (linux_termios->c_cflag & LINUX_CSTOPB) - bsd_termios->c_cflag |= CSTOPB; - if (linux_termios->c_cflag & LINUX_CREAD) - bsd_termios->c_cflag |= CREAD; - if (linux_termios->c_cflag & LINUX_PARENB) - bsd_termios->c_cflag |= PARENB; - if (linux_termios->c_cflag & LINUX_PARODD) - bsd_termios->c_cflag |= PARODD; - if (linux_termios->c_cflag & LINUX_HUPCL) - bsd_termios->c_cflag |= HUPCL; - if (linux_termios->c_cflag & LINUX_CLOCAL) - bsd_termios->c_cflag |= CLOCAL; - if (linux_termios->c_cflag & LINUX_CRTSCTS) - bsd_termios->c_cflag |= CRTSCTS; - - bsd_termios->c_lflag = 0; - if (linux_termios->c_lflag & LINUX_ISIG) - bsd_termios->c_lflag |= ISIG; - if (linux_termios->c_lflag & LINUX_ICANON) - bsd_termios->c_lflag |= ICANON; - if (linux_termios->c_lflag & LINUX_ECHO) - bsd_termios->c_lflag |= ECHO; - if (linux_termios->c_lflag & LINUX_ECHOE) - bsd_termios->c_lflag |= ECHOE; - if (linux_termios->c_lflag & LINUX_ECHOK) - bsd_termios->c_lflag |= ECHOK; - if (linux_termios->c_lflag & LINUX_ECHONL) - bsd_termios->c_lflag |= ECHONL; - if (linux_termios->c_lflag & LINUX_NOFLSH) - bsd_termios->c_lflag |= NOFLSH; - if (linux_termios->c_lflag & LINUX_TOSTOP) - bsd_termios->c_lflag |= TOSTOP; - if (linux_termios->c_lflag & LINUX_ECHOCTL) - bsd_termios->c_lflag |= ECHOCTL; - if (linux_termios->c_lflag & LINUX_ECHOPRT) - bsd_termios->c_lflag |= ECHOPRT; - if (linux_termios->c_lflag & LINUX_ECHOKE) - bsd_termios->c_lflag |= ECHOKE; - if (linux_termios->c_lflag & LINUX_FLUSHO) - bsd_termios->c_lflag |= FLUSHO; - if (linux_termios->c_lflag & LINUX_PENDIN) - bsd_termios->c_lflag |= PENDIN; - if (linux_termios->c_lflag & LINUX_IEXTEN) - bsd_termios->c_lflag |= IEXTEN; - - for (i=0; i<NCCS; i++) - bsd_termios->c_cc[i] = _POSIX_VDISABLE; - bsd_termios->c_cc[VINTR] = linux_termios->c_cc[LINUX_VINTR]; - bsd_termios->c_cc[VQUIT] = linux_termios->c_cc[LINUX_VQUIT]; - bsd_termios->c_cc[VERASE] = linux_termios->c_cc[LINUX_VERASE]; - bsd_termios->c_cc[VKILL] = linux_termios->c_cc[LINUX_VKILL]; - bsd_termios->c_cc[VEOF] = linux_termios->c_cc[LINUX_VEOF]; - bsd_termios->c_cc[VEOL] = linux_termios->c_cc[LINUX_VEOL]; - bsd_termios->c_cc[VMIN] = linux_termios->c_cc[LINUX_VMIN]; - bsd_termios->c_cc[VTIME] = linux_termios->c_cc[LINUX_VTIME]; - bsd_termios->c_cc[VEOL2] = linux_termios->c_cc[LINUX_VEOL2]; - bsd_termios->c_cc[VSUSP] = linux_termios->c_cc[LINUX_VSUSP]; - bsd_termios->c_cc[VSTART] = linux_termios->c_cc[LINUX_VSTART]; - bsd_termios->c_cc[VSTOP] = linux_termios->c_cc[LINUX_VSTOP]; - bsd_termios->c_cc[VREPRINT] = linux_termios->c_cc[LINUX_VREPRINT]; - bsd_termios->c_cc[VDISCARD] = linux_termios->c_cc[LINUX_VDISCARD]; - bsd_termios->c_cc[VWERASE] = linux_termios->c_cc[LINUX_VWERASE]; - bsd_termios->c_cc[VLNEXT] = linux_termios->c_cc[LINUX_VLNEXT]; - - for (i=0; i<NCCS; i++) { - if (bsd_termios->c_cc[i] == LINUX_POSIX_VDISABLE) - bsd_termios->c_cc[i] = _POSIX_VDISABLE; - } - - bsd_termios->c_ispeed = bsd_termios->c_ospeed = - linux_to_bsd_speed(linux_termios->c_cflag & LINUX_CBAUD, sptab); + + bios->c_iflag = 0; + if (lios->c_iflag & LINUX_IGNBRK) + bios->c_iflag |= IGNBRK; + if (lios->c_iflag & LINUX_BRKINT) + bios->c_iflag |= BRKINT; + if (lios->c_iflag & LINUX_IGNPAR) + bios->c_iflag |= IGNPAR; + if (lios->c_iflag & LINUX_PARMRK) + bios->c_iflag |= PARMRK; + if (lios->c_iflag & LINUX_INPCK) + bios->c_iflag |= INPCK; + if (lios->c_iflag & LINUX_ISTRIP) + bios->c_iflag |= ISTRIP; + if (lios->c_iflag & LINUX_INLCR) + bios->c_iflag |= INLCR; + if (lios->c_iflag & LINUX_IGNCR) + bios->c_iflag |= IGNCR; + if (lios->c_iflag & LINUX_ICRNL) + bios->c_iflag |= ICRNL; + if (lios->c_iflag & LINUX_IXON) + bios->c_iflag |= IXON; + if (lios->c_iflag & LINUX_IXANY) + bios->c_iflag |= IXANY; + if (lios->c_iflag & LINUX_IXOFF) + bios->c_iflag |= IXOFF; + if (lios->c_iflag & LINUX_IMAXBEL) + bios->c_iflag |= IMAXBEL; + + bios->c_oflag = 0; + if (lios->c_oflag & LINUX_OPOST) + bios->c_oflag |= OPOST; + if (lios->c_oflag & LINUX_ONLCR) + bios->c_oflag |= ONLCR; + if (lios->c_oflag & LINUX_XTABS) + bios->c_oflag |= OXTABS; + + bios->c_cflag = (lios->c_cflag & LINUX_CSIZE) << 4; + if (lios->c_cflag & LINUX_CSTOPB) + bios->c_cflag |= CSTOPB; + if (lios->c_cflag & LINUX_CREAD) + bios->c_cflag |= CREAD; + if (lios->c_cflag & LINUX_PARENB) + bios->c_cflag |= PARENB; + if (lios->c_cflag & LINUX_PARODD) + bios->c_cflag |= PARODD; + if (lios->c_cflag & LINUX_HUPCL) + bios->c_cflag |= HUPCL; + if (lios->c_cflag & LINUX_CLOCAL) + bios->c_cflag |= CLOCAL; + if (lios->c_cflag & LINUX_CRTSCTS) + bios->c_cflag |= CRTSCTS; + + bios->c_lflag = 0; + if (lios->c_lflag & LINUX_ISIG) + bios->c_lflag |= ISIG; + if (lios->c_lflag & LINUX_ICANON) + bios->c_lflag |= ICANON; + if (lios->c_lflag & LINUX_ECHO) + bios->c_lflag |= ECHO; + if (lios->c_lflag & LINUX_ECHOE) + bios->c_lflag |= ECHOE; + if (lios->c_lflag & LINUX_ECHOK) + bios->c_lflag |= ECHOK; + if (lios->c_lflag & LINUX_ECHONL) + bios->c_lflag |= ECHONL; + if (lios->c_lflag & LINUX_NOFLSH) + bios->c_lflag |= NOFLSH; + if (lios->c_lflag & LINUX_TOSTOP) + bios->c_lflag |= TOSTOP; + if (lios->c_lflag & LINUX_ECHOCTL) + bios->c_lflag |= ECHOCTL; + if (lios->c_lflag & LINUX_ECHOPRT) + bios->c_lflag |= ECHOPRT; + if (lios->c_lflag & LINUX_ECHOKE) + bios->c_lflag |= ECHOKE; + if (lios->c_lflag & LINUX_FLUSHO) + bios->c_lflag |= FLUSHO; + if (lios->c_lflag & LINUX_PENDIN) + bios->c_lflag |= PENDIN; + if (lios->c_lflag & LINUX_IEXTEN) + bios->c_lflag |= IEXTEN; + + for (i=0; i<NCCS; i++) + bios->c_cc[i] = _POSIX_VDISABLE; + bios->c_cc[VINTR] = lios->c_cc[LINUX_VINTR]; + bios->c_cc[VQUIT] = lios->c_cc[LINUX_VQUIT]; + bios->c_cc[VERASE] = lios->c_cc[LINUX_VERASE]; + bios->c_cc[VKILL] = lios->c_cc[LINUX_VKILL]; + bios->c_cc[VEOF] = lios->c_cc[LINUX_VEOF]; + bios->c_cc[VEOL] = lios->c_cc[LINUX_VEOL]; + bios->c_cc[VMIN] = lios->c_cc[LINUX_VMIN]; + bios->c_cc[VTIME] = lios->c_cc[LINUX_VTIME]; + bios->c_cc[VEOL2] = lios->c_cc[LINUX_VEOL2]; + bios->c_cc[VSUSP] = lios->c_cc[LINUX_VSUSP]; + bios->c_cc[VSTART] = lios->c_cc[LINUX_VSTART]; + bios->c_cc[VSTOP] = lios->c_cc[LINUX_VSTOP]; + bios->c_cc[VREPRINT] = lios->c_cc[LINUX_VREPRINT]; + bios->c_cc[VDISCARD] = lios->c_cc[LINUX_VDISCARD]; + bios->c_cc[VWERASE] = lios->c_cc[LINUX_VWERASE]; + bios->c_cc[VLNEXT] = lios->c_cc[LINUX_VLNEXT]; + + for (i=0; i<NCCS; i++) { + if (bios->c_cc[i] == LINUX_POSIX_VDISABLE) + bios->c_cc[i] = _POSIX_VDISABLE; + } + + bios->c_ispeed = bios->c_ospeed = + linux_to_bsd_speed(lios->c_cflag & LINUX_CBAUD, sptab); + #ifdef DEBUG printf("LINUX: BSD termios structure (output):\n"); printf("i=%08x o=%08x c=%08x l=%08x ispeed=%d ospeed=%d\n", - bsd_termios->c_iflag, bsd_termios->c_oflag, - bsd_termios->c_cflag, bsd_termios->c_lflag, - bsd_termios->c_ispeed, bsd_termios->c_ospeed); + bios->c_iflag, bios->c_oflag, bios->c_cflag, bios->c_lflag, + bios->c_ispeed, bios->c_ospeed); printf("c_cc "); for (i=0; i<NCCS; i++) - printf("%02x ", bsd_termios->c_cc[i]); + printf("%02x ", bios->c_cc[i]); printf("\n"); #endif } - static void -bsd_to_linux_termio(struct termios *bsd_termios, - struct linux_termio *linux_termio) +bsd_to_linux_termio(struct termios *bios, struct linux_termio *lio) { - struct linux_termios tmios; - - bsd_to_linux_termios(bsd_termios, &tmios); - linux_termio->c_iflag = tmios.c_iflag; - linux_termio->c_oflag = tmios.c_oflag; - linux_termio->c_cflag = tmios.c_cflag; - linux_termio->c_lflag = tmios.c_lflag; - linux_termio->c_line = tmios.c_line; - memcpy(linux_termio->c_cc, tmios.c_cc, LINUX_NCC); + struct linux_termios lios; + + bsd_to_linux_termios(bios, &lios); + lio->c_iflag = lios.c_iflag; + lio->c_oflag = lios.c_oflag; + lio->c_cflag = lios.c_cflag; + lio->c_lflag = lios.c_lflag; + lio->c_line = lios.c_line; + memcpy(lio->c_cc, lios.c_cc, LINUX_NCC); } static void -linux_to_bsd_termio(struct linux_termio *linux_termio, - struct termios *bsd_termios) +linux_to_bsd_termio(struct linux_termio *lio, struct termios *bios) +{ + struct linux_termios lios; + int i; + + lios.c_iflag = lio->c_iflag; + lios.c_oflag = lio->c_oflag; + lios.c_cflag = lio->c_cflag; + lios.c_lflag = lio->c_lflag; + for (i=LINUX_NCC; i<LINUX_NCCS; i++) + lios.c_cc[i] = LINUX_POSIX_VDISABLE; + memcpy(lios.c_cc, lio->c_cc, LINUX_NCC); + linux_to_bsd_termios(&lios, bios); +} + +static int +linux_ioctl_termio(struct proc *p, struct linux_ioctl_args *args) { - struct linux_termios tmios; - int i; + struct termios bios; + struct linux_termios lios; + struct linux_termio lio; + struct file *fp = p->p_fd->fd_ofiles[args->fd]; + int error; + + switch (args->cmd & 0xffff) { + + case LINUX_TCGETS: + error = fo_ioctl(fp, TIOCGETA, (caddr_t)&bios, p); + if (error) + return (error); + bsd_to_linux_termios(&bios, &lios); + return copyout(&lios, (caddr_t)args->arg, sizeof(lios)); + + case LINUX_TCSETS: + error = copyin((caddr_t)args->arg, &lios, sizeof(lios)); + if (error) + return (error); + linux_to_bsd_termios(&lios, &bios); + return (fo_ioctl(fp, TIOCSETA, (caddr_t)&bios, p)); + + case LINUX_TCSETSW: + error = copyin((caddr_t)args->arg, &lios, sizeof(lios)); + if (error) + return (error); + linux_to_bsd_termios(&lios, &bios); + return (fo_ioctl(fp, TIOCSETAW, (caddr_t)&bios, p)); + + case LINUX_TCSETSF: + error = copyin((caddr_t)args->arg, &lios, sizeof(lios)); + if (error) + return (error); + linux_to_bsd_termios(&lios, &bios); + return (fo_ioctl(fp, TIOCSETAF, (caddr_t)&bios, p)); + + case LINUX_TCGETA: + error = fo_ioctl(fp, TIOCGETA, (caddr_t)&bios, p); + if (error) + return (error); + bsd_to_linux_termio(&bios, &lio); + return (copyout(&lio, (caddr_t)args->arg, sizeof(lio))); + + case LINUX_TCSETA: + error = copyin((caddr_t)args->arg, &lio, sizeof(lio)); + if (error) + return (error); + linux_to_bsd_termio(&lio, &bios); + return (fo_ioctl(fp, TIOCSETA, (caddr_t)&bios, p)); + + case LINUX_TCSETAW: + error = copyin((caddr_t)args->arg, &lio, sizeof(lio)); + if (error) + return (error); + linux_to_bsd_termio(&lio, &bios); + return (fo_ioctl(fp, TIOCSETAW, (caddr_t)&bios, p)); + + case LINUX_TCSETAF: + error = copyin((caddr_t)args->arg, &lio, sizeof(lio)); + if (error) + return (error); + linux_to_bsd_termio(&lio, &bios); + return (fo_ioctl(fp, TIOCSETAF, (caddr_t)&bios, p)); + + /* LINUX_TCSBRK */ + + case LINUX_TCXONC: { + switch (args->arg) { + case LINUX_TCOOFF: + args->cmd = TIOCSTOP; + break; + case LINUX_TCOON: + args->cmd = TIOCSTART; + break; + case LINUX_TCIOFF: + case LINUX_TCION: { + int c; + struct write_args wr; + error = fo_ioctl(fp, TIOCGETA, (caddr_t)&bios, p); + if (error) + return (error); + c = (args->arg == LINUX_TCIOFF) ? VSTOP : VSTART; + c = bios.c_cc[c]; + if (c != _POSIX_VDISABLE) { + wr.fd = args->fd; + wr.buf = &c; + wr.nbyte = sizeof(c); + return (write(p, &wr)); + } else + return (0); + } + default: + return (EINVAL); + } + args->arg = 0; + return (ioctl(p, (struct ioctl_args *)args)); + } + + case LINUX_TCFLSH: { + args->cmd = TIOCFLUSH; + switch (args->arg) { + case LINUX_TCIFLUSH: + args->arg = FREAD; + break; + case LINUX_TCOFLUSH: + args->arg = FWRITE; + break; + case LINUX_TCIOFLUSH: + args->arg = FREAD | FWRITE; + break; + default: + return (EINVAL); + } + return (ioctl(p, (struct ioctl_args *)args)); + } + + case LINUX_TIOCEXCL: + args->cmd = TIOCEXCL; + return (ioctl(p, (struct ioctl_args *)args)); + + case LINUX_TIOCNXCL: + args->cmd = TIOCNXCL; + return (ioctl(p, (struct ioctl_args *)args)); + + /* LINUX_TIOCSCTTY */ + + case LINUX_TIOCGPGRP: + args->cmd = TIOCGPGRP; + return (ioctl(p, (struct ioctl_args *)args)); + + case LINUX_TIOCSPGRP: + args->cmd = TIOCSPGRP; + return (ioctl(p, (struct ioctl_args *)args)); + + /* LINUX_TIOCOUTQ */ + /* LINUX_TIOCSTI */ + + case LINUX_TIOCGWINSZ: + args->cmd = TIOCGWINSZ; + return (ioctl(p, (struct ioctl_args *)args)); + + case LINUX_TIOCSWINSZ: + args->cmd = TIOCSWINSZ; + return (ioctl(p, (struct ioctl_args *)args)); + + case LINUX_TIOCMGET: + args->cmd = TIOCMGET; + return (ioctl(p, (struct ioctl_args *)args)); - tmios.c_iflag = linux_termio->c_iflag; - tmios.c_oflag = linux_termio->c_oflag; - tmios.c_cflag = linux_termio->c_cflag; - tmios.c_lflag = linux_termio->c_lflag; + case LINUX_TIOCMBIS: + args->cmd = TIOCMBIS; + return (ioctl(p, (struct ioctl_args *)args)); - for (i=LINUX_NCC; i<LINUX_NCCS; i++) - tmios.c_cc[i] = LINUX_POSIX_VDISABLE; - memcpy(tmios.c_cc, linux_termio->c_cc, LINUX_NCC); + case LINUX_TIOCMBIC: + args->cmd = TIOCMBIC; + return (ioctl(p, (struct ioctl_args *)args)); - linux_to_bsd_termios(&tmios, bsd_termios); + case LINUX_TIOCMSET: + args->cmd = TIOCMSET; + return (ioctl(p, (struct ioctl_args *)args)); + + /* TIOCGSOFTCAR */ + /* TIOCSSOFTCAR */ + + case LINUX_FIONREAD: /* LINUX_TIOCINQ */ + args->cmd = FIONREAD; + return (ioctl(p, (struct ioctl_args *)args)); + + /* LINUX_TIOCLINUX */ + + case LINUX_TIOCCONS: + args->cmd = TIOCCONS; + return (ioctl(p, (struct ioctl_args *)args)); + + case LINUX_TIOCGSERIAL: { + struct linux_serial_struct lss; + lss.type = LINUX_PORT_16550A; + lss.flags = 0; + lss.close_delay = 0; + return copyout(&lss, (caddr_t)args->arg, sizeof(lss)); + } + + case LINUX_TIOCSSERIAL: { + struct linux_serial_struct lss; + error = copyin((caddr_t)args->arg, &lss, sizeof(lss)); + if (error) + return (error); + /* XXX - It really helps to have an implementation that + * does nothing. NOT! + */ + return (0); + } + + /* LINUX_TIOCPKT */ + + case LINUX_FIONBIO: + args->cmd = FIONBIO; + return (ioctl(p, (struct ioctl_args *)args)); + + case LINUX_TIOCNOTTY: + args->cmd = TIOCNOTTY; + return (ioctl(p, (struct ioctl_args *)args)); + + case LINUX_TIOCSETD: { + int line; + switch (args->arg) { + case LINUX_N_TTY: + line = TTYDISC; + break; + case LINUX_N_SLIP: + line = SLIPDISC; + break; + case LINUX_N_PPP: + line = PPPDISC; + break; + default: + return (EINVAL); + } + return (fo_ioctl(fp, TIOCSETD, (caddr_t)&line, p)); + } + + case LINUX_TIOCGETD: { + int linux_line; + int bsd_line = TTYDISC; + error = fo_ioctl(fp, TIOCGETD, (caddr_t)&bsd_line, p); + if (error) + return (error); + switch (bsd_line) { + case TTYDISC: + linux_line = LINUX_N_TTY; + break; + case SLIPDISC: + linux_line = LINUX_N_SLIP; + break; + case PPPDISC: + linux_line = LINUX_N_PPP; + break; + default: + return (EINVAL); + } + return (copyout(&linux_line, (caddr_t)args->arg, sizeof(int))); + } + + /* LINUX_TCSBRKP */ + /* LINUX_TIOCTTYGSTRUCT */ + + case LINUX_FIONCLEX: + args->cmd = FIONCLEX; + return (ioctl(p, (struct ioctl_args *)args)); + + case LINUX_FIOCLEX: + args->cmd = FIOCLEX; + return (ioctl(p, (struct ioctl_args *)args)); + + case LINUX_FIOASYNC: + args->cmd = FIOASYNC; + return (ioctl(p, (struct ioctl_args *)args)); + + /* LINUX_TIOCSERCONFIG */ + /* LINUX_TIOCSERGWILD */ + /* LINUX_TIOCSERSWILD */ + /* LINUX_TIOCGLCKTRMIOS */ + /* LINUX_TIOCSLCKTRMIOS */ + + } + + return (ENOIOCTL); } +/* + * CDROM related ioctls + */ + struct linux_cdrom_msf { - u_char cdmsf_min0; - u_char cdmsf_sec0; - u_char cdmsf_frame0; - u_char cdmsf_min1; - u_char cdmsf_sec1; - u_char cdmsf_frame1; + u_char cdmsf_min0; + u_char cdmsf_sec0; + u_char cdmsf_frame0; + u_char cdmsf_min1; + u_char cdmsf_sec1; + u_char cdmsf_frame1; }; struct linux_cdrom_tochdr { - u_char cdth_trk0; - u_char cdth_trk1; + u_char cdth_trk0; + u_char cdth_trk1; }; union linux_cdrom_addr { - struct { - u_char minute; - u_char second; - u_char frame; - } msf; - int lba; + struct { + u_char minute; + u_char second; + u_char frame; + } msf; + int lba; }; struct linux_cdrom_tocentry { - u_char cdte_track; - u_char cdte_adr:4; - u_char cdte_ctrl:4; - u_char cdte_format; - union linux_cdrom_addr cdte_addr; - u_char cdte_datamode; + u_char cdte_track; + u_char cdte_adr:4; + u_char cdte_ctrl:4; + u_char cdte_format; + union linux_cdrom_addr cdte_addr; + u_char cdte_datamode; }; struct linux_cdrom_subchnl { - u_char cdsc_format; - u_char cdsc_audiostatus; - u_char cdsc_adr:4; - u_char cdsc_ctrl:4; - u_char cdsc_trk; - u_char cdsc_ind; - union linux_cdrom_addr cdsc_absaddr; - union linux_cdrom_addr cdsc_reladdr; + u_char cdsc_format; + u_char cdsc_audiostatus; + u_char cdsc_adr:4; + u_char cdsc_ctrl:4; + u_char cdsc_trk; + u_char cdsc_ind; + union linux_cdrom_addr cdsc_absaddr; + union linux_cdrom_addr cdsc_reladdr; }; -#if 0 static void -linux_to_bsd_msf_lba(u_char address_format, - union linux_cdrom_addr *lp, union msf_lba *bp) +bsd_to_linux_msf_lba(u_char af, union msf_lba *bp, union linux_cdrom_addr *lp) { - if (address_format == CD_LBA_FORMAT) - bp->lba = lp->lba; - else { - bp->msf.minute = lp->msf.minute; - bp->msf.second = lp->msf.second; - bp->msf.frame = lp->msf.frame; - } + if (af == CD_LBA_FORMAT) + lp->lba = bp->lba; + else { + lp->msf.minute = bp->msf.minute; + lp->msf.second = bp->msf.second; + lp->msf.frame = bp->msf.frame; + } } -#endif static void -bsd_to_linux_msf_lba(u_char address_format, - union msf_lba *bp, union linux_cdrom_addr *lp) +set_linux_cdrom_addr(union linux_cdrom_addr *addr, int format, int lba) { - if (address_format == CD_LBA_FORMAT) - lp->lba = bp->lba; - else { - lp->msf.minute = bp->msf.minute; - lp->msf.second = bp->msf.second; - lp->msf.frame = bp->msf.frame; - } + if (format == LINUX_CDROM_MSF) { + addr->msf.frame = lba % 75; + lba /= 75; + lba += 2; + addr->msf.second = lba % 60; + addr->msf.minute = lba / 60; + } else + addr->lba = lba; } -static void -set_linux_cdrom_addr(union linux_cdrom_addr *addr, int format, int lba) +static int +linux_ioctl_cdrom(struct proc *p, struct linux_ioctl_args *args) { - if (format == LINUX_CDROM_MSF) { - addr->msf.frame = lba % 75; - lba /= 75; - lba += 2; - addr->msf.second = lba % 60; - addr->msf.minute = lba / 60; - } - else - addr->lba = lba; + struct file *fp = p->p_fd->fd_ofiles[args->fd]; + int error; + + switch (args->cmd & 0xffff) { + + case LINUX_CDROMPAUSE: + args->cmd = CDIOCPAUSE; + return (ioctl(p, (struct ioctl_args *)args)); + + case LINUX_CDROMRESUME: + args->cmd = CDIOCRESUME; + return (ioctl(p, (struct ioctl_args *)args)); + + case LINUX_CDROMPLAYMSF: + args->cmd = CDIOCPLAYMSF; + return (ioctl(p, (struct ioctl_args *)args)); + + case LINUX_CDROMPLAYTRKIND: + args->cmd = CDIOCPLAYTRACKS; + return (ioctl(p, (struct ioctl_args *)args)); + + case LINUX_CDROMREADTOCHDR: { + struct ioc_toc_header th; + struct linux_cdrom_tochdr lth; + error = fo_ioctl(fp, CDIOREADTOCHEADER, (caddr_t)&th, p); + if (!error) { + lth.cdth_trk0 = th.starting_track; + lth.cdth_trk1 = th.ending_track; + copyout(<h, (caddr_t)args->arg, sizeof(lth)); + } + return (error); + } + + case LINUX_CDROMREADTOCENTRY: { + struct linux_cdrom_tocentry lte, *ltep = + (struct linux_cdrom_tocentry *)args->arg; + struct ioc_read_toc_single_entry irtse; + irtse.address_format = ltep->cdte_format; + irtse.track = ltep->cdte_track; + error = fo_ioctl(fp, CDIOREADTOCENTRY, (caddr_t)&irtse, p); + if (!error) { + lte = *ltep; + lte.cdte_ctrl = irtse.entry.control; + lte.cdte_adr = irtse.entry.addr_type; + bsd_to_linux_msf_lba(irtse.address_format, + &irtse.entry.addr, <e.cdte_addr); + copyout(<e, (caddr_t)args->arg, sizeof(lte)); + } + return (error); + } + + case LINUX_CDROMSTOP: + args->cmd = CDIOCSTOP; + return (ioctl(p, (struct ioctl_args *)args)); + + case LINUX_CDROMSTART: + args->cmd = CDIOCSTART; + return (ioctl(p, (struct ioctl_args *)args)); + + case LINUX_CDROMEJECT: + args->cmd = CDIOCEJECT; + return (ioctl(p, (struct ioctl_args *)args)); + + /* LINUX_CDROMVOLCTRL */ + + case LINUX_CDROMSUBCHNL: { + struct linux_cdrom_subchnl sc; + struct ioc_read_subchannel bsdsc; + struct cd_sub_channel_info *bsdinfo; + caddr_t sg = stackgap_init(); + bsdinfo = (struct cd_sub_channel_info*)stackgap_alloc(&sg, + sizeof(struct cd_sub_channel_info)); + bsdsc.address_format = CD_LBA_FORMAT; + bsdsc.data_format = CD_CURRENT_POSITION; + bsdsc.data_len = sizeof(struct cd_sub_channel_info); + bsdsc.data = bsdinfo; + error = fo_ioctl(fp, CDIOCREADSUBCHANNEL, (caddr_t)&bsdsc, p); + if (error) + return (error); + error = copyin((caddr_t)args->arg, &sc, + sizeof(struct linux_cdrom_subchnl)); + if (error) + return (error); + sc.cdsc_audiostatus = bsdinfo->header.audio_status; + sc.cdsc_adr = bsdinfo->what.position.addr_type; + sc.cdsc_ctrl = bsdinfo->what.position.control; + sc.cdsc_trk = bsdinfo->what.position.track_number; + sc.cdsc_ind = bsdinfo->what.position.index_number; + set_linux_cdrom_addr(&sc.cdsc_absaddr, sc.cdsc_format, + bsdinfo->what.position.absaddr.lba); + set_linux_cdrom_addr(&sc.cdsc_reladdr, sc.cdsc_format, + bsdinfo->what.position.reladdr.lba); + error = copyout(&sc, (caddr_t)args->arg, + sizeof(struct linux_cdrom_subchnl)); + return (error); + } + + /* LINUX_CDROMREADMODE2 */ + /* LINUX_CDROMREADMODE1 */ + /* LINUX_CDROMREADAUDIO */ + /* LINUX_CDROMEJECT_SW */ + /* LINUX_CDROMMULTISESSION */ + /* LINUX_CDROM_GET_UPC */ + + case LINUX_CDROMRESET: + args->cmd = CDIOCRESET; + return (ioctl(p, (struct ioctl_args *)args)); + + /* LINUX_CDROMVOLREAD */ + /* LINUX_CDROMREADRAW */ + /* LINUX_CDROMREADCOOKED */ + /* LINUX_CDROMSEEK */ + /* LINUX_CDROMPLAYBLK */ + /* LINUX_CDROMREADALL */ + /* LINUX_CDROMCLOSETRAY */ + /* LINUX_CDROMLOADFROMSLOT */ + + } + + return (ENOIOCTL); } +/* + * Sound related ioctls + */ + static unsigned dirbits[4] = { IOC_VOID, IOC_IN, IOC_OUT, IOC_INOUT }; -#define SETDIR(c) (((c) & ~IOC_DIRMASK) | dirbits[args->cmd >> 30]) +#define SETDIR(c) (((c) & ~IOC_DIRMASK) | dirbits[args->cmd >> 30]) -int -linux_ioctl(struct proc *p, struct linux_ioctl_args *args) +static int +linux_ioctl_sound(struct proc *p, struct linux_ioctl_args *args) { - struct termios bsd_termios; - struct linux_termios linux_termios; - struct linux_termio linux_termio; - struct filedesc *fdp = p->p_fd; - struct file *fp; - int bsd_line, linux_line; - int error; -#ifdef DEBUG - printf("Linux-emul(%ld): ioctl(%d, %04lx, *)\n", - (long)p->p_pid, args->fd, args->cmd); -#endif - if ((unsigned)args->fd >= fdp->fd_nfiles - || (fp = fdp->fd_ofiles[args->fd]) == 0) - return EBADF; - - if (!fp || (fp->f_flag & (FREAD | FWRITE)) == 0) { - return EBADF; - } - - switch (args->cmd & 0xffff) { - - case LINUX_TCGETA: - if ((error = fo_ioctl(fp, TIOCGETA, (caddr_t)&bsd_termios, p)) != 0) - return error; - bsd_to_linux_termio(&bsd_termios, &linux_termio); - return copyout((caddr_t)&linux_termio, (caddr_t)args->arg, - sizeof(linux_termio)); - - case LINUX_TCSETA: - error = copyin((caddr_t)args->arg, &linux_termio, sizeof(linux_termio)); - if (error) - return error; - linux_to_bsd_termio(&linux_termio, &bsd_termios); - return fo_ioctl(fp, TIOCSETA, (caddr_t)&bsd_termios, p); - - case LINUX_TCSETAW: - error = copyin((caddr_t)args->arg, &linux_termio, sizeof(linux_termio)); - if (error) - return error; - linux_to_bsd_termio(&linux_termio, &bsd_termios); - return fo_ioctl(fp, TIOCSETAW, (caddr_t)&bsd_termios, p); - - case LINUX_TCSETAF: - error = copyin((caddr_t)args->arg, &linux_termio, sizeof(linux_termio)); - if (error) - return error; - linux_to_bsd_termio(&linux_termio, &bsd_termios); - return fo_ioctl(fp, TIOCSETAF, (caddr_t)&bsd_termios, p); - - case LINUX_TCGETS: - if ((error = fo_ioctl(fp, TIOCGETA, (caddr_t)&bsd_termios, p)) != 0) - return error; - bsd_to_linux_termios(&bsd_termios, &linux_termios); - return copyout((caddr_t)&linux_termios, (caddr_t)args->arg, - sizeof(linux_termios)); - - case LINUX_TCSETS: - error = copyin((caddr_t)args->arg, &linux_termios, - sizeof(linux_termios)); - if (error) - return error; - linux_to_bsd_termios(&linux_termios, &bsd_termios); - return fo_ioctl(fp, TIOCSETA, (caddr_t)&bsd_termios, p); - - case LINUX_TCSETSW: - error = copyin((caddr_t)args->arg, &linux_termios, - sizeof(linux_termios)); - if (error) - return error; - linux_to_bsd_termios(&linux_termios, &bsd_termios); - return fo_ioctl(fp, TIOCSETAW, (caddr_t)&bsd_termios, p); - - case LINUX_TCSETSF: - error = copyin((caddr_t)args->arg, &linux_termios, - sizeof(linux_termios)); - if (error) - return error; - linux_to_bsd_termios(&linux_termios, &bsd_termios); - return fo_ioctl(fp, TIOCSETAF, (caddr_t)&bsd_termios, p); - - case LINUX_TIOCGPGRP: - args->cmd = TIOCGPGRP; - return ioctl(p, (struct ioctl_args *)args); - - case LINUX_TIOCSPGRP: - args->cmd = TIOCSPGRP; - return ioctl(p, (struct ioctl_args *)args); - - case LINUX_TIOCGWINSZ: - args->cmd = TIOCGWINSZ; - return ioctl(p, (struct ioctl_args *)args); - - case LINUX_TIOCSWINSZ: - args->cmd = TIOCSWINSZ; - return ioctl(p, (struct ioctl_args *)args); - - case LINUX_TIOCMGET: - args->cmd = TIOCMGET; - return ioctl(p, (struct ioctl_args *)args); - - case LINUX_TIOCMBIS: - args->cmd = TIOCMBIS; - return ioctl(p, (struct ioctl_args *)args); - - case LINUX_TIOCMBIC: - args->cmd = TIOCMBIC; - return ioctl(p, (struct ioctl_args *)args); - - case LINUX_TIOCMSET: - args->cmd = TIOCMSET; - return ioctl(p, (struct ioctl_args *)args); - - case LINUX_FIONREAD: - args->cmd = FIONREAD; - return ioctl(p, (struct ioctl_args *)args); - - case LINUX_FIONBIO: - args->cmd = FIONBIO; - return ioctl(p, (struct ioctl_args *)args); - - case LINUX_FIOASYNC: - args->cmd = FIOASYNC; - return ioctl(p, (struct ioctl_args *)args); - - case LINUX_FIONCLEX: - args->cmd = FIONCLEX; - return ioctl(p, (struct ioctl_args *)args); - - case LINUX_FIOCLEX: - args->cmd = FIOCLEX; - return ioctl(p, (struct ioctl_args *)args); - - case LINUX_TIOCEXCL: - args->cmd = TIOCEXCL; - return ioctl(p, (struct ioctl_args *)args); - - case LINUX_TIOCNXCL: - args->cmd = TIOCNXCL; - return ioctl(p, (struct ioctl_args *)args); - - case LINUX_TIOCCONS: - args->cmd = TIOCCONS; - return ioctl(p, (struct ioctl_args *)args); - - case LINUX_TIOCNOTTY: - args->cmd = TIOCNOTTY; - return ioctl(p, (struct ioctl_args *)args); - - case LINUX_SIOCGIFCONF: - args->cmd = OSIOCGIFCONF; - return ioctl(p, (struct ioctl_args *)args); - - case LINUX_SIOCGIFFLAGS: - args->cmd = SIOCGIFFLAGS; - return ioctl(p, (struct ioctl_args *)args); - - case LINUX_SIOCGIFADDR: - args->cmd = OSIOCGIFADDR; - return ioctl(p, (struct ioctl_args *)args); - - case LINUX_SIOCGIFDSTADDR: - args->cmd = OSIOCGIFDSTADDR; - return ioctl(p, (struct ioctl_args *)args); - - case LINUX_SIOCGIFBRDADDR: - args->cmd = OSIOCGIFBRDADDR; - return ioctl(p, (struct ioctl_args *)args); - - case LINUX_SIOCGIFNETMASK: - args->cmd = OSIOCGIFNETMASK; - return ioctl(p, (struct ioctl_args *)args); - - /* get hardware address */ - case LINUX_SIOCGIFHWADDR: - { - int ifn; - struct ifnet *ifp; - struct ifaddr *ifa; - struct sockaddr_dl *sdl; - struct linux_ifreq *ifr = (struct linux_ifreq *)args->arg; - - /* - * Note that we don't actually respect the name in the ifreq structure, as - * Linux interface names are all different - */ + switch (args->cmd & 0xffff) { - for (ifn = 0; ifn < if_index; ifn++) { + case LINUX_SOUND_MIXER_WRITE_VOLUME: + args->cmd = SETDIR(SOUND_MIXER_WRITE_VOLUME); + return (ioctl(p, (struct ioctl_args *)args)); - ifp = ifnet_addrs[ifn]->ifa_ifp; /* pointer to interface */ - if (ifp->if_type == IFT_ETHER) { /* looks good */ - /* walk the address list */ - for (ifa = TAILQ_FIRST(&ifp->if_addrhead); ifa; ifa = TAILQ_NEXT(ifa, ifa_link)) { - if ((sdl = (struct sockaddr_dl *)ifa->ifa_addr) && /* we have an address structure */ - (sdl->sdl_family == AF_LINK) && /* it's a link address */ - (sdl->sdl_type == IFT_ETHER)) { /* for an ethernet link */ + case LINUX_SOUND_MIXER_WRITE_BASS: + args->cmd = SETDIR(SOUND_MIXER_WRITE_BASS); + return (ioctl(p, (struct ioctl_args *)args)); - return(copyout(LLADDR(sdl), (caddr_t)&ifr->ifr_hwaddr.sa_data, LINUX_IFHWADDRLEN)); - } - } - } - } - return(ENOENT); /* ??? */ - } - - case LINUX_SIOCADDMULTI: - args->cmd = SIOCADDMULTI; - return ioctl(p, (struct ioctl_args *)args); - - case LINUX_SIOCDELMULTI: - args->cmd = SIOCDELMULTI; - return ioctl(p, (struct ioctl_args *)args); - - case LINUX_FIOSETOWN: - args->cmd = FIOSETOWN; - return ioctl(p, (struct ioctl_args *)args); - - case LINUX_SIOCSPGRP: - args->cmd = SIOCSPGRP; - return ioctl(p, (struct ioctl_args *)args); - - case LINUX_FIOGETOWN: - args->cmd = FIOGETOWN; - return ioctl(p, (struct ioctl_args *)args); - - case LINUX_SIOCGPGRP: - args->cmd = SIOCGPGRP; - return ioctl(p, (struct ioctl_args *)args); - - case LINUX_SIOCATMARK: - args->cmd = SIOCATMARK; - return ioctl(p, (struct ioctl_args *)args); - - case LINUX_TIOCSETD: - switch (args->arg) { - case LINUX_N_TTY: - bsd_line = TTYDISC; - return fo_ioctl(fp, TIOCSETD, (caddr_t)&bsd_line, p); - case LINUX_N_SLIP: - bsd_line = SLIPDISC; - return fo_ioctl(fp, TIOCSETD, (caddr_t)&bsd_line, p); - case LINUX_N_PPP: - bsd_line = PPPDISC; - return fo_ioctl(fp, TIOCSETD, (caddr_t)&bsd_line, p); - default: - return EINVAL; - } + case LINUX_SOUND_MIXER_WRITE_TREBLE: + args->cmd = SETDIR(SOUND_MIXER_WRITE_TREBLE); + return (ioctl(p, (struct ioctl_args *)args)); + + case LINUX_SOUND_MIXER_WRITE_SYNTH: + args->cmd = SETDIR(SOUND_MIXER_WRITE_SYNTH); + return (ioctl(p, (struct ioctl_args *)args)); + + case LINUX_SOUND_MIXER_WRITE_PCM: + args->cmd = SETDIR(SOUND_MIXER_WRITE_PCM); + return (ioctl(p, (struct ioctl_args *)args)); + + case LINUX_SOUND_MIXER_WRITE_SPEAKER: + args->cmd = SETDIR(SOUND_MIXER_WRITE_SPEAKER); + return (ioctl(p, (struct ioctl_args *)args)); + + case LINUX_SOUND_MIXER_WRITE_LINE: + args->cmd = SETDIR(SOUND_MIXER_WRITE_LINE); + return (ioctl(p, (struct ioctl_args *)args)); + + case LINUX_SOUND_MIXER_WRITE_MIC: + args->cmd = SETDIR(SOUND_MIXER_WRITE_MIC); + return (ioctl(p, (struct ioctl_args *)args)); - case LINUX_TIOCGETD: - bsd_line = TTYDISC; - error = fo_ioctl(fp, TIOCGETD, (caddr_t)&bsd_line, p); - if (error) - return error; - switch (bsd_line) { - case TTYDISC: - linux_line = LINUX_N_TTY; - break; - case SLIPDISC: - linux_line = LINUX_N_SLIP; - break; - case PPPDISC: - linux_line = LINUX_N_PPP; - break; - default: - return EINVAL; + case LINUX_SOUND_MIXER_WRITE_CD: + args->cmd = SETDIR(SOUND_MIXER_WRITE_CD); + return (ioctl(p, (struct ioctl_args *)args)); + + case LINUX_SOUND_MIXER_WRITE_IMIX: + args->cmd = SETDIR(SOUND_MIXER_WRITE_IMIX); + return (ioctl(p, (struct ioctl_args *)args)); + + case LINUX_SOUND_MIXER_WRITE_ALTPCM: + args->cmd = SETDIR(SOUND_MIXER_WRITE_ALTPCM); + return (ioctl(p, (struct ioctl_args *)args)); + + case LINUX_SOUND_MIXER_WRITE_RECLEV: + args->cmd = SETDIR(SOUND_MIXER_WRITE_RECLEV); + return (ioctl(p, (struct ioctl_args *)args)); + + case LINUX_SOUND_MIXER_WRITE_IGAIN: + args->cmd = SETDIR(SOUND_MIXER_WRITE_IGAIN); + return (ioctl(p, (struct ioctl_args *)args)); + + case LINUX_SOUND_MIXER_WRITE_OGAIN: + args->cmd = SETDIR(SOUND_MIXER_WRITE_OGAIN); + return (ioctl(p, (struct ioctl_args *)args)); + + case LINUX_SOUND_MIXER_WRITE_LINE1: + args->cmd = SETDIR(SOUND_MIXER_WRITE_LINE1); + return (ioctl(p, (struct ioctl_args *)args)); + + case LINUX_SOUND_MIXER_WRITE_LINE2: + args->cmd = SETDIR(SOUND_MIXER_WRITE_LINE2); + return (ioctl(p, (struct ioctl_args *)args)); + + case LINUX_SOUND_MIXER_WRITE_LINE3: + args->cmd = SETDIR(SOUND_MIXER_WRITE_LINE3); + return (ioctl(p, (struct ioctl_args *)args)); + + case LINUX_OSS_GETVERSION: { + int version = linux_get_oss_version(p); + return (copyout(&version, (caddr_t)args->arg, sizeof(int))); } - return copyout(&linux_line, (caddr_t)args->arg, - sizeof(int)); - case LINUX_SNDCTL_SEQ_RESET: - args->cmd = SNDCTL_SEQ_RESET; - return ioctl(p, (struct ioctl_args *)args); + case LINUX_SOUND_MIXER_READ_DEVMASK: + args->cmd = SOUND_MIXER_READ_DEVMASK; + return (ioctl(p, (struct ioctl_args *)args)); - case LINUX_SNDCTL_SEQ_SYNC: - args->cmd = SNDCTL_SEQ_SYNC; - return ioctl(p, (struct ioctl_args *)args); + case LINUX_SNDCTL_DSP_RESET: + args->cmd = SNDCTL_DSP_RESET; + return (ioctl(p, (struct ioctl_args *)args)); - case LINUX_SNDCTL_SYNTH_INFO: - args->cmd = SNDCTL_SYNTH_INFO; - return ioctl(p, (struct ioctl_args *)args); + case LINUX_SNDCTL_DSP_SYNC: + args->cmd = SNDCTL_DSP_SYNC; + return (ioctl(p, (struct ioctl_args *)args)); - case LINUX_SNDCTL_SEQ_CTRLRATE: - args->cmd = SNDCTL_SEQ_CTRLRATE; - return ioctl(p, (struct ioctl_args *)args); + case LINUX_SNDCTL_DSP_SPEED: + args->cmd = SNDCTL_DSP_SPEED; + return (ioctl(p, (struct ioctl_args *)args)); - case LINUX_SNDCTL_SEQ_GETOUTCOUNT: - args->cmd = SNDCTL_SEQ_GETOUTCOUNT; - return ioctl(p, (struct ioctl_args *)args); + case LINUX_SNDCTL_DSP_STEREO: + args->cmd = SNDCTL_DSP_STEREO; + return (ioctl(p, (struct ioctl_args *)args)); - case LINUX_SNDCTL_SEQ_GETINCOUNT: - args->cmd = SNDCTL_SEQ_GETINCOUNT; - return ioctl(p, (struct ioctl_args *)args); + case LINUX_SNDCTL_DSP_GETBLKSIZE: /* LINUX_SNDCTL_DSP_SETBLKSIZE */ + args->cmd = SNDCTL_DSP_GETBLKSIZE; + return (ioctl(p, (struct ioctl_args *)args)); - case LINUX_SNDCTL_SEQ_PERCMODE: - args->cmd = SNDCTL_SEQ_PERCMODE; - return ioctl(p, (struct ioctl_args *)args); + case LINUX_SNDCTL_DSP_SETFMT: + args->cmd = SNDCTL_DSP_SETFMT; + return (ioctl(p, (struct ioctl_args *)args)); - case LINUX_SNDCTL_FM_LOAD_INSTR: - args->cmd = SNDCTL_FM_LOAD_INSTR; - return ioctl(p, (struct ioctl_args *)args); + case LINUX_SOUND_PCM_WRITE_CHANNELS: + args->cmd = SOUND_PCM_WRITE_CHANNELS; + return (ioctl(p, (struct ioctl_args *)args)); - case LINUX_SNDCTL_SEQ_TESTMIDI: - args->cmd = SNDCTL_SEQ_TESTMIDI; - return ioctl(p, (struct ioctl_args *)args); + case LINUX_SOUND_PCM_WRITE_FILTER: + args->cmd = SOUND_PCM_WRITE_FILTER; + return (ioctl(p, (struct ioctl_args *)args)); - case LINUX_SNDCTL_SEQ_RESETSAMPLES: - args->cmd = SNDCTL_SEQ_RESETSAMPLES; - return ioctl(p, (struct ioctl_args *)args); + case LINUX_SNDCTL_DSP_POST: + args->cmd = SNDCTL_DSP_POST; + return (ioctl(p, (struct ioctl_args *)args)); - case LINUX_SNDCTL_SEQ_NRSYNTHS: - args->cmd = SNDCTL_SEQ_NRSYNTHS; - return ioctl(p, (struct ioctl_args *)args); + case LINUX_SNDCTL_DSP_SUBDIVIDE: + args->cmd = SNDCTL_DSP_SUBDIVIDE; + return (ioctl(p, (struct ioctl_args *)args)); - case LINUX_SNDCTL_SEQ_NRMIDIS: - args->cmd = SNDCTL_SEQ_NRMIDIS; - return ioctl(p, (struct ioctl_args *)args); + case LINUX_SNDCTL_DSP_SETFRAGMENT: + args->cmd = SNDCTL_DSP_SETFRAGMENT; + return (ioctl(p, (struct ioctl_args *)args)); - case LINUX_SNDCTL_MIDI_INFO: - args->cmd = SNDCTL_MIDI_INFO; - return ioctl(p, (struct ioctl_args *)args); + case LINUX_SNDCTL_DSP_GETFMTS: + args->cmd = SNDCTL_DSP_GETFMTS; + return (ioctl(p, (struct ioctl_args *)args)); - case LINUX_SNDCTL_SEQ_TRESHOLD: - args->cmd = SNDCTL_SEQ_TRESHOLD; - return ioctl(p, (struct ioctl_args *)args); + case LINUX_SNDCTL_DSP_GETOSPACE: + args->cmd = SNDCTL_DSP_GETOSPACE; + return (ioctl(p, (struct ioctl_args *)args)); - case LINUX_SNDCTL_SYNTH_MEMAVL: - args->cmd = SNDCTL_SYNTH_MEMAVL; - return ioctl(p, (struct ioctl_args *)args); + case LINUX_SNDCTL_DSP_GETISPACE: + args->cmd = SNDCTL_DSP_GETISPACE; + return (ioctl(p, (struct ioctl_args *)args)); - case LINUX_SNDCTL_DSP_GETOPTR : - args->cmd = SNDCTL_DSP_GETOPTR; - return ioctl(p, (struct ioctl_args *)args); + case LINUX_SNDCTL_DSP_NONBLOCK: + args->cmd = SNDCTL_DSP_NONBLOCK; + return (ioctl(p, (struct ioctl_args *)args)); - case LINUX_SNDCTL_DSP_GETIPTR : - args->cmd = SNDCTL_DSP_GETIPTR; - return ioctl(p, (struct ioctl_args *)args); + case LINUX_SNDCTL_DSP_GETCAPS: + args->cmd = SNDCTL_DSP_GETCAPS; + return (ioctl(p, (struct ioctl_args *)args)); - case LINUX_SNDCTL_DSP_SETTRIGGER: - args->cmd = SNDCTL_DSP_SETTRIGGER; - return ioctl(p, (struct ioctl_args *)args); + case LINUX_SNDCTL_DSP_SETTRIGGER: /* LINUX_SNDCTL_GETTRIGGER */ + args->cmd = SNDCTL_DSP_SETTRIGGER; + return (ioctl(p, (struct ioctl_args *)args)); - case LINUX_SNDCTL_DSP_GETCAPS: - args->cmd = SNDCTL_DSP_GETCAPS; - return ioctl(p, (struct ioctl_args *)args); + case LINUX_SNDCTL_DSP_GETIPTR: + args->cmd = SNDCTL_DSP_GETIPTR; + return (ioctl(p, (struct ioctl_args *)args)); - case LINUX_SNDCTL_DSP_RESET: - args->cmd = SNDCTL_DSP_RESET; - return ioctl(p, (struct ioctl_args *)args); + case LINUX_SNDCTL_DSP_GETOPTR: + args->cmd = SNDCTL_DSP_GETOPTR; + return (ioctl(p, (struct ioctl_args *)args)); - case LINUX_SNDCTL_DSP_SYNC: - args->cmd = SNDCTL_DSP_SYNC; - return ioctl(p, (struct ioctl_args *)args); + case LINUX_SNDCTL_DSP_GETODELAY: + args->cmd = SNDCTL_DSP_GETODELAY; + return (ioctl(p, (struct ioctl_args *)args)); - case LINUX_SNDCTL_DSP_SPEED: - args->cmd = SNDCTL_DSP_SPEED; - return ioctl(p, (struct ioctl_args *)args); + case LINUX_SNDCTL_SEQ_RESET: + args->cmd = SNDCTL_SEQ_RESET; + return (ioctl(p, (struct ioctl_args *)args)); - case LINUX_SNDCTL_DSP_STEREO: - args->cmd = SNDCTL_DSP_STEREO; - return ioctl(p, (struct ioctl_args *)args); + case LINUX_SNDCTL_SEQ_SYNC: + args->cmd = SNDCTL_SEQ_SYNC; + return (ioctl(p, (struct ioctl_args *)args)); - case LINUX_SNDCTL_DSP_GETBLKSIZE: - /* LINUX_SNDCTL_DSP_SETBLKSIZE */ - args->cmd = SNDCTL_DSP_GETBLKSIZE; - return ioctl(p, (struct ioctl_args *)args); + case LINUX_SNDCTL_SYNTH_INFO: + args->cmd = SNDCTL_SYNTH_INFO; + return (ioctl(p, (struct ioctl_args *)args)); - case LINUX_SNDCTL_DSP_GETODELAY: - args->cmd = SNDCTL_DSP_GETODELAY; - return ioctl(p, (struct ioctl_args *)args); + case LINUX_SNDCTL_SEQ_CTRLRATE: + args->cmd = SNDCTL_SEQ_CTRLRATE; + return (ioctl(p, (struct ioctl_args *)args)); - case LINUX_SNDCTL_DSP_SETFMT: - args->cmd = SNDCTL_DSP_SETFMT; - return ioctl(p, (struct ioctl_args *)args); + case LINUX_SNDCTL_SEQ_GETOUTCOUNT: + args->cmd = SNDCTL_SEQ_GETOUTCOUNT; + return (ioctl(p, (struct ioctl_args *)args)); - case LINUX_SOUND_PCM_WRITE_CHANNELS: - args->cmd = SOUND_PCM_WRITE_CHANNELS; - return ioctl(p, (struct ioctl_args *)args); + case LINUX_SNDCTL_SEQ_GETINCOUNT: + args->cmd = SNDCTL_SEQ_GETINCOUNT; + return (ioctl(p, (struct ioctl_args *)args)); - case LINUX_SOUND_PCM_WRITE_FILTER: - args->cmd = SOUND_PCM_WRITE_FILTER; - return ioctl(p, (struct ioctl_args *)args); + case LINUX_SNDCTL_SEQ_PERCMODE: + args->cmd = SNDCTL_SEQ_PERCMODE; + return (ioctl(p, (struct ioctl_args *)args)); - case LINUX_SNDCTL_DSP_POST: - args->cmd = SNDCTL_DSP_POST; - return ioctl(p, (struct ioctl_args *)args); + case LINUX_SNDCTL_FM_LOAD_INSTR: + args->cmd = SNDCTL_FM_LOAD_INSTR; + return (ioctl(p, (struct ioctl_args *)args)); - case LINUX_SNDCTL_DSP_SUBDIVIDE: - args->cmd = SNDCTL_DSP_SUBDIVIDE; - return ioctl(p, (struct ioctl_args *)args); - - case LINUX_SNDCTL_DSP_SETFRAGMENT: - args->cmd = SNDCTL_DSP_SETFRAGMENT; - return ioctl(p, (struct ioctl_args *)args); + case LINUX_SNDCTL_SEQ_TESTMIDI: + args->cmd = SNDCTL_SEQ_TESTMIDI; + return (ioctl(p, (struct ioctl_args *)args)); - case LINUX_SNDCTL_DSP_GETFMTS: - args->cmd = SNDCTL_DSP_GETFMTS; - return ioctl(p, (struct ioctl_args *)args); - - case LINUX_SNDCTL_DSP_GETOSPACE: - args->cmd = SNDCTL_DSP_GETOSPACE; - return ioctl(p, (struct ioctl_args *)args); - - case LINUX_SNDCTL_DSP_GETISPACE: - args->cmd = SNDCTL_DSP_GETISPACE; - return ioctl(p, (struct ioctl_args *)args); - - case LINUX_SNDCTL_DSP_NONBLOCK: - args->cmd = SNDCTL_DSP_NONBLOCK; - return ioctl(p, (struct ioctl_args *)args); - - case LINUX_SOUND_MIXER_WRITE_VOLUME: - args->cmd = SETDIR(SOUND_MIXER_WRITE_VOLUME); - return ioctl(p, (struct ioctl_args *)args); - - case LINUX_SOUND_MIXER_WRITE_BASS: - args->cmd = SETDIR(SOUND_MIXER_WRITE_BASS); - return ioctl(p, (struct ioctl_args *)args); - - case LINUX_SOUND_MIXER_WRITE_TREBLE: - args->cmd = SETDIR(SOUND_MIXER_WRITE_TREBLE); - return ioctl(p, (struct ioctl_args *)args); - - case LINUX_SOUND_MIXER_WRITE_SYNTH: - args->cmd = SETDIR(SOUND_MIXER_WRITE_SYNTH); - return ioctl(p, (struct ioctl_args *)args); - - case LINUX_SOUND_MIXER_WRITE_PCM: - args->cmd = SETDIR(SOUND_MIXER_WRITE_PCM); - return ioctl(p, (struct ioctl_args *)args); - - case LINUX_SOUND_MIXER_WRITE_SPEAKER: - args->cmd = SETDIR(SOUND_MIXER_WRITE_SPEAKER); - return ioctl(p, (struct ioctl_args *)args); - - case LINUX_SOUND_MIXER_WRITE_LINE: - args->cmd = SETDIR(SOUND_MIXER_WRITE_LINE); - return ioctl(p, (struct ioctl_args *)args); - - case LINUX_SOUND_MIXER_WRITE_MIC: - args->cmd = SETDIR(SOUND_MIXER_WRITE_MIC); - return ioctl(p, (struct ioctl_args *)args); - - case LINUX_SOUND_MIXER_WRITE_CD: - args->cmd = SETDIR(SOUND_MIXER_WRITE_CD); - return ioctl(p, (struct ioctl_args *)args); - - case LINUX_SOUND_MIXER_WRITE_IMIX: - args->cmd = SETDIR(SOUND_MIXER_WRITE_IMIX); - return ioctl(p, (struct ioctl_args *)args); - - case LINUX_SOUND_MIXER_WRITE_ALTPCM: - args->cmd = SETDIR(SOUND_MIXER_WRITE_ALTPCM); - return ioctl(p, (struct ioctl_args *)args); - - case LINUX_SOUND_MIXER_WRITE_RECLEV: - args->cmd = SETDIR(SOUND_MIXER_WRITE_RECLEV); - return ioctl(p, (struct ioctl_args *)args); - - case LINUX_SOUND_MIXER_WRITE_IGAIN: - args->cmd = SETDIR(SOUND_MIXER_WRITE_IGAIN); - return ioctl(p, (struct ioctl_args *)args); - - case LINUX_SOUND_MIXER_WRITE_OGAIN: - args->cmd = SETDIR(SOUND_MIXER_WRITE_OGAIN); - return ioctl(p, (struct ioctl_args *)args); + case LINUX_SNDCTL_SEQ_RESETSAMPLES: + args->cmd = SNDCTL_SEQ_RESETSAMPLES; + return (ioctl(p, (struct ioctl_args *)args)); - case LINUX_SOUND_MIXER_WRITE_LINE1: - args->cmd = SETDIR(SOUND_MIXER_WRITE_LINE1); - return ioctl(p, (struct ioctl_args *)args); + case LINUX_SNDCTL_SEQ_NRSYNTHS: + args->cmd = SNDCTL_SEQ_NRSYNTHS; + return (ioctl(p, (struct ioctl_args *)args)); - case LINUX_SOUND_MIXER_WRITE_LINE2: - args->cmd = SETDIR(SOUND_MIXER_WRITE_LINE2); - return ioctl(p, (struct ioctl_args *)args); + case LINUX_SNDCTL_SEQ_NRMIDIS: + args->cmd = SNDCTL_SEQ_NRMIDIS; + return (ioctl(p, (struct ioctl_args *)args)); - case LINUX_SOUND_MIXER_WRITE_LINE3: - args->cmd = SETDIR(SOUND_MIXER_WRITE_LINE3); - return ioctl(p, (struct ioctl_args *)args); + case LINUX_SNDCTL_MIDI_INFO: + args->cmd = SNDCTL_MIDI_INFO; + return (ioctl(p, (struct ioctl_args *)args)); - case LINUX_SOUND_MIXER_READ_DEVMASK: - args->cmd = SOUND_MIXER_READ_DEVMASK; - return ioctl(p, (struct ioctl_args *)args); + case LINUX_SNDCTL_SEQ_TRESHOLD: + args->cmd = SNDCTL_SEQ_TRESHOLD; + return (ioctl(p, (struct ioctl_args *)args)); - case LINUX_TIOCGSERIAL: { - struct linux_serial_struct lss; + case LINUX_SNDCTL_SYNTH_MEMAVL: + args->cmd = SNDCTL_SYNTH_MEMAVL; + return (ioctl(p, (struct ioctl_args *)args)); - lss.type = LINUX_PORT_16550A; - lss.flags = 0; - lss.close_delay = 0; - return copyout((caddr_t)&lss, (caddr_t)args->arg, sizeof(lss)); - } + } - case LINUX_TIOCSSERIAL: { - struct linux_serial_struct lss; + return (ENOIOCTL); +} - error = copyin((caddr_t)args->arg, (caddr_t)&lss, sizeof(lss)); - if (error) - return error; - /* - * XXX - It really helps to have an implementation that does nothing. - * NOT! - */ - return 0; - } - - case LINUX_TCXONC: - switch (args->arg) { - case LINUX_TCOOFF: - args->cmd = TIOCSTOP; - break; - case LINUX_TCOON: - args->cmd = TIOCSTART; - break; - case LINUX_TCIOFF: - case LINUX_TCION: { - u_char c; - struct write_args wr; - error = fo_ioctl(fp, TIOCGETA, (caddr_t)&bsd_termios, p); - if (error != 0) - return error; - c = bsd_termios.c_cc[args->arg == LINUX_TCIOFF ? VSTOP : VSTART]; - if (c != _POSIX_VDISABLE) { - wr.fd = args->fd; - wr.buf = &c; - wr.nbyte = sizeof(c); - return write(p, &wr); - } - else - return (0); - } - default: - return EINVAL; - } - args->arg = 0; - return ioctl(p, (struct ioctl_args *)args); - - case LINUX_TCFLSH: - args->cmd = TIOCFLUSH; - switch (args->arg) { - case LINUX_TCIFLUSH: - args->arg = FREAD; - break; - case LINUX_TCOFLUSH: - args->arg = FWRITE; - break; - case LINUX_TCIOFLUSH: - args->arg = FREAD | FWRITE; - break; - default: - return EINVAL; - } - return ioctl(p, (struct ioctl_args *)args); - - case LINUX_VT_OPENQRY: - - args->cmd = VT_OPENQRY; - return ioctl(p, (struct ioctl_args *)args); - - case LINUX_VT_GETMODE: - - args->cmd = VT_GETMODE; - return ioctl(p, (struct ioctl_args *)args); - - case LINUX_VT_SETMODE: - { - struct vt_mode *mode; - args->cmd = VT_SETMODE; - mode = (struct vt_mode *)args->arg; - if (!ISSIGVALID(mode->frsig) && ISSIGVALID(mode->acqsig)) - mode->frsig = mode->acqsig; - return ioctl(p, (struct ioctl_args *)args); - } - - case LINUX_VT_GETSTATE: - - args->cmd = VT_GETACTIVE; - return ioctl(p, (struct ioctl_args *)args); - - case LINUX_VT_RELDISP: - - args->cmd = VT_RELDISP; - return ioctl(p, (struct ioctl_args *)args); - - case LINUX_VT_ACTIVATE: - - args->cmd = VT_ACTIVATE; - return ioctl(p, (struct ioctl_args *)args); - - case LINUX_VT_WAITACTIVE: - - args->cmd = VT_WAITACTIVE; - return ioctl(p, (struct ioctl_args *)args); - - case LINUX_KDGKBMODE: - - args->cmd = KDGKBMODE; - return ioctl(p, (struct ioctl_args *)args); - - case LINUX_KDSKBMODE: - { - int kbdmode; - switch (args->arg) { - case LINUX_KBD_RAW: - kbdmode = K_RAW; - return fo_ioctl(fp, KDSKBMODE, (caddr_t)&kbdmode, p); - case LINUX_KBD_XLATE: - kbdmode = K_XLATE; - return fo_ioctl(fp, KDSKBMODE , (caddr_t)&kbdmode, p); - case LINUX_KBD_MEDIUMRAW: - kbdmode = K_RAW; - return fo_ioctl(fp, KDSKBMODE , (caddr_t)&kbdmode, p); - default: - return EINVAL; +/* + * Console related ioctls + */ + +#define ISSIGVALID(sig) ((sig) > 0 && (sig) < NSIG) + +static int +linux_ioctl_console(struct proc *p, struct linux_ioctl_args *args) +{ + struct file *fp = p->p_fd->fd_ofiles[args->fd]; + + switch (args->cmd & 0xffff) { + + case LINUX_KIOCSOUND: + args->cmd = KIOCSOUND; + return (ioctl(p, (struct ioctl_args *)args)); + + case LINUX_KDMKTONE: + args->cmd = KDMKTONE; + return (ioctl(p, (struct ioctl_args *)args)); + + case LINUX_KDGETLED: + args->cmd = KDGETLED; + return (ioctl(p, (struct ioctl_args *)args)); + + case LINUX_KDSETLED: + args->cmd = KDSETLED; + return (ioctl(p, (struct ioctl_args *)args)); + + case LINUX_KDSETMODE: + args->cmd = KDSETMODE; + return (ioctl(p, (struct ioctl_args *)args)); + + case LINUX_KDGETMODE: + args->cmd = KDGETMODE; + return (ioctl(p, (struct ioctl_args *)args)); + + case LINUX_KDGKBMODE: + args->cmd = KDGKBMODE; + return (ioctl(p, (struct ioctl_args *)args)); + + case LINUX_KDSKBMODE: { + int kbdmode; + switch (args->arg) { + case LINUX_KBD_RAW: + kbdmode = K_RAW; + break; + case LINUX_KBD_XLATE: + kbdmode = K_XLATE; + break; + case LINUX_KBD_MEDIUMRAW: + kbdmode = K_RAW; + break; + default: + return (EINVAL); + } + return (fo_ioctl(fp, KDSKBMODE, (caddr_t)&kbdmode, p)); } - } - case LINUX_KDGETMODE: - args->cmd = KDGETMODE; - return ioctl(p, (struct ioctl_args *)args); + case LINUX_VT_OPENQRY: + args->cmd = VT_OPENQRY; + return (ioctl(p, (struct ioctl_args *)args)); + + case LINUX_VT_GETMODE: + args->cmd = VT_GETMODE; + return (ioctl(p, (struct ioctl_args *)args)); + + case LINUX_VT_SETMODE: { + struct vt_mode *mode; + args->cmd = VT_SETMODE; + mode = (struct vt_mode *)args->arg; + if (!ISSIGVALID(mode->frsig) && ISSIGVALID(mode->acqsig)) + mode->frsig = mode->acqsig; + return (ioctl(p, (struct ioctl_args *)args)); + } - case LINUX_KDSETMODE: - args->cmd = KDSETMODE; - return ioctl(p, (struct ioctl_args *)args); + case LINUX_VT_GETSTATE: + args->cmd = VT_GETACTIVE; + return (ioctl(p, (struct ioctl_args *)args)); - case LINUX_KDSETLED: - args->cmd = KDSETLED; - return ioctl(p, (struct ioctl_args *)args); + case LINUX_VT_RELDISP: + args->cmd = VT_RELDISP; + return (ioctl(p, (struct ioctl_args *)args)); - case LINUX_KDGETLED: - args->cmd = KDGETLED; - return ioctl(p, (struct ioctl_args *)args); + case LINUX_VT_ACTIVATE: + args->cmd = VT_ACTIVATE; + return (ioctl(p, (struct ioctl_args *)args)); - case LINUX_KIOCSOUND: - args->cmd = KIOCSOUND; - return ioctl(p, (struct ioctl_args *)args); + case LINUX_VT_WAITACTIVE: + args->cmd = VT_WAITACTIVE; + return (ioctl(p, (struct ioctl_args *)args)); - case LINUX_KDMKTONE: - args->cmd = KDMKTONE; - return ioctl(p, (struct ioctl_args *)args); + } + + return (ENOIOCTL); +} +/* + * Socket related ioctls + */ - case LINUX_CDROMPAUSE: - args->cmd = CDIOCPAUSE; - return ioctl(p, (struct ioctl_args *)args); +static int +linux_ioctl_socket(struct proc *p, struct linux_ioctl_args *args) +{ - case LINUX_CDROMRESUME: - args->cmd = CDIOCRESUME; - return ioctl(p, (struct ioctl_args *)args); + switch (args->cmd & 0xffff) { + + case LINUX_FIOSETOWN: + args->cmd = FIOSETOWN; + return (ioctl(p, (struct ioctl_args *)args)); + + case LINUX_SIOCSPGRP: + args->cmd = SIOCSPGRP; + return (ioctl(p, (struct ioctl_args *)args)); + + case LINUX_FIOGETOWN: + args->cmd = FIOGETOWN; + return (ioctl(p, (struct ioctl_args *)args)); + + case LINUX_SIOCGPGRP: + args->cmd = SIOCGPGRP; + return (ioctl(p, (struct ioctl_args *)args)); + + case LINUX_SIOCATMARK: + args->cmd = SIOCATMARK; + return (ioctl(p, (struct ioctl_args *)args)); + + /* LINUX_SIOCGSTAMP */ + + case LINUX_SIOCGIFCONF: + args->cmd = OSIOCGIFCONF; + return (ioctl(p, (struct ioctl_args *)args)); + + case LINUX_SIOCGIFFLAGS: + args->cmd = SIOCGIFFLAGS; + return (ioctl(p, (struct ioctl_args *)args)); + + case LINUX_SIOCGIFADDR: + args->cmd = OSIOCGIFADDR; + return (ioctl(p, (struct ioctl_args *)args)); + + case LINUX_SIOCGIFDSTADDR: + args->cmd = OSIOCGIFDSTADDR; + return (ioctl(p, (struct ioctl_args *)args)); + + case LINUX_SIOCGIFBRDADDR: + args->cmd = OSIOCGIFBRDADDR; + return (ioctl(p, (struct ioctl_args *)args)); + + case LINUX_SIOCGIFNETMASK: + args->cmd = OSIOCGIFNETMASK; + return (ioctl(p, (struct ioctl_args *)args)); + + case LINUX_SIOCGIFHWADDR: { + int ifn; + struct ifnet *ifp; + struct ifaddr *ifa; + struct sockaddr_dl *sdl; + struct linux_ifreq *ifr = (struct linux_ifreq *)args->arg; + + /* Note that we don't actually respect the name in the ifreq + * structure, as Linux interface names are all different. + */ + for (ifn = 0; ifn < if_index; ifn++) { + ifp = ifnet_addrs[ifn]->ifa_ifp; + if (ifp->if_type == IFT_ETHER) { + ifa = TAILQ_FIRST(&ifp->if_addrhead); + while (ifa) { + sdl=(struct sockaddr_dl*)ifa->ifa_addr; + if (sdl != NULL && + (sdl->sdl_family == AF_LINK) && + (sdl->sdl_type == IFT_ETHER)) { + return (copyout(LLADDR(sdl), + &ifr->ifr_hwaddr.sa_data, + LINUX_IFHWADDRLEN)); + } + ifa = TAILQ_NEXT(ifa, ifa_link); + } + } + } + return (ENOENT); + } - case LINUX_CDROMPLAYMSF: - args->cmd = CDIOCPLAYMSF; - return ioctl(p, (struct ioctl_args *)args); + case LINUX_SIOCADDMULTI: + args->cmd = SIOCADDMULTI; + return (ioctl(p, (struct ioctl_args *)args)); - case LINUX_CDROMPLAYTRKIND: - args->cmd = CDIOCPLAYTRACKS; - return ioctl(p, (struct ioctl_args *)args); + case LINUX_SIOCDELMULTI: + args->cmd = SIOCDELMULTI; + return (ioctl(p, (struct ioctl_args *)args)); - case LINUX_CDROMSTART: - args->cmd = CDIOCSTART; - return ioctl(p, (struct ioctl_args *)args); + } - case LINUX_CDROMSTOP: - args->cmd = CDIOCSTOP; - return ioctl(p, (struct ioctl_args *)args); + return (ENOIOCTL); +} - case LINUX_CDROMEJECT: - args->cmd = CDIOCEJECT; - return ioctl(p, (struct ioctl_args *)args); +/* + * main ioctl syscall function + */ - case LINUX_CDROMRESET: - args->cmd = CDIOCRESET; - return ioctl(p, (struct ioctl_args *)args); +int +linux_ioctl(struct proc *p, struct linux_ioctl_args *args) +{ + struct filedesc *fdp = p->p_fd; + struct file *fp; + struct handler_element *he; + int error, cmd; + +#ifdef DEBUG + printf("Linux-emul(%ld): ioctl(%d, %04lx, *)\n", (long)p->p_pid, + args->fd, args->cmd); +#endif + + if ((unsigned)args->fd >= fdp->fd_nfiles) + return (EBADF); + + fp = fdp->fd_ofiles[args->fd]; + if (fp == NULL || (fp->f_flag & (FREAD|FWRITE)) == 0) + return (EBADF); + + /* Iterate over the ioctl handlers */ + cmd = args->cmd & 0xffff; + TAILQ_FOREACH(he, &handlers, list) { + if (cmd >= he->low && cmd <= he->high) { + error = (*he->func)(p, args); + if (error != ENOIOCTL) + return (error); + } + } + + printf("linux: 'ioctl' fd=%d, cmd=%x ('%c',%d) not implemented\n", + args->fd, (int)(args->cmd & 0xffff), + (int)(args->cmd & 0xff00) >> 8, (int)(args->cmd & 0xff)); + + return (EINVAL); +} + +int +linux_ioctl_register_handler(struct linux_ioctl_handler *h) +{ + struct handler_element *he, *cur; + + if (h == NULL || h->func == NULL) + return (EINVAL); + + /* + * Reuse the element if the handler is already on the list, otherwise + * create a new element. + */ + TAILQ_FOREACH(he, &handlers, list) { + if (he->func == h->func) + break; + } + if (he == NULL) { + MALLOC(he, struct handler_element *, sizeof(*he), + M_LINUX, M_WAITOK); + he->func = h->func; + } else + TAILQ_REMOVE(&handlers, he, list); + + /* Initialize range information. */ + he->low = h->low; + he->high = h->high; + he->span = h->high - h->low + 1; + + /* Add the element to the list, sorted on span. */ + TAILQ_FOREACH(cur, &handlers, list) { + if (cur->span > he->span) { + TAILQ_INSERT_BEFORE(cur, he, list); + return (0); + } + } + TAILQ_INSERT_TAIL(&handlers, he, list); - case LINUX_CDROMREADTOCHDR: { - struct ioc_toc_header th; - struct linux_cdrom_tochdr lth; - error = fo_ioctl(fp, CDIOREADTOCHEADER, (caddr_t)&th, p); - if (!error) { - lth.cdth_trk0 = th.starting_track; - lth.cdth_trk1 = th.ending_track; - copyout((caddr_t)<h, (caddr_t)args->arg, sizeof(lth)); + return (0); +} + +int +linux_ioctl_unregister_handler(struct linux_ioctl_handler *h) +{ + struct handler_element *he; + + if (h == NULL || h->func == NULL) + return (EINVAL); + + TAILQ_FOREACH(he, &handlers, list) { + if (he->func == h->func) { + TAILQ_REMOVE(&handlers, he, list); + FREE(he, M_LINUX); + return (0); + } } - return error; - } - - case LINUX_CDROMREADTOCENTRY: { - struct linux_cdrom_tocentry lte, *ltep = - (struct linux_cdrom_tocentry *)args->arg; - struct ioc_read_toc_single_entry irtse; - irtse.address_format = ltep->cdte_format; - irtse.track = ltep->cdte_track; - error = fo_ioctl(fp, CDIOREADTOCENTRY, (caddr_t)&irtse, p); - if (!error) { - lte = *ltep; - lte.cdte_ctrl = irtse.entry.control; - lte.cdte_adr = irtse.entry.addr_type; - bsd_to_linux_msf_lba(irtse.address_format, - &irtse.entry.addr, <e.cdte_addr); - copyout((caddr_t)<e, (caddr_t)args->arg, sizeof(lte)); + + return (EINVAL); +} + +int +linux_ioctl_register_handlers(struct linker_set *s) +{ + int error, i; + + if (s == NULL) + return (EINVAL); + + for (i = 0; i < s->ls_length; i++) { + error = linux_ioctl_register_handler(s->ls_items[i]); + if (error) + return (error); } - return error; - } - - case LINUX_CDROMSUBCHNL: { - caddr_t sg; - struct linux_cdrom_subchnl sc; - struct ioc_read_subchannel bsdsc; - struct cd_sub_channel_info *bsdinfo; - - sg = stackgap_init(); - bsdinfo = (struct cd_sub_channel_info*)stackgap_alloc(&sg, - sizeof(struct cd_sub_channel_info)); - - bsdsc.address_format = CD_LBA_FORMAT; - bsdsc.data_format = CD_CURRENT_POSITION; - bsdsc.data_len = sizeof(struct cd_sub_channel_info); - bsdsc.data = bsdinfo; - error = fo_ioctl(fp, CDIOCREADSUBCHANNEL, (caddr_t)&bsdsc, p); - if (error) - return error; - - error = copyin((caddr_t)args->arg, (caddr_t)&sc, - sizeof(struct linux_cdrom_subchnl)); - if (error) - return error; - - sc.cdsc_audiostatus = bsdinfo->header.audio_status; - sc.cdsc_adr = bsdinfo->what.position.addr_type; - sc.cdsc_ctrl = bsdinfo->what.position.control; - sc.cdsc_trk = bsdinfo->what.position.track_number; - sc.cdsc_ind = bsdinfo->what.position.index_number; - set_linux_cdrom_addr(&sc.cdsc_absaddr, sc.cdsc_format, - bsdinfo->what.position.absaddr.lba); - set_linux_cdrom_addr(&sc.cdsc_reladdr, sc.cdsc_format, - bsdinfo->what.position.reladdr.lba); - error = copyout((caddr_t)&sc, (caddr_t)args->arg, - sizeof(struct linux_cdrom_subchnl)); - return error; - } - - case LINUX_OSS_GETVERSION: { - int version; - - version = linux_get_oss_version(p); - return copyout((caddr_t)&version, (caddr_t)args->arg, sizeof(int)); - } - - } - - uprintf("LINUX: 'ioctl' fd=%d, typ=0x%x(%c), num=0x%x not implemented\n", - args->fd, (u_int)((args->cmd & 0xffff00) >> 8), - (int)((args->cmd & 0xffff00) >> 8), (u_int)(args->cmd & 0xff)); - return EINVAL; + + return (0); +} + +int +linux_ioctl_unregister_handlers(struct linker_set *s) +{ + int error, i; + + if (s == NULL) + return (EINVAL); + + for (i = 0; i < s->ls_length; i++) { + error = linux_ioctl_unregister_handler(s->ls_items[i]); + if (error) + return (error); + } + + return (0); } diff --git a/sys/compat/linux/linux_ioctl.h b/sys/compat/linux/linux_ioctl.h new file mode 100644 index 0000000..fd637b4 --- /dev/null +++ b/sys/compat/linux/linux_ioctl.h @@ -0,0 +1,418 @@ +/*- + * Copyright (c) 1999 Marcel Moolenaar + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer + * in this position and unchanged. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software withough specific prior written permission + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#ifndef _LINUX_IOCTL_H_ +#define _LINUX_IOCTL_H_ + +/* + * cdrom + */ +#define LINUX_CDROMPAUSE 0x5301 +#define LINUX_CDROMRESUME 0x5302 +#define LINUX_CDROMPLAYMSF 0x5303 +#define LINUX_CDROMPLAYTRKIND 0x5304 +#define LINUX_CDROMREADTOCHDR 0x5305 +#define LINUX_CDROMREADTOCENTRY 0x5306 +#define LINUX_CDROMSTOP 0x5307 +#define LINUX_CDROMSTART 0x5308 +#define LINUX_CDROMEJECT 0x5309 +#define LINUX_CDROMVOLCTRL 0x530a +#define LINUX_CDROMSUBCHNL 0x530b +#define LINUX_CDROMREADMODE2 0x530c +#define LINUX_CDROMREADMODE1 0x530d +#define LINUX_CDROMREADAUDIO 0x530e +#define LINUX_CDROMEJECT_SW 0x530f +#define LINUX_CDROMMULTISESSION 0x5310 +#define LINUX_CDROM_GET_UPC 0x5311 +#define LINUX_CDROMRESET 0x5312 +#define LINUX_CDROMVOLREAD 0x5313 +#define LINUX_CDROMREADRAW 0x5314 +#define LINUX_CDROMREADCOOKED 0x5315 +#define LINUX_CDROMSEEK 0x5316 +#define LINUX_CDROMPLAYBLK 0x5317 +#define LINUX_CDROMREADALL 0x5318 +#define LINUX_CDROMCLOSETRAY 0x5319 +#define LINUX_CDROMLOADFROMSLOT 0x531a + +#define LINUX_IOCTL_CDROM_MIN LINUX_CDROMPAUSE +#define LINUX_IOCTL_CDROM_MAX LINUX_CDROMLOADFROMSLOT + +#define LINUX_CDROM_LBA 0x01 +#define LINUX_CDROM_MSF 0x02 + +/* + * console + */ +#define LINUX_KIOCSOUND 0x4B2F +#define LINUX_KDMKTONE 0x4B30 +#define LINUX_KDGETLED 0x4B31 +#define LINUX_KDSETLED 0x4B32 +#define LINUX_KDSETMODE 0x4B3A +#define LINUX_KDGETMODE 0x4B3B +#define LINUX_KDGKBMODE 0x4B44 +#define LINUX_KDSKBMODE 0x4B45 +#define LINUX_VT_OPENQRY 0x5600 +#define LINUX_VT_GETMODE 0x5601 +#define LINUX_VT_SETMODE 0x5602 +#define LINUX_VT_GETSTATE 0x5603 +#define LINUX_VT_RELDISP 0x5605 +#define LINUX_VT_ACTIVATE 0x5606 +#define LINUX_VT_WAITACTIVE 0x5607 + +#define LINUX_IOCTL_CONSOLE_MIN LINUX_KIOCSOUND +#define LINUX_IOCTL_CONSOLE_MAX LINUX_VT_WAITACTIVE + +#define LINUX_LED_SCR 0x01 +#define LINUX_LED_NUM 0x02 +#define LINUX_LED_CAP 0x04 + +#define LINUX_KD_TEXT 0x0 +#define LINUX_KD_GRAPHICS 0x1 +#define LINUX_KD_TEXT0 0x2 +#define LINUX_KD_TEXT1 0x3 + +#define LINUX_KBD_RAW 0 +#define LINUX_KBD_XLATE 1 +#define LINUX_KBD_MEDIUMRAW 2 + +/* + * socket + */ +#define LINUX_FIOSETOWN 0x8901 +#define LINUX_SIOCSPGRP 0x8902 +#define LINUX_FIOGETOWN 0x8903 +#define LINUX_SIOCGPGRP 0x8904 +#define LINUX_SIOCATMARK 0x8905 +#define LINUX_SIOCGSTAMP 0x8906 +#define LINUX_SIOCGIFCONF 0x8912 +#define LINUX_SIOCGIFFLAGS 0x8913 +#define LINUX_SIOCGIFADDR 0x8915 +#define LINUX_SIOCGIFDSTADDR 0x8917 +#define LINUX_SIOCGIFBRDADDR 0x8919 +#define LINUX_SIOCGIFNETMASK 0x891b +#define LINUX_SIOCGIFHWADDR 0x8927 +#define LINUX_SIOCADDMULTI 0x8931 +#define LINUX_SIOCDELMULTI 0x8932 + +#define LINUX_IOCTL_SOCKET_MIN LINUX_FIOSETOWN +#define LINUX_IOCTL_SOCKET_MAX LINUX_SIOCDELMULTI + +/* + * sound + */ +#define LINUX_SOUND_MIXER_WRITE_VOLUME 0x4d00 +#define LINUX_SOUND_MIXER_WRITE_BASS 0x4d01 +#define LINUX_SOUND_MIXER_WRITE_TREBLE 0x4d02 +#define LINUX_SOUND_MIXER_WRITE_SYNTH 0x4d03 +#define LINUX_SOUND_MIXER_WRITE_PCM 0x4d04 +#define LINUX_SOUND_MIXER_WRITE_SPEAKER 0x4d05 +#define LINUX_SOUND_MIXER_WRITE_LINE 0x4d06 +#define LINUX_SOUND_MIXER_WRITE_MIC 0x4d07 +#define LINUX_SOUND_MIXER_WRITE_CD 0x4d08 +#define LINUX_SOUND_MIXER_WRITE_IMIX 0x4d09 +#define LINUX_SOUND_MIXER_WRITE_ALTPCM 0x4d0A +#define LINUX_SOUND_MIXER_WRITE_RECLEV 0x4d0B +#define LINUX_SOUND_MIXER_WRITE_IGAIN 0x4d0C +#define LINUX_SOUND_MIXER_WRITE_OGAIN 0x4d0D +#define LINUX_SOUND_MIXER_WRITE_LINE1 0x4d0E +#define LINUX_SOUND_MIXER_WRITE_LINE2 0x4d0F +#define LINUX_SOUND_MIXER_WRITE_LINE3 0x4d10 +#define LINUX_OSS_GETVERSION 0x4d76 +#define LINUX_SOUND_MIXER_READ_DEVMASK 0x4dfe +#define LINUX_SNDCTL_DSP_RESET 0x5000 +#define LINUX_SNDCTL_DSP_SYNC 0x5001 +#define LINUX_SNDCTL_DSP_SPEED 0x5002 +#define LINUX_SNDCTL_DSP_STEREO 0x5003 +#define LINUX_SNDCTL_DSP_GETBLKSIZE 0x5004 +#define LINUX_SNDCTL_DSP_SETBLKSIZE LINUX_SNDCTL_DSP_GETBLKSIZE +#define LINUX_SNDCTL_DSP_SETFMT 0x5005 +#define LINUX_SOUND_PCM_WRITE_CHANNELS 0x5006 +#define LINUX_SOUND_PCM_WRITE_FILTER 0x5007 +#define LINUX_SNDCTL_DSP_POST 0x5008 +#define LINUX_SNDCTL_DSP_SUBDIVIDE 0x5009 +#define LINUX_SNDCTL_DSP_SETFRAGMENT 0x500A +#define LINUX_SNDCTL_DSP_GETFMTS 0x500B +#define LINUX_SNDCTL_DSP_GETOSPACE 0x500C +#define LINUX_SNDCTL_DSP_GETISPACE 0x500D +#define LINUX_SNDCTL_DSP_NONBLOCK 0x500E +#define LINUX_SNDCTL_DSP_GETCAPS 0x500F +#define LINUX_SNDCTL_DSP_GETTRIGGER 0x5010 +#define LINUX_SNDCTL_DSP_SETTRIGGER LINUX_SNDCTL_DSP_GETTRIGGER +#define LINUX_SNDCTL_DSP_GETIPTR 0x5011 +#define LINUX_SNDCTL_DSP_GETOPTR 0x5012 +#define LINUX_SNDCTL_DSP_GETODELAY 0x5017 +#define LINUX_SNDCTL_SEQ_RESET 0x5100 +#define LINUX_SNDCTL_SEQ_SYNC 0x5101 +#define LINUX_SNDCTL_SYNTH_INFO 0x5102 +#define LINUX_SNDCTL_SEQ_CTRLRATE 0x5103 +#define LINUX_SNDCTL_SEQ_GETOUTCOUNT 0x5104 +#define LINUX_SNDCTL_SEQ_GETINCOUNT 0x5105 +#define LINUX_SNDCTL_SEQ_PERCMODE 0x5106 +#define LINUX_SNDCTL_FM_LOAD_INSTR 0x5107 +#define LINUX_SNDCTL_SEQ_TESTMIDI 0x5108 +#define LINUX_SNDCTL_SEQ_RESETSAMPLES 0x5109 +#define LINUX_SNDCTL_SEQ_NRSYNTHS 0x510A +#define LINUX_SNDCTL_SEQ_NRMIDIS 0x510B +#define LINUX_SNDCTL_MIDI_INFO 0x510C +#define LINUX_SNDCTL_SEQ_TRESHOLD 0x510D +#define LINUX_SNDCTL_SYNTH_MEMAVL 0x510E + +#define LINUX_IOCTL_SOUND_MIN LINUX_SOUND_MIXER_WRITE_VOLUME +#define LINUX_IOCTL_SOUND_MAX LINUX_SNDCTL_SYNTH_MEMAVL + +/* + * termio + */ +#define LINUX_TCGETS 0x5401 +#define LINUX_TCSETS 0x5402 +#define LINUX_TCSETSW 0x5403 +#define LINUX_TCSETSF 0x5404 +#define LINUX_TCGETA 0x5405 +#define LINUX_TCSETA 0x5406 +#define LINUX_TCSETAW 0x5407 +#define LINUX_TCSETAF 0x5408 +#define LINUX_TCSBRK 0x5409 +#define LINUX_TCXONC 0x540A +#define LINUX_TCFLSH 0x540B +#define LINUX_TIOCEXCL 0x540C +#define LINUX_TIOCNXCL 0x540D +#define LINUX_TIOCSCTTY 0x540E +#define LINUX_TIOCGPGRP 0x540F +#define LINUX_TIOCSPGRP 0x5410 +#define LINUX_TIOCOUTQ 0x5411 +#define LINUX_TIOCSTI 0x5412 +#define LINUX_TIOCGWINSZ 0x5413 +#define LINUX_TIOCSWINSZ 0x5414 +#define LINUX_TIOCMGET 0x5415 +#define LINUX_TIOCMBIS 0x5416 +#define LINUX_TIOCMBIC 0x5417 +#define LINUX_TIOCMSET 0x5418 +#define LINUX_TIOCGSOFTCAR 0x5419 +#define LINUX_TIOCSSOFTCAR 0x541A +#define LINUX_FIONREAD 0x541B +#define LINUX_TIOCINQ FIONREAD +#define LINUX_TIOCLINUX 0x541C +#define LINUX_TIOCCONS 0x541D +#define LINUX_TIOCGSERIAL 0x541E +#define LINUX_TIOCSSERIAL 0x541F +#define LINUX_TIOCPKT 0x5420 +#define LINUX_FIONBIO 0x5421 +#define LINUX_TIOCNOTTY 0x5422 +#define LINUX_TIOCSETD 0x5423 +#define LINUX_TIOCGETD 0x5424 +#define LINUX_TCSBRKP 0x5425 +#define LINUX_TIOCTTYGSTRUCT 0x5426 +#define LINUX_FIONCLEX 0x5450 +#define LINUX_FIOCLEX 0x5451 +#define LINUX_FIOASYNC 0x5452 +#define LINUX_TIOCSERCONFIG 0x5453 +#define LINUX_TIOCSERGWILD 0x5454 +#define LINUX_TIOCSERSWILD 0x5455 +#define LINUX_TIOCGLCKTRMIOS 0x5456 +#define LINUX_TIOCSLCKTRMIOS 0x5457 + +#define LINUX_IOCTL_TERMIO_MIN LINUX_TCGETS +#define LINUX_IOCTL_TERMIO_MAX LINUX_TIOCSLCKTRMIOS + +/* arguments for tcflow() and LINUX_TCXONC */ +#define LINUX_TCOOFF 0 +#define LINUX_TCOON 1 +#define LINUX_TCIOFF 2 +#define LINUX_TCION 3 + +/* arguments for tcflush() and LINUX_TCFLSH */ +#define LINUX_TCIFLUSH 0 +#define LINUX_TCOFLUSH 1 +#define LINUX_TCIOFLUSH 2 + +/* line disciplines */ +#define LINUX_N_TTY 0 +#define LINUX_N_SLIP 1 +#define LINUX_N_MOUSE 2 +#define LINUX_N_PPP 3 + +/* Linux termio c_cc values */ +#define LINUX_VINTR 0 +#define LINUX_VQUIT 1 +#define LINUX_VERASE 2 +#define LINUX_VKILL 3 +#define LINUX_VEOF 4 +#define LINUX_VTIME 5 +#define LINUX_VMIN 6 +#define LINUX_VSWTC 7 +#define LINUX_NCC 8 + +/* Linux termios c_cc values */ +#define LINUX_VSTART 8 +#define LINUX_VSTOP 9 +#define LINUX_VSUSP 10 +#define LINUX_VEOL 11 +#define LINUX_VREPRINT 12 +#define LINUX_VDISCARD 13 +#define LINUX_VWERASE 14 +#define LINUX_VLNEXT 15 +#define LINUX_VEOL2 16 +#define LINUX_NCCS 19 + +#define LINUX_POSIX_VDISABLE '\0' + +/* Linux c_iflag masks */ +#define LINUX_IGNBRK 0x0000001 +#define LINUX_BRKINT 0x0000002 +#define LINUX_IGNPAR 0x0000004 +#define LINUX_PARMRK 0x0000008 +#define LINUX_INPCK 0x0000010 +#define LINUX_ISTRIP 0x0000020 +#define LINUX_INLCR 0x0000040 +#define LINUX_IGNCR 0x0000080 +#define LINUX_ICRNL 0x0000100 +#define LINUX_IUCLC 0x0000200 +#define LINUX_IXON 0x0000400 +#define LINUX_IXANY 0x0000800 +#define LINUX_IXOFF 0x0001000 +#define LINUX_IMAXBEL 0x0002000 + +/* Linux c_oflag masks */ +#define LINUX_OPOST 0x0000001 +#define LINUX_OLCUC 0x0000002 +#define LINUX_ONLCR 0x0000004 +#define LINUX_OCRNL 0x0000008 +#define LINUX_ONOCR 0x0000010 +#define LINUX_ONLRET 0x0000020 +#define LINUX_OFILL 0x0000040 +#define LINUX_OFDEL 0x0000080 +#define LINUX_NLDLY 0x0000100 + +#define LINUX_NL0 0x0000000 +#define LINUX_NL1 0x0000100 +#define LINUX_CRDLY 0x0000600 +#define LINUX_CR0 0x0000000 +#define LINUX_CR1 0x0000200 +#define LINUX_CR2 0x0000400 +#define LINUX_CR3 0x0000600 +#define LINUX_TABDLY 0x0001800 +#define LINUX_TAB0 0x0000000 +#define LINUX_TAB1 0x0000800 +#define LINUX_TAB2 0x0001000 +#define LINUX_TAB3 0x0001800 +#define LINUX_XTABS 0x0001800 +#define LINUX_BSDLY 0x0002000 +#define LINUX_BS0 0x0000000 +#define LINUX_BS1 0x0002000 +#define LINUX_VTDLY 0x0004000 +#define LINUX_VT0 0x0000000 +#define LINUX_VT1 0x0004000 +#define LINUX_FFDLY 0x0008000 +#define LINUX_FF0 0x0000000 +#define LINUX_FF1 0x0008000 + +#define LINUX_CBAUD 0x0000100f +#define LINUX_B0 0x00000000 +#define LINUX_B50 0x00000001 +#define LINUX_B75 0x00000002 +#define LINUX_B110 0x00000003 +#define LINUX_B134 0x00000004 +#define LINUX_B150 0x00000005 +#define LINUX_B200 0x00000006 +#define LINUX_B300 0x00000007 +#define LINUX_B600 0x00000008 +#define LINUX_B1200 0x00000009 +#define LINUX_B1800 0x0000000a +#define LINUX_B2400 0x0000000b +#define LINUX_B4800 0x0000000c +#define LINUX_B9600 0x0000000d +#define LINUX_B19200 0x0000000e +#define LINUX_B38400 0x0000000f +#define LINUX_EXTA LINUX_B19200 +#define LINUX_EXTB LINUX_B38400 +#define LINUX_CBAUDEX 0x00001000 +#define LINUX_B57600 0x00001001 +#define LINUX_B115200 0x00001002 + +#define LINUX_CSIZE 0x00000030 +#define LINUX_CS5 0x00000000 +#define LINUX_CS6 0x00000010 +#define LINUX_CS7 0x00000020 +#define LINUX_CS8 0x00000030 +#define LINUX_CSTOPB 0x00000040 +#define LINUX_CREAD 0x00000080 +#define LINUX_PARENB 0x00000100 +#define LINUX_PARODD 0x00000200 +#define LINUX_HUPCL 0x00000400 +#define LINUX_CLOCAL 0x00000800 +#define LINUX_CRTSCTS 0x80000000 + +/* Linux c_lflag masks */ +#define LINUX_ISIG 0x00000001 +#define LINUX_ICANON 0x00000002 +#define LINUX_XCASE 0x00000004 +#define LINUX_ECHO 0x00000008 +#define LINUX_ECHOE 0x00000010 +#define LINUX_ECHOK 0x00000020 +#define LINUX_ECHONL 0x00000040 +#define LINUX_NOFLSH 0x00000080 +#define LINUX_TOSTOP 0x00000100 +#define LINUX_ECHOCTL 0x00000200 +#define LINUX_ECHOPRT 0x00000400 +#define LINUX_ECHOKE 0x00000800 +#define LINUX_FLUSHO 0x00001000 +#define LINUX_PENDIN 0x00002000 +#define LINUX_IEXTEN 0x00008000 + +/* serial_struct values for TIOC[GS]SERIAL ioctls */ +#define LINUX_ASYNC_CLOSING_WAIT_INF 0 +#define LINUX_ASYNC_CLOSING_WAIT_NONE 65535 + +#define LINUX_PORT_UNKNOWN 0 +#define LINUX_PORT_8250 1 +#define LINUX_PORT_16450 2 +#define LINUX_PORT_16550 3 +#define LINUX_PORT_16550A 4 +#define LINUX_PORT_CIRRUS 5 +#define LINUX_PORT_16650 6 + +#define LINUX_PORT_MAX 6 + +#define LINUX_ASYNC_HUP_NOTIFY 0x0001 +#define LINUX_ASYNC_FOURPORT 0x0002 +#define LINUX_ASYNC_SAK 0x0004 +#define LINUX_ASYNC_SPLIT_TERMIOS 0x0008 +#define LINUX_ASYNC_SPD_MASK 0x0030 +#define LINUX_ASYNC_SPD_HI 0x0010 +#define LINUX_ASYNC_SPD_VHI 0x0020 +#define LINUX_ASYNC_SPD_CUST 0x0030 +#define LINUX_ASYNC_SKIP_TEST 0x0040 +#define LINUX_ASYNC_AUTO_IRQ 0x0080 +#define LINUX_ASYNC_SESSION_LOCKOUT 0x0100 +#define LINUX_ASYNC_PGRP_LOCKOUT 0x0200 +#define LINUX_ASYNC_CALLOUT_NOHUP 0x0400 +#define LINUX_ASYNC_FLAGS 0x0FFF + +#endif /* !_LINUX_IOCTL_H_ */ diff --git a/sys/compat/linux/linux_util.h b/sys/compat/linux/linux_util.h index 61a6371..f8775fb 100644 --- a/sys/compat/linux/linux_util.h +++ b/sys/compat/linux/linux_util.h @@ -80,6 +80,8 @@ stackgap_alloc(sgp, sz) #define DPRINTF(a) #endif +extern const char linux_emul_path[]; + int linux_emul_find __P((struct proc *, caddr_t *, const char *, char *, char **, int)); diff --git a/sys/i386/linux/imgact_linux.c b/sys/i386/linux/imgact_linux.c index c560d74..36f6946 100644 --- a/sys/i386/linux/imgact_linux.c +++ b/sys/i386/linux/imgact_linux.c @@ -52,6 +52,8 @@ #include <i386/linux/linux.h> +extern struct sysentvec linux_sysvec; + static int exec_linux_imgact __P((struct image_params *iparams)); static int diff --git a/sys/i386/linux/linux.h b/sys/i386/linux/linux.h index d3ba6cc..528a591 100644 --- a/sys/i386/linux/linux.h +++ b/sys/i386/linux/linux.h @@ -29,63 +29,162 @@ */ #ifndef _I386_LINUX_LINUX_H_ -#define _I386_LINUX_LINUX_H_ +#define _I386_LINUX_LINUX_H_ #include <i386/linux/linux_syscall.h> -typedef unsigned short linux_uid_t; -typedef unsigned short linux_gid_t; -typedef unsigned short linux_dev_t; -typedef unsigned long linux_ino_t; -typedef unsigned short linux_mode_t; -typedef unsigned short linux_nlink_t; -typedef long linux_time_t; -typedef long linux_clock_t; -typedef char * linux_caddr_t; -typedef long linux_off_t; +#ifdef MALLOC_DECLARE +MALLOC_DECLARE(M_LINUX); +#endif + +/* + * Miscellaneous + */ +#define LINUX_NAME_MAX 255 +#define LINUX_MAX_UTSNAME 65 + +/* Scheduling policies */ +#define LINUX_SCHED_OTHER 0 +#define LINUX_SCHED_FIFO 1 +#define LINUX_SCHED_RR 2 + +/* Resource limits */ +#define LINUX_RLIMIT_CPU 0 +#define LINUX_RLIMIT_FSIZE 1 +#define LINUX_RLIMIT_DATA 2 +#define LINUX_RLIMIT_STACK 3 +#define LINUX_RLIMIT_CORE 4 +#define LINUX_RLIMIT_RSS 5 +#define LINUX_RLIMIT_NPROC 6 +#define LINUX_RLIMIT_NOFILE 7 +#define LINUX_RLIMIT_MEMLOCK 8 +#define LINUX_RLIMIT_AS 9 /* address space limit */ + +#define LINUX_RLIM_NLIMITS 10 + +/* mmap options */ +#define LINUX_MAP_SHARED 0x0001 +#define LINUX_MAP_PRIVATE 0x0002 +#define LINUX_MAP_FIXED 0x0010 +#define LINUX_MAP_ANON 0x0020 +#define LINUX_MAP_GROWSDOWN 0x0100 + +typedef char * linux_caddr_t; +typedef long linux_clock_t; +typedef u_short linux_dev_t; +typedef u_short linux_gid_t; +typedef u_long linux_ino_t; +typedef int linux_key_t; /* XXX */ +typedef u_short linux_mode_t; +typedef u_short linux_nlink_t; +typedef long linux_off_t; +typedef int linux_pid_t; +typedef u_int linux_size_t; +typedef long linux_time_t; +typedef u_short linux_uid_t; + typedef struct { - long val[2]; + long val[2]; } linux_fsid_t; -typedef int linux_pid_t; -typedef int linux_key_t; -typedef unsigned int linux_size_t; + +struct linux_new_utsname { + char sysname[LINUX_MAX_UTSNAME]; + char nodename[LINUX_MAX_UTSNAME]; + char release[LINUX_MAX_UTSNAME]; + char version[LINUX_MAX_UTSNAME]; + char machine[LINUX_MAX_UTSNAME]; + char domainname[LINUX_MAX_UTSNAME]; +}; /* - * Signal stuff... + * Signalling */ -typedef void (*linux_handler_t)(int); +#define LINUX_SIGHUP 1 +#define LINUX_SIGINT 2 +#define LINUX_SIGQUIT 3 +#define LINUX_SIGILL 4 +#define LINUX_SIGTRAP 5 +#define LINUX_SIGABRT 6 +#define LINUX_SIGIOT LINUX_SIGABRT +#define LINUX_SIGBUS 7 +#define LINUX_SIGFPE 8 +#define LINUX_SIGKILL 9 +#define LINUX_SIGUSR1 10 +#define LINUX_SIGSEGV 11 +#define LINUX_SIGUSR2 12 +#define LINUX_SIGPIPE 13 +#define LINUX_SIGALRM 14 +#define LINUX_SIGTERM 15 +#define LINUX_SIGSTKFLT 16 +#define LINUX_SIGCHLD 17 +#define LINUX_SIGCONT 18 +#define LINUX_SIGSTOP 19 +#define LINUX_SIGTSTP 20 +#define LINUX_SIGTTIN 21 +#define LINUX_SIGTTOU 22 +#define LINUX_SIGURG 23 +#define LINUX_SIGXCPU 24 +#define LINUX_SIGXFSZ 25 +#define LINUX_SIGVTALRM 26 +#define LINUX_SIGPROF 27 +#define LINUX_SIGWINCH 28 +#define LINUX_SIGIO 29 +#define LINUX_SIGPOLL LINUX_SIGIO +#define LINUX_SIGPWR 30 +#define LINUX_SIGUNUSED 31 + +#define LINUX_NSIG 64 +#define LINUX_SIGTBLSZ 31 -typedef unsigned long linux_osigset_t; +/* sigaction flags */ +#define LINUX_SA_NOCLDSTOP 0x00000001 +#define LINUX_SA_NOCLDWAIT 0x00000002 +#define LINUX_SA_SIGINFO 0x00000004 +#define LINUX_SA_RESTORER 0x04000000 +#define LINUX_SA_ONSTACK 0x08000000 +#define LINUX_SA_RESTART 0x10000000 +#define LINUX_SA_INTERRUPT 0x20000000 +#define LINUX_SA_NOMASK 0x40000000 +#define LINUX_SA_ONESHOT 0x80000000 + +/* sigprocmask actions */ +#define LINUX_SIG_BLOCK 0 +#define LINUX_SIG_UNBLOCK 1 +#define LINUX_SIG_SETMASK 2 + +/* sigset_t macros */ +#define LINUX_SIGEMPTYSET(set) (set).__bits[0] = (set).__bits[1] = 0 +#define LINUX_SIGISMEMBER(set, sig) SIGISMEMBER(set, sig) +#define LINUX_SIGADDSET(set, sig) SIGADDSET(set, sig) + +typedef void (*linux_handler_t)(int); +typedef u_long linux_osigset_t; typedef struct { - unsigned int __bits[2]; + u_int __bits[2]; } linux_sigset_t; typedef struct { - void (*lsa_handler)(int); + linux_handler_t lsa_handler; linux_osigset_t lsa_mask; - unsigned long lsa_flags; - void (*lsa_restorer)(void); + u_long lsa_flags; + void (*lsa_restorer)(void); } linux_osigaction_t; typedef struct { - void (*lsa_handler)(int); - unsigned long lsa_flags; - void (*lsa_restorer)(void); + linux_handler_t lsa_handler; + u_long lsa_flags; + void (*lsa_restorer)(void); linux_sigset_t lsa_mask; } linux_sigaction_t; -typedef struct -{ - void *ss_sp; - int ss_flags; +typedef struct { + void *ss_sp; + int ss_flags; linux_size_t ss_size; } linux_stack_t; -/* - * The Linux sigcontext, pretty much a standard 386 trapframe. - */ - +/* The Linux sigcontext, pretty much a standard 386 trapframe. */ struct linux_sigcontext { int sc_gs; int sc_fs; @@ -117,400 +216,95 @@ struct linux_sigcontext { * This means that we need to pass the pointer to the handler too. * It is appended to the frame to not interfere with the rest of it. */ - struct linux_sigframe { int sf_sig; struct linux_sigcontext sf_sc; - void (*sf_handler)(int); + linux_handler_t sf_handler; }; extern int bsd_to_linux_signal[]; extern int linux_to_bsd_signal[]; -/* signal numbers */ -#define LINUX_SIGHUP 1 -#define LINUX_SIGINT 2 -#define LINUX_SIGQUIT 3 -#define LINUX_SIGILL 4 -#define LINUX_SIGTRAP 5 -#define LINUX_SIGABRT 6 -#define LINUX_SIGIOT 6 -#define LINUX_SIGBUS 7 -#define LINUX_SIGFPE 8 -#define LINUX_SIGKILL 9 -#define LINUX_SIGUSR1 10 -#define LINUX_SIGSEGV 11 -#define LINUX_SIGUSR2 12 -#define LINUX_SIGPIPE 13 -#define LINUX_SIGALRM 14 -#define LINUX_SIGTERM 15 -#define LINUX_SIGSTKFLT 16 -#define LINUX_SIGCHLD 17 -#define LINUX_SIGCONT 18 -#define LINUX_SIGSTOP 19 -#define LINUX_SIGTSTP 20 -#define LINUX_SIGTTIN 21 -#define LINUX_SIGTTOU 22 -#define LINUX_SIGURG 23 -#define LINUX_SIGXCPU 24 -#define LINUX_SIGXFSZ 25 -#define LINUX_SIGVTALRM 26 -#define LINUX_SIGPROF 27 -#define LINUX_SIGWINCH 28 -#define LINUX_SIGIO 29 -#define LINUX_SIGPOLL LINUX_SIGIO -#define LINUX_SIGPWR 30 -#define LINUX_SIGUNUSED 31 -#define LINUX_NSIG 64 -#define LINUX_SIGTBLSZ 31 - -/* sigaction flags */ -#define LINUX_SA_NOCLDSTOP 0x00000001 -#define LINUX_SA_NOCLDWAIT 0x00000002 -#define LINUX_SA_SIGINFO 0x00000004 -#define LINUX_SA_RESTORER 0x04000000 -#define LINUX_SA_ONSTACK 0x08000000 -#define LINUX_SA_RESTART 0x10000000 -#define LINUX_SA_INTERRUPT 0x20000000 -#define LINUX_SA_NOMASK 0x40000000 -#define LINUX_SA_ONESHOT 0x80000000 - -/* sigprocmask actions */ -#define LINUX_SIG_BLOCK 0 -#define LINUX_SIG_UNBLOCK 1 -#define LINUX_SIG_SETMASK 2 - -#define LINUX_SIGEMPTYSET(set) (set).__bits[0] = (set).__bits[1] = 0 -#define LINUX_SIGISMEMBER(set, sig) SIGISMEMBER(set, sig) -#define LINUX_SIGADDSET(set, sig) SIGADDSET(set, sig) - -extern char linux_sigcode[]; -extern int linux_szsigcode; -extern const char linux_emul_path[]; - -extern struct sysent linux_sysent[LINUX_SYS_MAXSYSCALL]; -extern struct sysentvec linux_sysvec; -extern struct sysentvec elf_linux_sysvec; +/* + * Pluggable ioctl handlers + */ +struct linker_set; +struct linux_ioctl_args; +struct proc; -/* dummy struct definitions */ -struct image_params; -struct trapframe; +typedef int linux_ioctl_function_t(struct proc *, struct linux_ioctl_args *); -#define LINUX_MAX_UTSNAME 65 -struct linux_new_utsname { - char sysname[LINUX_MAX_UTSNAME]; - char nodename[LINUX_MAX_UTSNAME]; - char release[LINUX_MAX_UTSNAME]; - char version[LINUX_MAX_UTSNAME]; - char machine[LINUX_MAX_UTSNAME]; - char domainname[LINUX_MAX_UTSNAME]; +struct linux_ioctl_handler { + linux_ioctl_function_t *func; + int low, high; }; -/* misc defines */ -#define LINUX_NAME_MAX 255 - -/* resource limits */ -#define LINUX_RLIMIT_CPU 0 -#define LINUX_RLIMIT_FSIZE 1 -#define LINUX_RLIMIT_DATA 2 -#define LINUX_RLIMIT_STACK 3 -#define LINUX_RLIMIT_CORE 4 -#define LINUX_RLIMIT_RSS 5 -#define LINUX_RLIMIT_NPROC 6 -#define LINUX_RLIMIT_NOFILE 7 -#define LINUX_RLIMIT_MEMLOCK 8 -#define LINUX_RLIMIT_AS 9 /* address space limit */ - -#define LINUX_RLIM_NLIMITS 10 - -/* keyboard defines */ -#define LINUX_KIOCSOUND 0x4B2F -#define LINUX_KDMKTONE 0x4B30 -#define LINUX_KDGETLED 0x4B31 -#define LINUX_KDSETLED 0x4B32 -#define LINUX_LED_SCR 0x01 -#define LINUX_LED_NUM 0x02 -#define LINUX_LED_CAP 0x04 - -#define LINUX_KDGKBMODE 0x4B44 -#define LINUX_KDSKBMODE 0x4B45 -#define LINUX_KDSETMODE 0x4B3A -#define LINUX_KDGETMODE 0x4B3B -#define LINUX_KD_TEXT 0x0 -#define LINUX_KD_GRAPHICS 0x1 -#define LINUX_KD_TEXT0 0x2 -#define LINUX_KD_TEXT1 0x3 - -#define LINUX_KBD_RAW 0 -#define LINUX_KBD_XLATE 1 -#define LINUX_KBD_MEDIUMRAW 2 - -/* termio commands */ -#define LINUX_TCGETS 0x5401 -#define LINUX_TCSETS 0x5402 -#define LINUX_TCSETSW 0x5403 -#define LINUX_TCSETSF 0x5404 -#define LINUX_TCGETA 0x5405 -#define LINUX_TCSETA 0x5406 -#define LINUX_TCSETAW 0x5407 -#define LINUX_TCSETAF 0x5408 -#define LINUX_TCSBRK 0x5409 -#define LINUX_TCXONC 0x540A -#define LINUX_TCFLSH 0x540B -#define LINUX_TIOCEXCL 0x540C -#define LINUX_TIOCNXCL 0x540D -#define LINUX_TIOCSCTTY 0x540E -#define LINUX_TIOCGPGRP 0x540F -#define LINUX_TIOCSPGRP 0x5410 -#define LINUX_TIOCOUTQ 0x5411 -#define LINUX_TIOCSTI 0x5412 -#define LINUX_TIOCGWINSZ 0x5413 -#define LINUX_TIOCSWINSZ 0x5414 -#define LINUX_TIOCMGET 0x5415 -#define LINUX_TIOCMBIS 0x5416 -#define LINUX_TIOCMBIC 0x5417 -#define LINUX_TIOCMSET 0x5418 -#define LINUX_TIOCGSOFTCAR 0x5419 -#define LINUX_TIOCSSOFTCAR 0x541A -#define LINUX_FIONREAD 0x541B -#define LINUX_TIOCINQ FIONREAD -#define LINUX_TIOCLINUX 0x541C -#define LINUX_TIOCCONS 0x541D -#define LINUX_TIOCGSERIAL 0x541E -#define LINUX_TIOCSSERIAL 0x541F -#define LINUX_TIOCPKT 0x5420 -#define LINUX_FIONBIO 0x5421 -#define LINUX_TIOCNOTTY 0x5422 -#define LINUX_TIOCSETD 0x5423 -#define LINUX_TIOCGETD 0x5424 -#define LINUX_TCSBRKP 0x5425 -#define LINUX_TIOCTTYGSTRUCT 0x5426 -#define LINUX_FIONCLEX 0x5450 -#define LINUX_FIOCLEX 0x5451 -#define LINUX_FIOASYNC 0x5452 -#define LINUX_TIOCSERCONFIG 0x5453 -#define LINUX_TIOCSERGWILD 0x5454 -#define LINUX_TIOCSERSWILD 0x5455 -#define LINUX_TIOCGLCKTRMIOS 0x5456 -#define LINUX_TIOCSLCKTRMIOS 0x5457 -#define LINUX_VT_OPENQRY 0x5600 -#define LINUX_VT_GETMODE 0x5601 -#define LINUX_VT_SETMODE 0x5602 -#define LINUX_VT_GETSTATE 0x5603 -#define LINUX_VT_RELDISP 0x5605 -#define LINUX_VT_ACTIVATE 0x5606 -#define LINUX_VT_WAITACTIVE 0x5607 - -/* arguments for tcflow() and LINUX_TCXONC */ -#define LINUX_TCOOFF 0 -#define LINUX_TCOON 1 -#define LINUX_TCIOFF 2 -#define LINUX_TCION 3 - -/* arguments for tcflush() and LINUX_TCFLSH */ -#define LINUX_TCIFLUSH 0 -#define LINUX_TCOFLUSH 1 -#define LINUX_TCIOFLUSH 2 - -/* line disciplines */ -#define LINUX_N_TTY 0 -#define LINUX_N_SLIP 1 -#define LINUX_N_MOUSE 2 -#define LINUX_N_PPP 3 - -/* Linux termio c_cc values */ -#define LINUX_VINTR 0 -#define LINUX_VQUIT 1 -#define LINUX_VERASE 2 -#define LINUX_VKILL 3 -#define LINUX_VEOF 4 -#define LINUX_VTIME 5 -#define LINUX_VMIN 6 -#define LINUX_VSWTC 7 -#define LINUX_NCC 8 - -/* Linux termios c_cc values */ -#define LINUX_VSTART 8 -#define LINUX_VSTOP 9 -#define LINUX_VSUSP 10 -#define LINUX_VEOL 11 -#define LINUX_VREPRINT 12 -#define LINUX_VDISCARD 13 -#define LINUX_VWERASE 14 -#define LINUX_VLNEXT 15 -#define LINUX_VEOL2 16 -#define LINUX_NCCS 19 - -#define LINUX_POSIX_VDISABLE '\0' - -/* Linux c_iflag masks */ -#define LINUX_IGNBRK 0x0000001 -#define LINUX_BRKINT 0x0000002 -#define LINUX_IGNPAR 0x0000004 -#define LINUX_PARMRK 0x0000008 -#define LINUX_INPCK 0x0000010 -#define LINUX_ISTRIP 0x0000020 -#define LINUX_INLCR 0x0000040 -#define LINUX_IGNCR 0x0000080 -#define LINUX_ICRNL 0x0000100 -#define LINUX_IUCLC 0x0000200 -#define LINUX_IXON 0x0000400 -#define LINUX_IXANY 0x0000800 -#define LINUX_IXOFF 0x0001000 -#define LINUX_IMAXBEL 0x0002000 - -/* Linux c_oflag masks */ -#define LINUX_OPOST 0x0000001 -#define LINUX_OLCUC 0x0000002 -#define LINUX_ONLCR 0x0000004 -#define LINUX_OCRNL 0x0000008 -#define LINUX_ONOCR 0x0000010 -#define LINUX_ONLRET 0x0000020 -#define LINUX_OFILL 0x0000040 -#define LINUX_OFDEL 0x0000080 -#define LINUX_NLDLY 0x0000100 - -#define LINUX_NL0 0x0000000 -#define LINUX_NL1 0x0000100 -#define LINUX_CRDLY 0x0000600 -#define LINUX_CR0 0x0000000 -#define LINUX_CR1 0x0000200 -#define LINUX_CR2 0x0000400 -#define LINUX_CR3 0x0000600 -#define LINUX_TABDLY 0x0001800 -#define LINUX_TAB0 0x0000000 -#define LINUX_TAB1 0x0000800 -#define LINUX_TAB2 0x0001000 -#define LINUX_TAB3 0x0001800 -#define LINUX_XTABS 0x0001800 -#define LINUX_BSDLY 0x0002000 -#define LINUX_BS0 0x0000000 -#define LINUX_BS1 0x0002000 -#define LINUX_VTDLY 0x0004000 -#define LINUX_VT0 0x0000000 -#define LINUX_VT1 0x0004000 -#define LINUX_FFDLY 0x0008000 -#define LINUX_FF0 0x0000000 -#define LINUX_FF1 0x0008000 - -#define LINUX_CBAUD 0x0000100f -#define LINUX_B0 0x00000000 -#define LINUX_B50 0x00000001 -#define LINUX_B75 0x00000002 -#define LINUX_B110 0x00000003 -#define LINUX_B134 0x00000004 -#define LINUX_B150 0x00000005 -#define LINUX_B200 0x00000006 -#define LINUX_B300 0x00000007 -#define LINUX_B600 0x00000008 -#define LINUX_B1200 0x00000009 -#define LINUX_B1800 0x0000000a -#define LINUX_B2400 0x0000000b -#define LINUX_B4800 0x0000000c -#define LINUX_B9600 0x0000000d -#define LINUX_B19200 0x0000000e -#define LINUX_B38400 0x0000000f -#define LINUX_EXTA LINUX_B19200 -#define LINUX_EXTB LINUX_B38400 -#define LINUX_CBAUDEX 0x00001000 -#define LINUX_B57600 0x00001001 -#define LINUX_B115200 0x00001002 - -#define LINUX_CSIZE 0x00000030 -#define LINUX_CS5 0x00000000 -#define LINUX_CS6 0x00000010 -#define LINUX_CS7 0x00000020 -#define LINUX_CS8 0x00000030 -#define LINUX_CSTOPB 0x00000040 -#define LINUX_CREAD 0x00000080 -#define LINUX_PARENB 0x00000100 -#define LINUX_PARODD 0x00000200 -#define LINUX_HUPCL 0x00000400 -#define LINUX_CLOCAL 0x00000800 -#define LINUX_CRTSCTS 0x80000000 - -/* Linux c_lflag masks */ -#define LINUX_ISIG 0x00000001 -#define LINUX_ICANON 0x00000002 -#define LINUX_XCASE 0x00000004 -#define LINUX_ECHO 0x00000008 -#define LINUX_ECHOE 0x00000010 -#define LINUX_ECHOK 0x00000020 -#define LINUX_ECHONL 0x00000040 -#define LINUX_NOFLSH 0x00000080 -#define LINUX_TOSTOP 0x00000100 -#define LINUX_ECHOCTL 0x00000200 -#define LINUX_ECHOPRT 0x00000400 -#define LINUX_ECHOKE 0x00000800 -#define LINUX_FLUSHO 0x00001000 -#define LINUX_PENDIN 0x00002000 -#define LINUX_IEXTEN 0x00008000 - -/* open/fcntl flags */ -#define LINUX_O_RDONLY 00 -#define LINUX_O_WRONLY 01 -#define LINUX_O_RDWR 02 -#define LINUX_O_CREAT 0100 -#define LINUX_O_EXCL 0200 -#define LINUX_O_NOCTTY 0400 -#define LINUX_O_TRUNC 01000 -#define LINUX_O_APPEND 02000 -#define LINUX_O_NONBLOCK 04000 -#define LINUX_O_NDELAY LINUX_O_NONBLOCK -#define LINUX_O_SYNC 010000 -#define LINUX_FASYNC 020000 - -/* fcntl flags */ -#define LINUX_F_DUPFD 0 -#define LINUX_F_GETFD 1 -#define LINUX_F_SETFD 2 -#define LINUX_F_GETFL 3 -#define LINUX_F_SETFL 4 -#define LINUX_F_GETLK 5 -#define LINUX_F_SETLK 6 -#define LINUX_F_SETLKW 7 -#define LINUX_F_SETOWN 8 -#define LINUX_F_GETOWN 9 - -#define LINUX_F_RDLCK 0 -#define LINUX_F_WRLCK 1 -#define LINUX_F_UNLCK 2 +int linux_ioctl_register_handler(struct linux_ioctl_handler *h); +int linux_ioctl_register_handlers(struct linker_set *s); +int linux_ioctl_unregister_handler(struct linux_ioctl_handler *h); +int linux_ioctl_unregister_handlers(struct linker_set *s); -/* mmap options */ -#define LINUX_MAP_SHARED 0x0001 -#define LINUX_MAP_PRIVATE 0x0002 -#define LINUX_MAP_FIXED 0x0010 -#define LINUX_MAP_ANON 0x0020 -#define LINUX_MAP_GROWSDOWN 0x0100 - -/* SystemV ipc defines */ -#define LINUX_SEMOP 1 -#define LINUX_SEMGET 2 -#define LINUX_SEMCTL 3 -#define LINUX_MSGSND 11 -#define LINUX_MSGRCV 12 -#define LINUX_MSGGET 13 -#define LINUX_MSGCTL 14 -#define LINUX_SHMAT 21 -#define LINUX_SHMDT 22 -#define LINUX_SHMGET 23 -#define LINUX_SHMCTL 24 - -#define LINUX_IPC_RMID 0 -#define LINUX_IPC_SET 1 -#define LINUX_IPC_STAT 2 -#define LINUX_IPC_INFO 3 - -#define LINUX_SHM_LOCK 11 -#define LINUX_SHM_UNLOCK 12 -#define LINUX_SHM_STAT 13 -#define LINUX_SHM_INFO 14 - -#define LINUX_SHM_RDONLY 0x1000 -#define LINUX_SHM_RND 0x2000 -#define LINUX_SHM_REMAP 0x4000 - -/* semctl Command Definitions. */ +/* + * open/fcntl flags + */ +#define LINUX_O_RDONLY 00 +#define LINUX_O_WRONLY 01 +#define LINUX_O_RDWR 02 +#define LINUX_O_CREAT 0100 +#define LINUX_O_EXCL 0200 +#define LINUX_O_NOCTTY 0400 +#define LINUX_O_TRUNC 01000 +#define LINUX_O_APPEND 02000 +#define LINUX_O_NONBLOCK 04000 +#define LINUX_O_NDELAY LINUX_O_NONBLOCK +#define LINUX_O_SYNC 010000 +#define LINUX_FASYNC 020000 + +#define LINUX_F_DUPFD 0 +#define LINUX_F_GETFD 1 +#define LINUX_F_SETFD 2 +#define LINUX_F_GETFL 3 +#define LINUX_F_SETFL 4 +#define LINUX_F_GETLK 5 +#define LINUX_F_SETLK 6 +#define LINUX_F_SETLKW 7 +#define LINUX_F_SETOWN 8 +#define LINUX_F_GETOWN 9 + +#define LINUX_F_RDLCK 0 +#define LINUX_F_WRLCK 1 +#define LINUX_F_UNLCK 2 + +/* + * SystemV IPC defines + */ +#define LINUX_SEMOP 1 +#define LINUX_SEMGET 2 +#define LINUX_SEMCTL 3 +#define LINUX_MSGSND 11 +#define LINUX_MSGRCV 12 +#define LINUX_MSGGET 13 +#define LINUX_MSGCTL 14 +#define LINUX_SHMAT 21 +#define LINUX_SHMDT 22 +#define LINUX_SHMGET 23 +#define LINUX_SHMCTL 24 + +#define LINUX_IPC_RMID 0 +#define LINUX_IPC_SET 1 +#define LINUX_IPC_STAT 2 +#define LINUX_IPC_INFO 3 + +#define LINUX_SHM_LOCK 11 +#define LINUX_SHM_UNLOCK 12 +#define LINUX_SHM_STAT 13 +#define LINUX_SHM_INFO 14 + +#define LINUX_SHM_RDONLY 0x1000 +#define LINUX_SHM_RND 0x2000 +#define LINUX_SHM_REMAP 0x4000 + +/* semctl commands */ #define LINUX_GETPID 11 #define LINUX_GETVAL 12 #define LINUX_GETALL 13 @@ -519,246 +313,104 @@ struct linux_new_utsname { #define LINUX_SETVAL 16 #define LINUX_SETALL 17 -/* Socket defines */ -#define LINUX_SOCKET 1 -#define LINUX_BIND 2 -#define LINUX_CONNECT 3 -#define LINUX_LISTEN 4 -#define LINUX_ACCEPT 5 -#define LINUX_GETSOCKNAME 6 -#define LINUX_GETPEERNAME 7 -#define LINUX_SOCKETPAIR 8 -#define LINUX_SEND 9 -#define LINUX_RECV 10 -#define LINUX_SENDTO 11 -#define LINUX_RECVFROM 12 -#define LINUX_SHUTDOWN 13 -#define LINUX_SETSOCKOPT 14 -#define LINUX_GETSOCKOPT 15 -#define LINUX_SENDMSG 16 -#define LINUX_RECVMSG 17 - -#define LINUX_AF_UNSPEC 0 -#define LINUX_AF_UNIX 1 -#define LINUX_AF_INET 2 -#define LINUX_AF_AX25 3 -#define LINUX_AF_IPX 4 -#define LINUX_AF_APPLETALK 5 - -#define LINUX_SOL_SOCKET 1 -#define LINUX_SOL_IP 0 -#define LINUX_SOL_IPX 256 -#define LINUX_SOL_AX25 257 -#define LINUX_SOL_TCP 6 -#define LINUX_SOL_UDP 17 - -#define LINUX_SO_DEBUG 1 -#define LINUX_SO_REUSEADDR 2 -#define LINUX_SO_TYPE 3 -#define LINUX_SO_ERROR 4 -#define LINUX_SO_DONTROUTE 5 -#define LINUX_SO_BROADCAST 6 -#define LINUX_SO_SNDBUF 7 -#define LINUX_SO_RCVBUF 8 -#define LINUX_SO_KEEPALIVE 9 -#define LINUX_SO_OOBINLINE 10 -#define LINUX_SO_NO_CHECK 11 -#define LINUX_SO_PRIORITY 12 -#define LINUX_SO_LINGER 13 - -#define LINUX_IP_TOS 1 -#define LINUX_IP_TTL 2 -#define LINUX_IP_HDRINCL 3 -#define LINUX_IP_OPTIONS 4 - -#define LINUX_IP_MULTICAST_IF 32 -#define LINUX_IP_MULTICAST_TTL 33 -#define LINUX_IP_MULTICAST_LOOP 34 -#define LINUX_IP_ADD_MEMBERSHIP 35 -#define LINUX_IP_DROP_MEMBERSHIP 36 - -/* Sound system defines */ -#define LINUX_SNDCTL_SEQ_RESET 0x5100 -#define LINUX_SNDCTL_SEQ_SYNC 0x5101 -#define LINUX_SNDCTL_SYNTH_INFO 0x5102 -#define LINUX_SNDCTL_SEQ_CTRLRATE 0x5103 -#define LINUX_SNDCTL_SEQ_GETOUTCOUNT 0x5104 -#define LINUX_SNDCTL_SEQ_GETINCOUNT 0x5105 -#define LINUX_SNDCTL_SEQ_PERCMODE 0x5106 -#define LINUX_SNDCTL_FM_LOAD_INSTR 0x5107 -#define LINUX_SNDCTL_SEQ_TESTMIDI 0x5108 -#define LINUX_SNDCTL_SEQ_RESETSAMPLES 0x5109 -#define LINUX_SNDCTL_SEQ_NRSYNTHS 0x510A -#define LINUX_SNDCTL_SEQ_NRMIDIS 0x510B -#define LINUX_SNDCTL_MIDI_INFO 0x510C -#define LINUX_SNDCTL_SEQ_TRESHOLD 0x510D -#define LINUX_SNDCTL_SYNTH_MEMAVL 0x510E -#define LINUX_SNDCTL_DSP_RESET 0x5000 -#define LINUX_SNDCTL_DSP_SYNC 0x5001 -#define LINUX_SNDCTL_DSP_SPEED 0x5002 -#define LINUX_SNDCTL_DSP_STEREO 0x5003 -#define LINUX_SNDCTL_DSP_GETBLKSIZE 0x5004 -#define LINUX_SNDCTL_DSP_SETBLKSIZE 0x5004 -#define LINUX_SNDCTL_DSP_SETFMT 0x5005 -#define LINUX_SOUND_PCM_WRITE_CHANNELS 0x5006 -#define LINUX_SOUND_PCM_WRITE_FILTER 0x5007 -#define LINUX_SNDCTL_DSP_POST 0x5008 -#define LINUX_SNDCTL_DSP_SUBDIVIDE 0x5009 -#define LINUX_SNDCTL_DSP_SETFRAGMENT 0x500A -#define LINUX_SNDCTL_DSP_GETFMTS 0x500B -#define LINUX_SNDCTL_DSP_GETOSPACE 0x500C -#define LINUX_SNDCTL_DSP_GETISPACE 0x500D -#define LINUX_SNDCTL_DSP_NONBLOCK 0x500E -#define LINUX_SNDCTL_DSP_GETCAPS 0x500F -#define LINUX_SNDCTL_DSP_GETTRIGGER 0x5010 -#define LINUX_SNDCTL_DSP_SETTRIGGER 0x5010 -#define LINUX_SNDCTL_DSP_GETIPTR 0x5011 -#define LINUX_SNDCTL_DSP_GETOPTR 0x5012 -#define LINUX_SNDCTL_DSP_GETODELAY 0x5017 -#define LINUX_SOUND_MIXER_WRITE_VOLUME 0x4d00 -#define LINUX_SOUND_MIXER_WRITE_BASS 0x4d01 -#define LINUX_SOUND_MIXER_WRITE_TREBLE 0x4d02 -#define LINUX_SOUND_MIXER_WRITE_SYNTH 0x4d03 -#define LINUX_SOUND_MIXER_WRITE_PCM 0x4d04 -#define LINUX_SOUND_MIXER_WRITE_SPEAKER 0x4d05 -#define LINUX_SOUND_MIXER_WRITE_LINE 0x4d06 -#define LINUX_SOUND_MIXER_WRITE_MIC 0x4d07 -#define LINUX_SOUND_MIXER_WRITE_CD 0x4d08 -#define LINUX_SOUND_MIXER_WRITE_IMIX 0x4d09 -#define LINUX_SOUND_MIXER_WRITE_ALTPCM 0x4d0A -#define LINUX_SOUND_MIXER_WRITE_RECLEV 0x4d0B -#define LINUX_SOUND_MIXER_WRITE_IGAIN 0x4d0C -#define LINUX_SOUND_MIXER_WRITE_OGAIN 0x4d0D -#define LINUX_SOUND_MIXER_WRITE_LINE1 0x4d0E -#define LINUX_SOUND_MIXER_WRITE_LINE2 0x4d0F -#define LINUX_SOUND_MIXER_WRITE_LINE3 0x4d10 -#define LINUX_SOUND_MIXER_READ_DEVMASK 0x4dfe - -#define LINUX_OSS_GETVERSION 0x4d76 - -/* Socket system defines */ -#define LINUX_FIOSETOWN 0x8901 -#define LINUX_SIOCSPGRP 0x8902 -#define LINUX_FIOGETOWN 0x8903 -#define LINUX_SIOCGPGRP 0x8904 -#define LINUX_SIOCATMARK 0x8905 -#define LINUX_SIOCGSTAMP 0x8906 -#define LINUX_SIOCGIFCONF 0x8912 -#define LINUX_SIOCGIFFLAGS 0x8913 -#define LINUX_SIOCGIFADDR 0x8915 -#define LINUX_SIOCGIFDSTADDR 0x8917 -#define LINUX_SIOCGIFBRDADDR 0x8919 -#define LINUX_SIOCGIFNETMASK 0x891b -#define LINUX_SIOCGIFHWADDR 0x8927 -#define LINUX_SIOCADDMULTI 0x8931 -#define LINUX_SIOCDELMULTI 0x8932 - -struct linux_sockaddr -{ - unsigned short sa_family; - char sa_data[14]; +/* + * Socket defines + */ +#define LINUX_SOCKET 1 +#define LINUX_BIND 2 +#define LINUX_CONNECT 3 +#define LINUX_LISTEN 4 +#define LINUX_ACCEPT 5 +#define LINUX_GETSOCKNAME 6 +#define LINUX_GETPEERNAME 7 +#define LINUX_SOCKETPAIR 8 +#define LINUX_SEND 9 +#define LINUX_RECV 10 +#define LINUX_SENDTO 11 +#define LINUX_RECVFROM 12 +#define LINUX_SHUTDOWN 13 +#define LINUX_SETSOCKOPT 14 +#define LINUX_GETSOCKOPT 15 +#define LINUX_SENDMSG 16 +#define LINUX_RECVMSG 17 + +#define LINUX_AF_UNSPEC 0 +#define LINUX_AF_UNIX 1 +#define LINUX_AF_INET 2 +#define LINUX_AF_AX25 3 +#define LINUX_AF_IPX 4 +#define LINUX_AF_APPLETALK 5 + +#define LINUX_SOL_SOCKET 1 +#define LINUX_SOL_IP 0 +#define LINUX_SOL_IPX 256 +#define LINUX_SOL_AX25 257 +#define LINUX_SOL_TCP 6 +#define LINUX_SOL_UDP 17 + +#define LINUX_SO_DEBUG 1 +#define LINUX_SO_REUSEADDR 2 +#define LINUX_SO_TYPE 3 +#define LINUX_SO_ERROR 4 +#define LINUX_SO_DONTROUTE 5 +#define LINUX_SO_BROADCAST 6 +#define LINUX_SO_SNDBUF 7 +#define LINUX_SO_RCVBUF 8 +#define LINUX_SO_KEEPALIVE 9 +#define LINUX_SO_OOBINLINE 10 +#define LINUX_SO_NO_CHECK 11 +#define LINUX_SO_PRIORITY 12 +#define LINUX_SO_LINGER 13 + +#define LINUX_IP_TOS 1 +#define LINUX_IP_TTL 2 +#define LINUX_IP_HDRINCL 3 +#define LINUX_IP_OPTIONS 4 + +#define LINUX_IP_MULTICAST_IF 32 +#define LINUX_IP_MULTICAST_TTL 33 +#define LINUX_IP_MULTICAST_LOOP 34 +#define LINUX_IP_ADD_MEMBERSHIP 35 +#define LINUX_IP_DROP_MEMBERSHIP 36 + +struct linux_sockaddr { + u_short sa_family; + char sa_data[14]; }; -struct linux_ifmap -{ - unsigned long mem_start; - unsigned long mem_end; - unsigned short base_addr; - unsigned char irq; - unsigned char dma; - unsigned char port; +struct linux_ifmap { + u_long mem_start; + u_long mem_end; + u_short base_addr; + u_char irq; + u_char dma; + u_char port; }; -struct linux_ifreq -{ -#define LINUX_IFHWADDRLEN 6 -#define LINUX_IFNAMSIZ 16 - union - { - char ifrn_name[LINUX_IFNAMSIZ]; /* if name, e.g. "en0" */ - } ifr_ifrn; - - union { - struct linux_sockaddr ifru_addr; - struct linux_sockaddr ifru_dstaddr; - struct linux_sockaddr ifru_broadaddr; - struct linux_sockaddr ifru_netmask; - struct linux_sockaddr ifru_hwaddr; - short ifru_flags; - int ifru_metric; - int ifru_mtu; - struct linux_ifmap ifru_map; - char ifru_slave[LINUX_IFNAMSIZ]; /* Just fits the size */ - caddr_t ifru_data; - } ifr_ifru; +#define LINUX_IFHWADDRLEN 6 +#define LINUX_IFNAMSIZ 16 + +struct linux_ifreq { + union { + char ifrn_name[LINUX_IFNAMSIZ]; + } ifr_ifrn; + + union { + struct linux_sockaddr ifru_addr; + struct linux_sockaddr ifru_dstaddr; + struct linux_sockaddr ifru_broadaddr; + struct linux_sockaddr ifru_netmask; + struct linux_sockaddr ifru_hwaddr; + short ifru_flags; + int ifru_metric; + int ifru_mtu; + struct linux_ifmap ifru_map; + char ifru_slave[LINUX_IFNAMSIZ]; /* Just fits the size */ + linux_caddr_t ifru_data; + } ifr_ifru; }; -#define ifr_name ifr_ifrn.ifrn_name /* interface name */ -#define ifr_hwaddr ifr_ifru.ifru_hwaddr /* MAC address */ - - -/* serial_struct values for TIOC[GS]SERIAL ioctls */ -#define LINUX_ASYNC_CLOSING_WAIT_INF 0 -#define LINUX_ASYNC_CLOSING_WAIT_NONE 65535 - -#define LINUX_PORT_UNKNOWN 0 -#define LINUX_PORT_8250 1 -#define LINUX_PORT_16450 2 -#define LINUX_PORT_16550 3 -#define LINUX_PORT_16550A 4 -#define LINUX_PORT_CIRRUS 5 -#define LINUX_PORT_16650 6 -#define LINUX_PORT_MAX 6 - -#define LINUX_ASYNC_HUP_NOTIFY 0x0001 -#define LINUX_ASYNC_FOURPORT 0x0002 -#define LINUX_ASYNC_SAK 0x0004 -#define LINUX_ASYNC_SPLIT_TERMIOS 0x0008 -#define LINUX_ASYNC_SPD_MASK 0x0030 -#define LINUX_ASYNC_SPD_HI 0x0010 -#define LINUX_ASYNC_SPD_VHI 0x0020 -#define LINUX_ASYNC_SPD_CUST 0x0030 -#define LINUX_ASYNC_SKIP_TEST 0x0040 -#define LINUX_ASYNC_AUTO_IRQ 0x0080 -#define LINUX_ASYNC_SESSION_LOCKOUT 0x0100 -#define LINUX_ASYNC_PGRP_LOCKOUT 0x0200 -#define LINUX_ASYNC_CALLOUT_NOHUP 0x0400 -#define LINUX_ASYNC_FLAGS 0x0FFF - -/* cdrom */ -#define LINUX_CDROMPAUSE 0x5301 -#define LINUX_CDROMRESUME 0x5302 -#define LINUX_CDROMPLAYMSF 0x5303 -#define LINUX_CDROMPLAYTRKIND 0x5304 -#define LINUX_CDROMREADTOCHDR 0x5305 -#define LINUX_CDROMREADTOCENTRY 0x5306 -#define LINUX_CDROMSTOP 0x5307 -#define LINUX_CDROMSTART 0x5308 -#define LINUX_CDROMEJECT 0x5309 -#define LINUX_CDROMVOLCTRL 0x530a -#define LINUX_CDROMSUBCHNL 0x530b -#define LINUX_CDROMREADMODE2 0x530c -#define LINUX_CDROMREADMODE1 0x530d -#define LINUX_CDROMREADAUDIO 0x530e -#define LINUX_CDROMEJECT_SW 0x530f -#define LINUX_CDROMMULTISESSION 0x5310 -#define LINUX_CDROM_GET_UPC 0x5311 -#define LINUX_CDROMRESET 0x5312 -#define LINUX_CDROMVOLREAD 0x5313 -#define LINUX_CDROMREADRAW 0x5314 -#define LINUX_CDROMREADCOOKED 0x5315 -#define LINUX_CDROMSEEK 0x5316 -#define LINUX_CDROMPLAYBLK 0x5317 -#define LINUX_CDROMREADALL 0x5318 -#define LINUX_CDROMCLOSETRAY 0x5319 -#define LINUX_CDROMLOADFROMSLOT 0x531a - -#define LINUX_CDROM_LBA 0x01 -#define LINUX_CDROM_MSF 0x02 - -/* Scheduling policies */ -#define LINUX_SCHED_OTHER 0 -#define LINUX_SCHED_FIFO 1 -#define LINUX_SCHED_RR 2 +#define ifr_name ifr_ifrn.ifrn_name /* interface name */ +#define ifr_hwaddr ifr_ifru.ifru_hwaddr /* MAC address */ #endif /* !_I386_LINUX_LINUX_H_ */ diff --git a/sys/i386/linux/linux_ioctl.c b/sys/i386/linux/linux_ioctl.c index 64fa513..bc23d69 100644 --- a/sys/i386/linux/linux_ioctl.c +++ b/sys/i386/linux/linux_ioctl.c @@ -37,6 +37,8 @@ #include <sys/file.h> #include <sys/filedesc.h> #include <sys/filio.h> +#include <sys/linker_set.h> +#include <sys/malloc.h> #include <sys/tty.h> #include <sys/socket.h> #include <net/if.h> @@ -48,1242 +50,1456 @@ #include <machine/console.h> #include <i386/linux/linux.h> +#include <i386/linux/linux_ioctl.h> +#include <i386/linux/linux_mib.h> #include <i386/linux/linux_proto.h> #include <i386/linux/linux_util.h> -#include <i386/linux/linux_mib.h> -#define ISSIGVALID(sig) ((sig) > 0 && (sig) < NSIG) +static linux_ioctl_function_t linux_ioctl_cdrom; +static linux_ioctl_function_t linux_ioctl_console; +static linux_ioctl_function_t linux_ioctl_socket; +static linux_ioctl_function_t linux_ioctl_sound; +static linux_ioctl_function_t linux_ioctl_termio; + +static struct linux_ioctl_handler cdrom_handler = +{ linux_ioctl_cdrom, LINUX_IOCTL_CDROM_MIN, LINUX_IOCTL_CDROM_MAX }; +static struct linux_ioctl_handler console_handler = +{ linux_ioctl_console, LINUX_IOCTL_CONSOLE_MIN, LINUX_IOCTL_CONSOLE_MAX }; +static struct linux_ioctl_handler socket_handler = +{ linux_ioctl_socket, LINUX_IOCTL_SOCKET_MIN, LINUX_IOCTL_SOCKET_MAX }; +static struct linux_ioctl_handler sound_handler = +{ linux_ioctl_sound, LINUX_IOCTL_SOUND_MIN, LINUX_IOCTL_SOUND_MAX }; +static struct linux_ioctl_handler termio_handler = +{ linux_ioctl_termio, LINUX_IOCTL_TERMIO_MIN, LINUX_IOCTL_TERMIO_MAX }; + +DATA_SET(linux_ioctl_handler_set, cdrom_handler); +DATA_SET(linux_ioctl_handler_set, console_handler); +DATA_SET(linux_ioctl_handler_set, socket_handler); +DATA_SET(linux_ioctl_handler_set, sound_handler); +DATA_SET(linux_ioctl_handler_set, termio_handler); + +struct handler_element +{ + TAILQ_ENTRY(handler_element) list; + int (*func)(struct proc *, struct linux_ioctl_args *); + int low, high, span; +}; + +static TAILQ_HEAD(, handler_element) handlers = + TAILQ_HEAD_INITIALIZER(handlers); + +/* + * termio related ioctls + */ struct linux_termio { - unsigned short c_iflag; - unsigned short c_oflag; - unsigned short c_cflag; - unsigned short c_lflag; - unsigned char c_line; - unsigned char c_cc[LINUX_NCC]; + unsigned short c_iflag; + unsigned short c_oflag; + unsigned short c_cflag; + unsigned short c_lflag; + unsigned char c_line; + unsigned char c_cc[LINUX_NCC]; }; - struct linux_termios { - unsigned int c_iflag; - unsigned int c_oflag; - unsigned int c_cflag; - unsigned int c_lflag; - unsigned char c_line; - unsigned char c_cc[LINUX_NCCS]; + unsigned int c_iflag; + unsigned int c_oflag; + unsigned int c_cflag; + unsigned int c_lflag; + unsigned char c_line; + unsigned char c_cc[LINUX_NCCS]; }; struct linux_winsize { - unsigned short ws_row, ws_col; - unsigned short ws_xpixel, ws_ypixel; + unsigned short ws_row, ws_col; + unsigned short ws_xpixel, ws_ypixel; }; static struct speedtab sptab[] = { - { B0, LINUX_B0 }, { B50, LINUX_B50 }, - { B75, LINUX_B75 }, { B110, LINUX_B110 }, - { B134, LINUX_B134 }, { B150, LINUX_B150 }, - { B200, LINUX_B200 }, { B300, LINUX_B300 }, - { B600, LINUX_B600 }, { B1200, LINUX_B1200 }, - { B1800, LINUX_B1800 }, { B2400, LINUX_B2400 }, - { B4800, LINUX_B4800 }, { B9600, LINUX_B9600 }, - { B19200, LINUX_B19200 }, { B38400, LINUX_B38400 }, - { B57600, LINUX_B57600 }, { B115200, LINUX_B115200 }, - {-1, -1 } + { B0, LINUX_B0 }, { B50, LINUX_B50 }, + { B75, LINUX_B75 }, { B110, LINUX_B110 }, + { B134, LINUX_B134 }, { B150, LINUX_B150 }, + { B200, LINUX_B200 }, { B300, LINUX_B300 }, + { B600, LINUX_B600 }, { B1200, LINUX_B1200 }, + { B1800, LINUX_B1800 }, { B2400, LINUX_B2400 }, + { B4800, LINUX_B4800 }, { B9600, LINUX_B9600 }, + { B19200, LINUX_B19200 }, { B38400, LINUX_B38400 }, + { B57600, LINUX_B57600 }, { B115200, LINUX_B115200 }, + {-1, -1 } }; struct linux_serial_struct { - int type; - int line; - int port; - int irq; - int flags; - int xmit_fifo_size; - int custom_divisor; - int baud_base; - unsigned short close_delay; - char reserved_char[2]; - int hub6; - unsigned short closing_wait; - unsigned short closing_wait2; - int reserved[4]; + int type; + int line; + int port; + int irq; + int flags; + int xmit_fifo_size; + int custom_divisor; + int baud_base; + unsigned short close_delay; + char reserved_char[2]; + int hub6; + unsigned short closing_wait; + unsigned short closing_wait2; + int reserved[4]; }; - static int linux_to_bsd_speed(int code, struct speedtab *table) { - for ( ; table->sp_code != -1; table++) - if (table->sp_code == code) - return (table->sp_speed); - return -1; + for ( ; table->sp_code != -1; table++) + if (table->sp_code == code) + return (table->sp_speed); + return -1; } static int bsd_to_linux_speed(int speed, struct speedtab *table) { - for ( ; table->sp_speed != -1; table++) - if (table->sp_speed == speed) - return (table->sp_code); - return -1; + for ( ; table->sp_speed != -1; table++) + if (table->sp_speed == speed) + return (table->sp_code); + return -1; } static void -bsd_to_linux_termios(struct termios *bsd_termios, - struct linux_termios *linux_termios) +bsd_to_linux_termios(struct termios *bios, struct linux_termios *lios) { - int i; + int i; #ifdef DEBUG - printf("LINUX: BSD termios structure (input):\n"); - printf("i=%08x o=%08x c=%08x l=%08x ispeed=%d ospeed=%d\n", - bsd_termios->c_iflag, bsd_termios->c_oflag, - bsd_termios->c_cflag, bsd_termios->c_lflag, - bsd_termios->c_ispeed, bsd_termios->c_ospeed); - printf("c_cc "); - for (i=0; i<NCCS; i++) - printf("%02x ", bsd_termios->c_cc[i]); - printf("\n"); + printf("LINUX: BSD termios structure (input):\n"); + printf("i=%08x o=%08x c=%08x l=%08x ispeed=%d ospeed=%d\n", + bios->c_iflag, bios->c_oflag, bios->c_cflag, bios->c_lflag, + bios->c_ispeed, bios->c_ospeed); + printf("c_cc "); + for (i=0; i<NCCS; i++) + printf("%02x ", bios->c_cc[i]); + printf("\n"); #endif - linux_termios->c_iflag = 0; - if (bsd_termios->c_iflag & IGNBRK) - linux_termios->c_iflag |= LINUX_IGNBRK; - if (bsd_termios->c_iflag & BRKINT) - linux_termios->c_iflag |= LINUX_BRKINT; - if (bsd_termios->c_iflag & IGNPAR) - linux_termios->c_iflag |= LINUX_IGNPAR; - if (bsd_termios->c_iflag & PARMRK) - linux_termios->c_iflag |= LINUX_PARMRK; - if (bsd_termios->c_iflag & INPCK) - linux_termios->c_iflag |= LINUX_INPCK; - if (bsd_termios->c_iflag & ISTRIP) - linux_termios->c_iflag |= LINUX_ISTRIP; - if (bsd_termios->c_iflag & INLCR) - linux_termios->c_iflag |= LINUX_INLCR; - if (bsd_termios->c_iflag & IGNCR) - linux_termios->c_iflag |= LINUX_IGNCR; - if (bsd_termios->c_iflag & ICRNL) - linux_termios->c_iflag |= LINUX_ICRNL; - if (bsd_termios->c_iflag & IXON) - linux_termios->c_iflag |= LINUX_IXON; - if (bsd_termios->c_iflag & IXANY) - linux_termios->c_iflag |= LINUX_IXANY; - if (bsd_termios->c_iflag & IXOFF) - linux_termios->c_iflag |= LINUX_IXOFF; - if (bsd_termios->c_iflag & IMAXBEL) - linux_termios->c_iflag |= LINUX_IMAXBEL; - - linux_termios->c_oflag = 0; - if (bsd_termios->c_oflag & OPOST) - linux_termios->c_oflag |= LINUX_OPOST; - if (bsd_termios->c_oflag & ONLCR) - linux_termios->c_oflag |= LINUX_ONLCR; - if (bsd_termios->c_oflag & OXTABS) - linux_termios->c_oflag |= LINUX_XTABS; - - linux_termios->c_cflag = - bsd_to_linux_speed(bsd_termios->c_ispeed, sptab); - linux_termios->c_cflag |= (bsd_termios->c_cflag & CSIZE) >> 4; - if (bsd_termios->c_cflag & CSTOPB) - linux_termios->c_cflag |= LINUX_CSTOPB; - if (bsd_termios->c_cflag & CREAD) - linux_termios->c_cflag |= LINUX_CREAD; - if (bsd_termios->c_cflag & PARENB) - linux_termios->c_cflag |= LINUX_PARENB; - if (bsd_termios->c_cflag & PARODD) - linux_termios->c_cflag |= LINUX_PARODD; - if (bsd_termios->c_cflag & HUPCL) - linux_termios->c_cflag |= LINUX_HUPCL; - if (bsd_termios->c_cflag & CLOCAL) - linux_termios->c_cflag |= LINUX_CLOCAL; - if (bsd_termios->c_cflag & CRTSCTS) - linux_termios->c_cflag |= LINUX_CRTSCTS; - - linux_termios->c_lflag = 0; - if (bsd_termios->c_lflag & ISIG) - linux_termios->c_lflag |= LINUX_ISIG; - if (bsd_termios->c_lflag & ICANON) - linux_termios->c_lflag |= LINUX_ICANON; - if (bsd_termios->c_lflag & ECHO) - linux_termios->c_lflag |= LINUX_ECHO; - if (bsd_termios->c_lflag & ECHOE) - linux_termios->c_lflag |= LINUX_ECHOE; - if (bsd_termios->c_lflag & ECHOK) - linux_termios->c_lflag |= LINUX_ECHOK; - if (bsd_termios->c_lflag & ECHONL) - linux_termios->c_lflag |= LINUX_ECHONL; - if (bsd_termios->c_lflag & NOFLSH) - linux_termios->c_lflag |= LINUX_NOFLSH; - if (bsd_termios->c_lflag & TOSTOP) - linux_termios->c_lflag |= LINUX_TOSTOP; - if (bsd_termios->c_lflag & ECHOCTL) - linux_termios->c_lflag |= LINUX_ECHOCTL; - if (bsd_termios->c_lflag & ECHOPRT) - linux_termios->c_lflag |= LINUX_ECHOPRT; - if (bsd_termios->c_lflag & ECHOKE) - linux_termios->c_lflag |= LINUX_ECHOKE; - if (bsd_termios->c_lflag & FLUSHO) - linux_termios->c_lflag |= LINUX_FLUSHO; - if (bsd_termios->c_lflag & PENDIN) - linux_termios->c_lflag |= LINUX_PENDIN; - if (bsd_termios->c_lflag & IEXTEN) - linux_termios->c_lflag |= LINUX_IEXTEN; - - for (i=0; i<LINUX_NCCS; i++) - linux_termios->c_cc[i] = LINUX_POSIX_VDISABLE; - linux_termios->c_cc[LINUX_VINTR] = bsd_termios->c_cc[VINTR]; - linux_termios->c_cc[LINUX_VQUIT] = bsd_termios->c_cc[VQUIT]; - linux_termios->c_cc[LINUX_VERASE] = bsd_termios->c_cc[VERASE]; - linux_termios->c_cc[LINUX_VKILL] = bsd_termios->c_cc[VKILL]; - linux_termios->c_cc[LINUX_VEOF] = bsd_termios->c_cc[VEOF]; - linux_termios->c_cc[LINUX_VEOL] = bsd_termios->c_cc[VEOL]; - linux_termios->c_cc[LINUX_VMIN] = bsd_termios->c_cc[VMIN]; - linux_termios->c_cc[LINUX_VTIME] = bsd_termios->c_cc[VTIME]; - linux_termios->c_cc[LINUX_VEOL2] = bsd_termios->c_cc[VEOL2]; - linux_termios->c_cc[LINUX_VSUSP] = bsd_termios->c_cc[VSUSP]; - linux_termios->c_cc[LINUX_VSTART] = bsd_termios->c_cc[VSTART]; - linux_termios->c_cc[LINUX_VSTOP] = bsd_termios->c_cc[VSTOP]; - linux_termios->c_cc[LINUX_VREPRINT] = bsd_termios->c_cc[VREPRINT]; - linux_termios->c_cc[LINUX_VDISCARD] = bsd_termios->c_cc[VDISCARD]; - linux_termios->c_cc[LINUX_VWERASE] = bsd_termios->c_cc[VWERASE]; - linux_termios->c_cc[LINUX_VLNEXT] = bsd_termios->c_cc[VLNEXT]; - - for (i=0; i<LINUX_NCCS; i++) { - if (linux_termios->c_cc[i] == _POSIX_VDISABLE) - linux_termios->c_cc[i] = LINUX_POSIX_VDISABLE; - } - - linux_termios->c_line = 0; + + lios->c_iflag = 0; + if (bios->c_iflag & IGNBRK) + lios->c_iflag |= LINUX_IGNBRK; + if (bios->c_iflag & BRKINT) + lios->c_iflag |= LINUX_BRKINT; + if (bios->c_iflag & IGNPAR) + lios->c_iflag |= LINUX_IGNPAR; + if (bios->c_iflag & PARMRK) + lios->c_iflag |= LINUX_PARMRK; + if (bios->c_iflag & INPCK) + lios->c_iflag |= LINUX_INPCK; + if (bios->c_iflag & ISTRIP) + lios->c_iflag |= LINUX_ISTRIP; + if (bios->c_iflag & INLCR) + lios->c_iflag |= LINUX_INLCR; + if (bios->c_iflag & IGNCR) + lios->c_iflag |= LINUX_IGNCR; + if (bios->c_iflag & ICRNL) + lios->c_iflag |= LINUX_ICRNL; + if (bios->c_iflag & IXON) + lios->c_iflag |= LINUX_IXON; + if (bios->c_iflag & IXANY) + lios->c_iflag |= LINUX_IXANY; + if (bios->c_iflag & IXOFF) + lios->c_iflag |= LINUX_IXOFF; + if (bios->c_iflag & IMAXBEL) + lios->c_iflag |= LINUX_IMAXBEL; + + lios->c_oflag = 0; + if (bios->c_oflag & OPOST) + lios->c_oflag |= LINUX_OPOST; + if (bios->c_oflag & ONLCR) + lios->c_oflag |= LINUX_ONLCR; + if (bios->c_oflag & OXTABS) + lios->c_oflag |= LINUX_XTABS; + + lios->c_cflag = bsd_to_linux_speed(bios->c_ispeed, sptab); + lios->c_cflag |= (bios->c_cflag & CSIZE) >> 4; + if (bios->c_cflag & CSTOPB) + lios->c_cflag |= LINUX_CSTOPB; + if (bios->c_cflag & CREAD) + lios->c_cflag |= LINUX_CREAD; + if (bios->c_cflag & PARENB) + lios->c_cflag |= LINUX_PARENB; + if (bios->c_cflag & PARODD) + lios->c_cflag |= LINUX_PARODD; + if (bios->c_cflag & HUPCL) + lios->c_cflag |= LINUX_HUPCL; + if (bios->c_cflag & CLOCAL) + lios->c_cflag |= LINUX_CLOCAL; + if (bios->c_cflag & CRTSCTS) + lios->c_cflag |= LINUX_CRTSCTS; + + lios->c_lflag = 0; + if (bios->c_lflag & ISIG) + lios->c_lflag |= LINUX_ISIG; + if (bios->c_lflag & ICANON) + lios->c_lflag |= LINUX_ICANON; + if (bios->c_lflag & ECHO) + lios->c_lflag |= LINUX_ECHO; + if (bios->c_lflag & ECHOE) + lios->c_lflag |= LINUX_ECHOE; + if (bios->c_lflag & ECHOK) + lios->c_lflag |= LINUX_ECHOK; + if (bios->c_lflag & ECHONL) + lios->c_lflag |= LINUX_ECHONL; + if (bios->c_lflag & NOFLSH) + lios->c_lflag |= LINUX_NOFLSH; + if (bios->c_lflag & TOSTOP) + lios->c_lflag |= LINUX_TOSTOP; + if (bios->c_lflag & ECHOCTL) + lios->c_lflag |= LINUX_ECHOCTL; + if (bios->c_lflag & ECHOPRT) + lios->c_lflag |= LINUX_ECHOPRT; + if (bios->c_lflag & ECHOKE) + lios->c_lflag |= LINUX_ECHOKE; + if (bios->c_lflag & FLUSHO) + lios->c_lflag |= LINUX_FLUSHO; + if (bios->c_lflag & PENDIN) + lios->c_lflag |= LINUX_PENDIN; + if (bios->c_lflag & IEXTEN) + lios->c_lflag |= LINUX_IEXTEN; + + for (i=0; i<LINUX_NCCS; i++) + lios->c_cc[i] = LINUX_POSIX_VDISABLE; + lios->c_cc[LINUX_VINTR] = bios->c_cc[VINTR]; + lios->c_cc[LINUX_VQUIT] = bios->c_cc[VQUIT]; + lios->c_cc[LINUX_VERASE] = bios->c_cc[VERASE]; + lios->c_cc[LINUX_VKILL] = bios->c_cc[VKILL]; + lios->c_cc[LINUX_VEOF] = bios->c_cc[VEOF]; + lios->c_cc[LINUX_VEOL] = bios->c_cc[VEOL]; + lios->c_cc[LINUX_VMIN] = bios->c_cc[VMIN]; + lios->c_cc[LINUX_VTIME] = bios->c_cc[VTIME]; + lios->c_cc[LINUX_VEOL2] = bios->c_cc[VEOL2]; + lios->c_cc[LINUX_VSUSP] = bios->c_cc[VSUSP]; + lios->c_cc[LINUX_VSTART] = bios->c_cc[VSTART]; + lios->c_cc[LINUX_VSTOP] = bios->c_cc[VSTOP]; + lios->c_cc[LINUX_VREPRINT] = bios->c_cc[VREPRINT]; + lios->c_cc[LINUX_VDISCARD] = bios->c_cc[VDISCARD]; + lios->c_cc[LINUX_VWERASE] = bios->c_cc[VWERASE]; + lios->c_cc[LINUX_VLNEXT] = bios->c_cc[VLNEXT]; + + for (i=0; i<LINUX_NCCS; i++) { + if (lios->c_cc[i] == _POSIX_VDISABLE) + lios->c_cc[i] = LINUX_POSIX_VDISABLE; + } + lios->c_line = 0; + #ifdef DEBUG - printf("LINUX: LINUX termios structure (output):\n"); - printf("i=%08x o=%08x c=%08x l=%08x line=%d\n", - linux_termios->c_iflag, linux_termios->c_oflag, linux_termios->c_cflag, - linux_termios->c_lflag, (int)linux_termios->c_line); - printf("c_cc "); - for (i=0; i<LINUX_NCCS; i++) - printf("%02x ", linux_termios->c_cc[i]); - printf("\n"); + printf("LINUX: LINUX termios structure (output):\n"); + printf("i=%08x o=%08x c=%08x l=%08x line=%d\n", lios->c_iflag, + lios->c_oflag, lios->c_cflag, lios->c_lflag, (int)lios->c_line); + printf("c_cc "); + for (i=0; i<LINUX_NCCS; i++) + printf("%02x ", lios->c_cc[i]); + printf("\n"); #endif } - static void -linux_to_bsd_termios(struct linux_termios *linux_termios, - struct termios *bsd_termios) +linux_to_bsd_termios(struct linux_termios *lios, struct termios *bios) { - int i; + int i; + #ifdef DEBUG - printf("LINUX: LINUX termios structure (input):\n"); - printf("i=%08x o=%08x c=%08x l=%08x line=%d\n", - linux_termios->c_iflag, linux_termios->c_oflag, linux_termios->c_cflag, - linux_termios->c_lflag, (int)linux_termios->c_line); - printf("c_cc "); - for (i=0; i<LINUX_NCCS; i++) - printf("%02x ", linux_termios->c_cc[i]); - printf("\n"); + printf("LINUX: LINUX termios structure (input):\n"); + printf("i=%08x o=%08x c=%08x l=%08x line=%d\n", lios->c_iflag, + lios->c_oflag, lios->c_cflag, lios->c_lflag, (int)lios->c_line); + printf("c_cc "); + for (i=0; i<LINUX_NCCS; i++) + printf("%02x ", lios->c_cc[i]); + printf("\n"); #endif - bsd_termios->c_iflag = 0; - if (linux_termios->c_iflag & LINUX_IGNBRK) - bsd_termios->c_iflag |= IGNBRK; - if (linux_termios->c_iflag & LINUX_BRKINT) - bsd_termios->c_iflag |= BRKINT; - if (linux_termios->c_iflag & LINUX_IGNPAR) - bsd_termios->c_iflag |= IGNPAR; - if (linux_termios->c_iflag & LINUX_PARMRK) - bsd_termios->c_iflag |= PARMRK; - if (linux_termios->c_iflag & LINUX_INPCK) - bsd_termios->c_iflag |= INPCK; - if (linux_termios->c_iflag & LINUX_ISTRIP) - bsd_termios->c_iflag |= ISTRIP; - if (linux_termios->c_iflag & LINUX_INLCR) - bsd_termios->c_iflag |= INLCR; - if (linux_termios->c_iflag & LINUX_IGNCR) - bsd_termios->c_iflag |= IGNCR; - if (linux_termios->c_iflag & LINUX_ICRNL) - bsd_termios->c_iflag |= ICRNL; - if (linux_termios->c_iflag & LINUX_IXON) - bsd_termios->c_iflag |= IXON; - if (linux_termios->c_iflag & LINUX_IXANY) - bsd_termios->c_iflag |= IXANY; - if (linux_termios->c_iflag & LINUX_IXOFF) - bsd_termios->c_iflag |= IXOFF; - if (linux_termios->c_iflag & LINUX_IMAXBEL) - bsd_termios->c_iflag |= IMAXBEL; - - bsd_termios->c_oflag = 0; - if (linux_termios->c_oflag & LINUX_OPOST) - bsd_termios->c_oflag |= OPOST; - if (linux_termios->c_oflag & LINUX_ONLCR) - bsd_termios->c_oflag |= ONLCR; - if (linux_termios->c_oflag & LINUX_XTABS) - bsd_termios->c_oflag |= OXTABS; - - bsd_termios->c_cflag = (linux_termios->c_cflag & LINUX_CSIZE) << 4; - if (linux_termios->c_cflag & LINUX_CSTOPB) - bsd_termios->c_cflag |= CSTOPB; - if (linux_termios->c_cflag & LINUX_CREAD) - bsd_termios->c_cflag |= CREAD; - if (linux_termios->c_cflag & LINUX_PARENB) - bsd_termios->c_cflag |= PARENB; - if (linux_termios->c_cflag & LINUX_PARODD) - bsd_termios->c_cflag |= PARODD; - if (linux_termios->c_cflag & LINUX_HUPCL) - bsd_termios->c_cflag |= HUPCL; - if (linux_termios->c_cflag & LINUX_CLOCAL) - bsd_termios->c_cflag |= CLOCAL; - if (linux_termios->c_cflag & LINUX_CRTSCTS) - bsd_termios->c_cflag |= CRTSCTS; - - bsd_termios->c_lflag = 0; - if (linux_termios->c_lflag & LINUX_ISIG) - bsd_termios->c_lflag |= ISIG; - if (linux_termios->c_lflag & LINUX_ICANON) - bsd_termios->c_lflag |= ICANON; - if (linux_termios->c_lflag & LINUX_ECHO) - bsd_termios->c_lflag |= ECHO; - if (linux_termios->c_lflag & LINUX_ECHOE) - bsd_termios->c_lflag |= ECHOE; - if (linux_termios->c_lflag & LINUX_ECHOK) - bsd_termios->c_lflag |= ECHOK; - if (linux_termios->c_lflag & LINUX_ECHONL) - bsd_termios->c_lflag |= ECHONL; - if (linux_termios->c_lflag & LINUX_NOFLSH) - bsd_termios->c_lflag |= NOFLSH; - if (linux_termios->c_lflag & LINUX_TOSTOP) - bsd_termios->c_lflag |= TOSTOP; - if (linux_termios->c_lflag & LINUX_ECHOCTL) - bsd_termios->c_lflag |= ECHOCTL; - if (linux_termios->c_lflag & LINUX_ECHOPRT) - bsd_termios->c_lflag |= ECHOPRT; - if (linux_termios->c_lflag & LINUX_ECHOKE) - bsd_termios->c_lflag |= ECHOKE; - if (linux_termios->c_lflag & LINUX_FLUSHO) - bsd_termios->c_lflag |= FLUSHO; - if (linux_termios->c_lflag & LINUX_PENDIN) - bsd_termios->c_lflag |= PENDIN; - if (linux_termios->c_lflag & LINUX_IEXTEN) - bsd_termios->c_lflag |= IEXTEN; - - for (i=0; i<NCCS; i++) - bsd_termios->c_cc[i] = _POSIX_VDISABLE; - bsd_termios->c_cc[VINTR] = linux_termios->c_cc[LINUX_VINTR]; - bsd_termios->c_cc[VQUIT] = linux_termios->c_cc[LINUX_VQUIT]; - bsd_termios->c_cc[VERASE] = linux_termios->c_cc[LINUX_VERASE]; - bsd_termios->c_cc[VKILL] = linux_termios->c_cc[LINUX_VKILL]; - bsd_termios->c_cc[VEOF] = linux_termios->c_cc[LINUX_VEOF]; - bsd_termios->c_cc[VEOL] = linux_termios->c_cc[LINUX_VEOL]; - bsd_termios->c_cc[VMIN] = linux_termios->c_cc[LINUX_VMIN]; - bsd_termios->c_cc[VTIME] = linux_termios->c_cc[LINUX_VTIME]; - bsd_termios->c_cc[VEOL2] = linux_termios->c_cc[LINUX_VEOL2]; - bsd_termios->c_cc[VSUSP] = linux_termios->c_cc[LINUX_VSUSP]; - bsd_termios->c_cc[VSTART] = linux_termios->c_cc[LINUX_VSTART]; - bsd_termios->c_cc[VSTOP] = linux_termios->c_cc[LINUX_VSTOP]; - bsd_termios->c_cc[VREPRINT] = linux_termios->c_cc[LINUX_VREPRINT]; - bsd_termios->c_cc[VDISCARD] = linux_termios->c_cc[LINUX_VDISCARD]; - bsd_termios->c_cc[VWERASE] = linux_termios->c_cc[LINUX_VWERASE]; - bsd_termios->c_cc[VLNEXT] = linux_termios->c_cc[LINUX_VLNEXT]; - - for (i=0; i<NCCS; i++) { - if (bsd_termios->c_cc[i] == LINUX_POSIX_VDISABLE) - bsd_termios->c_cc[i] = _POSIX_VDISABLE; - } - - bsd_termios->c_ispeed = bsd_termios->c_ospeed = - linux_to_bsd_speed(linux_termios->c_cflag & LINUX_CBAUD, sptab); + + bios->c_iflag = 0; + if (lios->c_iflag & LINUX_IGNBRK) + bios->c_iflag |= IGNBRK; + if (lios->c_iflag & LINUX_BRKINT) + bios->c_iflag |= BRKINT; + if (lios->c_iflag & LINUX_IGNPAR) + bios->c_iflag |= IGNPAR; + if (lios->c_iflag & LINUX_PARMRK) + bios->c_iflag |= PARMRK; + if (lios->c_iflag & LINUX_INPCK) + bios->c_iflag |= INPCK; + if (lios->c_iflag & LINUX_ISTRIP) + bios->c_iflag |= ISTRIP; + if (lios->c_iflag & LINUX_INLCR) + bios->c_iflag |= INLCR; + if (lios->c_iflag & LINUX_IGNCR) + bios->c_iflag |= IGNCR; + if (lios->c_iflag & LINUX_ICRNL) + bios->c_iflag |= ICRNL; + if (lios->c_iflag & LINUX_IXON) + bios->c_iflag |= IXON; + if (lios->c_iflag & LINUX_IXANY) + bios->c_iflag |= IXANY; + if (lios->c_iflag & LINUX_IXOFF) + bios->c_iflag |= IXOFF; + if (lios->c_iflag & LINUX_IMAXBEL) + bios->c_iflag |= IMAXBEL; + + bios->c_oflag = 0; + if (lios->c_oflag & LINUX_OPOST) + bios->c_oflag |= OPOST; + if (lios->c_oflag & LINUX_ONLCR) + bios->c_oflag |= ONLCR; + if (lios->c_oflag & LINUX_XTABS) + bios->c_oflag |= OXTABS; + + bios->c_cflag = (lios->c_cflag & LINUX_CSIZE) << 4; + if (lios->c_cflag & LINUX_CSTOPB) + bios->c_cflag |= CSTOPB; + if (lios->c_cflag & LINUX_CREAD) + bios->c_cflag |= CREAD; + if (lios->c_cflag & LINUX_PARENB) + bios->c_cflag |= PARENB; + if (lios->c_cflag & LINUX_PARODD) + bios->c_cflag |= PARODD; + if (lios->c_cflag & LINUX_HUPCL) + bios->c_cflag |= HUPCL; + if (lios->c_cflag & LINUX_CLOCAL) + bios->c_cflag |= CLOCAL; + if (lios->c_cflag & LINUX_CRTSCTS) + bios->c_cflag |= CRTSCTS; + + bios->c_lflag = 0; + if (lios->c_lflag & LINUX_ISIG) + bios->c_lflag |= ISIG; + if (lios->c_lflag & LINUX_ICANON) + bios->c_lflag |= ICANON; + if (lios->c_lflag & LINUX_ECHO) + bios->c_lflag |= ECHO; + if (lios->c_lflag & LINUX_ECHOE) + bios->c_lflag |= ECHOE; + if (lios->c_lflag & LINUX_ECHOK) + bios->c_lflag |= ECHOK; + if (lios->c_lflag & LINUX_ECHONL) + bios->c_lflag |= ECHONL; + if (lios->c_lflag & LINUX_NOFLSH) + bios->c_lflag |= NOFLSH; + if (lios->c_lflag & LINUX_TOSTOP) + bios->c_lflag |= TOSTOP; + if (lios->c_lflag & LINUX_ECHOCTL) + bios->c_lflag |= ECHOCTL; + if (lios->c_lflag & LINUX_ECHOPRT) + bios->c_lflag |= ECHOPRT; + if (lios->c_lflag & LINUX_ECHOKE) + bios->c_lflag |= ECHOKE; + if (lios->c_lflag & LINUX_FLUSHO) + bios->c_lflag |= FLUSHO; + if (lios->c_lflag & LINUX_PENDIN) + bios->c_lflag |= PENDIN; + if (lios->c_lflag & LINUX_IEXTEN) + bios->c_lflag |= IEXTEN; + + for (i=0; i<NCCS; i++) + bios->c_cc[i] = _POSIX_VDISABLE; + bios->c_cc[VINTR] = lios->c_cc[LINUX_VINTR]; + bios->c_cc[VQUIT] = lios->c_cc[LINUX_VQUIT]; + bios->c_cc[VERASE] = lios->c_cc[LINUX_VERASE]; + bios->c_cc[VKILL] = lios->c_cc[LINUX_VKILL]; + bios->c_cc[VEOF] = lios->c_cc[LINUX_VEOF]; + bios->c_cc[VEOL] = lios->c_cc[LINUX_VEOL]; + bios->c_cc[VMIN] = lios->c_cc[LINUX_VMIN]; + bios->c_cc[VTIME] = lios->c_cc[LINUX_VTIME]; + bios->c_cc[VEOL2] = lios->c_cc[LINUX_VEOL2]; + bios->c_cc[VSUSP] = lios->c_cc[LINUX_VSUSP]; + bios->c_cc[VSTART] = lios->c_cc[LINUX_VSTART]; + bios->c_cc[VSTOP] = lios->c_cc[LINUX_VSTOP]; + bios->c_cc[VREPRINT] = lios->c_cc[LINUX_VREPRINT]; + bios->c_cc[VDISCARD] = lios->c_cc[LINUX_VDISCARD]; + bios->c_cc[VWERASE] = lios->c_cc[LINUX_VWERASE]; + bios->c_cc[VLNEXT] = lios->c_cc[LINUX_VLNEXT]; + + for (i=0; i<NCCS; i++) { + if (bios->c_cc[i] == LINUX_POSIX_VDISABLE) + bios->c_cc[i] = _POSIX_VDISABLE; + } + + bios->c_ispeed = bios->c_ospeed = + linux_to_bsd_speed(lios->c_cflag & LINUX_CBAUD, sptab); + #ifdef DEBUG printf("LINUX: BSD termios structure (output):\n"); printf("i=%08x o=%08x c=%08x l=%08x ispeed=%d ospeed=%d\n", - bsd_termios->c_iflag, bsd_termios->c_oflag, - bsd_termios->c_cflag, bsd_termios->c_lflag, - bsd_termios->c_ispeed, bsd_termios->c_ospeed); + bios->c_iflag, bios->c_oflag, bios->c_cflag, bios->c_lflag, + bios->c_ispeed, bios->c_ospeed); printf("c_cc "); for (i=0; i<NCCS; i++) - printf("%02x ", bsd_termios->c_cc[i]); + printf("%02x ", bios->c_cc[i]); printf("\n"); #endif } - static void -bsd_to_linux_termio(struct termios *bsd_termios, - struct linux_termio *linux_termio) +bsd_to_linux_termio(struct termios *bios, struct linux_termio *lio) { - struct linux_termios tmios; - - bsd_to_linux_termios(bsd_termios, &tmios); - linux_termio->c_iflag = tmios.c_iflag; - linux_termio->c_oflag = tmios.c_oflag; - linux_termio->c_cflag = tmios.c_cflag; - linux_termio->c_lflag = tmios.c_lflag; - linux_termio->c_line = tmios.c_line; - memcpy(linux_termio->c_cc, tmios.c_cc, LINUX_NCC); + struct linux_termios lios; + + bsd_to_linux_termios(bios, &lios); + lio->c_iflag = lios.c_iflag; + lio->c_oflag = lios.c_oflag; + lio->c_cflag = lios.c_cflag; + lio->c_lflag = lios.c_lflag; + lio->c_line = lios.c_line; + memcpy(lio->c_cc, lios.c_cc, LINUX_NCC); } static void -linux_to_bsd_termio(struct linux_termio *linux_termio, - struct termios *bsd_termios) +linux_to_bsd_termio(struct linux_termio *lio, struct termios *bios) +{ + struct linux_termios lios; + int i; + + lios.c_iflag = lio->c_iflag; + lios.c_oflag = lio->c_oflag; + lios.c_cflag = lio->c_cflag; + lios.c_lflag = lio->c_lflag; + for (i=LINUX_NCC; i<LINUX_NCCS; i++) + lios.c_cc[i] = LINUX_POSIX_VDISABLE; + memcpy(lios.c_cc, lio->c_cc, LINUX_NCC); + linux_to_bsd_termios(&lios, bios); +} + +static int +linux_ioctl_termio(struct proc *p, struct linux_ioctl_args *args) { - struct linux_termios tmios; - int i; + struct termios bios; + struct linux_termios lios; + struct linux_termio lio; + struct file *fp = p->p_fd->fd_ofiles[args->fd]; + int error; + + switch (args->cmd & 0xffff) { + + case LINUX_TCGETS: + error = fo_ioctl(fp, TIOCGETA, (caddr_t)&bios, p); + if (error) + return (error); + bsd_to_linux_termios(&bios, &lios); + return copyout(&lios, (caddr_t)args->arg, sizeof(lios)); + + case LINUX_TCSETS: + error = copyin((caddr_t)args->arg, &lios, sizeof(lios)); + if (error) + return (error); + linux_to_bsd_termios(&lios, &bios); + return (fo_ioctl(fp, TIOCSETA, (caddr_t)&bios, p)); + + case LINUX_TCSETSW: + error = copyin((caddr_t)args->arg, &lios, sizeof(lios)); + if (error) + return (error); + linux_to_bsd_termios(&lios, &bios); + return (fo_ioctl(fp, TIOCSETAW, (caddr_t)&bios, p)); + + case LINUX_TCSETSF: + error = copyin((caddr_t)args->arg, &lios, sizeof(lios)); + if (error) + return (error); + linux_to_bsd_termios(&lios, &bios); + return (fo_ioctl(fp, TIOCSETAF, (caddr_t)&bios, p)); + + case LINUX_TCGETA: + error = fo_ioctl(fp, TIOCGETA, (caddr_t)&bios, p); + if (error) + return (error); + bsd_to_linux_termio(&bios, &lio); + return (copyout(&lio, (caddr_t)args->arg, sizeof(lio))); + + case LINUX_TCSETA: + error = copyin((caddr_t)args->arg, &lio, sizeof(lio)); + if (error) + return (error); + linux_to_bsd_termio(&lio, &bios); + return (fo_ioctl(fp, TIOCSETA, (caddr_t)&bios, p)); + + case LINUX_TCSETAW: + error = copyin((caddr_t)args->arg, &lio, sizeof(lio)); + if (error) + return (error); + linux_to_bsd_termio(&lio, &bios); + return (fo_ioctl(fp, TIOCSETAW, (caddr_t)&bios, p)); + + case LINUX_TCSETAF: + error = copyin((caddr_t)args->arg, &lio, sizeof(lio)); + if (error) + return (error); + linux_to_bsd_termio(&lio, &bios); + return (fo_ioctl(fp, TIOCSETAF, (caddr_t)&bios, p)); + + /* LINUX_TCSBRK */ + + case LINUX_TCXONC: { + switch (args->arg) { + case LINUX_TCOOFF: + args->cmd = TIOCSTOP; + break; + case LINUX_TCOON: + args->cmd = TIOCSTART; + break; + case LINUX_TCIOFF: + case LINUX_TCION: { + int c; + struct write_args wr; + error = fo_ioctl(fp, TIOCGETA, (caddr_t)&bios, p); + if (error) + return (error); + c = (args->arg == LINUX_TCIOFF) ? VSTOP : VSTART; + c = bios.c_cc[c]; + if (c != _POSIX_VDISABLE) { + wr.fd = args->fd; + wr.buf = &c; + wr.nbyte = sizeof(c); + return (write(p, &wr)); + } else + return (0); + } + default: + return (EINVAL); + } + args->arg = 0; + return (ioctl(p, (struct ioctl_args *)args)); + } + + case LINUX_TCFLSH: { + args->cmd = TIOCFLUSH; + switch (args->arg) { + case LINUX_TCIFLUSH: + args->arg = FREAD; + break; + case LINUX_TCOFLUSH: + args->arg = FWRITE; + break; + case LINUX_TCIOFLUSH: + args->arg = FREAD | FWRITE; + break; + default: + return (EINVAL); + } + return (ioctl(p, (struct ioctl_args *)args)); + } + + case LINUX_TIOCEXCL: + args->cmd = TIOCEXCL; + return (ioctl(p, (struct ioctl_args *)args)); + + case LINUX_TIOCNXCL: + args->cmd = TIOCNXCL; + return (ioctl(p, (struct ioctl_args *)args)); + + /* LINUX_TIOCSCTTY */ + + case LINUX_TIOCGPGRP: + args->cmd = TIOCGPGRP; + return (ioctl(p, (struct ioctl_args *)args)); + + case LINUX_TIOCSPGRP: + args->cmd = TIOCSPGRP; + return (ioctl(p, (struct ioctl_args *)args)); + + /* LINUX_TIOCOUTQ */ + /* LINUX_TIOCSTI */ + + case LINUX_TIOCGWINSZ: + args->cmd = TIOCGWINSZ; + return (ioctl(p, (struct ioctl_args *)args)); + + case LINUX_TIOCSWINSZ: + args->cmd = TIOCSWINSZ; + return (ioctl(p, (struct ioctl_args *)args)); + + case LINUX_TIOCMGET: + args->cmd = TIOCMGET; + return (ioctl(p, (struct ioctl_args *)args)); - tmios.c_iflag = linux_termio->c_iflag; - tmios.c_oflag = linux_termio->c_oflag; - tmios.c_cflag = linux_termio->c_cflag; - tmios.c_lflag = linux_termio->c_lflag; + case LINUX_TIOCMBIS: + args->cmd = TIOCMBIS; + return (ioctl(p, (struct ioctl_args *)args)); - for (i=LINUX_NCC; i<LINUX_NCCS; i++) - tmios.c_cc[i] = LINUX_POSIX_VDISABLE; - memcpy(tmios.c_cc, linux_termio->c_cc, LINUX_NCC); + case LINUX_TIOCMBIC: + args->cmd = TIOCMBIC; + return (ioctl(p, (struct ioctl_args *)args)); - linux_to_bsd_termios(&tmios, bsd_termios); + case LINUX_TIOCMSET: + args->cmd = TIOCMSET; + return (ioctl(p, (struct ioctl_args *)args)); + + /* TIOCGSOFTCAR */ + /* TIOCSSOFTCAR */ + + case LINUX_FIONREAD: /* LINUX_TIOCINQ */ + args->cmd = FIONREAD; + return (ioctl(p, (struct ioctl_args *)args)); + + /* LINUX_TIOCLINUX */ + + case LINUX_TIOCCONS: + args->cmd = TIOCCONS; + return (ioctl(p, (struct ioctl_args *)args)); + + case LINUX_TIOCGSERIAL: { + struct linux_serial_struct lss; + lss.type = LINUX_PORT_16550A; + lss.flags = 0; + lss.close_delay = 0; + return copyout(&lss, (caddr_t)args->arg, sizeof(lss)); + } + + case LINUX_TIOCSSERIAL: { + struct linux_serial_struct lss; + error = copyin((caddr_t)args->arg, &lss, sizeof(lss)); + if (error) + return (error); + /* XXX - It really helps to have an implementation that + * does nothing. NOT! + */ + return (0); + } + + /* LINUX_TIOCPKT */ + + case LINUX_FIONBIO: + args->cmd = FIONBIO; + return (ioctl(p, (struct ioctl_args *)args)); + + case LINUX_TIOCNOTTY: + args->cmd = TIOCNOTTY; + return (ioctl(p, (struct ioctl_args *)args)); + + case LINUX_TIOCSETD: { + int line; + switch (args->arg) { + case LINUX_N_TTY: + line = TTYDISC; + break; + case LINUX_N_SLIP: + line = SLIPDISC; + break; + case LINUX_N_PPP: + line = PPPDISC; + break; + default: + return (EINVAL); + } + return (fo_ioctl(fp, TIOCSETD, (caddr_t)&line, p)); + } + + case LINUX_TIOCGETD: { + int linux_line; + int bsd_line = TTYDISC; + error = fo_ioctl(fp, TIOCGETD, (caddr_t)&bsd_line, p); + if (error) + return (error); + switch (bsd_line) { + case TTYDISC: + linux_line = LINUX_N_TTY; + break; + case SLIPDISC: + linux_line = LINUX_N_SLIP; + break; + case PPPDISC: + linux_line = LINUX_N_PPP; + break; + default: + return (EINVAL); + } + return (copyout(&linux_line, (caddr_t)args->arg, sizeof(int))); + } + + /* LINUX_TCSBRKP */ + /* LINUX_TIOCTTYGSTRUCT */ + + case LINUX_FIONCLEX: + args->cmd = FIONCLEX; + return (ioctl(p, (struct ioctl_args *)args)); + + case LINUX_FIOCLEX: + args->cmd = FIOCLEX; + return (ioctl(p, (struct ioctl_args *)args)); + + case LINUX_FIOASYNC: + args->cmd = FIOASYNC; + return (ioctl(p, (struct ioctl_args *)args)); + + /* LINUX_TIOCSERCONFIG */ + /* LINUX_TIOCSERGWILD */ + /* LINUX_TIOCSERSWILD */ + /* LINUX_TIOCGLCKTRMIOS */ + /* LINUX_TIOCSLCKTRMIOS */ + + } + + return (ENOIOCTL); } +/* + * CDROM related ioctls + */ + struct linux_cdrom_msf { - u_char cdmsf_min0; - u_char cdmsf_sec0; - u_char cdmsf_frame0; - u_char cdmsf_min1; - u_char cdmsf_sec1; - u_char cdmsf_frame1; + u_char cdmsf_min0; + u_char cdmsf_sec0; + u_char cdmsf_frame0; + u_char cdmsf_min1; + u_char cdmsf_sec1; + u_char cdmsf_frame1; }; struct linux_cdrom_tochdr { - u_char cdth_trk0; - u_char cdth_trk1; + u_char cdth_trk0; + u_char cdth_trk1; }; union linux_cdrom_addr { - struct { - u_char minute; - u_char second; - u_char frame; - } msf; - int lba; + struct { + u_char minute; + u_char second; + u_char frame; + } msf; + int lba; }; struct linux_cdrom_tocentry { - u_char cdte_track; - u_char cdte_adr:4; - u_char cdte_ctrl:4; - u_char cdte_format; - union linux_cdrom_addr cdte_addr; - u_char cdte_datamode; + u_char cdte_track; + u_char cdte_adr:4; + u_char cdte_ctrl:4; + u_char cdte_format; + union linux_cdrom_addr cdte_addr; + u_char cdte_datamode; }; struct linux_cdrom_subchnl { - u_char cdsc_format; - u_char cdsc_audiostatus; - u_char cdsc_adr:4; - u_char cdsc_ctrl:4; - u_char cdsc_trk; - u_char cdsc_ind; - union linux_cdrom_addr cdsc_absaddr; - union linux_cdrom_addr cdsc_reladdr; + u_char cdsc_format; + u_char cdsc_audiostatus; + u_char cdsc_adr:4; + u_char cdsc_ctrl:4; + u_char cdsc_trk; + u_char cdsc_ind; + union linux_cdrom_addr cdsc_absaddr; + union linux_cdrom_addr cdsc_reladdr; }; -#if 0 static void -linux_to_bsd_msf_lba(u_char address_format, - union linux_cdrom_addr *lp, union msf_lba *bp) +bsd_to_linux_msf_lba(u_char af, union msf_lba *bp, union linux_cdrom_addr *lp) { - if (address_format == CD_LBA_FORMAT) - bp->lba = lp->lba; - else { - bp->msf.minute = lp->msf.minute; - bp->msf.second = lp->msf.second; - bp->msf.frame = lp->msf.frame; - } + if (af == CD_LBA_FORMAT) + lp->lba = bp->lba; + else { + lp->msf.minute = bp->msf.minute; + lp->msf.second = bp->msf.second; + lp->msf.frame = bp->msf.frame; + } } -#endif static void -bsd_to_linux_msf_lba(u_char address_format, - union msf_lba *bp, union linux_cdrom_addr *lp) +set_linux_cdrom_addr(union linux_cdrom_addr *addr, int format, int lba) { - if (address_format == CD_LBA_FORMAT) - lp->lba = bp->lba; - else { - lp->msf.minute = bp->msf.minute; - lp->msf.second = bp->msf.second; - lp->msf.frame = bp->msf.frame; - } + if (format == LINUX_CDROM_MSF) { + addr->msf.frame = lba % 75; + lba /= 75; + lba += 2; + addr->msf.second = lba % 60; + addr->msf.minute = lba / 60; + } else + addr->lba = lba; } -static void -set_linux_cdrom_addr(union linux_cdrom_addr *addr, int format, int lba) +static int +linux_ioctl_cdrom(struct proc *p, struct linux_ioctl_args *args) { - if (format == LINUX_CDROM_MSF) { - addr->msf.frame = lba % 75; - lba /= 75; - lba += 2; - addr->msf.second = lba % 60; - addr->msf.minute = lba / 60; - } - else - addr->lba = lba; + struct file *fp = p->p_fd->fd_ofiles[args->fd]; + int error; + + switch (args->cmd & 0xffff) { + + case LINUX_CDROMPAUSE: + args->cmd = CDIOCPAUSE; + return (ioctl(p, (struct ioctl_args *)args)); + + case LINUX_CDROMRESUME: + args->cmd = CDIOCRESUME; + return (ioctl(p, (struct ioctl_args *)args)); + + case LINUX_CDROMPLAYMSF: + args->cmd = CDIOCPLAYMSF; + return (ioctl(p, (struct ioctl_args *)args)); + + case LINUX_CDROMPLAYTRKIND: + args->cmd = CDIOCPLAYTRACKS; + return (ioctl(p, (struct ioctl_args *)args)); + + case LINUX_CDROMREADTOCHDR: { + struct ioc_toc_header th; + struct linux_cdrom_tochdr lth; + error = fo_ioctl(fp, CDIOREADTOCHEADER, (caddr_t)&th, p); + if (!error) { + lth.cdth_trk0 = th.starting_track; + lth.cdth_trk1 = th.ending_track; + copyout(<h, (caddr_t)args->arg, sizeof(lth)); + } + return (error); + } + + case LINUX_CDROMREADTOCENTRY: { + struct linux_cdrom_tocentry lte, *ltep = + (struct linux_cdrom_tocentry *)args->arg; + struct ioc_read_toc_single_entry irtse; + irtse.address_format = ltep->cdte_format; + irtse.track = ltep->cdte_track; + error = fo_ioctl(fp, CDIOREADTOCENTRY, (caddr_t)&irtse, p); + if (!error) { + lte = *ltep; + lte.cdte_ctrl = irtse.entry.control; + lte.cdte_adr = irtse.entry.addr_type; + bsd_to_linux_msf_lba(irtse.address_format, + &irtse.entry.addr, <e.cdte_addr); + copyout(<e, (caddr_t)args->arg, sizeof(lte)); + } + return (error); + } + + case LINUX_CDROMSTOP: + args->cmd = CDIOCSTOP; + return (ioctl(p, (struct ioctl_args *)args)); + + case LINUX_CDROMSTART: + args->cmd = CDIOCSTART; + return (ioctl(p, (struct ioctl_args *)args)); + + case LINUX_CDROMEJECT: + args->cmd = CDIOCEJECT; + return (ioctl(p, (struct ioctl_args *)args)); + + /* LINUX_CDROMVOLCTRL */ + + case LINUX_CDROMSUBCHNL: { + struct linux_cdrom_subchnl sc; + struct ioc_read_subchannel bsdsc; + struct cd_sub_channel_info *bsdinfo; + caddr_t sg = stackgap_init(); + bsdinfo = (struct cd_sub_channel_info*)stackgap_alloc(&sg, + sizeof(struct cd_sub_channel_info)); + bsdsc.address_format = CD_LBA_FORMAT; + bsdsc.data_format = CD_CURRENT_POSITION; + bsdsc.data_len = sizeof(struct cd_sub_channel_info); + bsdsc.data = bsdinfo; + error = fo_ioctl(fp, CDIOCREADSUBCHANNEL, (caddr_t)&bsdsc, p); + if (error) + return (error); + error = copyin((caddr_t)args->arg, &sc, + sizeof(struct linux_cdrom_subchnl)); + if (error) + return (error); + sc.cdsc_audiostatus = bsdinfo->header.audio_status; + sc.cdsc_adr = bsdinfo->what.position.addr_type; + sc.cdsc_ctrl = bsdinfo->what.position.control; + sc.cdsc_trk = bsdinfo->what.position.track_number; + sc.cdsc_ind = bsdinfo->what.position.index_number; + set_linux_cdrom_addr(&sc.cdsc_absaddr, sc.cdsc_format, + bsdinfo->what.position.absaddr.lba); + set_linux_cdrom_addr(&sc.cdsc_reladdr, sc.cdsc_format, + bsdinfo->what.position.reladdr.lba); + error = copyout(&sc, (caddr_t)args->arg, + sizeof(struct linux_cdrom_subchnl)); + return (error); + } + + /* LINUX_CDROMREADMODE2 */ + /* LINUX_CDROMREADMODE1 */ + /* LINUX_CDROMREADAUDIO */ + /* LINUX_CDROMEJECT_SW */ + /* LINUX_CDROMMULTISESSION */ + /* LINUX_CDROM_GET_UPC */ + + case LINUX_CDROMRESET: + args->cmd = CDIOCRESET; + return (ioctl(p, (struct ioctl_args *)args)); + + /* LINUX_CDROMVOLREAD */ + /* LINUX_CDROMREADRAW */ + /* LINUX_CDROMREADCOOKED */ + /* LINUX_CDROMSEEK */ + /* LINUX_CDROMPLAYBLK */ + /* LINUX_CDROMREADALL */ + /* LINUX_CDROMCLOSETRAY */ + /* LINUX_CDROMLOADFROMSLOT */ + + } + + return (ENOIOCTL); } +/* + * Sound related ioctls + */ + static unsigned dirbits[4] = { IOC_VOID, IOC_IN, IOC_OUT, IOC_INOUT }; -#define SETDIR(c) (((c) & ~IOC_DIRMASK) | dirbits[args->cmd >> 30]) +#define SETDIR(c) (((c) & ~IOC_DIRMASK) | dirbits[args->cmd >> 30]) -int -linux_ioctl(struct proc *p, struct linux_ioctl_args *args) +static int +linux_ioctl_sound(struct proc *p, struct linux_ioctl_args *args) { - struct termios bsd_termios; - struct linux_termios linux_termios; - struct linux_termio linux_termio; - struct filedesc *fdp = p->p_fd; - struct file *fp; - int bsd_line, linux_line; - int error; -#ifdef DEBUG - printf("Linux-emul(%ld): ioctl(%d, %04lx, *)\n", - (long)p->p_pid, args->fd, args->cmd); -#endif - if ((unsigned)args->fd >= fdp->fd_nfiles - || (fp = fdp->fd_ofiles[args->fd]) == 0) - return EBADF; - - if (!fp || (fp->f_flag & (FREAD | FWRITE)) == 0) { - return EBADF; - } - - switch (args->cmd & 0xffff) { - - case LINUX_TCGETA: - if ((error = fo_ioctl(fp, TIOCGETA, (caddr_t)&bsd_termios, p)) != 0) - return error; - bsd_to_linux_termio(&bsd_termios, &linux_termio); - return copyout((caddr_t)&linux_termio, (caddr_t)args->arg, - sizeof(linux_termio)); - - case LINUX_TCSETA: - error = copyin((caddr_t)args->arg, &linux_termio, sizeof(linux_termio)); - if (error) - return error; - linux_to_bsd_termio(&linux_termio, &bsd_termios); - return fo_ioctl(fp, TIOCSETA, (caddr_t)&bsd_termios, p); - - case LINUX_TCSETAW: - error = copyin((caddr_t)args->arg, &linux_termio, sizeof(linux_termio)); - if (error) - return error; - linux_to_bsd_termio(&linux_termio, &bsd_termios); - return fo_ioctl(fp, TIOCSETAW, (caddr_t)&bsd_termios, p); - - case LINUX_TCSETAF: - error = copyin((caddr_t)args->arg, &linux_termio, sizeof(linux_termio)); - if (error) - return error; - linux_to_bsd_termio(&linux_termio, &bsd_termios); - return fo_ioctl(fp, TIOCSETAF, (caddr_t)&bsd_termios, p); - - case LINUX_TCGETS: - if ((error = fo_ioctl(fp, TIOCGETA, (caddr_t)&bsd_termios, p)) != 0) - return error; - bsd_to_linux_termios(&bsd_termios, &linux_termios); - return copyout((caddr_t)&linux_termios, (caddr_t)args->arg, - sizeof(linux_termios)); - - case LINUX_TCSETS: - error = copyin((caddr_t)args->arg, &linux_termios, - sizeof(linux_termios)); - if (error) - return error; - linux_to_bsd_termios(&linux_termios, &bsd_termios); - return fo_ioctl(fp, TIOCSETA, (caddr_t)&bsd_termios, p); - - case LINUX_TCSETSW: - error = copyin((caddr_t)args->arg, &linux_termios, - sizeof(linux_termios)); - if (error) - return error; - linux_to_bsd_termios(&linux_termios, &bsd_termios); - return fo_ioctl(fp, TIOCSETAW, (caddr_t)&bsd_termios, p); - - case LINUX_TCSETSF: - error = copyin((caddr_t)args->arg, &linux_termios, - sizeof(linux_termios)); - if (error) - return error; - linux_to_bsd_termios(&linux_termios, &bsd_termios); - return fo_ioctl(fp, TIOCSETAF, (caddr_t)&bsd_termios, p); - - case LINUX_TIOCGPGRP: - args->cmd = TIOCGPGRP; - return ioctl(p, (struct ioctl_args *)args); - - case LINUX_TIOCSPGRP: - args->cmd = TIOCSPGRP; - return ioctl(p, (struct ioctl_args *)args); - - case LINUX_TIOCGWINSZ: - args->cmd = TIOCGWINSZ; - return ioctl(p, (struct ioctl_args *)args); - - case LINUX_TIOCSWINSZ: - args->cmd = TIOCSWINSZ; - return ioctl(p, (struct ioctl_args *)args); - - case LINUX_TIOCMGET: - args->cmd = TIOCMGET; - return ioctl(p, (struct ioctl_args *)args); - - case LINUX_TIOCMBIS: - args->cmd = TIOCMBIS; - return ioctl(p, (struct ioctl_args *)args); - - case LINUX_TIOCMBIC: - args->cmd = TIOCMBIC; - return ioctl(p, (struct ioctl_args *)args); - - case LINUX_TIOCMSET: - args->cmd = TIOCMSET; - return ioctl(p, (struct ioctl_args *)args); - - case LINUX_FIONREAD: - args->cmd = FIONREAD; - return ioctl(p, (struct ioctl_args *)args); - - case LINUX_FIONBIO: - args->cmd = FIONBIO; - return ioctl(p, (struct ioctl_args *)args); - - case LINUX_FIOASYNC: - args->cmd = FIOASYNC; - return ioctl(p, (struct ioctl_args *)args); - - case LINUX_FIONCLEX: - args->cmd = FIONCLEX; - return ioctl(p, (struct ioctl_args *)args); - - case LINUX_FIOCLEX: - args->cmd = FIOCLEX; - return ioctl(p, (struct ioctl_args *)args); - - case LINUX_TIOCEXCL: - args->cmd = TIOCEXCL; - return ioctl(p, (struct ioctl_args *)args); - - case LINUX_TIOCNXCL: - args->cmd = TIOCNXCL; - return ioctl(p, (struct ioctl_args *)args); - - case LINUX_TIOCCONS: - args->cmd = TIOCCONS; - return ioctl(p, (struct ioctl_args *)args); - - case LINUX_TIOCNOTTY: - args->cmd = TIOCNOTTY; - return ioctl(p, (struct ioctl_args *)args); - - case LINUX_SIOCGIFCONF: - args->cmd = OSIOCGIFCONF; - return ioctl(p, (struct ioctl_args *)args); - - case LINUX_SIOCGIFFLAGS: - args->cmd = SIOCGIFFLAGS; - return ioctl(p, (struct ioctl_args *)args); - - case LINUX_SIOCGIFADDR: - args->cmd = OSIOCGIFADDR; - return ioctl(p, (struct ioctl_args *)args); - - case LINUX_SIOCGIFDSTADDR: - args->cmd = OSIOCGIFDSTADDR; - return ioctl(p, (struct ioctl_args *)args); - - case LINUX_SIOCGIFBRDADDR: - args->cmd = OSIOCGIFBRDADDR; - return ioctl(p, (struct ioctl_args *)args); - - case LINUX_SIOCGIFNETMASK: - args->cmd = OSIOCGIFNETMASK; - return ioctl(p, (struct ioctl_args *)args); - - /* get hardware address */ - case LINUX_SIOCGIFHWADDR: - { - int ifn; - struct ifnet *ifp; - struct ifaddr *ifa; - struct sockaddr_dl *sdl; - struct linux_ifreq *ifr = (struct linux_ifreq *)args->arg; - - /* - * Note that we don't actually respect the name in the ifreq structure, as - * Linux interface names are all different - */ + switch (args->cmd & 0xffff) { - for (ifn = 0; ifn < if_index; ifn++) { + case LINUX_SOUND_MIXER_WRITE_VOLUME: + args->cmd = SETDIR(SOUND_MIXER_WRITE_VOLUME); + return (ioctl(p, (struct ioctl_args *)args)); - ifp = ifnet_addrs[ifn]->ifa_ifp; /* pointer to interface */ - if (ifp->if_type == IFT_ETHER) { /* looks good */ - /* walk the address list */ - for (ifa = TAILQ_FIRST(&ifp->if_addrhead); ifa; ifa = TAILQ_NEXT(ifa, ifa_link)) { - if ((sdl = (struct sockaddr_dl *)ifa->ifa_addr) && /* we have an address structure */ - (sdl->sdl_family == AF_LINK) && /* it's a link address */ - (sdl->sdl_type == IFT_ETHER)) { /* for an ethernet link */ + case LINUX_SOUND_MIXER_WRITE_BASS: + args->cmd = SETDIR(SOUND_MIXER_WRITE_BASS); + return (ioctl(p, (struct ioctl_args *)args)); - return(copyout(LLADDR(sdl), (caddr_t)&ifr->ifr_hwaddr.sa_data, LINUX_IFHWADDRLEN)); - } - } - } - } - return(ENOENT); /* ??? */ - } - - case LINUX_SIOCADDMULTI: - args->cmd = SIOCADDMULTI; - return ioctl(p, (struct ioctl_args *)args); - - case LINUX_SIOCDELMULTI: - args->cmd = SIOCDELMULTI; - return ioctl(p, (struct ioctl_args *)args); - - case LINUX_FIOSETOWN: - args->cmd = FIOSETOWN; - return ioctl(p, (struct ioctl_args *)args); - - case LINUX_SIOCSPGRP: - args->cmd = SIOCSPGRP; - return ioctl(p, (struct ioctl_args *)args); - - case LINUX_FIOGETOWN: - args->cmd = FIOGETOWN; - return ioctl(p, (struct ioctl_args *)args); - - case LINUX_SIOCGPGRP: - args->cmd = SIOCGPGRP; - return ioctl(p, (struct ioctl_args *)args); - - case LINUX_SIOCATMARK: - args->cmd = SIOCATMARK; - return ioctl(p, (struct ioctl_args *)args); - - case LINUX_TIOCSETD: - switch (args->arg) { - case LINUX_N_TTY: - bsd_line = TTYDISC; - return fo_ioctl(fp, TIOCSETD, (caddr_t)&bsd_line, p); - case LINUX_N_SLIP: - bsd_line = SLIPDISC; - return fo_ioctl(fp, TIOCSETD, (caddr_t)&bsd_line, p); - case LINUX_N_PPP: - bsd_line = PPPDISC; - return fo_ioctl(fp, TIOCSETD, (caddr_t)&bsd_line, p); - default: - return EINVAL; - } + case LINUX_SOUND_MIXER_WRITE_TREBLE: + args->cmd = SETDIR(SOUND_MIXER_WRITE_TREBLE); + return (ioctl(p, (struct ioctl_args *)args)); + + case LINUX_SOUND_MIXER_WRITE_SYNTH: + args->cmd = SETDIR(SOUND_MIXER_WRITE_SYNTH); + return (ioctl(p, (struct ioctl_args *)args)); + + case LINUX_SOUND_MIXER_WRITE_PCM: + args->cmd = SETDIR(SOUND_MIXER_WRITE_PCM); + return (ioctl(p, (struct ioctl_args *)args)); + + case LINUX_SOUND_MIXER_WRITE_SPEAKER: + args->cmd = SETDIR(SOUND_MIXER_WRITE_SPEAKER); + return (ioctl(p, (struct ioctl_args *)args)); + + case LINUX_SOUND_MIXER_WRITE_LINE: + args->cmd = SETDIR(SOUND_MIXER_WRITE_LINE); + return (ioctl(p, (struct ioctl_args *)args)); + + case LINUX_SOUND_MIXER_WRITE_MIC: + args->cmd = SETDIR(SOUND_MIXER_WRITE_MIC); + return (ioctl(p, (struct ioctl_args *)args)); - case LINUX_TIOCGETD: - bsd_line = TTYDISC; - error = fo_ioctl(fp, TIOCGETD, (caddr_t)&bsd_line, p); - if (error) - return error; - switch (bsd_line) { - case TTYDISC: - linux_line = LINUX_N_TTY; - break; - case SLIPDISC: - linux_line = LINUX_N_SLIP; - break; - case PPPDISC: - linux_line = LINUX_N_PPP; - break; - default: - return EINVAL; + case LINUX_SOUND_MIXER_WRITE_CD: + args->cmd = SETDIR(SOUND_MIXER_WRITE_CD); + return (ioctl(p, (struct ioctl_args *)args)); + + case LINUX_SOUND_MIXER_WRITE_IMIX: + args->cmd = SETDIR(SOUND_MIXER_WRITE_IMIX); + return (ioctl(p, (struct ioctl_args *)args)); + + case LINUX_SOUND_MIXER_WRITE_ALTPCM: + args->cmd = SETDIR(SOUND_MIXER_WRITE_ALTPCM); + return (ioctl(p, (struct ioctl_args *)args)); + + case LINUX_SOUND_MIXER_WRITE_RECLEV: + args->cmd = SETDIR(SOUND_MIXER_WRITE_RECLEV); + return (ioctl(p, (struct ioctl_args *)args)); + + case LINUX_SOUND_MIXER_WRITE_IGAIN: + args->cmd = SETDIR(SOUND_MIXER_WRITE_IGAIN); + return (ioctl(p, (struct ioctl_args *)args)); + + case LINUX_SOUND_MIXER_WRITE_OGAIN: + args->cmd = SETDIR(SOUND_MIXER_WRITE_OGAIN); + return (ioctl(p, (struct ioctl_args *)args)); + + case LINUX_SOUND_MIXER_WRITE_LINE1: + args->cmd = SETDIR(SOUND_MIXER_WRITE_LINE1); + return (ioctl(p, (struct ioctl_args *)args)); + + case LINUX_SOUND_MIXER_WRITE_LINE2: + args->cmd = SETDIR(SOUND_MIXER_WRITE_LINE2); + return (ioctl(p, (struct ioctl_args *)args)); + + case LINUX_SOUND_MIXER_WRITE_LINE3: + args->cmd = SETDIR(SOUND_MIXER_WRITE_LINE3); + return (ioctl(p, (struct ioctl_args *)args)); + + case LINUX_OSS_GETVERSION: { + int version = linux_get_oss_version(p); + return (copyout(&version, (caddr_t)args->arg, sizeof(int))); } - return copyout(&linux_line, (caddr_t)args->arg, - sizeof(int)); - case LINUX_SNDCTL_SEQ_RESET: - args->cmd = SNDCTL_SEQ_RESET; - return ioctl(p, (struct ioctl_args *)args); + case LINUX_SOUND_MIXER_READ_DEVMASK: + args->cmd = SOUND_MIXER_READ_DEVMASK; + return (ioctl(p, (struct ioctl_args *)args)); - case LINUX_SNDCTL_SEQ_SYNC: - args->cmd = SNDCTL_SEQ_SYNC; - return ioctl(p, (struct ioctl_args *)args); + case LINUX_SNDCTL_DSP_RESET: + args->cmd = SNDCTL_DSP_RESET; + return (ioctl(p, (struct ioctl_args *)args)); - case LINUX_SNDCTL_SYNTH_INFO: - args->cmd = SNDCTL_SYNTH_INFO; - return ioctl(p, (struct ioctl_args *)args); + case LINUX_SNDCTL_DSP_SYNC: + args->cmd = SNDCTL_DSP_SYNC; + return (ioctl(p, (struct ioctl_args *)args)); - case LINUX_SNDCTL_SEQ_CTRLRATE: - args->cmd = SNDCTL_SEQ_CTRLRATE; - return ioctl(p, (struct ioctl_args *)args); + case LINUX_SNDCTL_DSP_SPEED: + args->cmd = SNDCTL_DSP_SPEED; + return (ioctl(p, (struct ioctl_args *)args)); - case LINUX_SNDCTL_SEQ_GETOUTCOUNT: - args->cmd = SNDCTL_SEQ_GETOUTCOUNT; - return ioctl(p, (struct ioctl_args *)args); + case LINUX_SNDCTL_DSP_STEREO: + args->cmd = SNDCTL_DSP_STEREO; + return (ioctl(p, (struct ioctl_args *)args)); - case LINUX_SNDCTL_SEQ_GETINCOUNT: - args->cmd = SNDCTL_SEQ_GETINCOUNT; - return ioctl(p, (struct ioctl_args *)args); + case LINUX_SNDCTL_DSP_GETBLKSIZE: /* LINUX_SNDCTL_DSP_SETBLKSIZE */ + args->cmd = SNDCTL_DSP_GETBLKSIZE; + return (ioctl(p, (struct ioctl_args *)args)); - case LINUX_SNDCTL_SEQ_PERCMODE: - args->cmd = SNDCTL_SEQ_PERCMODE; - return ioctl(p, (struct ioctl_args *)args); + case LINUX_SNDCTL_DSP_SETFMT: + args->cmd = SNDCTL_DSP_SETFMT; + return (ioctl(p, (struct ioctl_args *)args)); - case LINUX_SNDCTL_FM_LOAD_INSTR: - args->cmd = SNDCTL_FM_LOAD_INSTR; - return ioctl(p, (struct ioctl_args *)args); + case LINUX_SOUND_PCM_WRITE_CHANNELS: + args->cmd = SOUND_PCM_WRITE_CHANNELS; + return (ioctl(p, (struct ioctl_args *)args)); - case LINUX_SNDCTL_SEQ_TESTMIDI: - args->cmd = SNDCTL_SEQ_TESTMIDI; - return ioctl(p, (struct ioctl_args *)args); + case LINUX_SOUND_PCM_WRITE_FILTER: + args->cmd = SOUND_PCM_WRITE_FILTER; + return (ioctl(p, (struct ioctl_args *)args)); - case LINUX_SNDCTL_SEQ_RESETSAMPLES: - args->cmd = SNDCTL_SEQ_RESETSAMPLES; - return ioctl(p, (struct ioctl_args *)args); + case LINUX_SNDCTL_DSP_POST: + args->cmd = SNDCTL_DSP_POST; + return (ioctl(p, (struct ioctl_args *)args)); - case LINUX_SNDCTL_SEQ_NRSYNTHS: - args->cmd = SNDCTL_SEQ_NRSYNTHS; - return ioctl(p, (struct ioctl_args *)args); + case LINUX_SNDCTL_DSP_SUBDIVIDE: + args->cmd = SNDCTL_DSP_SUBDIVIDE; + return (ioctl(p, (struct ioctl_args *)args)); - case LINUX_SNDCTL_SEQ_NRMIDIS: - args->cmd = SNDCTL_SEQ_NRMIDIS; - return ioctl(p, (struct ioctl_args *)args); + case LINUX_SNDCTL_DSP_SETFRAGMENT: + args->cmd = SNDCTL_DSP_SETFRAGMENT; + return (ioctl(p, (struct ioctl_args *)args)); - case LINUX_SNDCTL_MIDI_INFO: - args->cmd = SNDCTL_MIDI_INFO; - return ioctl(p, (struct ioctl_args *)args); + case LINUX_SNDCTL_DSP_GETFMTS: + args->cmd = SNDCTL_DSP_GETFMTS; + return (ioctl(p, (struct ioctl_args *)args)); - case LINUX_SNDCTL_SEQ_TRESHOLD: - args->cmd = SNDCTL_SEQ_TRESHOLD; - return ioctl(p, (struct ioctl_args *)args); + case LINUX_SNDCTL_DSP_GETOSPACE: + args->cmd = SNDCTL_DSP_GETOSPACE; + return (ioctl(p, (struct ioctl_args *)args)); - case LINUX_SNDCTL_SYNTH_MEMAVL: - args->cmd = SNDCTL_SYNTH_MEMAVL; - return ioctl(p, (struct ioctl_args *)args); + case LINUX_SNDCTL_DSP_GETISPACE: + args->cmd = SNDCTL_DSP_GETISPACE; + return (ioctl(p, (struct ioctl_args *)args)); - case LINUX_SNDCTL_DSP_GETOPTR : - args->cmd = SNDCTL_DSP_GETOPTR; - return ioctl(p, (struct ioctl_args *)args); + case LINUX_SNDCTL_DSP_NONBLOCK: + args->cmd = SNDCTL_DSP_NONBLOCK; + return (ioctl(p, (struct ioctl_args *)args)); - case LINUX_SNDCTL_DSP_GETIPTR : - args->cmd = SNDCTL_DSP_GETIPTR; - return ioctl(p, (struct ioctl_args *)args); + case LINUX_SNDCTL_DSP_GETCAPS: + args->cmd = SNDCTL_DSP_GETCAPS; + return (ioctl(p, (struct ioctl_args *)args)); - case LINUX_SNDCTL_DSP_SETTRIGGER: - args->cmd = SNDCTL_DSP_SETTRIGGER; - return ioctl(p, (struct ioctl_args *)args); + case LINUX_SNDCTL_DSP_SETTRIGGER: /* LINUX_SNDCTL_GETTRIGGER */ + args->cmd = SNDCTL_DSP_SETTRIGGER; + return (ioctl(p, (struct ioctl_args *)args)); - case LINUX_SNDCTL_DSP_GETCAPS: - args->cmd = SNDCTL_DSP_GETCAPS; - return ioctl(p, (struct ioctl_args *)args); + case LINUX_SNDCTL_DSP_GETIPTR: + args->cmd = SNDCTL_DSP_GETIPTR; + return (ioctl(p, (struct ioctl_args *)args)); - case LINUX_SNDCTL_DSP_RESET: - args->cmd = SNDCTL_DSP_RESET; - return ioctl(p, (struct ioctl_args *)args); + case LINUX_SNDCTL_DSP_GETOPTR: + args->cmd = SNDCTL_DSP_GETOPTR; + return (ioctl(p, (struct ioctl_args *)args)); - case LINUX_SNDCTL_DSP_SYNC: - args->cmd = SNDCTL_DSP_SYNC; - return ioctl(p, (struct ioctl_args *)args); + case LINUX_SNDCTL_DSP_GETODELAY: + args->cmd = SNDCTL_DSP_GETODELAY; + return (ioctl(p, (struct ioctl_args *)args)); - case LINUX_SNDCTL_DSP_SPEED: - args->cmd = SNDCTL_DSP_SPEED; - return ioctl(p, (struct ioctl_args *)args); + case LINUX_SNDCTL_SEQ_RESET: + args->cmd = SNDCTL_SEQ_RESET; + return (ioctl(p, (struct ioctl_args *)args)); - case LINUX_SNDCTL_DSP_STEREO: - args->cmd = SNDCTL_DSP_STEREO; - return ioctl(p, (struct ioctl_args *)args); + case LINUX_SNDCTL_SEQ_SYNC: + args->cmd = SNDCTL_SEQ_SYNC; + return (ioctl(p, (struct ioctl_args *)args)); - case LINUX_SNDCTL_DSP_GETBLKSIZE: - /* LINUX_SNDCTL_DSP_SETBLKSIZE */ - args->cmd = SNDCTL_DSP_GETBLKSIZE; - return ioctl(p, (struct ioctl_args *)args); + case LINUX_SNDCTL_SYNTH_INFO: + args->cmd = SNDCTL_SYNTH_INFO; + return (ioctl(p, (struct ioctl_args *)args)); - case LINUX_SNDCTL_DSP_GETODELAY: - args->cmd = SNDCTL_DSP_GETODELAY; - return ioctl(p, (struct ioctl_args *)args); + case LINUX_SNDCTL_SEQ_CTRLRATE: + args->cmd = SNDCTL_SEQ_CTRLRATE; + return (ioctl(p, (struct ioctl_args *)args)); - case LINUX_SNDCTL_DSP_SETFMT: - args->cmd = SNDCTL_DSP_SETFMT; - return ioctl(p, (struct ioctl_args *)args); + case LINUX_SNDCTL_SEQ_GETOUTCOUNT: + args->cmd = SNDCTL_SEQ_GETOUTCOUNT; + return (ioctl(p, (struct ioctl_args *)args)); - case LINUX_SOUND_PCM_WRITE_CHANNELS: - args->cmd = SOUND_PCM_WRITE_CHANNELS; - return ioctl(p, (struct ioctl_args *)args); + case LINUX_SNDCTL_SEQ_GETINCOUNT: + args->cmd = SNDCTL_SEQ_GETINCOUNT; + return (ioctl(p, (struct ioctl_args *)args)); - case LINUX_SOUND_PCM_WRITE_FILTER: - args->cmd = SOUND_PCM_WRITE_FILTER; - return ioctl(p, (struct ioctl_args *)args); + case LINUX_SNDCTL_SEQ_PERCMODE: + args->cmd = SNDCTL_SEQ_PERCMODE; + return (ioctl(p, (struct ioctl_args *)args)); - case LINUX_SNDCTL_DSP_POST: - args->cmd = SNDCTL_DSP_POST; - return ioctl(p, (struct ioctl_args *)args); + case LINUX_SNDCTL_FM_LOAD_INSTR: + args->cmd = SNDCTL_FM_LOAD_INSTR; + return (ioctl(p, (struct ioctl_args *)args)); - case LINUX_SNDCTL_DSP_SUBDIVIDE: - args->cmd = SNDCTL_DSP_SUBDIVIDE; - return ioctl(p, (struct ioctl_args *)args); - - case LINUX_SNDCTL_DSP_SETFRAGMENT: - args->cmd = SNDCTL_DSP_SETFRAGMENT; - return ioctl(p, (struct ioctl_args *)args); + case LINUX_SNDCTL_SEQ_TESTMIDI: + args->cmd = SNDCTL_SEQ_TESTMIDI; + return (ioctl(p, (struct ioctl_args *)args)); - case LINUX_SNDCTL_DSP_GETFMTS: - args->cmd = SNDCTL_DSP_GETFMTS; - return ioctl(p, (struct ioctl_args *)args); - - case LINUX_SNDCTL_DSP_GETOSPACE: - args->cmd = SNDCTL_DSP_GETOSPACE; - return ioctl(p, (struct ioctl_args *)args); - - case LINUX_SNDCTL_DSP_GETISPACE: - args->cmd = SNDCTL_DSP_GETISPACE; - return ioctl(p, (struct ioctl_args *)args); - - case LINUX_SNDCTL_DSP_NONBLOCK: - args->cmd = SNDCTL_DSP_NONBLOCK; - return ioctl(p, (struct ioctl_args *)args); - - case LINUX_SOUND_MIXER_WRITE_VOLUME: - args->cmd = SETDIR(SOUND_MIXER_WRITE_VOLUME); - return ioctl(p, (struct ioctl_args *)args); - - case LINUX_SOUND_MIXER_WRITE_BASS: - args->cmd = SETDIR(SOUND_MIXER_WRITE_BASS); - return ioctl(p, (struct ioctl_args *)args); - - case LINUX_SOUND_MIXER_WRITE_TREBLE: - args->cmd = SETDIR(SOUND_MIXER_WRITE_TREBLE); - return ioctl(p, (struct ioctl_args *)args); - - case LINUX_SOUND_MIXER_WRITE_SYNTH: - args->cmd = SETDIR(SOUND_MIXER_WRITE_SYNTH); - return ioctl(p, (struct ioctl_args *)args); - - case LINUX_SOUND_MIXER_WRITE_PCM: - args->cmd = SETDIR(SOUND_MIXER_WRITE_PCM); - return ioctl(p, (struct ioctl_args *)args); - - case LINUX_SOUND_MIXER_WRITE_SPEAKER: - args->cmd = SETDIR(SOUND_MIXER_WRITE_SPEAKER); - return ioctl(p, (struct ioctl_args *)args); - - case LINUX_SOUND_MIXER_WRITE_LINE: - args->cmd = SETDIR(SOUND_MIXER_WRITE_LINE); - return ioctl(p, (struct ioctl_args *)args); - - case LINUX_SOUND_MIXER_WRITE_MIC: - args->cmd = SETDIR(SOUND_MIXER_WRITE_MIC); - return ioctl(p, (struct ioctl_args *)args); - - case LINUX_SOUND_MIXER_WRITE_CD: - args->cmd = SETDIR(SOUND_MIXER_WRITE_CD); - return ioctl(p, (struct ioctl_args *)args); - - case LINUX_SOUND_MIXER_WRITE_IMIX: - args->cmd = SETDIR(SOUND_MIXER_WRITE_IMIX); - return ioctl(p, (struct ioctl_args *)args); - - case LINUX_SOUND_MIXER_WRITE_ALTPCM: - args->cmd = SETDIR(SOUND_MIXER_WRITE_ALTPCM); - return ioctl(p, (struct ioctl_args *)args); - - case LINUX_SOUND_MIXER_WRITE_RECLEV: - args->cmd = SETDIR(SOUND_MIXER_WRITE_RECLEV); - return ioctl(p, (struct ioctl_args *)args); - - case LINUX_SOUND_MIXER_WRITE_IGAIN: - args->cmd = SETDIR(SOUND_MIXER_WRITE_IGAIN); - return ioctl(p, (struct ioctl_args *)args); - - case LINUX_SOUND_MIXER_WRITE_OGAIN: - args->cmd = SETDIR(SOUND_MIXER_WRITE_OGAIN); - return ioctl(p, (struct ioctl_args *)args); + case LINUX_SNDCTL_SEQ_RESETSAMPLES: + args->cmd = SNDCTL_SEQ_RESETSAMPLES; + return (ioctl(p, (struct ioctl_args *)args)); - case LINUX_SOUND_MIXER_WRITE_LINE1: - args->cmd = SETDIR(SOUND_MIXER_WRITE_LINE1); - return ioctl(p, (struct ioctl_args *)args); + case LINUX_SNDCTL_SEQ_NRSYNTHS: + args->cmd = SNDCTL_SEQ_NRSYNTHS; + return (ioctl(p, (struct ioctl_args *)args)); - case LINUX_SOUND_MIXER_WRITE_LINE2: - args->cmd = SETDIR(SOUND_MIXER_WRITE_LINE2); - return ioctl(p, (struct ioctl_args *)args); + case LINUX_SNDCTL_SEQ_NRMIDIS: + args->cmd = SNDCTL_SEQ_NRMIDIS; + return (ioctl(p, (struct ioctl_args *)args)); - case LINUX_SOUND_MIXER_WRITE_LINE3: - args->cmd = SETDIR(SOUND_MIXER_WRITE_LINE3); - return ioctl(p, (struct ioctl_args *)args); + case LINUX_SNDCTL_MIDI_INFO: + args->cmd = SNDCTL_MIDI_INFO; + return (ioctl(p, (struct ioctl_args *)args)); - case LINUX_SOUND_MIXER_READ_DEVMASK: - args->cmd = SOUND_MIXER_READ_DEVMASK; - return ioctl(p, (struct ioctl_args *)args); + case LINUX_SNDCTL_SEQ_TRESHOLD: + args->cmd = SNDCTL_SEQ_TRESHOLD; + return (ioctl(p, (struct ioctl_args *)args)); - case LINUX_TIOCGSERIAL: { - struct linux_serial_struct lss; + case LINUX_SNDCTL_SYNTH_MEMAVL: + args->cmd = SNDCTL_SYNTH_MEMAVL; + return (ioctl(p, (struct ioctl_args *)args)); - lss.type = LINUX_PORT_16550A; - lss.flags = 0; - lss.close_delay = 0; - return copyout((caddr_t)&lss, (caddr_t)args->arg, sizeof(lss)); - } + } - case LINUX_TIOCSSERIAL: { - struct linux_serial_struct lss; + return (ENOIOCTL); +} - error = copyin((caddr_t)args->arg, (caddr_t)&lss, sizeof(lss)); - if (error) - return error; - /* - * XXX - It really helps to have an implementation that does nothing. - * NOT! - */ - return 0; - } - - case LINUX_TCXONC: - switch (args->arg) { - case LINUX_TCOOFF: - args->cmd = TIOCSTOP; - break; - case LINUX_TCOON: - args->cmd = TIOCSTART; - break; - case LINUX_TCIOFF: - case LINUX_TCION: { - u_char c; - struct write_args wr; - error = fo_ioctl(fp, TIOCGETA, (caddr_t)&bsd_termios, p); - if (error != 0) - return error; - c = bsd_termios.c_cc[args->arg == LINUX_TCIOFF ? VSTOP : VSTART]; - if (c != _POSIX_VDISABLE) { - wr.fd = args->fd; - wr.buf = &c; - wr.nbyte = sizeof(c); - return write(p, &wr); - } - else - return (0); - } - default: - return EINVAL; - } - args->arg = 0; - return ioctl(p, (struct ioctl_args *)args); - - case LINUX_TCFLSH: - args->cmd = TIOCFLUSH; - switch (args->arg) { - case LINUX_TCIFLUSH: - args->arg = FREAD; - break; - case LINUX_TCOFLUSH: - args->arg = FWRITE; - break; - case LINUX_TCIOFLUSH: - args->arg = FREAD | FWRITE; - break; - default: - return EINVAL; - } - return ioctl(p, (struct ioctl_args *)args); - - case LINUX_VT_OPENQRY: - - args->cmd = VT_OPENQRY; - return ioctl(p, (struct ioctl_args *)args); - - case LINUX_VT_GETMODE: - - args->cmd = VT_GETMODE; - return ioctl(p, (struct ioctl_args *)args); - - case LINUX_VT_SETMODE: - { - struct vt_mode *mode; - args->cmd = VT_SETMODE; - mode = (struct vt_mode *)args->arg; - if (!ISSIGVALID(mode->frsig) && ISSIGVALID(mode->acqsig)) - mode->frsig = mode->acqsig; - return ioctl(p, (struct ioctl_args *)args); - } - - case LINUX_VT_GETSTATE: - - args->cmd = VT_GETACTIVE; - return ioctl(p, (struct ioctl_args *)args); - - case LINUX_VT_RELDISP: - - args->cmd = VT_RELDISP; - return ioctl(p, (struct ioctl_args *)args); - - case LINUX_VT_ACTIVATE: - - args->cmd = VT_ACTIVATE; - return ioctl(p, (struct ioctl_args *)args); - - case LINUX_VT_WAITACTIVE: - - args->cmd = VT_WAITACTIVE; - return ioctl(p, (struct ioctl_args *)args); - - case LINUX_KDGKBMODE: - - args->cmd = KDGKBMODE; - return ioctl(p, (struct ioctl_args *)args); - - case LINUX_KDSKBMODE: - { - int kbdmode; - switch (args->arg) { - case LINUX_KBD_RAW: - kbdmode = K_RAW; - return fo_ioctl(fp, KDSKBMODE, (caddr_t)&kbdmode, p); - case LINUX_KBD_XLATE: - kbdmode = K_XLATE; - return fo_ioctl(fp, KDSKBMODE , (caddr_t)&kbdmode, p); - case LINUX_KBD_MEDIUMRAW: - kbdmode = K_RAW; - return fo_ioctl(fp, KDSKBMODE , (caddr_t)&kbdmode, p); - default: - return EINVAL; +/* + * Console related ioctls + */ + +#define ISSIGVALID(sig) ((sig) > 0 && (sig) < NSIG) + +static int +linux_ioctl_console(struct proc *p, struct linux_ioctl_args *args) +{ + struct file *fp = p->p_fd->fd_ofiles[args->fd]; + + switch (args->cmd & 0xffff) { + + case LINUX_KIOCSOUND: + args->cmd = KIOCSOUND; + return (ioctl(p, (struct ioctl_args *)args)); + + case LINUX_KDMKTONE: + args->cmd = KDMKTONE; + return (ioctl(p, (struct ioctl_args *)args)); + + case LINUX_KDGETLED: + args->cmd = KDGETLED; + return (ioctl(p, (struct ioctl_args *)args)); + + case LINUX_KDSETLED: + args->cmd = KDSETLED; + return (ioctl(p, (struct ioctl_args *)args)); + + case LINUX_KDSETMODE: + args->cmd = KDSETMODE; + return (ioctl(p, (struct ioctl_args *)args)); + + case LINUX_KDGETMODE: + args->cmd = KDGETMODE; + return (ioctl(p, (struct ioctl_args *)args)); + + case LINUX_KDGKBMODE: + args->cmd = KDGKBMODE; + return (ioctl(p, (struct ioctl_args *)args)); + + case LINUX_KDSKBMODE: { + int kbdmode; + switch (args->arg) { + case LINUX_KBD_RAW: + kbdmode = K_RAW; + break; + case LINUX_KBD_XLATE: + kbdmode = K_XLATE; + break; + case LINUX_KBD_MEDIUMRAW: + kbdmode = K_RAW; + break; + default: + return (EINVAL); + } + return (fo_ioctl(fp, KDSKBMODE, (caddr_t)&kbdmode, p)); } - } - case LINUX_KDGETMODE: - args->cmd = KDGETMODE; - return ioctl(p, (struct ioctl_args *)args); + case LINUX_VT_OPENQRY: + args->cmd = VT_OPENQRY; + return (ioctl(p, (struct ioctl_args *)args)); + + case LINUX_VT_GETMODE: + args->cmd = VT_GETMODE; + return (ioctl(p, (struct ioctl_args *)args)); + + case LINUX_VT_SETMODE: { + struct vt_mode *mode; + args->cmd = VT_SETMODE; + mode = (struct vt_mode *)args->arg; + if (!ISSIGVALID(mode->frsig) && ISSIGVALID(mode->acqsig)) + mode->frsig = mode->acqsig; + return (ioctl(p, (struct ioctl_args *)args)); + } - case LINUX_KDSETMODE: - args->cmd = KDSETMODE; - return ioctl(p, (struct ioctl_args *)args); + case LINUX_VT_GETSTATE: + args->cmd = VT_GETACTIVE; + return (ioctl(p, (struct ioctl_args *)args)); - case LINUX_KDSETLED: - args->cmd = KDSETLED; - return ioctl(p, (struct ioctl_args *)args); + case LINUX_VT_RELDISP: + args->cmd = VT_RELDISP; + return (ioctl(p, (struct ioctl_args *)args)); - case LINUX_KDGETLED: - args->cmd = KDGETLED; - return ioctl(p, (struct ioctl_args *)args); + case LINUX_VT_ACTIVATE: + args->cmd = VT_ACTIVATE; + return (ioctl(p, (struct ioctl_args *)args)); - case LINUX_KIOCSOUND: - args->cmd = KIOCSOUND; - return ioctl(p, (struct ioctl_args *)args); + case LINUX_VT_WAITACTIVE: + args->cmd = VT_WAITACTIVE; + return (ioctl(p, (struct ioctl_args *)args)); - case LINUX_KDMKTONE: - args->cmd = KDMKTONE; - return ioctl(p, (struct ioctl_args *)args); + } + + return (ENOIOCTL); +} +/* + * Socket related ioctls + */ - case LINUX_CDROMPAUSE: - args->cmd = CDIOCPAUSE; - return ioctl(p, (struct ioctl_args *)args); +static int +linux_ioctl_socket(struct proc *p, struct linux_ioctl_args *args) +{ - case LINUX_CDROMRESUME: - args->cmd = CDIOCRESUME; - return ioctl(p, (struct ioctl_args *)args); + switch (args->cmd & 0xffff) { + + case LINUX_FIOSETOWN: + args->cmd = FIOSETOWN; + return (ioctl(p, (struct ioctl_args *)args)); + + case LINUX_SIOCSPGRP: + args->cmd = SIOCSPGRP; + return (ioctl(p, (struct ioctl_args *)args)); + + case LINUX_FIOGETOWN: + args->cmd = FIOGETOWN; + return (ioctl(p, (struct ioctl_args *)args)); + + case LINUX_SIOCGPGRP: + args->cmd = SIOCGPGRP; + return (ioctl(p, (struct ioctl_args *)args)); + + case LINUX_SIOCATMARK: + args->cmd = SIOCATMARK; + return (ioctl(p, (struct ioctl_args *)args)); + + /* LINUX_SIOCGSTAMP */ + + case LINUX_SIOCGIFCONF: + args->cmd = OSIOCGIFCONF; + return (ioctl(p, (struct ioctl_args *)args)); + + case LINUX_SIOCGIFFLAGS: + args->cmd = SIOCGIFFLAGS; + return (ioctl(p, (struct ioctl_args *)args)); + + case LINUX_SIOCGIFADDR: + args->cmd = OSIOCGIFADDR; + return (ioctl(p, (struct ioctl_args *)args)); + + case LINUX_SIOCGIFDSTADDR: + args->cmd = OSIOCGIFDSTADDR; + return (ioctl(p, (struct ioctl_args *)args)); + + case LINUX_SIOCGIFBRDADDR: + args->cmd = OSIOCGIFBRDADDR; + return (ioctl(p, (struct ioctl_args *)args)); + + case LINUX_SIOCGIFNETMASK: + args->cmd = OSIOCGIFNETMASK; + return (ioctl(p, (struct ioctl_args *)args)); + + case LINUX_SIOCGIFHWADDR: { + int ifn; + struct ifnet *ifp; + struct ifaddr *ifa; + struct sockaddr_dl *sdl; + struct linux_ifreq *ifr = (struct linux_ifreq *)args->arg; + + /* Note that we don't actually respect the name in the ifreq + * structure, as Linux interface names are all different. + */ + for (ifn = 0; ifn < if_index; ifn++) { + ifp = ifnet_addrs[ifn]->ifa_ifp; + if (ifp->if_type == IFT_ETHER) { + ifa = TAILQ_FIRST(&ifp->if_addrhead); + while (ifa) { + sdl=(struct sockaddr_dl*)ifa->ifa_addr; + if (sdl != NULL && + (sdl->sdl_family == AF_LINK) && + (sdl->sdl_type == IFT_ETHER)) { + return (copyout(LLADDR(sdl), + &ifr->ifr_hwaddr.sa_data, + LINUX_IFHWADDRLEN)); + } + ifa = TAILQ_NEXT(ifa, ifa_link); + } + } + } + return (ENOENT); + } - case LINUX_CDROMPLAYMSF: - args->cmd = CDIOCPLAYMSF; - return ioctl(p, (struct ioctl_args *)args); + case LINUX_SIOCADDMULTI: + args->cmd = SIOCADDMULTI; + return (ioctl(p, (struct ioctl_args *)args)); - case LINUX_CDROMPLAYTRKIND: - args->cmd = CDIOCPLAYTRACKS; - return ioctl(p, (struct ioctl_args *)args); + case LINUX_SIOCDELMULTI: + args->cmd = SIOCDELMULTI; + return (ioctl(p, (struct ioctl_args *)args)); - case LINUX_CDROMSTART: - args->cmd = CDIOCSTART; - return ioctl(p, (struct ioctl_args *)args); + } - case LINUX_CDROMSTOP: - args->cmd = CDIOCSTOP; - return ioctl(p, (struct ioctl_args *)args); + return (ENOIOCTL); +} - case LINUX_CDROMEJECT: - args->cmd = CDIOCEJECT; - return ioctl(p, (struct ioctl_args *)args); +/* + * main ioctl syscall function + */ - case LINUX_CDROMRESET: - args->cmd = CDIOCRESET; - return ioctl(p, (struct ioctl_args *)args); +int +linux_ioctl(struct proc *p, struct linux_ioctl_args *args) +{ + struct filedesc *fdp = p->p_fd; + struct file *fp; + struct handler_element *he; + int error, cmd; + +#ifdef DEBUG + printf("Linux-emul(%ld): ioctl(%d, %04lx, *)\n", (long)p->p_pid, + args->fd, args->cmd); +#endif + + if ((unsigned)args->fd >= fdp->fd_nfiles) + return (EBADF); + + fp = fdp->fd_ofiles[args->fd]; + if (fp == NULL || (fp->f_flag & (FREAD|FWRITE)) == 0) + return (EBADF); + + /* Iterate over the ioctl handlers */ + cmd = args->cmd & 0xffff; + TAILQ_FOREACH(he, &handlers, list) { + if (cmd >= he->low && cmd <= he->high) { + error = (*he->func)(p, args); + if (error != ENOIOCTL) + return (error); + } + } + + printf("linux: 'ioctl' fd=%d, cmd=%x ('%c',%d) not implemented\n", + args->fd, (int)(args->cmd & 0xffff), + (int)(args->cmd & 0xff00) >> 8, (int)(args->cmd & 0xff)); + + return (EINVAL); +} + +int +linux_ioctl_register_handler(struct linux_ioctl_handler *h) +{ + struct handler_element *he, *cur; + + if (h == NULL || h->func == NULL) + return (EINVAL); + + /* + * Reuse the element if the handler is already on the list, otherwise + * create a new element. + */ + TAILQ_FOREACH(he, &handlers, list) { + if (he->func == h->func) + break; + } + if (he == NULL) { + MALLOC(he, struct handler_element *, sizeof(*he), + M_LINUX, M_WAITOK); + he->func = h->func; + } else + TAILQ_REMOVE(&handlers, he, list); + + /* Initialize range information. */ + he->low = h->low; + he->high = h->high; + he->span = h->high - h->low + 1; + + /* Add the element to the list, sorted on span. */ + TAILQ_FOREACH(cur, &handlers, list) { + if (cur->span > he->span) { + TAILQ_INSERT_BEFORE(cur, he, list); + return (0); + } + } + TAILQ_INSERT_TAIL(&handlers, he, list); - case LINUX_CDROMREADTOCHDR: { - struct ioc_toc_header th; - struct linux_cdrom_tochdr lth; - error = fo_ioctl(fp, CDIOREADTOCHEADER, (caddr_t)&th, p); - if (!error) { - lth.cdth_trk0 = th.starting_track; - lth.cdth_trk1 = th.ending_track; - copyout((caddr_t)<h, (caddr_t)args->arg, sizeof(lth)); + return (0); +} + +int +linux_ioctl_unregister_handler(struct linux_ioctl_handler *h) +{ + struct handler_element *he; + + if (h == NULL || h->func == NULL) + return (EINVAL); + + TAILQ_FOREACH(he, &handlers, list) { + if (he->func == h->func) { + TAILQ_REMOVE(&handlers, he, list); + FREE(he, M_LINUX); + return (0); + } } - return error; - } - - case LINUX_CDROMREADTOCENTRY: { - struct linux_cdrom_tocentry lte, *ltep = - (struct linux_cdrom_tocentry *)args->arg; - struct ioc_read_toc_single_entry irtse; - irtse.address_format = ltep->cdte_format; - irtse.track = ltep->cdte_track; - error = fo_ioctl(fp, CDIOREADTOCENTRY, (caddr_t)&irtse, p); - if (!error) { - lte = *ltep; - lte.cdte_ctrl = irtse.entry.control; - lte.cdte_adr = irtse.entry.addr_type; - bsd_to_linux_msf_lba(irtse.address_format, - &irtse.entry.addr, <e.cdte_addr); - copyout((caddr_t)<e, (caddr_t)args->arg, sizeof(lte)); + + return (EINVAL); +} + +int +linux_ioctl_register_handlers(struct linker_set *s) +{ + int error, i; + + if (s == NULL) + return (EINVAL); + + for (i = 0; i < s->ls_length; i++) { + error = linux_ioctl_register_handler(s->ls_items[i]); + if (error) + return (error); } - return error; - } - - case LINUX_CDROMSUBCHNL: { - caddr_t sg; - struct linux_cdrom_subchnl sc; - struct ioc_read_subchannel bsdsc; - struct cd_sub_channel_info *bsdinfo; - - sg = stackgap_init(); - bsdinfo = (struct cd_sub_channel_info*)stackgap_alloc(&sg, - sizeof(struct cd_sub_channel_info)); - - bsdsc.address_format = CD_LBA_FORMAT; - bsdsc.data_format = CD_CURRENT_POSITION; - bsdsc.data_len = sizeof(struct cd_sub_channel_info); - bsdsc.data = bsdinfo; - error = fo_ioctl(fp, CDIOCREADSUBCHANNEL, (caddr_t)&bsdsc, p); - if (error) - return error; - - error = copyin((caddr_t)args->arg, (caddr_t)&sc, - sizeof(struct linux_cdrom_subchnl)); - if (error) - return error; - - sc.cdsc_audiostatus = bsdinfo->header.audio_status; - sc.cdsc_adr = bsdinfo->what.position.addr_type; - sc.cdsc_ctrl = bsdinfo->what.position.control; - sc.cdsc_trk = bsdinfo->what.position.track_number; - sc.cdsc_ind = bsdinfo->what.position.index_number; - set_linux_cdrom_addr(&sc.cdsc_absaddr, sc.cdsc_format, - bsdinfo->what.position.absaddr.lba); - set_linux_cdrom_addr(&sc.cdsc_reladdr, sc.cdsc_format, - bsdinfo->what.position.reladdr.lba); - error = copyout((caddr_t)&sc, (caddr_t)args->arg, - sizeof(struct linux_cdrom_subchnl)); - return error; - } - - case LINUX_OSS_GETVERSION: { - int version; - - version = linux_get_oss_version(p); - return copyout((caddr_t)&version, (caddr_t)args->arg, sizeof(int)); - } - - } - - uprintf("LINUX: 'ioctl' fd=%d, typ=0x%x(%c), num=0x%x not implemented\n", - args->fd, (u_int)((args->cmd & 0xffff00) >> 8), - (int)((args->cmd & 0xffff00) >> 8), (u_int)(args->cmd & 0xff)); - return EINVAL; + + return (0); +} + +int +linux_ioctl_unregister_handlers(struct linker_set *s) +{ + int error, i; + + if (s == NULL) + return (EINVAL); + + for (i = 0; i < s->ls_length; i++) { + error = linux_ioctl_unregister_handler(s->ls_items[i]); + if (error) + return (error); + } + + return (0); } diff --git a/sys/i386/linux/linux_ioctl.h b/sys/i386/linux/linux_ioctl.h new file mode 100644 index 0000000..fd637b4 --- /dev/null +++ b/sys/i386/linux/linux_ioctl.h @@ -0,0 +1,418 @@ +/*- + * Copyright (c) 1999 Marcel Moolenaar + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer + * in this position and unchanged. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software withough specific prior written permission + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#ifndef _LINUX_IOCTL_H_ +#define _LINUX_IOCTL_H_ + +/* + * cdrom + */ +#define LINUX_CDROMPAUSE 0x5301 +#define LINUX_CDROMRESUME 0x5302 +#define LINUX_CDROMPLAYMSF 0x5303 +#define LINUX_CDROMPLAYTRKIND 0x5304 +#define LINUX_CDROMREADTOCHDR 0x5305 +#define LINUX_CDROMREADTOCENTRY 0x5306 +#define LINUX_CDROMSTOP 0x5307 +#define LINUX_CDROMSTART 0x5308 +#define LINUX_CDROMEJECT 0x5309 +#define LINUX_CDROMVOLCTRL 0x530a +#define LINUX_CDROMSUBCHNL 0x530b +#define LINUX_CDROMREADMODE2 0x530c +#define LINUX_CDROMREADMODE1 0x530d +#define LINUX_CDROMREADAUDIO 0x530e +#define LINUX_CDROMEJECT_SW 0x530f +#define LINUX_CDROMMULTISESSION 0x5310 +#define LINUX_CDROM_GET_UPC 0x5311 +#define LINUX_CDROMRESET 0x5312 +#define LINUX_CDROMVOLREAD 0x5313 +#define LINUX_CDROMREADRAW 0x5314 +#define LINUX_CDROMREADCOOKED 0x5315 +#define LINUX_CDROMSEEK 0x5316 +#define LINUX_CDROMPLAYBLK 0x5317 +#define LINUX_CDROMREADALL 0x5318 +#define LINUX_CDROMCLOSETRAY 0x5319 +#define LINUX_CDROMLOADFROMSLOT 0x531a + +#define LINUX_IOCTL_CDROM_MIN LINUX_CDROMPAUSE +#define LINUX_IOCTL_CDROM_MAX LINUX_CDROMLOADFROMSLOT + +#define LINUX_CDROM_LBA 0x01 +#define LINUX_CDROM_MSF 0x02 + +/* + * console + */ +#define LINUX_KIOCSOUND 0x4B2F +#define LINUX_KDMKTONE 0x4B30 +#define LINUX_KDGETLED 0x4B31 +#define LINUX_KDSETLED 0x4B32 +#define LINUX_KDSETMODE 0x4B3A +#define LINUX_KDGETMODE 0x4B3B +#define LINUX_KDGKBMODE 0x4B44 +#define LINUX_KDSKBMODE 0x4B45 +#define LINUX_VT_OPENQRY 0x5600 +#define LINUX_VT_GETMODE 0x5601 +#define LINUX_VT_SETMODE 0x5602 +#define LINUX_VT_GETSTATE 0x5603 +#define LINUX_VT_RELDISP 0x5605 +#define LINUX_VT_ACTIVATE 0x5606 +#define LINUX_VT_WAITACTIVE 0x5607 + +#define LINUX_IOCTL_CONSOLE_MIN LINUX_KIOCSOUND +#define LINUX_IOCTL_CONSOLE_MAX LINUX_VT_WAITACTIVE + +#define LINUX_LED_SCR 0x01 +#define LINUX_LED_NUM 0x02 +#define LINUX_LED_CAP 0x04 + +#define LINUX_KD_TEXT 0x0 +#define LINUX_KD_GRAPHICS 0x1 +#define LINUX_KD_TEXT0 0x2 +#define LINUX_KD_TEXT1 0x3 + +#define LINUX_KBD_RAW 0 +#define LINUX_KBD_XLATE 1 +#define LINUX_KBD_MEDIUMRAW 2 + +/* + * socket + */ +#define LINUX_FIOSETOWN 0x8901 +#define LINUX_SIOCSPGRP 0x8902 +#define LINUX_FIOGETOWN 0x8903 +#define LINUX_SIOCGPGRP 0x8904 +#define LINUX_SIOCATMARK 0x8905 +#define LINUX_SIOCGSTAMP 0x8906 +#define LINUX_SIOCGIFCONF 0x8912 +#define LINUX_SIOCGIFFLAGS 0x8913 +#define LINUX_SIOCGIFADDR 0x8915 +#define LINUX_SIOCGIFDSTADDR 0x8917 +#define LINUX_SIOCGIFBRDADDR 0x8919 +#define LINUX_SIOCGIFNETMASK 0x891b +#define LINUX_SIOCGIFHWADDR 0x8927 +#define LINUX_SIOCADDMULTI 0x8931 +#define LINUX_SIOCDELMULTI 0x8932 + +#define LINUX_IOCTL_SOCKET_MIN LINUX_FIOSETOWN +#define LINUX_IOCTL_SOCKET_MAX LINUX_SIOCDELMULTI + +/* + * sound + */ +#define LINUX_SOUND_MIXER_WRITE_VOLUME 0x4d00 +#define LINUX_SOUND_MIXER_WRITE_BASS 0x4d01 +#define LINUX_SOUND_MIXER_WRITE_TREBLE 0x4d02 +#define LINUX_SOUND_MIXER_WRITE_SYNTH 0x4d03 +#define LINUX_SOUND_MIXER_WRITE_PCM 0x4d04 +#define LINUX_SOUND_MIXER_WRITE_SPEAKER 0x4d05 +#define LINUX_SOUND_MIXER_WRITE_LINE 0x4d06 +#define LINUX_SOUND_MIXER_WRITE_MIC 0x4d07 +#define LINUX_SOUND_MIXER_WRITE_CD 0x4d08 +#define LINUX_SOUND_MIXER_WRITE_IMIX 0x4d09 +#define LINUX_SOUND_MIXER_WRITE_ALTPCM 0x4d0A +#define LINUX_SOUND_MIXER_WRITE_RECLEV 0x4d0B +#define LINUX_SOUND_MIXER_WRITE_IGAIN 0x4d0C +#define LINUX_SOUND_MIXER_WRITE_OGAIN 0x4d0D +#define LINUX_SOUND_MIXER_WRITE_LINE1 0x4d0E +#define LINUX_SOUND_MIXER_WRITE_LINE2 0x4d0F +#define LINUX_SOUND_MIXER_WRITE_LINE3 0x4d10 +#define LINUX_OSS_GETVERSION 0x4d76 +#define LINUX_SOUND_MIXER_READ_DEVMASK 0x4dfe +#define LINUX_SNDCTL_DSP_RESET 0x5000 +#define LINUX_SNDCTL_DSP_SYNC 0x5001 +#define LINUX_SNDCTL_DSP_SPEED 0x5002 +#define LINUX_SNDCTL_DSP_STEREO 0x5003 +#define LINUX_SNDCTL_DSP_GETBLKSIZE 0x5004 +#define LINUX_SNDCTL_DSP_SETBLKSIZE LINUX_SNDCTL_DSP_GETBLKSIZE +#define LINUX_SNDCTL_DSP_SETFMT 0x5005 +#define LINUX_SOUND_PCM_WRITE_CHANNELS 0x5006 +#define LINUX_SOUND_PCM_WRITE_FILTER 0x5007 +#define LINUX_SNDCTL_DSP_POST 0x5008 +#define LINUX_SNDCTL_DSP_SUBDIVIDE 0x5009 +#define LINUX_SNDCTL_DSP_SETFRAGMENT 0x500A +#define LINUX_SNDCTL_DSP_GETFMTS 0x500B +#define LINUX_SNDCTL_DSP_GETOSPACE 0x500C +#define LINUX_SNDCTL_DSP_GETISPACE 0x500D +#define LINUX_SNDCTL_DSP_NONBLOCK 0x500E +#define LINUX_SNDCTL_DSP_GETCAPS 0x500F +#define LINUX_SNDCTL_DSP_GETTRIGGER 0x5010 +#define LINUX_SNDCTL_DSP_SETTRIGGER LINUX_SNDCTL_DSP_GETTRIGGER +#define LINUX_SNDCTL_DSP_GETIPTR 0x5011 +#define LINUX_SNDCTL_DSP_GETOPTR 0x5012 +#define LINUX_SNDCTL_DSP_GETODELAY 0x5017 +#define LINUX_SNDCTL_SEQ_RESET 0x5100 +#define LINUX_SNDCTL_SEQ_SYNC 0x5101 +#define LINUX_SNDCTL_SYNTH_INFO 0x5102 +#define LINUX_SNDCTL_SEQ_CTRLRATE 0x5103 +#define LINUX_SNDCTL_SEQ_GETOUTCOUNT 0x5104 +#define LINUX_SNDCTL_SEQ_GETINCOUNT 0x5105 +#define LINUX_SNDCTL_SEQ_PERCMODE 0x5106 +#define LINUX_SNDCTL_FM_LOAD_INSTR 0x5107 +#define LINUX_SNDCTL_SEQ_TESTMIDI 0x5108 +#define LINUX_SNDCTL_SEQ_RESETSAMPLES 0x5109 +#define LINUX_SNDCTL_SEQ_NRSYNTHS 0x510A +#define LINUX_SNDCTL_SEQ_NRMIDIS 0x510B +#define LINUX_SNDCTL_MIDI_INFO 0x510C +#define LINUX_SNDCTL_SEQ_TRESHOLD 0x510D +#define LINUX_SNDCTL_SYNTH_MEMAVL 0x510E + +#define LINUX_IOCTL_SOUND_MIN LINUX_SOUND_MIXER_WRITE_VOLUME +#define LINUX_IOCTL_SOUND_MAX LINUX_SNDCTL_SYNTH_MEMAVL + +/* + * termio + */ +#define LINUX_TCGETS 0x5401 +#define LINUX_TCSETS 0x5402 +#define LINUX_TCSETSW 0x5403 +#define LINUX_TCSETSF 0x5404 +#define LINUX_TCGETA 0x5405 +#define LINUX_TCSETA 0x5406 +#define LINUX_TCSETAW 0x5407 +#define LINUX_TCSETAF 0x5408 +#define LINUX_TCSBRK 0x5409 +#define LINUX_TCXONC 0x540A +#define LINUX_TCFLSH 0x540B +#define LINUX_TIOCEXCL 0x540C +#define LINUX_TIOCNXCL 0x540D +#define LINUX_TIOCSCTTY 0x540E +#define LINUX_TIOCGPGRP 0x540F +#define LINUX_TIOCSPGRP 0x5410 +#define LINUX_TIOCOUTQ 0x5411 +#define LINUX_TIOCSTI 0x5412 +#define LINUX_TIOCGWINSZ 0x5413 +#define LINUX_TIOCSWINSZ 0x5414 +#define LINUX_TIOCMGET 0x5415 +#define LINUX_TIOCMBIS 0x5416 +#define LINUX_TIOCMBIC 0x5417 +#define LINUX_TIOCMSET 0x5418 +#define LINUX_TIOCGSOFTCAR 0x5419 +#define LINUX_TIOCSSOFTCAR 0x541A +#define LINUX_FIONREAD 0x541B +#define LINUX_TIOCINQ FIONREAD +#define LINUX_TIOCLINUX 0x541C +#define LINUX_TIOCCONS 0x541D +#define LINUX_TIOCGSERIAL 0x541E +#define LINUX_TIOCSSERIAL 0x541F +#define LINUX_TIOCPKT 0x5420 +#define LINUX_FIONBIO 0x5421 +#define LINUX_TIOCNOTTY 0x5422 +#define LINUX_TIOCSETD 0x5423 +#define LINUX_TIOCGETD 0x5424 +#define LINUX_TCSBRKP 0x5425 +#define LINUX_TIOCTTYGSTRUCT 0x5426 +#define LINUX_FIONCLEX 0x5450 +#define LINUX_FIOCLEX 0x5451 +#define LINUX_FIOASYNC 0x5452 +#define LINUX_TIOCSERCONFIG 0x5453 +#define LINUX_TIOCSERGWILD 0x5454 +#define LINUX_TIOCSERSWILD 0x5455 +#define LINUX_TIOCGLCKTRMIOS 0x5456 +#define LINUX_TIOCSLCKTRMIOS 0x5457 + +#define LINUX_IOCTL_TERMIO_MIN LINUX_TCGETS +#define LINUX_IOCTL_TERMIO_MAX LINUX_TIOCSLCKTRMIOS + +/* arguments for tcflow() and LINUX_TCXONC */ +#define LINUX_TCOOFF 0 +#define LINUX_TCOON 1 +#define LINUX_TCIOFF 2 +#define LINUX_TCION 3 + +/* arguments for tcflush() and LINUX_TCFLSH */ +#define LINUX_TCIFLUSH 0 +#define LINUX_TCOFLUSH 1 +#define LINUX_TCIOFLUSH 2 + +/* line disciplines */ +#define LINUX_N_TTY 0 +#define LINUX_N_SLIP 1 +#define LINUX_N_MOUSE 2 +#define LINUX_N_PPP 3 + +/* Linux termio c_cc values */ +#define LINUX_VINTR 0 +#define LINUX_VQUIT 1 +#define LINUX_VERASE 2 +#define LINUX_VKILL 3 +#define LINUX_VEOF 4 +#define LINUX_VTIME 5 +#define LINUX_VMIN 6 +#define LINUX_VSWTC 7 +#define LINUX_NCC 8 + +/* Linux termios c_cc values */ +#define LINUX_VSTART 8 +#define LINUX_VSTOP 9 +#define LINUX_VSUSP 10 +#define LINUX_VEOL 11 +#define LINUX_VREPRINT 12 +#define LINUX_VDISCARD 13 +#define LINUX_VWERASE 14 +#define LINUX_VLNEXT 15 +#define LINUX_VEOL2 16 +#define LINUX_NCCS 19 + +#define LINUX_POSIX_VDISABLE '\0' + +/* Linux c_iflag masks */ +#define LINUX_IGNBRK 0x0000001 +#define LINUX_BRKINT 0x0000002 +#define LINUX_IGNPAR 0x0000004 +#define LINUX_PARMRK 0x0000008 +#define LINUX_INPCK 0x0000010 +#define LINUX_ISTRIP 0x0000020 +#define LINUX_INLCR 0x0000040 +#define LINUX_IGNCR 0x0000080 +#define LINUX_ICRNL 0x0000100 +#define LINUX_IUCLC 0x0000200 +#define LINUX_IXON 0x0000400 +#define LINUX_IXANY 0x0000800 +#define LINUX_IXOFF 0x0001000 +#define LINUX_IMAXBEL 0x0002000 + +/* Linux c_oflag masks */ +#define LINUX_OPOST 0x0000001 +#define LINUX_OLCUC 0x0000002 +#define LINUX_ONLCR 0x0000004 +#define LINUX_OCRNL 0x0000008 +#define LINUX_ONOCR 0x0000010 +#define LINUX_ONLRET 0x0000020 +#define LINUX_OFILL 0x0000040 +#define LINUX_OFDEL 0x0000080 +#define LINUX_NLDLY 0x0000100 + +#define LINUX_NL0 0x0000000 +#define LINUX_NL1 0x0000100 +#define LINUX_CRDLY 0x0000600 +#define LINUX_CR0 0x0000000 +#define LINUX_CR1 0x0000200 +#define LINUX_CR2 0x0000400 +#define LINUX_CR3 0x0000600 +#define LINUX_TABDLY 0x0001800 +#define LINUX_TAB0 0x0000000 +#define LINUX_TAB1 0x0000800 +#define LINUX_TAB2 0x0001000 +#define LINUX_TAB3 0x0001800 +#define LINUX_XTABS 0x0001800 +#define LINUX_BSDLY 0x0002000 +#define LINUX_BS0 0x0000000 +#define LINUX_BS1 0x0002000 +#define LINUX_VTDLY 0x0004000 +#define LINUX_VT0 0x0000000 +#define LINUX_VT1 0x0004000 +#define LINUX_FFDLY 0x0008000 +#define LINUX_FF0 0x0000000 +#define LINUX_FF1 0x0008000 + +#define LINUX_CBAUD 0x0000100f +#define LINUX_B0 0x00000000 +#define LINUX_B50 0x00000001 +#define LINUX_B75 0x00000002 +#define LINUX_B110 0x00000003 +#define LINUX_B134 0x00000004 +#define LINUX_B150 0x00000005 +#define LINUX_B200 0x00000006 +#define LINUX_B300 0x00000007 +#define LINUX_B600 0x00000008 +#define LINUX_B1200 0x00000009 +#define LINUX_B1800 0x0000000a +#define LINUX_B2400 0x0000000b +#define LINUX_B4800 0x0000000c +#define LINUX_B9600 0x0000000d +#define LINUX_B19200 0x0000000e +#define LINUX_B38400 0x0000000f +#define LINUX_EXTA LINUX_B19200 +#define LINUX_EXTB LINUX_B38400 +#define LINUX_CBAUDEX 0x00001000 +#define LINUX_B57600 0x00001001 +#define LINUX_B115200 0x00001002 + +#define LINUX_CSIZE 0x00000030 +#define LINUX_CS5 0x00000000 +#define LINUX_CS6 0x00000010 +#define LINUX_CS7 0x00000020 +#define LINUX_CS8 0x00000030 +#define LINUX_CSTOPB 0x00000040 +#define LINUX_CREAD 0x00000080 +#define LINUX_PARENB 0x00000100 +#define LINUX_PARODD 0x00000200 +#define LINUX_HUPCL 0x00000400 +#define LINUX_CLOCAL 0x00000800 +#define LINUX_CRTSCTS 0x80000000 + +/* Linux c_lflag masks */ +#define LINUX_ISIG 0x00000001 +#define LINUX_ICANON 0x00000002 +#define LINUX_XCASE 0x00000004 +#define LINUX_ECHO 0x00000008 +#define LINUX_ECHOE 0x00000010 +#define LINUX_ECHOK 0x00000020 +#define LINUX_ECHONL 0x00000040 +#define LINUX_NOFLSH 0x00000080 +#define LINUX_TOSTOP 0x00000100 +#define LINUX_ECHOCTL 0x00000200 +#define LINUX_ECHOPRT 0x00000400 +#define LINUX_ECHOKE 0x00000800 +#define LINUX_FLUSHO 0x00001000 +#define LINUX_PENDIN 0x00002000 +#define LINUX_IEXTEN 0x00008000 + +/* serial_struct values for TIOC[GS]SERIAL ioctls */ +#define LINUX_ASYNC_CLOSING_WAIT_INF 0 +#define LINUX_ASYNC_CLOSING_WAIT_NONE 65535 + +#define LINUX_PORT_UNKNOWN 0 +#define LINUX_PORT_8250 1 +#define LINUX_PORT_16450 2 +#define LINUX_PORT_16550 3 +#define LINUX_PORT_16550A 4 +#define LINUX_PORT_CIRRUS 5 +#define LINUX_PORT_16650 6 + +#define LINUX_PORT_MAX 6 + +#define LINUX_ASYNC_HUP_NOTIFY 0x0001 +#define LINUX_ASYNC_FOURPORT 0x0002 +#define LINUX_ASYNC_SAK 0x0004 +#define LINUX_ASYNC_SPLIT_TERMIOS 0x0008 +#define LINUX_ASYNC_SPD_MASK 0x0030 +#define LINUX_ASYNC_SPD_HI 0x0010 +#define LINUX_ASYNC_SPD_VHI 0x0020 +#define LINUX_ASYNC_SPD_CUST 0x0030 +#define LINUX_ASYNC_SKIP_TEST 0x0040 +#define LINUX_ASYNC_AUTO_IRQ 0x0080 +#define LINUX_ASYNC_SESSION_LOCKOUT 0x0100 +#define LINUX_ASYNC_PGRP_LOCKOUT 0x0200 +#define LINUX_ASYNC_CALLOUT_NOHUP 0x0400 +#define LINUX_ASYNC_FLAGS 0x0FFF + +#endif /* !_LINUX_IOCTL_H_ */ diff --git a/sys/i386/linux/linux_sysvec.c b/sys/i386/linux/linux_sysvec.c index eaf2a04..76be2b4 100644 --- a/sys/i386/linux/linux_sysvec.c +++ b/sys/i386/linux/linux_sysvec.c @@ -57,6 +57,15 @@ #include <i386/linux/linux.h> #include <i386/linux/linux_proto.h> +MALLOC_DEFINE(M_LINUX, "linux", "Linux mode structures"); + +extern char linux_sigcode[]; +extern int linux_szsigcode; + +extern struct sysent linux_sysent[LINUX_SYS_MAXSYSCALL]; + +extern struct linker_set linux_ioctl_handler_set; + static int linux_fixup __P((long **stack_base, struct image_params *iparams)); static int elf_linux_fixup __P((long **stack_base, @@ -460,24 +469,27 @@ linux_elf_modevent(module_t mod, int type, void *data) switch(type) { case MOD_LOAD: for (brandinfo = &linux_brandlist[0]; *brandinfo != NULL; - ++brandinfo) + ++brandinfo) if (elf_insert_brand_entry(*brandinfo) < 0) error = EINVAL; if (error) printf("cannot insert Linux elf brand handler\n"); - else if (bootverbose) - printf("Linux-ELF exec handler installed\n"); + else { + linux_ioctl_register_handlers(&linux_ioctl_handler_set); + if (bootverbose) + printf("Linux-ELF exec handler installed\n"); + } break; case MOD_UNLOAD: + linux_ioctl_unregister_handlers(&linux_ioctl_handler_set); for (brandinfo = &linux_brandlist[0]; *brandinfo != NULL; - ++brandinfo) - if (elf_brand_inuse(*brandinfo)) { + ++brandinfo) + if (elf_brand_inuse(*brandinfo)) error = EBUSY; - } if (error == 0) { for (brandinfo = &linux_brandlist[0]; - *brandinfo != NULL; ++brandinfo) + *brandinfo != NULL; ++brandinfo) if (elf_remove_brand_entry(*brandinfo) < 0) error = EINVAL; } diff --git a/sys/i386/linux/linux_util.h b/sys/i386/linux/linux_util.h index 61a6371..f8775fb 100644 --- a/sys/i386/linux/linux_util.h +++ b/sys/i386/linux/linux_util.h @@ -80,6 +80,8 @@ stackgap_alloc(sgp, sz) #define DPRINTF(a) #endif +extern const char linux_emul_path[]; + int linux_emul_find __P((struct proc *, caddr_t *, const char *, char *, char **, int)); |