changes from Rick Macklem
authorRalph Campbell <ralph@ucbvax.Berkeley.EDU>
Mon, 21 Dec 1992 03:36:48 +0000 (19:36 -0800)
committerRalph Campbell <ralph@ucbvax.Berkeley.EDU>
Mon, 21 Dec 1992 03:36:48 +0000 (19:36 -0800)
SCCS-vsn: sys/pmax/dev/asc.c 7.9
SCCS-vsn: sys/pmax/dev/dc.c 7.12
SCCS-vsn: sys/pmax/dev/if_le.c 7.9
SCCS-vsn: sys/pmax/dev/cfb.c 7.6
SCCS-vsn: sys/pmax/dev/ascreg.h 7.3
SCCS-vsn: sys/pmax/dev/dtop.c 7.2
SCCS-vsn: sys/pmax/dev/fb.c 7.2
SCCS-vsn: sys/pmax/dev/mfb.c 7.2
SCCS-vsn: sys/pmax/dev/scc.c 7.2
SCCS-vsn: sys/pmax/dev/sccreg.h 7.2
SCCS-vsn: sys/pmax/dev/xcfb.c 7.2

usr/src/sys/pmax/dev/asc.c
usr/src/sys/pmax/dev/ascreg.h
usr/src/sys/pmax/dev/cfb.c
usr/src/sys/pmax/dev/dc.c
usr/src/sys/pmax/dev/dtop.c
usr/src/sys/pmax/dev/fb.c
usr/src/sys/pmax/dev/if_le.c
usr/src/sys/pmax/dev/mfb.c
usr/src/sys/pmax/dev/scc.c
usr/src/sys/pmax/dev/sccreg.h
usr/src/sys/pmax/dev/xcfb.c

index b1bfbdf..a59a5f9 100644 (file)
@@ -7,7 +7,7 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)asc.c       7.8 (Berkeley) %G%
+ *     @(#)asc.c       7.9 (Berkeley) %G%
  */
 
 /* 
  */
 
 /* 
 #include <pmax/pmax/kmin.h>
 #include <pmax/pmax/pmaxtype.h>
 
 #include <pmax/pmax/kmin.h>
 #include <pmax/pmax/pmaxtype.h>
 
-#define ASC_OFFSET_53C94       0x0             /* from module base */
-#define ASC_OFFSET_DMAR                0x40000         /* DMA Address Register */
-#define ASC_OFFSET_RAM         0x80000         /* SRAM Buffer */
-#define ASC_OFFSET_ROM         0xc0000         /* Diagnostic ROM */
-
-#define        ASC_RAM_SIZE            0x20000         /* 128k (32k*32) */
-
 #define        readback(a)     { register int foo; foo = (a); }
 #define        readback(a)     { register int foo; foo = (a); }
-/*
- * DMA Address Register
- */
-#define ASC_DMAR_MASK          0x1ffff         /* 17 bits, 128k */
-#define ASC_DMAR_WRITE         0x80000000      /* DMA direction bit */
-#define        ASC_DMA_ADDR(x)         ((unsigned)(x) & ASC_DMAR_MASK)
-
-/*
- * Synch xfer parameters, and timing conversions
- */
-#define SCSI_MIN_PERIOD                50      /* in 4 nsecs units */
-#define ASC_MIN_PERIOD25       5       /* in CLKS/BYTE, 1 CLK = 40nsecs */
-#define ASC_MIN_PERIOD12       3       /* in CLKS/BYTE, 1 CLK = 80nsecs */
-#define ASC_MAX_PERIOD25       35      /* in CLKS/BYTE, 1 CLK = 40nsecs */
-#define ASC_MAX_PERIOD12       18      /* in CLKS/BYTE, 1 CLK = 80nsecs */
-#define ASC_MAX_OFFSET         15      /* pure number */
-
 extern int pmax_boardtype;
 
 /*
 extern int pmax_boardtype;
 
 /*
@@ -389,7 +365,6 @@ typedef struct scsi_state {
 #define DID_SYNC       0x20    /* true if synchronous offset was negotiated */
 #define TRY_SYNC       0x40    /* true if try neg. synchronous offset */
 
 #define DID_SYNC       0x20    /* true if synchronous offset was negotiated */
 #define TRY_SYNC       0x40    /* true if try neg. synchronous offset */
 
-#define ASC_NCMD       7
 /*
  * State kept for each active SCSI host interface (53C94).
  */
 /*
  * State kept for each active SCSI host interface (53C94).
  */
@@ -428,7 +403,8 @@ typedef struct asc_softc *asc_softc_t;
 #define        ASCDMA_READ     1
 #define        ASCDMA_WRITE    2
 static void tb_dma_start(), tb_dma_end(), asic_dma_start(), asic_dma_end();
 #define        ASCDMA_READ     1
 #define        ASCDMA_WRITE    2
 static void tb_dma_start(), tb_dma_end(), asic_dma_start(), asic_dma_end();
-u_long asc_iobuf[33792];
+extern u_long asc_iomem;
+extern u_long asic_base;
 
 /*
  * Definition of the controller for the auto-configuration program.
 
 /*
  * Definition of the controller for the auto-configuration program.
@@ -450,7 +426,7 @@ asc_probe(cp)
        register asc_softc_t asc;
        register asc_regmap_t *regs;
        int unit, id, s, i;
        register asc_softc_t asc;
        register asc_regmap_t *regs;
        int unit, id, s, i;
-       u_int bufadr;
+       int bufsiz;
 
        if ((unit = cp->pmax_unit) >= NASC)
                return (0);
 
        if ((unit = cp->pmax_unit) >= NASC)
                return (0);
@@ -471,15 +447,13 @@ asc_probe(cp)
        switch (pmax_boardtype) {
        case DS_3MIN:
        case DS_MAXINE:
        switch (pmax_boardtype) {
        case DS_3MIN:
        case DS_MAXINE:
+       case DS_3MAXPLUS:
            if (unit == 0) {
            if (unit == 0) {
-               bufadr = MACH_PHYS_TO_UNCACHED(MACH_CACHED_TO_PHYS(asc_iobuf));
-               bufadr = (bufadr + NBPG - 1) & ~(NBPG - 1);
-               asc->buff = (u_char *)bufadr;
-               *((volatile int *)MACH_PHYS_TO_UNCACHED(KMIN_REG_SCSI_DMAPTR))
-                       = -1;
-               *((volatile int *)MACH_PHYS_TO_UNCACHED(KMIN_REG_SCSI_DMANPTR))
-                       = -1;
-               *((volatile int *)MACH_PHYS_TO_UNCACHED(KMIN_REG_SCSI_SCR)) = 0;
+               asc->buff = (u_char *)MACH_PHYS_TO_UNCACHED(asc_iomem);
+               bufsiz = 8192;
+               *((volatile int *)ASIC_REG_SCSI_DMAPTR(asic_base)) = -1;
+               *((volatile int *)ASIC_REG_SCSI_DMANPTR(asic_base)) = -1;
+               *((volatile int *)ASIC_REG_SCSI_SCR(asic_base)) = 0;
                asc->dma_start = asic_dma_start;
                asc->dma_end = asic_dma_end;
                break;
                asc->dma_start = asic_dma_start;
                asc->dma_end = asic_dma_end;
                break;
@@ -491,6 +465,7 @@ asc_probe(cp)
        default:
            asc->dmar = (volatile int *)(cp->pmax_addr + ASC_OFFSET_DMAR);
            asc->buff = (u_char *)(cp->pmax_addr + ASC_OFFSET_RAM);
        default:
            asc->dmar = (volatile int *)(cp->pmax_addr + ASC_OFFSET_DMAR);
            asc->buff = (u_char *)(cp->pmax_addr + ASC_OFFSET_RAM);
+           bufsiz = PER_TGT_DMA_SIZE;
            asc->dma_start = tb_dma_start;
            asc->dma_end = tb_dma_end;
        };
            asc->dma_start = tb_dma_start;
            asc->dma_end = tb_dma_end;
        };
@@ -500,6 +475,7 @@ asc_probe(cp)
         */
        switch (pmax_boardtype) {
        case DS_3MAX:
         */
        switch (pmax_boardtype) {
        case DS_3MAX:
+       case DS_3MAXPLUS:
                asc->min_period = ASC_MIN_PERIOD25;
                asc->max_period = ASC_MAX_PERIOD25;
                asc->ccf = ASC_CCF(25);
                asc->min_period = ASC_MIN_PERIOD25;
                asc->max_period = ASC_MAX_PERIOD25;
                asc->ccf = ASC_CCF(25);
@@ -551,15 +527,14 @@ asc_probe(cp)
         * This way we will eventually be able to attach/detach
         * drives on-fly.  And 18k/target is plenty for normal use.
         */
         * This way we will eventually be able to attach/detach
         * drives on-fly.  And 18k/target is plenty for normal use.
         */
-#define PER_TGT_DMA_SIZE       ((ASC_RAM_SIZE/7) & ~(sizeof(int)-1))
 
        /*
         * Give each target its own DMA buffer region.
         * We may want to try ping ponging buffers later.
         */
        for (i = 0; i < ASC_NCMD; i++) {
 
        /*
         * Give each target its own DMA buffer region.
         * We may want to try ping ponging buffers later.
         */
        for (i = 0; i < ASC_NCMD; i++) {
-               asc->st[i].dmaBufAddr = asc->buff + PER_TGT_DMA_SIZE * i;
-               asc->st[i].dmaBufSize = PER_TGT_DMA_SIZE;
+               asc->st[i].dmaBufAddr = asc->buff + bufsiz * i;
+               asc->st[i].dmaBufSize = bufsiz;
        }
        printf("asc%d at nexus0 csr 0x%x priority %d SCSI id %d\n",
                unit, cp->pmax_addr, cp->pmax_pri, id);
        }
        printf("asc%d at nexus0 csr 0x%x priority %d SCSI id %d\n",
                unit, cp->pmax_addr, cp->pmax_pri, id);
@@ -621,7 +596,8 @@ asc_reset(asc, regs)
        regs->asc_sel_timo = asc->timeout_250;
        /* restore our ID */
        regs->asc_cnfg1 = asc->myid | ASC_CNFG1_P_CHECK;
        regs->asc_sel_timo = asc->timeout_250;
        /* restore our ID */
        regs->asc_cnfg1 = asc->myid | ASC_CNFG1_P_CHECK;
-       regs->asc_cnfg2 = /* ASC_CNFG2_RFB | */ ASC_CNFG2_SCSI2;
+       /* include ASC_CNFG2_SCSI2 if you want to allow SCSI II commands */
+       regs->asc_cnfg2 = /* ASC_CNFG2_RFB | ASC_CNFG2_SCSI2 | */ ASC_CNFG2_EPL;
        regs->asc_cnfg3 = 0;
        /* zero anything else */
        ASC_TC_PUT(regs, 0);
        regs->asc_cnfg3 = 0;
        /* zero anything else */
        ASC_TC_PUT(regs, 0);
@@ -966,7 +942,18 @@ again:
                        return;
 
                default:
                        return;
 
                default:
-                       goto abort;
+                       /*
+                        * On rare occasions my RZ24 does a disconnect during
+                        * data in phase and the following seems to keep it
+                        * happy.
+                        * XXX Should a scsi disk ever do this??
+                        */
+                       asc->script = &asc_scripts[SCRIPT_RESEL];
+                       asc->state = ASC_STATE_RESEL;
+                       state->flags |= DISCONN;
+                       regs->asc_cmd = ASC_CMD_ENABLE_SEL;
+                       readback(regs->asc_cmd);
+                       return;
                }
        }
 
                }
        }
 
