BSD 4_4_Lite2 release
[unix-history] / usr / src / sys / hp300 / hp300 / trap.c
index adc3a53..f18333b 100644 (file)
@@ -1,17 +1,43 @@
 /*
  * Copyright (c) 1988 University of Utah.
 /*
  * Copyright (c) 1988 University of Utah.
- * Copyright (c) 1982, 1986, 1990 The Regents of the University of California.
- * All rights reserved.
+ * Copyright (c) 1982, 1986, 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.
  *
  *
  * This code is derived from software contributed to Berkeley by
  * the Systems Programming Group of the University of Utah Computer
  * Science Department.
  *
- * %sccs.include.redist.c%
+ * 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.
  *
  * from: Utah $Hdr: trap.c 1.37 92/12/20$
  *
  *
  * from: Utah $Hdr: trap.c 1.37 92/12/20$
  *
- *     @(#)trap.c      7.26 (Berkeley) %G%
+ *     @(#)trap.c      8.7 (Berkeley) 2/19/95
  */
 
 #include <sys/param.h>
  */
 
 #include <sys/param.h>
@@ -120,30 +146,30 @@ again:
 #endif
        /* take pending signals */
        while ((sig = CURSIG(p)) != 0)
 #endif
        /* 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_resched) {
                /*
                 * 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 (want_resched) {
                /*
                 * 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 setrq ourselves but before we
-                * swtch()'ed, we might not be on the queue indicated by
-                * our priority.
+                * If that happened after we put ourselves on the run queue
+                * but before we mi_switch()'ed, we might not be on the queue
+                * indicated by our priority.
                 */
                s = splstatclock();
                 */
                s = splstatclock();
-               setrq(p);
+               setrunqueue(p);
                p->p_stats->p_ru.ru_nivcsw++;
                p->p_stats->p_ru.ru_nivcsw++;
-               swtch();
+               mi_switch();
                splx(s);
                while ((sig = CURSIG(p)) != 0)
                splx(s);
                while ((sig = CURSIG(p)) != 0)
-                       psig(sig);
+                       postsig(sig);
        }
 
        /*
         * If profiling, charge system time to the trapped pc.
         */
        }
 
        /*
         * If profiling, charge system time to the trapped pc.
         */
-       if (p->p_flag & SPROFIL) {
+       if (p->p_flag & P_PROFIL) {
                extern int psratio;
 
                addupc_task(p, fp->f_pc,
                extern int psratio;
 
                addupc_task(p, fp->f_pc,
@@ -175,7 +201,7 @@ again:
                }
        }
 #endif
                }
        }
 #endif
-       curpri = p->p_pri;
+       curpriority = p->p_priority;
 }
 
 /*
 }
 
 /*
@@ -190,12 +216,11 @@ trap(type, code, v, frame)
        register unsigned v;
        struct frame frame;
 {
        register unsigned v;
        struct frame frame;
 {
-       register int i;
-       unsigned ucode;
+       extern char fswintr[];
        register struct proc *p;
        register struct proc *p;
+       register int i;
+       u_int ucode;
        u_quad_t sticks;
        u_quad_t sticks;
-       unsigned ncode;
-       extern char fswintr[];
 
        cnt.v_trap++;
        p = curproc;
 
        cnt.v_trap++;
        p = curproc;
@@ -237,18 +262,33 @@ copyfault:
                i = SIGBUS;
                break;
 
                i = SIGBUS;
                break;
 
+#ifdef HP380
+       case T_ADDRERR:
+               /*
+                * Yow!  Looks like we get a kernel exception if the PC
+                * in the RTE frame is odd on a 68040 (not on a 68030).
+                * It comes through as a user exception for access faults
+                * (T_MMUFLT).
+                */
+               if (*(short *)frame.f_pc != 0x4e73)
+                       goto dopanic;
+               /* fall through */
+#endif
+
 #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... */
 #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... */
