BSD 4_4_Lite1 release
[unix-history] / usr / src / sys / sparc / sparc / trap.c
index b460ba0..855516b 100644 (file)
@@ -1,40 +1,70 @@
 /*
 /*
- * Copyright (c) 1992 The Regents of the University of California.
- * All rights reserved.
+ * Copyright (c) 1992, 1993
+ *     The Regents of the University of California.  All rights reserved.
  *
  * This software was developed by the Computer Systems Engineering group
  * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
  * contributed to Berkeley.
  *
  *
  * This software was developed by the Computer Systems Engineering group
  * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
  * contributed to Berkeley.
  *
- * %sccs.include.redist.c%
+ * 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, Lawrence Berkeley Laboratory.
  *
  *
- *     @(#)trap.c      7.1 (Berkeley) %G%
+ * 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.
  *
  *
- * from: $Header: trap.c,v 1.31 92/07/11 11:08:57 torek Exp $
+ * 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.
+ *
+ *     @(#)trap.c      8.4 (Berkeley) 9/23/93
+ *
+ * from: $Header: trap.c,v 1.34 93/05/28 04:34:50 torek Exp $
  */
 
  */
 
-#include "param.h"
-#include "systm.h"
-#include "proc.h"
-#include "user.h"
-#include "kernel.h"
-#include "malloc.h"
-#include "resource.h"
-#include "signal.h"
-#include "wait.h"
-#include "syscall.h"
-#include "syslog.h"
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/proc.h>
+#include <sys/user.h>
+#include <sys/kernel.h>
+#include <sys/malloc.h>
+#include <sys/resource.h>
+#include <sys/signal.h>
+#include <sys/wait.h>
+#include <sys/syscall.h>
+#include <sys/syslog.h>
 #ifdef KTRACE
 #ifdef KTRACE
-#include "ktrace.h"
+#include <sys/ktrace.h>
 #endif
 
 #endif
 
-#include "vm/vm_kern.h"
-
-#include "machine/cpu.h"
-#include "machine/frame.h"
-#include "machine/trap.h"
+#include <vm/vm_kern.h>
 
 
-#include "ctlreg.h"
+#include <machine/cpu.h>
+#include <machine/ctlreg.h>
+#include <machine/frame.h>
+#include <machine/trap.h>
 
 #define        offsetof(s, f) ((int)&((s *)0)->f)
 
 
 #define        offsetof(s, f) ((int)&((s *)0)->f)
 
@@ -49,8 +79,8 @@ int   rwindow_debug = 0;
  * seems to imply that we should do this, and it does make sense.
  */
 struct fpstate initfpstate = {
  * seems to imply that we should do this, and it does make sense.
  */
 struct fpstate initfpstate = {
-       ~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0,
-       ~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0,
+       ~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0,
+         ~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0 }
 };
 
 /*
 };
 
 /*
@@ -131,40 +161,40 @@ userret(struct proc *p, int pc, u_quad_t oticks)
 
        /* take pending signals */
        while ((sig = CURSIG(p)) != 0)
 
        /* take pending signals */
        while ((sig = CURSIG(p)) != 0)
-               psig(sig);
-       p->p_pri = p->p_usrpri;
+               postsig(sig);
+       p->p_priority = p->p_usrpri;
        if (want_ast) {
                want_ast = 0;
        if (want_ast) {
                want_ast = 0;
-               if (p->p_flag & SOWEUPC) {
-                       p->p_flag &= ~SOWEUPC;
+               if (p->p_flag & P_OWEUPC) {
+                       p->p_flag &= ~P_OWEUPC;
                        ADDUPROF(p);
                }
        }
        if (want_resched) {
                /*
                        ADDUPROF(p);
                }
        }
        if (want_resched) {
                /*
-                * Since we are curproc, a clock interrupt could
-                * change our priority without changing run queues
-                * (the running process is not kept on a run queue).
-                * If this happened after we setrq ourselves but
-                * before we swtch()'ed, we might not be on the queue
+                * Since we are curproc, clock will normally just change
+                * our priority without moving us from one queue to another
+                * (since the running process is not on a queue.)
+                * If that happened after we put ourselves on the run queue
+                * but before we switched, we might not be on the queue
                 * indicated by our priority.
                 */
                (void) splstatclock();
                 * indicated by our priority.
                 */
                (void) splstatclock();
-               setrq(p);
+               setrunqueue(p);
                p->p_stats->p_ru.ru_nivcsw++;
                p->p_stats->p_ru.ru_nivcsw++;
-               swtch();
+               mi_switch();
                (void) spl0();
                while ((sig = CURSIG(p)) != 0)
                (void) spl0();
                while ((sig = CURSIG(p)) != 0)
-                       psig(sig);
+                       postsig(sig);
        }
 
        /*
         * If profiling, charge recent system time to the trapped pc.
         */
        }
 
        /*
         * If profiling, charge recent system time to the trapped pc.
         */
-       if (p->p_flag & SPROFIL)
+       if (p->p_flag & P_PROFIL)
                addupc_task(p, pc, (int)(p->p_sticks - oticks));
 
                addupc_task(p, pc, (int)(p->p_sticks - oticks));
 
-       curpri = p->p_pri;
+       curpriority = p->p_priority;
 }
 
 /*
 }
 
 /*
@@ -672,8 +702,8 @@ syscall(code, tf, pc, suncompat)
         * Any arguments beyond that are in the `argument extension' area
         * of the user's stack frame (see <machine/frame.h>).
         *
         * Any arguments beyond that are in the `argument extension' area
         * of the user's stack frame (see <machine/frame.h>).
         *
-        * Check for ``special'' codes that alter this, namely indir and
-        * __indir.  The latter takes a quad syscall number, so that other
+        * Check for ``special'' codes that alter this, namely syscall and
+        * __syscall.  The latter takes a quad syscall number, so that other
         * arguments are at their natural alignments.  Adjust the number
         * of ``easy'' arguments as appropriate; we will copy the hard
         * ones later as needed.
         * arguments are at their natural alignments.  Adjust the number
         * of ``easy'' arguments as appropriate; we will copy the hard
         * ones later as needed.
@@ -682,12 +712,12 @@ syscall(code, tf, pc, suncompat)
        nap = 6;
        switch (code) {
 
        nap = 6;
        switch (code) {
 
-       case SYS_indir:
+       case SYS_syscall:
                code = *ap++;
                nap--;
                break;
 
                code = *ap++;
                nap--;
                break;
 
-       case SYS___indir:
+       case SYS___syscall:
 #ifdef COMPAT_SUNOS
                if (suncompat)
                        break;
 #ifdef COMPAT_SUNOS
                if (suncompat)
                        break;
@@ -698,7 +728,7 @@ syscall(code, tf, pc, suncompat)
                break;
 
        }
                break;
 
        }
-       /* Callp currently points to indir, which returns ENOSYS. */
+       /* Callp currently points to syscall, which returns ENOSYS. */
        if (code < nsys) {
                callp += code;
                i = callp->sy_narg;
        if (code < nsys) {
                callp += code;
                i = callp->sy_narg;