@@ -1750,12 +1737,12 @@ asic_dma_start(asc, state, cp, flag)
        int flag;
 {
        register volatile u_int *ssr = (volatile u_int *)
        int flag;
 {
        register volatile u_int *ssr = (volatile u_int *)
-               MACH_PHYS_TO_UNCACHED(KMIN_REG_CSR);
+               ASIC_REG_CSR(asic_base);
        u_int phys, nphys;
 
        /* stop DMA engine first */
        *ssr &= ~ASIC_CSR_DMAEN_SCSI;
        u_int phys, nphys;
 
        /* stop DMA engine first */
        *ssr &= ~ASIC_CSR_DMAEN_SCSI;
-       * ((volatile int *)MACH_PHYS_TO_UNCACHED(KMIN_REG_SCSI_SCR)) = 0;
+       * ((volatile int *)ASIC_REG_SCSI_SCR(asic_base)) = 0;
 
        phys = MACH_CACHED_TO_PHYS(cp);
        cp = (caddr_t)pmax_trunc_page(cp + NBPG);
 
        phys = MACH_CACHED_TO_PHYS(cp);
        cp = (caddr_t)pmax_trunc_page(cp + NBPG);
@@ -1764,9 +1751,9 @@ asic_dma_start(asc, state, cp, flag)
        asc->dma_next = cp;
        asc->dma_xfer = state->dmalen - (nphys - phys);
 
        asc->dma_next = cp;
        asc->dma_xfer = state->dmalen - (nphys - phys);
 
-       *(volatile int *)MACH_PHYS_TO_UNCACHED(KMIN_REG_SCSI_DMAPTR) =
+       *(volatile int *)ASIC_REG_SCSI_DMAPTR(asic_base) =
                ASIC_DMA_ADDR(phys);
                ASIC_DMA_ADDR(phys);
-       *(volatile int *)MACH_PHYS_TO_UNCACHED(KMIN_REG_SCSI_DMANPTR) =
+       *(volatile int *)ASIC_REG_SCSI_DMANPTR(asic_base) =
                ASIC_DMA_ADDR(nphys);
        if (flag == ASCDMA_READ)
                *ssr |= ASIC_CSR_SCSI_DIR | ASIC_CSR_DMAEN_SCSI;
                ASIC_DMA_ADDR(nphys);
        if (flag == ASCDMA_READ)
                *ssr |= ASIC_CSR_SCSI_DIR | ASIC_CSR_DMAEN_SCSI;
@@ -1782,38 +1769,39 @@ asic_dma_end(asc, state, flag)
        int flag;
 {
        register volatile u_int *ssr = (volatile u_int *)
        int flag;
 {
        register volatile u_int *ssr = (volatile u_int *)
-               MACH_PHYS_TO_UNCACHED(KMIN_REG_CSR);
+               ASIC_REG_CSR(asic_base);
        int nb;
 
        *ssr &= ~ASIC_CSR_DMAEN_SCSI;
        int nb;
 
        *ssr &= ~ASIC_CSR_DMAEN_SCSI;
-       *((volatile int *)MACH_PHYS_TO_UNCACHED(KMIN_REG_SCSI_DMAPTR)) = -1;
-       *((volatile int *)MACH_PHYS_TO_UNCACHED(KMIN_REG_SCSI_DMANPTR)) = -1;
+       *((volatile int *)ASIC_REG_SCSI_DMAPTR(asic_base)) = -1;
+       *((volatile int *)ASIC_REG_SCSI_DMANPTR(asic_base)) = -1;
        MachEmptyWriteBuffer();
 
        if (flag == ASCDMA_READ) {
                MachFlushDCache(MACH_PHYS_TO_CACHED(
                    MACH_UNCACHED_TO_PHYS(state->dmaBufAddr)), state->dmalen);
        MachEmptyWriteBuffer();
 
        if (flag == ASCDMA_READ) {
                MachFlushDCache(MACH_PHYS_TO_CACHED(
                    MACH_UNCACHED_TO_PHYS(state->dmaBufAddr)), state->dmalen);
-               if (nb = *((int *)MACH_PHYS_TO_UNCACHED(KMIN_REG_SCSI_SCR))) {
+               if (nb = *((int *)ASIC_REG_SCSI_SCR(asic_base))) {
                        /* pick up last upto6 bytes, sigh. */
                        register u_short *to;
                        register int w;
        
                        /* Last byte really xferred is.. */
                        to = (u_short *)(state->dmaBufAddr + state->dmalen - (nb << 1));
                        /* pick up last upto6 bytes, sigh. */
                        register u_short *to;
                        register int w;
        
                        /* Last byte really xferred is.. */
                        to = (u_short *)(state->dmaBufAddr + state->dmalen - (nb << 1));
-                       w = *(int *)MACH_PHYS_TO_UNCACHED(KMIN_REG_SCSI_SDR0);
+                       w = *(int *)ASIC_REG_SCSI_SDR0(asic_base);
                        *to++ = w;
                        if (--nb > 0) {
                                w >>= 16;
                                *to++ = w;
                        }
                        if (--nb > 0) {
                        *to++ = w;
                        if (--nb > 0) {
                                w >>= 16;
                                *to++ = w;
                        }
                        if (--nb > 0) {
-                               w = *(int *)MACH_PHYS_TO_UNCACHED(KMIN_REG_SCSI_SDR1);
+                               w = *(int *)ASIC_REG_SCSI_SDR1(asic_base);
                                *to++ = w;
                        }
                }
        }
 }
 
                                *to++ = w;
                        }
                }
        }
 }
 
+#ifdef notdef
 /*
  * Called by asic_intr() for scsi dma pointer update interrupts.
  */
 /*
  * Called by asic_intr() for scsi dma pointer update interrupts.
  */
@@ -1826,20 +1814,17 @@ asc_dma_intr()
        asc->dma_xfer -= NBPG;
        if (asc->dma_xfer <= -NBPG) {
                volatile u_int *ssr = (volatile u_int *)
        asc->dma_xfer -= NBPG;
        if (asc->dma_xfer <= -NBPG) {
                volatile u_int *ssr = (volatile u_int *)
-                       MACH_PHYS_TO_UNCACHED(KMIN_REG_CSR);
+                       ASIC_REG_CSR(asic_base);
                *ssr &= ~ASIC_CSR_DMAEN_SCSI;
        } else {
                asc->dma_next += NBPG;
                next_phys = MACH_CACHED_TO_PHYS(asc->dma_next);
        }
                *ssr &= ~ASIC_CSR_DMAEN_SCSI;
        } else {
                asc->dma_next += NBPG;
                next_phys = MACH_CACHED_TO_PHYS(asc->dma_next);
        }
-#ifdef notdef
-       else
-               next_phys = MACH_CACHED_TO_PHYS(asc_iobuf);
-#endif
-       *(volatile int *)MACH_PHYS_TO_UNCACHED(KMIN_REG_SCSI_DMANPTR) =
+       *(volatile int *)ASIC_REG_SCSI_DMANPTR(asic_base) =
                ASIC_DMA_ADDR(next_phys);
        MachEmptyWriteBuffer();
 }
                ASIC_DMA_ADDR(next_phys);
        MachEmptyWriteBuffer();
 }
+#endif
 
 #ifdef DEBUG
 asc_DumpLog(str)
 
 #ifdef DEBUG
 asc_DumpLog(str)
