Source-Changes-HG archive

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

[src/trunk]: src/sys/dev Move a few things around, so that ic/siop_common.c a...



details:   https://anonhg.NetBSD.org/src/rev/9fc58e5c52f3
branches:  trunk
changeset: 525898:9fc58e5c52f3
user:      bouyer <bouyer%NetBSD.org@localhost>
date:      Sat Apr 20 00:15:54 2002 +0000

description:
Move a few things around, so that ic/siop_common.c and pci/siop_pci_common.c
can be compiled without including siopvar.h.

diffstat:

 sys/dev/ic/siop.c             |  971 +++++++++++++++++++++--------------------
 sys/dev/ic/siop_common.c      |  119 +++--
 sys/dev/ic/siopvar.h          |  132 +++-
 sys/dev/ic/siopvar_common.h   |  143 ++---
 sys/dev/pci/siop_pci.c        |   15 +-
 sys/dev/pci/siop_pci_common.c |   80 +-
 sys/dev/pci/siop_pci_common.h |   12 +-
 7 files changed, 786 insertions(+), 686 deletions(-)

diffs (truncated from 2924 to 300 lines):

diff -r 35631823d7ef -r 9fc58e5c52f3 sys/dev/ic/siop.c
--- a/sys/dev/ic/siop.c Fri Apr 19 23:13:44 2002 +0000
+++ b/sys/dev/ic/siop.c Sat Apr 20 00:15:54 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: siop.c,v 1.52 2002/04/18 12:03:15 bouyer Exp $ */
+/*     $NetBSD: siop.c,v 1.53 2002/04/20 00:15:54 bouyer Exp $ */
 
 /*
  * Copyright (c) 2000 Manuel Bouyer.
@@ -33,7 +33,7 @@
 /* SYM53c7/8xx PCI-SCSI I/O Processors driver */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: siop.c,v 1.52 2002/04/18 12:03:15 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: siop.c,v 1.53 2002/04/20 00:15:54 bouyer Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -56,8 +56,8 @@
 #include <dev/scsipi/scsiconf.h>
 
 #include <dev/ic/siopreg.h>
+#include <dev/ic/siopvar_common.h>
 #include <dev/ic/siopvar.h>
-#include <dev/ic/siopvar_common.h>
 
 #include "opt_siop.h"
 
@@ -96,7 +96,8 @@
 void   siop_morecbd __P((struct siop_softc *));
 struct siop_lunsw *siop_get_lunsw __P((struct siop_softc *));
 void   siop_add_reselsw __P((struct siop_softc *, int));
-void   siop_update_scntl3 __P((struct siop_softc *, struct siop_target *));
+void   siop_update_scntl3 __P((struct siop_softc *,
+                       struct siop_common_target *));
 
 #ifdef SIOP_STATS
 static int siop_stat_intr = 0;
