Home | History | Annotate | Line # | Download | only in dev
sbc.c revision 1.28.4.2
      1  1.28.4.2   thorpej /*	$NetBSD: sbc.c,v 1.28.4.2 1997/08/27 22:27:49 thorpej Exp $	*/
      2       1.1    scottr 
      3       1.1    scottr /*
      4      1.19    scottr  * Copyright (C) 1996 Scott Reynolds.  All rights reserved.
      5       1.1    scottr  *
      6       1.1    scottr  * Redistribution and use in source and binary forms, with or without
      7       1.1    scottr  * modification, are permitted provided that the following conditions
      8       1.1    scottr  * are met:
      9       1.1    scottr  * 1. Redistributions of source code must retain the above copyright
     10       1.1    scottr  *    notice, this list of conditions and the following disclaimer.
     11       1.1    scottr  * 2. Redistributions in binary form must reproduce the above copyright
     12       1.1    scottr  *    notice, this list of conditions and the following disclaimer in the
     13       1.1    scottr  *    documentation and/or other materials provided with the distribution.
     14      1.19    scottr  * 3. All advertising materials mentioning features or use of this software
     15      1.19    scottr  *    must display the following acknowledgement:
     16      1.19    scottr  *      This product includes software developed by Scott Reynolds for
     17      1.19    scottr  *      the NetBSD Project.
     18      1.19    scottr  * 4. The name of the author may not be used to endorse or promote products
     19      1.19    scottr  *    derived from this software without specific prior written permission
     20       1.1    scottr  *
     21      1.19    scottr  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     22       1.1    scottr  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     23       1.1    scottr  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     24      1.19    scottr  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     25       1.1    scottr  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     26       1.1    scottr  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     27       1.1    scottr  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     28       1.1    scottr  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     29       1.1    scottr  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     30       1.1    scottr  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     31       1.1    scottr  */
     32       1.1    scottr 
     33       1.1    scottr /*
     34       1.1    scottr  * This file contains only the machine-dependent parts of the mac68k
     35       1.1    scottr  * NCR 5380 SCSI driver.  (Autoconfig stuff and PDMA functions.)
     36       1.1    scottr  * The machine-independent parts are in ncr5380sbc.c
     37       1.1    scottr  *
     38       1.1    scottr  * Supported hardware includes:
     39       1.1    scottr  * Macintosh II family 5380-based controller
     40       1.1    scottr  *
     41       1.1    scottr  * Credits, history:
     42       1.1    scottr  *
     43       1.1    scottr  * Scott Reynolds wrote this module, based on work by Allen Briggs
     44       1.9    scottr  * (mac68k), Gordon W. Ross and David Jones (sun3), and Leo Weppelman
     45       1.9    scottr  * (atari).  Thanks to Allen for supplying crucial interpretation of the
     46       1.9    scottr  * NetBSD/mac68k 1.1 'ncrscsi' driver.  Also, Allen, Gordon, and Jason
     47       1.9    scottr  * Thorpe all helped to refine this code, and were considerable sources
     48       1.9    scottr  * of moral support.
     49       1.1    scottr  */
     50       1.1    scottr 
     51       1.1    scottr #include <sys/types.h>
     52       1.1    scottr #include <sys/param.h>
     53       1.1    scottr #include <sys/systm.h>
     54       1.1    scottr #include <sys/kernel.h>
     55       1.1    scottr #include <sys/errno.h>
     56       1.1    scottr #include <sys/device.h>
     57       1.1    scottr #include <sys/buf.h>
     58       1.1    scottr #include <sys/proc.h>
     59       1.1    scottr #include <sys/user.h>
     60       1.1    scottr 
     61  1.28.4.2   thorpej #include <dev/scsipi/scsi_all.h>
     62  1.28.4.2   thorpej #include <dev/scsipi/scsipi_all.h>
     63  1.28.4.2   thorpej #include <dev/scsipi/scsipi_debug.h>
     64  1.28.4.2   thorpej #include <dev/scsipi/scsiconf.h>
     65       1.1    scottr 
     66       1.1    scottr #include <dev/ic/ncr5380reg.h>
     67       1.1    scottr #include <dev/ic/ncr5380var.h>
     68       1.1    scottr 
     69       1.8    scottr #include <machine/cpu.h>
     70       1.1    scottr #include <machine/viareg.h>
     71       1.1    scottr 
     72  1.28.4.1   thorpej #include <mac68k/dev/sbcreg.h>
     73  1.28.4.1   thorpej #include <mac68k/dev/sbcvar.h>
     74       1.1    scottr 
     75      1.22    scottr int	sbc_debug = 0 /* | SBC_DB_INTR | SBC_DB_DMA */;
     76      1.22    scottr int	sbc_link_flags = 0 /* | SDEV_DB2 */;
     77      1.24    scottr int	sbc_options = 0 /* | SBC_PDMA */;
     78       1.1    scottr 
     79       1.1    scottr static	void	sbc_minphys __P((struct buf *bp));
     80       1.1    scottr 
     81  1.28.4.2   thorpej struct scsipi_adapter	sbc_ops = {
     82       1.1    scottr 	ncr5380_scsi_cmd,		/* scsi_cmd()		*/
     83       1.1    scottr 	sbc_minphys,			/* scsi_minphys()	*/
     84       1.1    scottr 	NULL,				/* open_target_lu()	*/
     85       1.1    scottr 	NULL,				/* close_target_lu()	*/
     86       1.1    scottr };
     87       1.1    scottr 
     88       1.1    scottr /* This is copied from julian's bt driver */
     89       1.1    scottr /* "so we have a default dev struct for our link struct." */
     90  1.28.4.2   thorpej struct scsipi_device sbc_dev = {
     91       1.1    scottr 	NULL,		/* Use default error handler.	    */
     92       1.1    scottr 	NULL,		/* Use default start handler.		*/
     93       1.1    scottr 	NULL,		/* Use default async handler.	    */
     94       1.1    scottr 	NULL,		/* Use default "done" routine.	    */
     95       1.1    scottr };
     96       1.1    scottr 
     97       1.1    scottr struct cfdriver sbc_cd = {
     98       1.1    scottr 	NULL, "sbc", DV_DULL
     99       1.1    scottr };
    100       1.1    scottr 
    101      1.28    scottr static	int	sbc_wait_busy __P((struct ncr5380_softc *));
    102      1.22    scottr static	int	sbc_ready __P((struct ncr5380_softc *));
    103      1.28    scottr static	int	sbc_wait_dreq __P((struct ncr5380_softc *));
    104       1.1    scottr 
    105       1.1    scottr static void
    106       1.1    scottr sbc_minphys(struct buf *bp)
    107       1.1    scottr {
    108       1.1    scottr 	if (bp->b_bcount > MAX_DMA_LEN)
    109       1.1    scottr 		bp->b_bcount = MAX_DMA_LEN;
    110       1.1    scottr 	return (minphys(bp));
    111       1.1    scottr }
    112       1.1    scottr 
    113       1.1    scottr 
    114       1.1    scottr /***
    115       1.1    scottr  * General support for Mac-specific SCSI logic.
    116       1.1    scottr  ***/
    117       1.1    scottr 
    118      1.28    scottr /* These are used in the following inline functions. */
    119      1.28    scottr int sbc_wait_busy_timo = 1000 * 5000;	/* X2 = 10 S. */
    120      1.28    scottr int sbc_ready_timo = 1000 * 5000;	/* X2 = 10 S. */
    121      1.28    scottr int sbc_wait_dreq_timo = 1000 * 5000;	/* X2 = 10 S. */
    122      1.28    scottr 
    123      1.28    scottr /* Return zero on success. */
    124      1.28    scottr static __inline__ int
    125      1.28    scottr sbc_wait_busy(sc)
    126      1.28    scottr 	struct ncr5380_softc *sc;
    127      1.28    scottr {
    128      1.28    scottr 	int timo = sbc_wait_busy_timo;
    129      1.28    scottr 	for (;;) {
    130      1.28    scottr 		if (SCI_BUSY(sc)) {
    131      1.28    scottr 			timo = 0;	/* return 0 */
    132      1.28    scottr 			break;
    133      1.28    scottr 		}
    134      1.28    scottr 		if (--timo < 0)
    135      1.28    scottr 			break;	/* return -1 */
    136      1.28    scottr 		delay(2);
    137      1.28    scottr 	}
    138      1.28    scottr 	return (timo);
    139      1.28    scottr }
    140      1.28    scottr 
    141      1.28    scottr static __inline__ int
    142      1.28    scottr sbc_ready(sc)
    143      1.28    scottr 	struct ncr5380_softc *sc;
    144      1.28    scottr {
    145      1.28    scottr 	int timo = sbc_ready_timo;
    146      1.28    scottr 
    147      1.28    scottr 	for (;;) {
    148      1.28    scottr 		if ((*sc->sci_csr & (SCI_CSR_DREQ|SCI_CSR_PHASE_MATCH))
    149      1.28    scottr 		    == (SCI_CSR_DREQ|SCI_CSR_PHASE_MATCH)) {
    150      1.28    scottr 			timo = 0;
    151      1.28    scottr 			break;
    152      1.28    scottr 		}
    153      1.28    scottr 		if (((*sc->sci_csr & SCI_CSR_PHASE_MATCH) == 0)
    154      1.28    scottr 		    || (SCI_BUSY(sc) == 0)) {
    155      1.28    scottr 			timo = -1;
    156      1.28    scottr 			break;
    157      1.28    scottr 		}
    158      1.28    scottr 		if (--timo < 0)
    159      1.28    scottr 			break;	/* return -1 */
    160      1.28    scottr 		delay(2);
    161      1.28    scottr 	}
    162      1.28    scottr 	return (timo);
    163      1.28    scottr }
    164      1.28    scottr 
    165      1.28    scottr static __inline__ int
    166      1.28    scottr sbc_wait_dreq(sc)
    167      1.28    scottr 	struct ncr5380_softc *sc;
    168      1.28    scottr {
    169      1.28    scottr 	int timo = sbc_wait_dreq_timo;
    170      1.28    scottr 
    171      1.28    scottr 	for (;;) {
    172      1.28    scottr 		if ((*sc->sci_csr & (SCI_CSR_DREQ|SCI_CSR_PHASE_MATCH))
    173      1.28    scottr 		    == (SCI_CSR_DREQ|SCI_CSR_PHASE_MATCH)) {
    174      1.28    scottr 			timo = 0;
    175      1.28    scottr 			break;
    176      1.28    scottr 		}
    177      1.28    scottr 		if (--timo < 0)
    178      1.28    scottr 			break;	/* return -1 */
    179      1.28    scottr 		delay(2);
    180      1.28    scottr 	}
    181      1.28    scottr 	return (timo);
    182      1.28    scottr }
    183      1.28    scottr 
    184       1.1    scottr void
    185       1.1    scottr sbc_irq_intr(p)
    186       1.1    scottr 	void *p;
    187       1.1    scottr {
    188      1.23    scottr 	struct ncr5380_softc *ncr_sc = p;
    189      1.23    scottr 	int claimed = 0;
    190       1.1    scottr 
    191       1.1    scottr 	/* How we ever arrive here without IRQ set is a mystery... */
    192       1.1    scottr 	if (*ncr_sc->sci_csr & SCI_CSR_INT) {
    193       1.3    scottr #ifdef SBC_DEBUG
    194       1.3    scottr 		if (sbc_debug & SBC_DB_INTR)
    195       1.3    scottr 			decode_5380_intr(ncr_sc);
    196       1.3    scottr #endif
    197       1.1    scottr 		claimed = ncr5380_intr(ncr_sc);
    198       1.1    scottr 		if (!claimed) {
    199       1.1    scottr 			if (((*ncr_sc->sci_csr & ~SCI_CSR_PHASE_MATCH) == SCI_CSR_INT)
    200       1.3    scottr 			    && ((*ncr_sc->sci_bus_csr & ~SCI_BUS_RST) == 0))
    201       1.1    scottr 				SCI_CLR_INTR(ncr_sc);	/* RST interrupt */
    202       1.1    scottr #ifdef SBC_DEBUG
    203       1.1    scottr 			else {
    204      1.13  christos 				printf("%s: spurious intr\n",
    205       1.1    scottr 				    ncr_sc->sc_dev.dv_xname);
    206       1.3    scottr 				SBC_BREAK;
    207       1.1    scottr 			}
    208       1.1    scottr #endif
    209       1.1    scottr 		}
    210       1.1    scottr 	}
    211       1.1    scottr }
    212       1.1    scottr 
    213       1.3    scottr #ifdef SBC_DEBUG
    214       1.3    scottr void
    215       1.3    scottr decode_5380_intr(ncr_sc)
    216       1.3    scottr 	struct ncr5380_softc *ncr_sc;
    217       1.3    scottr {
    218      1.28    scottr 	u_int8_t csr = *ncr_sc->sci_csr;
    219      1.28    scottr 	u_int8_t bus_csr = *ncr_sc->sci_bus_csr;
    220       1.3    scottr 
    221       1.3    scottr 	if (((csr & ~(SCI_CSR_PHASE_MATCH | SCI_CSR_ATN)) == SCI_CSR_INT) &&
    222       1.3    scottr 	    ((bus_csr & ~(SCI_BUS_MSG | SCI_BUS_CD | SCI_BUS_IO | SCI_BUS_DBP)) == SCI_BUS_SEL)) {
    223       1.3    scottr 		if (csr & SCI_BUS_IO)
    224      1.13  christos 			printf("%s: reselect\n", ncr_sc->sc_dev.dv_xname);
    225       1.3    scottr 		else
    226      1.13  christos 			printf("%s: select\n", ncr_sc->sc_dev.dv_xname);
    227       1.3    scottr 	} else if (((csr & ~SCI_CSR_ACK) == (SCI_CSR_DONE | SCI_CSR_INT)) &&
    228       1.3    scottr 	    ((bus_csr & (SCI_BUS_RST | SCI_BUS_BSY | SCI_BUS_SEL)) == SCI_BUS_BSY))
    229      1.13  christos 		printf("%s: dma eop\n", ncr_sc->sc_dev.dv_xname);
    230       1.3    scottr 	else if (((csr & ~SCI_CSR_PHASE_MATCH) == SCI_CSR_INT) &&
    231       1.3    scottr 	    ((bus_csr & ~SCI_BUS_RST) == 0))
    232      1.13  christos 		printf("%s: bus reset\n", ncr_sc->sc_dev.dv_xname);
    233       1.3    scottr 	else if (((csr & ~(SCI_CSR_DREQ | SCI_CSR_ATN | SCI_CSR_ACK)) == (SCI_CSR_PERR | SCI_CSR_INT | SCI_CSR_PHASE_MATCH)) &&
    234       1.3    scottr 	    ((bus_csr & (SCI_BUS_RST | SCI_BUS_BSY | SCI_BUS_SEL)) == SCI_BUS_BSY))
    235      1.13  christos 		printf("%s: parity error\n", ncr_sc->sc_dev.dv_xname);
    236       1.3    scottr 	else if (((csr & ~SCI_CSR_ATN) == SCI_CSR_INT) &&
    237       1.3    scottr 	    ((bus_csr & (SCI_BUS_RST | SCI_BUS_BSY | SCI_BUS_REQ | SCI_BUS_SEL)) == (SCI_BUS_BSY | SCI_BUS_REQ)))
    238      1.13  christos 		printf("%s: phase mismatch\n", ncr_sc->sc_dev.dv_xname);
    239       1.3    scottr 	else if (((csr & ~SCI_CSR_PHASE_MATCH) == (SCI_CSR_INT | SCI_CSR_DISC)) &&
    240       1.3    scottr 	    (bus_csr == 0))
    241      1.13  christos 		printf("%s: disconnect\n", ncr_sc->sc_dev.dv_xname);
    242       1.3    scottr 	else
    243      1.13  christos 		printf("%s: unknown intr: csr=%x, bus_csr=%x\n",
    244       1.3    scottr 		    ncr_sc->sc_dev.dv_xname, csr, bus_csr);
    245       1.3    scottr }
    246       1.3    scottr #endif
    247       1.1    scottr 
    248       1.8    scottr 
    249       1.1    scottr /***
    250       1.1    scottr  * The following code implements polled PDMA.
    251       1.1    scottr  ***/
    252       1.1    scottr 
    253      1.23    scottr int
    254      1.23    scottr sbc_pdma_in(ncr_sc, phase, datalen, data)
    255      1.23    scottr 	struct ncr5380_softc *ncr_sc;
    256      1.28    scottr 	int phase;
    257      1.28    scottr 	int datalen;
    258      1.23    scottr 	u_char *data;
    259      1.23    scottr {
    260      1.23    scottr 	struct sbc_softc *sc = (struct sbc_softc *)ncr_sc;
    261      1.24    scottr 	volatile u_int32_t *long_data = (u_int32_t *)sc->sc_drq_addr;
    262      1.24    scottr 	volatile u_int8_t *byte_data = (u_int8_t *)sc->sc_nodrq_addr;
    263      1.23    scottr 	int resid, s;
    264      1.23    scottr 
    265      1.28    scottr 	if (datalen < ncr_sc->sc_min_dma_len ||
    266      1.28    scottr 	    (sc->sc_options & SBC_PDMA) == 0)
    267      1.28    scottr 		return ncr5380_pio_in(ncr_sc, phase, datalen, data);
    268      1.28    scottr 
    269      1.23    scottr 	s = splbio();
    270      1.28    scottr 	if (sbc_wait_busy(ncr_sc)) {
    271      1.28    scottr 		splx(s);
    272      1.28    scottr 		return 0;
    273      1.28    scottr 	}
    274      1.28    scottr 
    275      1.23    scottr 	*ncr_sc->sci_mode |= SCI_MODE_DMA;
    276      1.23    scottr 	*ncr_sc->sci_irecv = 0;
    277       1.1    scottr 
    278      1.28    scottr #define R4	*((u_int32_t *)data)++ = *long_data
    279      1.28    scottr #define R1	*((u_int8_t *)data)++ = *byte_data
    280      1.23    scottr 	for (resid = datalen; resid >= 128; resid -= 128) {
    281      1.28    scottr 		if (sbc_ready(ncr_sc))
    282      1.23    scottr 			goto interrupt;
    283      1.23    scottr 		R4; R4; R4; R4; R4; R4; R4; R4;
    284      1.23    scottr 		R4; R4; R4; R4; R4; R4; R4; R4;
    285      1.23    scottr 		R4; R4; R4; R4; R4; R4; R4; R4;
    286      1.28    scottr 		R4; R4; R4; R4; R4; R4; R4; R4;		/* 128 */
    287      1.23    scottr 	}
    288      1.23    scottr 	while (resid) {
    289      1.28    scottr 		if (sbc_ready(ncr_sc))
    290      1.23    scottr 			goto interrupt;
    291      1.23    scottr 		R1;
    292      1.23    scottr 		resid--;
    293       1.1    scottr 	}
    294      1.23    scottr #undef R4
    295      1.23    scottr #undef R1
    296       1.1    scottr 
    297      1.23    scottr interrupt:
    298       1.1    scottr 	SCI_CLR_INTR(ncr_sc);
    299       1.1    scottr 	*ncr_sc->sci_mode &= ~SCI_MODE_DMA;
    300      1.28    scottr 	*ncr_sc->sci_icmd = 0;
    301      1.23    scottr 	splx(s);
    302      1.28    scottr 	return (datalen - resid);
    303       1.1    scottr }
    304       1.1    scottr 
    305      1.22    scottr int
    306      1.23    scottr sbc_pdma_out(ncr_sc, phase, datalen, data)
    307       1.1    scottr 	struct ncr5380_softc *ncr_sc;
    308      1.28    scottr 	int phase;
    309      1.28    scottr 	int datalen;
    310       1.1    scottr 	u_char *data;
    311       1.1    scottr {
    312       1.1    scottr 	struct sbc_softc *sc = (struct sbc_softc *)ncr_sc;
    313      1.24    scottr 	volatile u_int32_t *long_data = (u_int32_t *)sc->sc_drq_addr;
    314      1.24    scottr 	volatile u_int8_t *byte_data = (u_int8_t *)sc->sc_nodrq_addr;
    315      1.28    scottr 	int resid, s;
    316      1.28    scottr 	u_int8_t icmd;
    317      1.23    scottr 
    318      1.28    scottr 	if (datalen < ncr_sc->sc_min_dma_len ||
    319      1.28    scottr 	    (sc->sc_options & SBC_PDMA) == 0)
    320      1.24    scottr 		return ncr5380_pio_out(ncr_sc, phase, datalen, data);
    321      1.24    scottr 
    322      1.23    scottr 	s = splbio();
    323      1.28    scottr 	if (sbc_wait_busy(ncr_sc)) {
    324      1.28    scottr 		splx(s);
    325      1.28    scottr 		return 0;
    326      1.28    scottr 	}
    327      1.28    scottr 
    328      1.23    scottr 	icmd = *(ncr_sc->sci_icmd) & SCI_ICMD_RMASK;
    329      1.23    scottr 	*ncr_sc->sci_icmd = icmd | SCI_ICMD_DATA;
    330      1.23    scottr 	*ncr_sc->sci_mode |= SCI_MODE_DMA;
    331      1.23    scottr 	*ncr_sc->sci_dma_send = 0;
    332      1.23    scottr 
    333      1.28    scottr #define W1	*byte_data = *((u_int8_t *)data)++
    334      1.28    scottr #define W4	*long_data = *((u_int32_t *)data)++
    335      1.28    scottr 	for (resid = datalen; resid >= 64; resid -= 64) {
    336      1.28    scottr 		if (sbc_ready(ncr_sc))
    337      1.23    scottr 			goto interrupt;
    338      1.23    scottr 		W1;
    339      1.28    scottr 		if (sbc_ready(ncr_sc))
    340      1.23    scottr 			goto interrupt;
    341      1.23    scottr 		W1;
    342      1.28    scottr 		if (sbc_ready(ncr_sc))
    343      1.23    scottr 			goto interrupt;
    344      1.23    scottr 		W1;
    345      1.28    scottr 		if (sbc_ready(ncr_sc))
    346      1.23    scottr 			goto interrupt;
    347      1.23    scottr 		W1;
    348      1.28    scottr 		if (sbc_ready(ncr_sc))
    349      1.23    scottr 			goto interrupt;
    350      1.23    scottr 		W4; W4; W4; W4;
    351      1.23    scottr 		W4; W4; W4; W4;
    352      1.23    scottr 		W4; W4; W4; W4;
    353      1.23    scottr 		W4; W4; W4;
    354      1.23    scottr 	}
    355      1.28    scottr 	while (resid) {
    356      1.28    scottr 		if (sbc_ready(ncr_sc))
    357      1.23    scottr 			goto interrupt;
    358      1.23    scottr 		W1;
    359      1.28    scottr 		resid--;
    360      1.23    scottr 	}
    361      1.23    scottr #undef  W1
    362      1.23    scottr #undef  W4
    363      1.28    scottr 	if (sbc_wait_dreq(ncr_sc))
    364      1.28    scottr 		printf("%s: timeout waiting for DREQ.\n",
    365      1.28    scottr 		    ncr_sc->sc_dev.dv_xname);
    366      1.28    scottr 
    367      1.28    scottr 	*byte_data = 0;
    368      1.28    scottr 	goto done;
    369       1.1    scottr 
    370      1.28    scottr interrupt:
    371      1.28    scottr 	if ((*ncr_sc->sci_csr & SCI_CSR_PHASE_MATCH) == 0) {
    372      1.28    scottr 		*ncr_sc->sci_icmd = icmd & ~SCI_ICMD_DATA;
    373      1.28    scottr 		--resid;
    374       1.1    scottr 	}
    375       1.1    scottr 
    376      1.28    scottr done:
    377       1.1    scottr 	SCI_CLR_INTR(ncr_sc);
    378       1.1    scottr 	*ncr_sc->sci_mode &= ~SCI_MODE_DMA;
    379      1.23    scottr 	*ncr_sc->sci_icmd = icmd;
    380      1.23    scottr 	splx(s);
    381      1.23    scottr 	return (datalen - resid);
    382       1.1    scottr }
    383       1.1    scottr 
    384       1.1    scottr 
    385       1.1    scottr /***
    386       1.1    scottr  * The following code implements interrupt-driven PDMA.
    387       1.1    scottr  ***/
    388       1.1    scottr 
    389       1.1    scottr /*
    390       1.1    scottr  * This is the meat of the PDMA transfer.
    391       1.1    scottr  * When we get here, we shove data as fast as the mac can take it.
    392       1.1    scottr  * We depend on several things:
    393       1.1    scottr  *   * All macs after the Mac Plus that have a 5380 chip should have a general
    394       1.1    scottr  *     logic IC that handshakes data for blind transfers.
    395       1.1    scottr  *   * If the SCSI controller finishes sending/receiving data before we do,
    396       1.1    scottr  *     the same general logic IC will generate a /BERR for us in short order.
    397       1.1    scottr  *   * The fault address for said /BERR minus the base address for the
    398       1.1    scottr  *     transfer will be the amount of data that was actually written.
    399       1.1    scottr  *
    400       1.1    scottr  * We use the nofault flag and the setjmp/longjmp in locore.s so we can
    401       1.1    scottr  * detect and handle the bus error for early termination of a command.
    402       1.1    scottr  * This is usually caused by a disconnecting target.
    403       1.1    scottr  */
    404       1.1    scottr void
    405       1.1    scottr sbc_drq_intr(p)
    406       1.1    scottr 	void *p;
    407       1.1    scottr {
    408      1.27    scottr 	extern int *nofault, m68k_fault_addr;
    409      1.24    scottr 	struct sbc_softc *sc = (struct sbc_softc *)p;
    410      1.24    scottr 	struct ncr5380_softc *ncr_sc = (struct ncr5380_softc *)p;
    411      1.23    scottr 	struct sci_req *sr = ncr_sc->sc_current;
    412      1.23    scottr 	struct sbc_pdma_handle *dh = sr->sr_dma_hand;
    413      1.23    scottr 	label_t faultbuf;
    414      1.23    scottr 	volatile u_int32_t *long_drq;
    415      1.23    scottr 	u_int32_t *long_data;
    416      1.23    scottr 	volatile u_int8_t *drq;
    417      1.23    scottr 	u_int8_t *data;
    418      1.23    scottr 	int count, dcount, resid;
    419      1.23    scottr 	u_int8_t tmp;
    420      1.26    scottr 
    421      1.26    scottr 	/* Work around lame gcc initialization bug */
    422      1.26    scottr 	(void)&drq;
    423       1.1    scottr 
    424       1.1    scottr 	/*
    425       1.1    scottr 	 * If we're not ready to xfer data, or have no more, just return.
    426       1.1    scottr 	 */
    427       1.3    scottr 	if ((*ncr_sc->sci_csr & SCI_CSR_DREQ) == 0 || dh->dh_len == 0)
    428       1.1    scottr 		return;
    429       1.1    scottr 
    430       1.1    scottr #ifdef SBC_DEBUG
    431       1.1    scottr 	if (sbc_debug & SBC_DB_INTR)
    432      1.13  christos 		printf("%s: drq intr, dh_len=0x%x, dh_flags=0x%x\n",
    433       1.1    scottr 		    ncr_sc->sc_dev.dv_xname, dh->dh_len, dh->dh_flags);
    434       1.1    scottr #endif
    435       1.1    scottr 
    436       1.1    scottr 	/*
    437       1.1    scottr 	 * Setup for a possible bus error caused by SCSI controller
    438       1.1    scottr 	 * switching out of DATA-IN/OUT before we're done with the
    439       1.1    scottr 	 * current transfer.
    440       1.1    scottr 	 */
    441      1.26    scottr 	nofault = (int *)&faultbuf;
    442       1.1    scottr 
    443      1.24    scottr 	if (setjmp((label_t *)nofault)) {
    444      1.26    scottr 		nofault = (int *)0;
    445       1.8    scottr 		if ((dh->dh_flags & SBC_DH_DONE) == 0) {
    446      1.27    scottr 			count = ((  (u_long)m68k_fault_addr
    447      1.24    scottr 				  - (u_long)sc->sc_drq_addr));
    448       1.8    scottr 
    449       1.8    scottr 			if ((count < 0) || (count > dh->dh_len)) {
    450      1.13  christos 				printf("%s: complete=0x%x (pending 0x%x)\n",
    451       1.8    scottr 				    ncr_sc->sc_dev.dv_xname, count, dh->dh_len);
    452       1.8    scottr 				panic("something is wrong");
    453       1.8    scottr 			}
    454       1.1    scottr 
    455       1.8    scottr 			dh->dh_addr += count;
    456       1.8    scottr 			dh->dh_len -= count;
    457      1.18    scottr 		} else
    458      1.18    scottr 			count = 0;
    459       1.8    scottr 
    460       1.1    scottr #ifdef SBC_DEBUG
    461       1.1    scottr 		if (sbc_debug & SBC_DB_INTR)
    462      1.13  christos 			printf("%s: drq /berr, complete=0x%x (pending 0x%x)\n",
    463       1.8    scottr 			   ncr_sc->sc_dev.dv_xname, count, dh->dh_len);
    464       1.1    scottr #endif
    465      1.27    scottr 		m68k_fault_addr = 0;
    466       1.3    scottr 
    467       1.1    scottr 		return;
    468       1.1    scottr 	}
    469       1.1    scottr 
    470       1.1    scottr 	if (dh->dh_flags & SBC_DH_OUT) { /* Data Out */
    471      1.26    scottr 		dcount = 0;
    472      1.26    scottr 
    473       1.1    scottr 		/*
    474       1.1    scottr 		 * Get the source address aligned.
    475       1.1    scottr 		 */
    476       1.6    scottr 		resid =
    477      1.24    scottr 		    count = min(dh->dh_len, 4 - (((int)dh->dh_addr) & 0x3));
    478       1.1    scottr 		if (count && count < 4) {
    479      1.24    scottr 			drq = (volatile u_int8_t *)sc->sc_drq_addr;
    480      1.24    scottr 			data = (u_int8_t *)dh->dh_addr;
    481       1.8    scottr 
    482       1.1    scottr #define W1		*drq++ = *data++
    483       1.1    scottr 			while (count) {
    484       1.1    scottr 				W1; count--;
    485       1.1    scottr 			}
    486       1.1    scottr #undef W1
    487       1.1    scottr 			dh->dh_addr += resid;
    488       1.1    scottr 			dh->dh_len -= resid;
    489       1.1    scottr 		}
    490       1.1    scottr 
    491       1.1    scottr 		/*
    492       1.8    scottr 		 * Start the transfer.
    493       1.1    scottr 		 */
    494       1.1    scottr 		while (dh->dh_len) {
    495       1.1    scottr 			dcount = count = min(dh->dh_len, MAX_DMA_LEN);
    496      1.24    scottr 			long_drq = (volatile u_int32_t *)sc->sc_drq_addr;
    497      1.24    scottr 			long_data = (u_int32_t *)dh->dh_addr;
    498       1.1    scottr 
    499       1.1    scottr #define W4		*long_drq++ = *long_data++
    500       1.1    scottr 			while (count >= 64) {
    501       1.1    scottr 				W4; W4; W4; W4; W4; W4; W4; W4;
    502       1.1    scottr 				W4; W4; W4; W4; W4; W4; W4; W4; /*  64 */
    503       1.1    scottr 				count -= 64;
    504       1.1    scottr 			}
    505       1.1    scottr 			while (count >= 4) {
    506       1.1    scottr 				W4; count -= 4;
    507       1.1    scottr 			}
    508       1.1    scottr #undef W4
    509      1.24    scottr 			data = (u_int8_t *)long_data;
    510      1.24    scottr 			drq = (u_int8_t *)long_drq;
    511       1.8    scottr 
    512       1.7    scottr #define W1		*drq++ = *data++
    513       1.7    scottr 			while (count) {
    514       1.7    scottr 				W1; count--;
    515       1.7    scottr 			}
    516       1.7    scottr #undef W1
    517       1.7    scottr 			dh->dh_len -= dcount;
    518       1.7    scottr 			dh->dh_addr += dcount;
    519       1.7    scottr 		}
    520       1.8    scottr 		dh->dh_flags |= SBC_DH_DONE;
    521       1.7    scottr 
    522       1.7    scottr 		/*
    523       1.8    scottr 		 * XXX -- Read a byte from the SBC to trigger a /BERR.
    524       1.8    scottr 		 * This seems to be necessary for us to notice that
    525       1.8    scottr 		 * the target has disconnected.  Ick.  06 jun 1996 (sr)
    526       1.7    scottr 		 */
    527      1.26    scottr 		if (dcount >= MAX_DMA_LEN)
    528      1.24    scottr 			drq = (volatile u_int8_t *)sc->sc_drq_addr;
    529       1.8    scottr 		tmp = *drq;
    530       1.1    scottr 	} else {	/* Data In */
    531       1.1    scottr 		/*
    532       1.1    scottr 		 * Get the dest address aligned.
    533       1.1    scottr 		 */
    534       1.6    scottr 		resid =
    535      1.24    scottr 		    count = min(dh->dh_len, 4 - (((int)dh->dh_addr) & 0x3));
    536       1.1    scottr 		if (count && count < 4) {
    537      1.24    scottr 			data = (u_int8_t *)dh->dh_addr;
    538      1.24    scottr 			drq = (volatile u_int8_t *)sc->sc_drq_addr;
    539       1.8    scottr 
    540       1.1    scottr #define R1		*data++ = *drq++
    541       1.1    scottr 			while (count) {
    542       1.1    scottr 				R1; count--;
    543       1.1    scottr 			}
    544       1.1    scottr #undef R1
    545       1.1    scottr 			dh->dh_addr += resid;
    546       1.1    scottr 			dh->dh_len -= resid;
    547       1.1    scottr 		}
    548       1.1    scottr 
    549       1.1    scottr 		/*
    550       1.8    scottr 		 * Start the transfer.
    551       1.1    scottr 		 */
    552       1.1    scottr 		while (dh->dh_len) {
    553       1.1    scottr 			dcount = count = min(dh->dh_len, MAX_DMA_LEN);
    554      1.24    scottr 			long_data = (u_int32_t *)dh->dh_addr;
    555      1.24    scottr 			long_drq = (volatile u_int32_t *)sc->sc_drq_addr;
    556       1.1    scottr 
    557       1.1    scottr #define R4		*long_data++ = *long_drq++
    558       1.8    scottr 			while (count >= 64) {
    559       1.1    scottr 				R4; R4; R4; R4; R4; R4; R4; R4;
    560       1.1    scottr 				R4; R4; R4; R4; R4; R4; R4; R4;	/* 64 */
    561       1.8    scottr 				count -= 64;
    562       1.1    scottr 			}
    563       1.1    scottr 			while (count >= 4) {
    564       1.1    scottr 				R4; count -= 4;
    565       1.1    scottr 			}
    566       1.1    scottr #undef R4
    567      1.24    scottr 			data = (u_int8_t *)long_data;
    568      1.24    scottr 			drq = (volatile u_int8_t *)long_drq;
    569       1.8    scottr 
    570       1.1    scottr #define R1		*data++ = *drq++
    571       1.1    scottr 			while (count) {
    572       1.1    scottr 				R1; count--;
    573       1.1    scottr 			}
    574       1.1    scottr #undef R1
    575       1.1    scottr 			dh->dh_len -= dcount;
    576       1.1    scottr 			dh->dh_addr += dcount;
    577       1.1    scottr 		}
    578       1.8    scottr 		dh->dh_flags |= SBC_DH_DONE;
    579       1.1    scottr 	}
    580       1.1    scottr 
    581       1.1    scottr 	/*
    582       1.1    scottr 	 * OK.  No bus error occurred above.  Clear the nofault flag
    583       1.1    scottr 	 * so we no longer short-circuit bus errors.
    584       1.1    scottr 	 */
    585      1.28    scottr 	nofault = (int *)0;
    586       1.7    scottr 
    587       1.7    scottr #ifdef SBC_DEBUG
    588       1.7    scottr 	if (sbc_debug & (SBC_DB_REG | SBC_DB_INTR))
    589      1.13  christos 		printf("%s: drq intr complete: csr=0x%x, bus_csr=0x%x\n",
    590       1.7    scottr 		    ncr_sc->sc_dev.dv_xname, *ncr_sc->sci_csr,
    591       1.7    scottr 		    *ncr_sc->sci_bus_csr);
    592       1.7    scottr #endif
    593       1.1    scottr }
    594       1.1    scottr 
    595       1.1    scottr void
    596       1.1    scottr sbc_dma_alloc(ncr_sc)
    597       1.1    scottr 	struct ncr5380_softc *ncr_sc;
    598       1.1    scottr {
    599      1.24    scottr 	struct sbc_softc *sc = (struct sbc_softc *)ncr_sc;
    600       1.1    scottr 	struct sci_req *sr = ncr_sc->sc_current;
    601  1.28.4.2   thorpej 	struct scsipi_xfer *xs = sr->sr_xs;
    602       1.1    scottr 	struct sbc_pdma_handle *dh;
    603       1.1    scottr 	int		i, xlen;
    604       1.1    scottr 
    605       1.6    scottr #ifdef DIAGNOSTIC
    606       1.1    scottr 	if (sr->sr_dma_hand != NULL)
    607       1.1    scottr 		panic("sbc_dma_alloc: already have PDMA handle");
    608       1.1    scottr #endif
    609       1.1    scottr 
    610       1.1    scottr 	/* Polled transfers shouldn't allocate a PDMA handle. */
    611       1.1    scottr 	if (sr->sr_flags & SR_IMMED)
    612       1.1    scottr 		return;
    613       1.1    scottr 
    614       1.1    scottr 	xlen = ncr_sc->sc_datalen;
    615       1.1    scottr 
    616       1.1    scottr 	/* Make sure our caller checked sc_min_dma_len. */
    617       1.1    scottr 	if (xlen < MIN_DMA_LEN)
    618       1.1    scottr 		panic("sbc_dma_alloc: len=0x%x\n", xlen);
    619       1.1    scottr 
    620       1.1    scottr 	/*
    621       1.1    scottr 	 * Find free PDMA handle.  Guaranteed to find one since we
    622       1.1    scottr 	 * have as many PDMA handles as the driver has processes.
    623       1.1    scottr 	 * (instances?)
    624       1.1    scottr 	 */
    625       1.1    scottr 	 for (i = 0; i < SCI_OPENINGS; i++) {
    626       1.1    scottr 		if ((sc->sc_pdma[i].dh_flags & SBC_DH_BUSY) == 0)
    627       1.1    scottr 			goto found;
    628       1.1    scottr 	}
    629       1.1    scottr 	panic("sbc: no free PDMA handles");
    630       1.1    scottr found:
    631       1.1    scottr 	dh = &sc->sc_pdma[i];
    632       1.1    scottr 	dh->dh_flags = SBC_DH_BUSY;
    633       1.1    scottr 	dh->dh_addr = ncr_sc->sc_dataptr;
    634       1.1    scottr 	dh->dh_len = xlen;
    635       1.1    scottr 
    636       1.1    scottr 	/* Copy the 'write' flag for convenience. */
    637       1.1    scottr 	if (xs->flags & SCSI_DATA_OUT)
    638       1.1    scottr 		dh->dh_flags |= SBC_DH_OUT;
    639       1.1    scottr 
    640       1.1    scottr 	sr->sr_dma_hand = dh;
    641       1.1    scottr }
    642       1.1    scottr 
    643       1.1    scottr void
    644       1.1    scottr sbc_dma_free(ncr_sc)
    645       1.1    scottr 	struct ncr5380_softc *ncr_sc;
    646       1.1    scottr {
    647       1.1    scottr 	struct sci_req *sr = ncr_sc->sc_current;
    648       1.1    scottr 	struct sbc_pdma_handle *dh = sr->sr_dma_hand;
    649       1.1    scottr 
    650       1.6    scottr #ifdef DIAGNOSTIC
    651       1.1    scottr 	if (sr->sr_dma_hand == NULL)
    652       1.1    scottr 		panic("sbc_dma_free: no DMA handle");
    653       1.1    scottr #endif
    654       1.1    scottr 
    655       1.1    scottr 	if (ncr_sc->sc_state & NCR_DOINGDMA)
    656       1.1    scottr 		panic("sbc_dma_free: free while in progress");
    657       1.1    scottr 
    658       1.1    scottr 	if (dh->dh_flags & SBC_DH_BUSY) {
    659       1.1    scottr 		dh->dh_flags = 0;
    660       1.1    scottr 		dh->dh_addr = NULL;
    661       1.1    scottr 		dh->dh_len = 0;
    662       1.1    scottr 	}
    663       1.1    scottr 	sr->sr_dma_hand = NULL;
    664       1.1    scottr }
    665       1.1    scottr 
    666       1.1    scottr void
    667       1.1    scottr sbc_dma_poll(ncr_sc)
    668       1.1    scottr 	struct ncr5380_softc *ncr_sc;
    669       1.1    scottr {
    670       1.1    scottr 	struct sci_req *sr = ncr_sc->sc_current;
    671       1.1    scottr 
    672       1.3    scottr 	/*
    673       1.3    scottr 	 * We shouldn't arrive here; if SR_IMMED is set, then
    674       1.3    scottr 	 * dma_alloc() should have refused to allocate a handle
    675       1.3    scottr 	 * for the transfer.  This forces the polled PDMA code
    676       1.3    scottr 	 * to handle the request...
    677       1.3    scottr 	 */
    678       1.6    scottr #ifdef SBC_DEBUG
    679       1.1    scottr 	if (sbc_debug & SBC_DB_DMA)
    680      1.13  christos 		printf("%s: lost DRQ interrupt?\n", ncr_sc->sc_dev.dv_xname);
    681       1.1    scottr #endif
    682       1.3    scottr 	sr->sr_flags |= SR_OVERDUE;
    683       1.1    scottr }
    684       1.1    scottr 
    685       1.1    scottr void
    686       1.1    scottr sbc_dma_setup(ncr_sc)
    687       1.1    scottr 	struct ncr5380_softc *ncr_sc;
    688       1.1    scottr {
    689       1.1    scottr 	/* Not needed; we don't have real DMA */
    690       1.1    scottr }
    691       1.1    scottr 
    692       1.1    scottr void
    693       1.1    scottr sbc_dma_start(ncr_sc)
    694       1.1    scottr 	struct ncr5380_softc *ncr_sc;
    695       1.1    scottr {
    696      1.24    scottr 	struct sbc_softc *sc = (struct sbc_softc *)ncr_sc;
    697       1.1    scottr 	struct sci_req *sr = ncr_sc->sc_current;
    698       1.1    scottr 	struct sbc_pdma_handle *dh = sr->sr_dma_hand;
    699       1.1    scottr 
    700       1.1    scottr 	/*
    701       1.7    scottr 	 * Match bus phase, clear pending interrupts, set DMA mode, and
    702       1.7    scottr 	 * assert data bus (for writing only), then start the transfer.
    703       1.1    scottr 	 */
    704       1.1    scottr 	if (dh->dh_flags & SBC_DH_OUT) {
    705       1.1    scottr 		*ncr_sc->sci_tcmd = PHASE_DATA_OUT;
    706       1.1    scottr 		SCI_CLR_INTR(ncr_sc);
    707      1.22    scottr 		if (sc->sc_clrintr)
    708      1.22    scottr 			(*sc->sc_clrintr)(ncr_sc);
    709       1.1    scottr 		*ncr_sc->sci_mode |= SCI_MODE_DMA;
    710       1.1    scottr 		*ncr_sc->sci_icmd = SCI_ICMD_DATA;
    711       1.1    scottr 		*ncr_sc->sci_dma_send = 0;
    712       1.1    scottr 	} else {
    713       1.1    scottr 		*ncr_sc->sci_tcmd = PHASE_DATA_IN;
    714       1.1    scottr 		SCI_CLR_INTR(ncr_sc);
    715      1.22    scottr 		if (sc->sc_clrintr)
    716      1.22    scottr 			(*sc->sc_clrintr)(ncr_sc);
    717       1.1    scottr 		*ncr_sc->sci_mode |= SCI_MODE_DMA;
    718       1.1    scottr 		*ncr_sc->sci_icmd = 0;
    719       1.1    scottr 		*ncr_sc->sci_irecv = 0;
    720       1.1    scottr 	}
    721       1.3    scottr 	ncr_sc->sc_state |= NCR_DOINGDMA;
    722       1.1    scottr 
    723       1.6    scottr #ifdef SBC_DEBUG
    724       1.1    scottr 	if (sbc_debug & SBC_DB_DMA)
    725      1.13  christos 		printf("%s: PDMA started, va=%p, len=0x%x\n",
    726       1.1    scottr 		    ncr_sc->sc_dev.dv_xname, dh->dh_addr, dh->dh_len);
    727       1.1    scottr #endif
    728       1.1    scottr }
    729       1.1    scottr 
    730       1.1    scottr void
    731       1.1    scottr sbc_dma_eop(ncr_sc)
    732       1.1    scottr 	struct ncr5380_softc *ncr_sc;
    733       1.1    scottr {
    734       1.1    scottr 	/* Not used; the EOP pin is wired high (GMFH, pp. 389-390) */
    735       1.1    scottr }
    736       1.1    scottr 
    737       1.1    scottr void
    738       1.1    scottr sbc_dma_stop(ncr_sc)
    739       1.1    scottr 	struct ncr5380_softc *ncr_sc;
    740       1.1    scottr {
    741      1.24    scottr 	struct sbc_softc *sc = (struct sbc_softc *)ncr_sc;
    742       1.1    scottr 	struct sci_req *sr = ncr_sc->sc_current;
    743       1.1    scottr 	struct sbc_pdma_handle *dh = sr->sr_dma_hand;
    744      1.23    scottr 	int ntrans;
    745       1.1    scottr 
    746       1.1    scottr 	if ((ncr_sc->sc_state & NCR_DOINGDMA) == 0) {
    747       1.1    scottr #ifdef SBC_DEBUG
    748       1.1    scottr 		if (sbc_debug & SBC_DB_DMA)
    749      1.13  christos 			printf("%s: dma_stop: DMA not running\n",
    750       1.1    scottr 			    ncr_sc->sc_dev.dv_xname);
    751       1.1    scottr #endif
    752       1.1    scottr 		return;
    753       1.1    scottr 	}
    754       1.1    scottr 	ncr_sc->sc_state &= ~NCR_DOINGDMA;
    755       1.1    scottr 
    756       1.3    scottr 	if ((ncr_sc->sc_state & NCR_ABORTING) == 0) {
    757       1.1    scottr 		ntrans = ncr_sc->sc_datalen - dh->dh_len;
    758       1.1    scottr 
    759       1.1    scottr #ifdef SBC_DEBUG
    760       1.1    scottr 		if (sbc_debug & SBC_DB_DMA)
    761      1.13  christos 			printf("%s: dma_stop: ntrans=0x%x\n",
    762       1.1    scottr 			    ncr_sc->sc_dev.dv_xname, ntrans);
    763       1.1    scottr #endif
    764       1.1    scottr 
    765       1.1    scottr 		if (ntrans > ncr_sc->sc_datalen)
    766       1.1    scottr 			panic("sbc_dma_stop: excess transfer\n");
    767       1.1    scottr 
    768       1.1    scottr 		/* Adjust data pointer */
    769       1.1    scottr 		ncr_sc->sc_dataptr += ntrans;
    770       1.1    scottr 		ncr_sc->sc_datalen -= ntrans;
    771       1.1    scottr 
    772       1.1    scottr 		/* Clear any pending interrupts. */
    773       1.1    scottr 		SCI_CLR_INTR(ncr_sc);
    774      1.22    scottr 		if (sc->sc_clrintr)
    775      1.22    scottr 			(*sc->sc_clrintr)(ncr_sc);
    776       1.1    scottr 	}
    777       1.1    scottr 
    778       1.1    scottr 	/* Put SBIC back into PIO mode. */
    779       1.1    scottr 	*ncr_sc->sci_mode &= ~SCI_MODE_DMA;
    780       1.1    scottr 	*ncr_sc->sci_icmd = 0;
    781       1.1    scottr 
    782       1.1    scottr #ifdef SBC_DEBUG
    783       1.3    scottr 	if (sbc_debug & SBC_DB_REG)
    784      1.13  christos 		printf("%s: dma_stop: csr=0x%x, bus_csr=0x%x\n",
    785       1.1    scottr 		    ncr_sc->sc_dev.dv_xname, *ncr_sc->sci_csr,
    786       1.1    scottr 		    *ncr_sc->sci_bus_csr);
    787       1.1    scottr #endif
    788       1.1    scottr }
    789