Subject: Re: dump and tar problems
To: Daniel Senderowicz <daniel@synchrods.synchrods.COM>
From: Simon Burge <simonb@netbsd.org>
List: port-pmax
Date: 12/30/1999 15:57:32
Daniel Senderowicz wrote:

> [ dump problems ]

You need an up-to-date sys/dev/tc/asc_ioasic.c - either rev 1.15.2.1 of
the 1.4 branch or rev 1.18 for NetBSD-current.  The pre-release 1.4.2
snapshot in pub/arch/pmax/snapshot/1.4.2_ALPHA on ftp.netbsd.org has
this patch applied.  I've included a diff that should apply to a stock
1.4.1 kernel below.

Simon.
--

Index: asc_ioasic.c
===================================================================
RCS file: /cvsroot/syssrc/sys/dev/tc/asc_ioasic.c,v
retrieving revision 1.15
retrieving revision 1.15.2.1
diff -p -u -r1.15 -r1.15.2.1
--- asc_ioasic.c	1999/01/16 06:36:42	1.15
+++ asc_ioasic.c	1999/12/04 20:32:11	1.15.2.1
@@ -1,4 +1,4 @@
-/*	$NetBSD: asc_ioasic.c,v 1.15 1999/01/16 06:36:42 nisimura Exp $	*/
+/*	$NetBSD: asc_ioasic.c,v 1.15.2.1 1999/12/04 20:32:11 he Exp $	*/
 
 /*
  * Copyright 1996 The Board of Trustees of The Leland Stanford
@@ -148,6 +148,22 @@ asic_dma_start(asc, state, cp, flag, len
 	if (len > ((caddr_t)mips_trunc_page(cp + NBPG * 2) - cp))
 		len = (caddr_t)mips_trunc_page(cp + NBPG * 2) - cp;
 
+	if ((vaddr_t)cp & 7) {
+		u_int32_t *p;
+		u_int32_t scrval;
+
+		p = (u_int32_t *)((vaddr_t)cp & ~7);
+		*((volatile u_int32_t *)IOASIC_REG_SCSI_SDR0(ioasic_base)) = p[0];
+		*((volatile u_int32_t *)IOASIC_REG_SCSI_SDR1(ioasic_base)) = p[1];
+		scrval = ((vaddr_t)cp >> 1) & 3;
+		cp = (caddr_t)((vaddr_t)cp & ~7);
+		if (flag != ASCDMA_READ) {
+			scrval |= 4;
+			cp += 8;
+		}
+		*((volatile int *)IOASIC_REG_SCSI_SCR(ioasic_base)) = scrval;
+	}
+
 	/* If R4K, writeback and invalidate  the buffer */
 	if (CPUISMIPS3)
 		mips3_HitFlushDCache((vaddr_t)cp, len);
@@ -199,7 +215,6 @@ asic_dma_end(asc, state, flag)
 	register volatile u_int *dmap = (volatile u_int *)
 		IOASIC_REG_SCSI_DMAPTR(ioasic_base);
 	register u_short *to;
-	register int w;
 	int nb;
 
 	*ssr &= ~IOASIC_CSR_DMAEN_SCSI;
@@ -226,19 +241,13 @@ asic_dma_end(asc, state, flag)
 			    state->dmalen);
 #endif	/* USE_CACHED_BUFFER */
 		if ( (nb = *((int *)IOASIC_REG_SCSI_SCR(ioasic_base))) != 0) {
-			/* pick up last upto6 bytes, sigh. */
-	
-			/* Last byte really xferred is.. */
-			w = *(int *)IOASIC_REG_SCSI_SDR0(ioasic_base);
-			*to++ = w;
-			if (--nb > 0) {
-				w >>= 16;
-				*to++ = w;
-			}
-			if (--nb > 0) {
-				w = *(int *)IOASIC_REG_SCSI_SDR1(ioasic_base);
-				*to++ = w;
-			}
+			int sdr[2];
+			/* pick up last upto 6 bytes, sigh. */
+
+			/* Copy untransferred data from IOASIC */
+			sdr[0] = *(int *)IOASIC_REG_SCSI_SDR0(ioasic_base);
+			sdr[1] = *(int *)IOASIC_REG_SCSI_SDR1(ioasic_base);
+			memcpy(to, (char *)sdr, nb * 2);
 		}
 	}
 }