update for 4.4BSD-alpha distribution
authorAkito Fujita <fujita@ucbvax.Berkeley.EDU>
Fri, 24 Jul 1992 07:12:04 +0000 (23:12 -0800)
committerAkito Fujita <fujita@ucbvax.Berkeley.EDU>
Fri, 24 Jul 1992 07:12:04 +0000 (23:12 -0800)
SCCS-vsn: sys/luna68k/luna68k/clock.c 7.2
SCCS-vsn: sys/luna68k/luna68k/conf.c 7.2
SCCS-vsn: sys/luna68k/luna68k/genassym.c 7.2
SCCS-vsn: sys/luna68k/luna68k/locore.s 7.3
SCCS-vsn: sys/luna68k/luna68k/machdep.c 7.3
SCCS-vsn: sys/luna68k/luna68k/trap.c 7.2
SCCS-vsn: sys/luna68k/dev/if_le.c 7.2
SCCS-vsn: sys/luna68k/dev/if_lereg.h 7.2
SCCS-vsn: sys/luna68k/include/cpu.h 7.2
SCCS-vsn: sys/luna68k/include/param.h 7.2

usr/src/sys/luna68k/dev/if_le.c
usr/src/sys/luna68k/dev/if_lereg.h
usr/src/sys/luna68k/include/cpu.h
usr/src/sys/luna68k/include/param.h
usr/src/sys/luna68k/luna68k/clock.c
usr/src/sys/luna68k/luna68k/conf.c
usr/src/sys/luna68k/luna68k/genassym.c
usr/src/sys/luna68k/luna68k/locore.s
usr/src/sys/luna68k/luna68k/machdep.c
usr/src/sys/luna68k/luna68k/trap.c

index f6b2a7e..dce8611 100644 (file)
@@ -1,10 +1,12 @@
 /*
 /*
- * Copyright (c) 1982, 1990, 1992 The Regents of the University of California.
+ * Copyright (c) 1982, 1990 The Regents of the University of California.
  * All rights reserved.
  *
  * %sccs.include.redist.c%
  *
  * All rights reserved.
  *
  * %sccs.include.redist.c%
  *
- *     @(#)if_le.c     7.1 (Berkeley) %G%
+ * from: hp300/dev/if_le.c     7.12 (Berkeley) 7/6/92
+ *
+ *     @(#)if_le.c     7.2 (Berkeley) %G%
  */
 
 #include "le.h"
  */
 
 #include "le.h"
@@ -15,7 +17,7 @@
 /*
  * AMD 7990 LANCE
  *
 /*
  * AMD 7990 LANCE
  *
- * This driver will generate and accept tailer encapsulated packets even
+ * This driver will accept tailer encapsulated packets even
  * though it buys us nothing.  The motivation was to avoid incompatibilities
  * with VAXen, SUNs, and others that handle and benefit from them.
  * This reasoning is dubious.
  * though it buys us nothing.  The motivation was to avoid incompatibilities
  * with VAXen, SUNs, and others that handle and benefit from them.
  * This reasoning is dubious.
 #include "netns/ns_if.h"
 #endif
 
 #include "netns/ns_if.h"
 #endif
 
-#ifdef ISO
-extern char all_es_snpa[], all_is_snpa[], all_l1is_snpa[], all_l2is_snpa[];
-#endif
-
 #include "../include/cpu.h"
 #include "../include/mtpr.h"
 #include "device.h"
 #include "../include/cpu.h"
 #include "../include/mtpr.h"
 #include "device.h"
@@ -60,7 +58,6 @@ extern        char all_es_snpa[], all_is_snpa[], all_l1is_snpa[], all_l2is_snpa[];
 #if NBPFILTER > 0
 #include "../net/bpf.h"
 #include "../net/bpfdesc.h"
 #if NBPFILTER > 0
 #include "../net/bpf.h"
 #include "../net/bpfdesc.h"
-char hprmp_multi[] = { 9, 0, 9, 0, 0, 4};
 #endif
 
 
 #endif
 
 
@@ -89,25 +86,24 @@ struct      le_softc {
        struct  lereg1 *sc_r1;  /* LANCE registers */
        struct  lereg2 *sc_r2;  /* dual-port RAM */
        int     sc_rmd;         /* predicted next rmd to process */
        struct  lereg1 *sc_r1;  /* LANCE registers */
        struct  lereg2 *sc_r2;  /* dual-port RAM */
        int     sc_rmd;         /* predicted next rmd to process */
+       int     sc_tmd;         /* next available tmd */
+       int     sc_txcnt;       /* # of transmit buffers in use */
+       /* stats */
        int     sc_runt;
        int     sc_jab;
        int     sc_merr;
        int     sc_babl;
        int     sc_cerr;
        int     sc_miss;
        int     sc_runt;
        int     sc_jab;
        int     sc_merr;
        int     sc_babl;
        int     sc_cerr;
        int     sc_miss;
-       int     sc_xint;
+       int     sc_rown;
        int     sc_xown;
        int     sc_xown;
+       int     sc_xown2;
        int     sc_uflo;
        int     sc_rxlen;
        int     sc_rxoff;
        int     sc_txoff;
        int     sc_busy;
        short   sc_iflags;
        int     sc_uflo;
        int     sc_rxlen;
        int     sc_rxoff;
        int     sc_txoff;
        int     sc_busy;
        short   sc_iflags;
-       caddr_t sc_bpf;
-       int     sc_tmd;         /* predicted next tmd to process */
-       int     sc_txcnt;       /* transmissions in progress */
-       int     sc_txbad;
-       int     sc_txbusy;
 } le_softc[NLE];
 
 /* access LANCE registers */
 } le_softc[NLE];
 
 /* access LANCE registers */
@@ -156,13 +152,8 @@ leattach(hd)
         * Setup for transmit/receive
         */
        ler2->ler2_mode = LE_MODE;
         * Setup for transmit/receive
         */
        ler2->ler2_mode = LE_MODE;
-#if defined(ISO) || NBPFILTER > 0
-       ler2->ler2_ladrf0 = 0xffffffff;
-       ler2->ler2_ladrf1 = 0xffffffff;
-#else
-       ler2->ler2_ladrf0 = 0;
-       ler2->ler2_ladrf1 = 0;
-#endif
+       ler2->ler2_ladrf[0] = 0;
+       ler2->ler2_ladrf[1] = 0;
        ler2->ler2_rlen = LE_RLEN;
        ler2->ler2_rdra = (int)lemem->ler2_rmd;
        ler2->ler2_tlen = LE_TLEN;
        ler2->ler2_rlen = LE_RLEN;
        ler2->ler2_rdra = (int)lemem->ler2_rmd;
        ler2->ler2_tlen = LE_TLEN;
@@ -175,14 +166,94 @@ leattach(hd)
        ifp->if_ioctl = leioctl;
        ifp->if_output = ether_output;
        ifp->if_start = lestart;
        ifp->if_ioctl = leioctl;
        ifp->if_output = ether_output;
        ifp->if_start = lestart;
+#ifdef MULTICAST
+       ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
+#else
        ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX;
        ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX;
+#endif
 #if NBPFILTER > 0
 #if NBPFILTER > 0
-       bpfattach(&le->sc_bpf, ifp, DLT_EN10MB, sizeof(struct ether_header));
+       bpfattach(&ifp->if_bpf, ifp, DLT_EN10MB, sizeof(struct ether_header));
 #endif
        if_attach(ifp);
        return (1);
 }
 
 #endif
        if_attach(ifp);
        return (1);
 }
 
+#ifdef MULTICAST
+/*
+ * Setup the logical address filter
+ */
+void
+lesetladrf(sc)
+       register struct le_softc *sc;
+{
+       register volatile struct lereg2 *ler2 = sc->sc_r2;
+       register struct ifnet *ifp = &sc->sc_if;
+       register struct ether_multi *enm;
+       register u_char *cp;
+       register u_long crc;
+       register u_long c;
+       register int i, len;
+       struct ether_multistep step;
+
+       /*
+        * Set up multicast address filter by passing all multicast
+        * addresses through a crc generator, and then using the high
+        * order 6 bits as a index into the 64 bit logical address
+        * filter. The high order two bits select the word, while the
+        * rest of the bits select the bit within the word.
+        */
+
+       ler2->ler2_ladrf[0] = 0;
+       ler2->ler2_ladrf[1] = 0;
+       ifp->if_flags &= ~IFF_ALLMULTI;
+       ETHER_FIRST_MULTI(step, &sc->sc_ac, enm);
+       while (enm != NULL) {
+               if (bcmp((caddr_t)&enm->enm_addrlo,
+                   (caddr_t)&enm->enm_addrhi, sizeof(enm->enm_addrlo)) == 0) {
+                       /*
+                        * We must listen to a range of multicast
+                        * addresses. For now, just accept all
+                        * multicasts, rather than trying to set only
+                        * those filter bits needed to match the range.
+                        * (At this time, the only use of address
+                        * ranges is for IP multicast routing, for
+                        * which the range is big enough to require all
+                        * bits set.)
+                        */
+                       ler2->ler2_ladrf[0] = 0xffffffff;
+                       ler2->ler2_ladrf[1] = 0xffffffff;
+                       ifp->if_flags |= IFF_ALLMULTI;
+                       return;
+               }
+
+               cp = (unsigned char *)&enm->enm_addrlo;
+               c = *cp;
+               crc = 0xffffffff;
+               len = 6;
+               while (len-- > 0) {
+                       c = *cp;
+                       for (i = 0; i < 8; i++) {
+                               if ((c & 0x01) ^ (crc & 0x01)) {
+                                       crc >>= 1;
+                                       crc = crc ^ 0xedb88320;
+                               }
+                               else
+                                       crc >>= 1;
+                               c >>= 1;
+                       }
+                       cp++;
+               }
+               /* Just want the 6 most significant bits. */
+               crc = crc >> 26;
+
+               /* Turn on the corresponding bit in the filter. */
+               ler2->ler2_ladrf[crc >> 5] |= 1 << (crc & 0x1f);
+
+               ETHER_NEXT_MULTI(step, enm);
+       }
+}
+#endif
+
 ledrinit(ler2, le)
        register struct lereg2 *ler2;
        register struct le_softc *le;
 ledrinit(ler2, le)
        register struct lereg2 *ler2;
        register struct le_softc *le;
@@ -208,6 +279,13 @@ ledrinit(ler2, le)
                ler2->ler2_tmd[i].tmd2 = 0;
                ler2->ler2_tmd[i].tmd3 = 0;
        }
                ler2->ler2_tmd[i].tmd2 = 0;
                ler2->ler2_tmd[i].tmd3 = 0;
        }
+       /* Setup the logical address filter */
+#ifdef MULTICAST
+       lesetladrf(le);
+#else
+       ler2->ler2_ladrf[0] = 0;
+       ler2->ler2_ladrf[1] = 0;
+#endif
 }
 
 lereset(unit)
 }
 
 lereset(unit)
