Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/tc Make this work on alpha, and fix some other bogons.



details:   https://anonhg.NetBSD.org/src/rev/f26fd28e4663
branches:  trunk
changeset: 504517:f26fd28e4663
user:      ad <ad%NetBSD.org@localhost>
date:      Sun Mar 04 13:32:25 2001 +0000

description:
Make this work on alpha, and fix some other bogons.

diffstat:

 sys/dev/tc/px.c      |   30 ++++++--------
 sys/dev/tc/pxg.c     |   57 ++++++++++++++------------
 sys/dev/tc/stic.c    |  106 ++++++++++++++++++++++++++++++--------------------
 sys/dev/tc/sticreg.h |    8 +-
 sys/dev/tc/sticvar.h |    9 +--
 5 files changed, 115 insertions(+), 95 deletions(-)

diffs (truncated from 611 to 300 lines):

diff -r 130a9891d488 -r f26fd28e4663 sys/dev/tc/px.c
--- a/sys/dev/tc/px.c   Sun Mar 04 11:18:51 2001 +0000
+++ b/sys/dev/tc/px.c   Sun Mar 04 13:32:25 2001 +0000
@@ -1,7 +1,7 @@
-/*     $NetBSD: px.c,v 1.4 2000/12/17 13:52:03 ad Exp $        */
+/*     $NetBSD: px.c,v 1.5 2001/03/04 13:32:25 ad Exp $        */
 
 /*-
- * Copyright (c) 1999, 2000 The NetBSD Foundation, Inc.
+ * Copyright (c) 1999, 2000, 2001 The NetBSD Foundation, Inc.
  * All rights reserved.
  *
  * This code is derived from software contributed to The NetBSD Foundation
@@ -188,7 +188,6 @@
 
        kva = (caddr_t)TC_PHYS_TO_UNCACHED(si->si_slotbase);
 
-       si->si_slotkva = (u_int32_t *)kva;
        si->si_vdac = (u_int32_t *)(kva + PX_VDAC_OFFSET);
        si->si_vdac_reset = (u_int32_t *)(kva + PX_VDAC_RESET_OFFSET);
        si->si_stic = (volatile struct stic_regs *)(kva + PX_STIC_OFFSET);
@@ -225,12 +224,6 @@
                stic_flush(si);
        }
 
-       if ((state & STIC_INT_P) != 0) {
-               sr->sr_ipdvint = 
-                   STIC_INT_P_WE | (sr->sr_ipdvint & STIC_INT_P_EN);
-               tc_wmb();
-       }
-
 #ifdef DEBUG
        if ((sr->sr_ipdvint & STIC_INT_E) != 0) {
                printf("%s: error intr, %x %x %x %x %x", si->si_dv.dv_xname,
@@ -246,10 +239,6 @@
 px_pbuf_get(struct stic_info *si)
 {
 
-       /*
-        * XXX We should be synchronizing with STIC_INT_P so that an ISR
-        * doesn't blow us up.
-        */
        si->si_pbuf_select ^= STIC_PACKET_SIZE;
        return ((u_int32_t *)((caddr_t)si->si_buf + si->si_pbuf_select));
 }
