added my responsibility for the `cpm' port
[unix-history] / sys / i386 / isa / pccons.c
index cac3776..ca5621f 100644 (file)
@@ -34,7 +34,7 @@
  * SUCH DAMAGE.
  *
  *     from: @(#)pccons.c      5.11 (Berkeley) 5/21/91
  * SUCH DAMAGE.
  *
  *     from: @(#)pccons.c      5.11 (Berkeley) 5/21/91
- *     $Id: pccons.c,v 1.15 1994/03/18 17:18:12 ats Exp $
+ *     $Id: pccons.c,v 1.16 1994/05/03 19:38:49 davidg Exp $
  */
 
 /*
  */
 
 /*
@@ -295,7 +295,6 @@ pcopen(dev, flag, mode, p)
        tp->t_dev = dev;
        openf++;
        if ((tp->t_state & TS_ISOPEN) == 0) {
        tp->t_dev = dev;
        openf++;
        if ((tp->t_state & TS_ISOPEN) == 0) {
-               tp->t_state |= TS_WOPEN;
                ttychars(tp);
                tp->t_iflag = TTYDEF_IFLAG;
                tp->t_oflag = TTYDEF_OFLAG;
                ttychars(tp);
                tp->t_iflag = TTYDEF_IFLAG;
                tp->t_oflag = TTYDEF_OFLAG;
@@ -351,10 +350,8 @@ pcwrite(dev, uio, flag)
  * Catch the character, and see who it goes to.
  */
 void
  * Catch the character, and see who it goes to.
  */
 void
-pcrint(dev, irq, cpl)
-       dev_t dev;
-       int irq;                /* XXX ??? */
-       int cpl;
+pcrint(unit)
+       int unit;
 {
        int c;
        char *cp;
 {
        int c;
        char *cp;
@@ -458,17 +455,8 @@ pcstart(tp)
        if (tp->t_state & (TS_TIMEOUT|TS_BUSY|TS_TTSTOP))
                goto out;
        do {
        if (tp->t_state & (TS_TIMEOUT|TS_BUSY|TS_TTSTOP))
                goto out;
        do {
-       if (RB_LEN(tp->t_out) <= tp->t_lowat) {
-               if (tp->t_state&TS_ASLEEP) {
-                       tp->t_state &= ~TS_ASLEEP;
-                       wakeup((caddr_t)tp->t_out);
-               }
-               if (tp->t_wsel) {
-                       selwakeup(tp->t_wsel, tp->t_state & TS_WCOLL);
-                       tp->t_wsel = 0;
-                       tp->t_state &= ~TS_WCOLL;
-               }
-       }
+       if (tp->t_state & (TS_SO_OCOMPLETE | TS_SO_OLOWAT) || tp->t_wsel)
+               ttwwakeup(tp);
        if (RB_LEN(tp->t_out) == 0)
                goto out;
        c = getc(tp->t_out);
        if (RB_LEN(tp->t_out) == 0)
                goto out;
        c = getc(tp->t_out);
@@ -643,26 +631,13 @@ static u_char shift_down, ctrl_down, alt_down, caps, num, scroll;
 /* translate ANSI color codes to standard pc ones */
 static char fgansitopc[] =
 {      FG_BLACK, FG_RED, FG_GREEN, FG_BROWN, FG_BLUE,
 /* translate ANSI color codes to standard pc ones */
 static char fgansitopc[] =
 {      FG_BLACK, FG_RED, FG_GREEN, FG_BROWN, FG_BLUE,
-       FG_MAGENTA, FG_CYAN, FG_LIGHTGREY};
+       FG_MAGENTA, FG_CYAN, FG_LIGHTGREY
+};
 
 static char bgansitopc[] =
 {      BG_BLACK, BG_RED, BG_GREEN, BG_BROWN, BG_BLUE,
 
 static char bgansitopc[] =
 {      BG_BLACK, BG_RED, BG_GREEN, BG_BROWN, BG_BLUE,
-       BG_MAGENTA, BG_CYAN, BG_LIGHTGREY};
-
-static void move_up(u_short *s, u_short *d, u_int len)
-{
-       s += len;
-       d += len;
-       while (len-- > 0)
-               *--d = *--s;
-}
-
-
-static void move_down(u_short *s, u_short *d, u_int len)
-{
-       while (len-- > 0)
-               *d++ = *s++;
-}
+       BG_MAGENTA, BG_CYAN, BG_LIGHTGREY
+};
 
 /*
  *   sput has support for emulation of the 'pc3' termcap entry.
 
 /*
  *   sput has support for emulation of the 'pc3' termcap entry.
@@ -876,7 +851,7 @@ sput(c,  ka)
                                        posy = (crtat - Crtat) / vs.ncol;
                                        if (vs.cx > posy)
                                                vs.cx = posy;
                                        posy = (crtat - Crtat) / vs.ncol;
                                        if (vs.cx > posy)
                                                vs.cx = posy;
-                                       bcopy(Crtat+vs.ncol*vs.cx, Crtat, vs.ncol*(vs.nrow-vs.cx)*CHR);
+                                       bcopyw(Crtat+vs.ncol*vs.cx, Crtat, vs.ncol*(vs.nrow-vs.cx)*CHR);
                                        fillw((at <<8)+' ',
                                                (Crtat + vs.ncol * (vs.nrow - vs.cx)),
                                                vs.ncol * vs.cx);
                                        fillw((at <<8)+' ',
                                                (Crtat + vs.ncol * (vs.nrow - vs.cx)),
                                                vs.ncol * vs.cx);
@@ -888,7 +863,7 @@ sput(c,  ka)
                                        posy = (crtat - Crtat) / vs.ncol;
                                        if (vs.cx > vs.nrow - posy)
                                                vs.cx = vs.nrow - posy;
                                        posy = (crtat - Crtat) / vs.ncol;
                                        if (vs.cx > vs.nrow - posy)
                                                vs.cx = vs.nrow - posy;
-                                       bcopy(Crtat, Crtat+vs.ncol*vs.cx, vs.ncol*(vs.nrow-vs.cx)*CHR);
+                                       bcopyw(Crtat, Crtat+vs.ncol*vs.cx, vs.ncol*(vs.nrow-vs.cx)*CHR);
                                        fillw((at <<8)+' ', Crtat, vs.ncol*vs.cx);
                                        /* crtat += vs.ncol*vs.cx;*/ /* XXX */
                                        vs.esc = 0; vs.ebrac = 0; vs.eparm = 0;
                                        fillw((at <<8)+' ', Crtat, vs.ncol*vs.cx);
                                        /* crtat += vs.ncol*vs.cx;*/ /* XXX */
                                        vs.esc = 0; vs.ebrac = 0; vs.eparm = 0;
@@ -901,7 +876,7 @@ sput(c,  ka)
                                        src = Crtat + posy * vs.ncol;
                                        dst = src + vs.cx * vs.ncol;
                                        count = vs.nrow - (posy + vs.cx);
                                        src = Crtat + posy * vs.ncol;
                                        dst = src + vs.cx * vs.ncol;
                                        count = vs.nrow - (posy + vs.cx);
-                                       move_up(src, dst, count * vs.ncol);
+                                       bcopyw(src, dst, count * vs.ncol * CHR);
                                        fillw((at <<8)+' ', src, vs.cx * vs.ncol);
                                        vs.esc = 0; vs.ebrac = 0; vs.eparm = 0;
                                        break;
                                        fillw((at <<8)+' ', src, vs.cx * vs.ncol);
                                        vs.esc = 0; vs.ebrac = 0; vs.eparm = 0;
                                        break;
@@ -913,7 +888,7 @@ sput(c,  ka)
                                        dst = Crtat + posy * vs.ncol;
                                        src = dst + vs.cx * vs.ncol;
                                        count = vs.nrow - (posy + vs.cx);
                                        dst = Crtat + posy * vs.ncol;
                                        src = dst + vs.cx * vs.ncol;
                                        count = vs.nrow - (posy + vs.cx);
-                                       move_down(src, dst, count * vs.ncol);
+                                       bcopyw(src, dst, count * vs.ncol * CHR);
                                        src = dst + count * vs.ncol;
                                        fillw((at <<8)+' ', src, vs.cx * vs.ncol);
                                        vs.esc = 0; vs.ebrac = 0; vs.eparm = 0;
                                        src = dst + count * vs.ncol;
                                        fillw((at <<8)+' ', src, vs.cx * vs.ncol);
                                        vs.esc = 0; vs.ebrac = 0; vs.eparm = 0;
@@ -1003,7 +978,7 @@ sput(c,  ka)
        }
        if (sc && crtat >= Crtat+vs.ncol*vs.nrow) { /* scroll check */
                if (openf) do (void)sgetc(1); while (scroll);
        }
        if (sc && crtat >= Crtat+vs.ncol*vs.nrow) { /* scroll check */
                if (openf) do (void)sgetc(1); while (scroll);
-               bcopy(Crtat+vs.ncol, Crtat, vs.ncol*(vs.nrow-1)*CHR);
+               bcopyw(Crtat+vs.ncol, Crtat, vs.ncol*(vs.nrow-1)*CHR);
                fillw ((at << 8) + ' ', Crtat + vs.ncol*(vs.nrow-1),
                        vs.ncol);
                crtat -= vs.ncol;
                fillw ((at << 8) + ' ', Crtat + vs.ncol*(vs.nrow-1),
                        vs.ncol);
                crtat -= vs.ncol;
@@ -1561,6 +1536,12 @@ loop:
 #endif /* !XSERVER*/
        }
 
 #endif /* !XSERVER*/
        }
 
+       /*
+        *   Check for cntl-alt-del
+        */
+       if ((dt == 83) && ctrl_down && alt_down)
+               cpu_reset();
+
 #include "ddb.h"
 #if NDDB > 0
        /*
 #include "ddb.h"
 #if NDDB > 0
        /*
@@ -1568,7 +1549,7 @@ loop:
         */
        if ((dt == 1) && ctrl_down && alt_down) {
                Debugger("manual escape to debugger");
         */
        if ((dt == 1) && ctrl_down && alt_down) {
                Debugger("manual escape to debugger");
-               dt |= 0x80;     /* discard esc (ddb discarded ctrl-alt) */
+               goto loop;
        }
 #endif
 
        }
 #endif
 
@@ -1801,7 +1782,7 @@ void cons_normal()
 
 int pcmmap(dev_t dev, int offset, int nprot)
 {
 
 int pcmmap(dev_t dev, int offset, int nprot)
 {
-       if (offset > 0x20000)
+       if (offset > 0x20000 - PAGE_SIZE)
                return -1;
        return i386_btop((0xa0000 + offset));
 }
                return -1;
        return i386_btop((0xa0000 + offset));
 }