@@ -232,7 +310,7 @@ lereset(unit)
        LERDWR(ler0, LE_CSR0, ler1->ler1_rap);
        LERDWR(ler0, LE_STOP, ler1->ler1_rdp);
        ledrinit(le->sc_r2, le);
        LERDWR(ler0, LE_CSR0, ler1->ler1_rap);
        LERDWR(ler0, LE_STOP, ler1->ler1_rdp);
        ledrinit(le->sc_r2, le);
-       le->sc_txcnt = le->sc_tmd = le->sc_rmd = 0;
+       le->sc_rmd = le->sc_tmd = 0;
        LERDWR(ler0, LE_CSR1, ler1->ler1_rap);
        LERDWR(ler0, (int)&lemem->ler2_mode, ler1->ler1_rdp);
        LERDWR(ler0, LE_CSR2, ler1->ler1_rap);
        LERDWR(ler0, LE_CSR1, ler1->ler1_rap);
        LERDWR(ler0, (int)&lemem->ler2_mode, ler1->ler1_rdp);
        LERDWR(ler0, LE_CSR2, ler1->ler1_rap);
@@ -253,6 +331,7 @@ lereset(unit)
        LERDWR(ler0, LE_CSR0, ler1->ler1_rap);
        LERDWR(ler0, LE_STRT | LE_INEA, ler1->ler1_rdp);
        le->sc_if.if_flags &= ~IFF_OACTIVE;
        LERDWR(ler0, LE_CSR0, ler1->ler1_rap);
        LERDWR(ler0, LE_STRT | LE_INEA, ler1->ler1_rdp);
        le->sc_if.if_flags &= ~IFF_OACTIVE;
+       le->sc_txcnt = 0;
 }
 
 /*
 }
 
 /*
@@ -293,36 +372,38 @@ lestart(ifp)
        register struct mbuf *m;
        int len;
 
        register struct mbuf *m;
        int len;
 
-again:
        if ((le->sc_if.if_flags & IFF_RUNNING) == 0)
                return (0);
        if ((le->sc_if.if_flags & IFF_RUNNING) == 0)
                return (0);
-       IF_DEQUEUE(&le->sc_if.if_snd, m);
-       if (m == 0)
-               return (0);
-       tmd = le->sc_r2->ler2_tmd + le->sc_tmd;
-       if (tmd->tmd1 & LE_OWN)
-               return (le->sc_txbusy++, 0);
-       len = leput(le->sc_r2->ler2_tbuf[le->sc_tmd], m);
+       tmd = &le->sc_r2->ler2_tmd[le->sc_tmd];
+       do {
+               if (tmd->tmd1 & LE_OWN) {
+                       le->sc_xown2++;
+                       return (0);
+               }
+               IF_DEQUEUE(&le->sc_if.if_snd, m);
+               if (m == 0)
+                       return (0);
+               len = leput(le->sc_r2->ler2_tbuf[le->sc_tmd], m);
 #if NBPFILTER > 0
 #if NBPFILTER > 0
-       /*
-        * If bpf is listening on this interface, let it
-        * see the packet before we commit it to the wire.
-        */
-       if (le->sc_bpf)
-                bpf_tap(le->sc_bpf, le->sc_r2->ler2_tbuf[le->sc_tmd], len);
+               /* 
+                * If bpf is listening on this interface, let it 
+                * see the packet before we commit it to the wire.
+                */
+               if (ifp->if_bpf)
+                       bpf_tap(ifp->if_bpf, le->sc_r2->ler2_tbuf[le->sc_tmd],
+                               len);
 #endif
 #endif
-       tmd->tmd3 = 0;
-       tmd->tmd2 = -len;
-       if (++le->sc_tmd >= LETBUF)
-               le->sc_tmd = 0;
-       if (++le->sc_txcnt >= LETBUF) {
-               le->sc_txcnt = LETBUF;
-               le->sc_if.if_flags |= IFF_OACTIVE;
-               tmd->tmd1 = LE_OWN | LE_STP | LE_ENP;
-       } else {
+
+               tmd->tmd3 = 0;
+               tmd->tmd2 = -len;
                tmd->tmd1 = LE_OWN | LE_STP | LE_ENP;
                tmd->tmd1 = LE_OWN | LE_STP | LE_ENP;
-               goto again;
-       }
+               if (++le->sc_tmd == LETBUF) {
+                       le->sc_tmd = 0;
+                       tmd = le->sc_r2->ler2_tmd;
+               } else
+                       tmd++;
+       } while (++le->sc_txcnt < LETBUF);
+       le->sc_if.if_flags |= IFF_OACTIVE;
        return (0);
 }
 
        return (0);
 }
 
@@ -371,14 +452,10 @@ leintr(unit)
                lereset(unit);
                return(1);
        }
                lereset(unit);
                return(1);
        }
-       if (stat & LE_RINT) {
-               /* interrupt is cleared in lerint */
+       if (stat & LE_RINT)
                lerint(unit);
                lerint(unit);
-       }
-       if (stat & LE_TINT) {
-               LERDWR(ler0, LE_TINT|LE_INEA, ler1->ler1_rdp);
+       if (stat & LE_TINT)
                lexint(unit);
                lexint(unit);
-       }
        return(1);
 }
 
        return(1);
 }
 
@@ -391,52 +468,42 @@ lexint(unit)
 {
        register struct le_softc *le = &le_softc[unit];
        register struct letmd *tmd;
 {
        register struct le_softc *le = &le_softc[unit];
        register struct letmd *tmd;
-       int i, loopcount = 0;
+       int i, gotone = 0;
 
 
-       if (le->sc_txcnt == 0) {
-               le->sc_xint++;
-               return;
-       }
-again:
-       if ((i = le->sc_tmd - le->sc_txcnt) < 0) i += LETBUF;
-       tmd = le->sc_r2->ler2_tmd + i;
-       if (tmd->tmd1 & LE_OWN) {
-               if (loopcount)
-                       goto out;
-               le->sc_xown++;
-               return;
-       }
-       if (tmd->tmd1 & LE_ERR) {
-err:
-               lexerror(unit);
-               le->sc_if.if_oerrors++;
-               if (tmd->tmd3 & (LE_TBUFF|LE_UFLO)) {
-                       le->sc_uflo++;
-                       lereset(unit);
+       do {
+               if ((i = le->sc_tmd - le->sc_txcnt) < 0)
+                       i += LETBUF;
+               tmd = &le->sc_r2->ler2_tmd[i];
+               if (tmd->tmd1 & LE_OWN) {
+                       if (gotone)
+                               break;
+                       le->sc_xown++;
+                       return;
                }
                }
-               else if (tmd->tmd3 & LE_LCOL)
-                       le->sc_if.if_collisions++;
-               else if (tmd->tmd3 & LE_RTRY)
-                       le->sc_if.if_collisions += 16;
-       }
-       else if (tmd->tmd3 & LE_TBUFF)
+
+               /* clear interrupt */
+               LERDWR(le->sc_r0, LE_TINT|LE_INEA, le->sc_r1->ler1_rdp);
+
                /* XXX documentation says BUFF not included in ERR */
                /* XXX documentation says BUFF not included in ERR */
-               goto err;
-       else if (tmd->tmd1 & LE_ONE)
-               le->sc_if.if_collisions++;
-       else if (tmd->tmd1 & LE_MORE)
-               /* what is the real number? */
-               le->sc_if.if_collisions += 2;
-       else
-               le->sc_if.if_opackets++;
-       loopcount++;
-       if (--le->sc_txcnt > 0)
-               goto again;
-       if (le->sc_txcnt < 0) {
-               le->sc_txbad++;
-               le->sc_txcnt = 0;
-       }
-out:
+               if ((tmd->tmd1 & LE_ERR) || (tmd->tmd3 & LE_TBUFF)) {
+                       lexerror(unit);
+                       le->sc_if.if_oerrors++;
+                       if (tmd->tmd3 & (LE_TBUFF|LE_UFLO)) {
+                               le->sc_uflo++;
+                               lereset(unit);
+                       } else if (tmd->tmd3 & LE_LCOL)
+                               le->sc_if.if_collisions++;
+                       else if (tmd->tmd3 & LE_RTRY)
+                               le->sc_if.if_collisions += 16;
+               } else if (tmd->tmd1 & LE_ONE)
+                       le->sc_if.if_collisions++;
+               else if (tmd->tmd1 & LE_MORE)
+                       /* what is the real number? */
+                       le->sc_if.if_collisions += 2;
+               else
+                       le->sc_if.if_opackets++;
+               gotone++;
+       } while (--le->sc_txcnt > 0);
        le->sc_if.if_flags &= ~IFF_OACTIVE;
        (void) lestart(&le->sc_if);
 }
        le->sc_if.if_flags &= ~IFF_OACTIVE;
        (void) lestart(&le->sc_if);
 }
@@ -461,6 +528,7 @@ lerint(unit)
         * Out of sync with hardware, should never happen?
         */
        if (rmd->rmd1 & LE_OWN) {
         * Out of sync with hardware, should never happen?
         */
        if (rmd->rmd1 & LE_OWN) {
+               le->sc_rown++;
                LERDWR(le->sc_r0, LE_RINT|LE_INEA, le->sc_r1->ler1_rdp);
                return;
        }
                LERDWR(le->sc_r0, LE_RINT|LE_INEA, le->sc_r1->ler1_rdp);
                return;
        }
@@ -519,7 +587,7 @@ leread(unit, buf, len)
        register struct le_softc *le = &le_softc[unit];
        register struct ether_header *et;
        struct mbuf *m;
        register struct le_softc *le = &le_softc[unit];
        register struct ether_header *et;
        struct mbuf *m;
-       int off, resid;
+       int off, resid, flags;
 
        le->sc_if.if_ipackets++;
        et = (struct ether_header *)buf;
 
        le->sc_if.if_ipackets++;
        et = (struct ether_header *)buf;
@@ -550,32 +618,36 @@ leread(unit, buf, len)
                le->sc_if.if_ierrors++;
                return;
        }
                le->sc_if.if_ierrors++;
                return;
        }
+       flags = 0;
+       if (bcmp((caddr_t)etherbroadcastaddr,
+           (caddr_t)et->ether_dhost, sizeof(etherbroadcastaddr)) == 0)
+               flags |= M_BCAST;
+       if (et->ether_dhost[0] & 1)
+               flags |= M_MCAST;
+
 #if NBPFILTER > 0
        /*
         * Check if there's a bpf filter listening on this interface.
 #if NBPFILTER > 0
        /*
         * Check if there's a bpf filter listening on this interface.
-        * If so, hand off the raw packet to bpf, which must deal with
-        * trailers in its own way.
-        */
-       if (le->sc_bpf)
-               bpf_tap(le->sc_bpf, buf, len + sizeof(struct ether_header));
-#endif
-#if defined(ISO) || NBPFILTER > 0
-       /*
-        * Note that the interface cannot be in promiscuous mode if
-        * there are no bpf listeners.  If we are in promiscuous
-        * mode, we have to check if this packet is really ours.
-        * However, there may be appropriate multicate addresses involved
+        * If so, hand off the raw packet to enet.
         */
         */