index 2588dd9..ac12bce 100644 (file)
@@ -7,7 +7,7 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)ascreg.h    7.2 (Berkeley) %G%
+ *     @(#)ascreg.h    7.3 (Berkeley) %G%
  */
 
 /* 
  */
 
 /* 
  *     courtesy of NCR.  Thanks Ken !
  */
 
  *     courtesy of NCR.  Thanks Ken !
  */
 
+#define ASC_OFFSET_53C94       0x0             /* from module base */
+#define ASC_OFFSET_DMAR                0x40000         /* DMA Address Register */
+#define ASC_OFFSET_RAM         0x80000         /* SRAM Buffer */
+#define ASC_OFFSET_ROM         0xc0000         /* Diagnostic ROM */
+
+#define        ASC_RAM_SIZE            0x20000         /* 128k (32k*32) */
+#define PER_TGT_DMA_SIZE       ((ASC_RAM_SIZE/7) & ~(sizeof(int)-1))
+#define ASC_NCMD               7
+
+/*
+ * DMA Address Register
+ */
+#define ASC_DMAR_MASK          0x1ffff         /* 17 bits, 128k */
+#define ASC_DMAR_WRITE         0x80000000      /* DMA direction bit */
+#define        ASC_DMA_ADDR(x)         ((unsigned)(x) & ASC_DMAR_MASK)
+
+/*
+ * Synch xfer parameters, and timing conversions
+ */
+#define SCSI_MIN_PERIOD                50      /* in 4 nsecs units */
+#define ASC_MIN_PERIOD25       5       /* in CLKS/BYTE, 1 CLK = 40nsecs */
+#define ASC_MIN_PERIOD12       3       /* in CLKS/BYTE, 1 CLK = 80nsecs */
+#define ASC_MAX_PERIOD25       35      /* in CLKS/BYTE, 1 CLK = 40nsecs */
+#define ASC_MAX_PERIOD12       18      /* in CLKS/BYTE, 1 CLK = 80nsecs */
+#define ASC_MAX_OFFSET         15      /* pure number */
 /*
  * Register map, padded as needed
  */
 /*
  * Register map, padded as needed
  */
index de089f2..fbd1f8d 100644 (file)
@@ -7,7 +7,7 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)cfb.c       7.5 (Berkeley) %G%
+ *     @(#)cfb.c       7.6 (Berkeley) %G%
  */
 
 /*
  */
 
 /*
@@ -106,22 +106,16 @@ static void cfbConfigMouse(), cfbDeconfigMouse();
 extern void fbKbdEvent(), fbMouseEvent(), fbMouseButtons();
 void cfbKbdEvent(), cfbMouseEvent(), cfbMouseButtons();
 #if NDC > 0
 extern void fbKbdEvent(), fbMouseEvent(), fbMouseButtons();
 void cfbKbdEvent(), cfbMouseEvent(), cfbMouseButtons();
 #if NDC > 0
-#include <machine/dc7085cons.h>
-extern void dcPutc();
 extern void (*dcDivertXInput)();
 extern void (*dcMouseEvent)();
 extern void (*dcMouseButtons)();
 #endif
 #if NSCC > 0
 extern void (*dcDivertXInput)();
 extern void (*dcMouseEvent)();
 extern void (*dcMouseButtons)();
 #endif
 #if NSCC > 0
-#include <pmax/dev/sccreg.h>
-extern void sccPutc();
 extern void (*sccDivertXInput)();
 extern void (*sccMouseEvent)();
 extern void (*sccMouseButtons)();
 #endif
 #if NDTOP > 0
 extern void (*sccDivertXInput)();
 extern void (*sccMouseEvent)();
 extern void (*sccMouseButtons)();
 #endif
 #if NDTOP > 0
-#include <pmax/dev/dtopreg.h>
-extern void dtopKBDPutc();
 extern void (*dtopDivertXInput)();
 extern void (*dtopMouseEvent)();
 extern void (*dtopMouseButtons)();
 extern void (*dtopDivertXInput)();
 extern void (*dtopMouseEvent)();
 extern void (*dtopMouseButtons)();
@@ -366,8 +360,14 @@ cfbLoadCursor(cursor)
                while (j < 4) {
                        out = 0;
                        for (i = 0; i < 4; i++) {
                while (j < 4) {
                        out = 0;
                        for (i = 0; i < 4; i++) {
+#ifdef CURSOR_EL
                                out = (out << 2) | ((ap & 0x1) << 1) |
                                        (bp & 0x1);
                                out = (out << 2) | ((ap & 0x1) << 1) |
                                        (bp & 0x1);
+#else
+                               out = ((out >> 2) & 0x3f) |
+                                       ((ap & 0x1) << 7) |
+                                       ((bp & 0x1) << 6);
+#endif
                                ap >>= 1;
                                bp >>= 1;
                        }
                                ap >>= 1;
                                bp >>= 1;
                        }
@@ -457,31 +457,16 @@ cfbinit(cp)
 
        fp->isMono = 0;
        fp->fr_addr = (char *)(cp + CFB_OFFSET_VRAM);
 
        fp->isMono = 0;
        fp->fr_addr = (char *)(cp + CFB_OFFSET_VRAM);
-       fp->fbu = &cfbu;
+       /*
+        * Must be in Uncached space or the Xserver sees a stale version of
+        * the event queue and acts totally wacko. I don't understand this,
+        * since the R3000 uses a physical address cache?
+        */
+       fp->fbu = (struct fbuaccess *)
+               MACH_PHYS_TO_UNCACHED(MACH_CACHED_TO_PHYS(&cfbu));
        fp->posCursor = cfbPosCursor;
        fp->posCursor = cfbPosCursor;
-       switch (pmax_boardtype) {
-#if NDC > 0
-       case DS_3MAX:
-               fp->KBDPutc = dcPutc;
-               fp->kbddev = makedev(DCDEV, DCKBD_PORT);
-               break;
-#endif
-#if NSCC > 0
-       case DS_3MIN:
-               fp->KBDPutc = sccPutc;
-               fp->kbddev = makedev(SCCDEV, SCCKBD_PORT);
-               break;
-#endif
-#if NDTOP > 0
-       case DS_MAXINE:
-               fp->KBDPutc = dtopKBDPutc;
-               fp->kbddev = makedev(DTOPDEV, DTOPKBD_PORT);
-               break;
-#endif
-       default:
-               printf("Can't cofigure keyboard/mouse\n");
+       if (tb_kbdmouseconfig(fp))
                return (0);
                return (0);
-       };
 
        /*
         * Initialize the screen.
 
        /*
         * Initialize the screen.
index 7634d7a..57e3364 100644 (file)
@@ -7,7 +7,7 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)dc.c        7.11 (Berkeley) %G%
+ *     @(#)dc.c        7.12 (Berkeley) %G%
  */
 
 /*
  */
 
 /*
@@ -150,6 +150,14 @@ dcprobe(cp)
        if (badaddr(cp->pmax_addr, 2))
                return (0);
 
        if (badaddr(cp->pmax_addr, 2))
                return (0);
 
+       /*
+        * For a remote console, wait a while for previous output to
+        * complete.
+        */
+       if (major(cn_tab.cn_dev) == DCDEV && cp->pmax_unit == 0 &&
+               cn_tab.cn_screen == 0)
+               DELAY(10000);
+
        /* reset chip */
        dcaddr = (dcregs *)cp->pmax_addr;
        dcaddr->dc_csr = CSR_CLR;
        /* reset chip */
        dcaddr = (dcregs *)cp->pmax_addr;
        dcaddr->dc_csr = CSR_CLR;
@@ -174,8 +182,6 @@ dcprobe(cp)
                dc_timer = 1;
                timeout(dcscan, (void *)0, hz);
        }
                dc_timer = 1;
                timeout(dcscan, (void *)0, hz);
        }
-       printf("dc%d at nexus0 csr 0x%x priority %d\n",
-               cp->pmax_unit, cp->pmax_addr, cp->pmax_pri);
 
        /*
         * Special handling for consoles.
 
        /*
         * Special handling for consoles.
@@ -188,6 +194,7 @@ dcprobe(cp)
                        dcaddr->dc_lpr = LPR_RXENAB | LPR_B4800 | LPR_OPAR |
                                LPR_PARENB | LPR_8_BIT_CHAR | DCMOUSE_PORT;
                        MachEmptyWriteBuffer();
                        dcaddr->dc_lpr = LPR_RXENAB | LPR_B4800 | LPR_OPAR |
                                LPR_PARENB | LPR_8_BIT_CHAR | DCMOUSE_PORT;
                        MachEmptyWriteBuffer();
+                       DELAY(1000);
                        KBDReset(makedev(DCDEV, DCKBD_PORT), dcPutc);
                        MouseInit(makedev(DCDEV, DCMOUSE_PORT), dcPutc, dcGetc);
                        splx(s);
                        KBDReset(makedev(DCDEV, DCKBD_PORT), dcPutc);
                        MouseInit(makedev(DCDEV, DCMOUSE_PORT), dcPutc, dcGetc);
                        splx(s);
@@ -196,10 +203,13 @@ dcprobe(cp)
                        dcaddr->dc_lpr = LPR_RXENAB | LPR_8_BIT_CHAR |
                                LPR_B9600 | minor(cn_tab.cn_dev);
                        MachEmptyWriteBuffer();
                        dcaddr->dc_lpr = LPR_RXENAB | LPR_8_BIT_CHAR |
                                LPR_B9600 | minor(cn_tab.cn_dev);
                        MachEmptyWriteBuffer();
+                       DELAY(1000);
                        cn_tab.cn_disabled = 0;
                        splx(s);
                }
        }
                        cn_tab.cn_disabled = 0;
                        splx(s);
                }
        }
+       printf("dc%d at nexus0 csr 0x%x priority %d\n",
+               cp->pmax_unit, cp->pmax_addr, cp->pmax_pri);
        return (1);
 }
 
        return (1);
 }
 
index b4c0f17..fd19a6a 100644 (file)
@@ -7,7 +7,7 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)dtop.c      7.1 (Berkeley) %G%
+ *     @(#)dtop.c      7.2 (Berkeley) %G%
  */
 
 /* 
  */
 
 /* 
  *     Hardware-level operations for the Desktop serial line
  *     bus (i2c aka ACCESS).
  */
  *     Hardware-level operations for the Desktop serial line
  *     bus (i2c aka ACCESS).
  */
