Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/sparc64/dev clean up a bit, implement pci_conf_{rea...



details:   https://anonhg.NetBSD.org/src/rev/798362a772f0
branches:  trunk
changeset: 473465:798362a772f0
user:      mrg <mrg%NetBSD.org@localhost>
date:      Sat Jun 05 05:29:50 1999 +0000

description:
clean up a bit, implement pci_conf_{read,write}() with probe[gs]et() (not yet used).

diffstat:

 sys/arch/sparc64/dev/pci_machdep.c |  40 ++++++++++++++++++++++++++++++-------
 1 files changed, 32 insertions(+), 8 deletions(-)

diffs (116 lines):

diff -r b5437021712f -r 798362a772f0 sys/arch/sparc64/dev/pci_machdep.c
--- a/sys/arch/sparc64/dev/pci_machdep.c        Sat Jun 05 05:28:36 1999 +0000
+++ b/sys/arch/sparc64/dev/pci_machdep.c        Sat Jun 05 05:29:50 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pci_machdep.c,v 1.1 1999/06/04 13:42:15 mrg Exp $      */
+/*     $NetBSD: pci_machdep.c,v 1.2 1999/06/05 05:29:50 mrg Exp $      */
 
 /*
  * Copyright (c) 1999 Matthew R. Green
@@ -74,6 +74,11 @@
        NULL,
 };
 
+/* commonly used */
+#define TAG2BUS(tag)   ((tag) >> 16) & 0xff;
+#define TAG2DEV(tag)   ((tag) >> 11) & 0x1f;
+#define TAG2FN(tag)    ((tag) >> 8) & 0x7;
+
 /*
  * functions provided to the MI code.
  */
@@ -90,8 +95,8 @@
        pcitag_t tag;
        char *name, *devtype;
        u_int32_t hi, mid, lo, intr;
+       u_int32_t dev, fn, bus;
        int node, i, n, *ip, *ap;
-       u_int bus, dev, fn;
 
        DPRINTF((SPDB_INTFIX|SPDB_INTMAP), ("\npci_attach_hook:"));
 
@@ -165,9 +170,9 @@
                        goto clean2;
                DPRINTF(SPDB_INTFIX, (" got reg"));
 
-               bus = (ap[0] >> 16) & 0xff;
-               dev = (ap[0] >> 11) & 0x1f;
-               fn = (ap[0] >> 8) & 0x7;
+               bus = TAG2BUS(ap[0]);
+               dev = TAG2DEV(ap[0]);
+               fn = TAG2FN(ap[0]);
 
                DPRINTF(SPDB_INTFIX, ("; bus %u dev %u fn %u", bus, dev, fn));
 
@@ -241,6 +246,7 @@
        int f;
 {
 
+       /* make me a useable offset */
        return (b << 16) | (d << 11) | (f << 8);
 }
 
@@ -260,9 +266,9 @@
 {
        int bus, dev, fn;
 
-       bus = (tag >> 16) & 0xff;
-       dev = (tag >> 11) & 0x1f;
-       fn = (tag >> 8) & 0x7;
+       bus = TAG2BUS(tag);
+       dev = TAG2DEV(tag);
+       fn = TAG2FN(tag);
 
        if (sc->sc_mode == PSYCHO_MODE_SABRE) {
                /*
@@ -281,6 +287,7 @@
                 * make sure we are reading our own bus
                 */
                /* XXX??? */
+               panic("confaddr_ok: can't do SUNW,psycho yet");
        }
        return (1);
 }
@@ -294,6 +301,7 @@
 {
        struct psycho_pbm *pp = pc->cookie;
        struct psycho_softc *sc = pp->pp_sc;
+       u_int32_t data;
        pcireg_t val;
 
        DPRINTF(SPDB_CONF, ("pci_conf_read: tag %lx; reg %x; ", (long)tag, reg));
@@ -304,10 +312,21 @@
        if (confaddr_ok(sc, tag) == 0) {
                val = (pcireg_t)~0;
        } else {
+#if 0
+               membar_sync();
+               data = probeget(bus_type_asi[sc->sc_configtag->type],
+                              sc->sc_configaddr + tag + reg, 4);
+               membar_sync();
+               if (data == -1)
+                       val = (pcireg_t)~0;
+               else
+                       val = (pcireg_t)data;
+#else
                membar_sync();
                val = bus_space_read_4(sc->sc_configtag, sc->sc_configaddr,
                    tag + reg);
                membar_sync();
+#endif
        }
        DPRINTF(SPDB_CONF, (" returning %08x\n", (u_int)val));
 
@@ -333,7 +352,12 @@
                panic("pci_conf_write: bad addr");
                
        membar_sync();
+#if 0
+       probeset(bus_type_asi[sc->sc_configtag->type],
+                sc->sc_configaddr + tag + reg, 4, data);
+#else
        bus_space_write_4(sc->sc_configtag, sc->sc_configaddr, tag + reg, data);
+#endif
        membar_sync();
 }
 



Home | Main Index | Thread Index | Old Index