diff options
author | Michael Shalayeff <mickey@cvs.openbsd.org> | 2004-07-09 21:33:46 +0000 |
---|---|---|
committer | Michael Shalayeff <mickey@cvs.openbsd.org> | 2004-07-09 21:33:46 +0000 |
commit | c6c0af96adffb0022f3a8ab8ac0343f2fcbcad17 (patch) | |
tree | 3a795b54f75d953f1fbc901389a3af4ec31a3d66 /sys/compat/hpux/m68k | |
parent | 336d2bbe3d5efc5270e9d8d1bb7774ff2f7c598a (diff) |
split off the m68k-specific parts
Diffstat (limited to 'sys/compat/hpux/m68k')
-rw-r--r-- | sys/compat/hpux/m68k/Makefile | 7 | ||||
-rw-r--r-- | sys/compat/hpux/m68k/files.hpux | 17 | ||||
-rw-r--r-- | sys/compat/hpux/m68k/hpux_exec.c | 325 | ||||
-rw-r--r-- | sys/compat/hpux/m68k/hpux_exec.h | 120 | ||||
-rw-r--r-- | sys/compat/hpux/m68k/hpux_net.c | 314 | ||||
-rw-r--r-- | sys/compat/hpux/m68k/hpux_sig.c | 442 | ||||
-rw-r--r-- | sys/compat/hpux/m68k/syscalls.conf | 13 | ||||
-rw-r--r-- | sys/compat/hpux/m68k/syscalls.master | 464 |
8 files changed, 1702 insertions, 0 deletions
diff --git a/sys/compat/hpux/m68k/Makefile b/sys/compat/hpux/m68k/Makefile new file mode 100644 index 00000000000..90b5162664d --- /dev/null +++ b/sys/compat/hpux/m68k/Makefile @@ -0,0 +1,7 @@ +# $OpenBSD: Makefile,v 1.1 2004/07/09 21:33:45 mickey Exp $ + +DEP= syscalls.conf syscalls.master ../../kern/makesyscalls.sh +OBJS= hpux_sysent.c hpux_syscalls.c hpux_syscall.h hpux_syscallargs.h + +${OBJS}: ${DEP} + sh ../../kern/makesyscalls.sh syscalls.conf syscalls.master diff --git a/sys/compat/hpux/m68k/files.hpux b/sys/compat/hpux/m68k/files.hpux new file mode 100644 index 00000000000..4d154ecfe96 --- /dev/null +++ b/sys/compat/hpux/m68k/files.hpux @@ -0,0 +1,17 @@ +# $OpenBSD: files.hpux,v 1.1 2004/07/09 21:33:45 mickey Exp $ +# $NetBSD: files.hpux,v 1.2 1995/11/28 08:39:52 thorpej Exp $ +# +# Config file description for machine-independent HPUX compat code. +# Included by ports that need it. + +# ports should define any machine-specific files they need in their +# own file lists. + +file compat/hpux/hpux_compat.c compat_hpux +file compat/hpux/hpux_file.c compat_hpux +file compat/hpux/hpux_tty.c compat_hpux +file compat/hpux/m68k/hpux_exec.c compat_hpux +file compat/hpux/m68k/hpux_net.c compat_hpux +file compat/hpux/m68k/hpux_sig.c compat_hpux +file compat/hpux/m68k/hpux_syscalls.c compat_hpux & syscall_debug +file compat/hpux/m68k/hpux_sysent.c compat_hpux diff --git a/sys/compat/hpux/m68k/hpux_exec.c b/sys/compat/hpux/m68k/hpux_exec.c new file mode 100644 index 00000000000..1bad2ef2894 --- /dev/null +++ b/sys/compat/hpux/m68k/hpux_exec.c @@ -0,0 +1,325 @@ +/* $OpenBSD: hpux_exec.c,v 1.1 2004/07/09 21:33:45 mickey Exp $ */ +/* $NetBSD: hpux_exec.c,v 1.8 1997/03/16 10:14:44 thorpej Exp $ */ + +/* + * Copyright (c) 1995, 1997 Jason R. Thorpe. All rights reserved. + * Copyright (c) 1993, 1994 Christopher G. Demetriou + * + * 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. All advertising materials mentioning features or use of this software + * This product includes software developed by Christopher G. Demetriou. + * 4. 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 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. + */ + +/* + * Glue for exec'ing HP-UX executables and the HP-UX execv() system call. + * Based on sys/kern/exec_aout.c + */ + +#include <sys/param.h> +#include <sys/systm.h> +#include <sys/kernel.h> +#include <sys/proc.h> +#include <sys/malloc.h> +#include <sys/mount.h> +#include <sys/namei.h> +#include <sys/user.h> +#include <sys/vnode.h> +#include <sys/mman.h> +#include <sys/stat.h> + +#include <uvm/uvm_extern.h> + +#include <machine/cpu.h> +#include <machine/reg.h> + +#include <sys/syscallargs.h> + +#include <compat/hpux/hpux.h> +#include <compat/hpux/hpux_util.h> +#include <compat/hpux/m68k/hpux_syscall.h> +#include <compat/hpux/m68k/hpux_syscallargs.h> + +#include <machine/hpux_machdep.h> + +const char hpux_emul_path[] = "/emul/hpux"; +extern char sigcode[], esigcode[]; +extern struct sysent hpux_sysent[]; +#ifdef SYSCALL_DEBUG +extern char *hpux_syscallnames[]; +#endif +extern int bsdtohpuxerrnomap[]; + +static int exec_hpux_prep_nmagic(struct proc *, struct exec_package *); +static int exec_hpux_prep_zmagic(struct proc *, struct exec_package *); +static int exec_hpux_prep_omagic(struct proc *, struct exec_package *); + +struct emul emul_hpux = { + "hpux", + bsdtohpuxerrnomap, + hpux_sendsig, + HPUX_SYS_syscall, + HPUX_SYS_MAXSYSCALL, + hpux_sysent, +#ifdef SYSCALL_DEBUG + hpux_syscallnames, +#else + NULL, +#endif + 0, + copyargs, + hpux_setregs, + NULL, + sigcode, + esigcode, +}; + +int +exec_hpux_makecmds(p, epp) + struct proc *p; + struct exec_package *epp; +{ + struct hpux_exec *hpux_ep = epp->ep_hdr; + short sysid, magic; + int error = ENOEXEC; + + magic = HPUX_MAGIC(hpux_ep); + sysid = HPUX_SYSID(hpux_ep); + + if (sysid != MID_HPUX) + return (ENOEXEC); + + /* + * HP-UX is a 4k page size system, and executables assume + * this. + */ + if (PAGE_SIZE != HPUX_LDPGSZ) + return (ENOEXEC); + + switch (magic) { + case OMAGIC: + error = exec_hpux_prep_omagic(p, epp); + break; + + case NMAGIC: + error = exec_hpux_prep_nmagic(p, epp); + break; + + case ZMAGIC: + error = exec_hpux_prep_zmagic(p, epp); + break; + } + + if (error == 0) { + /* set up our emulation information */ + epp->ep_emul = &emul_hpux; + } else + kill_vmcmds(&epp->ep_vmcmds); + + return (error); +} + +static int +exec_hpux_prep_nmagic(p, epp) + struct proc *p; + struct exec_package *epp; +{ + struct hpux_exec *execp = epp->ep_hdr; + long bsize, baddr; + + epp->ep_taddr = 0; + epp->ep_tsize = execp->ha_text; + epp->ep_daddr = epp->ep_taddr + roundup(execp->ha_text, HPUX_LDPGSZ); + epp->ep_dsize = execp->ha_data + execp->ha_bss; + epp->ep_entry = execp->ha_entry; + + /* set up command for text segment */ + NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_readvn, execp->ha_text, + epp->ep_taddr, epp->ep_vp, HPUX_TXTOFF(*execp, NMAGIC), + VM_PROT_READ|VM_PROT_EXECUTE); + + /* set up command for data segment */ + NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_readvn, execp->ha_data, + epp->ep_daddr, epp->ep_vp, HPUX_DATAOFF(*execp, NMAGIC), + VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE); + + /* set up command for bss segment */ + baddr = round_page(epp->ep_daddr + execp->ha_data); + bsize = epp->ep_daddr + epp->ep_dsize - baddr; + if (bsize > 0) + NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_zero, bsize, baddr, + NULLVP, 0, VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE); + + return (exec_setup_stack(p, epp)); +} + +static int +exec_hpux_prep_zmagic(p, epp) + struct proc *p; + struct exec_package *epp; +{ + struct hpux_exec *execp = epp->ep_hdr; + long bsize, baddr; + long nontext; + + /* + * Check if vnode is in open for writing, because we want to + * demand-page out of it. If it is, don't do it, for various + * reasons. + */ + if ((execp->ha_text != 0 || execp->ha_data != 0) && + epp->ep_vp->v_writecount != 0) + return (ETXTBSY); + vn_marktext(epp->ep_vp); + + /* + * HP-UX ZMAGIC executables need to have their segment + * sizes frobbed. + */ + nontext = execp->ha_data + execp->ha_bss; + execp->ha_text = ctob(btoc(execp->ha_text)); + execp->ha_data = ctob(btoc(execp->ha_data)); + execp->ha_bss = nontext - execp->ha_data; + if (execp->ha_bss < 0) + execp->ha_bss = 0; + + epp->ep_taddr = 0; + epp->ep_tsize = execp->ha_text; + epp->ep_daddr = epp->ep_taddr + roundup(execp->ha_text, HPUX_LDPGSZ); + epp->ep_dsize = execp->ha_data + execp->ha_bss; + epp->ep_entry = execp->ha_entry; + + /* set up command for text segment */ + NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_pagedvn, execp->ha_text, + epp->ep_taddr, epp->ep_vp, HPUX_TXTOFF(*execp, ZMAGIC), + VM_PROT_READ|VM_PROT_EXECUTE); + + /* set up command for data segment */ + NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_pagedvn, execp->ha_data, + epp->ep_daddr, epp->ep_vp, HPUX_DATAOFF(*execp, ZMAGIC), + VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE); + + /* set up command for bss segment */ + baddr = round_page(epp->ep_daddr + execp->ha_data); + bsize = epp->ep_daddr + epp->ep_dsize - baddr; + if (bsize > 0) + NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_zero, bsize, baddr, + NULLVP, 0, VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE); + + return (exec_setup_stack(p, epp)); +} + +/* + * HP-UX's version of OMAGIC. + */ +static int +exec_hpux_prep_omagic(p, epp) + struct proc *p; + struct exec_package *epp; +{ + struct hpux_exec *execp = epp->ep_hdr; + long dsize, bsize, baddr; + + epp->ep_taddr = 0; + epp->ep_tsize = execp->ha_text; + epp->ep_daddr = epp->ep_taddr + roundup(execp->ha_text, HPUX_LDPGSZ); + epp->ep_dsize = execp->ha_data + execp->ha_bss; + epp->ep_entry = execp->ha_entry; + + /* set up command for text and data segments */ + NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_readvn, + execp->ha_text + execp->ha_data, epp->ep_taddr, epp->ep_vp, + HPUX_TXTOFF(*execp, OMAGIC), + VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE); + + /* set up command for bss segment */ + baddr = round_page(epp->ep_daddr + execp->ha_data); + bsize = epp->ep_daddr + epp->ep_dsize - baddr; + if (bsize > 0) + NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_zero, bsize, baddr, + NULLVP, 0, VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE); + + /* + * Make sure (# of pages) mapped above equals (vm_tsize + vm_dsize); + * obreak(2) relies on this fact. Both `vm_tsize' and `vm_dsize' are + * computed (in execve(2)) by rounding *up* `ep_tsize' and `ep_dsize' + * respectively to page boundaries. + * Compensate `ep_dsize' for the amount of data covered by the last + * text page. + */ + dsize = epp->ep_dsize + execp->ha_text - round_page(execp->ha_text); + epp->ep_dsize = (dsize > 0) ? dsize : 0; + return (exec_setup_stack(p, epp)); +} + +/* + * The HP-UX execv(2) system call. + * + * Just check the alternate emulation path, and pass it on to the NetBSD + * execve(). + */ +int +hpux_sys_execv(p, v, retval) + struct proc *p; + void *v; + register_t *retval; +{ + struct hpux_sys_execv_args /* { + syscallarg(char *) path; + syscallarg(char **) argv; + } */ *uap = v; + struct sys_execve_args ap; + caddr_t sg; + + sg = stackgap_init(p->p_emul); + HPUX_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); + + SCARG(&ap, path) = SCARG(uap, path); + SCARG(&ap, argp) = SCARG(uap, argp); + SCARG(&ap, envp) = NULL; + + return sys_execve(p, &ap, retval); +} + +int +hpux_sys_execve(p, v, retval) + struct proc *p; + void *v; + register_t *retval; +{ + struct hpux_sys_execve_args /* { + syscallarg(char *) path; + syscallarg(char **) argv; + syscallarg(char **) envp; + } */ *uap = v; + struct sys_execve_args ap; + caddr_t sg; + + sg = stackgap_init(p->p_emul); + HPUX_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); + + SCARG(&ap, path) = SCARG(uap, path); + SCARG(&ap, argp) = SCARG(uap, argp); + SCARG(&ap, envp) = SCARG(uap, envp); + + return (sys_execve(p, &ap, retval)); +} diff --git a/sys/compat/hpux/m68k/hpux_exec.h b/sys/compat/hpux/m68k/hpux_exec.h new file mode 100644 index 00000000000..ded9d211a9b --- /dev/null +++ b/sys/compat/hpux/m68k/hpux_exec.h @@ -0,0 +1,120 @@ +/* $OpenBSD: hpux_exec.h,v 1.1 2004/07/09 21:33:45 mickey Exp $ */ +/* $NetBSD: hpux_exec.h,v 1.7 1997/03/16 10:16:02 thorpej Exp $ */ + +/* + * Copyright (c) 1995 Jason R. Thorpe. All rights reserved. + * Copyright (c) 1988 University of Utah. + * Copyright (c) 1990, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * the Systems Programming Group of the University of Utah Computer + * Science Department. + * + * 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. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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. + * + * from: Utah $Hdr: hpux_exec.h 1.6 92/01/20$ + * + * @(#)hpux_exec.h 8.1 (Berkeley) 6/10/93 + */ + +#ifndef _HPUX_EXEC_H_ +#define _HPUX_EXEC_H_ + +/* + * HPUX a.out header format + */ +struct hpux_exec { + long ha_magic; /* magic number */ + short ha_version; /* version ID */ + short ha_shlhw; /* shared lib "highwater" mark */ + long ha_misc; /* misc. info */ + long ha_text; /* size of text segment */ + long ha_data; /* size of initialized data */ + long ha_bss; /* size of uninitialized data */ + long ha_trsize; /* size of text relocation */ + long ha_drsize; /* size of data relocation */ + long ha_pascal; /* pascal section size */ + long ha_symbols; /* symbol table size */ + long ha_pad0; + long ha_entry; /* entry point */ + long ha_pad1; + long ha_supsyms; /* supplementary symbol table */ + long ha_drelocs; /* non-PIC relocation info */ + long ha_extentions; /* file offset of special extensions */ +}; + +#define HPUX_EXEC_HDR_SIZE (sizeof(struct hpux_exec)) + +#define HPUX_MAGIC(ha) ((ha)->ha_magic & 0xffff) +#define HPUX_SYSID(ha) (((ha)->ha_magic >> 16) & 0xffff) + +/* + * Additional values for HPUX_MAGIC() + */ +#define HPUX_MAGIC_RELOC 0x0106 /* relocatable object */ +#define HPUX_MAGIC_DL 0x010d /* dynamic load library */ +#define HPUX_MAGIC_SHL 0x010e /* shared library */ + +#define HPUX_LDPGSZ 4096 /* align to this */ +#define HPUX_LDPGSHIFT 12 /* log2(HPUX_LDPGSZ) */ + +#define HPUX_SEGMENT_ROUND(x) \ + (((x) + HPUX_LDPGSZ - 1) & ~(HPUX_LDPGSZ - 1)) + +#define HPUX_TXTOFF(x, m) \ + ((((m) == ZMAGIC) || \ + ((m) == HPUX_MAGIC_SHL) || \ + ((m) == HPUX_MAGIC_DL)) ? \ + HPUX_LDPGSZ : HPUX_EXEC_HDR_SIZE) + +#define HPUX_DATAOFF(x, m) \ + ((((m) == ZMAGIC) || \ + ((m) == HPUX_MAGIC_SHL) || \ + ((m) == HPUX_MAGIC_DL)) ? \ + (HPUX_LDPGSZ + HPUX_SEGMENT_ROUND((x).ha_text)) : \ + (HPUX_EXEC_HDR_SIZE + (x).ha_text)) + +#define HPUX_PASOFF(x, m) \ + ((((m) == ZMAGIC) || \ + ((m) == HPUX_MAGIC_SHL) || \ + ((m) == HPUX_MAGIC_DL)) ? \ + (HPUX_LDPGSZ + HPUX_SEGMENT_ROUND((x).ha_text) + \ + HPUX_SEGMENT_ROUND((x).ha_data)) : \ + (HPUX_EXEC_HDR_SIZE + (x).ha_text + (x).ha_data)) + +#define HPUX_SYMOFF(x, m) (HPUX_PASOFF((x), (m)) + (x).ha_pascal) +#define HPUX_SUPSYMOFF(x, m) (HPUX_SYMOFF((x), (m)) + (x).ha_symbols) +#define HPUX_RTEXTOFF(x, m) (HPUX_SUPSYMOFF((x), (m)) + (x).ha_supsyms) +#define HPUX_RDATAOFF(x, m) (HPUX_RTEXTOFF((x), (m)) + (x).ha_trsize) +#define HPUX_EXTOFF(x, m) ((x).ha_extentions) + +#define HPUXM_VALID 0x00000001 +#define HPUXM_STKWT 0x02000000 +#define HPUXM_DATAWT 0x04000000 + +int exec_hpux_makecmds(struct proc *, struct exec_package *); + +#endif /* _HPUX_EXEC_H_ */ diff --git a/sys/compat/hpux/m68k/hpux_net.c b/sys/compat/hpux/m68k/hpux_net.c new file mode 100644 index 00000000000..b84d9c4f5c5 --- /dev/null +++ b/sys/compat/hpux/m68k/hpux_net.c @@ -0,0 +1,314 @@ +/* $OpenBSD: hpux_net.c,v 1.1 2004/07/09 21:33:45 mickey Exp $ */ +/* $NetBSD: hpux_net.c,v 1.14 1997/04/01 19:59:02 scottr Exp $ */ + +/* + * Copyright (c) 1988 University of Utah. + * Copyright (c) 1990, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * the Systems Programming Group of the University of Utah Computer + * Science Department. + * + * 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. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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. + * + * from: Utah $Hdr: hpux_net.c 1.8 93/08/02$ + * + * @(#)hpux_net.c 8.2 (Berkeley) 9/9/93 + */ + +/* + * Network related HP-UX compatibility routines + */ + +#include <sys/param.h> +#include <sys/systm.h> +#include <sys/kernel.h> +#include <sys/time.h> +#include <sys/errno.h> +#include <sys/proc.h> +#include <sys/file.h> +#include <sys/filedesc.h> +#include <sys/mbuf.h> +#include <sys/mount.h> +#include <sys/socket.h> +#include <sys/socketvar.h> +#include <sys/uio.h> +#include <sys/ktrace.h> +#include <sys/syscallargs.h> + +#include <compat/hpux/hpux.h> +#include <compat/hpux/hpux_util.h> +#include <compat/hpux/m68k/hpux_syscallargs.h> + +struct hpux_sys_getsockopt_args { + syscallarg(int) s; + syscallarg(int) level; + syscallarg(int) name; + syscallarg(caddr_t) val; + syscallarg(int *) avalsize; +}; + +int hpux_sys_setsockopt2(struct proc *, void *, register_t *); +int hpux_sys_getsockopt(struct proc *, void *, register_t *); + +void socksetsize(int, struct mbuf *); + + +#define MINBSDIPCCODE 0x3EE +#define NUMBSDIPC 32 + +/* + * HPUX netioctl() to BSD syscall map. + * Indexed by callno - MINBSDIPCCODE + */ + +struct hpuxtobsdipc { + int (*rout)(struct proc *, void *, register_t *); + int nargs; +} hpuxtobsdipc[NUMBSDIPC] = { + { sys_socket, 3 }, /* 3ee */ + { sys_listen, 2 }, /* 3ef */ + { sys_bind, 3 }, /* 3f0 */ + { compat_43_sys_accept, 3 }, /* 3f1 */ + { sys_connect, 3 }, /* 3f2 */ + { compat_43_sys_recv, 4 }, /* 3f3 */ + { compat_43_sys_send, 4 }, /* 3f4 */ + { sys_shutdown, 2 }, /* 3f5 */ + { compat_43_sys_getsockname, 3 }, /* 3f6 */ + { hpux_sys_setsockopt2, 5 }, /* 3f7 */ + { sys_sendto, 6 }, /* 3f8 */ + { compat_43_sys_recvfrom, 6 }, /* 3f9 */ + { compat_43_sys_getpeername, 3 }, /* 3fa */ + { NULL, 0 }, /* 3fb */ + { NULL, 0 }, /* 3fc */ + { NULL, 0 }, /* 3fd */ + { NULL, 0 }, /* 3fe */ + { NULL, 0 }, /* 3ff */ + { NULL, 0 }, /* 400 */ + { NULL, 0 }, /* 401 */ + { NULL, 0 }, /* 402 */ + { NULL, 0 }, /* 403 */ + { NULL, 0 }, /* 404 */ + { NULL, 0 }, /* 405 */ + { NULL, 0 }, /* 406 */ + { NULL, 0 }, /* 407 */ + { NULL, 0 }, /* 408 */ + { NULL, 0 }, /* 409 */ + { NULL, 0 }, /* 40a */ + { hpux_sys_getsockopt, 5 }, /* 40b */ + { NULL, 0 }, /* 40c */ + { NULL, 0 }, /* 40d */ +}; + +/* + * Single system call entry to BSD style IPC. + * Gleened from disassembled libbsdipc.a syscall entries. + */ +int +hpux_sys_netioctl(p, v, retval) + struct proc *p; + void *v; + register_t *retval; +{ + struct hpux_sys_netioctl_args *uap = v; + int *args, i; + int code; + int error; + + args = SCARG(uap, args); + code = SCARG(uap, call) - MINBSDIPCCODE; + if (code < 0 || code >= NUMBSDIPC || hpuxtobsdipc[code].rout == NULL) + return (EINVAL); + if ((i = hpuxtobsdipc[code].nargs * sizeof (int)) && + (error = copyin((caddr_t)args, (caddr_t)uap, (u_int)i))) { +#ifdef KTRACE + if (KTRPOINT(p, KTR_SYSCALL)) + ktrsyscall(p, code + MINBSDIPCCODE, + hpuxtobsdipc[code].nargs, + (register_t *)uap); +#endif + return (error); + } +#ifdef KTRACE + if (KTRPOINT(p, KTR_SYSCALL)) + ktrsyscall(p, code + MINBSDIPCCODE, + hpuxtobsdipc[code].nargs, + (register_t *)uap); +#endif + return ((*hpuxtobsdipc[code].rout)(p, uap, retval)); +} + +void +socksetsize(size, m) + int size; + struct mbuf *m; +{ + int tmp; + + if (size < sizeof(int)) { + switch(size) { + case 1: + tmp = (int) *mtod(m, char *); + break; + case 2: + tmp = (int) *mtod(m, short *); + break; + case 3: + default: /* XXX uh, what if sizeof(int) > 4? */ + tmp = (((int) *mtod(m, int *)) >> 8) & 0xffffff; + break; + } + *mtod(m, int *) = tmp; + m->m_len = sizeof(int); + } else { + m->m_len = size; + } +} + +/* ARGSUSED */ +int +hpux_sys_setsockopt2(p, v, retval) + struct proc *p; + void *v; + register_t *retval; +{ + struct hpux_sys_setsockopt_args *uap = v; + struct file *fp; + struct mbuf *m = NULL; + int tmp, error; + + if ((error = getsock(p->p_fd, SCARG(uap, s), &fp))) + return (error); + if (SCARG(uap, valsize) > MLEN) { + error = EINVAL; + goto bad; + } + if (SCARG(uap, val)) { + m = m_get(M_WAIT, MT_SOOPTS); + if ((error = copyin(SCARG(uap, val), mtod(m, caddr_t), + (u_int)SCARG(uap, valsize)))) { + (void) m_free(m); + goto bad; + } + if (SCARG(uap, name) == SO_LINGER) { + tmp = *mtod(m, int *); + mtod(m, struct linger *)->l_onoff = 1; + mtod(m, struct linger *)->l_linger = tmp; + m->m_len = sizeof(struct linger); + } else + socksetsize(SCARG(uap, valsize), m); + } else if (SCARG(uap, name) == ~SO_LINGER) { + m = m_get(M_WAIT, MT_SOOPTS); + SCARG(uap, name) = SO_LINGER; + mtod(m, struct linger *)->l_onoff = 0; + m->m_len = sizeof(struct linger); + } + error = sosetopt((struct socket *)fp->f_data, SCARG(uap, level), + SCARG(uap, name), m); +bad: + FRELE(fp); + return (error); +} + +/* ARGSUSED */ +int +hpux_sys_setsockopt(p, v, retval) + struct proc *p; + void *v; + register_t *retval; +{ + struct hpux_sys_setsockopt_args *uap = v; + struct file *fp; + struct mbuf *m = NULL; + int error; + + if ((error = getsock(p->p_fd, SCARG(uap, s), &fp))) + return (error); + if (SCARG(uap, valsize) > MLEN) { + error = EINVAL; + goto bad; + } + if (SCARG(uap, val)) { + m = m_get(M_WAIT, MT_SOOPTS); + if ((error = copyin(SCARG(uap, val), mtod(m, caddr_t), + (u_int)SCARG(uap, valsize)))) { + m_free(m); + goto bad; + } + socksetsize(SCARG(uap, valsize), m); + } + error = sosetopt((struct socket *)fp->f_data, SCARG(uap, level), + SCARG(uap, name), m); +bad: + FRELE(fp); + return (error); +} + +int +hpux_sys_getsockopt(p, v, retval) + struct proc *p; + void *v; + register_t *retval; +{ + struct hpux_sys_getsockopt_args *uap = v; + struct file *fp; + struct mbuf *m = NULL; + int valsize, error; + + if ((error = getsock(p->p_fd, SCARG(uap, s), &fp))) + return (error); + if (SCARG(uap, val)) { + if ((error = copyin((caddr_t)SCARG(uap, avalsize), + (caddr_t)&valsize, sizeof (valsize)))) { + goto bad; + } + } else + valsize = 0; + if ((error = sogetopt((struct socket *)fp->f_data, SCARG(uap, level), + SCARG(uap, name), &m))) + goto bad; + if (SCARG(uap, val) && valsize && m != NULL) { + if (SCARG(uap, name) == SO_LINGER) { + if (mtod(m, struct linger *)->l_onoff) + *mtod(m, int *) = mtod(m, struct linger *)->l_linger; + else + *mtod(m, int *) = 0; + m->m_len = sizeof(int); + } + if (valsize > m->m_len) + valsize = m->m_len; + error = copyout(mtod(m, caddr_t), SCARG(uap, val), + (u_int)valsize); + if (error == 0) + error = copyout((caddr_t)&valsize, + (caddr_t)SCARG(uap, avalsize), sizeof (valsize)); + } +bad: + FRELE(fp); + if (m != NULL) + m_free(m); + return (error); +} diff --git a/sys/compat/hpux/m68k/hpux_sig.c b/sys/compat/hpux/m68k/hpux_sig.c new file mode 100644 index 00000000000..1cce337a533 --- /dev/null +++ b/sys/compat/hpux/m68k/hpux_sig.c @@ -0,0 +1,442 @@ +/* $OpenBSD: hpux_sig.c,v 1.1 2004/07/09 21:33:45 mickey Exp $ */ +/* $NetBSD: hpux_sig.c,v 1.16 1997/04/01 19:59:02 scottr Exp $ */ + +/* + * Copyright (c) 1988 University of Utah. + * Copyright (c) 1990, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * the Systems Programming Group of the University of Utah Computer + * Science Department. + * + * 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. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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. + * + * from: Utah $Hdr: hpux_sig.c 1.4 92/01/20$ + * + * @(#)hpux_sig.c 8.2 (Berkeley) 9/23/93 + */ + +/* + * Signal related HPUX compatibility routines + */ + +#include <sys/param.h> +#include <sys/systm.h> +#include <sys/kernel.h> +#include <sys/mount.h> +#include <sys/proc.h> +#include <sys/signalvar.h> +#include <sys/syscallargs.h> + +#include <compat/hpux/hpux.h> +#include <compat/hpux/hpux_sig.h> +#include <compat/hpux/m68k/hpux_syscallargs.h> + +/* indexed by HPUX signal number - 1 */ +char hpuxtobsdsigmap[NSIG] = { +/*01*/ SIGHUP, SIGINT, SIGQUIT, SIGILL, SIGTRAP, SIGIOT, SIGEMT, SIGFPE, +/*09*/ SIGKILL, SIGBUS, SIGSEGV, SIGSYS, SIGPIPE, SIGALRM, SIGTERM, SIGUSR1, +/*17*/ SIGUSR2, SIGCHLD, 0, SIGVTALRM,SIGPROF, SIGIO, SIGWINCH, SIGSTOP, +/*25*/ SIGTSTP, SIGCONT,SIGTTIN, SIGTTOU, SIGURG, 0, 0, 0 +}; + +/* indexed by BSD signal number - 1 */ +char bsdtohpuxsigmap[NSIG] = { +/*01*/ 1, 2, 3, 4, 5, 6, 7, 8, +/*09*/ 9, 10, 11, 12, 13, 14, 15, 29, +/*17*/ 24, 25, 26, 18, 27, 28, 22, 0, +/*25*/ 0, 20, 21, 23, 0, 16, 17, 0 +}; + +/* + * XXX: In addition to mapping the signal number we also have + * to see if the "old" style signal mechinism is needed. + * If so, we set the OUSIG flag. This is not really correct + * as under HP-UX "old" style handling can be set on a per + * signal basis and we are setting it for all signals in one + * swell foop. I suspect we can get away with this since I + * doubt any program of interest mixes the two semantics. + */ +int +hpux_sys_sigvec(p, v, retval) + struct proc *p; + void *v; + register_t *retval; +{ + struct hpux_sys_sigvec_args *uap = v; + struct sigvec vec; + struct sigacts *ps = p->p_sigacts; + struct sigvec *sv; + int sig; + int bit, error; + + sig = hpuxtobsdsig(SCARG(uap, signo)); + if (sig <= 0 || sig >= NSIG || sig == SIGKILL || sig == SIGSTOP) + return (EINVAL); + sv = &vec; + if (SCARG(uap, osv)) { + sv->sv_handler = ps->ps_sigact[sig]; + sv->sv_mask = ps->ps_catchmask[sig]; + bit = sigmask(sig); + sv->sv_flags = 0; + if ((ps->ps_sigonstack & bit) != 0) + sv->sv_flags |= SV_ONSTACK; + if ((ps->ps_sigintr & bit) != 0) + sv->sv_flags |= SV_INTERRUPT; + if ((ps->ps_sigreset & bit) != 0) + sv->sv_flags |= HPUXSV_RESET; + sv->sv_mask &= ~bit; + error = copyout((caddr_t)sv, (caddr_t)SCARG(uap, osv), + sizeof (vec)); + if (error) + return (error); + } + if (SCARG(uap, nsv)) { + error = copyin((caddr_t)SCARG(uap, nsv), (caddr_t)sv, + sizeof (vec)); + if (error) + return (error); + if (sig == SIGCONT && sv->sv_handler == SIG_IGN) + return (EINVAL); + sv->sv_flags ^= SA_RESTART; + setsigvec(p, sig, (struct sigaction *)sv); +#if 0 +/* XXX -- SOUSIG no longer exists, do something here */ + if (sv->sv_flags & HPUXSV_RESET) + p->p_flag |= SOUSIG; /* XXX */ +#endif + } + return (0); +} + +int +hpux_sys_sigblock(p, v, retval) + struct proc *p; + void *v; + register_t *retval; +{ + struct hpux_sys_sigblock_args *uap = v; + + (void) splhigh(); + *retval = bsdtohpuxmask(p->p_sigmask); + p->p_sigmask |= hpuxtobsdmask(SCARG(uap, mask)) &~ sigcantmask; + (void) spl0(); + return (0); +} + +int +hpux_sys_sigsetmask(p, v, retval) + struct proc *p; + void *v; + register_t *retval; +{ + struct hpux_sys_sigsetmask_args *uap = v; + + (void) splhigh(); + *retval = bsdtohpuxmask(p->p_sigmask); + p->p_sigmask = hpuxtobsdmask(SCARG(uap, mask)) &~ sigcantmask; + (void) spl0(); + return (0); +} + +int +hpux_sys_sigpause(p, v, retval) + struct proc *p; + void *v; + register_t *retval; +{ + struct hpux_sys_sigpause_args *uap = v; + + SCARG(uap, mask) = hpuxtobsdmask(SCARG(uap, mask)); + return (sys_sigsuspend(p, uap, retval)); +} + +/* not totally correct, but close enuf' */ +int +hpux_sys_kill(p, v, retval) + struct proc *p; + void *v; + register_t *retval; +{ + struct hpux_sys_kill_args *uap = v; + + if (SCARG(uap, signo)) { + SCARG(uap, signo) = hpuxtobsdsig(SCARG(uap, signo)); + if (SCARG(uap, signo) == 0) + SCARG(uap, signo) = NSIG; + } + return (sys_kill(p, uap, retval)); +} + +/* + * The following (sigprocmask, sigpending, sigsuspend, sigaction are + * POSIX calls. Under BSD, the library routine dereferences the sigset_t + * pointers before traping. Not so under HP-UX. + */ + +/* + * Manipulate signal mask. + * Note that we receive new mask, not pointer, + * and return old mask as return value; + * the library stub does the rest. + */ +int +hpux_sys_sigprocmask(p, v, retval) + struct proc *p; + void *v; + register_t *retval; +{ + struct hpux_sys_sigprocmask_args *uap = v; + int mask, error = 0; + hpux_sigset_t sigset; + + /* + * Copy out old mask first to ensure no errors. + * (proc sigmask should not be changed if call fails for any reason) + */ + if (SCARG(uap, oset)) { + bzero((caddr_t)&sigset, sizeof(sigset)); + sigset.sigset[0] = bsdtohpuxmask(p->p_sigmask); + if (copyout((caddr_t)&sigset, (caddr_t)SCARG(uap, oset), + sizeof(sigset))) + return (EFAULT); + } + if (SCARG(uap, set)) { + if (copyin((caddr_t)SCARG(uap, set), (caddr_t)&sigset, + sizeof(sigset))) + return (EFAULT); + mask = hpuxtobsdmask(sigset.sigset[0]); + (void) splhigh(); + switch (SCARG(uap, how)) { + case HPUXSIG_BLOCK: + p->p_sigmask |= mask &~ sigcantmask; + break; + case HPUXSIG_UNBLOCK: + p->p_sigmask &= ~mask; + break; + case HPUXSIG_SETMASK: + p->p_sigmask = mask &~ sigcantmask; + break; + default: + error = EINVAL; + break; + } + (void) spl0(); + } + return (error); +} + +int +hpux_sys_sigpending(p, v, retval) + struct proc *p; + void *v; + register_t *retval; +{ + struct hpux_sys_sigpending_args *uap = v; + hpux_sigset_t sigset; + + sigset.sigset[0] = bsdtohpuxmask(p->p_siglist); + return (copyout((caddr_t)&sigset, (caddr_t)SCARG(uap, set), + sizeof(sigset))); +} + +int +hpux_sys_sigsuspend(p, v, retval) + struct proc *p; + void *v; + register_t *retval; +{ + struct hpux_sys_sigsuspend_args *uap = v; + struct sigacts *ps = p->p_sigacts; + hpux_sigset_t sigset; + int mask; + + if (copyin((caddr_t)SCARG(uap, set), (caddr_t)&sigset, sizeof(sigset))) + return (EFAULT); + mask = hpuxtobsdmask(sigset.sigset[0]); + ps->ps_oldmask = p->p_sigmask; + ps->ps_flags |= SAS_OLDMASK; + p->p_sigmask = mask &~ sigcantmask; + (void) tsleep((caddr_t)ps, PPAUSE | PCATCH, "pause", 0); + /* always return EINTR rather than ERESTART... */ + return (EINTR); +} + +int +hpux_sys_sigaction(p, v, retval) + struct proc *p; + void *v; + register_t *retval; +{ + struct hpux_sys_sigaction_args *uap = v; + struct hpux_sigaction action; + struct sigacts *ps = p->p_sigacts; + struct hpux_sigaction *sa; + int sig; + int bit; + + sig = hpuxtobsdsig(SCARG(uap, signo)); + if (sig <= 0 || sig >= NSIG || sig == SIGKILL || sig == SIGSTOP) + return (EINVAL); + + sa = &action; + if (SCARG(uap, osa)) { + sa->sa__handler = ps->ps_sigact[sig]; + bzero((caddr_t)&sa->sa_mask, sizeof(sa->sa_mask)); + sa->sa_mask.sigset[0] = bsdtohpuxmask(ps->ps_catchmask[sig]); + bit = sigmask(sig); + sa->sa_flags = 0; + if ((ps->ps_sigonstack & bit) != 0) + sa->sa_flags |= HPUXSA_ONSTACK; + if ((ps->ps_sigreset & bit) != 0) + sa->sa_flags |= HPUXSA_RESETHAND; + if (p->p_flag & P_NOCLDSTOP) + sa->sa_flags |= HPUXSA_NOCLDSTOP; + if (p->p_flag & P_NOCLDWAIT) + sa->sa_flags |= HPUXSA_NOCLDWAIT; + if (copyout((caddr_t)sa, (caddr_t)SCARG(uap, osa), + sizeof (action))) + return (EFAULT); + } + if (SCARG(uap, nsa)) { + struct sigaction act; + + if (copyin((caddr_t)SCARG(uap, nsa), (caddr_t)sa, + sizeof (action))) + return (EFAULT); + if (sig == SIGCONT && sa->sa__handler == SIG_IGN) + return (EINVAL); + /* + * Create a sigaction struct for setsigvec + */ + act.sa_handler = sa->sa__handler; + act.sa_mask = hpuxtobsdmask(sa->sa_mask.sigset[0]); + act.sa_flags = SA_RESTART; + if (sa->sa_flags & HPUXSA_ONSTACK) + act.sa_flags |= SA_ONSTACK; + if (sa->sa_flags & HPUXSA_NOCLDSTOP) + act.sa_flags |= SA_NOCLDSTOP; + if (sa->sa_flags & HPUXSA_NOCLDWAIT) + act.sa_flags |= SA_NOCLDWAIT; + setsigvec(p, sig, &act); +#if 0 +/* XXX -- SOUSIG no longer exists, do something here */ + if (sa->sa_flags & HPUXSA_RESETHAND) + p->p_flag |= SOUSIG; /* XXX */ +#endif + } + return (0); +} + +int +hpux_sys_ssig_6x(p, v, retval) + struct proc *p; + void *v; + register_t *retval; +{ + struct hpux_sys_ssig_6x_args /* { + syscallarg(int) signo; + syscallarg(sig_t) fun; + } */ *uap = v; + int a; + struct sigaction vec; + struct sigaction *sa = &vec; + + a = hpuxtobsdsig(SCARG(uap, signo)); + sa->sa_handler = SCARG(uap, fun); + /* + * Kill processes trying to use job control facilities + * (this'll help us find any vestiges of the old stuff). + */ + if ((a &~ 0377) || + (sa->sa_handler != SIG_DFL && sa->sa_handler != SIG_IGN && + ((int)sa->sa_handler) & 1)) { + psignal(p, SIGSYS); + return (0); + } + if (a <= 0 || a >= NSIG || a == SIGKILL || a == SIGSTOP || + (a == SIGCONT && sa->sa_handler == SIG_IGN)) + return (EINVAL); + sa->sa_mask = 0; + sa->sa_flags = 0; + *retval = (int)p->p_sigacts->ps_sigact[a]; + setsigvec(p, a, sa); +#if 0 + p->p_flag |= SOUSIG; /* mark as simulating old stuff */ +#endif + return (0); +} + +/* signal numbers: convert from HPUX to BSD */ +int +hpuxtobsdsig(sig) + int sig; +{ + if (--sig < 0 || sig >= NSIG) + return(0); + return((int)hpuxtobsdsigmap[sig]); +} + +/* signal numbers: convert from BSD to HPUX */ +int +bsdtohpuxsig(sig) + int sig; +{ + if (--sig < 0 || sig >= NSIG) + return(0); + return((int)bsdtohpuxsigmap[sig]); +} + +/* signal masks: convert from HPUX to BSD (not pretty or fast) */ +int +hpuxtobsdmask(mask) + int mask; +{ + int nmask, sig, nsig; + + if (mask == 0 || mask == -1) + return(mask); + nmask = 0; + for (sig = 1; sig < NSIG; sig++) + if ((mask & sigmask(sig)) && (nsig = hpuxtobsdsig(sig))) + nmask |= sigmask(nsig); + return(nmask); +} + +int +bsdtohpuxmask(mask) + int mask; +{ + int nmask, sig, nsig; + + if (mask == 0 || mask == -1) + return(mask); + nmask = 0; + for (sig = 1; sig < NSIG; sig++) + if ((mask & sigmask(sig)) && (nsig = bsdtohpuxsig(sig))) + nmask |= sigmask(nsig); + return(nmask); +} diff --git a/sys/compat/hpux/m68k/syscalls.conf b/sys/compat/hpux/m68k/syscalls.conf new file mode 100644 index 00000000000..73a5090d7d6 --- /dev/null +++ b/sys/compat/hpux/m68k/syscalls.conf @@ -0,0 +1,13 @@ +# $OpenBSD: syscalls.conf,v 1.1 2004/07/09 21:33:45 mickey Exp $ +# $NetBSD: syscalls.conf,v 1.2 1995/11/28 08:39:54 thorpej Exp $ + +sysnames="hpux_syscalls.c" +sysnumhdr="hpux_syscall.h" +syssw="hpux_sysent.c" +sysarghdr="hpux_syscallargs.h" +compatopts="" +libcompatopts="" + +switchname="hpux_sysent" +namesname="hpux_syscallnames" +constprefix="HPUX_SYS_" diff --git a/sys/compat/hpux/m68k/syscalls.master b/sys/compat/hpux/m68k/syscalls.master new file mode 100644 index 00000000000..dc576ad1bbe --- /dev/null +++ b/sys/compat/hpux/m68k/syscalls.master @@ -0,0 +1,464 @@ + $OpenBSD: syscalls.master,v 1.1 2004/07/09 21:33:45 mickey Exp $ +; $NetBSD: syscalls.master,v 1.13 1997/03/16 03:48:04 thorpej Exp $ + +; @(#)syscalls.master 8.1 (Berkeley) 7/19/93 + +; OpenBSD COMPAT_HPUX system call name/number "master" file. +; (See syscalls.conf to see what it is processed into.) +; +; Fields: number type [type-dependent ...] +; number system call number, must be in order +; type one of STD, OBSOL, UNIMPL, NODEF, NOARGS, or one of +; the compatibility options defined in syscalls.conf. +; +; types: +; STD always included +; OBSOL obsolete, not included in system +; UNIMPL unimplemented, not included in system +; NODEF included, but don't define the syscall number +; NOARGS included, but don't define the syscall args structure +; +; The compat options are defined in the syscalls.conf file, and the +; compat option name is prefixed to the syscall name. Other than +; that, they're like NODEF (for 'compat' options), or STD (for +; 'libcompat' options). +; +; The type-dependent arguments are as follows: +; For STD, NODEF, NOARGS, and compat syscalls: +; { pseudo-proto } [alias] +; For other syscalls: +; [comment] +; +; #ifdef's, etc. may be included, and are copied to the output files. +; #include's are copied to the syscall switch definition file only. + +#include <sys/param.h> +#include <sys/systm.h> +#include <sys/signal.h> +#include <sys/mount.h> +#include <sys/exec.h> +#include <sys/syscallargs.h> + +#include <compat/hpux/hpux.h> +#include <compat/hpux/m68k/hpux_syscallargs.h> + +#include <machine/hpux_machdep.h> + +0 NOARGS { int sys_nosys(void); } syscall +1 NOARGS { int sys_exit(int rval); } +2 STD { int hpux_sys_fork(void); } +3 STD { int hpux_sys_read(int fd, char *buf, u_int nbyte); } +4 STD { int hpux_sys_write(int fd, char *buf, u_int nbyte); } +5 STD { int hpux_sys_open(char *path, int flags, int mode); } +6 NOARGS { int sys_close(int fd); } +7 STD { int hpux_sys_wait(int *status); } +8 STD { int hpux_sys_creat(char *path, int mode); } +9 NOARGS { int sys_link(char *path, char *link); } +10 STD { int hpux_sys_unlink(char *path); } +11 STD { int hpux_sys_execv(char * path, char * * argp); } +12 STD { int hpux_sys_chdir(char *path); } +13 STD { int hpux_sys_time_6x(time_t *t); } +14 STD { int hpux_sys_mknod(char *path, int mode, int dev); } +15 STD { int hpux_sys_chmod(char *path, int mode); } +16 STD { int hpux_sys_chown(char *path, int uid, int gid); } +17 NOARGS { int sys_obreak(char *nsize); } +18 STD { int hpux_sys_stat_6x(char *path, \ + struct hpux_ostat *sb); } +19 NOARGS { long compat_43_sys_lseek(int fd, long offset, \ + int whence); } +20 NOARGS { pid_t sys_getpid(void); } +21 UNIMPL mount +22 UNIMPL umount +23 NOARGS { int sys_setuid(uid_t uid); } +24 NOARGS { uid_t sys_getuid(void); } +25 STD { int hpux_sys_stime_6x(int time); } +#ifdef PTRACE +26 STD { int hpux_sys_ptrace(int req, int pid, int *addr, \ + int data); } +#else +26 UNIMPL ptrace +#endif +27 STD { int hpux_sys_alarm_6x(int deltat); } +28 STD { int hpux_sys_fstat_6x(int fd, \ + struct hpux_ostat *sb); } +29 STD { int hpux_sys_pause_6x(void); } +30 STD { int hpux_sys_utime_6x(char *fname, time_t *tptr); } +31 STD { int hpux_sys_stty_6x(int fd, caddr_t arg); } +32 STD { int hpux_sys_gtty_6x(int fd, caddr_t arg); } +33 STD { int hpux_sys_access(char *path, int flags); } +34 STD { int hpux_sys_nice_6x(int nval); } +35 STD { int hpux_sys_ftime_6x(struct hpux_timeb *tp); } +36 NOARGS { int sys_sync(void); } +37 STD { int hpux_sys_kill(pid_t pid, int signo); } +38 STD { int hpux_sys_stat(char *path, struct hpux_stat *sb); } +39 STD { int hpux_sys_setpgrp_6x(void); } +40 STD { int hpux_sys_lstat(char *path, struct hpux_stat *sb); } +41 NOARGS { int sys_dup(int fd); } +42 NOARGS { int sys_opipe(void); } +43 STD { int hpux_sys_times_6x(struct tms *tms); } +44 NOARGS { int sys_profil(caddr_t samples, u_int size, \ + u_int offset, u_int scale); } + +45 UNIMPL ki_syscall +46 NOARGS { int sys_setgid(gid_t gid); } +47 NOARGS { gid_t sys_getgid(void); } +48 STD { int hpux_sys_ssig_6x(int signo, sig_t fun); } +49 UNIMPL reserved for USG +50 UNIMPL reserved for USG +51 UNIMPL acct +52 UNIMPL +53 UNIMPL +54 STD { int hpux_sys_ioctl(int fd, int com, caddr_t data); } +55 UNIMPL reboot +56 STD { int hpux_sys_symlink(char *path, char *link); } +57 STD { int hpux_sys_utssys(struct hpux_utsname *uts, \ + int dev, int request); } +58 STD { int hpux_sys_readlink(char *path, char *buf, \ + int count); } +59 STD { int hpux_sys_execve(char *path, char **argp, \ + char **envp); } +60 NOARGS { int sys_umask(int newmask); } +61 NOARGS { int sys_chroot(char *path); } +62 STD { int hpux_sys_fcntl(int fd, int cmd, int arg); } +63 STD { int hpux_sys_ulimit(int cmd, int newlimit); } +64 UNIMPL +65 UNIMPL +66 STD { int hpux_sys_vfork(void); } +67 NOARGS { int hpux_sys_read(int fd, char *buf, u_int nbyte); } vread +68 NOARGS { int hpux_sys_write(int fd, char *buf, u_int nbyte); } vwrite +69 UNIMPL +70 UNIMPL +71 STD { int hpux_sys_mmap(caddr_t addr, size_t len, \ + int prot, int flags, int fd, long pos); } +72 UNIMPL +73 NOARGS { int sys_munmap(caddr_t addr, size_t len); } +74 NOARGS { int sys_mprotect(caddr_t addr, size_t len, \ + int prot); } +75 UNIMPL +76 UNIMPL +77 UNIMPL +78 UNIMPL +79 NOARGS { int sys_getgroups(u_int gidsetsize, gid_t *gidset); } +80 NOARGS { int sys_setgroups(u_int gidsetsize, gid_t *gidset); } +81 STD { int hpux_sys_getpgrp2(pid_t pid); } +82 STD { int hpux_sys_setpgrp2(pid_t pid, pid_t pgid); } +83 NOARGS { int sys_setitimer(u_int which, \ + struct itimerval *itv, struct itimerval *oitv); } +84 STD { int hpux_sys_wait3(int *status, int options, \ + int rusage); } +85 UNIMPL swapon +86 NOARGS { int sys_getitimer(u_int which, \ + struct itimerval *itv); } +87 UNIMPL +88 UNIMPL +89 UNIMPL +90 NOARGS { int sys_dup2(u_int from, u_int to); } +91 UNIMPL +92 STD { int hpux_sys_fstat(int fd, struct hpux_stat *sb); } +93 NOARGS { int sys_select(u_int nd, fd_set *in, fd_set *ou, \ + fd_set *ex, struct timeval *tv); } +94 UNIMPL +95 NOARGS { int sys_fsync(int fd); } +96 UNIMPL +97 UNIMPL +98 UNIMPL +99 UNIMPL +100 UNIMPL +101 UNIMPL +102 UNIMPL +103 STD { int hpux_sys_sigreturn(struct hpuxsigcontext \ + *sigcntxp); } +104 UNIMPL +105 UNIMPL +106 UNIMPL +107 UNIMPL +108 STD { int hpux_sys_sigvec(int signo, struct sigvec *nsv, \ + struct sigvec *osv); } +109 STD { int hpux_sys_sigblock(int mask); } +110 STD { int hpux_sys_sigsetmask(int mask); } +111 STD { int hpux_sys_sigpause(int mask); } +112 NOARGS { int compat_43_sys_sigstack(struct sigstack *nss, \ + struct sigstack *oss); } +113 UNIMPL +114 UNIMPL +115 UNIMPL +116 NOARGS { int sys_gettimeofday(struct timeval *tp); } +117 UNIMPL +118 UNIMPL +119 UNIMPL io_stub +120 STD { int hpux_sys_readv(int fd, struct iovec *iovp, \ + u_int iovcnt); } +121 STD { int hpux_sys_writev(int fd, struct iovec *iovp, \ + u_int iovcnt); } +122 NOARGS { int sys_settimeofday(struct timeval *tv, \ + struct timezone *tzp); } +123 NOARGS { int sys_fchown(int fd, int uid, int gid); } +124 NOARGS { int sys_fchmod(int fd, int mode); } +125 UNIMPL +126 NOARGS { int sys_setresuid(uid_t ruid, uid_t uide, \ + uid_t suid); } +127 NOARGS { int sys_setresgid(gid_t rgid, gid_t egid, \ + gid_t sgid); } +128 STD { int hpux_sys_rename(char *from, char *to); } +129 STD { int hpux_sys_truncate(char *path, long length); } +130 NOARGS { int compat_43_sys_ftruncate(int fd, long length); } +131 UNIMPL +132 STD { int hpux_sys_sysconf(int name); } +133 UNIMPL +134 UNIMPL +135 UNIMPL +136 STD { int hpux_sys_mkdir(char *path, int mode); } +137 STD { int hpux_sys_rmdir(char *path); } +138 UNIMPL +139 UNIMPL +140 UNIMPL +141 UNIMPL +142 UNIMPL +143 UNIMPL +144 STD { int hpux_sys_getrlimit(u_int which, \ + struct ogetrlimit *rlp); } +145 STD { int hpux_sys_setrlimit(u_int which, \ + struct ogetrlimit *rlp); } +146 UNIMPL +147 UNIMPL +148 UNIMPL +149 UNIMPL +150 UNIMPL +151 UNIMPL privgrp +152 STD { int hpux_sys_rtprio(pid_t pid, int prio); } +153 UNIMPL plock +154 STD { int hpux_sys_netioctl(int call, int *args); } +155 STD { int hpux_sys_lockf(int fd, int func, long size); } +#ifdef SYSVSEM +156 NOARGS { int sys_semget(key_t key, int nsems, int semflg); } +157 NOARGS { int sys___semctl(int semid, int semnum, int cmd, \ + union semun *arg); } +158 NOARGS { int sys_semop(int semid, struct sembuf *sops, \ + u_int nsops); } +#else +156 UNIMPL semget +157 UNIMPL semctl +158 UNIMPL semop +#endif +#ifdef SYSVMSG +159 NOARGS { int sys_msgget(key_t key, int msgflg); } +160 NOARGS { int sys_msgctl(int msqid, int cmd, \ + struct msqid_ds *buf); } +161 NOARGS { int sys_msgsnd(int msqid, void *msgp, size_t msgsz, \ + int msgflg); } +162 NOARGS { int sys_msgrcv(int msqid, void *msgp, size_t msgsz, \ + long msgtyp, int msgflg); } +#else +159 UNIMPL msgget +160 UNIMPL msgctl +161 UNIMPL msgsnd +162 UNIMPL msgrcv +#endif +#ifdef SYSVSHM +163 NOARGS { int sys_shmget(key_t key, int size, int shmflg); } +164 STD { int hpux_sys_shmctl(int shmid, int cmd, \ + caddr_t buf); } +165 NOARGS { int sys_shmat(int shmid, void *shmaddr, int shmflg); } +166 NOARGS { int sys_shmdt(void *shmaddr); } +#else +163 UNIMPL shmget +164 UNIMPL shmctl +165 UNIMPL shmat +166 UNIMPL shmdt +#endif +167 STD { int hpux_sys_advise(int arg); } +168 UNIMPL nsp_init +169 UNIMPL cluster +170 UNIMPL mkrnod +171 UNIMPL +172 UNIMPL unsp_open +173 UNIMPL +174 STD { int hpux_sys_getcontext(char *buf, int len); } +175 UNIMPL setcontext +176 UNIMPL bigio +177 UNIMPL pipenode +178 UNIMPL lsync +179 UNIMPL getmachineid +180 UNIMPL mysite +181 UNIMPL sitels +182 UNIMPL swapclients +183 UNIMPL rmtprocess +184 UNIMPL dskless_stats +185 UNIMPL +186 UNIMPL setacl +187 UNIMPL fsetacl +188 UNIMPL getacl +189 UNIMPL fgetacl +190 STD { int hpux_sys_getaccess(char *path, uid_t uid, \ + int ngroups, gid_t *gidset, void *label, \ + void *privs); } +191 UNIMPL getaudid +192 UNIMPL setaudid +193 UNIMPL getaudproc +194 UNIMPL setaudproc +195 UNIMPL getevent +196 UNIMPL setevent +197 UNIMPL audwrite +198 UNIMPL audswitch +199 UNIMPL audctl +200 STD { int hpux_sys_waitpid(pid_t pid, int *status, \ + int options, struct rusage *rusage); } +201 UNIMPL +202 UNIMPL +203 UNIMPL +204 UNIMPL +205 UNIMPL +206 UNIMPL +207 UNIMPL +208 UNIMPL +209 UNIMPL +210 UNIMPL +211 UNIMPL +212 UNIMPL +213 UNIMPL +214 UNIMPL +215 UNIMPL +216 UNIMPL +217 UNIMPL +218 UNIMPL +219 UNIMPL +220 UNIMPL +221 UNIMPL +222 UNIMPL +223 UNIMPL +224 UNIMPL set_no_trunc +225 NOARGS { int sys_pathconf(char *path, int name); } +226 NOARGS { int sys_fpathconf(int fd, int name); } +227 UNIMPL +228 UNIMPL +229 UNIMPL async_daemon +230 UNIMPL nfs_fcntl +231 NOARGS { int compat_43_sys_getdirentries(int fd, char *buf, \ + u_int count, long *basep); } +232 NOARGS { int compat_09_sys_getdomainname(char *domainname, \ + int len); } +233 UNIMPL nfs_getfh +234 UNIMPL vfsmount +235 UNIMPL nfs_svc +236 NOARGS { int compat_09_sys_setdomainname(char *domainname, \ + int len); } +237 UNIMPL statfs +238 UNIMPL fstatfs +239 STD { int hpux_sys_sigaction(int signo, \ + struct hpux_sigaction *nsa, \ + struct hpux_sigaction *osa); } +240 STD { int hpux_sys_sigprocmask(int how, \ + hpux_sigset_t *set, hpux_sigset_t *oset); } +241 STD { int hpux_sys_sigpending(hpux_sigset_t *set); } +242 STD { int hpux_sys_sigsuspend(hpux_sigset_t *set); } +243 UNIMPL fsctl +244 UNIMPL +245 UNIMPL pstat +246 UNIMPL +247 UNIMPL +248 UNIMPL +249 UNIMPL +250 UNIMPL +251 UNIMPL ulconnect +252 UNIMPL ulcontrol +253 UNIMPL ulcreate +254 UNIMPL uldest +255 UNIMPL ulrecv +256 UNIMPL ulrecvcn +257 UNIMPL ulsend +258 UNIMPL ulshutdown +259 UNIMPL swapfs +260 UNIMPL +261 UNIMPL +262 UNIMPL +263 UNIMPL +264 UNIMPL +265 UNIMPL +266 UNIMPL +267 UNIMPL tsync +268 NOARGS { int compat_43_sys_getdtablesize(void); } +269 NOARGS { int sys_poll(struct pollfd *fds, u_int nfds, \ + int timeout); } +270 UNIMPL getmsg +271 UNIMPL putmsg +272 NOARGS { int sys_fchdir(int fd); } +273 UNIMPL getmount_cnt +274 UNIMPL getmount_entry +275 NOARGS { int compat_43_sys_accept(int s, caddr_t name, \ + int *anamelen); } +276 NOARGS { int sys_bind(int s, caddr_t name, int namelen); } +277 NOARGS { int sys_connect(int s, caddr_t name, int namelen); } +278 NOARGS { int compat_43_sys_getpeername(int fdes, caddr_t asa, \ + int *alen); } +279 NOARGS { int compat_43_sys_getsockname(int fdec, caddr_t asa, \ + int *alen); } +280 NOARGS { int sys_getsockopt(int s, int level, int name, \ + caddr_t val, int *avalsize); } +281 NOARGS { int sys_listen(int s, int backlog); } +282 NOARGS { int compat_43_sys_recv(int s, caddr_t buf, int len, \ + int flags); } +283 NOARGS { int compat_43_sys_recvfrom(int s, caddr_t buf, \ + size_t len, int flags, caddr_t from, \ + int *fromlenaddr); } +284 NOARGS { int compat_43_sys_recvmsg(int s, \ + struct omsghdr *msg, int flags); } +285 NOARGS { int compat_43_sys_send(int s, caddr_t buf, int len, \ + int flags); } +286 NOARGS { int compat_43_sys_sendmsg(int s, caddr_t msg, \ + int flags); } +287 NOARGS { int sys_sendto(int s, caddr_t buf, size_t len, \ + int flags, caddr_t to, int tolen); } +288 STD { int hpux_sys_setsockopt(int s, int level, int name, \ + caddr_t val, int valsize); } +289 NOARGS { int sys_shutdown(int s, int how); } +290 NOARGS { int sys_socket(int domain, int type, int protocol); } +291 NOARGS { int sys_socketpair(int domain, int type, \ + int protocol, int *rsv); } +292 UNIMPL +293 UNIMPL +294 UNIMPL +295 UNIMPL +296 UNIMPL +297 UNIMPL +298 UNIMPL ipccreate +299 UNIMPL ipcname +300 UNIMPL ipcnamerase +301 UNIMPL ipclookup +302 UNIMPL ipcselect +303 UNIMPL ipcconnect +304 UNIMPL ipcrecvcn +305 UNIMPL ipcsend +306 UNIMPL ipcrecv +307 UNIMPL ipcgetnodename +308 UNIMPL ipcsetnodename +309 UNIMPL ipcontrol +310 UNIMPL ipcshutdown +311 UNIMPL ipcdest +#ifdef SYSVSEM +312 NOARGS { int sys___semctl(int semid, int semnum, int cmd, \ + union semun *arg); } nsemctl +#else +312 UNIMPL semctl +#endif +#ifdef SYSVMSG +313 NOARGS { int sys_msgctl(int msqid, int cmd, \ + struct msqid_ds *buf); } nmsgctl +#else +313 UNIMPL msgctl +#endif +#ifdef SYSVSHM +314 STD { int hpux_sys_nshmctl(int shmid, int cmd, \ + caddr_t buf); } +#else +314 UNIMPL shmctl +#endif +315 UNIMPL mpctl +316 UNIMPL exportfs +317 UNIMPL getpmsg +318 UNIMPL putpmsg +319 UNIMPL strioctl +320 UNIMPL msync +321 UNIMPL msleep +322 UNIMPL mwakeup +323 UNIMPL msem_init +324 UNIMPL msem_remove |