Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/pmax/dev Many fixes to support PXG, PXG+ and PXG+ T...



details:   https://anonhg.NetBSD.org/src/rev/385f6d703755
branches:  trunk
changeset: 472257:385f6d703755
user:      ad <ad%NetBSD.org@localhost>
date:      Mon Apr 26 04:37:33 1999 +0000

description:
Many fixes to support PXG, PXG+ and PXG+ Turbo. Interrupt handling is
totally broken for the PXG and will remain so until more documentation is
available. This destroys the queueing, hardware clipping, and VDAC update
mechanisms on the PXG.

diffstat:

 sys/arch/pmax/dev/px.c    |  273 ++++++++++++++++++++++++++++++---------------
 sys/arch/pmax/dev/pxreg.h |   25 ++--
 sys/arch/pmax/dev/pxvar.h |    3 +-
 3 files changed, 197 insertions(+), 104 deletions(-)

diffs (truncated from 647 to 300 lines):

diff -r 6c912c5acfa2 -r 385f6d703755 sys/arch/pmax/dev/px.c
--- a/sys/arch/pmax/dev/px.c    Mon Apr 26 04:34:00 1999 +0000
+++ b/sys/arch/pmax/dev/px.c    Mon Apr 26 04:37:33 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: px.c,v 1.4 1999/04/25 04:04:16 simonb Exp $ */
+/*     $NetBSD: px.c,v 1.5 1999/04/26 04:37:33 ad Exp $ */
 
 /*
  * Copyright (c) 1997 Jonathan Stone <jonathan%NetBSD.org@localhost>
@@ -37,7 +37,7 @@
 #endif
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: px.c,v 1.4 1999/04/25 04:04:16 simonb Exp $");
+__KERNEL_RCSID(0, "$NetBSD: px.c,v 1.5 1999/04/26 04:37:33 ad Exp $");
 
 /*
  * px.c: driver for the DEC TURBOchannel 2D and 3D accelerated framebuffers
@@ -88,19 +88,16 @@
        struct  px_info *px_info;
 };
 
-/* Called externally */
 int    px_match __P((struct device *, struct cfdata *, void *));
 void   px_attach __P((struct device *, struct device *, void *));
 int    px_intr __P((void *xxx_sc));
 
-/* Our cdev interface */
 int    pxopen __P((dev_t, int, int, struct proc *));
 int    pxclose __P((dev_t, int, int, struct proc *));
 int    pxioctl __P((dev_t, u_long, caddr_t, int, struct proc *));
 int    pxpoll __P((dev_t, int, struct proc *));
 int    pxmmap __P((dev_t, int, int));
 
-/* Stuff that we use internally */
 static int32_t *px_alloc_pbuf __P((struct px_info *));
 static int     px_send_packet __P((struct px_info *, int *buf));
 static void    px_init_stic __P((struct px_info *, int));
@@ -115,6 +112,7 @@
 static void    px_qvss_init __P((struct px_info *));
 static int     px_mmap_info  __P((struct proc *, dev_t, vm_offset_t *));
 static void    px_cursor_hack __P((struct fbinfo *, int, int));
+static int     px_probe_sram __P((struct px_info *));
 
 struct cfattach px_ca = {
        sizeof(struct px_softc),
@@ -125,9 +123,7 @@
 /* The different types of card that we support, for px_match(). */
 static const char *px_types[] = {
        "PMAG-CA ",
-       "PMAG-DA ", /* XXX should this be PMAGB-DA? */
-       "PMAG-E  ", /* XXX should this be PMAGB-EA? */
-       "PMAG-EA ",
+       "PMAG-DA ",
        "PMAG-F  ", /* XXX always -FA? */
        "PMAG-FA ",
 };
@@ -156,9 +152,6 @@
 };
 
 /* Colormap for wscons, matching WSCOL_*. Upper 8 are high-intensity */
-#define FGCOLOR(a)     ((a) & 255)
-#define BGCOLOR(a)     (((a) >> 8) & 255)
-
 static const u_char px_cmap[16*3] = {
        0x00, 0x00, 0x00, /* black */
        0x7f, 0x00, 0x00, /* red */
@@ -241,22 +234,22 @@
 };
 
 #define        BT459_SELECT(vdac, regno) do {          \
-       (vdac)->lo = (regno) & 0x00ff;          \
-       (vdac)->hi = ((regno) & 0x0f00) >> 8;   \
+       (vdac)->lo = DUPBYTE0(regno);           \
+       (vdac)->hi = DUPBYTE1(regno);           \
        tc_wmb();                               \
    } while(0);
 
 #define        BT459_WRITE_REG(vdac, data) \
-       (vdac)->reg = (data) & 0xffffff, tc_wmb();
+       ((vdac)->reg = (data)), tc_wmb();
 
 #define        BT459_WRITE_CMAP(vdac, data) \