-#define NOT_TO(p) (bcmp(et->ether_dhost, p, sizeof(et->ether_dhost)) != 0)
-       if (et->ether_dhost[0] & 1) {
-               if (NOT_TO(etherbroadcastaddr) && NOT_TO(hprmp_multi)
-#ifdef ISO
-                   && NOT_TO(all_es_snpa) && NOT_TO(all_is_snpa)
-                   && NOT_TO(all_l1is_snpa) && NOT_TO(all_l2is_snpa)
+       if (le->sc_if.if_bpf) {
+               bpf_tap(le->sc_if.if_bpf, buf, len + sizeof(struct ether_header));
+
+               /*
+                * Keep the packet if it's a broadcast or has our
+                * physical ethernet address (or if we support
+                * multicast and it's one).
+                */
+               if (
+#ifdef MULTICAST
+                   (flags & (M_BCAST | M_MCAST)) == 0 &&
+#else
+                   (flags & M_BCAST) == 0 &&
 #endif
 #endif
-                    ) return;
-       } else if ((le->sc_if.if_flags & IFF_PROMISC) && NOT_TO(le->sc_addr))
-               return;
+                   bcmp(et->ether_dhost, le->sc_addr,
+                       sizeof(et->ether_dhost)) != 0)
+                       return;
+       }
 #endif
        /*
         * Pull packet off interface.  Off is nonzero if packet
 #endif
        /*
         * Pull packet off interface.  Off is nonzero if packet
@@ -584,6 +656,7 @@ leread(unit, buf, len)
         * the type and length which are at the front of any trailer data.
         */
        m = m_devget((char *)(et + 1), len, off, &le->sc_if, 0);
         * the type and length which are at the front of any trailer data.
         */
        m = m_devget((char *)(et + 1), len, off, &le->sc_if, 0);
+       m->m_flags |= flags;
        if (m == 0)
                return;
        ether_input(&le->sc_if, et, m);
        if (m == 0)
                return;
        ether_input(&le->sc_if, et, m);
@@ -690,6 +763,24 @@ leioctl(ifp, cmd, data)
                }
                break;
 
                }
                break;
 
+#ifdef MULTICAST
+       case SIOCADDMULTI:
+       case SIOCDELMULTI:
+               /* Update our multicast list  */
+               error = (cmd == SIOCADDMULTI) ?
+                   ether_addmulti((struct ifreq *)data, &le->sc_ac) :
+                   ether_delmulti((struct ifreq *)data, &le->sc_ac);
+
+               if (error == ENETRESET) {
+                       /*
+                        * Multicast list has changed; set the hardware
+                        * filter accordingly.
+                        */
+                       lereset(ifp->if_unit);
+                       error = 0;
+               }
+               break;
+#endif
        default:
                error = EINVAL;
        }
        default:
                error = EINVAL;
        }
index 27e191f..2a2039e 100644 (file)
@@ -1,12 +1,20 @@
 /*
 /*
- * Copyright (c) 1982, 1990, 1992 The Regents of the University of California.
+ * Copyright (c) 1982, 1990 The Regents of the University of California.
  * All rights reserved.
  *
  * %sccs.include.redist.c%
  *
  * All rights reserved.
  *
  * %sccs.include.redist.c%
  *
- *     @(#)if_lereg.h  7.1 (Berkeley) %G%
+ * from: hp300/dev/if_lereg.h  7.4 (Berkeley) 7/6/92
+ *
+ *     @(#)if_lereg.h  7.2 (Berkeley) %G%
  */
 
  */
 
+#ifdef KERNEL
+#include "iotypes.h"   /* XXX */
+#else
+#include <luna68k/dev/iotypes.h>       /* XXX */
+#endif
+
 #define        LEID            21
 
 #define        LEMTU           1518
 #define        LEID            21
 
 #define        LEMTU           1518
@@ -18,8 +26,6 @@
 #define        LETBUFLOG2      1
 #define        LE_TLEN         (LETBUFLOG2 << 13)
 
 #define        LETBUFLOG2      1
 #define        LE_TLEN         (LETBUFLOG2 << 13)
 
-#define vu_char                volatile u_char
-
 /*
  * LANCE registers.
  */
 /*
  * LANCE registers.
  */
