Module Name:    src
Committed By:   martin
Date:           Sun Feb 12 12:22:44 UTC 2023

Modified Files:
        src/sys/arch/next68k/stand/boot [netbsd-9]: Makefile README devopen.c
            dmareg.h machdep.c rtc.c scsi.c sd.c srt0.s version

Log Message:
Pull up following revision(s) (requested by tsutsui in ticket #1591):

        sys/arch/next68k/stand/boot/scsi.c: revision 1.11
        sys/arch/next68k/stand/boot/sd.c: revision 1.13
        sys/arch/next68k/stand/boot/scsi.c: revision 1.12
        sys/arch/next68k/stand/boot/sd.c: revision 1.14
        sys/arch/next68k/stand/boot/sd.c: revision 1.15
        sys/arch/next68k/stand/boot/sd.c: revision 1.16
        sys/arch/next68k/stand/boot/rtc.c: revision 1.7
        sys/arch/next68k/stand/boot/dmareg.h: revision 1.4
        sys/arch/next68k/stand/boot/machdep.c: revision 1.8
        sys/arch/next68k/stand/boot/srt0.s: revision 1.3
        sys/arch/next68k/stand/boot/README: revision 1.2
        sys/arch/next68k/stand/boot/devopen.c: revision 1.7
        sys/arch/next68k/stand/boot/Makefile: revision 1.30
        sys/arch/next68k/stand/boot/Makefile: revision 1.31
        sys/arch/next68k/stand/boot/version: revision 1.5

Remove trailing spaces and TABs.

Make sure to specify volatile explicitly on DMA register accesses.

It looks booting from SCSI disks on next68k have been broken
since NetBSD 1.6 days, but now it works.

Avoid possible division by zero trap in error cases to make debug easier.

Request only 36 bytes for a response of INQUIRY command for legacy drives.
Some drives don't respond larger requested size for newer
SCSI3 devices and not all drivers can handle short xfers.
We should fix drivers to handle such short xfers properly,
but we need only SCSI device type here (and the 36 bytes are
enough even if we want vendor and product names on a bootloader).
The problem is reported from Andreas Grabher (a maintainer of NeXT
Computer Emulator) on port-next68k@:
 https://mail-index.netbsd.org/port-next68k/2023/02/thread1.html

Disable DEBUG options properly.

Bump version to 1.6 to denote recent bootloader's >20 years old bug fixes.


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.29.18.1 src/sys/arch/next68k/stand/boot/Makefile
cvs rdiff -u -r1.1.1.1 -r1.1.1.1.242.1 src/sys/arch/next68k/stand/boot/README
cvs rdiff -u -r1.6 -r1.6.32.1 src/sys/arch/next68k/stand/boot/devopen.c
cvs rdiff -u -r1.3 -r1.3.202.1 src/sys/arch/next68k/stand/boot/dmareg.h
cvs rdiff -u -r1.7 -r1.7.102.1 src/sys/arch/next68k/stand/boot/machdep.c
cvs rdiff -u -r1.6 -r1.6.70.1 src/sys/arch/next68k/stand/boot/rtc.c
cvs rdiff -u -r1.10 -r1.10.96.1 src/sys/arch/next68k/stand/boot/scsi.c
cvs rdiff -u -r1.12 -r1.12.34.1 src/sys/arch/next68k/stand/boot/sd.c
cvs rdiff -u -r1.2 -r1.2.218.1 src/sys/arch/next68k/stand/boot/srt0.s
cvs rdiff -u -r1.4 -r1.4.212.1 src/sys/arch/next68k/stand/boot/version

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/next68k/stand/boot/Makefile
diff -u src/sys/arch/next68k/stand/boot/Makefile:1.29 src/sys/arch/next68k/stand/boot/Makefile:1.29.18.1
--- src/sys/arch/next68k/stand/boot/Makefile:1.29	Sat Apr  8 19:53:22 2017
+++ src/sys/arch/next68k/stand/boot/Makefile	Sun Feb 12 12:22:44 2023
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.29 2017/04/08 19:53:22 christos Exp $
+#	$NetBSD: Makefile,v 1.29.18.1 2023/02/12 12:22:44 martin Exp $
 
 NOMAN=	# defined
 
@@ -23,11 +23,14 @@ SAMISCMAKEFLAGS= SA_USE_LOADFILE=yes # S
 RELOC=	4380000
 
 # XXX make defs arch-indep.
-INCLUDES+=	-I${.OBJDIR} -I${S}/arch -I${S} -I${S}/lib/libsa 
-DEFS+=		-D_STANDALONE -DMC68040 -DSUPPORT_BOOTP -DSUPPORT_DHCP  -DDEBUG -DSD_DEBUG -DSCSI_DEBUG # -DEN_DEBUG   -DNETIF_DEBUG  
-SAMISCCPPFLAGS=	-DSUPPORT_DHCP -DSUPPORT_BOOTP -DSA_EXEC_ANYOWNER # -DBOOTP_DEBUG -DETHER_DEBUG -DNET_DEBUG # -DNETIF_DEBUG -DNFS_DEBUG  -DARP_DEBUG 
+INCLUDES+=	-I${.OBJDIR} -I${S}/arch -I${S} -I${S}/lib/libsa
+DEFS+=		-D_STANDALONE -DMC68040 -DSUPPORT_BOOTP -DSUPPORT_DHCP
+#DEFS+=		-DDEBUG -DSD_DEBUG -DSCSI_DEBUG -DEN_DEBUG -DNETIF_DEBUG
+SAMISCCPPFLAGS=	-DSUPPORT_DHCP -DSUPPORT_BOOTP -DSA_EXEC_ANYOWNER
+#SAMISCCPPFLAGS+= -DBOOTP_DEBUG -DETHER_DEBUG -DNET_DEBUG-DNETIF_DEBUG
+#SAMISCCPPFLAGS+= -DNFS_DEBUG -DARP_DEBUG
 WARNS=1
-CFLAGS+=	 -ffreestanding -nostdinc ${INCLUDES} ${DEFS}
+CFLAGS+=	-ffreestanding -nostdinc ${INCLUDES} ${DEFS}
 CFLAGS+=	-Wall -Wmissing-prototypes -Wstrict-prototypes -Wpointer-arith
 AFLAGS+=	${INCLUDES}
 # XXX SHOULD NOT NEED TO DEFINE THESE!

Index: src/sys/arch/next68k/stand/boot/README
diff -u src/sys/arch/next68k/stand/boot/README:1.1.1.1 src/sys/arch/next68k/stand/boot/README:1.1.1.1.242.1
--- src/sys/arch/next68k/stand/boot/README:1.1.1.1	Tue Jun  9 07:53:06 1998
+++ src/sys/arch/next68k/stand/boot/README	Sun Feb 12 12:22:44 2023
@@ -1,9 +1,9 @@
-$NetBSD: README,v 1.1.1.1 1998/06/09 07:53:06 dbj Exp $
+$NetBSD: README,v 1.1.1.1.242.1 2023/02/12 12:22:44 martin Exp $
 
 NeXT standalone bootblocks.
 Rolf Grossmann, Dec 1994
 
-Started work based on files from hp300/stand. boot.c was from post-1.0 
+Started work based on files from hp300/stand. boot.c was from post-1.0
 sparc/stand/boot.c, modified to work for the needs of the NeXT PROM,
 i.e. it wants to call the kernel, so the bootblock has to return the
 entry point.

Index: src/sys/arch/next68k/stand/boot/devopen.c
diff -u src/sys/arch/next68k/stand/boot/devopen.c:1.6 src/sys/arch/next68k/stand/boot/devopen.c:1.6.32.1
--- src/sys/arch/next68k/stand/boot/devopen.c:1.6	Sun Aug 10 07:40:49 2014
+++ src/sys/arch/next68k/stand/boot/devopen.c	Sun Feb 12 12:22:44 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: devopen.c,v 1.6 2014/08/10 07:40:49 isaki Exp $	*/
+/*	$NetBSD: devopen.c,v 1.6.32.1 2023/02/12 12:22:44 martin Exp $	*/
 /*
  * Copyright (c) 1994 Rolf Grossmann
  * All rights reserved.
@@ -40,7 +40,7 @@ devlookup(const char *d, int len)
 {
     struct devsw *dp = devsw;
     int i;
-    
+
     for (i = 0; i < ndevs; i++, dp++)
 	if (dp->dv_name && strncmp(dp->dv_name, d, len) == 0)
 	    return i;
@@ -68,7 +68,7 @@ devparse(const char *fname, int *dev,
 {
     int i;
     const char *s, *args[3];
-    
+
     /* get device name */
     for (s = fname; *s && *s != '/' && *s != '('; s++)
 	;
@@ -86,7 +86,7 @@ devparse(const char *fname, int *dev,
 	}
 	if (*s != ')')
 	    goto baddev;
-	
+
 	switch(i) {
 	  case 3:
 	      *count  = atoi(args[0]);
@@ -108,9 +108,9 @@ devparse(const char *fname, int *dev,
     /* no device present */
     else
 	*file = (char *)fname;	/* XXX discard const */
-    
+
     return 0;
-    
+
 baddev:
     return ENXIO;
 }
@@ -132,15 +132,15 @@ devopen(struct open_file *f, const char 
 	return error;
 
     dp = &devsw[dev];
-	
+
     if ((void *)dp->dv_open == (void *)nodev)
 	return ENXIO;
 
     f->f_dev = dp;
-    
+
     if ((error = (*dp->dv_open)(f, count, lun, part)) != 0)
 	printf("%s(%d,%d,%d): %d = %s\n", devsw[dev].dv_name,
 	       count, lun, part, error, strerror(error));
 
     return error;
-}    
+}

Index: src/sys/arch/next68k/stand/boot/dmareg.h
diff -u src/sys/arch/next68k/stand/boot/dmareg.h:1.3 src/sys/arch/next68k/stand/boot/dmareg.h:1.3.202.1
--- src/sys/arch/next68k/stand/boot/dmareg.h:1.3	Wed Sep 11 01:46:36 2002
+++ src/sys/arch/next68k/stand/boot/dmareg.h	Sun Feb 12 12:22:44 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: dmareg.h,v 1.3 2002/09/11 01:46:36 mycroft Exp $	*/
+/*	$NetBSD: dmareg.h,v 1.3.202.1 2023/02/12 12:22:44 martin Exp $	*/
 /*
  * Copyright (c) 1997 Rolf Grossmann
  * All rights reserved.
@@ -55,7 +55,7 @@
 		 &~(DMA_ENDALIGNMENT-1))|0x80000000))
 
 struct dma_dev {		/* format of dma device registers */
-	int dd_csr;		/* control & status register */
+	volatile uint32_t dd_csr; /* control & status register */
 	char dd_pad[0x3fec];	/* csr not contiguous with next */
 	char *dd_saved_next;	/* saved pointers for HW restart */
 	char *dd_saved_limit;

Index: src/sys/arch/next68k/stand/boot/machdep.c
diff -u src/sys/arch/next68k/stand/boot/machdep.c:1.7 src/sys/arch/next68k/stand/boot/machdep.c:1.7.102.1
--- src/sys/arch/next68k/stand/boot/machdep.c:1.7	Mon Dec 24 15:46:45 2007
+++ src/sys/arch/next68k/stand/boot/machdep.c	Sun Feb 12 12:22:44 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.7 2007/12/24 15:46:45 perry Exp $	*/
+/*	$NetBSD: machdep.c,v 1.7.102.1 2023/02/12 12:22:44 martin Exp $	*/
 /*
  * Copyright (c) 1998 Darrin Jewell
  * Copyright (c) 1994 Rolf Grossmann
@@ -117,10 +117,10 @@ trap(struct trapframe *fp)
 	printf("Got unexpected trap: format=%x vector=%x sr=%x pc=%x\n",
 	       fp->fmt, fp->vec, fp->sr, fp->pc);
 	printf("dregs: %x %x %x %x %x %x %x %x\n",
-	       fp->dregs[0], fp->dregs[1], fp->dregs[2], fp->dregs[3], 
+	       fp->dregs[0], fp->dregs[1], fp->dregs[2], fp->dregs[3],
 	       fp->dregs[4], fp->dregs[5], fp->dregs[6], fp->dregs[7]);
 	printf("aregs: %x %x %x %x %x %x %x %x\n",
-	       fp->aregs[0], fp->aregs[1], fp->aregs[2], fp->aregs[3], 
+	       fp->aregs[0], fp->aregs[1], fp->aregs[2], fp->aregs[3],
 	       fp->aregs[4], fp->aregs[5], fp->aregs[6], fp->aregs[7]);
 	intrap = 0;
 #ifdef DEBUG

Index: src/sys/arch/next68k/stand/boot/rtc.c
diff -u src/sys/arch/next68k/stand/boot/rtc.c:1.6 src/sys/arch/next68k/stand/boot/rtc.c:1.6.70.1
--- src/sys/arch/next68k/stand/boot/rtc.c:1.6	Mon Jan 12 11:32:44 2009
+++ src/sys/arch/next68k/stand/boot/rtc.c	Sun Feb 12 12:22:44 2023
@@ -1,4 +1,4 @@
-/*      $NetBSD: rtc.c,v 1.6 2009/01/12 11:32:44 tsutsui Exp $        */
+/*      $NetBSD: rtc.c,v 1.6.70.1 2023/02/12 12:22:44 martin Exp $        */
 /*
  * Copyright (c) 1997 Rolf Grossmann
  * All rights reserved.
@@ -51,7 +51,7 @@ rtc_read(u_char reg)
 	int i;
 	u_int tmp;
 	u_char val;
-    
+
 	*scr2 = (*scr2 & ~(SCR2_RTDATA | SCR2_RTCLK)) | SCR2_RTCE;
 	DELAY(1);
 
@@ -74,7 +74,7 @@ rtc_read(u_char reg)
 	val = 0;			/* should be anyway */
 	for (i=0; i<8; i++) {
 		val <<= 1;
-	
+
 		tmp = *scr2 & ~(SCR2_RTDATA | SCR2_RTCLK);
 
 		*scr2 = tmp | SCR2_RTCLK;
@@ -96,7 +96,7 @@ void
 rtc_init(void)
 {
 	u_char val;
-	
+
 	val = rtc_read(RTC_STATUS);
 	new_clock = (val & RTC_NEW_CLOCK) ? 1 : 0;
 }
@@ -105,7 +105,7 @@ satime_t
 getsecs(void)
 {
 	u_int secs;
-	
+
 	if (new_clock) {
 		secs = rtc_read(RTC_CNTR0) << 24 |
 		       rtc_read(RTC_CNTR1) << 16 |
@@ -124,6 +124,6 @@ getsecs(void)
 		       BCD_DECODE(m) * 60 +
 		       BCD_DECODE(s);
 	}
-	
+
 	return secs;
 }

Index: src/sys/arch/next68k/stand/boot/scsi.c
diff -u src/sys/arch/next68k/stand/boot/scsi.c:1.10 src/sys/arch/next68k/stand/boot/scsi.c:1.10.96.1
--- src/sys/arch/next68k/stand/boot/scsi.c:1.10	Sun Mar 30 16:28:08 2008
+++ src/sys/arch/next68k/stand/boot/scsi.c	Sun Feb 12 12:22:44 2023
@@ -1,4 +1,4 @@
-/*      $NetBSD: scsi.c,v 1.10 2008/03/30 16:28:08 he Exp $        */
+/*      $NetBSD: scsi.c,v 1.10.96.1 2023/02/12 12:22:44 martin Exp $        */
 /*
  * Copyright (c) 1994, 1997 Rolf Grossmann
  * All rights reserved.
@@ -61,7 +61,7 @@ int scsiicmd(char target, char lun,
 #define NDPRINTF(x)
 #define PRINTF(x)
 /* printf x; */
-#ifdef xSCSI_DEBUG
+#ifdef SCSI_DEBUG
 #define DPRINTF(x) printf x;
 #else
 #define DPRINTF(x)
@@ -77,7 +77,7 @@ scsi_init(void)
     dma = (struct dma_dev *)P_SCSI_CSR;
 
     dma_buffer = DMA_ALIGN(char *, the_dma_buffer);
-    
+
     P_FLOPPY[FLP_CTRL] &= ~FLC_82077_SEL;	/* select SCSI chip */
 
     /* first reset DMA */
@@ -96,7 +96,7 @@ scsi_init(void)
     /* now reset the SCSI bus */
     sr[NCR_CMD]        = NCRCMD_RSTSCSI;
     DELAY(4000000);	/* XXX should be about 2-3 seconds at least */
-    
+
     /* then reset the SCSI chip again and initialize it properly */
     sr[NCR_CMD]        = NCRCMD_RSTCHIP;
     sr[NCR_CMD]        = NCRCMD_NOP;
@@ -125,7 +125,7 @@ scsierror(char *error)
 short
 scsi_getbyte(volatile uint8_t *sr)
 {
-    if ((sr[NCR_FFLAG] & NCRFIFO_FF) == 0) 
+    if ((sr[NCR_FFLAG] & NCRFIFO_FF) == 0)
     {
 	printf("getbyte: no data!\n");
 	return -1;
@@ -187,7 +187,7 @@ scsiicmd(char target, char lun,
 	sr[NCR_FIFO] = cbuf[i];
     sr[NCR_CMD]   = NCRCMD_SELATN;
     sc->sc_state  = SCSI_SELECTING;
-    
+
     while(sc->sc_state != SCSI_DONE) {
 	if (scsi_wait_for_intr()) /* maybe we'd better use real intrs ? */
 	    return EIO;
@@ -207,12 +207,12 @@ scsiicmd(char target, char lun,
     redo:
 	DPRINTF(("scsiicmd: regs[intr=%x, stat=%x, step=%x]\n",
 		 sc->sc_intrstatus, sc->sc_status, sc->sc_seqstep));
-	
+
 	if (sc->sc_intrstatus & NCRINTR_SBR) {
 	    scsierror("scsi bus reset");
 	    return EIO;
 	}
-	
+
 	if ((sc->sc_status & NCRSTAT_GE)
 	    || (sc->sc_intrstatus & NCRINTR_ILL)) {
 	    scsierror("software error");
@@ -227,12 +227,12 @@ scsiicmd(char target, char lun,
 	switch(sc->sc_state)
 	{
 	  case SCSI_SELECTING:
-	      if (sc->sc_intrstatus & NCRINTR_DIS) 
+	      if (sc->sc_intrstatus & NCRINTR_DIS)
 	      {
 		  sc->sc_state = SCSI_IDLE;
 		  return EUNIT;	/* device not present */
 	      }
-	      
+
 #define NCRINTR_DONE (NCRINTR_BS | NCRINTR_FC)
 	      if ((sc->sc_intrstatus & NCRINTR_DONE) != NCRINTR_DONE)
 	      {
@@ -310,7 +310,7 @@ scsiicmd(char target, char lun,
     sc->sc_state = SCSI_IDLE;
     return -sc->sc_result;
 }
-    
+
 int
 scsi_msgin(void)
 {
@@ -340,11 +340,10 @@ dma_start(char *addr, int len)
 {
     volatile uint8_t *sr;
     struct dma_dev *dma;
-    
-    
+
     sr = P_SCSI;
     dma = (struct dma_dev *)P_SCSI_CSR;
-    
+
     if (len > MAX_DMASIZE)
     {
 	scsierror("DMA too long");
@@ -365,15 +364,15 @@ dma_start(char *addr, int len)
 	return -1;
 #endif
     }
-    
+
     PRINTF(("DMA start: %lx, %d byte.\n", (long)addr, len));
 
-    DPRINTF(("dma_bufffer: start: 0x%lx end: 0x%lx \n", 
+    DPRINTF(("dma_bufffer: start: 0x%lx end: 0x%lx \n",
 				(long)dma_buffer,(long)DMA_ENDALIGN(char *, dma_buffer+len)));
 
     sc->dma_addr = addr;
     sc->dma_len = len;
-    
+
     sr[NCR_TCL]  = len & 0xff;
     sr[NCR_TCM]  = len >> 8;
     sr[NCR_CMD]  = NCRCMD_DMA | NCRCMD_NOP;
@@ -405,7 +404,7 @@ dma_done(void)
     struct dma_dev *dma;
     int resid, state;
     int flushcount = 0;
-    
+
     sr = P_SCSI;
     dma = (struct dma_dev *)P_SCSI_CSR;
 
@@ -419,16 +418,16 @@ dma_done(void)
     if (!(sr[NCR_FFLAG] & NCRFIFO_FF)) {
 	    sr[ESP_DCTL] = ESPDCTL_20MHZ | ESPDCTL_INTENB | ESPDCTL_DMAMOD
 		    | ESPDCTL_DMARD;
-	    while (!(state & DMACSR_COMPLETE) && (state & DMACSR_ENABLE) && flushcount < 16) 
+	    while (!(state & DMACSR_COMPLETE) && (state & DMACSR_ENABLE) && flushcount < 16)
 	    {
-		    
+
 		    DPRINTF(("DMA still enabled, flushing DCTL.\n"));
-		    
+
 		    sr[ESP_DCTL] = ESPDCTL_20MHZ | ESPDCTL_INTENB | ESPDCTL_DMAMOD
 			    | ESPDCTL_DMARD | ESPDCTL_FLUSH;
 		    sr[ESP_DCTL] = ESPDCTL_20MHZ | ESPDCTL_INTENB | ESPDCTL_DMAMOD
 			    | ESPDCTL_DMARD;
-		    
+
 		    flushcount++;
 		    state = dma->dd_csr & (DMACSR_BUSEXC | DMACSR_COMPLETE
 					   | DMACSR_SUPDATE | DMACSR_ENABLE);
@@ -467,6 +466,6 @@ dma_done(void)
     return sc->dma_len;
 
     /* scsierror("DMA not completed\n"); */
-    
+
     return 0;
 }

Index: src/sys/arch/next68k/stand/boot/sd.c
diff -u src/sys/arch/next68k/stand/boot/sd.c:1.12 src/sys/arch/next68k/stand/boot/sd.c:1.12.34.1
--- src/sys/arch/next68k/stand/boot/sd.c:1.12	Sat Mar 29 19:20:29 2014
+++ src/sys/arch/next68k/stand/boot/sd.c	Sun Feb 12 12:22:44 2023
@@ -1,4 +1,4 @@
-/*      $NetBSD: sd.c,v 1.12 2014/03/29 19:20:29 christos Exp $        */
+/*      $NetBSD: sd.c,v 1.12.34.1 2023/02/12 12:22:44 martin Exp $        */
 /*
  * Copyright (c) 1994 Rolf Grossmann
  * All rights reserved.
@@ -40,7 +40,7 @@
 #include <lib/libkern/libkern.h> /* for bzero() */
 #include "dmareg.h"
 
-#ifdef xSD_DEBUG
+#ifdef SD_DEBUG
 #define DPRINTF(x) printf x;
 #else
 #define DPRINTF(x)
@@ -87,7 +87,7 @@ sdprobe(char target, char lun)
     do {
 	    count = 0;
 	error = scsiicmd(target, lun, (u_char *)&cdb1, sizeof(cdb1), NULL, &count);
-	if (error == -SCSI_BUSY) { 
+	if (error == -SCSI_BUSY) {
 		register int N = 10000000; while (--N > 0);
 	}
     } while ((error == -SCSI_CHECK || error == -SCSI_BUSY)
@@ -98,19 +98,19 @@ sdprobe(char target, char lun)
 
     memset(&cdb2, 0, sizeof(cdb2));
     cdb2.opcode = INQUIRY;
-    cdb2.length = sizeof(inq);
-    count = sizeof (inq);
+    cdb2.length = SCSIPI_INQUIRY_LENGTH_SCSI2;
+    count = SCSIPI_INQUIRY_LENGTH_SCSI2;
     error = scsiicmd(target, lun, (u_char *)&cdb2, sizeof(cdb2),
 		     (char *)&inq, &count);
     if (error != 0)
       return error<0 ? EHER : error;
 
-    if ((inq.device & SID_TYPE) != T_DIRECT 
+    if ((inq.device & SID_TYPE) != T_DIRECT
 	&& (inq.device & SID_TYPE) != T_CDROM)
       return EUNIT;	/* not a disk */
 
     DPRINTF(("booting disk %s.\n", inq.vendor));
-    
+
     return 0;
 }
 
@@ -135,6 +135,10 @@ sdgetinfo(struct sd_softc *ss)
 	return error<0 ? EHER : error;
     blklen = (cap.length[0]<<24) + (cap.length[1]<<16)
 	     + (cap.length[2]<<8) + cap.length[3];
+
+    /* avoid division by zero trap even on possible xfer errors */
+    if (blklen == 0)
+	blklen = DEV_BSIZE;
     ss->sc_dev_bsize = blklen;
 
     ss->sc_pinfo.offset[ss->sc_part] = 0; /* read absolute sector */
@@ -188,9 +192,9 @@ sdopen(struct open_file *f, char count, 
     register struct sd_softc *ss;
     char unit, cnt;
     int error;
-    
+
     DPRINTF(("open: sd(%d,%d,%d)\n", count, lun, part));
-    
+
     if (lun >= NSD)
 	return EUNIT;
 
@@ -211,7 +215,7 @@ sdopen(struct open_file *f, char count, 
 
     if (unit >= NSD)
 	return EUNIT;
-    
+
     ss = alloc(sizeof(struct sd_softc));
     ss->sc_unit = unit;
     ss->sc_lun = lun;
@@ -244,10 +248,10 @@ sdstrategy(struct sd_softc *ss, int rw, 
     u_long blk = dblk + ss->sc_pinfo.offset[ss->sc_part];
     struct scsipi_rw_10 cdb;
     int error;
-    
+
     if (size == 0)
 	return 0;
-    
+
     if (rw != F_READ)
     {
 	printf("sdstrategy: write not implemented.\n");
@@ -291,4 +295,3 @@ sdstrategy(struct sd_softc *ss, int rw, 
     DPRINTF(("sdstrategy: read %d bytes\n", *rsize));
     return 0;
 }
-    

Index: src/sys/arch/next68k/stand/boot/srt0.s
diff -u src/sys/arch/next68k/stand/boot/srt0.s:1.2 src/sys/arch/next68k/stand/boot/srt0.s:1.2.218.1
--- src/sys/arch/next68k/stand/boot/srt0.s:1.2	Sat May 12 22:35:30 2001
+++ src/sys/arch/next68k/stand/boot/srt0.s	Sun Feb 12 12:22:44 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: srt0.s,v 1.2 2001/05/12 22:35:30 chs Exp $	*/
+/*	$NetBSD: srt0.s,v 1.2.218.1 2023/02/12 12:22:44 martin Exp $	*/
 /*
  * Copyright (c) 1994 Rolf Grossmann
  * All rights reserved.
@@ -71,7 +71,7 @@ Lclr:
 	|| restore prom vectors
 	movel	save_vbr,%a0
 	movec	%a0,%vbr
-	
+
 	|| return kernel start address (still in d0)
 	rts
 
@@ -82,7 +82,7 @@ hloop:
 	movel	#halt,%d0
 	trap	#13			| halt the system
 	bra	hloop			| and do not allow continuation
-	
+
 ASENTRY_NOPROFILE(astrap)
 	moveml	%d0-%d7/%a0-%a7,%sp@-	| save all registers
 

Index: src/sys/arch/next68k/stand/boot/version
diff -u src/sys/arch/next68k/stand/boot/version:1.4 src/sys/arch/next68k/stand/boot/version:1.4.212.1
--- src/sys/arch/next68k/stand/boot/version:1.4	Fri Nov  9 19:53:17 2001
+++ src/sys/arch/next68k/stand/boot/version	Sun Feb 12 12:22:44 2023
@@ -1,6 +1,7 @@
-$NetBSD: version,v 1.4 2001/11/09 19:53:17 scw Exp $
+$NetBSD: version,v 1.4.212.1 2023/02/12 12:22:44 martin Exp $
 
 1.1:	initial import
 1.3:	Add ELF support
 1.4:	loadfile() update:  ELF symbols no longer need backward seeks.
 1.5:	loadfile() update to avoid backwards seeks for ELF Program Headers.
+1.6:	Fix a bug on DMA reg accesses and a problem on detecting old drives

Reply via email to