-       (vdac)->cmap = (data) & 0xffffff, tc_wmb();
+       ((vdac)->cmap = (data)), tc_wmb();
 
 #define BT459_READ_REG(vdac)   ((vdac)->reg)
 
 /* We have to support 3 VDACs on the 24-bit cards */
 #define DUPBYTE0(x) ((((x)&0xff)<<16) | (((x)&0xff)<<8) | ((x)&0xff))
-#define DUPBYTE1(x) ((((x)<<8)&0xff00) | ((x)&0xff00) | (((x)>>8)&0xff))
+#define DUPBYTE1(x) ((((x)<<8)&0xff0000) | ((x)&0xff00) | (((x)>>8)&0xff))
 #define DUPBYTE2(x) (((x)&0xff0000) | (((x)>>8)&0xff00) | (((x)>>16)&0xff))
 
 #define PACK_WORD(p, o) ((p)[(o)] | ((p)[(o)+1] << 16))
@@ -301,7 +294,7 @@
        slotbase = (caddr_t)TC_PHYS_TO_UNCACHED(ta->ta_addr);
 
        /* Init the card only if it hasn't been done before... */
-       if (px_cons_info && slotbase != (caddr_t)px_cons_info->pxi_slotbase)
+       if (!px_cons_info || slotbase != (caddr_t)px_cons_info->pxi_slotbase)
                px_init((struct fbinfo *)1, slotbase, sc->px_dv.dv_unit, 1);
 
        /* px_init() fills in px_unit[#] */
@@ -318,14 +311,16 @@
 
        /* Set ISR driven packet-buffer polling addresses */
        for (i = 0; i < 16; i++) {
-               caddr_t addr = (caddr_t)pxi->pxi_rbuf + i * 4096;
+               caddr_t addr = (caddr_t)pxi->pxi_rbuf + (i << 12);
                pxi->pxi_qpoll[i] = px_poll_addr(slotbase, addr);
        }
 
        /* The following values are filled in by px_init_stic. */
-       printf(": %s Rev. %d, %dx%d stamp, %d plane\n", pxi->pxi_type,
-           pxi->pxi_revision, pxi->pxi_stampw, pxi->pxi_stamph,
-           pxi->pxi_nplanes);
+       printf(": %cD, %dx%d stamp, %d plane", (pxi->pxi_option ? '3' : '2'),
+           pxi->pxi_stampw, pxi->pxi_stamph, pxi->pxi_nplanes);
+       if (pxi->pxi_option)
+               printf(", %dkB SRAM", px_probe_sram(pxi) >> 10);
+       printf("\n");
 }
 
 
@@ -356,49 +351,49 @@
                px_cons_rbuf_use = 1;
        }
 
-       /* Align to 8kB */
+       /* Align to 8kB. px_info struct gets the first 4kB */
        bufpa = (bufpa + 8191) & ~8191;
-
-       /* px_info struct gets the first 4kB */
        pxi = (struct px_info *)MIPS_PHYS_TO_KSEG0(bufpa);
        px_unit[unit] = pxi;
        bufpa += PXMAP_INFO_SIZE;
 
-       if (fi == NULL)
-               px_cons_info = pxi;
-
        if (bufpa + PXMAP_RBUF_SIZE > 8192*1024) {
                printf("px%d: ring buffer outside first 8MB of RAM\n", unit);
                return 0;
        }
 
-       /* Fill info struct enough to init the STIC, then do it */
        pxi->pxi_slotbase = TC_PHYS_TO_UNCACHED(slotbase);
        pxi->pxi_unit = unit;
        pxi->pxi_stamp = (caddr_t) (pxi->pxi_slotbase + PX_STAMP_OFFSET);
        pxi->pxi_poll = (int32_t *) (pxi->pxi_slotbase + PX_STIC_POLL_OFFSET);
        pxi->pxi_stic = (struct stic_regs *) (pxi->pxi_slotbase + PX_STIC_OFFSET);
-
-       /* We need to do this ASAP so we can disable the co-processor */
-       px_init_stic(pxi, 1);
-
-       /* PXG upwards has it's VDAC at a different location */
-       i = (pxi->pxi_option ? PXG_VDAC_OFFSET : PX_VDAC_OFFSET);
-       pxi->pxi_vdac = (struct bt459_regs *) (slotbase + i);
-
        pxi->pxi_rbuf = (int *)MIPS_PHYS_TO_KSEG0(bufpa);
        pxi->pxi_rbuf_phys = bufpa;
        pxi->pxi_rbuf_size = PXMAP_RBUF_SIZE;
        pxi->pxi_pbuf_select = 0;
        pxi->pxi_flg = PX_ENABLE;
 
+       /* We need to do this ASAP so we can disable the co-processor */
+       px_init_stic(pxi, 1);
+       
+       /* 
+        * If this is a PXG, use the SRAM and not kernel bss.
+        * XXX this is a big fat waste of memory.
+        */
+       if (pxi->pxi_option) {
+               bufpa = MIPS_KSEG0_TO_PHYS(slotbase + PXG_SRAM_OFFSET);
+               pxi->pxi_rbuf = (int *)MIPS_PHYS_TO_KSEG0(bufpa);
+               pxi->pxi_rbuf_phys = bufpa;
+               pxi->pxi_rbuf_size = 128*1024; /* XXX might have 256kB */
+       }
+
        /* Get a font and lock */
        wsfont_init();
 
        if ((i = wsfont_find(NULL, 0, 0, 2)) < 0)
                panic("px_init: unable to get font");
 