+/************************************************************
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts,
+and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
+
+                        All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its 
+documentation for any purpose and without fee is hereby granted, 
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in 
+supporting documentation, and that the names of Digital or MIT not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.  
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+********************************************************/
 
 #include <dtop.h>
 #if NDTOP > 0
 
 #include <dtop.h>
 #if NDTOP > 0
@@ -80,6 +103,7 @@ int dtopparam                __P((struct tty *, struct termios *));
 int dtopstop           __P((struct tty *, int));
 void dtopstart         __P((struct tty *));
 void dtopKBDPutc       __P((dev_t, int));
 int dtopstop           __P((struct tty *, int));
 void dtopstart         __P((struct tty *));
 void dtopKBDPutc       __P((dev_t, int));
+static void dtop_keyboard_repeat __P((dtop_device_t));
 
 struct tty dtop_tty[NDTOP];
 void   (*dtopDivertXInput)();  /* X windows keyboard input routine */
 
 struct tty dtop_tty[NDTOP];
 void   (*dtopDivertXInput)();  /* X windows keyboard input routine */
@@ -119,7 +143,19 @@ struct dtop_softc {
 
 typedef struct dtop_softc *dtop_softc_t;
 struct tty dtop_tty[NDTOP];
 
 typedef struct dtop_softc *dtop_softc_t;
 struct tty dtop_tty[NDTOP];
-static int dtopenabled = 0;
+
+/*
+ * lk201 keyboard divisions and up/down mode key bitmap.
+ */
+#define NUMDIVS 14
+static u_char divbeg[NUMDIVS] = {0xbf, 0x91, 0xbc, 0xbd, 0xb0, 0xad, 0xa6,
+                                0xa9, 0x88, 0x56, 0x63, 0x6f, 0x7b, 0x7e};
+static u_char divend[NUMDIVS] = {0xff, 0xa5, 0xbc, 0xbe, 0xb2, 0xaf, 0xa8,
+                                0xac, 0x90, 0x62, 0x6e, 0x7a, 0x7d, 0x87};
+/*
+ * Initial defaults, groups 5 and 6 are up/down
+ */
+static u_long keymodes[8] = {0, 0, 0, 0, 0, 0x0003e000, 0, 0};
 
 /*
  * Definition of the driver for the auto-configuration program.
 
 /*
  * Definition of the driver for the auto-configuration program.
@@ -163,7 +199,9 @@ dtopprobe(cp)
         * poke it now.
         */
        dtopintr(dtopunit);
         * poke it now.
         */
        dtopintr(dtopunit);
-       dtopenabled = 1;
+       dtop->probed_once = 1;
+       printf("dtop%d at nexus0 csr 0x%x priority %d\n",
+               cp->pmax_unit, cp->pmax_addr, cp->pmax_pri);
        return (1);
 }
 
        return (1);
 }
 
@@ -300,7 +338,7 @@ dtopintr(unit)
 
        dtop = &dtop_softc[unit];
        if (dtop_get_packet(dtop, &msg) < 0) {
 
        dtop = &dtop_softc[unit];
        if (dtop_get_packet(dtop, &msg) < 0) {
-               if (dtopenabled)
+               if (dtop->probed_once)
                        printf("%s", "dtop: overrun (or stray)\n");
                return;
        }
                        printf("%s", "dtop: overrun (or stray)\n");
                return;
        }