-       /*
-        * The user has most likely trashed the RTE or FP state info
-        * in the stack frame of a signal handler.
-        */
+               /*
+                * The user has most likely trashed the RTE or FP state info
+                * in the stack frame of a signal handler.
+                */
                type |= T_USER;
                printf("pid %d: kernel %s exception\n", p->p_pid,
                type |= T_USER;
                printf("pid %d: kernel %s exception\n", p->p_pid,
-                      type==T_COPERR ? "coprocessor" : "format");
+                      (type==T_COPERR|T_USER) ? "coprocessor" :
+                      (type==T_ADDRERR|T_USER) ? "RTE address" :
+                      "RTE format");
                p->p_sigacts->ps_sigact[SIGILL] = SIG_DFL;
                i = sigmask(SIGILL);
                p->p_sigignore &= ~i;
                p->p_sigacts->ps_sigact[SIGILL] = SIG_DFL;
                i = sigmask(SIGILL);
                p->p_sigignore &= ~i;
@@ -408,8 +448,8 @@ copyfault:
                        return;
                }
                spl0();
                        return;
                }
                spl0();
-               if (p->p_flag & SOWEUPC) {
-                       p->p_flag &= ~SOWEUPC;
+               if (p->p_flag & P_OWEUPC) {
+                       p->p_flag &= ~P_OWEUPC;
                        ADDUPROF(p);
                }
                goto out;
                        ADDUPROF(p);
                }
                goto out;
@@ -850,7 +890,7 @@ syscall(code, frame)
        register caddr_t params;
        register struct sysent *callp;
        register struct proc *p;
        register caddr_t params;
        register struct sysent *callp;
        register struct proc *p;
-       int error, opc, numsys, s;
+       int error, opc, numsys;
        u_int argsize;
        struct args {
                int i[8];
        u_int argsize;
        struct args {
                int i[8];
@@ -878,7 +918,7 @@ syscall(code, frame)
        params = (caddr_t)frame.f_regs[SP] + sizeof(int);
        switch (code) {
 
        params = (caddr_t)frame.f_regs[SP] + sizeof(int);
        switch (code) {
 
-       case SYS_indir:
+       case SYS_syscall:
                /*
                 * Code is first argument, followed by actual args.
                 */
                /*
                 * Code is first argument, followed by actual args.
                 */
@@ -893,9 +933,9 @@ syscall(code, frame)
                        code = numsys;
                break;
 
                        code = numsys;
                break;
 
-       case SYS___indir:
+       case SYS___syscall:
                /*
                /*
-                * Like indir, but code is a quad, so as to maintain
+                * Like syscall, but code is a quad, so as to maintain
                 * quad alignment for the rest of the arguments.
                 */
 #ifdef HPUXCOMPAT
                 * quad alignment for the rest of the arguments.
                 */
 #ifdef HPUXCOMPAT
@@ -913,25 +953,25 @@ syscall(code, frame)
        if (code < numsys)
                callp += code;
        else
        if (code < numsys)
                callp += code;
        else
-               callp += SYS_indir;     /* => nosys */
-       argsize = callp->sy_narg * sizeof(int);
+               callp += SYS_syscall;   /* => nosys */
+       argsize = callp->sy_argsize;
        if (argsize && (error = copyin(params, (caddr_t)&args, argsize))) {
 #ifdef KTRACE
                if (KTRPOINT(p, KTR_SYSCALL))
        if (argsize && (error = copyin(params, (caddr_t)&args, argsize))) {
 #ifdef KTRACE
                if (KTRPOINT(p, KTR_SYSCALL))
-                       ktrsyscall(p->p_tracep, code, callp->sy_narg, args.i);
+                       ktrsyscall(p->p_tracep, code, argsize, args.i);
 #endif
                goto bad;
        }
 #ifdef KTRACE
        if (KTRPOINT(p, KTR_SYSCALL))
 #endif
                goto bad;
        }
 #ifdef KTRACE
        if (KTRPOINT(p, KTR_SYSCALL))
-               ktrsyscall(p->p_tracep, code, callp->sy_narg, args.i);
+               ktrsyscall(p->p_tracep, code, argsize, args.i);
 #endif
        rval[0] = 0;
        rval[1] = frame.f_regs[D1];
 #ifdef HPUXCOMPAT
        /* debug kludge */
        if (callp->sy_call == notimp)
 #endif
        rval[0] = 0;
        rval[1] = frame.f_regs[D1];
 #ifdef HPUXCOMPAT
        /* debug kludge */
        if (callp->sy_call == notimp)
-               error = notimp(p, args.i, rval, code, callp->sy_narg);
+               error = notimp(p, args.i, rval, code, argsize);
        else
 #endif
                error = (*callp->sy_call)(p, &args, rval);
        else
 #endif
                error = (*callp->sy_call)(p, &args, rval);