Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 10 Mar 1998 15:56:19 -0800 (PST)
From:      nsayer@quack.kfu.com
To:        FreeBSD-gnats-submit@FreeBSD.ORG
Subject:   kern/5971: SI patch for -current
Message-ID:  <199803102356.PAA27763@zephyr.specialix.com>

next in thread | raw e-mail | index | archive | help

>Number:         5971
>Category:       kern
>Synopsis:       SI patch for -current
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Quarter:
>Keywords:
>Date-Required:
>Class:          support
>Submitter-Id:   current-users
>Arrival-Date:   Tue Mar 10 16:00:01 PST 1998
>Last-Modified:
>Originator:     Nick Sayer
>Organization:
Specialix, Inc.
>Release:        FreeBSD-current i386
>Environment:

Specialix SI/XIO or SX host card setup.

>Description:

This patch is against the -current version of the si driver.
It...

1. Fixes some bugs in the SX ISA interrupt setup.
2. Changes the names of the download code objects. This is required to fit in
   with the new naming structure for the objects supplied by Specialix.
3. Fixes some bugs in and adds support for SXDC in the MTA probing code.
4. Fixes problems the driver had with some versions of the host card
   that can't handle non 8-bit I/O. The driver now funnels all bcopy calls
   into a conditional bit of code that can either use traditional bcopy
   or an 8 bit loop.
5. Turns off the default CRTSCTS setting to make these ports act more like
   regular ports. Use the ttyi__ and/or ttyl__ devices to force things.
6. Other miscelaneous fixes having to do with the SX (aka Jet) cards.

>How-To-Repeat:

>Fix:

1. Rename si_code.c to si2_z280.c.
2. Rename si_jet.c to si3_t225.c.
3. Make the same changes in /sys/i386/conf/files.i386. These changes
make the filenames the same as the equivalent files for Specialix drivers.
4. Apply the patch below.
5. Whoever does this should get the latest copies of si?_????.c from me,
since they will probably have been updated by the time this gets read. :-/

--- si.c.orig	Tue Mar 10 15:08:35 1998
+++ si.c	Tue Mar 10 15:45:10 1998
@@ -30,11 +30,11 @@
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
  * NO EVENT SHALL THE AUTHORS BE LIABLE.
  *
- *	$Id: si.c,v 1.67 1998/02/15 14:42:33 peter Exp $
+ *	$Id: si.c,v 1.67 1998/03/10 14:42:33 nsayer Exp $
  */
 
 #ifndef lint
-static const char si_copyright1[] =  "@(#) (C) Specialix International, 1990,1992",
+static const char si_copyright1[] =  "@(#) (C) Specialix International, 1990,1992,1998",
                   si_copyright2[] =  "@(#) (C) Andy Rutter 1993",
                   si_copyright3[] =  "@(#) (C) Peter Wemm 1995";
 #endif	/* not lint */
@@ -94,9 +94,10 @@
 #define	POLL		/* turn on poller to scan for lost interrupts */
 #define REALPOLL	/* on each poll, scan for work regardless */
 #define POLLHZ	(hz/10)	/* 10 times per second */
-#define SI_DEF_HWFLOW	/* turn on default CRTSCTS flow control */
+#undef SI_DEF_HWFLOW	/* turn on default CRTSCTS flow control */
 #define SI_I_HIGH_WATER	(TTYHOG - 2 * SI_BUFFERSIZE)
-#define INT_COUNT 25000	/* max of 125 ints per second */
+#define INT_COUNT 25000		/* max of 125 ints per second */
+#define JET_INT_COUNT 100	/* max of 100 ints per second */
 #define RXINT_COUNT 1	/* one rxint per 10 milliseconds */
 
 enum si_mctl { GET, SET, BIS, BIC };
@@ -177,18 +178,22 @@
 static int si_Nmodules;
 static int si_debug = 0;	/* data, not bss, so it's patchable */
 
+SYSCTL_INT(_machdep, OID_AUTO, si_debug, CTLFLAG_RW, &si_debug, 0, "");
+
 static struct tty *si_tty;
 
