Pull up following revision(s) (requested by tsutsui in ticket #1600):

sys/arch/next68k/stand/boot/en.c: revision 1.20
	sys/arch/next68k/stand/boot/scsi.c: revision 1.13
	sys/arch/next68k/stand/boot/scsi.c: revision 1.14
	sys/arch/next68k/stand/boot/conf.c: revision 1.8
	sys/arch/next68k/stand/boot/sd.c: revision 1.17
	sys/arch/next68k/stand/boot/samachdep.h: revision 1.1
	sys/arch/next68k/stand/boot/samachdep.h: revision 1.2
	sys/arch/next68k/stand/boot/rtc.c: revision 1.8
	sys/arch/next68k/stand/boot/machdep.c: revision 1.9
	sys/arch/next68k/stand/boot/boot.c: revision 1.14
	sys/arch/next68k/stand/boot/boot.c: revision 1.15
	sys/arch/next68k/stand/boot/scsivar.h: revision 1.2
	sys/arch/next68k/stand/boot/devopen.c: revision 1.8
	sys/arch/next68k/stand/boot/version: revision 1.7

Use common declarations and macros in proper headers.

Also fix inconsistent sdopen() and sdstrategy() args and
remove useless #if 0'ed out code.
No functional change.

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.

Actually bump version (missed in the previous commit).
This commit is contained in:
martin 2023-02-22 12:09:16 +00:00
parent c41274d785
commit 62f4d2be02
11 changed files with 127 additions and 67 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: boot.c,v 1.12.22.1 2023/02/15 19:28:29 martin Exp $ */
/* $NetBSD: boot.c,v 1.12.22.2 2023/02/22 12:09:16 martin Exp $ */
/*
* Copyright (c) 1994 Rolf Grossmann
* All rights reserved.
@ -34,17 +34,17 @@
#include <lib/libsa/stand.h>
#include <lib/libsa/loadfile.h>
#include <lib/libsa/dev_net.h>
#include <lib/libkern/libkern.h>
#include <machine/cpu.h> /* for NEXT_RAMBASE */
#include <next68k/next68k/nextrom.h>
#include "samachdep.h"
#define KERN_LOADADDR NEXT_RAMBASE
extern int errno;
extern char *mg;
#define MON(type, off) (*(type *)((u_int) (mg) + off))
int devparse(const char *, int *, char *, char *, char *, char **);
@ -56,18 +56,12 @@ int devparse(const char *, int *, char *, char *, char *, char **);
* Boot device is derived from PROM provided information.
*/
extern char bootprog_rev[];
extern char bootprog_name[];
extern int build;
#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;
extern void rtc_init(void);
extern int try_bootp;
volatile int qq;
int
@ -86,10 +80,13 @@ main(char *boot_arg)
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);

View File

