diff options
Diffstat (limited to 'sys/arch')
30 files changed, 1264 insertions, 970 deletions
diff --git a/sys/arch/mvme68k/conf/GENERIC b/sys/arch/mvme68k/conf/GENERIC index 8c793036a83..ba6d5817228 100644 --- a/sys/arch/mvme68k/conf/GENERIC +++ b/sys/arch/mvme68k/conf/GENERIC @@ -1,4 +1,4 @@ -# $OpenBSD: GENERIC,v 1.8 1996/06/30 17:39:38 deraadt Exp $ +# $OpenBSD: GENERIC,v 1.9 1997/03/31 00:23:50 downsj Exp $ machine mvme68k m68k @@ -8,7 +8,6 @@ include "../../../conf/GENERIC" option M68040 # support for 040 option FPSP # MC68040 floating point support option M68030 # support for 030 -option FPCOPROC # Support for MC6888[12] (Required) option MVME147 # (requires M68030) option MVME162 # (requires M68040, FPSP) @@ -16,6 +15,8 @@ option MVME167 # includes 166 (requires M68040, FPSP) #option MVME177 # (requires M68060, ...) option COMPAT_SUNOS +option COMPAT_HPUX +option COMPAT_M68K4K maxusers 32 diff --git a/sys/arch/mvme68k/conf/MINIROOT b/sys/arch/mvme68k/conf/MINIROOT index 5b7e18983dd..403ec146401 100644 --- a/sys/arch/mvme68k/conf/MINIROOT +++ b/sys/arch/mvme68k/conf/MINIROOT @@ -1,4 +1,4 @@ -# $OpenBSD: MINIROOT,v 1.1 1997/02/16 03:19:53 rahnds Exp $ +# $OpenBSD: MINIROOT,v 1.2 1997/03/31 00:23:51 downsj Exp $ machine mvme68k m68k @@ -8,7 +8,6 @@ include "../../../conf/GENERIC" option M68040 # support for 040 option FPSP # MC68040 floating point support option M68030 # support for 030 -option FPCOPROC # Support for MC6888[12] (Required) option MVME147 # (requires M68030) option MVME162 # (requires M68040, FPSP) @@ -16,6 +15,8 @@ option MVME167 # includes 166 (requires M68040, FPSP) #option MVME177 # (requires M68060, ...) #option COMPAT_SUNOS +#option COMPAT_HPUX +#option COMPAT_M68K4K maxusers 32 diff --git a/sys/arch/mvme68k/conf/MVME147 b/sys/arch/mvme68k/conf/MVME147 index 5f92eb19fc1..c552040b942 100644 --- a/sys/arch/mvme68k/conf/MVME147 +++ b/sys/arch/mvme68k/conf/MVME147 @@ -1,11 +1,10 @@ -# $OpenBSD: MVME147,v 1.9 1996/09/20 06:45:14 deraadt Exp $ +# $OpenBSD: MVME147,v 1.10 1997/03/31 00:23:52 downsj Exp $ machine mvme68k m68k #option "M68040" # support for 040 #option FPSP # MC68040 floating point support option "M68030" # support for 030 -option FPCOPROC # Support for MC6888[12] (Required) option MVME147 # (requires M68030) #option MVME162 # (requires M68040) diff --git a/sys/arch/mvme68k/conf/MVME162 b/sys/arch/mvme68k/conf/MVME162 index 98bb0bfdc52..cf3ec08bfd3 100644 --- a/sys/arch/mvme68k/conf/MVME162 +++ b/sys/arch/mvme68k/conf/MVME162 @@ -1,11 +1,10 @@ -# $OpenBSD: MVME162,v 1.9 1996/09/20 06:45:15 deraadt Exp $ +# $OpenBSD: MVME162,v 1.10 1997/03/31 00:23:53 downsj Exp $ machine mvme68k m68k option "M68040" # support for 040 option FPSP # MC68040 floating point support #option "M68030" # support for 030 -#option FPCOPROC # Support for MC6888[12] (Required) #option MVME147 # (requires M68030) option MVME162 # (requires M68040) diff --git a/sys/arch/mvme68k/conf/MVME167 b/sys/arch/mvme68k/conf/MVME167 index 76619840ca1..ff63dbe1075 100644 --- a/sys/arch/mvme68k/conf/MVME167 +++ b/sys/arch/mvme68k/conf/MVME167 @@ -1,11 +1,10 @@ -# $OpenBSD: MVME167,v 1.9 1996/09/20 06:45:15 deraadt Exp $ +# $OpenBSD: MVME167,v 1.10 1997/03/31 00:23:54 downsj Exp $ machine mvme68k m68k option "M68040" # support for 040 option FPSP # MC68040 floating point support #option "M68030" # support for 030 -#option FPCOPROC # Support for MC6888[12] (Required) #option MVME147 # (requires M68030) #option MVME162 # (requires M68040) diff --git a/sys/arch/mvme68k/conf/Makefile.mvme68k b/sys/arch/mvme68k/conf/Makefile.mvme68k index a8dfe59c17a..4b929ef061f 100644 --- a/sys/arch/mvme68k/conf/Makefile.mvme68k +++ b/sys/arch/mvme68k/conf/Makefile.mvme68k @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile.mvme68k,v 1.7 1996/05/27 22:11:36 chuck Exp $ +# $OpenBSD: Makefile.mvme68k,v 1.8 1997/03/31 00:23:54 downsj Exp $ # This makefile is constructed from a machine description: # config machineid @@ -23,17 +23,24 @@ AS?= as CC?= cc CPP?= cpp LD?= ld -STRIP?= strip -d -TOUCH?= touch -f -c +STRIP?= strip +COPTS?= -O2 # source tree is located via $S relative to the compilation directory S= ../../../.. MVME68K=../.. -INCLUDES= -I. -I$S/arch -I$S -CPPFLAGS= ${INCLUDES} ${IDENT} -D_KERNEL -Dmvme68k -CFLAGS= ${DEBUG} -O2 -Werror +INCLUDES= -I. -I$S/arch -I$S -nostdinc +CPPFLAGS= ${INCLUDES} ${IDENT} ${PARAM} -D_KERNEL -Dmvme68k +CWARNFLAGS= -Werror +CFLAGS= ${DEBUG} ${COPTS} ${CWARNFLAGS} -msoft-float AFLAGS= -x assembler-with-cpp -traditional-cpp -D_LOCORE +LINKFLAGS= -Ttext 0x10000 -z -e start +STRIPFLAGS= -d + +HOSTCC= ${CC} +HOSTED_CPPFLAGS=${CPPFLAGS:S/^-nostdinc$//} +HOSTED_CFLAGS= ${CFLAGS} ### find out what to use for libkern .include "$S/lib/libkern/Makefile.inc" @@ -54,19 +61,13 @@ LIBCOMPAT= ${COMPATLIB_PROF} ### for the Motorola 68040 Floating Point Software Product .include "$S/arch/m68k/fpsp/Makefile.inc" -# compile rules: rules are named ${TYPE}_${SUFFIX}${CONFIG_DEP} -# where TYPE is NORMAL, DRIVER, or PROFILE}; SUFFIX is the file suffix, -# capitalized (e.g. C for a .c file), and CONFIG_DEP is _C if the file -# is marked as config-dependent. +# compile rules: rules are named ${TYPE}_${SUFFIX} where TYPE is NORMAL or +# HOSTED}, and SUFFIX is the file suffix, capitalized (e.g. C for a .c file). NORMAL_C= ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c $< -NORMAL_C_C= ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} ${PARAM} -c $< - -DRIVER_C= ${CC} -c ${CFLAGS} ${CPPFLAGS} ${PROF} $< -DRIVER_C_C= ${CC} -c ${CFLAGS} ${CPPFLAGS} ${PROF} ${PARAM} $< - NORMAL_S= ${CC} ${AFLAGS} ${CPPFLAGS} -c $< -NORMAL_S_C= ${CC} ${AFLAGS} ${CPPFLAGS} ${PARAM} -c $< + +HOSTED_C= ${HOSTCC} ${HOSTED_CFLAGS} ${HOSTED_CPPFLAGS} -c $< %OBJS @@ -79,37 +80,37 @@ NORMAL_S_C= ${CC} ${AFLAGS} ${CPPFLAGS} ${PARAM} -c $< # ${SYSTEM_LD_HEAD} # ${SYSTEM_LD} swapxxx.o # ${SYSTEM_LD_TAIL} +SYSTEM_OBJ= locore.o ${FPSP} \ + param.o ioconf.o ${OBJS} ${LIBKERN} ${LIBCOMPAT} +SYSTEM_DEP= Makefile ${SYSTEM_OBJ} +SYSTEM_LD_HEAD= @rm -f $@ +SYSTEM_LD= @echo ${LD} ${LINKFLAGS} -o $@ '$${SYSTEM_OBJ}' vers.o; \ + ${LD} ${LINKFLAGS} -o $@ ${SYSTEM_OBJ} vers.o +SYSTEM_LD_TAIL= @size $@; chmod 755 $@ + DEBUG?= .if ${DEBUG} == "-g" -LDX=-X +LINKFLAGS+= -X +SYSTEM_LD_TAIL+=; \ + echo cp $@ $@.gdb; rm -f $@.gdb; cp $@ $@.gdb; \ + echo ${STRIP} ${STRIPFLAGS} $@; ${STRIP} ${STRIPFLAGS} $@ .else -LDX=-x +LINKFLAGS+= -S .endif -SYSTEM_OBJ= locore.o ${OBJS} param.o ioconf.o ${FPSP} \ - ${LIBKERN} ${LIBCOMPAT} -SYSTEM_DEP= Makefile ${SYSTEM_OBJ} -SYSTEM_LD_HEAD= @echo loading $@; rm -f $@ -SYSTEM_LD= @${LD} ${LDX} -Ttext 0x10000 -z -o $@ -e start \ - ${SYSTEM_OBJ} vers.o -SYSTEM_LD_TAIL= @echo rearranging symbols; size $@; chmod 755 $@ %LOAD -assym.h: genassym - ./genassym >assym.h - -genassym: genassym.o - ${CC} -o $@ genassym.o - -genassym.o: ${MVME68K}/mvme68k/genassym.c - ${NORMAL_C_C} +assym.h: $S/kern/genassym.sh ${MVME68K}/mvme68k/genassym.cf + sh $S/kern/genassym.sh ${CC} ${CFLAGS} ${CPPFLAGS} \ + ${PARAM} < ${MVME68K}/mvme68k/genassym.cf > assym.h.tmp && \ + mv -f assym.h.tmp assym.h param.c: $S/conf/param.c rm -f param.c cp $S/conf/param.c . param.o: param.c Makefile - ${NORMAL_C_C} + ${NORMAL_C} ioconf.o: ioconf.c ${NORMAL_C} @@ -121,7 +122,7 @@ newvers: ${SYSTEM_DEP} ${SYSTEM_SWAP_DEP} clean:: rm -f eddep bsd bsd.gdb tags *.o locore.i \ - [a-z]*.s [Ee]rrs linterrs makelinks genassym + [a-z]*.s [Ee]rrs linterrs makelinks assym.h lint: /tmp param.c @lint -hbxn -DGENERIC -Dvolatile= ${COPTS} ${PARAM} -UKGDB \ @@ -148,7 +149,6 @@ depend:: .depend mkdep ${AFLAGS} ${CPPFLAGS} ${MVME68K}/mvme68k/locore.s mkdep -a ${CFLAGS} ${CPPFLAGS} param.c ioconf.c ${CFILES} mkdep -a ${AFLAGS} ${CPPFLAGS} ${SFILES} - mkdep -a ${CFLAGS} ${CPPFLAGS} ${PARAM} ${MVME68K}/mvme68k/genassym.c # depend on root or device configuration @@ -160,7 +160,7 @@ if_tun.o if_loop.o if_ethersubr.o: Makefile in_proto.o: Makefile # depend on maxusers -genassym.o machdep.o: Makefile +assym.h machdep.o: Makefile # depend on CPU configuration locore.o machdep.o: Makefile diff --git a/sys/arch/mvme68k/conf/X b/sys/arch/mvme68k/conf/X index dc822c7523d..f61a0311e3a 100644 --- a/sys/arch/mvme68k/conf/X +++ b/sys/arch/mvme68k/conf/X @@ -1,11 +1,10 @@ -# $OpenBSD: X,v 1.2 1997/02/11 02:55:10 deraadt Exp $ +# $OpenBSD: X,v 1.3 1997/03/31 00:23:55 downsj Exp $ machine mvme68k m68k option "M68040" # support for 040 option FPSP # MC68040 floating point support #option "M68030" # support for 030 -#option FPCOPROC # Support for MC6888[12] (Required) #option MVME147 # (requires M68030) option MVME162 # (requires M68040) diff --git a/sys/arch/mvme68k/conf/files.mvme68k b/sys/arch/mvme68k/conf/files.mvme68k index da3aff441f2..95d4a7c957b 100644 --- a/sys/arch/mvme68k/conf/files.mvme68k +++ b/sys/arch/mvme68k/conf/files.mvme68k @@ -1,4 +1,4 @@ -# $OpenBSD: files.mvme68k,v 1.8 1996/12/20 08:26:26 deraadt Exp $ +# $OpenBSD: files.mvme68k,v 1.9 1997/03/31 00:23:56 downsj Exp $ # config file for mvme68k @@ -126,7 +126,6 @@ file arch/mvme68k/mvme68k/pmap_bootstrap.c file arch/mvme68k/mvme68k/sys_machdep.c file arch/mvme68k/mvme68k/trap.c file arch/mvme68k/mvme68k/vm_machdep.c -file arch/m68k/m68k/copy.s file dev/cons.c file dev/cninit.c @@ -134,8 +133,12 @@ file arch/m68k/m68k/db_memrw.c ddb # Compatibility modules +# HP-UX binary compatibility +include "compat/hpux/files.hpux" +file arch/mvme68k/mvme68k/hpux_machdep.c compat_hpux + # SunOS Binary Compatibility (COMPAT_SUNOS) -include "../../../compat/sunos/files.sunos" +include "compat/sunos/files.sunos" file arch/m68k/m68k/sunos_machdep.c compat_sunos device wl: tty diff --git a/sys/arch/mvme68k/include/autoconf.h b/sys/arch/mvme68k/include/autoconf.h index c7c19ac876e..1249e5122b1 100644 --- a/sys/arch/mvme68k/include/autoconf.h +++ b/sys/arch/mvme68k/include/autoconf.h @@ -1,4 +1,4 @@ -/* $OpenBSD: autoconf.h,v 1.5 1996/06/11 10:15:43 deraadt Exp $ */ +/* $OpenBSD: autoconf.h,v 1.6 1997/03/31 00:23:58 downsj Exp $ */ /* * Copyright (c) 1995 Theo de Raadt @@ -31,6 +31,9 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#ifndef _MVME68K_AUTOCONF_H_ +#define _MVME68K_AUTOCONF_H_ + struct confargs { int ca_bustype; void *ca_vaddr; @@ -65,3 +68,5 @@ struct device *bootdv; /* boot device */ void *mapiodev __P((void *pa, int size)); void unmapiodev __P((void *kva, int size)); + +#endif diff --git a/sys/arch/mvme68k/include/cdefs.h b/sys/arch/mvme68k/include/cdefs.h index 8ab985b5069..7ff575c6da4 100644 --- a/sys/arch/mvme68k/include/cdefs.h +++ b/sys/arch/mvme68k/include/cdefs.h @@ -1,8 +1,3 @@ -/* $OpenBSD: cdefs.h,v 1.3 1996/04/28 10:56:05 deraadt Exp $ */ - -#ifndef _MACHINE_CDEFS_H_ -#define _MACHINE_CDEFS_H_ +/* $OpenBSD: cdefs.h,v 1.4 1997/03/31 00:23:58 downsj Exp $ */ #include <m68k/cdefs.h> - -#endif diff --git a/sys/arch/mvme68k/include/cpu.h b/sys/arch/mvme68k/include/cpu.h index 492e23dd052..ecb5325b953 100644 --- a/sys/arch/mvme68k/include/cpu.h +++ b/sys/arch/mvme68k/include/cpu.h @@ -1,4 +1,4 @@ -/* $OpenBSD: cpu.h,v 1.5 1997/02/10 17:49:09 deraadt Exp $ */ +/* $OpenBSD: cpu.h,v 1.6 1997/03/31 00:23:59 downsj Exp $ */ /* * Copyright (c) 1995 Theo de Raadt @@ -71,6 +71,9 @@ * @(#)cpu.h 8.4 (Berkeley) 1/5/94 */ +#ifndef _MVME68K_CPU_H_ +#define _MVME68K_CPU_H_ + /* * Exported definitions unique to mvme68k/68k cpu support. */ @@ -280,3 +283,4 @@ struct haltvec { void (*hv_fn) __P((void)); int hv_pri; }; +#endif diff --git a/sys/arch/mvme68k/include/disklabel.h b/sys/arch/mvme68k/include/disklabel.h index b3cc39689b6..f2b386c6a9b 100644 --- a/sys/arch/mvme68k/include/disklabel.h +++ b/sys/arch/mvme68k/include/disklabel.h @@ -1,3 +1,5 @@ +/* $OpenBSD: disklabel.h,v 1.5 1997/03/31 00:24:00 downsj Exp $ */ + /* * Copyright (c) 1996 Nivas Madhur * Copyright (c) 1995 Dale Rahn. @@ -29,8 +31,8 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef _MACHINE_DISKLABEL_H_ -#define _MACHINE_DISKLABEL_H_ +#ifndef _MVME68K_DISKLABEL_H_ +#define _MVME68K_DISKLABEL_H_ /* number of boot pieces , ie xxboot bootxx */ #define NUMBOOT 2 @@ -149,4 +151,4 @@ struct cpu_disklabel { u_long magic2; u_char cfg_4[192]; }; -#endif _MACHINE_DISKLABEL_H_ +#endif /* _MVME68K_DISKLABEL_H_ */ diff --git a/sys/arch/mvme68k/include/exec.h b/sys/arch/mvme68k/include/exec.h index ef5cfd8e3e2..9de9c813006 100644 --- a/sys/arch/mvme68k/include/exec.h +++ b/sys/arch/mvme68k/include/exec.h @@ -1,4 +1,4 @@ -/* $OpenBSD: exec.h,v 1.5 1996/12/23 02:42:31 deraadt Exp $ */ +/* $OpenBSD: exec.h,v 1.6 1997/03/31 00:24:01 downsj Exp $ */ /* * Copyright (c) 1993 Christopher G. Demetriou @@ -26,8 +26,8 @@ * (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 _MACHINE_EXEC_H_ -#define _MACHINE_EXEC_H_ +#ifndef _MVME68K_EXEC_H_ +#define _MVME68K_EXEC_H_ #define __LDPGSZ 8192 @@ -57,4 +57,4 @@ struct relocation_info_m68k { #define _KERN_DO_ELF #endif -#endif /* _MACHINE_EXEC_H_ */ +#endif /* _MVME68K_EXEC_H_ */ diff --git a/sys/arch/mvme68k/include/float.h b/sys/arch/mvme68k/include/float.h index b171bd9dea8..6c9b3c0a9ac 100644 --- a/sys/arch/mvme68k/include/float.h +++ b/sys/arch/mvme68k/include/float.h @@ -1,8 +1,3 @@ -/* $OpenBSD: float.h,v 1.3 1996/04/28 10:56:18 deraadt Exp $ */ - -#ifndef _MACHINE_FLOAT_H_ -#define _MACHINE_FLOAT_H_ +/* $OpenBSD: float.h,v 1.4 1997/03/31 00:24:01 downsj Exp $ */ #include <m68k/float.h> - -#endif diff --git a/sys/arch/mvme68k/include/hpux_machdep.h b/sys/arch/mvme68k/include/hpux_machdep.h new file mode 100644 index 00000000000..e9133eb543f --- /dev/null +++ b/sys/arch/mvme68k/include/hpux_machdep.h @@ -0,0 +1,80 @@ +/* $OpenBSD: hpux_machdep.h,v 1.1 1997/03/31 00:24:02 downsj Exp $ */ +/* $NetBSD: hpux_machdep.h,v 1.6 1997/03/16 10:02:40 thorpej Exp $ */ + +/*- + * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Jason R. Thorpe. + * + * 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 + * must display the following acknowledgement: + * This product includes software developed by the NetBSD + * Foundation, Inc. and its contributors. + * 4. Neither the name of The NetBSD Foundation 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 NETBSD FOUNDATION, INC. 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. + */ + +#ifndef _MVME68K_HPUX_MACHDEP_H_ +#define _MVME68K_HPUX_MACHDEP_H_ + +/* + * Information pushed on stack when a signal is delivered. + * This is used by the kernel to restore state following + * execution of the signal handler. It is also made available + * to the handler to allow it to restore state properly if + * a non-standard exit is performed. + */ +struct hpuxsigcontext { + int hsc_syscall; /* ??? (syscall number?) */ + char hsc_action; /* ??? */ + char hsc_pad1; + char hsc_pad2; + char hsc_onstack; /* sigstack state to restore */ + int hsc_mask; /* signal mask to restore */ + int hsc_sp; /* sp to restore */ + short hsc_ps; /* psl to restore */ + int hsc_pc; /* pc to restore */ + + /* + * The following are not actually used by HP-UX. They exist + * for the convenience of the compatibility code. + */ + short _hsc_pad; + int _hsc_ap; /* pointer to hpuxsigstate */ +}; + +int hpux_cpu_makecmds __P((struct proc *, struct exec_package *)); +int hpux_cpu_vmcmd __P((struct proc *, struct exec_vmcmd *)); +void hpux_cpu_bsd_to_hpux_stat __P((struct stat *, struct hpux_stat *)); +void hpux_cpu_uname __P((struct hpux_utsname *)); +int hpux_cpu_sysconf_arch __P((void)); +int hpux_to_bsd_uoff __P((int *, int *, struct proc *)); + +void hpux_sendsig __P((sig_t, int, int, u_long, int, union sigval)); +void hpux_setregs __P((struct proc *, struct exec_package *, + u_long, register_t *)); + +#endif /* ! _MVME68K_HPUX_MACHDEP_H_ */ diff --git a/sys/arch/mvme68k/include/nvram.h b/sys/arch/mvme68k/include/nvram.h index 03ac2f50d4e..2325ef8cfbd 100644 --- a/sys/arch/mvme68k/include/nvram.h +++ b/sys/arch/mvme68k/include/nvram.h @@ -1,4 +1,4 @@ -/* $OpenBSD: nvram.h,v 1.3 1996/04/28 10:56:23 deraadt Exp $ */ +/* $OpenBSD: nvram.h,v 1.4 1997/03/31 00:24:03 downsj Exp $ */ /* * Copyright (c) 1995 Theo de Raadt @@ -31,6 +31,9 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#ifndef _MVME68K_NVRAM_H_ +#define _MVME68K_NVRAM_H_ + struct nvram_147 { u_char user[0x400]; u_char os[0x200]; @@ -77,3 +80,5 @@ struct nvram_16x { } conf; /*struct clockreg cl; */ }; + +#endif diff --git a/sys/arch/mvme68k/include/param.h b/sys/arch/mvme68k/include/param.h index 5b7219ccc5e..abc3e5e126c 100644 --- a/sys/arch/mvme68k/include/param.h +++ b/sys/arch/mvme68k/include/param.h @@ -1,4 +1,4 @@ -/* $OpenBSD: param.h,v 1.4 1996/04/28 10:55:42 deraadt Exp $ */ +/* $OpenBSD: param.h,v 1.5 1997/03/31 00:24:04 downsj Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -181,3 +181,17 @@ #ifdef _KERNEL #define DELAY(n) delay(n) #endif + +#ifdef COMPAT_HPUX +/* + * Constants/macros for HPUX multiple mapping of user address space. + * Pages in the first 256Mb are mapped in at every 256Mb segment. + */ +#define HPMMMASK 0xF0000000 +#define ISHPMMADDR(v) \ + ((curproc->p_md.md_flags & MDP_HPUXMMAP) && \ + ((unsigned)(v) & HPMMMASK) && \ + ((unsigned)(v) & HPMMMASK) != HPMMMASK) +#define HPMMBASEADDR(v) \ + ((unsigned)(v) & ~HPMMMASK) +#endif diff --git a/sys/arch/mvme68k/include/pcb.h b/sys/arch/mvme68k/include/pcb.h index 211ecc78c42..bbdee873ac5 100644 --- a/sys/arch/mvme68k/include/pcb.h +++ b/sys/arch/mvme68k/include/pcb.h @@ -1,4 +1,4 @@ -/* $OpenBSD: pcb.h,v 1.3 1996/04/28 10:56:24 deraadt Exp $ */ +/* $OpenBSD: pcb.h,v 1.4 1997/03/31 00:24:04 downsj Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -42,6 +42,9 @@ * @(#)pcb.h 8.1 (Berkeley) 6/10/93 */ +#ifndef _MVME68K_PCB_H_ +#define _MVME68K_PCB_H_ + #include <machine/frame.h> /* @@ -65,3 +68,5 @@ struct pcb { struct md_coredump { int md_exec[16]; /* exec structure for HP-UX core dumps */ }; + +#endif diff --git a/sys/arch/mvme68k/include/pmap.h b/sys/arch/mvme68k/include/pmap.h index ac1a785e455..905b3c577e8 100644 --- a/sys/arch/mvme68k/include/pmap.h +++ b/sys/arch/mvme68k/include/pmap.h @@ -1,4 +1,4 @@ -/* $OpenBSD: pmap.h,v 1.3 1996/04/28 10:56:25 deraadt Exp $ */ +/* $OpenBSD: pmap.h,v 1.4 1997/03/31 00:24:05 downsj Exp $ */ /* * Copyright (c) 1987 Carnegie-Mellon University @@ -40,8 +40,8 @@ * @(#)pmap.h 8.1 (Berkeley) 6/10/93 */ -#ifndef _MACHINE_PMAP_H_ -#define _MACHINE_PMAP_H_ +#ifndef _MVME68K_PMAP_H_ +#define _MVME68K_PMAP_H_ #include <machine/pte.h> @@ -155,4 +155,4 @@ extern pt_entry_t *Sysmap; extern char *vmmap; /* map for mem, dumps, etc. */ #endif /* _KERNEL */ -#endif /* !_MACHINE_PMAP_H_ */ +#endif /* !_MVME68K_PMAP_H_ */ diff --git a/sys/arch/mvme68k/include/proc.h b/sys/arch/mvme68k/include/proc.h index 1711d32893b..f55f547f83b 100644 --- a/sys/arch/mvme68k/include/proc.h +++ b/sys/arch/mvme68k/include/proc.h @@ -1,4 +1,4 @@ -/* $OpenBSD: proc.h,v 1.4 1996/04/28 10:56:25 deraadt Exp $ */ +/* $OpenBSD: proc.h,v 1.5 1997/03/31 00:24:06 downsj Exp $ */ /* * Copyright (c) 1991, 1993 @@ -35,6 +35,9 @@ * @(#)proc.h 8.1 (Berkeley) 6/10/93 */ +#ifndef _MVME68K_PROC_H_ +#define _MVME68K_PROC_H_ + /* * Machine-dependent part of the proc structure for mvme68k. */ @@ -45,9 +48,10 @@ struct mdproc { /* md_flags */ #define MDP_STACKADJ 0x0002 /* frame SP adjusted; undo when syscall does ERESTART */ -#define MDP_HPUXTRACE 0x0004 /* being traced by HP-UX process */ #define MDP_HPUXMMAP 0x0008 /* VA space is multiply mapped */ #define MDP_CCBDATA 0x0010 /* copyback caching of data (68040) */ #define MDP_CCBSTACK 0x0020 /* copyback caching of stack (68040) */ #define MDP_UNCACHE_WX 0x0040 /* The process might modify code, so don't cache writeable executable pages. */ + +#endif diff --git a/sys/arch/mvme68k/include/pte.h b/sys/arch/mvme68k/include/pte.h index 6aa1b56f792..b5c2e6f7630 100644 --- a/sys/arch/mvme68k/include/pte.h +++ b/sys/arch/mvme68k/include/pte.h @@ -1,4 +1,4 @@ -/* $OpenBSD: pte.h,v 1.3 1996/04/28 10:56:29 deraadt Exp $ */ +/* $OpenBSD: pte.h,v 1.4 1997/03/31 00:24:07 downsj Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -42,8 +42,8 @@ * @(#)pte.h 8.1 (Berkeley) 6/10/93 */ -#ifndef _MACHINE_PTE_H_ -#define _MACHINE_PTE_H_ +#ifndef _MVME68K_PTE_H_ +#define _MVME68K_PTE_H_ /* * m68k hardware segment/page table entries @@ -149,4 +149,4 @@ typedef int pt_entry_t; /* Mach page table entry */ #define kvtophys(va) \ ((kvtopte(va)->pg_pfnum << PGSHIFT) | ((int)(va) & PGOFSET)) -#endif /* !_MACHINE_PTE_H_ */ +#endif /* !_MVME68K_PTE_H_ */ diff --git a/sys/arch/mvme68k/include/reg.h b/sys/arch/mvme68k/include/reg.h index adfeaea12df..ae0e25f7a31 100644 --- a/sys/arch/mvme68k/include/reg.h +++ b/sys/arch/mvme68k/include/reg.h @@ -1,8 +1,3 @@ -/* $OpenBSD: reg.h,v 1.3 1996/04/28 10:56:31 deraadt Exp $ */ - -#ifndef _MACHINE_REG_H_ -#define _MACHINE_REG_H_ +/* $OpenBSD: reg.h,v 1.4 1997/03/31 00:24:08 downsj Exp $ */ #include <m68k/reg.h> - -#endif /* _MACHINE_REG_H_ */ diff --git a/sys/arch/mvme68k/include/types.h b/sys/arch/mvme68k/include/types.h index 578b5148e95..f1474b87914 100644 --- a/sys/arch/mvme68k/include/types.h +++ b/sys/arch/mvme68k/include/types.h @@ -1,10 +1,5 @@ -/* $OpenBSD: types.h,v 1.3 1996/04/28 10:56:35 deraadt Exp $ */ - -#ifndef _MACHINE_TYPES_H_ -#define _MACHINE_TYPES_H_ +/* $OpenBSD: types.h,v 1.4 1997/03/31 00:24:08 downsj Exp $ */ #include <m68k/types.h> #define __BDEVSW_DUMP_OLD_TYPE - -#endif diff --git a/sys/arch/mvme68k/mvme68k/genassym.c b/sys/arch/mvme68k/mvme68k/genassym.c deleted file mode 100644 index 7deeb6fc803..00000000000 --- a/sys/arch/mvme68k/mvme68k/genassym.c +++ /dev/null @@ -1,288 +0,0 @@ -/* $OpenBSD: genassym.c,v 1.4 1997/02/10 17:49:11 deraadt Exp $ */ - -/* - * Copyright (c) 1995 Theo de Raadt - * - * 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 - * must display the following acknowledgement: - * This product includes software developed under OpenBSD by - * Theo de Raadt for Willowglen Singapore. - * 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. - * - * Copyright (c) 1982, 1990, 1993 - * The Regents of the University of California. 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. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. 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. - * - * @(#)genassym.c 8.3 (Berkeley) 1/4/94 - */ - -/* XXXX */ -#define _VA_LIST_ _BSD_VA_LIST_ -#define _PTRDIFF_T_ _BSD_PTRDIFF_T_ - -#include <sys/param.h> -#include <sys/buf.h> -#include <sys/map.h> -#include <sys/proc.h> -#include <sys/mbuf.h> -#include <sys/msgbuf.h> -#include <sys/syscall.h> -#include <sys/user.h> - -#include <machine/cpu.h> -#include <machine/trap.h> -#include <machine/psl.h> -#include <machine/nvram.h> -#include <machine/reg.h> -#include <machine/autoconf.h> -#include <machine/prom.h> -#include <machine/pte.h> -#include <vm/vm.h> - -#include <errno.h> -#include <stdio.h> -#include <stddef.h> -#include <string.h> - -extern int errno; - -#if defined(MVME162) || defined(MVME167) -#ifndef M68040 -#error "MVME162/MVME167 requires M68040 support" -#endif -#endif - -#if defined(MVME147) -#ifndef M68030 -#error "MVME147 requires M68030 support" -#endif -#endif - -#if defined(MVME172) || defined(MVME177) -#ifndef M68060 -#error "MVME172/MVME177 requires M68060 support" -#endif -#endif - -void -def(what, val) - char *what; - int val; -{ - - if (printf("#define\t%s\t%d\n", what, val) < 0) { - (void)fprintf(stderr, "genassym: printf: %s\n", - strerror(errno)); - exit(1); - } -} - -void -flush() -{ - - if (fflush(stdout) || fsync(fileno(stdout)) < 0) { - (void)fprintf(stderr, "genassym: flush stdout: %s\n", - strerror(errno)); - exit(1); - } -} - -#define off(what, s, m) def(what, (int)offsetof(s, m)) - -main() -{ - /* general constants */ - def("UPAGES", UPAGES); - def("USPACE", USPACE); - def("NBPG", NBPG); - def("PGSHIFT", PGSHIFT); - def("USRSTACK", USRSTACK); - - /* proc fields and values */ - off("P_FORW", struct proc, p_forw); - off("P_BACK", struct proc, p_back); - off("P_VMSPACE", struct proc, p_vmspace); - off("P_ADDR", struct proc, p_addr); - off("P_PRIORITY", struct proc, p_priority); - off("P_STAT", struct proc, p_stat); - off("P_WCHAN", struct proc, p_wchan); - off("P_FLAG", struct proc, p_flag); - off("P_MD_FLAGS", struct proc, p_md.md_flags); - off("P_MD_REGS", struct proc, p_md.md_regs); - - def("SSLEEP", SSLEEP); - def("SRUN", SRUN); - - /* VM structure fields */ - off("VM_PMAP", struct vmspace, vm_pmap); - off("PM_STCHG", struct pmap, pm_stchanged); - - /* interrupt/fault metering */ - off("V_SWTCH", struct vmmeter, v_swtch); - off("V_INTR", struct vmmeter, v_intr); - - /* trap types (should just include trap.h?) */ - def("T_BUSERR", T_BUSERR); - def("T_ADDRERR", T_ADDRERR); - def("T_ILLINST", T_ILLINST); - def("T_ZERODIV", T_ZERODIV); - def("T_CHKINST", T_CHKINST); - def("T_TRAPVINST", T_TRAPVINST); - def("T_PRIVINST", T_PRIVINST); - def("T_TRACE", T_TRACE); - def("T_MMUFLT", T_MMUFLT); - def("T_SSIR", T_SSIR); - def("T_FMTERR", T_FMTERR); - def("T_COPERR", T_COPERR); - def("T_FPERR", T_FPERR); - def("T_ASTFLT", T_ASTFLT); - def("T_TRAP15", T_TRAP15); - def("T_FPEMULI", T_FPEMULI); - def("T_FPEMULD", T_FPEMULD); - - /* PSL values (should just include psl.h?) */ - def("PSL_S", PSL_S); - def("PSL_IPL7", PSL_IPL7); - def("PSL_LOWIPL", PSL_LOWIPL); - def("PSL_HIGHIPL", PSL_HIGHIPL); - def("PSL_USER", PSL_USER); - def("SPL1", PSL_S | PSL_IPL1); - def("SPL2", PSL_S | PSL_IPL2); - def("SPL3", PSL_S | PSL_IPL3); - def("SPL4", PSL_S | PSL_IPL4); - def("SPL5", PSL_S | PSL_IPL5); - def("SPL6", PSL_S | PSL_IPL6); - - /* magic */ - def("FC_USERD", FC_USERD); - def("EIOMAPSIZE", EIOMAPSIZE); - def("CACHE_ON", CACHE_ON); - def("CACHE_OFF", CACHE_OFF); - def("CACHE_CLR", CACHE_CLR); - def("IC_CLEAR", IC_CLEAR); - def("DC_CLEAR", DC_CLEAR); - - /* pte/ste bits */ - def("PG_V", PG_V); - def("PG_NV", PG_NV); - def("PG_RO", PG_RO); - def("PG_RW", PG_RW); - def("PG_CI", PG_CI); - def("PG_PROT", PG_PROT); - def("PG_FRAME", PG_FRAME); - def("SG_V", SG_V); - def("SG_NV", SG_NV); - def("SG_RW", SG_RW); - def("SG_FRAME", SG_FRAME); - def("SG_ISHIFT", SG_ISHIFT); - - /* pcb fields */ - off("PCB_PS", struct pcb, pcb_ps); - off("PCB_USTP", struct pcb, pcb_ustp); - off("PCB_USP", struct pcb, pcb_usp); - off("PCB_REGS", struct pcb, pcb_regs); - off("PCB_ONFAULT", struct pcb, pcb_onfault); - off("PCB_FPCTX", struct pcb, pcb_fpregs); - def("SIZEOF_PCB", sizeof(struct pcb)); - def("SIZEOF_TRAPFRAME", sizeof(struct trapframe)); - - /* exception frame offset/sizes */ - off("FR_SP", struct frame, f_regs[15]); - off("FR_HW", struct frame, f_sr); - off("FR_ADJ", struct frame, f_stackadj); - - /* system calls */ - def("SYS_exit", SYS_exit); - def("SYS_execve", SYS_execve); - def("SYS_sigreturn", SYS_sigreturn); - - /* errno */ - def("EFAULT", EFAULT); - def("ENAMETOOLONG", ENAMETOOLONG); - - def("SIZEOF_MVMEPROM_BRDID", sizeof(struct mvmeprom_brdid)); - off("MVMEPROM_BRDID_MODEL", struct mvmeprom_brdid, model); - - off("NVRAM_147_ETHER", struct nvram_147, ether); - off("NVRAM_147_EMEM", struct nvram_147, emem); - - off("NVRAM_16X_ETHER", struct nvram_16x, conf.ether); - - def("INTIOBASE_147", INTIOBASE_147); - def("INTIOBASE_162", INTIOBASE_162); - def("INTIOSIZE_147", INTIOSIZE_147); - def("INTIOSIZE_162", INTIOSIZE_162); - - def("CPU_147", CPU_147); - def("CPU_162", CPU_162); - def("CPU_166", CPU_166); - def("CPU_167", CPU_167); - def("CPU_172", CPU_172); - def("CPU_177", CPU_177); - - def("MMU_68851", MMU_68851); - def("MMU_68030", MMU_68030); - def("MMU_68040", MMU_68040); - - def("CPU_68020", CPU_68020); - def("CPU_68030", CPU_68030); - def("CPU_68040", CPU_68040); - def("CPU_68060", CPU_68060); - - off("NETCTRL_DEV", struct prom_netctrl, dev); - off("NETCTRL_CTRL", struct prom_netctrl, ctrl); - off("NETCTRL_CMD", struct prom_netctrl, cmd); - off("NETCTRL_ADDR", struct prom_netctrl, addr); - off("NETCTRL_LEN", struct prom_netctrl, len); - - exit(0); -} diff --git a/sys/arch/mvme68k/mvme68k/genassym.cf b/sys/arch/mvme68k/mvme68k/genassym.cf new file mode 100644 index 00000000000..5b7ee6456b6 --- /dev/null +++ b/sys/arch/mvme68k/mvme68k/genassym.cf @@ -0,0 +1,254 @@ +# $OpenBSD: genassym.cf,v 1.1 1997/03/31 00:24:11 downsj Exp $ + +# +# Copyright (c) 1995 Theo de Raadt +# +# 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 +# must display the following acknowledgement: +# This product includes software developed under OpenBSD by +# Theo de Raadt for Willowglen Singapore. +# 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. +# +# Copyright (c) 1982, 1990, 1993 +# The Regents of the University of California. 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. All advertising materials mentioning features or use of this software +# must display the following acknowledgement: +# This product includes software developed by the University of +# California, Berkeley and its contributors. +# 4. 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. +# +# @(#)genassym.c 8.3 (Berkeley) 1/4/94 +# + +include <sys/param.h> +include <sys/buf.h> +include <sys/map.h> +include <sys/proc.h> +include <sys/mbuf.h> +include <sys/msgbuf.h> +include <sys/syscall.h> +include <sys/user.h> + +include <machine/cpu.h> +include <machine/trap.h> +include <machine/psl.h> +include <machine/nvram.h> +include <machine/reg.h> +include <machine/autoconf.h> +include <machine/prom.h> +include <machine/pte.h> +include <vm/vm.h> + +define __XXX_BUG_FODDER 0 + +# CPU options +ifdef M68020 +define M68020 1 +endif +ifdef M68030 +define M68030 1 +endif +ifdef M68040 +define M68040 1 +endif +ifdef M68060 +define M68060 1 +endif + +# MMU options +ifdef M68K_MMU_MOTOROLA +define M68K_MMU_MOTOROLA 1 +endif + +# general constants +define UPAGES UPAGES +define USPACE USPACE +define NBPG NBPG +define PGSHIFT PGSHIFT +define USRSTACK USRSTACK + +# proc fields and values +define P_FORW offsetof(struct proc, p_forw) +define P_BACK offsetof(struct proc, p_back) +define P_VMSPACE offsetof(struct proc, p_vmspace) +define P_ADDR offsetof(struct proc, p_addr) +define P_PRIORITY offsetof(struct proc, p_priority) +define P_STAT offsetof(struct proc, p_stat) +define P_WCHAN offsetof(struct proc, p_wchan) +define P_FLAG offsetof(struct proc, p_flag) +define P_MD_FLAGS offsetof(struct proc, p_md.md_flags) +define P_MD_REGS offsetof(struct proc, p_md.md_regs) + +define SSLEEP SSLEEP +define SRUN SRUN + +# VM structure fields +define VM_PMAP offsetof(struct vmspace, vm_pmap) +define PM_STCHG offsetof(struct pmap, pm_stchanged) + +# interrupt/fault metering +define V_SWTCH offsetof(struct vmmeter, v_swtch) +define V_INTR offsetof(struct vmmeter, v_intr) + +# trap types (should just include trap.h?) +define T_BUSERR T_BUSERR +define T_ADDRERR T_ADDRERR +define T_ILLINST T_ILLINST +define T_ZERODIV T_ZERODIV +define T_CHKINST T_CHKINST +define T_TRAPVINST T_TRAPVINST +define T_PRIVINST T_PRIVINST +define T_TRACE T_TRACE +define T_MMUFLT T_MMUFLT +define T_SSIR T_SSIR +define T_FMTERR T_FMTERR +define T_COPERR T_COPERR +define T_FPERR T_FPERR +define T_ASTFLT T_ASTFLT +define T_TRAP15 T_TRAP15 +define T_FPEMULI T_FPEMULI +define T_FPEMULD T_FPEMULD + +# PSL values (should just include psl.h?) +define PSL_S PSL_S +define PSL_IPL7 PSL_IPL7 +define PSL_LOWIPL PSL_LOWIPL +define PSL_HIGHIPL PSL_HIGHIPL +define PSL_USER PSL_USER +define SPL1 PSL_S | PSL_IPL1 +define SPL2 PSL_S | PSL_IPL2 +define SPL3 PSL_S | PSL_IPL3 +define SPL4 PSL_S | PSL_IPL4 +define SPL5 PSL_S | PSL_IPL5 +define SPL6 PSL_S | PSL_IPL6 + +# magic +define FC_USERD FC_USERD +define EIOMAPSIZE EIOMAPSIZE +define CACHE_ON CACHE_ON +define CACHE_OFF CACHE_OFF +define CACHE_CLR CACHE_CLR +define IC_CLEAR IC_CLEAR +define DC_CLEAR DC_CLEAR + +# pte/ste bits +define PG_V PG_V +define PG_NV PG_NV +define PG_RO PG_RO +define PG_RW PG_RW +define PG_CI PG_CI +define PG_PROT PG_PROT +define PG_FRAME PG_FRAME +define SG_V SG_V +define SG_NV SG_NV +define SG_RW SG_RW +define SG_FRAME SG_FRAME +define SG_ISHIFT SG_ISHIFT + +# pcb fields +define PCB_PS offsetof(struct pcb, pcb_ps) +define PCB_USTP offsetof(struct pcb, pcb_ustp) +define PCB_USP offsetof(struct pcb, pcb_usp) +define PCB_REGS offsetof(struct pcb, pcb_regs) +define PCB_ONFAULT offsetof(struct pcb, pcb_onfault) +define PCB_FPCTX offsetof(struct pcb, pcb_fpregs) +define SIZEOF_PCB sizeof(struct pcb) +define SIZEOF_TRAPFRAME sizeof(struct trapframe) + +# exception frame offset/sizes +define FR_SP offsetof(struct frame, f_regs[15]) +define FR_HW offsetof(struct frame, f_sr) +define FR_ADJ offsetof(struct frame, f_stackadj) + +# system calls +define SYS_exit SYS_exit +define SYS_execve SYS_execve +define SYS_sigreturn SYS_sigreturn + +# errno +define EFAULT EFAULT +define ENAMETOOLONG ENAMETOOLONG + +define SIZEOF_MVMEPROM_BRDID sizeof(struct mvmeprom_brdid) +define MVMEPROM_BRDID_MODEL offsetof(struct mvmeprom_brdid, model) + +define NVRAM_147_ETHER offsetof(struct nvram_147, ether) +define NVRAM_147_EMEM offsetof(struct nvram_147, emem) + +define NVRAM_16X_ETHER offsetof(struct nvram_16x, conf.ether) + +define INTIOBASE_147 INTIOBASE_147 +define INTIOBASE_162 INTIOBASE_162 +define INTIOSIZE_147 INTIOSIZE_147 +define INTIOSIZE_162 INTIOSIZE_162 + +define CPU_147 CPU_147 +define CPU_162 CPU_162 +define CPU_166 CPU_166 +define CPU_167 CPU_167 +define CPU_172 CPU_172 +define CPU_177 CPU_177 + +define MMU_68851 MMU_68851 +define MMU_68030 MMU_68030 +define MMU_68040 MMU_68040 + +define CPU_68020 CPU_68020 +define CPU_68030 CPU_68030 +define CPU_68040 CPU_68040 +define CPU_68060 CPU_68060 + +define FPU_68881 FPU_68881 +define FPU_68882 FPU_68882 +define FPU_68040 FPU_68040 +define FPU_68060 FPU_68060 + +define NETCTRL_DEV offsetof(struct prom_netctrl, dev) +define NETCTRL_CTRL offsetof(struct prom_netctrl, ctrl) +define NETCTRL_CMD offsetof(struct prom_netctrl, cmd) +define NETCTRL_ADDR offsetof(struct prom_netctrl, addr) +define NETCTRL_LEN offsetof(struct prom_netctrl, len) diff --git a/sys/arch/mvme68k/mvme68k/hpux_machdep.c b/sys/arch/mvme68k/mvme68k/hpux_machdep.c new file mode 100644 index 00000000000..0646fe937fc --- /dev/null +++ b/sys/arch/mvme68k/mvme68k/hpux_machdep.c @@ -0,0 +1,755 @@ +/* $OpenBSD: hpux_machdep.c,v 1.1 1997/03/31 00:24:11 downsj Exp $ */ +/* $NetBSD: hpux_machdep.c,v 1.9 1997/03/16 10:00:45 thorpej Exp $ */ + +/* + * Copyright (c) 1995, 1996, 1997 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. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 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 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. + */ + +/* + * Machinde-dependent bits for HP-UX binary compatibility. + */ + +#include <sys/param.h> +#include <sys/systm.h> +#include <sys/signalvar.h> +#include <sys/kernel.h> +#include <sys/filedesc.h> +#include <sys/proc.h> +#include <sys/buf.h> +#include <sys/wait.h> +#include <sys/file.h> +#include <sys/exec.h> +#include <sys/namei.h> +#include <sys/vnode.h> +#include <sys/ioctl.h> +#include <sys/ptrace.h> +#include <sys/stat.h> +#include <sys/syslog.h> +#include <sys/malloc.h> +#include <sys/mount.h> +#include <sys/ipc.h> +#include <sys/namei.h> +#include <sys/user.h> +#include <sys/mman.h> +#include <sys/conf.h> + +#include <machine/cpu.h> +#include <machine/reg.h> +#include <machine/psl.h> +#include <machine/vmparam.h> + +#include <vm/vm.h> +#include <vm/vm_param.h> +#include <vm/vm_map.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/hpux_syscall.h> +#include <compat/hpux/hpux_syscallargs.h> + +#include <machine/hpux_machdep.h> + +extern short exframesize[]; + +struct valtostr { + int val; + const char *str; +}; + +static struct valtostr machine_table[] = { + /* We approximate based on cputype. */ + { CPU_68020, "350" }, /* 68020 == 350. */ + { CPU_68030, "370" }, /* 68030 == 370. */ + { CPU_68040, "380" }, /* 68040 == 380. */ + { -1, "3?0" }, /* unknown system (???) */ +}; + +/* + * 6.0 and later context. + * XXX what are the HP-UX "localroot" semantics? Should we handle + * XXX diskless systems here? + */ +static struct valtostr context_table[] = { + { FPU_68040, + "standalone HP-MC68040 HP-MC68881 HP-MC68020 HP-MC68010 localroot default" + }, + { FPU_68881, + "standalone HP-MC68881 HP-MC68020 HP-MC68010 localroot default" + }, + { FPU_NONE, + "standalone HP-MC68020 HP-MC68010 localroot default" + }, + { 0, NULL }, +}; + +#define UOFF(f) ((int)&((struct user *)0)->f) +#define HPUOFF(f) ((int)&((struct hpux_user *)0)->f) + +/* simplified FP structure */ +struct bsdfp { + int save[54]; + int reg[24]; + int ctrl[3]; +}; + +/* + * m68k-specific setup for HP-UX executables. + * XXX m68k/m68k/hpux_machdep.c? + */ +int +hpux_cpu_makecmds(p, epp) + struct proc *p; + struct exec_package *epp; +{ + struct hpux_exec *hpux_ep = epp->ep_hdr; + + /* set up command for exec header */ + NEW_VMCMD(&epp->ep_vmcmds, hpux_cpu_vmcmd, + sizeof(struct hpux_exec), (long)epp->ep_hdr, NULLVP, 0, 0); +} + +/* + * We need to stash the exec header in the pcb, so we define + * this vmcmd to do it for us, since vmcmds are executed once + * we're committed to the exec (i.e. the old program has been unmapped). + * + * The address of the header is in ev->ev_addr and the length is + * in ev->ev_len. + */ +int +hpux_cpu_vmcmd(p, ev) + struct proc *p; + struct exec_vmcmd *ev; +{ + struct hpux_exec *execp = (struct hpux_exec *)ev->ev_addr; + + /* Make sure we have room. */ + if (ev->ev_len <= sizeof(p->p_addr->u_md.md_exec)) + bcopy((caddr_t)ev->ev_addr, p->p_addr->u_md.md_exec, + ev->ev_len); + + /* Deal with misc. HP-UX process attributes. */ + if (execp->ha_trsize & HPUXM_VALID) { + if (execp->ha_trsize & HPUXM_DATAWT) + p->p_md.md_flags &= ~MDP_CCBDATA; + + if (execp->ha_trsize & HPUXM_STKWT) + p->p_md.md_flags & ~MDP_CCBSTACK; + } + + return (0); +} + +/* + * Machine-dependent stat structure conversion. + */ +void +hpux_cpu_bsd_to_hpux_stat(sb, hsb) + struct stat *sb; + struct hpux_stat *hsb; +{ +} + +/* + * Machine-dependent uname information. + */ +void +hpux_cpu_uname(ut) + struct hpux_utsname *ut; +{ + int i; + + bzero(ut->machine, sizeof(ut->machine)); + + /* + * Find the current machine-ID in the table and + * copy the string into the uname. + */ + for (i = 0; machine_table[i].val != -1; ++i) + if (machine_table[i].val == cputype) + break; + + sprintf(ut->machine, "9000/%s", machine_table[i].str); +} + +/* + * Return arch-type for hpux_sys_sysconf() + */ +int +hpux_cpu_sysconf_arch() +{ + + switch (cputype) { + case CPU_68020: + return (HPUX_SYSCONF_CPUM020); + + case CPU_68030: + return (HPUX_SYSCONF_CPUM030); + + case CPU_68040: + return (HPUX_SYSCONF_CPUM040); + + default: + return (HPUX_SYSCONF_CPUM020); /* ??? */ + } + /* NOTREACHED */ +} + +/* + * HP-UX advise(2) system call. + */ +int +hpux_sys_advise(p, v, retval) + struct proc *p; + void *v; + register_t *retval; +{ + struct hpux_sys_advise_args *uap = v; + int error = 0; + + switch (SCARG(uap, arg)) { + case 0: + p->p_md.md_flags |= MDP_HPUXMMAP; + break; + + case 1: + ICIA(); + break; + + case 2: + DCIA(); + break; + + default: + error = EINVAL; + break; + } + + return (error); +} + +/* + * HP-UX getcontext(2) system call. + * Man page lies, behaviour here is based on observed behaviour. + */ +int +hpux_sys_getcontext(p, v, retval) + struct proc *p; + void *v; + register_t *retval; +{ + struct hpux_sys_getcontext_args *uap = v; + int l, i, error = 0; + register int len; + + for (i = 0; context_table[i].str != NULL; i++) + if (context_table[i].val == fputype) + break; + if (context_table[i].str == NULL) { + /* + * XXX What else? It's not like this can happen... + */ + return (EINVAL); + } + + /* + 1 ... count the terminating \0. */ + l = strlen(context_table[i].str) + 1; + len = min(SCARG(uap, len), l); + + if (len) + error = copyout(context_table[i].str, SCARG(uap, buf), len); + if (error == 0) + *retval = l; + return (0); +} + +/* + * Brutal hack! Map HP-UX u-area offsets into BSD k-stack offsets. + * XXX This probably doesn't work anymore, BTW. --thorpej + */ +int +hpux_to_bsd_uoff(off, isps, p) + int *off, *isps; + struct proc *p; +{ + register int *ar0 = p->p_md.md_regs; + struct hpux_fp *hp; + struct bsdfp *bp; + register u_int raddr; + + *isps = 0; + + /* u_ar0 field; procxmt puts in U_ar0 */ + if ((int)off == HPUOFF(hpuxu_ar0)) + return(UOFF(U_ar0)); + + if (fputype) { + /* FP registers from PCB */ + hp = (struct hpux_fp *)HPUOFF(hpuxu_fp); + bp = (struct bsdfp *)UOFF(u_pcb.pcb_fpregs); + + if (off >= hp->hpfp_ctrl && off < &hp->hpfp_ctrl[3]) + return((int)&bp->ctrl[off - hp->hpfp_ctrl]); + + if (off >= hp->hpfp_reg && off < &hp->hpfp_reg[24]) + return((int)&bp->reg[off - hp->hpfp_reg]); + } + + /* + * Everything else we recognize comes from the kernel stack, + * so we convert off to an absolute address (if not already) + * for simplicity. + */ + if (off < (int *)ctob(UPAGES)) + off = (int *)((u_int)off + (u_int)p->p_addr); /* XXX */ + + /* + * General registers. + * We know that the HP-UX registers are in the same order as ours. + * The only difference is that their PS is 2 bytes instead of a + * padded 4 like ours throwing the alignment off. + */ + if (off >= ar0 && off < &ar0[18]) { + /* + * PS: return low word and high word of PC as HP-UX would + * (e.g. &u.u_ar0[16.5]). + * + * XXX we don't do this since HP-UX adb doesn't rely on + * it and passing such an offset to procxmt will cause + * it to fail anyway. Instead, we just set the offset + * to PS and let hpux_ptrace() shift up the value returned. + */ + if (off == &ar0[PS]) { +#if 0 + raddr = (u_int) &((short *)ar0)[PS*2+1]; +#else + raddr = (u_int) &ar0[(int)(off - ar0)]; +#endif + *isps = 1; + } + /* + * PC: off will be &u.u_ar0[16.5] since HP-UX saved PS + * is only 16 bits. + */ + else if (off == (int *)&(((short *)ar0)[PS*2+1])) + raddr = (u_int) &ar0[PC]; + /* + * D0-D7, A0-A7: easy + */ + else + raddr = (u_int) &ar0[(int)(off - ar0)]; + return((int)(raddr - (u_int)p->p_addr)); /* XXX */ + } + + /* everything else */ + return (-1); +} + +#define HSS_RTEFRAME 0x01 +#define HSS_FPSTATE 0x02 +#define HSS_USERREGS 0x04 + +struct hpuxsigstate { + int hss_flags; /* which of the following are valid */ + struct frame hss_frame; /* original exception frame */ + struct fpframe hss_fpstate; /* 68881/68882 state info */ +}; + +/* + * WARNING: code in locore.s assumes the layout shown here for hsf_signum + * thru hsf_handler so... don't screw with them! + */ +struct hpuxsigframe { + int hsf_signum; /* signo for handler */ + int hsf_code; /* additional info for handler */ + struct hpuxsigcontext *hsf_scp; /* context ptr for handler */ + sig_t hsf_handler; /* handler addr for u_sigc */ + struct hpuxsigstate hsf_sigstate; /* state of the hardware */ + struct hpuxsigcontext hsf_sc; /* actual context */ +}; + +#ifdef DEBUG +int hpuxsigdebug = 0; +int hpuxsigpid = 0; +#define SDB_FOLLOW 0x01 +#define SDB_KSTACK 0x02 +#define SDB_FPSTATE 0x04 +#endif + +/* + * Send an interrupt to process. + */ +/* ARGSUSED */ +void +hpux_sendsig(catcher, sig, mask, code, type, val) + sig_t catcher; + int sig, mask; + u_long code; + int type; + union sigval val; +{ + register struct proc *p = curproc; + register struct hpuxsigframe *kfp, *fp; + register struct frame *frame; + register struct sigacts *psp = p->p_sigacts; + register short ft; + int oonstack, fsize; + extern char sigcode[], esigcode[]; + + frame = (struct frame *)p->p_md.md_regs; + ft = frame->f_format; + oonstack = psp->ps_sigstk.ss_flags & SS_ONSTACK; + + /* + * Allocate and validate space for the signal handler + * context. Note that if the stack is in P0 space, the + * call to grow() is a nop, and the useracc() check + * will fail if the process has not already allocated + * the space with a `brk'. + */ + fsize = sizeof(struct hpuxsigframe); + if ((psp->ps_flags & SAS_ALTSTACK) && !oonstack && + (psp->ps_sigonstack & sigmask(sig))) { + fp = (struct hpuxsigframe *)(psp->ps_sigstk.ss_sp + + psp->ps_sigstk.ss_size - fsize); + psp->ps_sigstk.ss_flags |= SS_ONSTACK; + } else + fp = (struct hpuxsigframe *)(frame->f_regs[SP] - fsize); + if ((unsigned)fp <= USRSTACK - ctob(p->p_vmspace->vm_ssize)) + (void)grow(p, (unsigned)fp); + +#ifdef DEBUG + if ((hpuxsigdebug & SDB_KSTACK) && p->p_pid == hpuxsigpid) + printf("hpux_sendsig(%d): sig %d ssp %x usp %x scp %x ft %d\n", + p->p_pid, sig, &oonstack, fp, &fp->sf_sc, ft); +#endif + + if (useracc((caddr_t)fp, fsize, B_WRITE) == 0) { +#ifdef DEBUG + if ((hpuxsigdebug & SDB_KSTACK) && p->p_pid == hpuxsigpid) + printf("hpux_sendsig(%d): useracc failed on sig %d\n", + p->p_pid, sig); +#endif + /* + * Process has trashed its stack; give it an illegal + * instruction to halt it in its tracks. + */ + SIGACTION(p, SIGILL) = SIG_DFL; + sig = sigmask(SIGILL); + p->p_sigignore &= ~sig; + p->p_sigcatch &= ~sig; + p->p_sigmask &= ~sig; + psignal(p, SIGILL); + return; + } + kfp = (struct hpuxsigframe *)malloc((u_long)fsize, M_TEMP, M_WAITOK); + + /* + * Build the argument list for the signal handler. + */ + kfp->hsf_signum = bsdtohpuxsig(sig); + kfp->hsf_code = code; + kfp->hsf_scp = &fp->hsf_sc; + kfp->hsf_handler = catcher; + + /* + * Save necessary hardware state. Currently this includes: + * - general registers + * - original exception frame (if not a "normal" frame) + * - FP coprocessor state + */ + kfp->hsf_sigstate.hss_flags = HSS_USERREGS; + bcopy((caddr_t)frame->f_regs, + (caddr_t)kfp->hsf_sigstate.hss_frame.f_regs, sizeof frame->f_regs); + if (ft >= FMT7) { +#ifdef DEBUG + if (ft > 15 || exframesize[ft] < 0) + panic("hpux_sendsig: bogus frame type"); +#endif + kfp->hsf_sigstate.hss_flags |= HSS_RTEFRAME; + kfp->hsf_sigstate.hss_frame.f_format = frame->f_format; + kfp->hsf_sigstate.hss_frame.f_vector = frame->f_vector; + bcopy((caddr_t)&frame->F_u, + (caddr_t)&kfp->hsf_sigstate.hss_frame.F_u, exframesize[ft]); + + /* + * Leave an indicator that we need to clean up the kernel + * stack. We do this by setting the "pad word" above the + * hardware stack frame to the amount the stack must be + * adjusted by. + * + * N.B. we increment rather than just set f_stackadj in + * case we are called from syscall when processing a + * sigreturn. In that case, f_stackadj may be non-zero. + */ + frame->f_stackadj += exframesize[ft]; + frame->f_format = frame->f_vector = 0; +#ifdef DEBUG + if (hpuxsigdebug & SDB_FOLLOW) + printf("hpux_sendsig(%d): copy out %d of frame %d\n", + p->p_pid, exframesize[ft], ft); +#endif + } + if (fputype) { + kfp->hsf_sigstate.hss_flags |= HSS_FPSTATE; + m68881_save(&kfp->hsf_sigstate.hss_fpstate); + } + +#ifdef DEBUG + if ((hpuxsigdebug & SDB_FPSTATE) && *(char *)&kfp->sf_state.ss_fpstate) + printf("hpux_sendsig(%d): copy out FP state (%x) to %x\n", + p->p_pid, *(u_int *)&kfp->sf_state.ss_fpstate, + &kfp->sf_state.ss_fpstate); +#endif + + /* + * Build the signal context to be used by hpux_sigreturn. + */ + kfp->hsf_sc.hsc_syscall = 0; /* XXX */ + kfp->hsf_sc.hsc_action = 0; /* XXX */ + kfp->hsf_sc.hsc_pad1 = kfp->hsf_sc.hsc_pad2 = 0; + kfp->hsf_sc.hsc_onstack = oonstack; + kfp->hsf_sc.hsc_mask = mask; + kfp->hsf_sc.hsc_sp = frame->f_regs[SP]; + kfp->hsf_sc.hsc_ps = frame->f_sr; + kfp->hsf_sc.hsc_pc = frame->f_pc; + + /* How amazingly convenient! */ + kfp->hsf_sc._hsc_pad = 0; + kfp->hsf_sc._hsc_ap = (int)&fp->hsf_sigstate; + + (void) copyout((caddr_t)kfp, (caddr_t)fp, fsize); + frame->f_regs[SP] = (int)fp; + +#ifdef DEBUG + if (hpuxsigdebug & SDB_FOLLOW) { + printf( + "hpux_sendsig(%d): sig %d scp %x fp %x sc_sp %x sc_ap %x\n", + p->p_pid, sig, kfp->sf_scp, fp, + kfp->sf_sc.sc_sp, kfp->sf_sc.sc_ap); + } +#endif + + /* + * Signal trampoline code is at base of user stack. + */ + frame->f_pc = (int)PS_STRINGS - (esigcode - sigcode); +#ifdef DEBUG + if ((hpuxsigdebug & SDB_KSTACK) && p->p_pid == hpuxsigpid) + printf("hpux_sendsig(%d): sig %d returns\n", + p->p_pid, sig); +#endif + free((caddr_t)kfp, M_TEMP); +} + +/* + * System call to cleanup state after a signal + * has been taken. Reset signal mask and + * stack state from context left by sendsig (above). + * Return to previous pc and psl as specified by + * context left by sendsig. Check carefully to + * make sure that the user has not modified the + * psl to gain improper priviledges or to cause + * a machine fault. + */ +/* ARGSUSED */ +int +hpux_sys_sigreturn(p, v, retval) + struct proc *p; + void *v; + register_t *retval; +{ + struct hpux_sys_sigreturn_args /* { + syscallarg(struct hpuxsigcontext *) sigcntxp; + } */ *uap = v; + register struct hpuxsigcontext *scp; + register struct frame *frame; + register int rf; + struct hpuxsigcontext tsigc; + struct hpuxsigstate tstate; + int flags; + + scp = SCARG(uap, sigcntxp); +#ifdef DEBUG + if (hpuxsigdebug & SDB_FOLLOW) + printf("sigreturn: pid %d, scp %x\n", p->p_pid, scp); +#endif + if ((int)scp & 1) + return (EINVAL); + + /* + * Fetch and test the HP-UX context structure. + * We grab it all at once for speed. + */ + if (useracc((caddr_t)scp, sizeof (*scp), B_WRITE) == 0 || + copyin((caddr_t)scp, (caddr_t)&tsigc, sizeof tsigc)) + return (EINVAL); + scp = &tsigc; + if ((scp->hsc_ps & (PSL_MBZ|PSL_IPL|PSL_S)) != 0) + return (EINVAL); + + /* + * Restore the user supplied information + */ + if (scp->hsc_onstack & 01) + p->p_sigacts->ps_sigstk.ss_flags |= SS_ONSTACK; + else + p->p_sigacts->ps_sigstk.ss_flags &= ~SS_ONSTACK; + p->p_sigmask = scp->hsc_mask &~ sigcantmask; + frame = (struct frame *) p->p_md.md_regs; + frame->f_regs[SP] = scp->hsc_sp; + frame->f_pc = scp->hsc_pc; + frame->f_sr = scp->hsc_ps; + + /* + * Grab a pointer to the hpuxsigstate. + * If zero, the user is probably doing a longjmp. + * (This will never happen, really, since HP-UX doesn't + * know/care about the state pointer.) + */ + if ((rf = scp->_hsc_ap) == 0) + return (EJUSTRETURN); + + /* + * See if there is anything to do before we go to the + * expense of copying in close to 1/2K of data + */ + flags = fuword((caddr_t)rf); +#ifdef DEBUG + if (hpuxsigdebug & SDB_FOLLOW) + printf("sigreturn(%d): sc_ap %x flags %x\n", + p->p_pid, rf, flags); +#endif + /* + * fuword failed (bogus _hsc_ap value). + */ + if (flags == -1) + return (EINVAL); + if (flags == 0 || copyin((caddr_t)rf, (caddr_t)&tstate, sizeof tstate)) + return (EJUSTRETURN); +#ifdef DEBUG + if ((hpuxsigdebug & SDB_KSTACK) && p->p_pid == hpuxsigpid) + printf("sigreturn(%d): ssp %x usp %x scp %x ft %d\n", + p->p_pid, &flags, scp->sc_sp, SCARG(uap, sigcntxp), + (flags & HSS_RTEFRAME) ? tstate.ss_frame.f_format : -1); +#endif + /* + * Restore most of the users registers except for A6 and SP + * which were handled above. + */ + if (flags & HSS_USERREGS) + bcopy((caddr_t)tstate.hss_frame.f_regs, + (caddr_t)frame->f_regs, sizeof(frame->f_regs)-2*NBPW); + + /* + * Restore long stack frames. Note that we do not copy + * back the saved SR or PC, they were picked up above from + * the sigcontext structure. + */ + if (flags & HSS_RTEFRAME) { + register int sz; + + /* grab frame type and validate */ + sz = tstate.hss_frame.f_format; + if (sz > 15 || (sz = exframesize[sz]) < 0) + return (EINVAL); + frame->f_stackadj -= sz; + frame->f_format = tstate.hss_frame.f_format; + frame->f_vector = tstate.hss_frame.f_vector; + bcopy((caddr_t)&tstate.hss_frame.F_u, + (caddr_t)&frame->F_u, sz); +#ifdef DEBUG + if (hpuxsigdebug & SDB_FOLLOW) + printf("sigreturn(%d): copy in %d of frame type %d\n", + p->p_pid, sz, tstate.ss_frame.f_format); +#endif + } + + /* + * Finally we restore the original FP context + */ + if (flags & HSS_FPSTATE) + m68881_restore(&tstate.hss_fpstate); + +#ifdef DEBUG + if ((hpuxsigdebug & SDB_FPSTATE) && *(char *)&tstate.ss_fpstate) + printf("sigreturn(%d): copied in FP state (%x) at %x\n", + p->p_pid, *(u_int *)&tstate.ss_fpstate, + &tstate.ss_fpstate); + + if ((hpuxsigdebug & SDB_FOLLOW) || + ((hpuxsigdebug & SDB_KSTACK) && p->p_pid == hpuxsigpid)) + printf("sigreturn(%d): returns\n", p->p_pid); +#endif + return (EJUSTRETURN); +} + +/* + * Set registers on exec. + * XXX Should clear registers except sp, pc. + */ +void +hpux_setregs(p, pack, stack, retval) + register struct proc *p; + struct exec_package *pack; + u_long stack; + register_t *retval; +{ + struct frame *frame = (struct frame *)p->p_md.md_regs; + + frame->f_pc = pack->ep_entry & ~1; + frame->f_regs[SP] = stack; + frame->f_regs[A2] = (int)PS_STRINGS; + + /* restore a null state frame */ + p->p_addr->u_pcb.pcb_fpregs.fpf_null = 0; + if (fputype) + m68881_restore(&p->p_addr->u_pcb.pcb_fpregs); + + p->p_md.md_flags &= ~MDP_HPUXMMAP; + frame->f_regs[A0] = 0; /* not 68010 (bit 31), no FPA (30) */ + retval[0] = 0; /* no float card */ + if (fputype) + retval[1] = 1; /* yes 68881 */ + else + retval[1] = 0; /* no 68881 */ +} diff --git a/sys/arch/mvme68k/mvme68k/locore.s b/sys/arch/mvme68k/mvme68k/locore.s index b3d8ffc1b3d..3c9a6c625a2 100644 --- a/sys/arch/mvme68k/mvme68k/locore.s +++ b/sys/arch/mvme68k/mvme68k/locore.s @@ -1,4 +1,4 @@ -/* $OpenBSD: locore.s,v 1.15 1997/02/10 17:49:12 deraadt Exp $ */ +/* $OpenBSD: locore.s,v 1.16 1997/03/31 00:24:13 downsj Exp $ */ /* * Copyright (c) 1995 Theo de Raadt @@ -246,6 +246,9 @@ is162: RELOC(_cputype, a0) | no, we have 68040 movl #CPU_68040,a0@ | set to reflect 68040 CPU + RELOC(_fputype, a0) + movl #FPU_68040,a0@ | and a 68040 FPU + bra is16x #endif @@ -264,6 +267,9 @@ is167: RELOC(_cputype, a0) | no, we have 68040 movl #CPU_68040,a0@ | set to reflect 68040 CPU + RELOC(_fputype, a0) + movl #FPU_68040,a0@ | and a 68040 FPU + bra is16x #endif @@ -479,12 +485,14 @@ Lenab1: movl #USRSTACK-4,a2 movl a2,usp | init user SP movl a1,_curpcb | proc0 is running -#ifdef FPCOPROC + + tstl _fputype | Have an FPU? + jeq Lenab2 | No, skip. clrl a1@(PCB_FPCTX) | ensure null FP context movl a1,sp@- jbsr _m68881_restore | restore it (does not kill a1) addql #4,sp -#endif +Lenab2: /* flush TLB and turn on caches */ jbsr _TBIA | invalidate TLB cmpl #MMU_68040,_mmutype | 68040? @@ -732,34 +740,41 @@ Lstkadj: */ _fpfline: #if defined(M68040) + cmpl #FPU_68040,_fputype | 68040 FPU? + jne Lfp_unimp | no, skip FPSP cmpw #0x202c,sp@(6) | format type 2? jne _illinst | no, not an FP emulation +Ldofp_unimp: #ifdef FPSP .globl fpsp_unimp jmp fpsp_unimp | yes, go handle it -#else +#endif +Lfp_unimp: +#endif/* M68040 */ +#ifdef FPU_EMULATE clrl sp@- | stack adjust count moveml #0xFFFF,sp@- | save registers moveq #T_FPEMULI,d0 | denote as FP emulation trap jra fault | do it -#endif #else jra _illinst #endif _fpunsupp: #if defined(M68040) - cmpl #MMU_68040,_mmutype | 68040? + cmpl #FPU_68040,_fputype | 68040 FPU? jne _illinst | no, treat as illinst #ifdef FPSP .globl fpsp_unsupp jmp fpsp_unsupp | yes, go handle it -#else +#endif +Lfp_unsupp: +#endif /* M68040 */ +#ifdef FPU_EMULATE clrl sp@- | stack adjust count moveml #0xFFFF,sp@- | save registers moveq #T_FPEMULD,d0 | denote as FP emulation trap jra fault | do it -#endif #else jra _illinst #endif @@ -772,7 +787,6 @@ _fpunsupp: */ .globl _fpfault _fpfault: -#ifdef FPCOPROC clrl sp@- | stack adjust count moveml #0xFFFF,sp@- | save user registers movl usp,a0 | and save @@ -781,6 +795,11 @@ _fpfault: movl _curpcb,a0 | current pcb lea a0@(PCB_FPCTX),a0 | address of FP savearea fsave a0@ | save state +#if defined(M68040) || defined(M68060) + /* always null state frame on 68040, 68060 */ + cmpl #CPU_68040,_cputype + jle Lfptnull +#endif tstb a0@ | null state frame? jeq Lfptnull | yes, safe clrw d0 | no, need to tweak BIU @@ -791,9 +810,6 @@ Lfptnull: frestore a0@ | restore state movl #T_FPERR,sp@- | push type arg jra Ltrapnstkadj | call trap and deal with stack cleanup -#else - jra _badtrap | treat as an unexpected trap -#endif /* * Coprocessor and format errors can generate mid-instruction stack @@ -917,29 +933,16 @@ Ltrap1: rte /* - * Routines for traps 1 and 2. The meaning of the two traps depends - * on whether we are an HPUX compatible process or a native 4.3 process. - * Our native 4.3 implementation uses trap 1 as sigreturn() and trap 2 - * as a breakpoint trap. HPUX uses trap 1 for a breakpoint, so we have - * to make adjustments so that trap 2 is used for sigreturn. + * Trap 1 - sigreturn */ _trap1: -#ifdef COMPAT_HPUX - btst #MDP_TRCB,mdpflag | being traced by an HPUX process? - jeq sigreturn | no, trap1 is sigreturn - jra _trace | yes, trap1 is breakpoint -#else - jra sigreturn | no, trap1 is sigreturn -#endif + jra sigreturn +/* + * Trap 2 - trace trap + */ _trap2: -#ifdef COMPAT_HPUX - btst #MDP_TRCB,mdpflag | being traced by an HPUX process? - jeq _trace | no, trap2 is breakpoint - jra sigreturn | yes, trap2 is sigreturn -#else - jra _trace | no, trap2 is breakpoint -#endif + jra _trace /* * Trap 12 is the entry point for the cachectl "syscall" (both HPUX & BSD) @@ -1132,22 +1135,8 @@ Ldorte: #define ALTENTRY(name, rname) ENTRY(name) #endif -/* - * non-local gotos - */ -ENTRY(setjmp) - movl sp@(4),a0 | savearea pointer - moveml #0xFCFC,a0@ | save d2-d7/a2-a7 - movl sp@,a0@(48) | and return address - moveq #0,d0 | return 0 - rts - -ENTRY(longjmp) - movl sp@(4),a0 - moveml a0@+,#0xFCFC - movl a0@,sp@ - moveq #1,d0 - rts +/* Use standard m68k support. */ +#include <m68k/m68k/support.s> /* * The following primitives manipulate the run queues. _whichqs tells which @@ -1292,7 +1281,7 @@ Lbadsw: /* * cpu_switch() * - * NOTE: On the mc68851 (318/319/330) we attempt to avoid flushing the + * NOTE: On the mc68851 we attempt to avoid flushing the * entire ATC. The effort involved in selective flushing may not be * worth it, maybe we should just flush the whole thing? * @@ -1352,7 +1341,9 @@ Lsw2: moveml #0xFCFC,a1@(PCB_REGS) | save non-scratch registers movl usp,a2 | grab USP (a2 has been saved) movl a2,a1@(PCB_USP) | and save it -#ifdef FPCOPROC + + tstl _fputype | If we don't have an FPU, + jeq Lswnofpsave | don't try to save it. lea a1@(PCB_FPCTX),a2 | pointer to FP save area fsave a2@ | save FP state tstb a2@ | null state frame? @@ -1360,7 +1351,6 @@ Lsw2: fmovem fp0-fp7,a2@(216) | save FP general registers fmovem fpcr/fpsr/fpi,a2@(312) | save FP control registers Lswnofpsave: -#endif #ifdef DIAGNOSTIC tstl a0@(P_WCHAN) @@ -1414,7 +1404,9 @@ Lcxswdone: moveml a1@(PCB_REGS),#0xFCFC | and registers movl a1@(PCB_USP),a0 movl a0,usp | and USP -#ifdef FPCOPROC + + tstl _fputype | If we don't have an FPU, + jeq Lnofprest | don't try to restore it. lea a1@(PCB_FPCTX),a0 | pointer to FP save area tstb a0@ | null state frame? jeq Lresfprest | yes, easy @@ -1429,7 +1421,7 @@ Lresnot040: fmovem a0@(216),fp0-fp7 | restore FP general registers Lresfprest: frestore a0@ | restore state -#endif +Lnofprest: movw a1@(PCB_PS),sr | no, restore PS moveq #1,d0 | return 1 (for alternate returns) rts @@ -1444,7 +1436,9 @@ ENTRY(savectx) movl usp,a0 | grab USP movl a0,a1@(PCB_USP) | and save it moveml #0xFCFC,a1@(PCB_REGS) | save non-scratch registers -#ifdef FPCOPROC + + tstl _fputype | If we don't have an FPU, + jeq Lsvnofpsave | don't try to save it. lea a1@(PCB_FPCTX),a0 | pointer to FP save area fsave a0@ | save FP state tstb a0@ | null state frame? @@ -1452,7 +1446,6 @@ ENTRY(savectx) fmovem fp0-fp7,a0@(216) | save FP general registers fmovem fpcr/fpsr/fpi,a0@(312) | save FP control registers Lsvnofpsave: -#endif moveq #0,d0 | return 0 rts @@ -1760,31 +1753,6 @@ ENTRY(spl0) Lspldone: rts -ENTRY(_insque) - movw sr,d0 - movw #PSL_HIGHIPL,sr | atomic - movl sp@(8),a0 | where to insert (after) - movl sp@(4),a1 | element to insert (e) - movl a0@,a1@ | e->next = after->next - movl a0,a1@(4) | e->prev = after - movl a1,a0@ | after->next = e - movl a1@,a0 - movl a1,a0@(4) | e->next->prev = e - movw d0,sr - rts - -ENTRY(_remque) - movw sr,d0 - movw #PSL_HIGHIPL,sr | atomic - movl sp@(4),a0 | element to remove (e) - movl a0@,a1 - movl a0@(4),a0 - movl a0,a1@(4) | e->next->prev = e->prev - movl a1,a0@ | e->prev->next = e->next - movw d0,sr - rts - -#ifdef FPCOPROC /* * Save and restore 68881 state. */ @@ -1807,7 +1775,6 @@ ENTRY(m68881_restore) Lm68881rdone: frestore a0@ | restore state rts -#endif /* * Handle the nitty-gritty of rebooting the machine. @@ -1881,11 +1848,13 @@ not147: /*NOTREACHED*/ .data - .globl _mmutype,_protorp, _cputype + .globl _mmutype,_protorp,_cputype,_fputype _mmutype: .long MMU_68030 | default to MMU_68030 _cputype: .long CPU_68030 | default to CPU_68030 +_fputype: + .long FPU_68881 | default to 68881 FPU _protorp: .long 0,0 | prototype root pointer .globl _cold diff --git a/sys/arch/mvme68k/mvme68k/machdep.c b/sys/arch/mvme68k/mvme68k/machdep.c index 3391f9a1e4d..71395910905 100644 --- a/sys/arch/mvme68k/mvme68k/machdep.c +++ b/sys/arch/mvme68k/mvme68k/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.20 1997/02/14 05:10:17 rahnds Exp $ */ +/* $OpenBSD: machdep.c,v 1.21 1997/03/31 00:24:14 downsj Exp $ */ /* * Copyright (c) 1995 Theo de Raadt @@ -419,11 +419,12 @@ setregs(p, pack, stack, retval) frame->f_pc = pack->ep_entry & ~1; frame->f_regs[SP] = stack; frame->f_regs[A2] = (int)PS_STRINGS; -#ifdef FPCOPROC + /* restore a null state frame */ p->p_addr->u_pcb.pcb_fpregs.fpf_null = 0; - m68881_restore(&p->p_addr->u_pcb.pcb_fpregs); -#endif + if (fputype) + m68881_restore(&p->p_addr->u_pcb.pcb_fpregs); + #ifdef COMPAT_SUNOS /* * SunOS' ld.so does self-modifying code without knowing @@ -435,53 +436,6 @@ setregs(p, pack, stack, retval) else p->p_md.md_flags &= ~MDP_UNCACHE_WX; #endif -#ifdef COMPAT_HPUX - p->p_md.md_flags &= ~MDP_HPUXMMAP; - if (p->p_emul == &emul_hpux) { - frame->f_regs[A0] = 0; /* not 68010 (bit 31), no FPA (30) */ - retval[0] = 0; /* no float card */ -#ifdef FPCOPROC - retval[1] = 1; /* yes 68881 */ -#else - retval[1] = 0; /* no 68881 */ -#endif - } - /* - * XXX This doesn't have much to do with setting registers but - * I didn't want to muck up kern_exec.c with this code, so I - * stuck it here. - * - * Ensure we perform the right action on traps type 1 and 2: - * If our parent is an HPUX process and we are being traced, turn - * on HPUX style interpretation. Else if we were using the HPUX - * style interpretation, revert to the BSD interpretation. - * - * Note that we do this by changing the trap instruction in the - * global "sigcode" array which then gets copied out to the user's - * sigcode in the stack. Since we are changing it in the global - * array we must always reset it, even for non-HPUX processes. - * - * Note also that implementing it in this way creates a potential - * race where we could have tweaked it for process A which then - * blocks in the copyout to the stack and process B comes along - * and untweaks it causing A to wind up with the wrong setting - * when the copyout continues. However, since we have already - * copied something out to this user stack page (thereby faulting - * it in), this scenerio is extremely unlikely. - */ - { - extern short sigcodetrap[]; - - if ((p->p_pptr->p_emul == &emul_hpux) && - (p->p_flag & P_TRACED)) { - p->p_md.md_flags |= MDP_HPUXTRACE; - *sigcodetrap = 0x4E42; - } else { - p->p_md.md_flags &= ~MDP_HPUXTRACE; - *sigcodetrap = 0x4E41; - } - } -#endif } /* @@ -617,438 +571,6 @@ cpu_sysctl(name, namelen, oldp, oldlenp, newp, newlen, p) /* NOTREACHED */ } -#define SS_RTEFRAME 1 -#define SS_FPSTATE 2 -#define SS_USERREGS 4 - -struct sigstate { - int ss_flags; /* which of the following are valid */ - struct frame ss_frame; /* original exception frame */ - struct fpframe ss_fpstate; /* 68881/68882 state info */ -}; - -/* - * WARNING: code in locore.s assumes the layout shown for sf_signum - * thru sf_handler so... don't screw with them! - */ -struct sigframe { - int sf_signum; /* signo for handler */ - siginfo_t *sf_sip; - struct sigcontext *sf_scp; /* context ptr for handler */ - sig_t sf_handler; /* handler addr for u_sigc */ - struct sigstate sf_state; /* state of the hardware */ - struct sigcontext sf_sc; /* actual context */ - siginfo_t sf_si; -}; - -#ifdef COMPAT_HPUX -struct hpuxsigcontext { - int hsc_syscall; - char hsc_action; - char hsc_pad1; - char hsc_pad2; - char hsc_onstack; - int hsc_mask; - int hsc_sp; - short hsc_ps; - int hsc_pc; -/* the rest aren't part of the context but are included for our convenience */ - short hsc_pad; - u_int hsc_magic; /* XXX sigreturn: cookie */ - struct sigcontext *hsc_realsc; /* XXX sigreturn: ptr to BSD context */ -}; - -/* - * For an HP-UX process, a partial hpuxsigframe follows the normal sigframe. - * Tremendous waste of space, but some HP-UX applications (e.g. LCL) need it. - */ -struct hpuxsigframe { - int hsf_signum; - int hsf_code; - struct sigcontext *hsf_scp; - int hsf_nothing; - struct hpuxsigcontext hsf_sc; - int hsf_regs[15]; -}; -#endif - -#ifdef DEBUG -int sigdebug = 0; -int sigpid = 0; -#define SDB_FOLLOW 0x01 -#define SDB_KSTACK 0x02 -#define SDB_FPSTATE 0x04 -#endif - -/* - * Send an interrupt to process. - */ -void -sendsig(catcher, sig, mask, code, type, val) - sig_t catcher; - int sig, mask; - u_long code; - int type; - union sigval val; -{ - register struct proc *p = curproc; - register struct sigframe *fp, *kfp; - register struct frame *frame; - register struct sigacts *psp = p->p_sigacts; - register short ft; - int oonstack, fsize; - extern char sigcode[], esigcode[]; - - frame = (struct frame *)p->p_md.md_regs; - ft = frame->f_format; - oonstack = psp->ps_sigstk.ss_flags & SA_ONSTACK; - /* - * Allocate and validate space for the signal handler - * context. Note that if the stack is in P0 space, the - * call to grow() is a nop, and the useracc() check - * will fail if the process has not already allocated - * the space with a `brk'. - */ -#ifdef COMPAT_HPUX - if (p->p_emul == &emul_hpux) - fsize = sizeof(struct sigframe) + sizeof(struct hpuxsigframe); - else -#endif - fsize = sizeof(struct sigframe); - if ((psp->ps_flags & SAS_ALTSTACK) && !oonstack && - (psp->ps_sigonstack & sigmask(sig))) { - fp = (struct sigframe *)(psp->ps_sigstk.ss_sp + - psp->ps_sigstk.ss_size - fsize); - psp->ps_sigstk.ss_flags |= SA_ONSTACK; - } else - fp = (struct sigframe *)(frame->f_regs[SP] - fsize); - if ((unsigned)fp <= USRSTACK - ctob(p->p_vmspace->vm_ssize)) - (void)grow(p, (unsigned)fp); -#ifdef DEBUG - if ((sigdebug & SDB_KSTACK) && p->p_pid == sigpid) - printf("sendsig(%d): sig %d ssp %x usp %x scp %x ft %d\n", - p->p_pid, sig, &oonstack, fp, &fp->sf_sc, ft); -#endif - if (useracc((caddr_t)fp, fsize, B_WRITE) == 0) { -#ifdef DEBUG - if ((sigdebug & SDB_KSTACK) && p->p_pid == sigpid) - printf("sendsig(%d): useracc failed on sig %d\n", - p->p_pid, sig); -#endif - /* - * Process has trashed its stack; give it an illegal - * instruction to halt it in its tracks. - */ - SIGACTION(p, SIGILL) = SIG_DFL; - sig = sigmask(SIGILL); - p->p_sigignore &= ~sig; - p->p_sigcatch &= ~sig; - p->p_sigmask &= ~sig; - psignal(p, SIGILL); - return; - } - kfp = (struct sigframe *)malloc((u_long)fsize, M_TEMP, M_WAITOK); - /* - * Build the argument list for the signal handler. - */ - kfp->sf_signum = sig; - kfp->sf_sip = NULL; - kfp->sf_scp = &fp->sf_sc; - kfp->sf_handler = catcher; - - /* - * Save necessary hardware state. Currently this includes: - * - general registers - * - original exception frame (if not a "normal" frame) - * - FP coprocessor state - */ - kfp->sf_state.ss_flags = SS_USERREGS; - bcopy((caddr_t)frame->f_regs, - (caddr_t)kfp->sf_state.ss_frame.f_regs, sizeof frame->f_regs); - if (ft >= FMT7) { -#ifdef DEBUG - if (ft > 15 || exframesize[ft] < 0) - panic("sendsig: bogus frame type"); -#endif - kfp->sf_state.ss_flags |= SS_RTEFRAME; - kfp->sf_state.ss_frame.f_format = frame->f_format; - kfp->sf_state.ss_frame.f_vector = frame->f_vector; - bcopy((caddr_t)&frame->F_u, - (caddr_t)&kfp->sf_state.ss_frame.F_u, exframesize[ft]); - /* - * Leave an indicator that we need to clean up the kernel - * stack. We do this by setting the "pad word" above the - * hardware stack frame to the amount the stack must be - * adjusted by. - * - * N.B. we increment rather than just set f_stackadj in - * case we are called from syscall when processing a - * sigreturn. In that case, f_stackadj may be non-zero. - */ - frame->f_stackadj += exframesize[ft]; - frame->f_format = frame->f_vector = 0; -#ifdef DEBUG - if (sigdebug & SDB_FOLLOW) - printf("sendsig(%d): copy out %d of frame %d\n", - p->p_pid, exframesize[ft], ft); -#endif - } -#ifdef FPCOPROC - kfp->sf_state.ss_flags |= SS_FPSTATE; - m68881_save(&kfp->sf_state.ss_fpstate); -#ifdef DEBUG - if ((sigdebug & SDB_FPSTATE) && *(char *)&kfp->sf_state.ss_fpstate) - printf("sendsig(%d): copy out FP state (%x) to %x\n", - p->p_pid, *(u_int *)&kfp->sf_state.ss_fpstate, - &kfp->sf_state.ss_fpstate); -#endif -#endif - /* - * Build the signal context to be used by sigreturn. - */ - kfp->sf_sc.sc_onstack = oonstack; - kfp->sf_sc.sc_mask = mask; - kfp->sf_sc.sc_sp = frame->f_regs[SP]; - kfp->sf_sc.sc_fp = frame->f_regs[A6]; - kfp->sf_sc.sc_ap = (int)&fp->sf_state; - kfp->sf_sc.sc_pc = frame->f_pc; - kfp->sf_sc.sc_ps = frame->f_sr; - - if (psp->ps_siginfo & sigmask(sig)) { - kfp->sf_sip = &fp->sf_si; - initsiginfo(&kfp->sf_si, sig, code, type, val); - } - -#ifdef COMPAT_HPUX - /* - * Create an HP-UX style sigcontext structure and associated goo - */ - if (p->p_emul == &emul_hpux) { - register struct hpuxsigframe *hkfp; - - hkfp = (struct hpuxsigframe *)&kfp[1]; - hkfp->hsf_signum = bsdtohpuxsig(kfp->sf_signum); - hkfp->hsf_code = kfp->sf_code; - hkfp->hsf_scp = (struct sigcontext *) - &((struct hpuxsigframe *)(&fp[1]))->hsf_sc; - hkfp->hsf_sc.hsc_syscall = 0; /* XXX */ - hkfp->hsf_sc.hsc_action = 0; /* XXX */ - hkfp->hsf_sc.hsc_pad1 = hkfp->hsf_sc.hsc_pad2 = 0; - hkfp->hsf_sc.hsc_onstack = kfp->sf_sc.sc_onstack; - hkfp->hsf_sc.hsc_mask = kfp->sf_sc.sc_mask; - hkfp->hsf_sc.hsc_sp = kfp->sf_sc.sc_sp; - hkfp->hsf_sc.hsc_ps = kfp->sf_sc.sc_ps; - hkfp->hsf_sc.hsc_pc = kfp->sf_sc.sc_pc; - hkfp->hsf_sc.hsc_pad = 0; - hkfp->hsf_sc.hsc_magic = 0xdeadbeef; - hkfp->hsf_sc.hsc_realsc = kfp->sf_scp; - bcopy((caddr_t)frame->f_regs, (caddr_t)hkfp->hsf_regs, - sizeof (hkfp->hsf_regs)); - - kfp->sf_signum = hkfp->hsf_signum; - kfp->sf_scp = hkfp->hsf_scp; - } -#endif - /* XXX do not copy out siginfo if not needed */ - (void) copyout((caddr_t)kfp, (caddr_t)fp, fsize); - frame->f_regs[SP] = (int)fp; -#ifdef DEBUG - if (sigdebug & SDB_FOLLOW) - printf("sendsig(%d): sig %d scp %x fp %x sc_sp %x sc_ap %x\n", - p->p_pid, sig, kfp->sf_scp, fp, - kfp->sf_sc.sc_sp, kfp->sf_sc.sc_ap); -#endif - /* - * Signal trampoline code is at base of user stack. - */ - frame->f_pc = (int)PS_STRINGS - (esigcode - sigcode); -#ifdef DEBUG - if ((sigdebug & SDB_KSTACK) && p->p_pid == sigpid) - printf("sendsig(%d): sig %d returns\n", - p->p_pid, sig); -#endif - free((caddr_t)kfp, M_TEMP); -} - -/* - * System call to cleanup state after a signal - * has been taken. Reset signal mask and - * stack state from context left by sendsig (above). - * Return to previous pc and psl as specified by - * context left by sendsig. Check carefully to - * make sure that the user has not modified the - * psl to gain improper priviledges or to cause - * a machine fault. - */ -/* ARGSUSED */ -sys_sigreturn(p, v, retval) - struct proc *p; - void *v; - register_t *retval; -{ - struct sys_sigreturn_args /* { - syscallarg(struct sigcontext *) sigcntxp; - } */ *uap = v; - register struct sigcontext *scp; - register struct frame *frame; - register int rf; - struct sigcontext tsigc; - struct sigstate tstate; - int flags; - - scp = SCARG(uap, sigcntxp); -#ifdef DEBUG - if (sigdebug & SDB_FOLLOW) - printf("sigreturn: pid %d, scp %x\n", p->p_pid, scp); -#endif - if ((int)scp & 1) - return (EINVAL); -#ifdef COMPAT_HPUX - /* - * Grab context as an HP-UX style context and determine if it - * was one that we contructed in sendsig. - */ - if (p->p_emul == &emul_hpux) { - struct hpuxsigcontext *hscp = (struct hpuxsigcontext *)scp; - struct hpuxsigcontext htsigc; - - if (useracc((caddr_t)hscp, sizeof (*hscp), B_WRITE) == 0 || - copyin((caddr_t)hscp, (caddr_t)&htsigc, sizeof htsigc)) - return (EINVAL); - /* - * If not generated by sendsig or we cannot restore the - * BSD-style sigcontext, just restore what we can -- state - * will be lost, but them's the breaks. - */ - hscp = &htsigc; - if (hscp->hsc_magic != 0xdeadbeef || - (scp = hscp->hsc_realsc) == 0 || - useracc((caddr_t)scp, sizeof (*scp), B_WRITE) == 0 || - copyin((caddr_t)scp, (caddr_t)&tsigc, sizeof tsigc)) { - if (hscp->hsc_onstack & 01) - p->p_sigacts->ps_sigstk.ss_flags |= SA_ONSTACK; - else - p->p_sigacts->ps_sigstk.ss_flags &= ~SA_ONSTACK; - p->p_sigmask = hscp->hsc_mask &~ sigcantmask; - frame = (struct frame *) p->p_md.md_regs; - frame->f_regs[SP] = hscp->hsc_sp; - frame->f_pc = hscp->hsc_pc; - frame->f_sr = hscp->hsc_ps &~ PSL_USERCLR; - return (EJUSTRETURN); - } - /* - * Otherwise, overlay BSD context with possibly modified - * HP-UX values. - */ - tsigc.sc_onstack = hscp->hsc_onstack; - tsigc.sc_mask = hscp->hsc_mask; - tsigc.sc_sp = hscp->hsc_sp; - tsigc.sc_ps = hscp->hsc_ps; - tsigc.sc_pc = hscp->hsc_pc; - } else -#endif - /* - * Test and fetch the context structure. - * We grab it all at once for speed. - */ - if (useracc((caddr_t)scp, sizeof (*scp), B_WRITE) == 0 || - copyin((caddr_t)scp, (caddr_t)&tsigc, sizeof tsigc)) - return (EINVAL); - scp = &tsigc; - if ((scp->sc_ps & (PSL_MBZ|PSL_IPL|PSL_S)) != 0) - return (EINVAL); - /* - * Restore the user supplied information - */ - if (scp->sc_onstack & 01) - p->p_sigacts->ps_sigstk.ss_flags |= SA_ONSTACK; - else - p->p_sigacts->ps_sigstk.ss_flags &= ~SA_ONSTACK; - p->p_sigmask = scp->sc_mask &~ sigcantmask; - frame = (struct frame *) p->p_md.md_regs; - frame->f_regs[SP] = scp->sc_sp; - frame->f_regs[A6] = scp->sc_fp; - frame->f_pc = scp->sc_pc; - frame->f_sr = scp->sc_ps; - /* - * Grab pointer to hardware state information. - * If zero, the user is probably doing a longjmp. - */ - if ((rf = scp->sc_ap) == 0) - return (EJUSTRETURN); - /* - * See if there is anything to do before we go to the - * expense of copying in close to 1/2K of data - */ - flags = fuword((caddr_t)rf); -#ifdef DEBUG - if (sigdebug & SDB_FOLLOW) - printf("sigreturn(%d): sc_ap %x flags %x\n", - p->p_pid, rf, flags); -#endif - /* - * fuword failed (bogus sc_ap value). - */ - if (flags == -1) - return (EINVAL); - if (flags == 0 || copyin((caddr_t)rf, (caddr_t)&tstate, sizeof tstate)) - return (EJUSTRETURN); -#ifdef DEBUG - if ((sigdebug & SDB_KSTACK) && p->p_pid == sigpid) - printf("sigreturn(%d): ssp %x usp %x scp %x ft %d\n", - p->p_pid, &flags, scp->sc_sp, SCARG(uap, sigcntxp), - (flags&SS_RTEFRAME) ? tstate.ss_frame.f_format : -1); -#endif - /* - * Restore most of the users registers except for A6 and SP - * which were handled above. - */ - if (flags & SS_USERREGS) - bcopy((caddr_t)tstate.ss_frame.f_regs, - (caddr_t)frame->f_regs, sizeof(frame->f_regs)-2*NBPW); - /* - * Restore long stack frames. Note that we do not copy - * back the saved SR or PC, they were picked up above from - * the sigcontext structure. - */ - if (flags & SS_RTEFRAME) { - register int sz; - - /* grab frame type and validate */ - sz = tstate.ss_frame.f_format; - if (sz > 15 || (sz = exframesize[sz]) < 0) - return (EINVAL); - frame->f_stackadj -= sz; - frame->f_format = tstate.ss_frame.f_format; - frame->f_vector = tstate.ss_frame.f_vector; - bcopy((caddr_t)&tstate.ss_frame.F_u, (caddr_t)&frame->F_u, sz); -#ifdef DEBUG - if (sigdebug & SDB_FOLLOW) - printf("sigreturn(%d): copy in %d of frame type %d\n", - p->p_pid, sz, tstate.ss_frame.f_format); -#endif - } -#ifdef FPCOPROC - /* - * Finally we restore the original FP context - */ - if (flags & SS_FPSTATE) - m68881_restore(&tstate.ss_fpstate); -#ifdef DEBUG - if ((sigdebug & SDB_FPSTATE) && *(char *)&tstate.ss_fpstate) - printf("sigreturn(%d): copied in FP state (%x) at %x\n", - p->p_pid, *(u_int *)&tstate.ss_fpstate, - &tstate.ss_fpstate); -#endif -#endif -#ifdef DEBUG - if ((sigdebug & SDB_FOLLOW) || - ((sigdebug & SDB_KSTACK) && p->p_pid == sigpid)) - printf("sigreturn(%d): returns\n", p->p_pid); -#endif - return (EJUSTRETURN); -} - int waittime = -1; static struct haltvec *halts; diff --git a/sys/arch/mvme68k/mvme68k/trap.c b/sys/arch/mvme68k/mvme68k/trap.c index f46ac56a999..9a4ed40be2d 100644 --- a/sys/arch/mvme68k/mvme68k/trap.c +++ b/sys/arch/mvme68k/mvme68k/trap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: trap.c,v 1.15 1997/02/24 13:00:54 deraadt Exp $ */ +/* $OpenBSD: trap.c,v 1.16 1997/03/31 00:24:16 downsj Exp $ */ /* * Copyright (c) 1995 Theo de Raadt @@ -320,9 +320,7 @@ copyfault: i = SIGBUS; break; -#ifdef FPCOPROC case T_COPERR: /* kernel coprocessor violation */ -#endif case T_FMTERR|T_USER: /* do all RTE errors come in as T_USER? */ case T_FMTERR: /* ...just in case... */ /* @@ -343,7 +341,6 @@ copyfault: v = frame.f_pc; break; -#ifdef FPCOPROC case T_COPERR|T_USER: /* user coprocessor violation */ /* What is a proper response here? */ typ = FPE_FLTINV; @@ -366,7 +363,6 @@ copyfault: i = SIGFPE; v = frame.f_pc; break; -#endif #ifdef M68040 case T_FPEMULI|T_USER: /* unimplemented FP instuction */ diff --git a/sys/arch/mvme68k/mvme68k/vm_machdep.c b/sys/arch/mvme68k/mvme68k/vm_machdep.c index ac04b72e91f..e51c2c5850e 100644 --- a/sys/arch/mvme68k/mvme68k/vm_machdep.c +++ b/sys/arch/mvme68k/mvme68k/vm_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vm_machdep.c,v 1.7 1996/06/11 10:15:58 deraadt Exp $ */ +/* $OpenBSD: vm_machdep.c,v 1.8 1997/03/31 00:24:17 downsj Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -76,8 +76,6 @@ cpu_fork(p1, p2) extern struct pcb *curpcb; extern void proc_trampoline(), child_return(); - p2->p_md.md_flags = p1->p_md.md_flags & ~MDP_HPUXTRACE; - /* Sync curpcb (which is presumably p1's PCB) and copy it to p2. */ savectx(curpcb); *pcb = p1->p_addr->u_pcb; @@ -145,18 +143,6 @@ cpu_coredump(p, vp, cred, chdr) struct ucred *cred; struct core *chdr; { - -#ifdef COMPAT_HPUX - extern struct emul emul_hpux; - - /* - * If we loaded from an HP-UX format binary file we dump enough - * of an HP-UX style user struct so that the HP-UX debuggers can - * grok it. - */ - if (p->p_emul == &emul_hpux) - return (hpux_dumpu(vp, cred)); -#endif return (vn_rdwr(UIO_WRITE, vp, (caddr_t) p->p_addr, USPACE, (off_t)0, UIO_SYSSPACE, IO_NODELOCKED|IO_UNIT, cred, (int *) NULL, p)); |