@@ -360,11 +398,46 @@ dtopKBDPutc(dev, c)
        dev_t dev;
        int c;
 {
        dev_t dev;
        int c;
 {
+       register int i;
+       static int param = 0, cmd, mod, typ;
+       static u_char parms[2];
 
        /*
 
        /*
-        * Not yet, someday we will know how to send commands to the
-        * LK501 over the Access bus.
+        * Emulate the lk201 command codes.
         */
         */
+       if (param == 0) {
+               typ = (c & 0x1);
+               cmd = ((c >> 3) & 0xf);
+               mod = ((c >> 1) & 0x3);
+       } else
+               parms[param - 1] = (c & 0x7f);
+       if (c & 0x80) {
+               if (typ) {
+                       /*
+                        * A peripheral command code. Someday this driver
+                        * should know how to send commands to the lk501,
+                        * but until then this is all essentially a no-op.
+                        */
+                       ;
+               } else {
+                       /*
+                        * Set modes. These have to be emulated in software.
+                        */
+                       if (cmd > 0 && cmd < 15) {
+                               cmd--;
+                               if (mod & 0x2)
+                                  for (i = divbeg[cmd]; i <= divend[cmd]; i++)
+                                       keymodes[i >> 5] |=
+                                               (1 << (i & 0x1f));
+                               else
+                                  for (i = divbeg[cmd]; i <= divend[cmd]; i++)
+                                       keymodes[i >> 5] &=
+                                               ~(1 << (i & 0x1f));
+                       }
+               }
+               param = 0;
+       } else if (++param > 2)
+               param = 2;
 }
 
 /*
 }
 
 /*
@@ -404,13 +477,13 @@ dtop_get_packet(dtop, pkt)
         * the average packet exactly one word long, too.
         */
        for (max = 0; (max < DTOP_MAX_POLL) && !DTOP_RX_AVAIL(poll); max++)
         * the average packet exactly one word long, too.
         */
        for (max = 0; (max < DTOP_MAX_POLL) && !DTOP_RX_AVAIL(poll); max++)
-               DELAY(16);
+               DELAY(1);
        if (max == DTOP_MAX_POLL)
                goto bad;
        pkt->src_address = DTOP_GET_BYTE(data);
 
        for (max = 0; (max < DTOP_MAX_POLL) && !DTOP_RX_AVAIL(poll); max++)
        if (max == DTOP_MAX_POLL)
                goto bad;
        pkt->src_address = DTOP_GET_BYTE(data);
 
        for (max = 0; (max < DTOP_MAX_POLL) && !DTOP_RX_AVAIL(poll); max++)
-               DELAY(16);
+               DELAY(1);
        if (max == DTOP_MAX_POLL)
                goto bad;
        pkt->code.bits = DTOP_GET_BYTE(data);
        if (max == DTOP_MAX_POLL)
                goto bad;
        pkt->code.bits = DTOP_GET_BYTE(data);
@@ -423,7 +496,7 @@ dtop_get_packet(dtop, pkt)
        for (i = 0; i < len; i++) {
 again:
                for (max = 0; (max < DTOP_MAX_POLL) && !DTOP_RX_AVAIL(poll); max++)
        for (i = 0; i < len; i++) {
 again:
                for (max = 0; (max < DTOP_MAX_POLL) && !DTOP_RX_AVAIL(poll); max++)
-                       DELAY(16);
+                       DELAY(1);
                if (max == DTOP_MAX_POLL)
                        goto bad;
                if (c == DTOP_ESC_CHAR) {
                if (max == DTOP_MAX_POLL)
                        goto bad;
                if (c == DTOP_ESC_CHAR) {
@@ -551,24 +624,34 @@ dtop_locator_handler(dev, msg, event, outc)
        register MouseReport *mrp = &currentRep;
 
        if (dtopMouseButtons) {
        register MouseReport *mrp = &currentRep;
 
        if (dtopMouseButtons) {
+               mrp->state = 0;
                /*
                 * Do the position first
                 */
                coord = GET_SHORT(msg->body[2], msg->body[3]);
                /*
                 * Do the position first
                 */
                coord = GET_SHORT(msg->body[2], msg->body[3]);
-               mrp->dx = coord;
-               if (coord != 0)
+               if (coord < 0) {
+                       coord = -coord;
+                       moved = 1;
+               } else if (coord > 0) {
+                       mrp->state |= MOUSE_X_SIGN;
                        moved = 1;
                        moved = 1;
+               }
+               mrp->dx = (coord & 0x1f);
                coord = GET_SHORT(msg->body[4], msg->body[5]);
                coord = GET_SHORT(msg->body[4], msg->body[5]);
-               coord = - coord;
-               mrp->dy = coord;
-               if (coord != 0)
+               if (coord < 0) {
+                       coord = -coord;
+                       moved = 1;
+               } else if (coord > 0) {
+                       mrp->state |= MOUSE_Y_SIGN;
                        moved = 1;
                        moved = 1;
+               }
+               mrp->dy = (coord & 0x1f);
        
                /*
                 * Time for the buttons now
                 */
                buttons = GET_SHORT(msg->body[0], msg->body[1]);
        
                /*
                 * Time for the buttons now
                 */
                buttons = GET_SHORT(msg->body[0], msg->body[1]);
-               mrp->state = MOUSE_Y_SIGN | MOUSE_X_SIGN | (buttons & 0x7);
+               mrp->state |= (buttons & 0x7);
                if (moved)
                        (*dtopMouseEvent)(mrp);
                (*dtopMouseButtons)(mrp);
                if (moved)
                        (*dtopMouseEvent)(mrp);
                (*dtopMouseButtons)(mrp);
@@ -600,63 +683,6 @@ dtop_keyboard_handler(dev, msg, event, outc)
         * emulate the stateful lk201, since the X11R5 X servers
         * only know about the lk201... (oh well)
         */
         * emulate the stateful lk201, since the X11R5 X servers
         * only know about the lk201... (oh well)
         */
-       if (event != DTOP_EVENT_RECEIVE_PACKET) {
-               switch (event) {
-               case DTOP_EVENT_POLL:
-                   {
-                       register unsigned int   t, t0;
-
-                       /*
-                        * Note we will always have at least the
-                        * end-of-list marker present (a zero)
-                        * Here stop and trigger of autorepeat.
-                        * Do not repeat shift keys, either.
-                        */
-                       {
-                               register unsigned char  uc, i = 0;
-
-rpt_char:
-                               uc = dev->keyboard.last_codes[i];
-
-                               if (uc == DTOP_KBD_EMPTY) {
-                                       dev->keyboard.k_ar_state = K_AR_OFF;
-                                       return 0;
-                               }
-                               if ((uc >= KEY_R_SHIFT) && (uc <= KEY_R_ALT)) {
-                                       /* sometimes swapped. Grrr. */
-                                       if (++i < dev->keyboard.last_codes_count) 
-                                               goto rpt_char;
-                                       dev->keyboard.k_ar_state = K_AR_OFF;
-                                       return 0;
-                               }
-                               c = uc;
-                       }
-
-                       /*
-                        * Got a char. See if enough time from stroke,
-                        * or from last repeat.
-                        */
-                       t0 = (dev->keyboard.k_ar_state == K_AR_TRIGGER) ? 30 : 500;
-                       t = TO_MS(time);
-                       if ((t - dev->keyboard.last_msec) < t0)
-                               return 0;
-
-                       dev->keyboard.k_ar_state = K_AR_TRIGGER;
-
-                       if (dtopDivertXInput) {
-                               (*dtopDivertXInput)(KEY_REPEAT);
-                               return (0);
-                       }
-                       if ((outc = kbdMapChar(KEY_REPEAT)) >= 0)
-                               (*linesw[tp->t_line].l_rint)(outc, tp);
-                       return 0;
-                   }
-               default:
-                       printf("Unknown dtop keyb\n");
-               }
-               return -1;
-       }
-
        msg_len = msg->code.val.len;
 
        /* Check for errors */
        msg_len = msg->code.val.len;
 
        /* Check for errors */
@@ -724,14 +750,10 @@ rpt_char:
        ls = &dev->keyboard.last_codes[dev->keyboard.last_codes_count - 1];
        for ( ; ls >= le; ls--)
            if (c = *ls) {
        ls = &dev->keyboard.last_codes[dev->keyboard.last_codes_count - 1];
        for ( ; ls >= le; ls--)
            if (c = *ls) {
-               /*
-                * If there are no other down/up keys currently down, we
-                * should actually generate a KEY_UP, but that would require
-                * a lot more state.
-                */
                (void) kbdMapChar(c);                   
 
                (void) kbdMapChar(c);                   
 
-               if (outc == 0 && dtopDivertXInput)
+               if (outc == 0 && dtopDivertXInput &&
+                   (keymodes[(c >> 5) & 0x7] & (1 << (c & 0x1f))))
                        (*dtopDivertXInput)(c);
            }
        /*
                        (*dtopDivertXInput)(c);
            }
        /*
@@ -765,7 +787,7 @@ rpt_char:
 }
 
 /*
 }
 
 /*
- * Polled operations: we must do autorepeat by hand. Sigh.
+ * Timeout routine to do autorepeat.
  */
 void
 dtop_keyboard_autorepeat(arg)
  */
 void
 dtop_keyboard_autorepeat(arg)
@@ -776,7 +798,7 @@ dtop_keyboard_autorepeat(arg)
 
        s = spltty();
        if (dev->keyboard.k_ar_state != K_AR_IDLE)
 
        s = spltty();
        if (dev->keyboard.k_ar_state != K_AR_IDLE)
-               (void)dtop_keyboard_handler(dev, 0, DTOP_EVENT_POLL, 0);
+               dtop_keyboard_repeat(dev);
 
        if (dev->keyboard.k_ar_state == K_AR_OFF)
                dev->keyboard.k_ar_state = K_AR_IDLE;
 
        if (dev->keyboard.k_ar_state == K_AR_OFF)
                dev->keyboard.k_ar_state = K_AR_IDLE;
@@ -785,4 +807,43 @@ dtop_keyboard_autorepeat(arg)
 
        splx(s);
 }
 
        splx(s);
 }
+
+/*
+ * See if an autorepeat is required.
+ */
+static void
+dtop_keyboard_repeat(dev)
+       dtop_device_t dev;
+{
+       register int i, c;
+       register u_int t, t0;
+       struct tty *tp = dtop_tty;
+
+       for (i = 0; i < dev->keyboard.last_codes_count; i++) {
+               c = (int)dev->keyboard.last_codes[i];
+               if (c != DTOP_KBD_EMPTY &&
+                   (keymodes[(c >> 5) & 0x7] & (1 << (c & 0x1f))) == 0) {
+                       /*
+                        * Got a char. See if enough time from stroke,
+                        * or from last repeat.
+                        */
+                       t0 = (dev->keyboard.k_ar_state == K_AR_TRIGGER) ? 30 : 500;
+                       t = TO_MS(time);
+                       if ((t - dev->keyboard.last_msec) < t0)
+                               return;
+
+                       dev->keyboard.k_ar_state = K_AR_TRIGGER;
+
+                       if (dtopDivertXInput) {
+                               (*dtopDivertXInput)(KEY_REPEAT);
+                               return;
+                       }
+
+                       if ((c = kbdMapChar(KEY_REPEAT)) >= 0)
+                               (*linesw[tp->t_line].l_rint)(c, tp);
+                       return;
+               }
+       }
+       dev->keyboard.k_ar_state = K_AR_OFF;
+}
 #endif
 #endif
index fd2fbed..3c6edbb 100644 (file)
@@ -7,7 +7,7 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)fb.c        7.1 (Berkeley) %G%
+ *     @(#)fb.c        7.2 (Berkeley) %G%
  */
 
 /* 
  */
 
 /* 
 
 #include <machine/machConst.h>
 #include <machine/pmioctl.h>
 
 #include <machine/machConst.h>
 #include <machine/pmioctl.h>
-#include <machine/dc7085cons.h>
 
 #include <pmax/dev/device.h>
 #include <pmax/dev/font.c>
 
 #include <pmax/dev/device.h>
 #include <pmax/dev/font.c>
-#include <pmax/dev/sccreg.h>
 #include <pmax/dev/fbreg.h>
 
 #include <pmax/stand/dec_prom.h>
 #include <pmax/dev/fbreg.h>
 
 #include <pmax/stand/dec_prom.h>
 #include <pmax/pmax/cons.h>
 #include <pmax/pmax/pmaxtype.h>
 
 #include <pmax/pmax/cons.h>
 #include <pmax/pmax/pmaxtype.h>
 
+#include <dc.h>
+#include <scc.h>
+#include <dtop.h>
+
 void fbKbdEvent(), fbMouseEvent(), fbMouseButtons(), fbScroll();
 void fbBlitc(), fbPutc();
 extern int pmax_boardtype;
 extern struct consdev cn_tab;
 void fbKbdEvent(), fbMouseEvent(), fbMouseButtons(), fbScroll();
 void fbBlitc(), fbPutc();
 extern int pmax_boardtype;
 extern struct consdev cn_tab;
-#include "dc.h"
 #if NDC > 0
 #if NDC > 0
+#include <machine/dc7085cons.h>
 extern int dcGetc(), dcparam();
 extern void dcPutc();
 #endif
 extern int dcGetc(), dcparam();
 extern void dcPutc();
 #endif
-#include "scc.h"
+#if NDTOP > 0
+#include <pmax/dev/dtopreg.h>
+extern void dtopKBDPutc();
+#endif
 #if NSCC > 0
 #if NSCC > 0
+#include <pmax/dev/sccreg.h>
 extern int sccGetc(), sccparam();
 extern void sccPutc();
 #endif
 extern int sccGetc(), sccparam();
 extern void sccPutc();
 #endif
@@ -571,8 +577,8 @@ fbMouseButtons(newRepPtr, fp)
                eventPtr->time = TO_MS(time);
                eventPtr->x = fp->fbu->scrInfo.mouse.x;
                eventPtr->y = fp->fbu->scrInfo.mouse.y;
                eventPtr->time = TO_MS(time);
                eventPtr->x = fp->fbu->scrInfo.mouse.x;
                eventPtr->y = fp->fbu->scrInfo.mouse.y;
+               fp->fbu->scrInfo.qe.eTail = i;
        }
        }
-       fp->fbu->scrInfo.qe.eTail = i;
        selwakeup(&fp->selp);
 
        lastRep = *newRepPtr;
        selwakeup(&fp->selp);
 
        lastRep = *newRepPtr;
@@ -1001,3 +1007,38 @@ KBDGetc()
        }
        return (c);
 }
        }
        return (c);
 }
+
+/*
+ * Configure the keyboard/mouse based on machine type for turbochannel
+ * display boards.
+ */
+tb_kbdmouseconfig(fp)
+       struct pmax_fb *fp;
+{
+
+       switch (pmax_boardtype) {
+#if NDC > 0
+       case DS_3MAX:
+               fp->KBDPutc = dcPutc;
+               fp->kbddev = makedev(DCDEV, DCKBD_PORT);
+               break;
+#endif
+#if NSCC > 0
+       case DS_3MIN:
+       case DS_3MAXPLUS:
+               fp->KBDPutc = sccPutc;
+               fp->kbddev = makedev(SCCDEV, SCCKBD_PORT);
+               break;
+#endif
+#if NDTOP > 0
+       case DS_MAXINE:
+               fp->KBDPutc = dtopKBDPutc;
+               fp->kbddev = makedev(DTOPDEV, DTOPKBD_PORT);
+               break;
+#endif
+       default:
+               printf("Can't configure keyboard/mouse\n");
+               return (1);
+       };
+       return (0);
+}
index 629184d..f15cbf8 100644 (file)
@@ -7,7 +7,7 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)if_le.c     7.8 (Berkeley) %G%
+ *     @(#)if_le.c     7.9 (Berkeley) %G%
  */
 
 #include <le.h>
  */
 
 #include <le.h>
@@ -135,6 +135,7 @@ void copytobuf_gap16(), copyfrombuf_gap16(), bzerobuf_gap16();
 
 extern int pmax_boardtype;
 extern u_long le_iomem;
 
 extern int pmax_boardtype;
 extern u_long le_iomem;
+extern u_long asic_base;
 
 /*
  * Test to see if device is present.
 
 /*
  * Test to see if device is present.
@@ -165,15 +166,15 @@ leprobe(dp)
                break;
        case DS_3MIN:
        case DS_MAXINE:
                break;
        case DS_3MIN:
        case DS_MAXINE:
+       case DS_3MAXPLUS:
                if (dp->pmax_unit == 0) {
                        volatile u_int *ssr, *ldp;
 
                        le->sc_r1 = ler1 = (volatile struct lereg1 *)
                if (dp->pmax_unit == 0) {
                        volatile u_int *ssr, *ldp;
 
                        le->sc_r1 = ler1 = (volatile struct lereg1 *)
-                               MACH_PHYS_TO_UNCACHED(KMIN_SYS_LANCE);
+                               ASIC_SYS_LANCE(asic_base);
+                       cp = (u_char *)ASIC_SYS_ETHER_ADDRESS(asic_base);
                        le->sc_r2 = (volatile void *)
                                MACH_PHYS_TO_UNCACHED(le_iomem);
                        le->sc_r2 = (volatile void *)
                                MACH_PHYS_TO_UNCACHED(le_iomem);
-                       cp = (u_char *)MACH_PHYS_TO_UNCACHED(
-                               KMIN_SYS_ETHER_ADDRESS);
                        le->sc_ler2pad = 1;
                        le->sc_copytobuf = copytobuf_gap16;
                        le->sc_copyfrombuf = copyfrombuf_gap16;
                        le->sc_ler2pad = 1;
                        le->sc_copytobuf = copytobuf_gap16;
                        le->sc_copyfrombuf = copyfrombuf_gap16;
@@ -182,10 +183,9 @@ leprobe(dp)
                        /*
                         * And enable Lance dma through the asic.
                         */
                        /*
                         * And enable Lance dma through the asic.
                         */
-                       ssr = (volatile u_int *)
-                               MACH_PHYS_TO_UNCACHED(KMIN_REG_CSR);
+                       ssr = (volatile u_int *)ASIC_REG_CSR(asic_base);
                        ldp = (volatile u_int *)
                        ldp = (volatile u_int *)
-                               MACH_PHYS_TO_UNCACHED(KMIN_REG_LANCE_DMAPTR);
+                               ASIC_REG_LANCE_DMAPTR(asic_base);
                        *ldp = (le_iomem << 3); /* phys addr << 3 */
                        *ssr |= ASIC_CSR_DMAEN_LANCE;
                        break;
                        *ldp = (le_iomem << 3); /* phys addr << 3 */
                        *ssr |= ASIC_CSR_DMAEN_LANCE;
                        break;
index 8c8e145..1398753 100644 (file)
@@ -7,7 +7,7 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)mfb.c       7.1 (Berkeley) %G%
+ *     @(#)mfb.c       7.2 (Berkeley) %G%
  */
 
 /* 
  */
 
 /* 
@@ -105,22 +105,16 @@ static u_char bt431_read_reg();
 extern void fbKbdEvent(), fbMouseEvent(), fbMouseButtons();
 void mfbKbdEvent(), mfbMouseEvent(), mfbMouseButtons();
 #if NDC > 0
 extern void fbKbdEvent(), fbMouseEvent(), fbMouseButtons();
 void mfbKbdEvent(), mfbMouseEvent(), mfbMouseButtons();
 #if NDC > 0
-#include <machine/dc7085cons.h>
-extern void dcPutc();
 extern void (*dcDivertXInput)();
 extern void (*dcMouseEvent)();
 extern void (*dcMouseButtons)();
 #endif
 #if NSCC > 0
 extern void (*dcDivertXInput)();
 extern void (*dcMouseEvent)();
 extern void (*dcMouseButtons)();
 #endif
 #if NSCC > 0
-#include <pmax/dev/sccreg.h>
-extern void sccPutc();
 extern void (*sccDivertXInput)();
 extern void (*sccMouseEvent)();
 extern void (*sccMouseButtons)();
 #endif
 #if NDTOP > 0
 extern void (*sccDivertXInput)();
 extern void (*sccMouseEvent)();
 extern void (*sccMouseButtons)();
 #endif
 #if NDTOP > 0
-#include <pmax/dev/dtopreg.h>
-extern void dtopKBDPutc();
 extern void (*dtopDivertXInput)();
 extern void (*dtopMouseEvent)();
 extern void (*dtopMouseButtons)();
 extern void (*dtopDivertXInput)();
 extern void (*dtopMouseEvent)();
 extern void (*dtopMouseButtons)();
@@ -370,8 +364,14 @@ mfbLoadCursor(cursor)
                while (j < 2) {
                        out = 0;
                        for (i = 0; i < 8; i++) {
                while (j < 2) {
                        out = 0;
                        for (i = 0; i < 8; i++) {
+#ifdef CURSOR_EL
                                out = (out << 1) | ((ap & 0x1) << 8) |
                                        (bp & 0x1);
                                out = (out << 1) | ((ap & 0x1) << 8) |
                                        (bp & 0x1);
+#else
+                               out = ((out >> 1) & 0x7f7f) |
+                                       ((ap & 0x1) << 15) |
+                                       ((bp & 0x1) << 7);
+#endif
                                ap >>= 1;
                                bp >>= 1;
                        }
                                ap >>= 1;
                                bp >>= 1;
                        }
@@ -407,31 +407,16 @@ mfbinit(cp)
 
        fp->isMono = 1;
        fp->fr_addr = (char *)cp;
 
        fp->isMono = 1;
        fp->fr_addr = (char *)cp;
-       fp->fbu = &mfbu;
+       /*
+        * Must be in Uncached space or the Xserver sees a stale version of
+        * the event queue and acts totally wacko. I don't understand this,
+        * since the R3000 uses a physical address cache?
+        */
+       fp->fbu = (struct fbuaccess *)
+               MACH_PHYS_TO_UNCACHED(MACH_CACHED_TO_PHYS(&mfbu));
        fp->posCursor = mfbPosCursor;
        fp->posCursor = mfbPosCursor;
-       switch (pmax_boardtype) {
-#if NDC > 0
-       case DS_3MAX:
-               fp->KBDPutc = dcPutc;
-               fp->kbddev = makedev(DCDEV, DCKBD_PORT);
-               break;
-#endif
-#if NSCC > 0
-       case DS_3MIN:
-               fp->KBDPutc = sccPutc;
-               fp->kbddev = makedev(SCCDEV, SCCKBD_PORT);
-               break;
-#endif
-#if NDTOP > 0
-       case DS_MAXINE:
-               fp->KBDPutc = dtopKBDPutc;
-               fp->kbddev = makedev(DTOPDEV, DTOPKBD_PORT);
-               break;
-#endif
-       default:
-               printf("Can't configure keyboard/mouse\n");
+       if (tb_kbdmouseconfig(fp))
                return (0);
                return (0);
-       };
 
        /*
         * Initialize the screen.
 
        /*
         * Initialize the screen.
index cbbfe2b..04ee10f 100644 (file)
@@ -7,7 +7,7 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)scc.c       7.1 (Berkeley) %G%
+ *     @(#)scc.c       7.2 (Berkeley) %G%
  */
 
 /* 
  */
 
 /* 
@@ -151,12 +151,19 @@ sccprobe(cp)
        struct termios cterm;
        int s;
 
        struct termios cterm;
        int s;
 
-printf("scc probe addr=0x%x\n",cp->pmax_addr);
        if (cp->pmax_unit >= NSCC)
                return (0);
        if (badaddr(cp->pmax_addr, 2))
                return (0);
 
        if (cp->pmax_unit >= NSCC)
                return (0);
        if (badaddr(cp->pmax_addr, 2))
                return (0);
 
+       /*
+        * For a remote console, wait a while for previous output to
+        * complete.
+        */
+       if (major(cn_tab.cn_dev) == SCCDEV && cn_tab.cn_screen == 0 &&
+               SCCUNIT(cn_tab.cn_dev) == cp->pmax_unit)
+               DELAY(10000);
+
        sc = &scc_softc[cp->pmax_unit];
        pdp = &sc->scc_pdma[0];
 
        sc = &scc_softc[cp->pmax_unit];
        pdp = &sc->scc_pdma[0];
 
@@ -168,7 +175,6 @@ printf("scc probe addr=0x%x\n",cp->pmax_addr);
                pdp->p_fcn = (void (*)())0;
                tp->t_addr = (caddr_t)pdp;
                tp->t_dev = (dev_t)((cp->pmax_unit << 1) | cntr);
                pdp->p_fcn = (void (*)())0;
                tp->t_addr = (caddr_t)pdp;
                tp->t_dev = (dev_t)((cp->pmax_unit << 1) | cntr);
-printf("for dev=0x%x\n",tp->t_dev);
                pdp++, tp++;
        }
        sc->scc_softCAR = cp->pmax_flags | 0x2;
                pdp++, tp++;
        }
        sc->scc_softCAR = cp->pmax_flags | 0x2;
@@ -176,9 +182,6 @@ printf("for dev=0x%x\n",tp->t_dev);
        /* reset chip */
        sccreset(sc);
 
        /* reset chip */
        sccreset(sc);
 
-       printf("scc%d at nexus0 csr 0x%x priority %d\n",
-               cp->pmax_unit, cp->pmax_addr, cp->pmax_pri);
-
        /*
         * Special handling for consoles.
         */
        /*
         * Special handling for consoles.
         */
@@ -190,6 +193,7 @@ printf("for dev=0x%x\n",tp->t_dev);
                                cterm.c_cflag = CS8;
                                cterm.c_ospeed = cterm.c_ispeed = 4800;
                                (void) sccparam(&ctty, &cterm);
                                cterm.c_cflag = CS8;
                                cterm.c_ospeed = cterm.c_ispeed = 4800;
                                (void) sccparam(&ctty, &cterm);
+                               DELAY(1000);
                                KBDReset(ctty.t_dev, sccPutc);
                                splx(s);
                        } else if (cp->pmax_unit == 1) {
                                KBDReset(ctty.t_dev, sccPutc);
                                splx(s);
                        } else if (cp->pmax_unit == 1) {
@@ -198,6 +202,7 @@ printf("for dev=0x%x\n",tp->t_dev);
                                cterm.c_cflag = CS8 | PARENB | PARODD;
                                cterm.c_ospeed = cterm.c_ispeed = 4800;
                                (void) sccparam(&ctty, &cterm);
                                cterm.c_cflag = CS8 | PARENB | PARODD;
                                cterm.c_ospeed = cterm.c_ispeed = 4800;
                                (void) sccparam(&ctty, &cterm);
+                               DELAY(1000);
                                MouseInit(ctty.t_dev, sccPutc, sccGetc);
                                splx(s);
                        }
                                MouseInit(ctty.t_dev, sccPutc, sccGetc);
                                splx(s);
                        }
@@ -208,9 +213,12 @@ printf("for dev=0x%x\n",tp->t_dev);
                cterm.c_cflag = CS8;
                cterm.c_ospeed = cterm.c_ispeed = 9600;
                (void) sccparam(&ctty, &cterm);
                cterm.c_cflag = CS8;
                cterm.c_ospeed = cterm.c_ispeed = 9600;
                (void) sccparam(&ctty, &cterm);
+               DELAY(1000);
                cn_tab.cn_disabled = 0;
                splx(s);
        }
                cn_tab.cn_disabled = 0;
                splx(s);
        }
