diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 1999-11-13 22:13:01 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 1999-11-13 22:13:01 +0000 |
commit | e90fc07791a6c21f7fd44de7f836be82d0315fd0 (patch) | |
tree | 71f23d2d6085c248489e6201db05145bc2cd629b /sys | |
parent | 6247affda263fd2d97f4dcf0f1f3c2a03d38513f (diff) |
Add OSS audio support to BSD/OS emulation.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/compat/bsdos/bsdos_ioctl.c | 142 | ||||
-rw-r--r-- | sys/compat/bsdos/bsdos_ioctl.h | 55 | ||||
-rw-r--r-- | sys/compat/bsdos/files.bsdos | 3 | ||||
-rw-r--r-- | sys/compat/bsdos/syscalls.master | 5 |
4 files changed, 202 insertions, 3 deletions
diff --git a/sys/compat/bsdos/bsdos_ioctl.c b/sys/compat/bsdos/bsdos_ioctl.c new file mode 100644 index 00000000000..588a1439ce5 --- /dev/null +++ b/sys/compat/bsdos/bsdos_ioctl.c @@ -0,0 +1,142 @@ +/* $OpenBSD: bsdos_ioctl.c,v 1.1 1999/11/13 22:13:00 millert Exp $ */ + +/* + * Copyright (c) 1999 Todd C. Miller <Todd.Miller@courtesan.com> + * 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. + * 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 without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``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. + */ + +#include <sys/param.h> +#include <sys/systm.h> +#include <sys/proc.h> +#include <sys/mount.h> + +#include <sys/syscallargs.h> + +#include <compat/bsdos/bsdos_syscallargs.h> +#include <compat/bsdos/bsdos_ioctl.h> + +#include <compat/ossaudio/ossaudio.h> +#include <compat/ossaudio/ossaudiovar.h> + +#include <compat/common/compat_util.h> + +static void bsdos_to_oss __P((struct bsdos_sys_ioctl_args *, struct oss_sys_ioctl_args *)); + +/* + * BSD/OS and OSS have different values for IOC_*. Also, + * sizeof(bsdos_audio_buf_info) != sizeof(oss_audio_buf_info) which + * is encoded in OSS_SNDCTL_DSP_GETOSPACE and OSS_SNDCTL_DSP_GETISPACE. + */ +static void +bsdos_to_oss(bap, oap) + struct bsdos_sys_ioctl_args *bap; + struct oss_sys_ioctl_args *oap; +{ + u_long bcom, ocom; + + bcom = SCARG(bap, com); + ocom = bcom & ~BSDOS_IOC_DIRMASK; + switch (bcom & BSDOS_IOC_DIRMASK) { + case BSDOS_IOC_VOID: + ocom |= OSS_IOC_VOID; + break; + case BSDOS_IOC_OUT: + if (bcom == BSDOS_SNDCTL_DSP_GETOSPACE) + ocom = OSS_SNDCTL_DSP_GETOSPACE; + else if (bcom == BSDOS_SNDCTL_DSP_GETISPACE) + ocom = OSS_SNDCTL_DSP_GETISPACE; + else + ocom |= OSS_IOC_OUT; + break; + case BSDOS_IOC_IN: + ocom |= OSS_IOC_IN; + break; + case BSDOS_IOC_INOUT: + ocom |= OSS_IOC_INOUT; + break; + } + SCARG(oap, fd) = SCARG(bap, fd); + SCARG(oap, com) = ocom; + SCARG(oap, data) = SCARG(bap, data); +} + +int +bsdos_sys_ioctl(p, v, retval) + struct proc *p; + void *v; + register_t *retval; +{ + struct bsdos_sys_ioctl_args /* { + syscallarg(int) fd; + syscallarg(u_long) com; + syscallarg(caddr_t) data; + } */ *uap = v; + struct oss_sys_ioctl_args ap; + + /* + * XXX should support 'T' timer ioctl's + * XXX also /dev/sequencer and /dev/patmgr# + */ + switch (BSDOS_IOCGROUP(SCARG(uap, com))) { + case 'M': + bsdos_to_oss(uap, &ap); + return (oss_ioctl_mixer(p, &ap, retval)); + case 'Q': + bsdos_to_oss(uap, &ap); + return (oss_ioctl_sequencer(p, &ap, retval)); + case 'P': + bsdos_to_oss(uap, &ap); + /* + * Special handling since the BSD/OS audio_buf_info + * struct lacks a fragstotal member. + */ + if (SCARG(uap, com) == BSDOS_SNDCTL_DSP_GETOSPACE || + SCARG(uap, com) == BSDOS_SNDCTL_DSP_GETISPACE) + { + struct oss_audio_buf_info oss_buf, *oss_bufp; + struct bsdos_audio_buf_info bsdos_buf; + caddr_t sg = stackgap_init(p->p_emul); + int error; + + oss_bufp = stackgap_alloc(&sg, sizeof(*oss_bufp)); + SCARG(&ap, data) = (void *) oss_bufp; + error = oss_ioctl_audio(p, &ap, retval); + if (error) + return (error); + error = copyin(oss_bufp, &oss_buf, sizeof(oss_buf)); + if (error) + return (error); + bsdos_buf.fragments = oss_buf.fragstotal; + bsdos_buf.fragsize = oss_buf.fragsize; + bsdos_buf.bytes = oss_buf.bytes; + error = copyout(&bsdos_buf, SCARG(uap, data), + sizeof(bsdos_buf)); + if (error) + return (error); + } else + return (oss_ioctl_audio(p, &ap, retval)); + } + return (sys_ioctl(p, uap, retval)); +} diff --git a/sys/compat/bsdos/bsdos_ioctl.h b/sys/compat/bsdos/bsdos_ioctl.h new file mode 100644 index 00000000000..00bb3bc957a --- /dev/null +++ b/sys/compat/bsdos/bsdos_ioctl.h @@ -0,0 +1,55 @@ +/* $OpenBSD: bsdos_ioctl.h,v 1.1 1999/11/13 22:13:00 millert Exp $ */ + +/* + * Copyright (c) 1999 Todd C. Miller <Todd.Miller@courtesan.com> + * 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. + * 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 without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``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. + */ + +#ifndef _BSDOS_IOCTL_H +#define _BSDOS_IOCTL_H + +struct bsdos_audio_buf_info { + int fragments; + int fragsize; + int bytes; +}; + +#define BSDOS_IOCPARM_MASK 0x1fff +#define BSDOS_IOCGROUP(x) (((x) >> 8) & 0xff) + +#define BSDOS_IOC_VOID (unsigned long)0x20000000 +#define BSDOS_IOC_OUT (unsigned long)0x40000000 +#define BSDOS_IOC_IN (unsigned long)0x80000000 +#define BSDOS_IOC_INOUT (BSDOS_IOC_IN|BSDOS_IOC_OUT) +#define BSDOS_IOC_DIRMASK (unsigned long)0xe0000000 + +#define _BSDOS_IOC(inout,group,num,len) \ + (inout | ((len & BSDOS_IOCPARM_MASK) << 16) | ((group) << 8) | (num)) +#define _BSDOS_IOR(g,n,t) _BSDOS_IOC(BSDOS_IOC_OUT, (g), (n), sizeof(t)) + +#define BSDOS_SNDCTL_DSP_GETOSPACE _BSDOS_IOR('P', 12, struct bsdos_audio_buf_info) +#define BSDOS_SNDCTL_DSP_GETISPACE _BSDOS_IOR('P', 13, struct bsdos_audio_buf_info) + +#endif /* _BSDOS_IOCTL_H */ diff --git a/sys/compat/bsdos/files.bsdos b/sys/compat/bsdos/files.bsdos index 66854b8dc7f..7029fbf78c2 100644 --- a/sys/compat/bsdos/files.bsdos +++ b/sys/compat/bsdos/files.bsdos @@ -1,4 +1,4 @@ -# $OpenBSD: files.bsdos,v 1.2 1999/11/10 15:55:13 mickey Exp $ +# $OpenBSD: files.bsdos,v 1.3 1999/11/13 22:13:00 millert Exp $ # # Config file description for machine-independent BSD/OS compat code. # Included by ports that need it. @@ -7,5 +7,6 @@ # own file lists. file compat/bsdos/bsdos_exec.c compat_bsdos +file compat/bsdos/bsdos_ioctl.c compat_bsdos file compat/bsdos/bsdos_sysent.c compat_bsdos file compat/bsdos/bsdos_syscalls.c compat_bsdos & syscall_debug diff --git a/sys/compat/bsdos/syscalls.master b/sys/compat/bsdos/syscalls.master index af947a3ddce..a0e3091615d 100644 --- a/sys/compat/bsdos/syscalls.master +++ b/sys/compat/bsdos/syscalls.master @@ -1,4 +1,4 @@ - $OpenBSD: syscalls.master,v 1.5 1999/06/07 07:17:46 deraadt Exp $ + $OpenBSD: syscalls.master,v 1.6 1999/11/13 22:13:00 millert Exp $ ; OpenBSD COMPAT_BSDOS system call name/number "master" file. ; (See syscalls.conf to see what it is processed into.) @@ -117,7 +117,8 @@ 52 NOARGS { int sys_sigpending(void); } 53 NOARGS { int sys_sigaltstack(struct sigaltstack *nss, \ struct sigaltstack *oss); } -54 NOARGS { int sys_ioctl(int fd, u_long com, caddr_t data); } +54 STD { int bsdos_sys_ioctl(int fd, u_long com, \ + caddr_t data); } 55 NOARGS { int sys_reboot(int opt); } 56 NOARGS { int sys_revoke(char *path); } 57 NOARGS { int sys_symlink(char *path, char *link); } |