Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/sparc64 move sparc32 MD bits here.
details: https://anonhg.NetBSD.org/src/rev/72fc842d97aa
branches: trunk
changeset: 467526:72fc842d97aa
user: mrg <mrg%NetBSD.org@localhost>
date: Thu Mar 25 16:26:19 1999 +0000
description:
move sparc32 MD bits here.
diffstat:
sys/arch/sparc64/conf/files.sparc64 | 11 +-
sys/arch/sparc64/include/netbsd32_machdep.h | 50 +++++
sys/arch/sparc64/sparc64/netbsd32_machdep.c | 280 ++++++++++++++++++++++++++++
3 files changed, 336 insertions(+), 5 deletions(-)
diffs (truncated from 370 to 300 lines):
diff -r 9d4b219a1c84 -r 72fc842d97aa sys/arch/sparc64/conf/files.sparc64
--- a/sys/arch/sparc64/conf/files.sparc64 Thu Mar 25 16:22:49 1999 +0000
+++ b/sys/arch/sparc64/conf/files.sparc64 Thu Mar 25 16:26:19 1999 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: files.sparc64,v 1.14 1999/02/12 05:57:21 mrg Exp $
+# $NetBSD: files.sparc64,v 1.15 1999/03/25 16:26:20 mrg Exp $
# @(#)files.sparc64 8.1 (Berkeley) 7/19/93
# sparc64-specific configuration info
@@ -53,8 +53,8 @@
attach fdc at mainbus, sbus
device fd: disk
attach fd at fdc
-file arch/sparc64/dev/fd.c fdc | fd needs-flag
-file arch/sparc64/sparc/bsd_fdintr.s fdc
+file dev/sun/fd.c fdc | fd needs-flag
+file arch/sparc64/sparc64/bsd_fdintr.s fdc
#
# Console (zs) related stuff
@@ -190,8 +190,9 @@
# Binary compatiblity with previous NetBSD releases.
file arch/sparc64/sparc64/compat_13_machdep.c compat_13
-# NetBSD/sparc Binary compatibility (COMPAT_SPARC32)
-include "../../../compat/sparc32/files.sparc32"
+# NetBSD/sparc Binary compatibility (COMPAT_NETBSD32)
+include "../../../compat/netbsd32/files.netbsd32"
+file arch/sparc64/sparc64/netbsd32_machdep.c compat_netbsd32
# SVR4 Binary Compatibility (COMPAT_SVR4)
include "../../../compat/svr4/files.svr4"
diff -r 9d4b219a1c84 -r 72fc842d97aa sys/arch/sparc64/include/netbsd32_machdep.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/sparc64/include/netbsd32_machdep.h Thu Mar 25 16:26:19 1999 +0000
@@ -0,0 +1,50 @@
+/* $NetBSD: netbsd32_machdep.h,v 1.1 1999/03/25 16:26:19 mrg Exp $ */
+
+/*
+ * Copyright (c) 1998 Matthew R. Green
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED 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.
+ */
+
+#ifndef _MACHINE_NETBSD32_H_
+#define _MACHINE_NETBSD32_H_
+
+/* from <arch/sparc/include/signal.h> */
+typedef u_int32_t netbsd32_sigcontextp_t;
+
+/* XXX how can this work? */
+struct sparc32_sigcontext {
+ int sc_onstack; /* sigstack state to restore */
+ int sc_mask; /* signal mask to restore */
+ /* begin machine dependent portion */
+ int sc_sp; /* %sp to restore */
+ int sc_pc; /* pc to restore */
+ int sc_npc; /* npc to restore */
+ int sc_psr; /* psr to restore */
+ int sc_g1; /* %g1 to restore */
+ int sc_o0; /* %o0 to restore */
+};
+
+#endif /* _MACHINE_NETBSD32_H_ */
diff -r 9d4b219a1c84 -r 72fc842d97aa sys/arch/sparc64/sparc64/netbsd32_machdep.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/sparc64/sparc64/netbsd32_machdep.c Thu Mar 25 16:26:19 1999 +0000
@@ -0,0 +1,280 @@
+/*
+ * Set up registers on exec.
+ *
+ * XXX this entire mess must be fixed
+ */
+/* ARGSUSED */
+void
+sparc32_setregs(p, pack, stack)
+ struct proc *p;
+ struct exec_package *pack;
+ u_long stack; /* XXX */
+{
+ register struct trapframe *tf = p->p_md.md_tf;
+ register struct fpstate *fs;
+ register int64_t tstate;
+
+ /* Don't allow misaligned code by default */
+ p->p_md.md_flags &= ~MDP_FIXALIGN;
+
+ /*
+ * Set the registers to 0 except for:
+ * %o6: stack pointer, built in exec())
+ * %tstate: (retain icc and xcc and cwp bits)
+ * %g1: address of PS_STRINGS (used by crt0)
+ * %tpc,%tnpc: entry point of program
+ */
+ tstate = ((PSTATE_USER)<<TSTATE_PSTATE_SHIFT)
+ | (tf->tf_tstate & TSTATE_CWP);
+ if ((fs = p->p_md.md_fpstate) != NULL) {
+ /*
+ * We hold an FPU state. If we own *the* FPU chip state
+ * we must get rid of it, and the only way to do that is
+ * to save it. In any case, get rid of our FPU state.
+ */
+ if (p == fpproc) {
+ savefpstate(fs);
+ fpproc = NULL;
+ }
+ free((void *)fs, M_SUBPROC);
+ p->p_md.md_fpstate = NULL;
+ }
+ bzero((caddr_t)tf, sizeof *tf);
+ tf->tf_tstate = tstate;
+ tf->tf_global[1] = (int)PS_STRINGS;
+ tf->tf_pc = pack->ep_entry & ~3;
+ tf->tf_npc = tf->tf_pc + 4;
+
+ stack -= sizeof(struct rwindow32);
+ tf->tf_out[6] = stack;
+ tf->tf_out[7] = NULL;
+}
+
+/*
+ * NB: since this is a 32-bit address world, sf_scp and sf_sc
+ * can't be a pointer since those are 64-bits wide.
+ */
+struct netbsd32_sigframe {
+ int sf_signo; /* signal number */
+ int sf_code; /* code */
+ u_int sf_scp; /* SunOS user addr of sigcontext */
+ int sf_addr; /* SunOS compat, always 0 for now */
+ struct sparc32_sigcontext sf_sc; /* actual sigcontext */
+};
+
+#undef DEBUG
+#ifdef DEBUG
+extern int sigdebug;
+#endif
+
+void
+netbsd32_sendsig(catcher, sig, mask, code)
+ sig_t catcher;
+ int sig, mask;
+ u_long code;
+{
+ register struct proc *p = curproc;
+ register struct sigacts *psp = p->p_sigacts;
+ register struct sparc32_sigframe *fp;
+ register struct trapframe *tf;
+ register int addr, onstack;
+ struct rwindow32 *kwin, *oldsp, *newsp;
+ struct sparc32_sigframe sf;
+ extern char sigcode[], esigcode[];
+#define szsigcode (esigcode - sigcode)
+
+ tf = p->p_md.md_tf;
+ /* Need to attempt to zero extend this 32-bit pointer */
+ oldsp = (struct rwindow32 *)(u_long)(u_int)tf->tf_out[6];
+ /* Do we need to jump onto the signal stack? */
+ onstack =
+ (psp->ps_sigstk.ss_flags & (SS_DISABLE | SS_ONSTACK)) == 0 &&
+ (psp->ps_sigact[sig].sa_flags & SA_ONSTACK) != 0;
+ if (onstack) {
+ fp = (struct sparc32_sigframe *)(psp->ps_sigstk.ss_sp +
+ psp->ps_sigstk.ss_size);
+ psp->ps_sigstk.ss_flags |= SS_ONSTACK;
+ } else
+ fp = (struct sparc32_sigframe *)oldsp;
+ fp = (struct sparc32_sigframe *)((long)(fp - 1) & ~7);
+
+#ifdef DEBUG
+ sigpid = p->p_pid;
+ if ((sigdebug & SDB_KSTACK) && p->p_pid == sigpid) {
+ printf("sendsig: %s[%d] sig %d newusp %p scp %p oldsp %p\n",
+ p->p_comm, p->p_pid, sig, fp, &fp->sf_sc, oldsp);
+ if (sigdebug & SDB_DDB) Debugger();
+ }
+#endif
+ /*
+ * Now set up the signal frame. We build it in kernel space
+ * and then copy it out. We probably ought to just build it
+ * directly in user space....
+ */
+ sf.sf_signo = sig;
+ sf.sf_code = code;
+#ifdef COMPAT_SUNOS
+ sf.sf_scp = (u_long)&fp->sf_sc;
+#endif
+ sf.sf_addr = 0; /* XXX */
+
+ /*
+ * Build the signal context to be used by sigreturn.
+ */
+ sf.sf_sc.sc_onstack = onstack;
+ sf.sf_sc.sc_mask = mask;
+ sf.sf_sc.sc_sp = (long)oldsp;
+ sf.sf_sc.sc_pc = tf->tf_pc;
+ sf.sf_sc.sc_npc = tf->tf_npc;
+ sf.sf_sc.sc_psr = TSTATECCR_TO_PSR(tf->tf_tstate); /* XXX */
+ sf.sf_sc.sc_g1 = tf->tf_global[1];
+ sf.sf_sc.sc_o0 = tf->tf_out[0];
+
+ /*
+ * Put the stack in a consistent state before we whack away
+ * at it. Note that write_user_windows may just dump the
+ * registers into the pcb; we need them in the process's memory.
+ * We also need to make sure that when we start the signal handler,
+ * its %i6 (%fp), which is loaded from the newly allocated stack area,
+ * joins seamlessly with the frame it was in when the signal occurred,
+ * so that the debugger and _longjmp code can back up through it.
+ */
+ newsp = (struct rwindow32 *)((long)fp - sizeof(struct rwindow32));
+ write_user_windows();
+#ifdef DEBUG
+ if ((sigdebug & SDB_KSTACK))
+ printf("sendsig: saving sf to %p, setting stack pointer %p to %p\n",
+ fp, &(((union rwindow *)newsp)->v8.rw_in[6]), oldsp);
+#endif
+ kwin = (struct rwindow32 *)(((caddr_t)tf)-CCFSZ);
+ if (rwindow_save(p) ||
+ copyout((caddr_t)&sf, (caddr_t)fp, sizeof sf) ||
+ suword(&(((union rwindow *)newsp)->v8.rw_in[6]), (u_long)oldsp)) {
+ /*
+ * Process has trashed its stack; give it an illegal
+ * instruction to halt it in its tracks.
+ */
+#ifdef DEBUG
+ if ((sigdebug & SDB_KSTACK) && p->p_pid == sigpid)
+ printf("sendsig: window save or copyout error\n");
+ printf("sendsig: stack was trashed trying to send sig %d, sending SIGILL\n", sig);
+ if (sigdebug & SDB_DDB) Debugger();
+#endif
+ sigexit(p, SIGILL);
+ /* NOTREACHED */
+ }
+
+#ifdef DEBUG
+ if (sigdebug & SDB_FOLLOW) {
+ printf("sendsig: %s[%d] sig %d scp %p\n",
+ p->p_comm, p->p_pid, sig, &fp->sf_sc);
+ }
+#endif
+ /*
+ * Arrange to continue execution at the code copied out in exec().
+ * It needs the function to call in %g1, and a new stack pointer.
+ */
+ addr = (long)PS_STRINGS - szsigcode;
+ tf->tf_global[1] = (long)catcher;
+ tf->tf_pc = addr;
+ tf->tf_npc = addr + 4;
+ tf->tf_out[6] = (u_int64_t)(u_int)(u_long)newsp;
+
+ /* Remember that we're now on the signal stack. */
+ if (onstack)
+ psp->ps_sigstk.ss_flags |= SS_ONSTACK;
+
+#ifdef DEBUG
+ if ((sigdebug & SDB_KSTACK) && p->p_pid == sigpid) {
+ printf("sendsig: about to return to catcher %p thru %p\n",
+ catcher, addr);
+ if (sigdebug & SDB_DDB) Debugger();
+ }
+#endif
+}
+
+#undef DEBUG
+int
+compat_sparc32_sigreturn(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct compat_sparc32_sigreturn_args /* {
+ syscallarg(struct sparc32_sigcontext *) sigcntxp;
+ } */ *uap = v;
+ struct sparc32_sigcontext *scp;
+ struct sparc32_sigcontext sc;
+ register struct trapframe *tf;
+ struct rwindow32 *rwstack, *kstack;
+ sigset_t mask;
Home |
Main Index |
Thread Index |
Old Index