@@ -37,15 +43,14 @@ struct lereg1 {
 
 /*
  * Overlayed on 16K dual-port RAM.
 
 /*
  * Overlayed on 16K dual-port RAM.
- * Current size is 13,758 bytes with 8 x 1518 receive buffers and
- * 1 x 1518 transmit buffer.
+ * Current size is 15,284 bytes with 8 x 1518 receive buffers and
+ * 2 x 1518 transmit buffers.
  */
 struct lereg2 {
        /* init block */
        u_short ler2_mode;              /* +0x0000 */
        u_char  ler2_padr[6];           /* +0x0002 */
  */
 struct lereg2 {
        /* init block */
        u_short ler2_mode;              /* +0x0000 */
        u_char  ler2_padr[6];           /* +0x0002 */
-       u_long  ler2_ladrf0;            /* +0x0008 */
-       u_long  ler2_ladrf1;            /* +0x000C */
+       u_long  ler2_ladrf[2];          /* +0x0008 */
        u_short ler2_rdra;              /* +0x0010 */
        u_short ler2_rlen;              /* +0x0012 */
        u_short ler2_tdra;              /* +0x0014 */
        u_short ler2_rdra;              /* +0x0010 */
        u_short ler2_rlen;              /* +0x0012 */
        u_short ler2_tdra;              /* +0x0014 */
@@ -64,8 +69,8 @@ struct lereg2 {
                short   tmd2;
                u_short tmd3;
        } ler2_tmd[LETBUF];
                short   tmd2;
                u_short tmd3;
        } ler2_tmd[LETBUF];
-       char    ler2_rbuf[LERBUF][LEMTU]; /* +0x0060 */
-       char    ler2_tbuf[LETBUF][LEMTU]; /* +0x2FD0 */
+       char    ler2_rbuf[LERBUF][LEMTU]; /* +0x0068 */
+       char    ler2_tbuf[LETBUF][LEMTU]; /* +0x2FD8 */
 };
 
 /*
 };
 
 /*
index 03a230c..4965ddf 100644 (file)
@@ -13,7 +13,9 @@
  * from: Utah $Hdr: cpu.h 1.16 91/03/25$
  * OMRON: $Id: cpu.h,v 1.2 92/06/14 06:27:54 moti Exp $
  *
  * from: Utah $Hdr: cpu.h 1.16 91/03/25$
  * OMRON: $Id: cpu.h,v 1.2 92/06/14 06:27:54 moti Exp $
  *
- *     @(#)cpu.h       7.1 (Berkeley) %G%
+ * from: hp300/include/cpu.h   7.12 (Berkeley) 7/8/92
+ *
+ *     @(#)cpu.h       7.2 (Berkeley) %G%
  */
 
 /*
  */
 
 /*
  */
 #define        COPY_SIGCODE            /* copy sigcode above user stack in exec */
 
  */
 #define        COPY_SIGCODE            /* copy sigcode above user stack in exec */
 
-/*
- * function vs. inline configuration;
- * these are defined to get generic functions
- * rather than inline or machine-dependent implementations
- */
-#define        NEED_MINMAX             /* need {,i,l,ul}{min,max} functions */
-#undef NEED_FFS                /* don't need ffs function */
-#undef NEED_BCMP               /* don't need bcmp function */
-#undef NEED_STRLEN             /* don't need strlen function */
-
 #define        cpu_exec(p)     /* nothing */
 #define        cpu_wait(p)     /* nothing */
 #define cpu_setstack(p, ap) \
        (p)->p_md.md_regs[SP] = ap
 
 /*
 #define        cpu_exec(p)     /* nothing */
 #define        cpu_wait(p)     /* nothing */
 #define cpu_setstack(p, ap) \
        (p)->p_md.md_regs[SP] = ap
 
 /*
- * Arguments to hardclock, softclock and gatherstats
- * encapsulate the previous machine state in an opaque
- * clockframe; for 68k, use just what the hardware
- * leaves on the stack.
+ * Arguments to hardclock and gatherstats encapsulate the previous
+ * machine state in an opaque clockframe.  One the 68k, we use
+ * what the hardware pushes on an interrupt (but we pad the sr to a
+ * longword boundary).
  */
  */
-typedef struct intrframe {
-       char    *pc;
-       int     ps;
-} clockframe;
-
-#define        CLKF_USERMODE(framep)   (((framep)->ps & PSL_S) == 0)
-#define        CLKF_BASEPRI(framep)    (((framep)->ps & PSL_IPL7) == 0)
+struct clockframe {
+       u_short pad;            /* pad to get stack aligned */
+       u_short sr;             /* sr at time of interrupt */
+       u_long  pc;             /* pc at time of interrupt */
+       u_short vo;             /* vector offset (4-word frame) */
+};
+
+#define        CLKF_USERMODE(framep)   (((framep)->sr & PSL_S) == 0)
+#define        CLKF_BASEPRI(framep)    (((framep)->sr & PSL_IPL) == 0)
 #define        CLKF_PC(framep)         ((framep)->pc)
 #define        CLKF_PC(framep)         ((framep)->pc)
+#if 0
+/* We would like to do it this way... */
+#define        CLKF_INTR(framep)       (((framep)->sr & PSL_M) == 0)
+#else
+/* but until we start using PSL_M, we have to do this instead */
+#define        CLKF_INTR(framep)       (0)     /* XXX */
+#endif
 
 
 /*
 
 
 /*
@@ -65,11 +66,11 @@ typedef struct intrframe {
 #define        need_resched()  { want_resched++; aston(); }
 
 /*
 #define        need_resched()  { want_resched++; aston(); }
 
 /*
- * Give a profiling tick to the current process from the softclock
- * interrupt.  On 68k, request an ast to send us through trap(),
- * marking the proc as needing a profiling tick.
+ * Give a profiling tick to the current process when the user profiling
+ * buffer pages are invalid.  On the 68k, request an ast to send us
+ * through trap, marking the proc as needing a profiling tick.
  */
  */
-#define        profile_tick(p, framep) { (p)->p_flag |= SOWEUPC; aston(); }
+#define        need_proftick(p)        { (p)->p_flag |= SOWEUPC; aston(); }
 
 /*
  * Notify the current process (p) that it has a signal pending,
 
 /*
  * Notify the current process (p) that it has a signal pending,
index 105f6b5..81909ba 100644 (file)
@@ -13,9 +13,9 @@
  * from: Utah $Hdr: machparam.h 1.11 89/08/14$
  * OMRON: $Id: param.h,v 1.3 92/06/14 06:28:28 moti Exp $
  *
  * from: Utah $Hdr: machparam.h 1.11 89/08/14$
  * OMRON: $Id: param.h,v 1.3 92/06/14 06:28:28 moti Exp $
  *
- * from: hp300/include/param.h 7.8 (Berkeley) 6/28/91
+ * from: hp300/include/param.h 7.12 (Berkeley) 7/8/92
  *
  *
- *     @(#)param.h     7.1 (Berkeley) %G%
+ *     @(#)param.h     7.2 (Berkeley) %G%
  */
 
 /*
  */
 
 /*
 #define spl6()  _spl(PSL_S|PSL_IPL6)
 #define spl7()  _spl(PSL_S|PSL_IPL7)
 
 #define spl6()  _spl(PSL_S|PSL_IPL6)
 #define spl7()  _spl(PSL_S|PSL_IPL7)
 
-#define splsoftclock()  spl1()
-#define splnet()        spl1()
-#define splbio()        spl5()
-#define splimp()        spl5()
-#define spltty()        spl6()
-#define splclock()      spl5()
-#define splvm()         spl6()
-#define splhigh()       spl7()
-#define splsched()      spl7()
+#define splsoftclock() spl1()
+#define splnet()       spl1()
+#define splbio()       spl5()
+#define splimp()       spl5()
+#define spltty()       spl6()
+#define splclock()     spl5()
+#define splstatclock() spl5()
+#define splvm()                spl6()
+#define splhigh()      spl7()
+#define splsched()     spl7()
 
 /* watch out for side effects */
 #define splx(s)         (s & PSL_IPL ? _spl(s) : spl0())
 
 /* watch out for side effects */
 #define splx(s)         (s & PSL_IPL ? _spl(s) : spl0())
index c8152fb..c51d971 100644 (file)
  * from: Utah $Hdr: clock.c 1.18 91/01/21$
  * OMRON: $Id: clock.c,v 1.1 92/05/27 14:24:06 moti Exp $
  *
  * from: Utah $Hdr: clock.c 1.18 91/01/21$
  * OMRON: $Id: clock.c,v 1.1 92/05/27 14:24:06 moti Exp $
  *
- * from: hp300/hp300/clock.c   7.8 (Berkeley) 2/25/92
+ * from: hp300/hp300/clock.c    7.14 (Berkeley) 7/8/92
  *
  *
- *     @(#)clock.c     7.1 (Berkeley) %G%
+ *     @(#)clock.c     7.2 (Berkeley) %G%
  */
 
 #include "param.h"
 #include "kernel.h"
 #include "clockreg.h"
 
  */
 
 #include "param.h"
 #include "kernel.h"
 #include "clockreg.h"
 
+extern int clock_on;
+
 static int month_days[12] = {
     31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
 };
 static int month_days[12] = {
     31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
 };
@@ -50,7 +52,7 @@ int battery_chkfg;
 /*
  * Start the real-time clock.
  */
 /*
  * Start the real-time clock.
  */
-startrtclock()
+cpu_initclocks()
 {
        static char *rtcstrings = "RTC";     /* For compat */
 
 {
        static char *rtcstrings = "RTC";     /* For compat */
 
@@ -72,17 +74,29 @@ startrtclock()
        bbc->cal_hour &= ~BBC_KICK;
        bbc->cal_ctl &= ~BBC_WRT;
        strcpy(bbc->nvram,rtcstrings);
        bbc->cal_hour &= ~BBC_KICK;
        bbc->cal_ctl &= ~BBC_WRT;
        strcpy(bbc->nvram,rtcstrings);
+
+       /* set flag for clockintr. */
+       clock_on = 1;
 }
 
 }
 
-/* 
- * Enable clock intrruupt.
- */
-enablertclock()
+void
+setstatclockrate(newhz)
+        int newhz;
 {
 {
-        extern int clock_on;
+}
 
 
-       /* set flag for clockintr. */
-       clock_on = 1;
+microtime(tvp)
+        register struct timeval *tvp;
+{
+        int s = splhigh();
+
+        *tvp = time;
+        tvp->tv_usec += tick;
+        while (tvp->tv_usec > 1000000) {
+                tvp->tv_sec++;
+                tvp->tv_usec -= 1000000;
+        }
+        splx(s);
 }
 
 /*
 }
 
 /*
index 6d970a7..7ddd993 100644 (file)
@@ -5,9 +5,9 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- * from: hp300/hp300/conf.c    7.1 (Berkeley) 6/4/92
+ * from: hp300/hp300/conf.c    7.13 (Berkeley) 7/9/92
  *
  *
- *     @(#)conf.c      7.1 (Berkeley) %G%
+ *     @(#)conf.c      7.2 (Berkeley) %G%
  */
 
 #include "sys/param.h"
  */
 
 #include "sys/param.h"
@@ -191,17 +191,6 @@ cdev_decl(sio);
 
 cdev_decl(cd);
 
 
 cdev_decl(cd);
 
-/*
-#include "clock.h"
-cdev_decl(clock);
-*/
-/* open, close, ioctl, map -- XXX should be a map device */
-#define        cdev_clock_init(c,n) { \
-       dev_init(c,n,open), dev_init(c,n,close), (dev_type_read((*))) nullop, \
-       (dev_type_write((*))) nullop, dev_init(c,n,ioctl), \
-       (dev_type_stop((*))) enodev, (dev_type_reset((*))) nullop, 0, \
-       (dev_type_select((*))) nullop, dev_init(c,n,map), 0 }
-
 cdev_decl(vn);
 /* open, read, write, ioctl -- XXX should be a disk */
 #define        cdev_vn_init(c,n) { \
 cdev_decl(vn);
 /* open, read, write, ioctl -- XXX should be a disk */
 #define        cdev_vn_init(c,n) { \
@@ -248,7 +237,7 @@ struct cdevsw       cdevsw[] =
        cdev_notdef(),                  /* 15 */
        cdev_notdef(),                  /* 16 */
        cdev_notdef(),                  /* 17 */
        cdev_notdef(),                  /* 15 */
        cdev_notdef(),                  /* 16 */
        cdev_notdef(),                  /* 17 */
-       cdev_notdef(),                  /* 18: mapped clock */
+       cdev_notdef(),                  /* 18 */
        cdev_vn_init(NVN,vn),           /* 19: vnode disk */
        cdev_tape_init(NST,st),         /* 20: scsi tape */
        cdev_fd_init(1,fd),             /* 21: file descriptor pseudo-dev */
        cdev_vn_init(NVN,vn),           /* 19: vnode disk */
        cdev_tape_init(NST,st),         /* 20: scsi tape */
        cdev_fd_init(1,fd),             /* 21: file descriptor pseudo-dev */
index 562b0e6..52081ea 100644 (file)
@@ -7,9 +7,9 @@
  *
  * OMRON: $Id: genassym.c,v 1.2 92/06/14 06:15:25 moti Exp $
  *
  *
  * OMRON: $Id: genassym.c,v 1.2 92/06/14 06:15:25 moti Exp $
  *
- * from: hp300/hp300/genassym.c        7.9 (Berkeley) 8/29/91
+ * from: hp300/hp300/genassym.c        7.11 (Berkeley) 7/8/92
  *
  *
- *     @(#)genassym.c  7.1 (Berkeley) %G%
+ *     @(#)genassym.c  7.2 (Berkeley) %G%
  */
 
 #define KERNEL
  */
 
 #define KERNEL
 #include "sys/user.h"
 #include "pte.h"
 
 #include "sys/user.h"
 #include "pte.h"
 
+#include <errno.h>
+#include <stdio.h>
+#include <stddef.h>
+#include <string.h>
+#include <unistd.h>
+
+extern int errno;
+
+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()
 {
 main()
 {
-       register struct proc *p = (struct proc *)0;
-       register struct vmmeter *vm = (struct vmmeter *)0;
-       register struct user *up = (struct user *)0;
-       register struct rusage *rup = (struct rusage *)0;
-       struct vmspace *vms = (struct vmspace *)0;
-       pmap_t pmap = (pmap_t)0;
-       struct pcb *pcb = (struct pcb *)0;
        struct KernInter *KernInter = (struct KernInter *)0;
        struct pio *pio = (struct pio *)PIO0_ADDR;
        register unsigned i;
 
        struct KernInter *KernInter = (struct KernInter *)0;
        struct pio *pio = (struct pio *)PIO0_ADDR;
        register unsigned i;
 
-       printf("#define\tP_LINK %d\n", &p->p_link);
-       printf("#define\tP_RLINK %d\n", &p->p_rlink);
-       printf("#define\tP_VMSPACE %d\n", &p->p_vmspace);
-       printf("#define\tVM_PMAP %d\n", &vms->vm_pmap);
-       printf("#define\tPM_STCHG %d\n", &pmap->pm_stchanged);
-       printf("#define\tP_ADDR %d\n", &p->p_addr);
-       printf("#define\tP_PRI %d\n", &p->p_pri);
-       printf("#define\tP_STAT %d\n", &p->p_stat);
-       printf("#define\tP_WCHAN %d\n", &p->p_wchan);
-       printf("#define\tP_FLAG %d\n", &p->p_flag);
-       printf("#define\tSSLEEP %d\n", SSLEEP);
-       printf("#define\tSRUN %d\n", SRUN);
-       printf("#define\tV_SWTCH %d\n", &vm->v_swtch);
-       printf("#define\tV_TRAP %d\n", &vm->v_trap);
-       printf("#define\tV_SYSCALL %d\n", &vm->v_syscall);
-       printf("#define\tV_INTR %d\n", &vm->v_intr);
-       printf("#define\tV_SOFT %d\n", &vm->v_soft);
-       printf("#define\tV_FAULTS %d\n", &vm->v_faults);
-       printf("#define\tKI_MAXADDR %d\n", &KernInter->maxaddr);
-       printf("#define\tUPAGES %d\n", UPAGES);
-       printf("#define\tHIGHPAGES %d\n", HIGHPAGES);
-       printf("#define\tP1PAGES %d\n", P1PAGES);
-       printf("#define\tCLSIZE %d\n", CLSIZE);
-       printf("#define\tNBPG %d\n", NBPG);
-       printf("#define\tNPTEPG %d\n", NPTEPG);
-       printf("#define\tPGSHIFT %d\n", PGSHIFT);
-       printf("#define\tSYSPTSIZE %d\n", SYSPTSIZE);
-       printf("#define\tUSRPTSIZE %d\n", USRPTSIZE);
-       printf("#define\tUSRIOSIZE %d\n", USRIOSIZE);
-#ifdef SYSVSHM
-       printf("#define\tSHMMAXPGS %d\n", SHMMAXPGS);
-#endif
-       printf("#define\tUSRSTACK %d\n", USRSTACK);
-       printf("#define\tKERNELSTACK %d\n", KERNELSTACK);
-       printf("#define\tMSGBUFPTECNT %d\n", btoc(sizeof (struct msgbuf)));
-       printf("#define\tNMBCLUSTERS %d\n", NMBCLUSTERS);
-       printf("#define\tMCLBYTES %d\n", MCLBYTES);
-       printf("#define\tNKMEMCLUSTERS %d\n", NKMEMCLUSTERS);
-       printf("#define\tU_PROF %d\n", &up->u_stats.p_prof);
-       printf("#define\tU_PROFSCALE %d\n", &up->u_stats.p_prof.pr_scale);
-       printf("#define\tRU_MINFLT %d\n", &rup->ru_minflt);
-       printf("#define\tT_BUSERR %d\n", T_BUSERR);
-       printf("#define\tT_ADDRERR %d\n", T_ADDRERR);
-       printf("#define\tT_ILLINST %d\n", T_ILLINST);
-       printf("#define\tT_ZERODIV %d\n", T_ZERODIV);
-       printf("#define\tT_CHKINST %d\n", T_CHKINST);
-       printf("#define\tT_TRAPVINST %d\n", T_TRAPVINST);
-       printf("#define\tT_PRIVINST %d\n", T_PRIVINST);
-       printf("#define\tT_TRACE %d\n", T_TRACE);
-       printf("#define\tT_MMUFLT %d\n", T_MMUFLT);
-       printf("#define\tT_SSIR %d\n", T_SSIR);
-       printf("#define\tT_FMTERR %d\n", T_FMTERR);
-       printf("#define\tT_COPERR %d\n", T_COPERR);
-       printf("#define\tT_FPERR %d\n", T_FPERR);
-       printf("#define\tT_ASTFLT %d\n", T_ASTFLT);
-       printf("#define\tT_TRAP15 %d\n", T_TRAP15);
-       printf("#define\tT_FPEMULI %d\n", T_FPEMULI);
-       printf("#define\tT_FPEMULD %d\n", T_FPEMULD);
-       printf("#define\tPSL_S %d\n", PSL_S);
-       printf("#define\tPSL_IPL7 %d\n", PSL_IPL7);
-       printf("#define\tPSL_LOWIPL %d\n", PSL_LOWIPL);
-       printf("#define\tPSL_HIGHIPL %d\n", PSL_HIGHIPL);
-       printf("#define\tPSL_USER %d\n", PSL_USER);
-       printf("#define\tSPL1 %d\n", PSL_S | PSL_IPL1);
-       printf("#define\tSPL2 %d\n", PSL_S | PSL_IPL2);
-       printf("#define\tSPL3 %d\n", PSL_S | PSL_IPL3);
-       printf("#define\tSPL4 %d\n", PSL_S | PSL_IPL4);
-       printf("#define\tSPL5 %d\n", PSL_S | PSL_IPL5);
-       printf("#define\tSPL6 %d\n", PSL_S | PSL_IPL6);
-       printf("#define\tFC_USERD %d\n", FC_USERD);
-       printf("#define\tFC_PURGE %d\n", FC_PURGE);
-       printf("#define\tCACHE_ON %d\n", CACHE_ON);
-       printf("#define\tCACHE_OFF %d\n", CACHE_OFF);
-       printf("#define\tCACHE_CLR %d\n", CACHE_CLR);
-       printf("#define\tIC_CLEAR %d\n", IC_CLEAR);
-       printf("#define\tDC_CLEAR %d\n", DC_CLEAR);
-       printf("#define\tPG_V %d\n", PG_V);
-       printf("#define\tPG_NV %d\n", PG_NV);
-       printf("#define\tPG_RO %d\n", PG_RO);
-       printf("#define\tPG_RW %d\n", PG_RW);
-       printf("#define\tPG_CI %d\n", PG_CI);
-       printf("#define\tPG_PROT %d\n", PG_PROT);
-       printf("#define\tPG_FRAME %d\n", PG_FRAME);
-       printf("#define\tSG_V %d\n", SG_V);
-       printf("#define\tSG_NV %d\n", SG_NV);
-       printf("#define\tSG_RW %d\n", SG_RW);
-       printf("#define\tSG_FRAME %d\n", SG_FRAME);
-       printf("#define\tSG_ISHIFT %d\n", SG_ISHIFT);
-       printf("#define\tPCB_FLAGS %d\n", &pcb->pcb_flags);
-       printf("#define\tPCB_PS %d\n", &pcb->pcb_ps);
-       printf("#define\tPCB_USTP %d\n", &pcb->pcb_ustp);
-       printf("#define\tPCB_USP %d\n", &pcb->pcb_usp);
-       printf("#define\tPCB_REGS %d\n", pcb->pcb_regs);
-       printf("#define\tPCB_ONFAULT %d\n", &pcb->pcb_onfault);
-       printf("#define\tPCB_FPCTX %d\n", &pcb->pcb_fpregs);
-       printf("#define\tSIZEOF_PCB %d\n", sizeof(struct pcb));
-       printf("#define\tSP %d\n", SP);
-       printf("#define\tB_READ %d\n", B_READ);
-       printf("#define\tENOENT %d\n", ENOENT);
-       printf("#define\tEFAULT %d\n", EFAULT);
-       printf("#define\tENAMETOOLONG %d\n", ENAMETOOLONG);
-       printf("#define\tPIO0_A %d\n", &pio->a_port);
-       printf("#define\tPIO0_B %d\n", &pio->b_port);
-       printf("#define\tPIO0_CTL %d\n", &pio->control_port);
-       printf("#define\tPIO_MODED %d\n", PIO_MODED);
-       printf("#define\tCLOCK_REG %d\n", CLOCK_REG);
-       printf("#define\tCLK_INT %d\n", CLK_INT);
-       printf("#define\tCLK_CLR %d\n", CLK_CLR);
-       printf("#define\tSYS_exit %d\n", SYS_exit);
-       printf("#define\tSYS_execve %d\n", SYS_execve);
-       printf("#define\tSYS_sigreturn %d\n", SYS_sigreturn);
+       def("UPAGES", UPAGES);
+       def("NBPG", NBPG);
+       def("PGSHIFT", PGSHIFT);
+       def("USRSTACK", USRSTACK);
+       def("KERNELSTACK", KERNELSTACK);
+       def("KI_MAXADDR", &KernInter->maxaddr);
+
+       off("P_LINK", struct proc, p_link);
+       off("P_RLINK", struct proc, p_rlink);
+       off("P_VMSPACE", struct proc, p_vmspace);
+       off("P_ADDR", struct proc, p_addr);
+       off("P_PRI", struct proc, p_pri);
+       off("P_STAT", struct proc, p_stat);
+       off("P_WCHAN", struct proc, p_wchan);
+       off("P_FLAG", struct proc, p_flag);
+       def("SSLEEP", SSLEEP);
+       def("SRUN", SRUN);
+
+       off("VM_PMAP", struct vmspace, vm_pmap);
+       off("PM_STCHG", struct pmap, pm_stchanged);
+
+       off("V_SWTCH", struct vmmeter, v_swtch);
+       off("V_INTR", struct vmmeter, v_intr);
+
+       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);
+
+       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);
+
+       def("FC_USERD", FC_USERD);
+       def("FC_PURGE", FC_PURGE);
+       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);
+
+       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);
+
+       off("PCB_FLAGS", struct pcb, pcb_flags);
+       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("SYS_exit", SYS_exit);
+       def("SYS_execve", SYS_execve);
+       def("SYS_sigreturn", SYS_sigreturn);
+
+       def("EFAULT", EFAULT);
+       def("ENAMETOOLONG", ENAMETOOLONG);
+
+       def("CLOCK_REG", CLOCK_REG);
+       def("CLK_INT", CLK_INT);
+       def("CLK_CLR", CLK_CLR);
+
+       def("PIO0_A", &pio->a_port);
+       def("PIO0_B", &pio->b_port);
+       def("PIO0_CTL", &pio->control_port);
+       def("PIO_MODED", PIO_MODED);
+
 #ifdef OLD_LUNA
 #ifdef OLD_LUNA
-       printf("define\tFLINE_VEC %d\n",44); /* F-Line excep vector offset */
-       printf("define\tCOPRO_VEC %d\n",52); /* Coprocessor prot. offset */
+       def("FLINE_VEC", 44); /* F-Line excep vector offset */
+       def("COPRO_VEC", 52); /* Coprocessor prot. offset */
 #endif
        exit(0);
 }
 #endif
        exit(0);
 }
index a49c0df..08e0270 100644 (file)
@@ -13,9 +13,9 @@
  * from: Utah $Hdr: locore.s 1.62 92/01/20$
  * OMRON: $Id: locore.s,v 1.2 92/06/14 06:16:34 moti Exp $
  *
  * from: Utah $Hdr: locore.s 1.62 92/01/20$
  * OMRON: $Id: locore.s,v 1.2 92/06/14 06:16:34 moti Exp $
  *
- * from: hp300/hp300/locore.s  7.13 (Berkeley) 6/5/92
+ * from: hp300/hp300/locore.s   7.16 (Berkeley) 7/8/92
  *
  *
- *     @(#)locore.s    7.2 (Berkeley) %G%
+ *     @(#)locore.s    7.3 (Berkeley) %G%
  */
 
 #include "assym.s"
  */
 
 #include "assym.s"
@@ -448,13 +448,6 @@ _lev5intr:
        moveml  #0xC0C0,sp@-
 #ifdef DEBUG
        .globl  _panicstr, _regdump, _panic
        moveml  #0xC0C0,sp@-
 #ifdef DEBUG
        .globl  _panicstr, _regdump, _panic
-       tstl    timebomb                | set to go off?
-       jeq     Lnobomb                 | no, skip it
-       subql   #1,timebomb             | decrement
-       jne     Lnobomb                 | not ready to go off
-       moveml  sp@+,#0x0303            | temporarily restore regs
-       jra     Lbomb                   | go die
-Lnobomb:
        cmpl    #_kstack+NBPG,sp        | are we still in stack pages?
        jcc     Lstackok                | yes, continue normally
        tstl    _curproc                | if !curproc could have swtch_exit'ed,
        cmpl    #_kstack+NBPG,sp        | are we still in stack pages?
        jcc     Lstackok                | yes, continue normally
        tstl    _curproc                | if !curproc could have swtch_exit'ed,
@@ -473,19 +466,8 @@ Lnobomb:
        addql   #8,sp                   | pop params
        movl    #Lstkrip,sp@-           | push panic message
        jbsr    _panic                  | ES and D
        addql   #8,sp                   | pop params
        movl    #Lstkrip,sp@-           | push panic message
        jbsr    _panic                  | ES and D
-Lbomb:
-       moveml  #0xFFFF,sp@-            | push all registers
-       movl    sp,a0                   | remember this spot
-       movl    #256,sp@-               | longword count
-       movl    a0,sp@-                 | and reg pointer
-       jbsr    _regdump                | dump core
-       addql   #8,sp                   | pop params
-       movl    #Lbomrip,sp@-           | push panic message
-       jbsr    _panic                  | ES and D
 Lstkrip:
        .asciz  "k-stack overflow"
 Lstkrip:
        .asciz  "k-stack overflow"
-Lbomrip:
-       .asciz  "timebomb"
        .even
 Lstackok:
 #endif
        .even
 Lstackok:
 #endif
@@ -670,189 +652,6 @@ start:
        jbsr    _pmap_bootstrap         | bootstrap(firstpa, nextpa)
        addql   #8,sp
 
        jbsr    _pmap_bootstrap         | bootstrap(firstpa, nextpa)
        addql   #8,sp
 
-#ifdef BOOTDEBUG
-/*
- * If we are debugging the pmap_bootstrap code, we ignore what it has
- * just done (without clobbering it) and do it ourselves here with the
- * code we know works.
- */
-       .globl  _Xavail_start
-       movl    _Xavali_start,a4        | grab new first avail PA
-       movl    a4,d1                   | new firstpa
-       movl    d5,d0
-       addl    a5,d0                   | old firstpa
-       subl    d0,d1                   | new - old == amount allocated
-       addl    d1,d5                   | update firstva
-/*
- * Allocate kernel segment/page table resources.
- * In LUNA, kernel is always loaded at 0, so PA = VA.
- *     a4 contains the PA(also VA) of first available page at any time
- * We assume (i.e. do not check) that the initial page table size
- *
- * (Sysptsize) is big enough to map everything we allocate here.
- *
- */
-       .globl  _Sysseg, _Sysmap, _Sysptmap, _Sysptsize
-#if 0
-       movl    #0,a5                   | kernel is loaded at 0
-       movl    #_end,d5                | end of static kernel text/data
-       addl    #NBPG-1,d5
-       andl    #PG_FRAME,d5            | round to a page
-       movl    d5,a4
-#endif
-/* allocate kernel segment table */
-       movl    a4,_Sysseg              | remember VA for pmap module
-       movl    a4,sp@-                 | remember PA for loading MMU
-       addl    #NBPG,a4
-/* allocate kernel page table map */
-       movl    a4,_Sysptmap            | remember VA for pmap module
-       movl    a4,sp@-                 | remember PA for PT map load
-       addl    #NBPG,a4
-/* compute KVA of Sysptmap; mapped after page table pages */
-       movl    d0,d2                   | remember PT size (bytes)
-       moveq   #SG_ISHIFT-PGSHIFT,d1
-       lsll    d1,d0                   | page table size serves as seg index
-       movl    d0,_Sysmap              | remember VA for pmap module
-/* initialize ST and PT map: PT pages + PT map */
-       movl    sp@+,a1                 | PT map PA
-       movl    sp@+,d4                 | start of PT pages
-       movl    sp@+,a0                 | ST phys addr
-       lea     a0@(NBPG),a2            | end of ST (LUNA)
-       movl    d4,d3
-       orl     #SG_RW+SG_V,d4          | create proto STE for ST
-       orl     #PG_RW+PG_CI+PG_V,d3    | create proto PTE for PT map
-List1:
-       movl    d4,a0@+
-       movl    d3,a1@+
-       addl    #NBPG,d4
-       addl    #NBPG,d3
-       cmpl    a4,d4                   | sleezy, but works ok
-       jcs     List1
-/* initialize ST and PT map: invalidate up to last entry */
-List2:
-       movl    #SG_NV,a0@+
-       movl    #PG_NV,a1@+
-       cmpl    a2,a0
-       jcs     List2
-
-/* IOPT setup: allocate IOPT and setup routine call (LUNA) */
-       movl    _ioptpage,d0            | IOPTPAGE(=11PG)
-       movl    #PGSHIFT,d1
-       lsll    d1,d0                   | convert bytes
-       movl    a4,a2                   | save start of IOPT
-       addl    d0,a4
-       moveml  #0xC0C0,sp@-            | save scratch regs
-       movl    a2,sp@-                 | start of IOPT
-       jbsr    _iopage_setup           | IOPT setup routine
-       addql   #4,sp                   | pop arg
-       moveml  sp@+,#0x0303            | restore regs
-
-/*
- * 0x3FF00000 for UPAGES is used for mapping the current process 
- * u-area (u + kernel stack).  
- */
-       movl    a4,d1                   | grab next available for PT page
-       andl    #SG_FRAME,d1            | mask to frame number
-       orl     #SG_RW+SG_V,d1          | RW and valid
-       movl    a0,a2                   | remember addr for PT load
-       movl    a0,sp@-                 | push end of ST entry
-       subl    #NBPG,a0                | start of ST entry
-       movl    #KERNELSTACK,d3         | compute kernel stack 
-       movl    #SG_ISHIFT,d4           |   ST entry offset
-       lsrl    d4,d3                   |
-       lsll    #2,d3                   |
-       addl    d3,a0                   | ST entry address
-       movl    d1,a0@                  | store at 0x3FC00000 ST entry
-       movl    sp@+,a0                 | pop start of PT entry
-       andl    #PG_FRAME,d1
-       orl     #PG_RW+PG_V,d1          | convert to PTE
-       movl    a1,sp@-                 | push end of PT map
-       subl    #NBPG,a1                | start of PT map
-       addl    d3,a1                   | offset computed above
-       movl    d1,a1@                  | store in PT map
-       movl    sp@+,a1                 | pop end of PT map
-       movl    a4,a0                   | physical beginning of PT page
-       lea     a0@(NBPG),a1            | end of page
-Lispt7:
-       movl    #PG_NV,a0@+             | invalidate
-       cmpl    a1,a0
-       jcs     Lispt7
-       addl    #NBPG,a4
-/* record KVA at which to access current u-area PTEs */
-       movl    _Sysmap,d0              | get system PT address
-       movl    #NPTEPG*NBPG,d1         | size of system PT
-       lsrl    #2,d1                   | kernel MAX VA = 0x4000000 (LUNA)
-       addl    d1,d0                   | end of system PT
-       subl    #HIGHPAGES*4,d0         | back up to first PTE for u-area
-       movl    d0,_Umap                | remember location
-/* initialize page table pages */
-       movl    a2,a0                   | end of ST is start of PT
-       addl    d2,a2                   | add size to get end of PT
-/* text pages are read-only */
-       clrl    d0                      | assume load at VA 0
-       clrl    d1                      | PA = VA
-       andl    #PG_FRAME,d1            | convert to a page frame
-#ifdef KGDB
-       orl     #PG_RW+PG_V,d1          | XXX: RW for now
-#else
-       orl     #PG_RO+PG_V,d1          | create proto PTE
-#endif
-       movl    #_etext,a1              | go til end of text
-Lipt1:
-       movl    d1,a0@+                 | load PTE
-       addl    #NBPG,d1                | increment page frame number
-       addl    #NBPG,d0                | and address counter
-       cmpl    a1,d0                   | done yet?
-       jcs     Lipt1                   | no, keep going
-/* data, bss and dynamic tables are read/write */
-       andl    #PG_FRAME,d1            | mask out old prot bits
-       orl     #PG_RW+PG_V,d1          | mark as valid and RW
-       movl    d5,a1                   | go til end of data allocated so far
-       addl    #(UPAGES+1)*NBPG,a1     | and proc0 PT/u-area (to be allocated)
-Lipt2:
-       movl    d1,a0@+                 | load PTE
-       addl    #NBPG,d1                | increment page frame number
-       addl    #NBPG,d0                | and address counter
-       cmpl    a1,d0                   | done yet?
-       jcs     Lipt2                   | no, keep going
-/* invalidate remainder of kernel PT */
-       movl    a2,a1                   | end of PT
-Lipt3:
-       movl    #PG_NV,a0@+             | invalidate PTE
-       cmpl    a1,a0                   | done yet?
-       jcs     Lipt3                   | no, keep going
-
-/*
- * Setup page table for process 0.
- *
- * We set up page table access for the kernel via Umap and access to
- * the u-area itself via `u'.  First available UPAGES pages (start at
- * VA=PA: a4) are used for the u-area.
- */
-       movl    a4,d0
-       movl    a4,a2
-       lea     a4@(-HIGHPAGES*4),a0    | u-area PTE base in Umap PT
-       lea     a0@(UPAGES*4),a1        | end of PTEs for u-area
-       movl    d0,d1                   | get base of u-area
-       andl    #PG_FRAME,d1            | mask to page frame number
-       orl     #PG_RW+PG_V,d1          | add valid and writable
-Liudot2:
-       movl    d1,a0@+                 | validate p_addr PTE
-       addl    #NBPG,d1                | to next page
-       cmpl    a1,a0                   | done yet?
-       jcs     Liudot2                 | no, keep going
-/* clear process 0 u-area */
-       addl    #NBPG*UPAGES,d0         | end of u-area
-Lclru1:
-       clrl    a2@+                    | clear
-       cmpl    d0,a2                   | done yet?
-       jcs     Lclru1                  | no, keep going
-       movl    a2,a4                   | save phys addr of first avail page
-       RELOC(_proc0paddr, a0)
-       movl    d5,a0@                  | save KVA of proc0 u-area
-       addl    #UPAGES*NBPG,d5         | increment virtual addr as well
-#endif
-
 /*
  * Prepare to enable MMU.
  */
 /*
  * Prepare to enable MMU.
  */
@@ -993,44 +792,6 @@ _szicode:
        .globl _/**/name; _/**/name:
 #endif
 
        .globl _/**/name; _/**/name:
 #endif
 
-/*
- * update profiling information for the user
- * addupc(pc, &u.u_prof, ticks)
- */
-ENTRY(addupc)
-       movl    a2,sp@-                 | scratch register
-       movl    sp@(12),a2              | get &u.u_prof
-       movl    sp@(8),d0               | get user pc
-       subl    a2@(8),d0               | pc -= pr->pr_off
-       jlt     Lauexit                 | less than 0, skip it
-       movl    a2@(12),d1              | get pr->pr_scale
-       lsrl    #1,d0                   | pc /= 2
-       lsrl    #1,d1                   | scale /= 2
-       mulul   d1,d0                   | pc /= scale
-       moveq   #14,d1
-       lsrl    d1,d0                   | pc >>= 14
-       bclr    #0,d0                   | pc &= ~1
-       cmpl    a2@(4),d0               | too big for buffer?
-       jge     Lauexit                 | yes, screw it
-       addl    a2@,d0                  | no, add base
-       movl    d0,sp@-                 | push address
-       jbsr    _fusword                | grab old value
-       movl    sp@+,a0                 | grab address back
-       cmpl    #-1,d0                  | access ok
-       jeq     Lauerror                | no, skip out
-       addw    sp@(18),d0              | add tick to current value
-       movl    d0,sp@-                 | push value
-       movl    a0,sp@-                 | push address
-       jbsr    _susword                | write back new value
-       addql   #8,sp                   | pop params
-       tstl    d0                      | fault?
-       jeq     Lauexit                 | no, all done
-Lauerror:
-       clrl    a2@(12)                 | clear scale (turn off prof)
-Lauexit:
-       movl    sp@+,a2                 | restore scratch reg
-       rts
-
 /*
  * copyinstr(fromaddr, toaddr, maxlength, &lencopied)
  *
 /*
  * copyinstr(fromaddr, toaddr, maxlength, &lencopied)
  *
@@ -1392,7 +1153,7 @@ pcbflag:
 ENTRY(swtch_exit)
        movl    #nullpcb,_curpcb        | save state into garbage pcb
        lea     tmpstk,sp               | goto a tmp stack
 ENTRY(swtch_exit)
        movl    #nullpcb,_curpcb        | save state into garbage pcb
        lea     tmpstk,sp               | goto a tmp stack
-       jra     _swtch
+       jra     _cpu_swtch
 
 /*
  * When no processes are on the runq, Swtch branches to idle
 
 /*
  * When no processes are on the runq, Swtch branches to idle
@@ -1415,7 +1176,7 @@ Lbadsw:
        /*NOTREACHED*/
 
 /*
        /*NOTREACHED*/
 
 /*
- * Swtch()
+ * cpu_swtch()
  *
  * NOTE: On the mc68851 (318/319/330) we attempt to avoid flushing the
  * entire ATC.  The effort involved in selective flushing may not be
  *
  * NOTE: On the mc68851 (318/319/330) we attempt to avoid flushing the
  * entire ATC.  The effort involved in selective flushing may not be
@@ -1425,7 +1186,7 @@ Lbadsw:
  * user's PTEs have been changed (formerly denoted by the SPTECHG p_flag
  * bit).  For now, we just always flush the full ATC.
  */
  * user's PTEs have been changed (formerly denoted by the SPTECHG p_flag
  * bit).  For now, we just always flush the full ATC.
  */
-ENTRY(swtch)
+ENTRY(cpu_swtch)
        movl    _curpcb,a0              | current pcb
        movw    sr,a0@(PCB_PS)          | save sr before changing ipl
 #ifdef notyet
        movl    _curpcb,a0              | current pcb
        movw    sr,a0@(PCB_PS)          | save sr before changing ipl
 #ifdef notyet
@@ -1433,6 +1194,7 @@ ENTRY(swtch)
 #endif
        clrl    _curproc
        addql   #1,_cnt+V_SWTCH
 #endif
        clrl    _curproc
        addql   #1,_cnt+V_SWTCH
+
 Lsw1:
        /*
         * Find the highest-priority queue that isn't empty,
 Lsw1:
        /*
         * Find the highest-priority queue that isn't empty,
@@ -1625,6 +1387,16 @@ ENTRY(fusword)
        nop
        jra     Lfsdone
 
        nop
        jra     Lfsdone
 
+/* Just like fusword, but tells trap code not to page in. */
+ENTRY(fuswintr)
+       movl    sp@(4),a0
+       movl    _curpcb,a1
+       movl    #_fswintr,a1@(PCB_ONFAULT)
+       moveq   #0,d0
+       movsw   a0@,d0
+       nop
+       jra     Lfsdone
+
 ALTENTRY(fuibyte, _fubyte)
 ENTRY(fubyte)
        movl    sp@(4),a0               | address to read
 ALTENTRY(fuibyte, _fubyte)
 ENTRY(fubyte)
        movl    sp@(4),a0               | address to read
@@ -1641,6 +1413,13 @@ Lfsdone:
        clrl    a1@(PCB_ONFAULT)        | clear fault address
        rts
 
        clrl    a1@(PCB_ONFAULT)        | clear fault address
        rts
 
+/* Just like Lfserr, but the address is different (& exported). */
+       .globl  _fswintr
+_fswintr:
+       moveq   #-1,d0
+       jra     Lfsdone
+
+
 /*
  * Write a longword in user instruction space.
  * Largely the same as suword but with a final i-cache purge on those
 /*
  * Write a longword in user instruction space.
  * Largely the same as suword but with a final i-cache purge on those
@@ -1678,6 +1457,16 @@ ENTRY(susword)
        moveq   #0,d0                   | indicate no fault
        jra     Lfsdone
 
        moveq   #0,d0                   | indicate no fault
        jra     Lfsdone
 
+ENTRY(suswintr)
+       movl    sp@(4),a0
+       movw    sp@(10),d0
+       movl    _curpcb,a1
+       movl    #_fswintr,a1@(PCB_ONFAULT)
+       movsw   d0,a0@
+       nop
+       moveq   #0,d0
+       jra     Lfsdone
+
 ALTENTRY(suibyte, _subyte)
 ENTRY(subyte)
        movl    sp@(4),a0               | address to write
 ALTENTRY(suibyte, _subyte)
 ENTRY(subyte)
        movl    sp@(4),a0               | address to write
index ad699b2..478d799 100644 (file)
@@ -13,9 +13,9 @@
  * from: Utah $Hdr: machdep.c 1.63 91/04/24$
  * OMRON: $Id: machdep.c,v 1.3 92/06/14 06:17:12 moti Exp $
  *
  * from: Utah $Hdr: machdep.c 1.63 91/04/24$
  * OMRON: $Id: machdep.c,v 1.3 92/06/14 06:17:12 moti Exp $
  *
- * from: hp300/hp300/machdep.c 7.28 (Berkeley) 6/5/92
+ * from: hp300/hp300/machdep.c  7.29 (Berkeley) 7/8/92
  *
  *
- *     @(#)machdep.c   7.2 (Berkeley) %G%
+ *     @(#)machdep.c   7.3 (Berkeley) %G%
  */
 
 #include "param.h"
  */
 
 #include "param.h"
@@ -761,20 +761,6 @@ dumpsys()
        }
 }
 
        }
 }
 