+       printf("scc%d at nexus0 csr 0x%x priority %d\n",
+               cp->pmax_unit, cp->pmax_addr, cp->pmax_pri);
        return (1);
 }
 
        return (1);
 }
 
@@ -271,7 +279,7 @@ sccreset(sc)
 
        /* interrupt conditions */
        val =   SCC_WR1_RXI_ALL_CHAR | SCC_WR1_PARITY_IE |
 
        /* interrupt conditions */
        val =   SCC_WR1_RXI_ALL_CHAR | SCC_WR1_PARITY_IE |
-               SCC_WR1_EXT_IE | SCC_WR1_TX_IE;         
+               SCC_WR1_EXT_IE;
        sc->scc_wreg[SCC_CHANNEL_A].wr1 = val;
        sc->scc_wreg[SCC_CHANNEL_B].wr1 = val;
 }
        sc->scc_wreg[SCC_CHANNEL_A].wr1 = val;
        sc->scc_wreg[SCC_CHANNEL_B].wr1 = val;
 }
@@ -287,12 +295,10 @@ sccopen(dev, flag, mode, p)
        int s, error = 0;
 
        unit = SCCUNIT(dev);
        int s, error = 0;
 
        unit = SCCUNIT(dev);
-printf("sccopen\n");
        if (unit >= NSCC)
                return (ENXIO);
        line = SCCLINE(dev);
        sc = &scc_softc[unit];
        if (unit >= NSCC)
                return (ENXIO);
        line = SCCLINE(dev);
        sc = &scc_softc[unit];