@ -1,4 +1,4 @@
/* $NetBSD: conf.c,v 1.7 2005/12/11 12:18:29 christos Exp $ */
/* $NetBSD: conf.c,v 1.7.170.1 2023/02/22 12:09:16 martin Exp $ */
/*
* Copyright (c) 1982, 1986, 1990, 1993
@ -45,21 +45,15 @@
#include <netif.h>
#include <dev_net.h>
#include "samachdep.h"
/*
* Device configuration
*/
extern int sdstrategy(void *, int, daddr_t, size_t, void *, size_t *);
extern int sdopen(struct open_file *, ...);
extern int sdclose(struct open_file *);
#define sdioctl noioctl
/* ### now from libsa
extern int enstrategy(void *, int, daddr_t, size_t, void *, size_t *);
extern int enopen(struct open_file *, ...);
extern int enclose(struct open_file *);
#define enioctl noioctl
*/
struct devsw devsw[] = {
{ "sd", sdstrategy, sdopen, sdclose, sdioctl },

View File

@ -1,4 +1,4 @@
/* $NetBSD: devopen.c,v 1.6.32.1 2023/02/12 12:22:44 martin Exp $ */
/* $NetBSD: devopen.c,v 1.6.32.2 2023/02/22 12:09:16 martin Exp $ */
/*
* Copyright (c) 1994 Rolf Grossmann
* All rights reserved.
@ -33,7 +33,7 @@
#include <lib/libkern/libkern.h>
int devlookup(const char *, int);
int devparse(const char *, int *, char *, char *, char *, char **);
int devparse(const char *, int *, int *, int *, int *, char **);
int
devlookup(const char *d, int len)
@ -64,7 +64,7 @@ devlookup(const char *d, int len)
*/
int
devparse(const char *fname, int *dev,
char *count, char *lun, char *part, char **file)
int *count, int *lun, int *part, char **file)
{
int i;
const char *s, *args[3];
@ -120,7 +120,7 @@ devopen(struct open_file *f, const char *fname, char **file)
{
int error;
int dev;
char count, lun, part;
int count, lun, part;
struct devsw *dp;
dev = 0; /* default device is first in table (usually scsi disk) */

View File

@ -1,4 +1,4 @@
/* $NetBSD: en.c,v 1.19 2018/03/08 03:12:02 mrg Exp $ */
/* $NetBSD: en.c,v 1.19.6.1 2023/02/22 12:09:16 martin Exp $ */
/*
* Copyright (c) 1996 Rolf Grossmann
* All rights reserved.
@ -37,6 +37,7 @@
#include <next68k/next68k/nextrom.h>
#include "enreg.h"
#include "dmareg.h"
#include "samachdep.h"
#include <stand.h>
#include <netif.h>
@ -45,7 +46,6 @@
#include <lib/libkern/libkern.h>
extern char *mg;
#define MON(type, off) (*(type *)((u_int) (mg) + off))
#define PRINTF(x) printf x;
@ -80,8 +80,6 @@ struct netif_driver en_driver = {
en_ifs, sizeof(en_ifs) / sizeof(en_ifs[0])
};
extern int turbo;
/* ### int netdev_sock;
static int open_count; */

View File

@ -1,4 +1,4 @@
/* $NetBSD: machdep.c,v 1.7.102.1 2023/02/12 12:22:44 martin Exp $ */
/* $NetBSD: machdep.c,v 1.7.102.2 2023/02/22 12:09:16 martin Exp $ */
/*
* Copyright (c) 1998 Darrin Jewell
* Copyright (c) 1994 Rolf Grossmann
@ -35,12 +35,12 @@
#include <stand.h>
#include <next68k/next68k/nextrom.h>
#include "samachdep.h"
char *mg;
#define MON(type, off) (*(type *)((u_int) (mg) + off))
extern int entry_point;
#ifdef DEBUG
int debug = 1;
#else
@ -86,7 +86,6 @@ putchar(int c)
__dead void
_rtt(void)
{
extern __dead void _halt(void);
printf("Press any key to halt.\n");
getchar();

View File

@ -1,4 +1,4 @@
/* $NetBSD: rtc.c,v 1.6.70.1 2023/02/12 12:22:44 martin Exp $ */
/* $NetBSD: rtc.c,v 1.6.70.2 2023/02/22 12:09:16 martin Exp $ */
/*
* Copyright (c) 1997 Rolf Grossmann
* All rights reserved.
@ -35,12 +35,9 @@
#include <lib/libsa/stand.h>
#include <lib/libsa/net.h>
#include "samachdep.h"
u_char rtc_read(u_char);
void rtc_init(void);
/* ### where shall I put this definition? */
#define DELAY(n) { register int N = (n); while (--N > 0); }
static volatile u_int *scr2 = (u_int *)NEXT_P_SCR2_CON;
static u_char new_clock;

View File

@ -0,0 +1,77 @@
/* $NetBSD: samachdep.h,v 1.2.4.2 2023/02/22 12:09:16 martin Exp $ */
/*
* Copyright (c) 1982, 1990, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)samachdep.h 8.1 (Berkeley) 6/10/93
*/
#include <sys/param.h>
#include <lib/libsa/stand.h>
/* boot.c */
extern int entry_point;
extern int cpuspeed;
extern int turbo;
/* en.c */
int enstrategy(void *, int, daddr_t, size_t, void *, size_t *);
int enopen(struct open_file *, ...);
int enclose(struct open_file *);
/* machdep.c */
extern char *mg;
/* rtc.c */
void rtc_init(void);
/* sd.c */
int sdstrategy(void *, int, daddr_t, size_t, void *, size_t *);
int sdopen(struct open_file *, ...);
int sdclose(struct open_file *);
/* srt0.S */
__dead void _halt(void);
/* vers.c (generated by sys/conf/newvers_stand.sh) */
extern char bootprog_name[], bootprog_rev[], bootprog_kernrev[];
/* build.c (generated by ${.CURDIR}/newvers.sh) */
extern int build;
/* 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)

View File

@ -1,4 +1,4 @@
/* $NetBSD: scsi.c,v 1.10.96.1 2023/02/12 12:22:44 martin Exp $ */
/* $NetBSD: scsi.c,v 1.10.96.2 2023/02/22 12:09:16 martin Exp $ */
/*
* Copyright (c) 1994, 1997 Rolf Grossmann
* All rights reserved.
@ -33,17 +33,15 @@
#include <next68k/dev/espreg.h>
#include <dev/ic/ncr53c9xreg.h>
#include <dev/scsipi/scsi_message.h>
#if 0
#include <next/next/prominfo.h>
#else
#include <next68k/next68k/nextrom.h>
#endif
#include "scsireg.h"
#include "dmareg.h"
#include "scsivar.h"
#include <lib/libsa/stand.h>
#include "samachdep.h"
struct scsi_softc scsi_softc, *sc = &scsi_softc;
char the_dma_buffer[MAX_DMASIZE+DMA_ENDALIGNMENT], *dma_buffer;
@ -51,12 +49,9 @@ int scsi_msgin(void);
int dma_start(char *addr, int len);
int dma_done(void);
void scsi_init(void);
void scsierror(char *error);
short scsi_getbyte(volatile uint8_t *sr);
int scsi_wait_for_intr(void);
int scsiicmd(char target, char lun,
u_char *cbuf, int clen, char *addr, int *len);
#define NDPRINTF(x)
#define PRINTF(x)
@ -95,7 +90,8 @@ scsi_init(void)
/* 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;
@ -136,16 +132,10 @@ scsi_getbyte(volatile uint8_t *sr)
int
scsi_wait_for_intr(void)
{
#if 0
extern struct prominfo *pi;
volitle int = pi->pi_intrstat; /* ### use constant? */
#else
extern char *mg;
#define MON(type, off) (*(type *)((u_int) (mg) + off))
volatile int *intrstat = MON(volatile int *,MG_intrstat);
#ifdef SCSI_DEBUG
/* volatile int *intrmask = MON(volatile int *,MG_intrmask); */
#endif
#endif
int count;

View File

@ -1,4 +1,4 @@
/* $NetBSD: scsivar.h,v 1.1.1.1 1998/06/09 07:53:06 dbj Exp $ */
/* $NetBSD: scsivar.h,v 1.1.1.1.242.1 2023/02/22 12:09:16 martin Exp $ */
/*
* Copyright (c) 1994 Rolf Grossmann
* All rights reserved.
@ -69,4 +69,5 @@ struct scsi_softc {
extern struct scsi_softc scsi_softc;
#define DELAY(n) { register int N = (n); while (--N > 0); }
void scsi_init(void);
int scsiicmd(char, char, u_char *, int, char *, int *);

View File

@ -1,4 +1,4 @@
/* $NetBSD: sd.c,v 1.12.34.1 2023/02/12 12:22:44 martin Exp $ */
/* $NetBSD: sd.c,v 1.12.34.2 2023/02/22 12:09:16 martin Exp $ */
/*
* Copyright (c) 1994 Rolf Grossmann
* All rights reserved.
@ -38,7 +38,10 @@
#include <dev/scsipi/scsipi_disk.h>
#include <lib/libsa/stand.h>
#include <lib/libkern/libkern.h> /* for bzero() */
#include "dmareg.h"
#include "scsivar.h"
#include "samachdep.h"
#ifdef SD_DEBUG
#define DPRINTF(x) printf x;
@ -62,14 +65,8 @@ struct sd_softc {
#define NSD 7
#define MAXRETRIES 5 /* must be at least one */
void scsi_init(void);
int scsiicmd(char, char, u_char *, int, char *, int *);
int sdstrategy(struct sd_softc *ss, int rw, daddr_t dblk, size_t size,
void *buf, size_t *rsize);
int sdprobe(char target, char lun);
int sdgetinfo(struct sd_softc *ss);
int sdopen(struct open_file *f, char count, char lun, char part);
int sdclose(struct open_file *f);
int
sdprobe(char target, char lun)
@ -187,12 +184,20 @@ sdgetinfo(struct sd_softc *ss)
}
int
sdopen(struct open_file *f, char count, char lun, char part)
sdopen(struct open_file *f, ...)
{
va_list ap;
int count, lun, part;
register struct sd_softc *ss;
char unit, cnt;
int error;
va_start(ap, f);
count = va_arg(ap, int);
lun = va_arg(ap, int);
part = va_arg(ap, int);
va_end(ap);
DPRINTF(("open: sd(%d,%d,%d)\n", count, lun, part));
if (lun >= NSD)
@ -242,9 +247,10 @@ sdclose(struct open_file *f)
}
int
sdstrategy(struct sd_softc *ss, int rw, daddr_t dblk, size_t size,
sdstrategy(void *devdata, int rw, daddr_t dblk, size_t size,
void *buf, size_t *rsize)
{
struct sd_softc *ss = devdata;
u_long blk = dblk + ss->sc_pinfo.offset[ss->sc_part];
struct scsipi_rw_10 cdb;
int error;

View File

@ -1,4 +1,4 @@
$NetBSD: version,v 1.4.212.2 2023/02/15 19:28:29 martin Exp $
$NetBSD: version,v 1.4.212.3 2023/02/22 12:09:16 martin Exp $
1.1: initial import
1.3: Add ELF support
@ -6,3 +6,4 @@ $NetBSD: version,v 1.4.212.2 2023/02/15 19:28:29 martin Exp $
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
1.7: Add support of NeXT_CUBE_TURBO
1.8: Fix DELAY() to actually wait specified microsconds