-microtime(tvp)
-       register struct timeval *tvp;
-{
-       int s = splhigh();
-
-       *tvp = time;
-       tvp->tv_usec += tick;
-       while (tvp->tv_usec > 1000000) {
-               tvp->tv_sec++;
-               tvp->tv_usec -= 1000000;
-       }
-       splx(s);
-}
-
 initcpu()
 {
        parityenable();
 initcpu()
 {
        parityenable();
@@ -901,8 +887,11 @@ int panicbutton = 1;       /* non-zero if panic buttons are enabled */
 int crashandburn = 0;
 int candbdelay = 50;   /* give em half a second */
 
 int crashandburn = 0;
 int candbdelay = 50;   /* give em half a second */
 
-candbtimer()
+void
+candbtimer(arg)
+       void *arg;
 {
 {
+
        crashandburn = 0;
 }
 #endif
        crashandburn = 0;
 }
 #endif
@@ -932,7 +921,7 @@ nmihand(frame)
                                      "forced crash, nosync" : "forced crash");
                        }
                        crashandburn++;
                                      "forced crash, nosync" : "forced crash");
                        }
                        crashandburn++;
-                       timeout(candbtimer, (caddr_t)0, candbdelay);
+                       timeout(candbtimer, (void *)0, candbdelay);
                }
 #endif
                return;
                }
 #endif
                return;