-printf("paddr=0x%x\n",sc->scc_pdma[line].p_addr);
        if (sc->scc_pdma[line].p_addr == (void *)0)
                return (ENXIO);
        tp = &scc_tty[minor(dev)];
        if (sc->scc_pdma[line].p_addr == (void *)0)
                return (ENXIO);
        tp = &scc_tty[minor(dev)];
@@ -300,7 +306,6 @@ printf("paddr=0x%x\n",sc->scc_pdma[line].p_addr);
        tp->t_oproc = sccstart;
        tp->t_param = sccparam;
        tp->t_dev = dev;
        tp->t_oproc = sccstart;
        tp->t_param = sccparam;
        tp->t_dev = dev;
-printf("openinscc\n");
        if ((tp->t_state & TS_ISOPEN) == 0) {
                tp->t_state |= TS_WOPEN;
                ttychars(tp);
        if ((tp->t_state & TS_ISOPEN) == 0) {
                tp->t_state |= TS_WOPEN;
                ttychars(tp);
@@ -623,9 +628,25 @@ sccintr(unit)
                                MachEmptyWriteBuffer();
                        }
                }
                                MachEmptyWriteBuffer();
                        }
                }
-           } else if (rr2 == SCC_RR2_A_RECV_DONE) {
-               tp = &scc_tty[unit | SCC_CHANNEL_A];
-               SCC_READ_DATA(regs, SCC_CHANNEL_A, cc);
+           } else if (rr2 == SCC_RR2_A_RECV_DONE ||
+               rr2 == SCC_RR2_B_RECV_DONE || rr2 == SCC_RR2_A_RECV_SPECIAL ||
+               rr2 == SCC_RR2_B_RECV_SPECIAL) {
+               if (rr2 == SCC_RR2_A_RECV_DONE || rr2 == SCC_RR2_A_RECV_SPECIAL)
+                       chan = SCC_CHANNEL_A;
+               else
+                       chan = SCC_CHANNEL_B;
+               tp = &scc_tty[unit | chan];
+               SCC_READ_DATA(regs, chan, cc);
+               if (rr2 == SCC_RR2_A_RECV_SPECIAL ||
+                       rr2 == SCC_RR2_B_RECV_SPECIAL) {
+                       SCC_READ_REG(regs, chan, SCC_RR1, rr1);
+                       SCC_WRITE_REG(regs, chan, SCC_RR0, SCC_RESET_ERROR);
+                       if ((rr1 & SCC_RR1_RX_OVERRUN) && overrun == 0) {
+                               log(LOG_WARNING, "scc%d,%d: silo overflow\n",
+                                       unit >> 1, chan);
+                               overrun = 1;
+                       }
+               }
 
                /*
                 * Keyboard needs special treatment.
 
                /*
                 * Keyboard needs special treatment.
@@ -692,16 +713,12 @@ sccintr(unit)
 #endif
                                continue;
                }
 #endif
                                continue;
                }
-               (*linesw[tp->t_line].l_rint)(cc, tp);
-           } else if (rr2 == SCC_RR2_B_RECV_DONE) {
-               tp = &scc_tty[unit | SCC_CHANNEL_B];
-               SCC_READ_DATA(regs, SCC_CHANNEL_B, cc);
-               if (!(tp->t_state & TS_ISOPEN)) {
-                       wakeup((caddr_t)&tp->t_rawq);
-#ifdef PORTSELECTOR
-                       if (!(tp->t_state & TS_WOPEN))
-#endif
-                               continue;
+               if (rr2 == SCC_RR2_A_RECV_SPECIAL ||
+                       rr2 == SCC_RR2_B_RECV_SPECIAL) {
+                       if (rr1 & SCC_RR1_PARITY_ERR)
+                               cc |= TTY_PE;
+                       if (rr1 & SCC_RR1_FRAME_ERR)
+                               cc |= TTY_FE;
                }
                (*linesw[tp->t_line].l_rint)(cc, tp);
            } else if ((rr2 == SCC_RR2_A_EXT_STATUS) || (rr2 == SCC_RR2_B_EXT_STATUS)) {
                }
                (*linesw[tp->t_line].l_rint)(cc, tp);
            } else if ((rr2 == SCC_RR2_A_EXT_STATUS) || (rr2 == SCC_RR2_B_EXT_STATUS)) {
@@ -709,24 +726,6 @@ sccintr(unit)
                        SCC_CHANNEL_A : SCC_CHANNEL_B;
                SCC_WRITE_REG(regs, chan, SCC_RR0, SCC_RESET_EXT_IP);
                scc_modem_intr(unit | chan);
                        SCC_CHANNEL_A : SCC_CHANNEL_B;
                SCC_WRITE_REG(regs, chan, SCC_RR0, SCC_RESET_EXT_IP);
                scc_modem_intr(unit | chan);
-           } else if ((rr2 == SCC_RR2_A_RECV_SPECIAL) || (rr2 == SCC_RR2_B_RECV_SPECIAL)) {
-               chan = (rr2 == SCC_RR2_A_RECV_SPECIAL) ?
-                       SCC_CHANNEL_A : SCC_CHANNEL_B;
-               tp = &scc_tty[unit | chan];
-               SCC_READ_REG(regs, chan, SCC_RR1, rr1);
-               SCC_WRITE_REG(regs, chan, SCC_RR0, SCC_RESET_ERROR);
-               if ((rr1 & SCC_RR1_RX_OVERRUN) && overrun == 0) {
-                       log(LOG_WARNING, "scc%d,%d: silo overflow\n", unit >> 1,
-                               chan);
-                       overrun = 1;
-                       continue;
-               }
-               cc = 0;
-               if (rr1 & SCC_RR1_PARITY_ERR)
-                       cc |= TTY_PE;
-               if (rr1 & SCC_RR1_FRAME_ERR)
-                       cc |= TTY_FE;
-               (*linesw[tp->t_line].l_rint)(cc, tp);
            }
        }
 }
            }
        }
 }
@@ -740,7 +739,7 @@ sccstart(tp)
        register struct scc_softc *sc;
        register int cc, chan;
        u_char temp;
        register struct scc_softc *sc;
        register int cc, chan;
        u_char temp;
-       int s;
+       int s, sendone;
 
        dp = (struct pdma *)tp->t_addr;
        regs = (scc_regmap_t *)dp->p_addr;
 
        dp = (struct pdma *)tp->t_addr;
        regs = (scc_regmap_t *)dp->p_addr;
@@ -795,14 +794,15 @@ sccstart(tp)
         * Enable transmission and send the first char, as required.
         */
        chan = SCCLINE(tp->t_dev);
         * Enable transmission and send the first char, as required.
         */
        chan = SCCLINE(tp->t_dev);
+       SCC_READ_REG(regs, chan, SCC_RR0, temp);
+       sendone = (temp & SCC_RR0_TX_EMPTY);
        SCC_READ_REG(regs, chan, SCC_RR15, temp);
        temp |= SCC_WR15_TX_UNDERRUN_IE;
        SCC_WRITE_REG(regs, chan, SCC_WR15, temp);
        temp = sc->scc_wreg[chan].wr1 | SCC_WR1_TX_IE;
        SCC_WRITE_REG(regs, chan, SCC_WR1, temp);
        sc->scc_wreg[chan].wr1 = temp;
        SCC_READ_REG(regs, chan, SCC_RR15, temp);
        temp |= SCC_WR15_TX_UNDERRUN_IE;
        SCC_WRITE_REG(regs, chan, SCC_WR15, temp);
        temp = sc->scc_wreg[chan].wr1 | SCC_WR1_TX_IE;
        SCC_WRITE_REG(regs, chan, SCC_WR1, temp);
        sc->scc_wreg[chan].wr1 = temp;
-       SCC_READ_REG(regs, chan, SCC_RR0, temp);
-       if (temp & SCC_RR0_TX_EMPTY) {
+       if (sendone) {
 #ifdef DIAGNOSTIC
                if (cc == 0)
                        panic("sccstart: No chars");
 #ifdef DIAGNOSTIC
                if (cc == 0)
                        panic("sccstart: No chars");
@@ -977,24 +977,29 @@ sccPutc(dev, c)
        int c;
 {
        register scc_regmap_t *regs;
        int c;
 {
        register scc_regmap_t *regs;
-       register int timeout, line;
+       register int line;
        register u_char value;
        int s;
 
        s = spltty();
        line = SCCLINE(dev);
        regs = (scc_regmap_t *)scc_softc[SCCUNIT(dev)].scc_pdma[line].p_addr;
        register u_char value;
        int s;
 
        s = spltty();
        line = SCCLINE(dev);
        regs = (scc_regmap_t *)scc_softc[SCCUNIT(dev)].scc_pdma[line].p_addr;
+
        /*
         * Wait for transmitter to be not busy.
         */
        /*
         * Wait for transmitter to be not busy.
         */
-       timeout = 1000000;
        do {
                SCC_READ_REG(regs, line, SCC_RR0, value);
        do {
                SCC_READ_REG(regs, line, SCC_RR0, value);
-       } while ((value & SCC_RR0_TX_EMPTY) == 0 && --timeout > 0);
-       if (timeout == 0)
-               printf("sccPutc: timeout waiting for TRDY\n");
-       else
-               SCC_WRITE_DATA(regs, line, c);
+               if (value & SCC_RR0_TX_EMPTY)
+                       break;
+               DELAY(100);
+       } while (1);
+
+       /*
+        * Send the char.
+        */
+       SCC_WRITE_DATA(regs, line, c);
+       MachEmptyWriteBuffer();
        splx(s);
 }
 #endif /* NSCC */
        splx(s);
 }
 #endif /* NSCC */
index 0ef5b8d..5ec2027 100644 (file)
@@ -7,7 +7,7 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)sccreg.h    7.1 (Berkeley) %G%
+ *     @(#)sccreg.h    7.2 (Berkeley) %G%
  */
 
 /* 
  */
 
 /* 
@@ -348,6 +348,6 @@ typedef struct {
  * B channels for the comm port(s).
  */
 #define        SCCCOMM2_PORT   0x0
  * B channels for the comm port(s).
  */
 #define        SCCCOMM2_PORT   0x0
-#define        SCCKBD_PORT     0x1
+#define        SCCMOUSE_PORT   0x1
 #define        SCCCOMM3_PORT   0x2
 #define        SCCCOMM3_PORT   0x2
-#define        SCCMOUSE_PORT   0x3
+#define        SCCKBD_PORT     0x3
index ed5a05e..0f58f24 100644 (file)
@@ -7,7 +7,7 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)xcfb.c      7.1 (Berkeley) %G%
+ *     @(#)xcfb.c      7.2 (Berkeley) %G%
  */
 
 /* 
  */
 
 /* 
@@ -250,7 +250,6 @@ xcfbioctl(dev, cmd, data, flag)
                break;
 
        case QIOCKPCMD:
                break;
 
        case QIOCKPCMD:
-#ifdef notyet
            {
                pmKpCmd *kpCmdPtr;
                unsigned char *cp;
            {
                pmKpCmd *kpCmdPtr;
                unsigned char *cp;
@@ -268,7 +267,6 @@ xcfbioctl(dev, cmd, data, flag)
                        (*fp->KBDPutc)(fp->kbddev, (int)*cp);
                }
            }
                        (*fp->KBDPutc)(fp->kbddev, (int)*cp);
                }
            }
-#endif /* notyet */
            break;
 
        case QIOCADDR:
            break;
 
        case QIOCADDR:
@@ -481,7 +479,14 @@ void
 xcfbPosCursor(x, y)
        register int x, y;
 {
 xcfbPosCursor(x, y)
        register int x, y;
 {
+       register struct pmax_fb *fp = &xcfbfb;
 
 
+       if (y < fp->fbu->scrInfo.min_cur_y || y > fp->fbu->scrInfo.max_cur_y)
+               y = fp->fbu->scrInfo.max_cur_y;
+       if (x < fp->fbu->scrInfo.min_cur_x || x > fp->fbu->scrInfo.max_cur_x)
+               x = fp->fbu->scrInfo.max_cur_x;
+       fp->fbu->scrInfo.cursor.x = x;          /* keep track of real cursor */
+       fp->fbu->scrInfo.cursor.y = y;          /* position, indep. of mouse */
        ims332_write_register(IMS332_REG_CURSOR_LOC,
                ((x & 0xfff) << 12) | (y & 0xfff));
 }
        ims332_write_register(IMS332_REG_CURSOR_LOC,
                ((x & 0xfff) << 12) | (y & 0xfff));
 }
@@ -553,8 +558,9 @@ xcfbLoadCursor(cursor)
                while (j < 2) {
                        out = 0;
                        for (i = 0; i < 8; i++) {
                while (j < 2) {
                        out = 0;
                        for (i = 0; i < 8; i++) {
-                               out = (out << 2) | ((ap & 0x1) << 1) |
-                                       (bp & 0x1);
+                               out = ((out >> 2) & 0x3fff) |
+                                       ((ap & 0x1) << 15) |
+                                       ((bp & 0x1) << 14);
                                ap >>= 1;
                                bp >>= 1;
                        }
                                ap >>= 1;
                                bp >>= 1;
                        }
@@ -577,7 +583,6 @@ xcfbLoadCursor(cursor)
 
 /*
  * Initialization
 
 /*
  * Initialization
- * (For some reason, X runs faster with the frame buffer cached?)
  */
 int
 xcfbinit()
  */
 int
 xcfbinit()
@@ -586,9 +591,22 @@ xcfbinit()
        register struct pmax_fb *fp = &xcfbfb;
 
        fp->isMono = 0;
        register struct pmax_fb *fp = &xcfbfb;
 
        fp->isMono = 0;
+
+       /*
+        * Or Cached? A comment in the Mach driver suggests that the X server
+        * runs faster in cached address space, but the X server is going
+        * to blow away the data cache whenever it updates the screen, so..
+        */
        fp->fr_addr = (char *)
        fp->fr_addr = (char *)
-               MACH_PHYS_TO_CACHED(XINE_PHYS_CFB_START + VRAM_OFFSET);
-       fp->fbu = &xcfbu;
+               MACH_PHYS_TO_UNCACHED(XINE_PHYS_CFB_START + VRAM_OFFSET);
+
+       /*
+        * Must be in Uncached space or the Xserver sees a stale version of
+        * the event queue and acts totally wacko. I don't understand this,
+        * since the R3000 uses a physical address cache?
+        */
+       fp->fbu = (struct fbuaccess *)
+               MACH_PHYS_TO_UNCACHED(MACH_CACHED_TO_PHYS(&xcfbu));
        fp->posCursor = xcfbPosCursor;
        fp->KBDPutc = dtopKBDPutc;
        fp->kbddev = makedev(DTOPDEV, DTOPKBD_PORT);
        fp->posCursor = xcfbPosCursor;
        fp->KBDPutc = dtopKBDPutc;
        fp->kbddev = makedev(DTOPDEV, DTOPKBD_PORT);
@@ -636,8 +654,8 @@ xcfbinit()
        fp->fbu->scrInfo.max_col = 80;
        fp->fbu->scrInfo.max_x = 1024;
        fp->fbu->scrInfo.max_y = 768;
        fp->fbu->scrInfo.max_col = 80;
        fp->fbu->scrInfo.max_x = 1024;
        fp->fbu->scrInfo.max_y = 768;
-       fp->fbu->scrInfo.max_cur_x = 1023;
-       fp->fbu->scrInfo.max_cur_y = 767;
+       fp->fbu->scrInfo.max_cur_x = 1008;
+       fp->fbu->scrInfo.max_cur_y = 752;
        fp->fbu->scrInfo.version = 11;
        fp->fbu->scrInfo.mthreshold = 4;        
        fp->fbu->scrInfo.mscale = 2;
        fp->fbu->scrInfo.version = 11;
        fp->fbu->scrInfo.mthreshold = 4;        
        fp->fbu->scrInfo.mscale = 2;