@@ -118,8 +119,8 @@
        struct siop_softc *sc;
        int ops;
 {
-       if ((sc->features & SF_CHIP_RAM) == 0)
-               bus_dmamap_sync(sc->sc_dmat, sc->sc_scriptdma, 0,
+       if ((sc->sc_c.features & SF_CHIP_RAM) == 0)
+               bus_dmamap_sync(sc->sc_c.sc_dmat, sc->sc_c.sc_scriptdma, 0,
                    PAGE_SIZE, ops);
 }
 
@@ -129,10 +130,11 @@
        struct siop_softc *sc;
        u_int offset;
 {
-       if (sc->features & SF_CHIP_RAM) {
-               return bus_space_read_4(sc->sc_ramt, sc->sc_ramh, offset * 4);
+       if (sc->sc_c.features & SF_CHIP_RAM) {
+               return bus_space_read_4(sc->sc_c.sc_ramt, sc->sc_c.sc_ramh,
+                   offset * 4);
        } else {
-               return le32toh(sc->sc_script[offset]);
+               return le32toh(sc->sc_c.sc_script[offset]);
        }
 }
 
@@ -144,10 +146,11 @@
        u_int offset;
        u_int32_t val;
 {
-       if (sc->features & SF_CHIP_RAM) {
-               bus_space_write_4(sc->sc_ramt, sc->sc_ramh, offset * 4, val);
+       if (sc->sc_c.features & SF_CHIP_RAM) {
+               bus_space_write_4(sc->sc_c.sc_ramt, sc->sc_c.sc_ramh,
+                   offset * 4, val);
        } else {
-               sc->sc_script[offset] = htole32(val);
+               sc->sc_c.sc_script[offset] = htole32(val);
        }
 }
 
@@ -162,37 +165,39 @@
        /*
         * Allocate DMA-safe memory for the script and map it.
         */
-       if ((sc->features & SF_CHIP_RAM) == 0) {
-               error = bus_dmamem_alloc(sc->sc_dmat, PAGE_SIZE, 
+       if ((sc->sc_c.features & SF_CHIP_RAM) == 0) {
+               error = bus_dmamem_alloc(sc->sc_c.sc_dmat, PAGE_SIZE, 
                    PAGE_SIZE, 0, &seg, 1, &rseg, BUS_DMA_NOWAIT);
                if (error) {
                        printf("%s: unable to allocate script DMA memory, "
-                           "error = %d\n", sc->sc_dev.dv_xname, error);
+                           "error = %d\n", sc->sc_c.sc_dev.dv_xname, error);
                        return;
                }
-               error = bus_dmamem_map(sc->sc_dmat, &seg, rseg, PAGE_SIZE,
-                   (caddr_t *)&sc->sc_script, BUS_DMA_NOWAIT|BUS_DMA_COHERENT);
+               error = bus_dmamem_map(sc->sc_c.sc_dmat, &seg, rseg, PAGE_SIZE,
+                   (caddr_t *)&sc->sc_c.sc_script,
+                   BUS_DMA_NOWAIT|BUS_DMA_COHERENT);
                if (error) {
                        printf("%s: unable to map script DMA memory, "
-                           "error = %d\n", sc->sc_dev.dv_xname, error);
+                           "error = %d\n", sc->sc_c.sc_dev.dv_xname, error);
                        return;
                }
-               error = bus_dmamap_create(sc->sc_dmat, PAGE_SIZE, 1,
-                   PAGE_SIZE, 0, BUS_DMA_NOWAIT, &sc->sc_scriptdma);
+               error = bus_dmamap_create(sc->sc_c.sc_dmat, PAGE_SIZE, 1,
+                   PAGE_SIZE, 0, BUS_DMA_NOWAIT, &sc->sc_c.sc_scriptdma);
                if (error) {
                        printf("%s: unable to create script DMA map, "
-                           "error = %d\n", sc->sc_dev.dv_xname, error);
+                           "error = %d\n", sc->sc_c.sc_dev.dv_xname, error);
                        return;
                }
-               error = bus_dmamap_load(sc->sc_dmat, sc->sc_scriptdma,
-                   sc->sc_script, PAGE_SIZE, NULL, BUS_DMA_NOWAIT);
+               error = bus_dmamap_load(sc->sc_c.sc_dmat, sc->sc_c.sc_scriptdma,
+                   sc->sc_c.sc_script, PAGE_SIZE, NULL, BUS_DMA_NOWAIT);
                if (error) {
                        printf("%s: unable to load script DMA map, "
-                           "error = %d\n", sc->sc_dev.dv_xname, error);
+                           "error = %d\n", sc->sc_c.sc_dev.dv_xname, error);
                        return;
                }
-               sc->sc_scriptaddr = sc->sc_scriptdma->dm_segs[0].ds_addr;
-               sc->ram_size = PAGE_SIZE;
+               sc->sc_c.sc_scriptaddr =
+                   sc->sc_c.sc_scriptdma->dm_segs[0].ds_addr;
+               sc->sc_c.ram_size = PAGE_SIZE;
        }
        TAILQ_INIT(&sc->free_list);
        TAILQ_INIT(&sc->cmds);
@@ -200,48 +205,50 @@
        sc->sc_currschedslot = 0;
 #ifdef SIOP_DEBUG
        printf("%s: script size = %d, PHY addr=0x%x, VIRT=%p\n",
-           sc->sc_dev.dv_xname, (int)sizeof(siop_script),
-           (u_int32_t)sc->sc_scriptaddr, sc->sc_script);
+           sc->sc_c.sc_dev.dv_xname, (int)sizeof(siop_script),
+           (u_int32_t)sc->sc_c.sc_scriptaddr, sc->sc_c.sc_script);
 #endif
 
