Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/next68k/stand/boot Replace DELAY() with one in hp30...



details:   https://anonhg.NetBSD.org/src/rev/9efac470ccad
branches:  trunk
changeset: 373472:9efac470ccad
user:      tsutsui <tsutsui%NetBSD.org@localhost>
date:      Sun Feb 12 10:04:56 2023 +0000

description:
Replace DELAY() with one in hp300 bootloader and adjust cpuspeed counts.

Fix boot failure on my ancient Seagate ST52160N drive.
It looks some of such old drives can't respond to SCSI
test-unit-ready command without proper wait after SCSI bus reset.
Bump version again to denote a fix.

XXX we should re-evaluate cpuspeed counts for DELAY() in bootloaders
    (where cache is disabled) on other m68k ports, hp300 and luna68k etc.

diffstat:

 sys/arch/next68k/stand/boot/boot.c      |  10 +++++++---
 sys/arch/next68k/stand/boot/samachdep.h |  15 +++++++++++++--
 sys/arch/next68k/stand/boot/scsi.c      |   5 +++--
 3 files changed, 23 insertions(+), 7 deletions(-)

diffs (85 lines):

diff -r 01167f52ddbb -r 9efac470ccad sys/arch/next68k/stand/boot/boot.c
--- a/sys/arch/next68k/stand/boot/boot.c        Sun Feb 12 08:45:18 2023 +0000
+++ b/sys/arch/next68k/stand/boot/boot.c        Sun Feb 12 10:04:56 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: boot.c,v 1.14 2023/02/12 08:25:09 tsutsui Exp $        */
+/*     $NetBSD: boot.c,v 1.15 2023/02/12 10:04:56 tsutsui Exp $        */
 /*
  * Copyright (c) 1994 Rolf Grossmann
  * All rights reserved.
@@ -59,6 +59,7 @@
 #define KNAMEN 100
 char kernel[KNAMEN];
 int entry_point;               /* return value filled in by machdep_start */
+int cpuspeed = MHZ_33;         /* assume fastest 33 MHz for sanity */
 int turbo;
 
 volatile int qq;
@@ -79,10 +80,13 @@
        machine = MON(char, MG_machine_type);
        if (machine == NeXT_TURBO_MONO ||
            machine == NeXT_TURBO_COLOR ||
-           machine == NeXT_CUBE_TURBO)
+           machine == NeXT_CUBE_TURBO) {
                turbo = 1;
-       else
+               cpuspeed = MHZ_33;
+       } else {
                turbo = 0;
+               cpuspeed = MHZ_25;
+       }
 
        memset(marks, 0, sizeof(marks));
        printf(">> %s BOOT [%s #%d]\n", bootprog_name, bootprog_rev, build);
diff -r 01167f52ddbb -r 9efac470ccad sys/arch/next68k/stand/boot/samachdep.h
--- a/sys/arch/next68k/stand/boot/samachdep.h   Sun Feb 12 08:45:18 2023 +0000
+++ b/sys/arch/next68k/stand/boot/samachdep.h   Sun Feb 12 10:04:56 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: samachdep.h,v 1.1 2023/02/12 08:25:09 tsutsui Exp $    */
+/*     $NetBSD: samachdep.h,v 1.2 2023/02/12 10:04:56 tsutsui Exp $    */
 
 /*
  * Copyright (c) 1982, 1990, 1993
@@ -36,6 +36,7 @@
 
 /* boot.c */
 extern int entry_point;
+extern int cpuspeed;
 extern int turbo;
 
 /* en.c */
@@ -63,4 +64,14 @@
 /* build.c (generated by ${.CURDIR}/newvers.sh) */
 extern int build;
 
-#define DELAY(n)       { register int N = (n); while (--N > 0); }
+/* delay constants; note all CPU cache is turned off here */
+#define MHZ_25         3
+#define MHZ_33         4
+
+#define DELAY(n)                                                       \
+do {                                                                   \
+       register u_int __n = (cpuspeed * (n) / 4) + 1;                  \
+       do {                                                            \
+               __asm("subql #1, %0" : "=r" (__n) : "0" (__n));         \
+       } while (__n > 0);                                              \
+} while (/* CONSTCOND */ 0)
diff -r 01167f52ddbb -r 9efac470ccad sys/arch/next68k/stand/boot/scsi.c
--- a/sys/arch/next68k/stand/boot/scsi.c        Sun Feb 12 08:45:18 2023 +0000
+++ b/sys/arch/next68k/stand/boot/scsi.c        Sun Feb 12 10:04:56 2023 +0000
@@ -1,4 +1,4 @@
-/*      $NetBSD: scsi.c,v 1.13 2023/02/12 08:25:09 tsutsui Exp $        */
+/*      $NetBSD: scsi.c,v 1.14 2023/02/12 10:04:56 tsutsui Exp $        */
 /*
  * Copyright (c) 1994, 1997 Rolf Grossmann
  * All rights reserved.
@@ -90,7 +90,8 @@
 
     /* now reset the SCSI bus */
     sr[NCR_CMD]        = NCRCMD_RSTSCSI;
-    DELAY(4000000);    /* XXX should be about 2-3 seconds at least */
+    /* wait 2 seconds after SCSI bus reset */
+    DELAY(2 * 1000 * 1000);
 
     /* then reset the SCSI chip again and initialize it properly */
     sr[NCR_CMD]        = NCRCMD_RSTCHIP;



Home | Main Index | Thread Index | Old Index