-       if (wsfont_lock(i, &pxi->pxi_font, WSFONT_BIG, WSFONT_LITTLE) < 0)
+       if (wsfont_lock(i, &pxi->pxi_font, WSFONT_R2L, WSFONT_L2R) < 0)
                panic("px_init: unable to lock font");
 
        /* Only now can we init the bt459... */
@@ -410,7 +405,9 @@
        pxi->pxi_fontscale = pxi->pxi_font->fontheight * pxi->pxi_font->stride;
 
        /* Connect to rcons if this is the console device */
-       if (!fi) {
+       if (fi == NULL) {
+               px_cons_info = pxi;
+               
                /* XXX no multiscreen X support yet */
                px_qvss_init(pxi);
 
@@ -490,17 +487,17 @@
 
        /* Set cursor colormap */
        BT459_SELECT(vdac, BT459_REG_CCOLOR_1);
-       BT459_WRITE_REG(vdac, DUPBYTE0(0xff));
-       BT459_WRITE_REG(vdac, DUPBYTE0(0xff));
-       BT459_WRITE_REG(vdac, DUPBYTE0(0xff));
+       BT459_WRITE_REG(vdac, 0xffffff);
+       BT459_WRITE_REG(vdac, 0xffffff);
+       BT459_WRITE_REG(vdac, 0xffffff);
 
        BT459_WRITE_REG(vdac, 0x00);
        BT459_WRITE_REG(vdac, 0x00);
        BT459_WRITE_REG(vdac, 0x00);
 
-       BT459_WRITE_REG(vdac, DUPBYTE0(0xff));
-       BT459_WRITE_REG(vdac, DUPBYTE0(0xff));
-       BT459_WRITE_REG(vdac, DUPBYTE0(0xff));
+       BT459_WRITE_REG(vdac, 0xffffff);
+       BT459_WRITE_REG(vdac, 0xffffff);
+       BT459_WRITE_REG(vdac, 0xffffff);
 
        /* Build and load a sane colormap */
        bzero(pxi->pxi_cmap, sizeof(pxi->pxi_cmap));
@@ -530,7 +527,7 @@
        int buf;
 {
        int i;
-
+       
        if (buf == 0) {
                /*
                 * For the real framebuffer (# 0), we can cheat and use the
@@ -559,7 +556,26 @@
        /* Don't give a damn about Z-buffers... */
        panic("px_probe_planes: (buf != 0) was un-implemented (bloat)");
 }
+       
 
+/*
+ * Figure out how much SRAM the _PXG_ has.
+ */
+static int
+px_probe_sram(pxi)
+       struct px_info *pxi;
+{
+       volatile int32_t *a, *b;
+       
+       a = (int32_t *)(pxi->pxi_slotbase + PXG_SRAM_OFFSET);
+       b = a + (0x20000 >> 1);
+       
+       *a = 4321;
+       *b = 1234;
+       tc_wmb();
+       
+       return (*a == *b) ? 0x20000 : 0x40000;
+}
 
 /*
  * Initialize the STIC (STamp Interface Chip) and stamp
@@ -571,10 +587,23 @@
 {
        int modtype, xconfig, yconfig, config;
        struct stic_regs *stic;
+       volatile int32_t *slot;
        caddr_t stamp;
+       int i;
 
        stic = pxi->pxi_stic;
        stamp = pxi->pxi_stamp;
+       
+       /* If this is a 3D board, disable the i860 co-processor. */
+       if (((stic->modcl >> 12) & 3) != 0) {
+               slot = (volatile int32_t *)pxi->pxi_slotbase;
+
+               slot[PXG_N10_RESET_OFFSET >> 2] = 0;
+               tc_wmb();
+               slot[PXG_HOST_INTR_OFFSET >> 2] = 0;
+               tc_wmb();
+               DELAY(40000); /* paranoia */
+       }       
 
        /*
         * Initialize STIC interface chip registers. Magic sequence from
@@ -603,7 +632,6 @@
                *(int32_t *) (stamp + __PXS(0x100b0)) = config | 8;
                *(int32_t *) (stamp + __PXS(0x100b4)) = 0x0;
        }
-
        /*
         * Remember the size of the stamp, and card revision. Also
         * figure out the number of planes.
@@ -614,6 +642,10 @@
                pxi->pxi_revision = (char)(modtype >> 24);
                pxi->pxi_option = (char)((modtype >> 12) & 3);
 
+               /* PXG upwards has it's VDAC at a different location */
+               i = (pxi->pxi_option ? PXG_VDAC_OFFSET : PX_VDAC_OFFSET);



Home | Main Index | Thread Index | Old Index