index a9e9d4b..ce0ca25 100644 (file)
@@ -13,9 +13,9 @@
  * from: Utah $Hdr: trap.c 1.35 91/12/26$
  * OMRON: $Id: trap.c,v 1.2 92/06/14 06:23:41 moti Exp $
  *
  * from: Utah $Hdr: trap.c 1.35 91/12/26$
  * OMRON: $Id: trap.c,v 1.2 92/06/14 06:23:41 moti Exp $
  *
- * from: hp300/hp300/trap.c    7.20 (Berkeley) 6/5/92
+ * from: hp300/hp300/trap.c     7.23 (Berkeley) 7/9/92
  *
  *
- *     @(#)trap.c      7.1 (Berkeley) %G%
+ *     @(#)trap.c      7.2 (Berkeley) %G%
  */
 
 #include "param.h"
  */
 
 #include "param.h"
@@ -25,6 +25,7 @@
 #include "kernel.h"
 #include "signalvar.h"
 #include "resourcevar.h"
 #include "kernel.h"
 #include "signalvar.h"
 #include "resourcevar.h"
+#include "syscall.h"
 #include "syslog.h"
 #include "user.h"
 #ifdef KTRACE
 #include "syslog.h"
 #include "user.h"
 #ifdef KTRACE
@@ -90,6 +91,76 @@ int mmupid = -1;
 #define MDB_ISPID(p)   (p) == mmupid
 #endif
 
 #define MDB_ISPID(p)   (p) == mmupid
 #endif
 
+/*
+ * trap and syscall both need the following work done before returning
+ * to user mode.
+ */
+static inline void
+userret(p, fp, oticks, faultaddr, fromtrap)
+       register struct proc *p;
+       register struct frame *fp;
+       u_quad_t oticks;
+       u_int faultaddr;
+       int fromtrap;
+{
+       int sig, s;
+
+       /* take pending signals */
+       while ((sig = CURSIG(p)) != 0)
+               psig(sig);
+       p->p_pri = 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 that happened after we setrq ourselves but before we
+                * swtch()'ed, we might not be on the queue indicated by
+                * our priority.
+                */
+               s = splstatclock();
+               setrq(p);
+               p->p_stats->p_ru.ru_nivcsw++;
+               swtch();
+               splx(s);
+               while ((sig = CURSIG(p)) != 0)
+                       psig(sig);
+       }
+
+       /*
+        * If profiling, charge system time to the trapped pc.
+        */
+       if (p->p_flag & SPROFIL)
+               addupc_intr(p, fp->f_pc, (int)(p->p_sticks - oticks));
+#ifdef HP380
+       /*
+        * Deal with user mode writebacks (from trap, or from sigreturn).
+        * If any writeback fails, go back and attempt signal delivery.
+        * unless we have already been here and attempted the writeback
+        * (e.g. bad address with user ignoring SIGSEGV).  In that case
+        * we just return to the user without sucessfully completing
+        * the writebacks.  Maybe we should just drop the sucker?
+        */
+       if (mmutype == MMU_68040 && fp->f_format == FMT7) {
+               if (beenhere) {
+#ifdef DEBUG
+                       if (mmudebug & MDB_WBFAILED)
+                               printf(fromtrap ?
+               "pid %d(%s): writeback aborted, pc=%x, fa=%x\n" :
+               "pid %d(%s): writeback aborted in sigreturn, pc=%x\n",
+                                   p->p_pid, p->p_comm, fp->f_pc, faultaddr);
+#endif
+               } else if (sig = writeback(fp, fromtrap)) {
+                       beenhere = 1;
+                       oticks = p->p_sticks;
+                       trapsignal(p, sig, faultaddr);
+                       goto again;
+               }
+       }
+#endif
+       curpri = p->p_pri;
+}
+
 /*
  * Trap is called from locore to handle most types of processor traps,
  * including events such as simulated software interrupts/AST's.
 /*
  * Trap is called from locore to handle most types of processor traps,
  * including events such as simulated software interrupts/AST's.
@@ -103,16 +174,18 @@ trap(type, code, v, frame)
        struct frame frame;
 {
        register int i;
        struct frame frame;
 {
        register int i;
-       unsigned ucode = 0;
-       register struct proc *p = curproc;
-       struct timeval syst;
+       unsigned ucode;
+       register struct proc *p;
+       u_quad_t sticks;
        unsigned ncode;
        unsigned ncode;
-       int s;
+       extern char fswintr[];
 
        cnt.v_trap++;
 
        cnt.v_trap++;
-       syst = p->p_stime;
+       p = curproc;
+       ucode = 0;
        if (USERMODE(frame.f_sr)) {
                type |= T_USER;
        if (USERMODE(frame.f_sr)) {
                type |= T_USER;
+               sticks = p->p_sticks;
                p->p_md.md_regs = frame.f_regs;
        }
        switch (type) {
                p->p_md.md_regs = frame.f_regs;
        }
        switch (type) {
@@ -261,7 +334,7 @@ copyfault:
                if (ssir & SIR_CLOCK) {
                        siroff(SIR_CLOCK);
                        cnt.v_soft++;
                if (ssir & SIR_CLOCK) {
                        siroff(SIR_CLOCK);
                        cnt.v_soft++;
-                       softclock((caddr_t)frame.f_pc, (int)frame.f_sr);
+                       softclock();
                }
                /*
                 * If this was not an AST trap, we are all done.
                }
                /*
                 * If this was not an AST trap, we are all done.
@@ -271,15 +344,19 @@ copyfault:
                        return;
                }
                spl0();
                        return;
                }
                spl0();
-#ifndef PROFTIMER
-               if ((p->p_flag&SOWEUPC) && p->p_stats->p_prof.pr_scale) {
-                       addupc(frame.f_pc, &p->p_stats->p_prof, 1);
+               if (p->p_flag & SOWEUPC) {
                        p->p_flag &= ~SOWEUPC;
                        p->p_flag &= ~SOWEUPC;
+                       ADDUPROF(p);
                }
                }
-#endif
                goto out;
 
        case T_MMUFLT:          /* kernel mode page fault */
                goto out;
 
        case T_MMUFLT:          /* kernel mode page fault */
+               /*
+                * If we were doing profiling ticks or other user mode
+                * stuff from interrupt code, Just Say No.
+                */
+               if (p->p_addr->u_pcb.pcb_onfault == fswintr)
+                       goto copyfault;
                /* fall into ... */
 
        case T_MMUFLT|T_USER:   /* page fault */
                /* fall into ... */
 
        case T_MMUFLT|T_USER:   /* page fault */
@@ -367,90 +444,70 @@ copyfault:
        if ((type & T_USER) == 0)
                return;
 out:
        if ((type & T_USER) == 0)
                return;
 out:
-       while (i = CURSIG(p))
-               psig(i);
-       p->p_pri = 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 that happened after we setrq ourselves but before we
-                * swtch()'ed, we might not be on the queue indicated by
-                * our priority.
-                */
-               s = splclock();
-               setrq(p);
-               p->p_stats->p_ru.ru_nivcsw++;
-               swtch();
-               splx(s);
-               while (i = CURSIG(p))
-                       psig(i);
-       }
-       if (p->p_stats->p_prof.pr_scale) {
-               int ticks;
-               struct timeval *tv = &p->p_stime;
-
-               ticks = ((tv->tv_sec - syst.tv_sec) * 1000 +
-                       (tv->tv_usec - syst.tv_usec) / 1000) / (tick / 1000);
-               if (ticks) {
-#ifdef PROFTIMER
-                       extern int profscale;
-                       addupc(frame.f_pc, &p->p_stats->p_prof,
-                           ticks * profscale);
-#else
-                       addupc(frame.f_pc, &p->p_stats->p_prof, ticks);
-#endif
-               }
-       }
-       curpri = p->p_pri;
+       userret(p, &frame, sticks, v, 1);
 }
 
 /*
  * Proces a system call.
  */
 syscall(code, frame)
 }
 
 /*
  * Proces a system call.
  */
 syscall(code, frame)