-/* where the firmware lives; defined in si_code.c and si_jet.c */
-/* old: si_code.c */
-extern int si_dsize;
-extern unsigned char si_download[];
-/* new: si_jet.c */
-extern int si3_dsize;
-extern unsigned char si3_download[];
-extern unsigned short si3_bootloadaddr;
-extern int si3_bsize;
-extern unsigned char si3_bootstrap[];
+/* where the firmware lives; defined in si2_z280.c and si3_t225.c */
+/* old: si2_z280.c */
+extern unsigned char si2_z280_download[];
+extern unsigned short si2_z280_downloadaddr;
+extern int si2_z280_dsize;
+/* new: si3_t225.c */
++extern unsigned char si3_t225_download[];
++extern unsigned short si3_t225_downloadaddr;
++extern int si3_t225_dsize;
++extern unsigned char si3_t225_bootstrap[];
++extern unsigned short si3_t225_bootloadaddr;
++extern int si3_t225_bsize;
 
 
 struct si_softc {
@@ -586,7 +591,7 @@
 		if ((id->id_irq&(IRQ9|IRQ10|IRQ11|IRQ12|IRQ15)) == 0) {
 			goto bad_irq;
 		}
-		id->id_msize = SIJET_MEMSIZE;
+		id->id_msize = SIJETISA_MEMSIZE;
 		break;
 	case SIEISA:
 		id->id_msize = SIEISA_MEMSIZE;
@@ -602,6 +607,22 @@
 }
 
 /*
+ * We have to make an 8 bit version of bcopy, since some cards can't
+ * deal with 32 bit I/O
+ */
+#if 1
+static void
+si_bcopy(const void *src, void *dst, size_t len)
+{
+	while(len--)
+		*(((u_char *)dst)++)=*(((u_char *)src)++);
+}
+#else
+#define si_bcopy bcopy
+#endif
+
+
+/*
  * Attach the device.  Initialize the card.
  */
 static int
@@ -636,40 +657,32 @@
 	/*
 	 * OK, now lets download the firmware and try and boot the CPU..
 	 *
-	 * You can't use bcopy, since some cards won't take 32 bit writes.
 	 */
 	if ((sc->sc_type == SIJETISA) || (sc->sc_type == SIJETPCI))
 	{
 		DPRINT((0, DBG_DOWNLOAD, "si%d: jet_download: nbytes %d\n",
-			id->id_unit, si3_dsize));
-		{
-			u_int i;
-			for (i=0;i<si3_dsize;i++)
-				maddr[i]=si3_download[i];
-		}
+			id->id_unit, si3_t225_dsize));
+		si_bcopy(si3_t225_download,maddr+si3_t225_downloadaddr,si3_t225_
+
 		DPRINT((0, DBG_DOWNLOAD, "si%d: jet_bootstrap: nbytes %d -> %x\n",
-			id->id_unit, si3_bsize, si3_bootloadaddr));
-		{
-			u_int i;
-			for (i=0;i<si3_bsize;i++)
-				maddr[i+si3_bootloadaddr]=si3_bootstrap[i];
-		}
+			id->id_unit, si3_t225_bsize, si3_t225_bootloadaddr));
+		si_bcopy(si3_t225_bootstrap,maddr+si3_t225_bootloadaddr,
+			si3_t225_bsize);
+
 	}
 	else
 	{
 		DPRINT((0, DBG_DOWNLOAD, "si%d: si_download: nbytes %d\n",
-			id->id_unit, si_dsize));
-		{
-			u_int i;
-			for (i=0;i<si_dsize;i++)
-				maddr[i]=si_download[i];
-		}
+			id->id_unit, si2_z280_dsize));
+		si_bcopy(si2_z280_download,maddr+si2_z280_downloadaddr,
+			si2_z280_dsize);
+
 	}
 
 	switch (sc->sc_type) {
 	case SIEISA:
 #if NEISA > 0
-		/* modify the Z280 firmware to tell it that it's on an EISA */
+		/* modify the download code to tell it that it's on an EISA */
 		*(maddr+0x42) = 1;
 		outb(sc->sc_eisa_iobase+2, sc->sc_eisa_irqbits | 4);
 		(void)inb(sc->sc_eisa_iobase+3); /* reset interrupt */
@@ -682,7 +695,7 @@
 		 */
 		return 0;
 	case SIPCI:
-		/* modify the Z280 firmware to tell it that it's on a PCI */
+		/* modify the download code to tell it that it's on an EISA */
 		*(maddr+0x42) = 1;
 		*(maddr+SIPCIRESET) = 1;
 		*(maddr+SIPCIINTCL) = 0;
@@ -693,7 +706,24 @@
 		break;
 	case SIJETISA:
 		*(maddr+SIJETRESET) = 0;
-		*(maddr+SIJETCONFIG) = SIJETBUSEN|SIJETIRQEN|(sc->sc_irq<<4);
+		switch (sc->sc_irq) {
+		case IRQ9:
+			*(maddr+SIJETCONFIG) = SIJETBUSEN|SIJETIRQEN|0x90;
+			break;
+		case IRQ10:
+			*(maddr+SIJETCONFIG) = SIJETBUSEN|SIJETIRQEN|0xa0;
+			break;
+		case IRQ11:
+			*(maddr+SIJETCONFIG) = SIJETBUSEN|SIJETIRQEN|0xb0;
+			break;
+		case IRQ12:
+			*(maddr+SIJETCONFIG) = SIJETBUSEN|SIJETIRQEN|0xc0;
+			break;
+		case IRQ15:
+			*(maddr+SIJETCONFIG) = SIJETBUSEN|SIJETIRQEN|0xf0;
+			break;
+		}
+
 		break;
 	case SIHOST:
 		*(maddr+SIRESET_CL) = 0;
@@ -730,10 +760,16 @@
 		sc->sc_type = SIEMPTY;
 		return 0;
 	case 1:
-			/* set throttle to 125 intr per second */
-		regp->int_count = INT_COUNT;
-			/* rx intr max of 25 timer per second */
-		regp->rx_int_count = RXINT_COUNT;
+		if ((sc->sc_type == SIJETISA) || (sc->sc_type == SIJETPCI)) {
+				/* set throttle to 100 times per second */
+			regp->int_count = JET_INT_COUNT;
+				/* rx_intr_count is a NOP in Jet */
+		} else {
+				/* set throttle to 125 times per second */
+			regp->int_count = INT_COUNT;
+				/* rx intr max of 25 times per second */
+			regp->rx_int_count = RXINT_COUNT;
+		}
 		regp->int_pending = 0;		/* no intr pending */
 		regp->int_scounter = 0;	/* reset counter */
 		break;
@@ -745,7 +781,7 @@
 			si_type[sc->sc_type]);
 		return 0;
 	default:
-		printf("si%d: Z280 version error - initstat %x\n",
+		printf("si%d: download code version error - initstat %x\n",
 			unit, regp->initstat);
 		return 0;
 	}
@@ -758,29 +794,60 @@
 	modp = (struct si_module *)(maddr + 0x80);
 	for (;;) {
 		DPRINT((0, DBG_DOWNLOAD, "si%d: ccb addr 0x%x\n", unit, modp));
-		switch (modp->sm_type & (~MMASK)) {
-		case M232:
-		case M422:
+		switch (modp->sm_type) {
+		case TA4:
 			DPRINT((0, DBG_DOWNLOAD,
-				"si%d: Found 232/422 module, %d ports\n",
-				unit, (int)(modp->sm_type & MMASK)));
-
-			/* this is a firmware issue */
-			if (si_Nports == SI_MAXPORTPERCARD) {
-				printf("si%d: extra ports ignored\n", unit);
-				continue;
-			}
-
-			x = modp->sm_type & MMASK;
-			nport += x;
-			si_Nports += x;
-			si_Nmodules++;
+				"si%d: Found old TA4 module, 4 ports\n",
+				unit));
+			x = 4;
+			break;
+		case TA8:
+			DPRINT((0, DBG_DOWNLOAD,
+				"si%d: Found old TA8 module, 8 ports\n",
+				unit));
+			x = 8;
+			break;
+		case TA4_ASIC:
+			DPRINT((0, DBG_DOWNLOAD,
+				"si%d: Found ASIC TA4 module, 4 ports\n",
+				unit));
+			x = 4;
+			break;
+		case TA8_ASIC:
+			DPRINT((0, DBG_DOWNLOAD,
+				"si%d: Found ASIC TA8 module, 8 ports\n",
+				unit));
+			x = 8;
+			break;
+		case MTA:
+			DPRINT((0, DBG_DOWNLOAD,
+				"si%d: Found CD1400 module, 8 ports\n",
+				unit));
+			x = 8;
+			break;
+		case SXDC:
+			DPRINT((0, DBG_DOWNLOAD,
+				"si%d: Found SXDC module, 8 ports\n",
+				unit));
+			x = 8;
 			break;
 		default:
 			printf("si%d: unknown module type %d\n",
 				unit, modp->sm_type);
-			break;
+			goto try_next;
+
+		}
+		/* this is a firmware issue */
+		if (si_Nports == SI_MAXPORTPERCARD) {
+			printf("si%d: extra ports ignored\n", unit);
+			goto try_next;
 		}