-       sc->sc_adapt.adapt_dev = &sc->sc_dev;
-       sc->sc_adapt.adapt_nchannels = 1;
-       sc->sc_adapt.adapt_openings = 0;
-       sc->sc_adapt.adapt_max_periph = SIOP_NTAG - 1;
-       sc->sc_adapt.adapt_ioctl = siop_ioctl;
-       sc->sc_adapt.adapt_minphys = minphys;
-       sc->sc_adapt.adapt_request = siop_scsipi_request;
+       sc->sc_c.sc_adapt.adapt_dev = &sc->sc_c.sc_dev;
+       sc->sc_c.sc_adapt.adapt_nchannels = 1;
+       sc->sc_c.sc_adapt.adapt_openings = 0;
+       sc->sc_c.sc_adapt.adapt_max_periph = SIOP_NTAG - 1;
+       sc->sc_c.sc_adapt.adapt_ioctl = siop_ioctl;
+       sc->sc_c.sc_adapt.adapt_minphys = minphys;
+       sc->sc_c.sc_adapt.adapt_request = siop_scsipi_request;
 
-       memset(&sc->sc_chan, 0, sizeof(sc->sc_chan));
-       sc->sc_chan.chan_adapter = &sc->sc_adapt;
-       sc->sc_chan.chan_bustype = &scsi_bustype;
-       sc->sc_chan.chan_channel = 0;
-       sc->sc_chan.chan_flags = SCSIPI_CHAN_CANGROW;
-       sc->sc_chan.chan_ntargets = (sc->features & SF_BUS_WIDE) ? 16 : 8;
-       sc->sc_chan.chan_nluns = 8;
-       sc->sc_chan.chan_id = bus_space_read_1(sc->sc_rt, sc->sc_rh, SIOP_SCID);
-       if (sc->sc_chan.chan_id == 0 ||
-           sc->sc_chan.chan_id >= sc->sc_chan.chan_ntargets)
-               sc->sc_chan.chan_id = SIOP_DEFAULT_TARGET;
+       memset(&sc->sc_c.sc_chan, 0, sizeof(sc->sc_c.sc_chan));
+       sc->sc_c.sc_chan.chan_adapter = &sc->sc_c.sc_adapt;
+       sc->sc_c.sc_chan.chan_bustype = &scsi_bustype;
+       sc->sc_c.sc_chan.chan_channel = 0;
+       sc->sc_c.sc_chan.chan_flags = SCSIPI_CHAN_CANGROW;
+       sc->sc_c.sc_chan.chan_ntargets =
+           (sc->sc_c.features & SF_BUS_WIDE) ? 16 : 8;
+       sc->sc_c.sc_chan.chan_nluns = 8;
+       sc->sc_c.sc_chan.chan_id =
+           bus_space_read_1(sc->sc_c.sc_rt, sc->sc_c.sc_rh, SIOP_SCID);
+       if (sc->sc_c.sc_chan.chan_id == 0 ||
+           sc->sc_c.sc_chan.chan_id >= sc->sc_c.sc_chan.chan_ntargets)
+               sc->sc_c.sc_chan.chan_id = SIOP_DEFAULT_TARGET;
 
        for (i = 0; i < 16; i++)
-               sc->targets[i] = NULL;
+               sc->sc_c.targets[i] = NULL;
 
        /* find min/max sync period for this chip */
-       sc->maxsync = 0;
-       sc->minsync = 255;
+       sc->sc_c.maxsync = 0;
+       sc->sc_c.minsync = 255;
        for (i = 0; i < sizeof(scf_period) / sizeof(scf_period[0]); i++) {
-               if (sc->clock_period != scf_period[i].clock)
+               if (sc->sc_c.clock_period != scf_period[i].clock)
                        continue;
-               if (sc->maxsync < scf_period[i].period)
-                       sc->maxsync = scf_period[i].period;
-               if (sc->minsync > scf_period[i].period)
-                       sc->minsync = scf_period[i].period;
+               if (sc->sc_c.maxsync < scf_period[i].period)
+                       sc->sc_c.maxsync = scf_period[i].period;
+               if (sc->sc_c.minsync > scf_period[i].period)
+                       sc->sc_c.minsync = scf_period[i].period;
        }
-       if (sc->maxsync == 255 || sc->minsync == 0)
+       if (sc->sc_c.maxsync == 255 || sc->sc_c.minsync == 0)
                panic("siop: can't find my sync parameters\n");
        /* Do a bus reset, so that devices fall back to narrow/async */
-       siop_resetbus(sc);
+       siop_resetbus(&sc->sc_c);
        /*
         * siop_reset() will reset the chip, thus clearing pending interrupts
         */
@@ -250,7 +257,7 @@
        siop_dump_script(sc);
 #endif
 
-       config_found((struct device*)sc, &sc->sc_chan, scsiprint);
+       config_found((struct device*)sc, &sc->sc_c.sc_chan, scsiprint);
 }
 
 void