-       volatile unsigned code;
+       u_int code;
        struct frame frame;
 {
        register caddr_t params;
        struct frame frame;
 {
        register caddr_t params;
-       register int i;
        register struct sysent *callp;
        register struct sysent *callp;
-       register struct proc *p = curproc;
+       register struct proc *p;
        int error, opc, numsys, s;
        int error, opc, numsys, s;
+       u_int argsize;
        struct args {
                int i[8];
        } args;
        int rval[2];
        struct args {
                int i[8];
        } args;
        int rval[2];
-       struct timeval syst;
-       struct sysent *systab;
+       u_quad_t sticks;
 
        cnt.v_syscall++;
 
        cnt.v_syscall++;
-       syst = p->p_stime;
        if (!USERMODE(frame.f_sr))
                panic("syscall");
        if (!USERMODE(frame.f_sr))
                panic("syscall");
+       p = curproc;
+       sticks = p->p_sticks;
        p->p_md.md_regs = frame.f_regs;
        opc = frame.f_pc - 2;
        p->p_md.md_regs = frame.f_regs;
        opc = frame.f_pc - 2;
-       systab = sysent;
-       numsys = nsysent;
+       callp = sysent, numsys = nsysent;
        params = (caddr_t)frame.f_regs[SP] + sizeof(int);
        params = (caddr_t)frame.f_regs[SP] + sizeof(int);
-       if (code == 0) {                        /* indir */
+       switch (code) {
+
+       case SYS_indir:
+               /*
+                * Code is first argument, followed by actual args.
+                */
                code = fuword(params);
                params += sizeof(int);
                code = fuword(params);
                params += sizeof(int);
+               break;
+
+       case SYS___indir:
+               /*
+                * Like indir, but code is a quad, so as to maintain
+                * quad alignment for the rest of the arguments.
+                */
+               code = fuword(params + _QUAD_LOWWORD * sizeof(int));
+               params += sizeof(quad_t);
+               break;
+
+       default:
+               /* nothing to do by default */
+               break;
        }
        }
-       if (code >= numsys)
-               callp = &systab[0];             /* indir (illegal) */
+       if (code < numsys)
+               callp += code;
        else
        else
-               callp = &systab[code];
-       if ((i = callp->sy_narg * sizeof (int)) &&
-           (error = copyin(params, (caddr_t)&args, (u_int)i))) {
-               frame.f_regs[D0] = error;
-               frame.f_sr |= PSL_C;    /* carry bit */
+               callp += SYS_indir;     /* => nosys */
+       argsize = callp->sy_narg * sizeof(int);
+       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);
 #endif
 #ifdef KTRACE
                if (KTRPOINT(p, KTR_SYSCALL))
                        ktrsyscall(p->p_tracep, code, callp->sy_narg, args.i);
 #endif
-               goto done;
+               goto bad;
        }
 #ifdef KTRACE
        if (KTRPOINT(p, KTR_SYSCALL))
        }
 #ifdef KTRACE
        if (KTRPOINT(p, KTR_SYSCALL))