+
+		nport += x;
+		si_Nports += x;
+		si_Nmodules++;
+
+try_next:
 		if (modp->sm_next == 0)
 			break;
 		modp = (struct si_module *)
@@ -814,33 +881,40 @@
 	modp = (struct si_module *)(maddr + 0x80);
 	uart_type = 0;
 	for (;;) {
-		switch (modp->sm_type & (~MMASK)) {
-		case M232:
-		case M422:
-			nmodule++;
-			nport = (modp->sm_type & MMASK);
-			ccbp = (struct si_channel *)((char *)modp+0x100);
-			if (uart_type == 0)
-				uart_type = ccbp->type;
-			for (x = 0; x < nport; x++, pp++, ccbp++) {
-				pp->sp_ccb = ccbp;	/* save the address */
-				pp->sp_tty = tp++;
-				pp->sp_pend = IDLE_CLOSE;
-				pp->sp_state = 0;	/* internal flag */
-				pp->sp_dtr_wait = 3 * hz;
-				pp->sp_iin.c_iflag = si_default_iflag;
-				pp->sp_iin.c_oflag = si_default_oflag;
-				pp->sp_iin.c_cflag = si_default_cflag;
-				pp->sp_iin.c_lflag = si_default_lflag;
-				termioschars(&pp->sp_iin);
-				pp->sp_iin.c_ispeed = pp->sp_iin.c_ospeed =
-					si_default_rate;
-				pp->sp_iout = pp->sp_iin;
-			}
+		switch (modp->sm_type) {
+		case TA4: nport = 4;
 			break;
-		default:
+		case TA8: nport = 8;
+			break;
+		case TA4_ASIC: nport = 4;
 			break;
+		case TA8_ASIC: nport = 8;
+			break;
+		case MTA: nport = 8;
+			break;
+		case SXDC: nport = 8;
+			break;
+		default: goto try_next2;
+		}
+		ccbp = (struct si_channel *)((char *)modp+0x100);
+		if (uart_type == 0)
+			uart_type = ccbp->type;
+		for (x = 0; x < nport; x++, pp++, ccbp++) {
+			pp->sp_ccb = ccbp;	/* save the address */
+			pp->sp_tty = tp++;
+			pp->sp_pend = IDLE_CLOSE;
+			pp->sp_state = 0;	/* internal flag */
+			pp->sp_dtr_wait = 3 * hz;
+			pp->sp_iin.c_iflag = si_default_iflag;
+			pp->sp_iin.c_oflag = si_default_oflag;
+			pp->sp_iin.c_cflag = si_default_cflag;
+			pp->sp_iin.c_lflag = si_default_lflag;
+			termioschars(&pp->sp_iin);
+			pp->sp_iin.c_ispeed = pp->sp_iin.c_ospeed =
+				si_default_rate;
+			pp->sp_iout = pp->sp_iin;
 		}
+try_next2:
 		if (modp->sm_next == 0) {
 			printf("si%d: card: %s, ports: %d, modules: %d (type: %d)\n",
 				unit,
@@ -1554,15 +1628,15 @@
 	/* these next three use a different structure */
 	case TCSI_PORT:
 		SUCHECK;
-		bcopy(xpp, &sps->tc_siport, sizeof(sps->tc_siport));
+		si_bcopy(xpp, &sps->tc_siport, sizeof(sps->tc_siport));
 		break;
 	case TCSI_CCB:
 		SUCHECK;
-		bcopy((char *)xpp->sp_ccb, &sps->tc_ccb, sizeof(sps->tc_ccb));
+		si_bcopy((char *)xpp->sp_ccb, &sps->tc_ccb, sizeof(sps->tc_ccb));
 		break;
 	case TCSI_TTY:
 		SUCHECK;
-		bcopy(xpp->sp_tty, &sps->tc_tty, sizeof(sps->tc_tty));
+		si_bcopy(xpp->sp_tty, &sps->tc_tty, sizeof(sps->tc_tty));
 		break;
 	default:
 		error = EINVAL;
@@ -1601,6 +1675,7 @@
 		oflag, cflag, iflag, lflag));
 
 
+	/* XXX - if Jet host and SXDC module, use extended baud rates */
 	/* if not hung up.. */
 	if (t->c_ospeed != 0) {
 		/* translate baud rate to firmware values */
@@ -1917,6 +1992,7 @@
  */
 
 static BYTE si_rxbuf[SI_BUFFERSIZE];	/* input staging area */
+static BYTE si_txbuf[SI_BUFFERSIZE];	/* output staging area */
 
 void
 siintr(int unit)
@@ -1935,9 +2011,11 @@
 	DPRINT((0, (unit < 0) ? DBG_POLL:DBG_INTR, "siintr(%d)\n", unit));
 	if (in_intr) {
 		if (unit < 0)	/* should never happen */
-			return;
-		printf("si%d: Warning interrupt handler re-entered\n",
-			unit);
+			printf("si%d: WARNING poll entered during interrupt\n",
+				unit);
+		else
+			printf("si%d: WARNING interrupt handler re-entered\n",
+				unit);
 		return;
 	}
 	in_intr = 1;
@@ -2037,7 +2115,7 @@
 			si_modem_state(pp, tp, ccbp->hi_ip);
 
 			/*
-			 * Check to see if there's we should 'receive'
+			 * Check to see if we should 'receive'
 			 * characters.
 			 */
 			if (tp->t_state & TS_CONNECTED &&
@@ -2110,7 +2188,7 @@
 
 				DPRINT((pp, DBG_INTR, "\tsingle copy\n"));
 				z = ccbp->hi_rxbuf + op;
-				bcopy((caddr_t)z, si_rxbuf, n);
+				si_bcopy((caddr_t)z, si_rxbuf, n);
 
 				op += n;
 			} else {
@@ -2118,11 +2196,11 @@
 
 				DPRINT((pp, DBG_INTR, "\tdouble part 1 %d\n", x));
 				z = ccbp->hi_rxbuf + op;
-				bcopy((caddr_t)z, si_rxbuf, x);
+				si_bcopy((caddr_t)z, si_rxbuf, x);
 
 				DPRINT((pp, DBG_INTR, "\tdouble part 2 %d\n", n-x));
 				z = ccbp->hi_rxbuf;
-				bcopy((caddr_t)z, si_rxbuf+x, n-x);
+				si_bcopy((caddr_t)z, si_rxbuf+x, n-x);
 
 				op += n;
 			}
@@ -2266,19 +2344,17 @@
 		}
 		amount = min(nchar, (255 - (BYTE)count));
 		ipos = (unsigned int)ccbp->hi_txipos;
+		n = q_to_b(&tp->t_outq, si_txbuf, amount);
 		/* will it fit in one lump? */
-		if ((SI_BUFFERSIZE - ipos) >= amount) {
-			n = q_to_b(&tp->t_outq,
-				(char *)&ccbp->hi_txbuf[ipos], amount);
+		if ((SI_BUFFERSIZE - ipos) >= n) {
+			si_bcopy(si_txbuf, (char *)&ccbp->hi_txbuf[ipos], n);
 		} else {
-			n = q_to_b(&tp->t_outq,
-				(char *)&ccbp->hi_txbuf[ipos],
+			si_bcopy(si_txbuf, (char *)&ccbp->hi_txbuf[ipos],
 				SI_BUFFERSIZE-ipos);
-			if (n == SI_BUFFERSIZE-ipos) {
-				n += q_to_b(&tp->t_outq,
-					(char *)&ccbp->hi_txbuf[0],
-					amount - (SI_BUFFERSIZE-ipos));
-			}
+			si_bcopy(si_txbuf+(SI_BUFFERSIZE-ipos),
+				(char *)&ccbp->hi_txbuf[0],
+				n-(SI_BUFFERSIZE-ipos));
+
 		}
 		ccbp->hi_txipos += n;
 		count = (int)ccbp->hi_txipos - (int)ccbp->hi_txopos;
@@ -2406,7 +2482,7 @@
 }
 
 /*
- * Issue a command to the Z280 host card CPU.
+ * Issue a command to the host card CPU.
  */
 
 static void
>Audit-Trail:
>Unformatted:

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199803102356.PAA27763>