@@ -260,107 +267,111 @@
        int i, j;
        struct siop_lunsw *lunsw;
 
-       siop_common_reset(sc);
+       siop_common_reset(&sc->sc_c);
 
        /* copy and patch the script */
-       if (sc->features & SF_CHIP_RAM) {
-               bus_space_write_region_4(sc->sc_ramt, sc->sc_ramh, 0,
+       if (sc->sc_c.features & SF_CHIP_RAM) {
+               bus_space_write_region_4(sc->sc_c.sc_ramt, sc->sc_c.sc_ramh, 0,
                    siop_script, sizeof(siop_script) / sizeof(siop_script[0]));
                for (j = 0; j <
                    (sizeof(E_abs_msgin_Used) / sizeof(E_abs_msgin_Used[0]));
                    j++) {
-                       bus_space_write_4(sc->sc_ramt, sc->sc_ramh,
+                       bus_space_write_4(sc->sc_c.sc_ramt, sc->sc_c.sc_ramh,
                            E_abs_msgin_Used[j] * 4,
-                           sc->sc_scriptaddr + Ent_msgin_space);
+                           sc->sc_c.sc_scriptaddr + Ent_msgin_space);
                }
 #ifdef SIOP_SYMLED
-               bus_space_write_region_4(sc->sc_ramt, sc->sc_ramh, Ent_led_on1,
-                   siop_led_on, sizeof(siop_led_on) / sizeof(siop_led_on[0]));
-               bus_space_write_region_4(sc->sc_ramt, sc->sc_ramh, Ent_led_on2,
-                   siop_led_on, sizeof(siop_led_on) / sizeof(siop_led_on[0]));
-               bus_space_write_region_4(sc->sc_ramt, sc->sc_ramh, Ent_led_off,
-                   siop_led_off,
+               bus_space_write_region_4(sc->sc_c.sc_ramt, sc->sc_c.sc_ramh,
+                   Ent_led_on1, siop_led_on,
+                   sizeof(siop_led_on) / sizeof(siop_led_on[0]));
+               bus_space_write_region_4(sc->sc_c.sc_ramt, sc->sc_c.sc_ramh,
+                   Ent_led_on2, siop_led_on,
+                   sizeof(siop_led_on) / sizeof(siop_led_on[0]));
+               bus_space_write_region_4(sc->sc_c.sc_ramt, sc->sc_c.sc_ramh,
+                   Ent_led_off, siop_led_off,
                    sizeof(siop_led_off) / sizeof(siop_led_off[0]));
 #endif
        } else {
                for (j = 0;
                    j < (sizeof(siop_script) / sizeof(siop_script[0])); j++) {
-                       sc->sc_script[j] = htole32(siop_script[j]);
+                       sc->sc_c.sc_script[j] = htole32(siop_script[j]);
                }
                for (j = 0; j <
                    (sizeof(E_abs_msgin_Used) / sizeof(E_abs_msgin_Used[0]));
                    j++) {
-                       sc->sc_script[E_abs_msgin_Used[j]] =
-                           htole32(sc->sc_scriptaddr + Ent_msgin_space);
+                       sc->sc_c.sc_script[E_abs_msgin_Used[j]] =
+                           htole32(sc->sc_c.sc_scriptaddr + Ent_msgin_space);
                }
 #ifdef SIOP_SYMLED
                for (j = 0;
                    j < (sizeof(siop_led_on) / sizeof(siop_led_on[0])); j++)
-                       sc->sc_script[
+                       sc->sc_c.sc_script[
                            Ent_led_on1 / sizeof(siop_led_on[0]) + j
                            ] = htole32(siop_led_on[j]);
                for (j = 0;
                    j < (sizeof(siop_led_on) / sizeof(siop_led_on[0])); j++)
-                       sc->sc_script[
+                       sc->sc_c.sc_script[
                            Ent_led_on2 / sizeof(siop_led_on[0]) + j
                            ] = htole32(siop_led_on[j]);
                for (j = 0;
                    j < (sizeof(siop_led_off) / sizeof(siop_led_off[0])); j++)
-                       sc->sc_script[
+                       sc->sc_c.sc_script[
                           Ent_led_off / sizeof(siop_led_off[0]) + j
                           ] = htole32(siop_led_off[j]);
 #endif
        }
        sc->script_free_lo = sizeof(siop_script) / sizeof(siop_script[0]);
-       sc->script_free_hi = sc->ram_size / 4;
+       sc->script_free_hi = sc->sc_c.ram_size / 4;



Home | Main Index | Thread Index | Old Index