@@ -257,25 +246,32 @@
 static int
 px_pbuf_post(struct stic_info *si, u_int32_t *buf)
 {
-       volatile u_int32_t *poll;
+       volatile u_int32_t *poll, junk;
+       volatile struct stic_regs *sr;
        u_long v;
        int c;
 
+       sr = si->si_stic;
+
        /* Get address of poll register for this buffer. */
        v = (u_long)STIC_KSEG_TO_PHYS(buf);
        v = ((v & 0xffff8000) << 3) | (v & 0x7fff);
-       poll = (volatile u_int32_t *)((caddr_t)si->si_slotkva + (v >> 9));
+       poll = (volatile u_int32_t *)((caddr_t)si->si_slotbase + (v >> 9));
 
        /*
         * Read the poll register and make sure the stamp wants to accept
         * our packet.  This read will initiate the DMA.  Don't wait for
         * ever, just in case something's wrong.
         */
-       tc_syncbus();
+       tc_mb();
 
        for (c = STAMP_RETRIES; c != 0; c--) {
-               if (*poll == STAMP_OK)
+               if ((sr->sr_ipdvint & STIC_INT_P) != 0) {
+                       sr->sr_ipdvint = STIC_INT_P_WE | STIC_INT_P_EN;
+                       tc_wmb();
+                       junk = *poll;
                        return (0);
+               }
                DELAY(STAMP_DELAY);
        }
 
diff -r 130a9891d488 -r f26fd28e4663 sys/dev/tc/pxg.c
--- a/sys/dev/tc/pxg.c  Sun Mar 04 11:18:51 2001 +0000
+++ b/sys/dev/tc/pxg.c  Sun Mar 04 13:32:25 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pxg.c,v 1.3 2001/01/09 16:04:03 ad Exp $       */
+/*     $NetBSD: pxg.c,v 1.4 2001/03/04 13:32:25 ad Exp $       */
 
 /*-
  * Copyright (c) 1999, 2000, 2001 The NetBSD Foundation, Inc.
@@ -162,7 +162,8 @@
                        break;
 
        printf(": %s, %d plane, %dx%d stamp, %dkB SRAM\n", pxg_types[i + 1],
-           si->si_depth, si->si_stampw, si->si_stamph, si->si_buf_size >> 10);
+           si->si_depth, si->si_stampw, si->si_stamph,
+           (int)si->si_buf_size >> 10);
 
        stic_attach(self, si, console);
 }
@@ -183,19 +184,15 @@
 {
        volatile u_int32_t *slot;
        caddr_t kva;
-       paddr_t bpa;
 
-       kva = (caddr_t)TC_PHYS_TO_UNCACHED(si->si_slotbase);
-       bpa = STIC_KSEG_TO_PHYS((caddr_t)kva + PXG_SRAM_OFFSET);
-       slot = (volatile u_int32_t *)kva;
+       kva = (caddr_t)si->si_slotbase;
 
-       si->si_slotkva = (u_int32_t *)kva;
        si->si_vdac = (u_int32_t *)(kva + PXG_VDAC_OFFSET);
        si->si_vdac_reset = (u_int32_t *)(kva + PXG_VDAC_RESET_OFFSET);
        si->si_stic = (volatile struct stic_regs *)(kva + PXG_STIC_OFFSET);
        si->si_stamp = (u_int32_t *)(kva + PXG_STAMP_OFFSET);
-       si->si_buf = (u_int32_t *)TC_PHYS_TO_UNCACHED(bpa);
-       si->si_buf_phys = bpa;
+       si->si_buf = (u_int32_t *)(kva + PXG_SRAM_OFFSET);
+       si->si_buf_phys = STIC_KSEG_TO_PHYS(si->si_buf);
        si->si_buf_size = pxg_probe_sram(si);
        si->si_disptype = WSDISPLAY_TYPE_PXG;
 
@@ -204,9 +201,11 @@
        si->si_ioctl = pxg_ioctl;
 
        /* Disable the co-processor. */
+       slot = (volatile u_int32_t *)kva;
        slot[PXG_I860_RESET_OFFSET >> 2] = 0;
-       tc_syncbus();
+       tc_wmb();
        slot[PXG_HOST_INTR_OFFSET >> 2] = 0;
+       tc_wmb();
        tc_syncbus();
        DELAY(40000);
 
@@ -224,11 +223,11 @@
 {
        volatile u_int32_t *a, *b;
 
-       a = si->si_slotkva + (PXG_SRAM_OFFSET >> 2);
-       b = a + (0x20000 >> 1);
+       a = (volatile u_int32_t *)si->si_slotbase + (PXG_SRAM_OFFSET >> 2);
+       b = a + (0x20000 >> 2);
        *a = 4321;
        *b = 1234;
-       tc_syncbus();
+       tc_mb();
        return ((*a == *b) ? 0x20000 : 0x40000);
 }
 
@@ -247,7 +246,7 @@
            ((BT459_IREG_ID & 0xff) << 8) | ((BT459_IREG_ID & 0xff) << 16);
        vdac[BT459_REG_ADDR_HIGH] = ((BT459_IREG_ID & 0xff00) >> 8) | 
            (BT459_IREG_ID & 0xff00) | ((BT459_IREG_ID & 0xff00) << 8);
-       tc_syncbus();
+       tc_mb();
        id = vdac[BT459_REG_IREG_DATA] & 0x00ffffff;
 
        /* 3 VDACs */
@@ -276,7 +275,8 @@
        si = cookie;
        sr = si->si_stic;
        state = sr->sr_ipdvint;
-       hi = si->si_slotkva + (PXG_HOST_INTR_OFFSET / sizeof(u_int32_t));
+       hi = (volatile u_int32_t *)si->si_slotbase +
+           (PXG_HOST_INTR_OFFSET / sizeof(u_int32_t));
 
        /* Clear the interrupt condition */
        it = hi[0] & 15;
@@ -303,10 +303,6 @@
 pxg_pbuf_get(struct stic_info *si)
 {
 
-       /*
-        * XXX We should be synchronizing with STIC_INT_P so that an ISR
-        * doesn't blow us up.
-        */
        si->si_pbuf_select ^= STIC_PACKET_SIZE;
        return ((u_int32_t *)((caddr_t)si->si_buf + si->si_pbuf_select));
 }
@@ -314,24 +310,31 @@
 static int
 pxg_pbuf_post(struct stic_info *si, u_int32_t *buf)
 {
-       volatile u_int32_t *poll;
+       volatile u_int32_t *poll, junk;
+       volatile struct stic_regs *sr;
        u_long v;
        int c;
 
+       sr = si->si_stic;
+
        /* Get address of poll register for this buffer. */
        v = ((u_long)buf - (u_long)si->si_buf) >> 9;
-       poll = (volatile u_int32_t *)((caddr_t)si->si_slotkva + v);
+       poll = (volatile u_int32_t *)((caddr_t)si->si_slotbase + v);
 
        /*
         * Read the poll register and make sure the stamp wants to accept
         * our packet.  This read will initiate the DMA.  Don't wait for
         * ever, just in case something's wrong.
         */
-       tc_syncbus();
+       tc_mb();
 
        for (c = STAMP_RETRIES; c != 0; c--) {
-               if (*poll == STAMP_OK)
+               if ((sr->sr_ipdvint & STIC_INT_P) != 0) {
+                       sr->sr_ipdvint = STIC_INT_P_WE | STIC_INT_P_EN;
+                       tc_wmb();
+                       junk = *poll;
                        return (0);
+               }
                DELAY(STAMP_DELAY);
        }
 
@@ -344,16 +347,18 @@
 pxg_ioctl(struct stic_info *si, u_long cmd, caddr_t data, int flag,
          struct proc *p)
 {
+       volatile u_int32_t *ptr;
        int rv;
 
        if (cmd == STICIO_START860 || cmd == STICIO_RESET860) {
                if ((rv = suser(p->p_ucred, &p->p_acflag)) != 0)
                        return (rv);
+               ptr = (volatile u_int32_t *)si->si_slotbase;
                if (cmd == STICIO_START860)
-                       si->si_slotkva[PXG_I860_START_OFFSET >> 2] = 1;
+                       ptr[PXG_I860_START_OFFSET >> 2] = 1;
                else
-                       si->si_slotkva[PXG_I860_RESET_OFFSET >> 2] = 0;
-               tc_syncbus();
+                       ptr[PXG_I860_RESET_OFFSET >> 2] = 0;
+               tc_wmb();
                rv = 0;
        } else
                rv = ENOTTY;
diff -r 130a9891d488 -r f26fd28e4663 sys/dev/tc/stic.c
--- a/sys/dev/tc/stic.c Sun Mar 04 11:18:51 2001 +0000
+++ b/sys/dev/tc/stic.c Sun Mar 04 13:32:25 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: stic.c,v 1.7 2001/01/09 16:04:03 ad Exp $      */
+/*     $NetBSD: stic.c,v 1.8 2001/03/04 13:32:25 ad Exp $      */
 
 /*-
  * Copyright (c) 1999, 2000, 2001 The NetBSD Foundation, Inc.
@@ -267,7 +267,7 @@
        0, 0,
        &stic_emulops,
        0, 0,
-       WSATTR_REVERSE | WSATTR_HILIT | WSATTR_WSCOLORS
+       WSSCREEN_WSCOLORS | WSSCREEN_HILIT
 };
 
 static const struct wsscreen_descr *_stic_scrlist[] = {
@@ -293,10 +293,11 @@
 
        /* Hit it... */
        SELECT(vdac, BT459_IREG_COMMAND_0);
-       REG(vdac, bt_reg) = 0x00c0c0c0; tc_syncbus();
+       REG(vdac, bt_reg) = 0x00c0c0c0; tc_wmb();
 
        /* Now reset the VDAC. */
        *si->si_vdac_reset = 0;
+       tc_wmb();
        tc_syncbus();
        DELAY(1000);
 
@@ -358,11 +359,13 @@
         * Initialize the interface chip registers.
         */
        sr->sr_sticsr = 0x00000030;     /* Get the STIC's attention. */
+       tc_wmb();
        tc_syncbus();
        DELAY(4000);                    /* wait 4ms for STIC to respond. */
        sr->sr_sticsr = 0x00000000;     /* Hit the STIC's csr again... */
-       tc_syncbus();
+       tc_wmb();
        sr->sr_buscsr = 0xffffffff;     /* and bash its bus-acess csr. */
+       tc_wmb();
        tc_syncbus();                   /* Blam! */
        DELAY(20000);                   /* wait until the stic recovers... */
 
@@ -394,9 +397,10 @@
        sr->sr_hblank = (255 << 16) | 340;
        sr->sr_hsync2 = 245;
        sr->sr_hsync = (261 << 16) | 293;
-       sr->sr_ipdvint = STIC_INT_CLR | STIC_INT_WE;
+       sr->sr_ipdvint = STIC_INT_CLR | STIC_INT_WE | STIC_INT_P;
        sr->sr_sticsr = 8;
        tc_wmb();
+       tc_syncbus();
 }
 
 void
@@ -430,13 +434,13 @@
 



Home | Main Index | Thread Index | Old Index