@@ -459,64 +516,34 @@ syscall(code, frame)
        rval[0] = 0;
        rval[1] = frame.f_regs[D1];
        error = (*callp->sy_call)(p, &args, rval);
        rval[0] = 0;
        rval[1] = frame.f_regs[D1];
        error = (*callp->sy_call)(p, &args, rval);
-       if (error == ERESTART)
-               frame.f_pc = opc;
-       else if (error != EJUSTRETURN) {
-               if (error) {
-                       frame.f_regs[D0] = error;
-                       frame.f_sr |= PSL_C;    /* carry bit */
-               } else {
-                       frame.f_regs[D0] = rval[0];
-                       frame.f_regs[D1] = rval[1];
-                       frame.f_sr &= ~PSL_C;
-               }
-       }
-       /* else if (error == EJUSTRETURN) */
-               /* nothing to do */
+       switch (error) {
 
 
-done:
-       /*
-        * Reinitialize proc pointer `p' as it may be different
-        * if this is a child returning from fork syscall.
-        */
-       p = curproc;
-       while (i = CURSIG(p))
-               psig(i);
-       p->p_pri = p->p_usrpri;
-       if (want_resched) {
+       case 0:
                /*
                /*
-                * 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.
+                * Reinitialize proc pointer `p' as it may be different
+                * if this is a child returning from fork syscall.
                 */
                 */
-               s = splclock();
-               setrq(p);
-               p->p_stats->p_ru.ru_nivcsw++;
-               swtch();
-               splx(s);
-               while (i = CURSIG(p))
-                       psig(i);
-       }
-       if (p->p_stats->p_prof.pr_scale) {
-               int ticks;
-               struct timeval *tv = &p->p_stime;
-
-               ticks = ((tv->tv_sec - syst.tv_sec) * 1000 +
-                       (tv->tv_usec - syst.tv_usec) / 1000) / (tick / 1000);
-               if (ticks) {
-#ifdef PROFTIMER
-                       extern int profscale;
-                       addupc(frame.f_pc, &p->p_stats->p_prof,
-                           ticks * profscale);
-#else
-                       addupc(frame.f_pc, &p->p_stats->p_prof, ticks);
-#endif
-               }
+               p = curproc;
+               frame.f_regs[D0] = rval[0];
+               frame.f_regs[D1] = rval[1];
+               frame.f_sr &= ~PSL_C;
+               break;
+
+       case ERESTART:
+               frame.f_pc = opc;
+               break;
+
+       case EJUSTRETURN:
+               break;          /* nothing to do */
+
+       default:
+       bad:
+               frame.f_regs[D0] = error;
+               frame.f_sr |= PSL_C;
+               break;
        }
        }
-       curpri = p->p_pri;
+
+       userret(p, &frame, sticks, (u_int)0, 0);
 #ifdef KTRACE
        if (KTRPOINT(p, KTR_SYSRET))
                ktrsysret(p->p_tracep, code, error, rval[0]);
 #ifdef KTRACE
        if (KTRPOINT(p, KTR_SYSRET))
                ktrsysret(p->p_tracep, code, error, rval[0]);