boot from ufs program from Phil Bunde.
This commit is contained in:
parent
8360c5f4ab
commit
3e6203f54d
|
@ -0,0 +1,82 @@
|
|||
# from: @(#)Makefile 8.1 (Berkeley) 6/10/93
|
||||
# $Id: Makefile,v 1.1 1994/05/30 19:58:42 phil Exp $
|
||||
|
||||
DESTDIR=
|
||||
|
||||
# load at 1.5Meg -- allow 1.4xx meg kernel, but below ram disk
|
||||
# NOTE: alloc() function takes memory after _end
|
||||
RELOC= 180000
|
||||
|
||||
CONS= -DSCNCONSOLE
|
||||
DEFS= -DSTANDALONE ${CONS}
|
||||
CFLAGS= -O ${INCPATH} ${DEFS} -fwritable-strings
|
||||
|
||||
SRCS= cons.c devopen.c scn.c scsi_low.c scsi_hi.c \
|
||||
conf.c prf.c tgets.c machdep.c sd.c filesystem.c
|
||||
|
||||
S= ${.CURDIR}/../../..
|
||||
|
||||
.PATH: ${S}/arch/${MACHINE_ARCH}/${MACHINE_ARCH}
|
||||
.PATH: ${S}/stand ${S}/lib/libsa
|
||||
|
||||
INCPATH=-I${.CURDIR} -I${.CURDIR}/../.. -I${S} -I${S}/lib/libsa
|
||||
|
||||
### find out what to use for libkern
|
||||
.include "$S/lib/libkern/Makefile.inc"
|
||||
LIBKERN= ${KERNLIB}
|
||||
|
||||
.include "$S/lib/libsa/Makefile.inc"
|
||||
LIBSA= ${SA_LIB}
|
||||
|
||||
LIBS= ${LIBSA} ${.OBJDIR}/libdrive.a \
|
||||
${LIBKERN} ${LIBSA} ${LIBKERN}
|
||||
|
||||
BOOTS= boot
|
||||
ALL= ${BOOTS}
|
||||
|
||||
all: ${ALL}
|
||||
|
||||
${BOOTS}: ${LIBS}
|
||||
|
||||
OBJS= ${SRCS:N*.h:R:S/$/.o/g}
|
||||
${.OBJDIR}/libdrive.a: ${OBJS}
|
||||
ar crv $@ $?
|
||||
ranlib $@
|
||||
|
||||
# depend on DEFS
|
||||
|
||||
devopen.o machdep.o srt0.o: Makefile
|
||||
cons.o: Makefile
|
||||
|
||||
# startups
|
||||
|
||||
srt0.o: ${.CURDIR}/srt0.s
|
||||
cpp ${INCPATH} ${DEFS} ${.CURDIR}/srt0.s | as -o srt0.o
|
||||
|
||||
# new boot
|
||||
boot: boot.o srt0.o ${LIBS}
|
||||
ld -z -T ${RELOC} -e begin srt0.o boot.o ${LIBS} -o $@
|
||||
@size boot
|
||||
|
||||
# new boot user mode test
|
||||
TESTBOOT= boot.o test.o $(SC) ${LIBS}
|
||||
# objects from regular libc;
|
||||
SC= cerror.o syscall.o malloc.o sbrk.o getpagesize.o
|
||||
testboot: $(TESTBOOT)
|
||||
ld -o testboot /usr/lib/crt0.o $(TESTBOOT) ${LIBS} -o $@
|
||||
|
||||
$(SC): /usr/lib/libc.a
|
||||
ar x /usr/lib/libc.a $(SC)
|
||||
|
||||
# utilities
|
||||
|
||||
clean cleandir:
|
||||
rm -f *.o errs make.out
|
||||
rm -f a.out boot cat ls testboot
|
||||
rm -f *.core
|
||||
rm -f libdrive.a
|
||||
|
||||
.include <bsd.dep.mk>
|
||||
.include <bsd.obj.mk>
|
||||
|
||||
FRC:
|
|
@ -0,0 +1,24 @@
|
|||
pc532 stand/boot
|
||||
Phil Budne <phil@ultimate.com> 5/19/1994
|
||||
|
||||
Based on hp300 stand/pboot.c, uses libso
|
||||
(lacks the fun "spinner" that the i386 boot program displays)
|
||||
|
||||
May be debugged under usermode (using "testboot" image)
|
||||
|
||||
Passes howto, bootdev, & symbols to booted program;
|
||||
r3/ magic value 0xc1e86394 (3253232532)
|
||||
r4/ end of symbols
|
||||
r5/ physical load address (typ 0x2000)
|
||||
r6/ bootdev
|
||||
r7/ howto (flags: RB_{ASKNAME,KDB,SINGLE,HALT})
|
||||
|
||||
All files have Berzerkley style copyrights, except libso files from
|
||||
Jordan Hubbard's "libso" (which in turn come from Bruce Culbertson's
|
||||
ROM monitor); scsi_hi.c scsi_lo.c so.h
|
||||
|
||||
TODO:
|
||||
|
||||
check if kernel will overlap boot program!
|
||||
pick up initial how and boot dev
|
||||
|
|
@ -0,0 +1,276 @@
|
|||
/*-
|
||||
* Copyright (c) 1982, 1986, 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. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. 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.
|
||||
*
|
||||
* from: @(#)boot.c 8.1 (Berkeley) 6/10/93
|
||||
* $Id: boot.c,v 1.1 1994/05/30 19:58:45 phil Exp $
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
static char rcsid[] = "$Id: boot.c,v 1.1 1994/05/30 19:58:45 phil Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/reboot.h>
|
||||
#include <a.out.h>
|
||||
#include "stand.h"
|
||||
#include "samachdep.h"
|
||||
|
||||
/*
|
||||
* Boot program... bits in `howto' determine whether boot stops to
|
||||
* ask for system name. Boot device is derived from ROM provided
|
||||
* information.
|
||||
*/
|
||||
|
||||
extern unsigned opendev;
|
||||
extern int noconsole;
|
||||
extern int testing;
|
||||
|
||||
char *ssym, *esym;
|
||||
|
||||
char *name;
|
||||
char *names[] = {
|
||||
"/netbsd", "/onetbsd", "/netbsd.old",
|
||||
};
|
||||
#define NUMNAMES (sizeof(names)/sizeof(char *))
|
||||
|
||||
static int bdev, bctlr, bunit, bpart;
|
||||
|
||||
main()
|
||||
{
|
||||
int currname = 0;
|
||||
int io;
|
||||
|
||||
cninit();
|
||||
scsiinit();
|
||||
|
||||
printf("\n>> NetBSD BOOT pc532 [$Revision: 1.1 $]\n");
|
||||
|
||||
bdev = B_TYPE(bootdev);
|
||||
bctlr = B_CONTROLLER(bootdev);
|
||||
bunit = B_UNIT(bootdev);
|
||||
bpart = B_PARTITION(bootdev);
|
||||
|
||||
for (;;) {
|
||||
name = names[currname++];
|
||||
if (currname == NUMNAMES)
|
||||
currname = 0;
|
||||
|
||||
if (!noconsole) {
|
||||
howto = 0;
|
||||
getbootdev(&howto);
|
||||
}
|
||||
else
|
||||
printf(": %s\n", name);
|
||||
|
||||
io = open(name, 0);
|
||||
if (io >= 0) {
|
||||
copyunix(howto, opendev, io);
|
||||
close(io);
|
||||
}
|
||||
else
|
||||
printf("boot: %s\n", strerror(errno));
|
||||
}
|
||||
}
|
||||
|
||||
/*ARGSUSED*/
|
||||
copyunix(howto, devtype, io)
|
||||
register int howto; /* boot flags */
|
||||
register u_int devtype; /* boot device */
|
||||
register int io;
|
||||
{
|
||||
struct exec x;
|
||||
int i;
|
||||
register char *load; /* load addr for unix */
|
||||
register char *addr;
|
||||
int dev, ctlr, unit, part;
|
||||
|
||||
/* XXX use devtype? */
|
||||
dev = B_TYPE(opendev);
|
||||
ctlr = B_CONTROLLER(opendev);
|
||||
unit = B_UNIT(opendev);
|
||||
part = B_PARTITION(opendev);
|
||||
|
||||
i = read(io, (char *)&x, sizeof(x));
|
||||
if (i != sizeof(x) || N_BADMAG(x)) {
|
||||
printf("Bad format\n");
|
||||
return;
|
||||
}
|
||||
|
||||
load = addr = x.a_entry & 0x00ffff00; /* XXX make less magical? */
|
||||
printf("Booting %s%d%c:%s @ 0x%x\n",
|
||||
devsw[dev].dv_name, unit + (8*ctlr), 'a'+part, name, addr);
|
||||
|
||||
if (testing) {
|
||||
load = addr = alloc(2*1024*1024); /* XXX stat the file? */
|
||||
if (!addr) {
|
||||
printf("alloc failed\n");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
/* Text */
|
||||
printf("%d", x.a_text);
|
||||
#ifdef pc532
|
||||
if (N_GETMAGIC(x) == ZMAGIC && lseek(io, 0, SEEK_SET) == -1)
|
||||
goto shread;
|
||||
#else
|
||||
if (N_GETMAGIC(x) == ZMAGIC && lseek(io, getpagesize(), SEEK_SET) == -1)
|
||||
goto shread;
|
||||
#endif
|
||||
if (read(io, (char *)addr, x.a_text) != x.a_text)
|
||||
goto shread;
|
||||
addr += x.a_text;
|
||||
if (N_GETMAGIC(x) == NMAGIC
|
||||
#ifndef pc532
|
||||
|| N_GETMAGIC(x) == ZMAGIC
|
||||
#endif
|
||||
)
|
||||
while ((int)addr & CLOFSET)
|
||||
*addr++ = 0;
|
||||
/* Data */
|
||||
printf("+%d", x.a_data);
|
||||
if (read(io, addr, x.a_data) != x.a_data)
|
||||
goto shread;
|
||||
addr += x.a_data;
|
||||
|
||||
/* Bss */
|
||||
printf("+%d", x.a_bss);
|
||||
bzero( addr, x.a_bss );
|
||||
addr += x.a_bss;
|
||||
|
||||
/* Symbols */
|
||||
ssym = addr;
|
||||
bcopy(&x.a_syms, addr, sizeof(x.a_syms));
|
||||
addr += sizeof(x.a_syms);
|
||||
printf(" [%d+", x.a_syms);
|
||||
if (read(io, addr, x.a_syms) != x.a_syms)
|
||||
goto shread;
|
||||
addr += x.a_syms;
|
||||
|
||||
/* read size of string table */
|
||||
if (read(io, &i, sizeof(int)) != sizeof(int))
|
||||
goto shread;
|
||||
|
||||
/* read strings */
|
||||
printf("%d]", i);
|
||||
bcopy(&i, addr, sizeof(int));
|
||||
if (i) {
|
||||
i -= sizeof(int);
|
||||
addr += sizeof(int);
|
||||
if (read(io, addr, i) != i)
|
||||
goto shread;
|
||||
addr += i;
|
||||
}
|
||||
|
||||
#define round_to_size(x,t) \
|
||||
(((int)(x) + sizeof(t) - 1) & ~(sizeof(t) - 1))
|
||||
esym = (char *)round_to_size(addr - load,int);
|
||||
#undef round_to_size
|
||||
|
||||
/* and note the end address of all this */
|
||||
printf(" total=0x%x", addr);
|
||||
|
||||
#ifdef pc532
|
||||
x.a_entry &= 0xffffff;
|
||||
#endif
|
||||
printf(" start 0x%x\n", x.a_entry);
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("ssym=0x%x esym=0x%x\n", ssym, esym);
|
||||
printf("\n\nReturn to boot...\n");
|
||||
getchar();
|
||||
#endif
|
||||
|
||||
if (!testing) {
|
||||
#ifdef __GNUC__
|
||||
/* do NOT change order!!
|
||||
* the following are passed as args, and are in registers
|
||||
* clobbered by the last two movd's!!!
|
||||
*/
|
||||
asm(" movd %0,r5" : : "g" (load));
|
||||
asm(" movd %0,r6" : : "g" (devtype));
|
||||
asm(" movd %0,r7" : : "g" (howto));
|
||||
|
||||
/* magic value for locore.s to look for (3253232532) */
|
||||
asm(" movd %0,r3" : : "i" (0xc1e86394));
|
||||
asm(" movd %0,r4" : : "g" (esym));
|
||||
#endif /* __GNUC__ */
|
||||
(*((int (*)()) x.a_entry))();
|
||||
}
|
||||
return;
|
||||
shread:
|
||||
printf("Short read\n");
|
||||
return;
|
||||
}
|
||||
|
||||
char line[100];
|
||||
|
||||
getbootdev(howto)
|
||||
int *howto;
|
||||
{
|
||||
char c, *ptr = line;
|
||||
|
||||
printf("Boot: [[[%s%d%c:]%s][-s][-a][-d]] :- ",
|
||||
devsw[bdev].dv_name, bunit + (8 * bctlr), 'a'+bpart, name);
|
||||
|
||||
if (tgets(line)) {
|
||||
while (c = *ptr) {
|
||||
while (c == ' ')
|
||||
c = *++ptr;
|
||||
if (!c)
|
||||
return;
|
||||
if (c == '-')
|
||||
while ((c = *++ptr) && c != ' ')
|
||||
switch (c) {
|
||||
case 'a':
|
||||
*howto |= RB_ASKNAME;
|
||||
continue;
|
||||
case 's':
|
||||
*howto |= RB_SINGLE;
|
||||
continue;
|
||||
case 'd':
|
||||
*howto |= RB_KDB;
|
||||
continue;
|
||||
case 'b':
|
||||
*howto |= RB_HALT;
|
||||
continue;
|
||||
}
|
||||
else {
|
||||
name = ptr;
|
||||
while ((c = *++ptr) && c != ' ');
|
||||
if (c)
|
||||
*ptr++ = 0;
|
||||
}
|
||||
}
|
||||
} else
|
||||
printf("\n");
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
/*
|
||||
* Copyright (c) 1982, 1986, 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. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. 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.
|
||||
*
|
||||
* from: @(#)conf.c 8.1 (Berkeley) 6/10/93
|
||||
* $Id: conf.c,v 1.1 1994/05/30 19:58:46 phil Exp $
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
#include "stand.h"
|
||||
|
||||
int sdstrategy __P((void *devdata, int rw,
|
||||
daddr_t blk, u_int size, char *buf, u_int *rsize));
|
||||
int sdopen __P((struct open_file *f, ...));
|
||||
|
||||
extern int sdstrategy(), sdopen();
|
||||
#define sdioctl noioctl
|
||||
|
||||
struct devsw devsw[] = {
|
||||
{ "sd", sdstrategy, sdopen, nullsys, sdioctl }, /*0*/
|
||||
};
|
||||
|
||||
int ndevs = (sizeof(devsw)/sizeof(devsw[0]));
|
|
@ -0,0 +1,92 @@
|
|||
/*
|
||||
* Copyright (c) 1988 University of Utah.
|
||||
* Copyright (c) 1990, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* the Systems Programming Group of the University of Utah Computer
|
||||
* Science Department.
|
||||
*
|
||||
* 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. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. 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.
|
||||
*
|
||||
* from: Utah Hdr: cons.c 1.7 92/02/28
|
||||
* from: @(#)cons.c 8.1 (Berkeley) 6/10/93
|
||||
*
|
||||
* $Id: cons.c,v 1.1 1994/05/30 19:58:47 phil Exp $
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <dev/cons.h>
|
||||
#include "samachdep.h"
|
||||
|
||||
#ifdef SCNCONSOLE
|
||||
int scnprobe(), scninit(), scngetchar(), scnputchar();
|
||||
#endif
|
||||
|
||||
struct consdev constab[] = {
|
||||
#ifdef SCNCONSOLE
|
||||
{ scnprobe, scninit, scngetchar, scnputchar },
|
||||
#endif
|
||||
{ 0 },
|
||||
};
|
||||
|
||||
struct consdev *cn_tab;
|
||||
int noconsole;
|
||||
|
||||
cninit()
|
||||
{
|
||||
register struct consdev *cp;
|
||||
|
||||
cn_tab = NULL;
|
||||
noconsole = 1;
|
||||
for (cp = constab; cp->cn_probe; cp++) {
|
||||
(*cp->cn_probe)(cp);
|
||||
if (cp->cn_pri > CN_DEAD &&
|
||||
(cn_tab == NULL || cp->cn_pri > cn_tab->cn_pri))
|
||||
cn_tab = cp;
|
||||
}
|
||||
if (cn_tab) {
|
||||
(*cn_tab->cn_init)(cn_tab);
|
||||
noconsole = 0;
|
||||
}
|
||||
}
|
||||
|
||||
cngetc()
|
||||
{
|
||||
if (cn_tab)
|
||||
return((*cn_tab->cn_getc)());
|
||||
return(0);
|
||||
}
|
||||
|
||||
cnputc(c)
|
||||
int c;
|
||||
{
|
||||
if (cn_tab)
|
||||
(*cn_tab->cn_putc)(c);
|
||||
}
|
|
@ -0,0 +1,201 @@
|
|||
/*-
|
||||
* Copyright (c) 1993 John Brezak
|
||||
* 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. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR `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 AUTHOR 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.
|
||||
*
|
||||
* $Id: devopen.c,v 1.1 1994/05/30 19:58:48 phil Exp $
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/reboot.h>
|
||||
|
||||
#include "stand.h"
|
||||
#include "samachdep.h"
|
||||
|
||||
u_int opendev;
|
||||
|
||||
#define ispart(c) ((c) >= 'a' && (c) <= 'h')
|
||||
|
||||
atoi(char *cp)
|
||||
{
|
||||
int val = 0;
|
||||
while(isdigit(*cp))
|
||||
val = val * 10 + (*cp++ - '0');
|
||||
return(val);
|
||||
}
|
||||
|
||||
usage()
|
||||
{
|
||||
printf("\
|
||||
Usage: device(adaptor, controller, drive, partition)file\n\
|
||||
<device><unit><partitonletter>:file\n\
|
||||
");
|
||||
}
|
||||
|
||||
devlookup(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);
|
||||
|
||||
printf("No such device - Configured devices are:\n");
|
||||
for (dp = devsw, i = 0; i < ndevs; i++, dp++)
|
||||
if (dp->dv_name)
|
||||
printf(" %s", dp->dv_name);
|
||||
printf("\n");
|
||||
errno = ENODEV;
|
||||
return(-1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Parse a device spec in one of two forms.
|
||||
*
|
||||
* dev(adapt, ctlr, unit, part)file
|
||||
* [A-Za-z]*[0-9]*[A-Za-z]:file
|
||||
* dev unit part
|
||||
*/
|
||||
devparse(char *fname, int *dev, int *adapt, int *ctlr, int *unit, int *part, char **file)
|
||||
{
|
||||
int *argp, i;
|
||||
char *s, *args[4];
|
||||
|
||||
/* get device name and make lower case */
|
||||
for (s = fname; *s && *s != '/' && *s != ':' && *s != '('; s++)
|
||||
if (isupper(*s)) *s = tolower(*s);
|
||||
|
||||
/* first form */
|
||||
if (*s == '(') {
|
||||
/* lookup device and get index */
|
||||
if ((*dev = devlookup(fname, s - fname)) < 0)
|
||||
goto baddev;
|
||||
|
||||
/* tokenize device ident */
|
||||
args[0] = ++s;
|
||||
for (args[0] = s, i = 1; *s && *s != ')'; s++) {
|
||||
if (*s == ',')
|
||||
args[i++] = ++s;
|
||||
}
|
||||
switch(i) {
|
||||
case 4:
|
||||
*adapt = atoi(args[0]);
|
||||
*ctlr = atoi(args[1]);
|
||||
*unit = atoi(args[2]);
|
||||
*part = atoi(args[3]);
|
||||
break;
|
||||
case 3:
|
||||
*ctlr = atoi(args[0]);
|
||||
*unit = atoi(args[1]);
|
||||
*part = atoi(args[2]);
|
||||
break;
|
||||
case 2:
|
||||
*unit = atoi(args[0]);
|
||||
*part = atoi(args[1]);
|
||||
break;
|
||||
case 1:
|
||||
*part = atoi(args[0]);
|
||||
break;
|
||||
case 0:
|
||||
break;
|
||||
}
|
||||
*file = ++s;
|
||||
}
|
||||
|
||||
/* second form */
|
||||
else if (*s == ':') {
|
||||
/* isolate device */
|
||||
for (s = fname; *s != ':' && !isdigit(*s); s++);
|
||||
|
||||
/* lookup device and get index */
|
||||
if ((*dev = devlookup(fname, s - fname)) < 0)
|
||||
goto baddev;
|
||||
|
||||
/* isolate unit */
|
||||
if ((*unit = atoi(s)) > sizeof(char))
|
||||
goto bad;
|
||||
for (; isdigit(*s); s++);
|
||||
|
||||
/* translate partition */
|
||||
if (!ispart(*s))
|
||||
goto bad;
|
||||
|
||||
*part = *s++ - 'a';
|
||||
if (*s != ':')
|
||||
goto bad;
|
||||
*file = ++s;
|
||||
}
|
||||
|
||||
/* no device present */
|
||||
else
|
||||
*file = fname;
|
||||
|
||||
/* return the remaining unparsed part as the file to boot */
|
||||
return(0);
|
||||
|
||||
bad:
|
||||
usage();
|
||||
|
||||
baddev:
|
||||
return(-1);
|
||||
}
|
||||
|
||||
|
||||
devopen(f, fname, file)
|
||||
struct open_file *f;
|
||||
char *fname;
|
||||
char **file;
|
||||
{
|
||||
int n, error;
|
||||
int dev, ctlr, unit, part;
|
||||
int adapt = 0; /* XXX not used on HP */
|
||||
struct devsw *dp = &devsw[0];
|
||||
|
||||
dev = B_TYPE(bootdev);
|
||||
ctlr = B_CONTROLLER(bootdev);
|
||||
unit = B_UNIT(bootdev);
|
||||
part = B_PARTITION(bootdev);
|
||||
|
||||
if (error = devparse(fname, &dev, &adapt, &ctlr, &unit, &part, file))
|
||||
return(error);
|
||||
|
||||
dp = &devsw[dev];
|
||||
|
||||
if (!dp->dv_open)
|
||||
return(ENODEV);
|
||||
|
||||
opendev = MAKEBOOTDEV(dev, adapt, ctlr, unit, part);
|
||||
|
||||
f->f_dev = dp;
|
||||
|
||||
if ((error = (*dp->dv_open)(f, ctlr, unit, part)) == 0)
|
||||
return(0);
|
||||
|
||||
printf("%s(%d,%d,%d,%d): %s\n", devsw[dev].dv_name,
|
||||
adapt, ctlr, unit, part, strerror(error));
|
||||
|
||||
return(error);
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
/*
|
||||
* Copyright (c) 1993 Philip A. Nelson.
|
||||
* 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. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by Philip A. Nelson.
|
||||
* 4. The name of Philip A. Nelson may not be used to endorse or promote
|
||||
* products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY PHILIP NELSON ``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 PHILIP NELSON 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.
|
||||
*
|
||||
* filesystem.c
|
||||
*
|
||||
* $Id: filesystem.c,v 1.1 1994/05/30 19:58:49 phil Exp $
|
||||
*/
|
||||
|
||||
#include <stand.h>
|
||||
#include <ufs.h>
|
||||
|
||||
struct fs_ops file_system[] =
|
||||
{ ufs_open, ufs_close, ufs_read, ufs_write, ufs_seek, ufs_stat };
|
||||
|
||||
int nfsys = sizeof(file_system)/sizeof(struct fs_ops);
|
|
@ -0,0 +1,100 @@
|
|||
/*
|
||||
* Copyright (c) 1994 Philip L. Budne.
|
||||
* 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. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by Philip L. Budne.
|
||||
* 4. The name of Philip L. Budne may not be used to endorse or promote
|
||||
* products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY PHILIP NELSON ``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 PHILIP NELSON 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.
|
||||
*
|
||||
* scn.c
|
||||
*
|
||||
* $Id: machdep.c,v 1.1 1994/05/30 19:58:50 phil Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
* pc532 standalone machdep code
|
||||
* Phil Budne, May 10, 1994
|
||||
*
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include "samachdep.h"
|
||||
|
||||
int testing = 0;
|
||||
|
||||
void
|
||||
bzero( char *addr, int len )
|
||||
{
|
||||
while (len-- > 0)
|
||||
*addr++ = '\0';
|
||||
}
|
||||
|
||||
/* XXX TEMP; would like to use code more like hp300 scsi.c */
|
||||
|
||||
void
|
||||
scsiinit(void)
|
||||
{
|
||||
}
|
||||
|
||||
int
|
||||
scsialive(int ctlr)
|
||||
{
|
||||
return 1; /* controller always alive! */
|
||||
}
|
||||
|
||||
/* call functions in scsi_hi.c */
|
||||
#include "so.h"
|
||||
|
||||
int
|
||||
scsi_tt_read(ctlr, slave, buf, len, blk, nblk)
|
||||
int ctlr, slave;
|
||||
u_char *buf;
|
||||
u_int len;
|
||||
daddr_t blk;
|
||||
u_int nblk;
|
||||
{
|
||||
#if 0
|
||||
printf("scsi_tt_read ctlr %d, slave %d, len %d, blk %d, nblk %d\n",
|
||||
ctlr, slave, len, blk, nblk );
|
||||
#endif
|
||||
if (sc_rdwt(DISK_READ, blk, buf, nblk, 1<<slave, 0) == 0)
|
||||
return 0;
|
||||
return -2;
|
||||
}
|
||||
|
||||
int
|
||||
scsi_tt_write(ctlr, slave, buf, len, blk, nblk)
|
||||
int ctlr, slave;
|
||||
u_char *buf;
|
||||
u_int len;
|
||||
daddr_t blk;
|
||||
u_int nblk;
|
||||
{
|
||||
#if 0
|
||||
if (sc_rdwt(DISK_WRITE, blk, buf, nblk, 1<<slave, 0) == 0)
|
||||
return 0;
|
||||
#endif
|
||||
return -2;
|
||||
}
|
|
@ -0,0 +1,78 @@
|
|||
/*
|
||||
* Copyright (c) 1982, 1986, 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. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. 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.
|
||||
*
|
||||
* from: @(#)prf.c 8.1 (Berkeley) 6/10/93
|
||||
* $Id: prf.c,v 1.1 1994/05/30 19:58:51 phil Exp $
|
||||
*/
|
||||
|
||||
getchar()
|
||||
{
|
||||
register int c;
|
||||
|
||||
while((c = cngetc()) == 0)
|
||||
;
|
||||
if (c == '\r')
|
||||
c = '\n';
|
||||
else if (c == ('c'&037)) {
|
||||
panic("^C");
|
||||
/* NOTREACHED */
|
||||
}
|
||||
if (c != '\b' && c != '\177')
|
||||
putchar(c);
|
||||
return(c);
|
||||
}
|
||||
|
||||
tgetchar()
|
||||
{
|
||||
register int c;
|
||||
|
||||
if ((c = cngetc()) == 0)
|
||||
return(0);
|
||||
|
||||
if (c == '\r')
|
||||
c = '\n';
|
||||
else if (c == ('c'&037)) {
|
||||
panic("^C");
|
||||
/* NOTREACHED */
|
||||
}
|
||||
if (c != '\b' && c != '\177')
|
||||
putchar(c);
|
||||
return(c);
|
||||
}
|
||||
|
||||
putchar(c)
|
||||
register int c;
|
||||
{
|
||||
cnputc(c);
|
||||
if (c == '\n')
|
||||
cnputc('\r');
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
/*
|
||||
* 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. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. 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.
|
||||
*
|
||||
* from: @(#)samachdep.h 8.1 (Berkeley) 6/10/93
|
||||
*
|
||||
* $Id: samachdep.h,v 1.1 1994/05/30 19:58:53 phil Exp $
|
||||
*/
|
||||
|
||||
#define NSCSI 1
|
||||
#define NSD 8
|
||||
|
||||
extern int howto;
|
||||
extern unsigned int bootdev;
|
|
@ -0,0 +1,103 @@
|
|||
/*-
|
||||
* Copyright (c) 1994 Philip L. Budne.
|
||||
* 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. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by Philip L. Budne.
|
||||
* 4. The name of Philip L. Budne may not be used to endorse or promote
|
||||
* products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY PHILIP BUDNE ``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 PHILIP BUDNE 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.
|
||||
*
|
||||
* scn.c
|
||||
*
|
||||
* $Id: scn.c,v 1.1 1994/05/30 19:58:54 phil Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
* scn.c -- scn2681/2692/68881 standalone console driver
|
||||
* Phil Budne, May 10, 1994
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef SCNCONSOLE
|
||||
#include <sys/types.h>
|
||||
#include <dev/cons.h>
|
||||
|
||||
#define DUART 0x28000000
|
||||
|
||||
/* registers */
|
||||
#define SCN_STAT 1
|
||||
#define SCN_DATA 3
|
||||
|
||||
/* status bits */
|
||||
#define STAT_RXRDY 0x01
|
||||
#define STAT_TXRDY 0x04
|
||||
|
||||
#ifndef SCNCNUNIT
|
||||
#define SCNCNUNIT 0
|
||||
#endif
|
||||
|
||||
unsigned char * volatile scncnaddr = (unsigned char *) DUART + 8 * SCNCNUNIT;
|
||||
|
||||
scnprobe(cp)
|
||||
struct consdev *cp;
|
||||
{
|
||||
/* the only game in town */
|
||||
cp->cn_pri = CN_NORMAL; /* XXX remote? */
|
||||
}
|
||||
|
||||
scninit(cp)
|
||||
struct consdev *cp;
|
||||
{
|
||||
/* leave things they way the PROM set them */
|
||||
}
|
||||
|
||||
scngetchar()
|
||||
{
|
||||
register unsigned char * volatile scn = scncnaddr;
|
||||
|
||||
if ((scn[SCN_STAT] & STAT_RXRDY) == 0)
|
||||
return(0);
|
||||
return scn[SCN_DATA];
|
||||
}
|
||||
|
||||
scnputchar(c)
|
||||
register int c;
|
||||
{
|
||||
register unsigned char * volatile scn = scncnaddr;
|
||||
register int timo;
|
||||
short stat;
|
||||
|
||||
/* wait a reasonable time for the transmitter to come ready */
|
||||
timo = 50000;
|
||||
while (((stat = scn[SCN_STAT]) & STAT_TXRDY) == 0 && --timo)
|
||||
;
|
||||
scn[SCN_DATA] = c;
|
||||
#if 0
|
||||
/* wait for this transmission to complete */
|
||||
timo = 1000000;
|
||||
while (((stat = scn[SCN_STAT]) & STAT_TXRDY) == 0 && --timo)
|
||||
;
|
||||
#endif
|
||||
}
|
||||
#endif
|
|
@ -0,0 +1,300 @@
|
|||
/****************************************************************************
|
||||
* NS32K Monitor SCSI high-level driver
|
||||
* Bruce Culbertson
|
||||
* 8 March 1990
|
||||
*
|
||||
* There are three monitor SCSI commands. "Read" and "write" I think are
|
||||
* fairly self explanatory once you read the help messages. They, in fact,
|
||||
* execute the "extended read", "extended write", and "request sense"
|
||||
* commands from the SCSI standard.
|
||||
*
|
||||
* "Raw" lets you execute any SCSI command but you need a SCSI reference to
|
||||
* know what the commands are and what their formats are. The SCSI
|
||||
* standard specifies that there are six buffers which, for example, hold a
|
||||
* SCSI command or are the source or destination for data. You provide
|
||||
* "raw" with an array of pointers to the six buffers. Using "edit", you
|
||||
* can enter a SCSI command somewhere in memory and you can create the
|
||||
* array of pointers. The array must actually be eight entries long; two
|
||||
* entries are not used. By typing "raw <array address>", the SCSI command
|
||||
* is executed.
|
||||
*
|
||||
* By the way, "read", "write", and "raw" talk only to the DP8490 SCSI
|
||||
* controller. I have not had time to read the Adaptec data sheet and
|
||||
* write a driver for it.
|
||||
****************************************************************************/
|
||||
#include "so.h"
|
||||
|
||||
#define OK 0
|
||||
#define NOT_OK OK+1
|
||||
#define PRIVATE
|
||||
#define PUBLIC
|
||||
#define U8 unsigned char
|
||||
|
||||
long scsiAdr = DEFAULT_SCSI_ADR, /* default SCSI address */
|
||||
scsiLun = DEFAULT_SCSI_LUN;
|
||||
|
||||
struct cmd_desc { /* SCSI command description */
|
||||
const U8 *cmd; /* command string */
|
||||
const U8 *odata; /* data to output, if any */
|
||||
const struct cmd_desc *chain; /* next command */
|
||||
};
|
||||
|
||||
struct drive { /* SCSI drive description */
|
||||
U8 adr, lun; /* SCSI address and LUN */
|
||||
U8 flags; /* drive characteristics */
|
||||
U8 stat; /* drive state */
|
||||
const struct cmd_desc *init; /* list of initialize commands */
|
||||
};
|
||||
/* for drive.flags */
|
||||
#define EXTENDED_RDWR 1 /* device does extended read, write */
|
||||
#define EXTENDED_SENSE 2 /* device does extended sense */
|
||||
/* for drive.stat */
|
||||
#define INITIALIZED 1 /* device is initialized */
|
||||
|
||||
#ifdef OMTI
|
||||
/* These SCSI commands initialize a OMTI 5200 SCSI controller with a 360K
|
||||
* floppy at LUN=1 and an ST-225 at LUN=0.
|
||||
*/
|
||||
const U8 floppy_parms_cmd[] = {0xc2, 0x20, 0, 0, 0, 0};
|
||||
const U8 floppy_parms_data[] = {0, 3, 0x27, 0xa, 0, 0, 0, 0x80, 1, 0};
|
||||
const U8 floppy_format_cmd[] = {0xc0, 0x20, 0, 0, 9, 0x8b};
|
||||
const U8 floppy_recal_cmd[] = {1, 0x20, 0, 0, 0, 0};
|
||||
const U8 wini_parms_cmd[] = {0xc2, 0, 0, 0, 0, 0};
|
||||
const U8 wini_parms_data[] = {0, 0, 0, 3, 2, 0x63, 0, 1, 0x10, 0};
|
||||
const U8 wini_recal_cmd[] = {1, 0, 0, 0, 0, 0};
|
||||
const struct cmd_desc floppy_init2 =
|
||||
{floppy_recal_cmd, 0, 0};
|
||||
const struct cmd_desc floppy_init1 =
|
||||
{floppy_format_cmd, 0, &floppy_init2};
|
||||
const struct cmd_desc floppy_init0 =
|
||||
{floppy_parms_cmd, floppy_parms_data, &floppy_init1};
|
||||
const struct cmd_desc wini_init1 =
|
||||
{wini_recal_cmd, 0, 0};
|
||||
const struct cmd_desc wini_init0 =
|
||||
{wini_parms_cmd, wini_parms_data, &wini_init1};
|
||||
#endif
|
||||
|
||||
PRIVATE struct drive drive_tbl[] = {
|
||||
#ifdef OMTI
|
||||
{1, 0, 0, 0, &wini_init0},
|
||||
{1, 1, 0, 0, &floppy_init0},
|
||||
#endif
|
||||
{0, 0, EXTENDED_RDWR | EXTENDED_SENSE, 1, 0},
|
||||
};
|
||||
#define DRV_TBL_SZ (sizeof (drive_tbl) / sizeof (struct drive))
|
||||
|
||||
/* Round up to multiple of four since SCSI transfers are always multiples
|
||||
* of four bytes.
|
||||
*/
|
||||
#define CMD_LEN 12 /* longest SCSI command */
|
||||
#define SENSE_LEN 24 /* extended sense length */
|
||||
#define MSG_LEN 4
|
||||
#define STAT_LEN 4
|
||||
|
||||
#define MAX_SCSI_RETRIES 6
|
||||
#define CMD_IX 2
|
||||
#define CMD_SENSE 0x03
|
||||
#define CMD_READ 0x08
|
||||
#define CMD_WRITE 0x0a
|
||||
#define CMD_XREAD 0x28
|
||||
#define CMD_XWRITE 0x2a
|
||||
PRIVATE U8 cmd_buf[CMD_LEN];
|
||||
|
||||
#define SENSE_KEY 2
|
||||
#define NO_SENSE 0
|
||||
#define RECOVERY_ERR 1
|
||||
#define UNIT_ATTN 6
|
||||
#define ADD_SENSE_CODE 12
|
||||
#define SENSE_RST 0x29
|
||||
PRIVATE U8 sense_buf[SENSE_LEN];
|
||||
|
||||
#define CHECK_CONDITION 2
|
||||
#define STAT_IX 3
|
||||
#define STAT_MASK 0x1f
|
||||
PRIVATE U8 stat_buf[STAT_LEN];
|
||||
#define IMSG_IX 7
|
||||
PRIVATE U8 msg_buf[MSG_LEN];
|
||||
|
||||
#define ODATA_IX 0
|
||||
#define IDATA_IX 1
|
||||
PRIVATE struct scsi_args scsi_args;
|
||||
|
||||
/*===========================================================================*
|
||||
* sc_rdwt *
|
||||
*===========================================================================*/
|
||||
/* Carry out a read or write request for the SCSI disk. */
|
||||
PRIVATE int
|
||||
sc_rdwt(op, block, ram_adr, len, sc_adr, lun)
|
||||
long block, ram_adr, len, sc_adr, lun;
|
||||
{
|
||||
int retries, ret;
|
||||
U8 *p;
|
||||
struct drive *dp;
|
||||
|
||||
/* get drive characteristics */
|
||||
for (dp = drive_tbl; dp < drive_tbl + DRV_TBL_SZ - 1; ++dp)
|
||||
if (dp->adr == sc_adr && dp->lun == lun) break;
|
||||
if (dp == drive_tbl + DRV_TBL_SZ - 1) {
|
||||
dp->adr = sc_adr; /* have default, set adr, lun */
|
||||
dp->lun = lun;
|
||||
}
|
||||
for (retries = 0; retries < MAX_SCSI_RETRIES; ++retries) {
|
||||
if (dp->init && !(dp->stat & INITIALIZED))
|
||||
if (OK != sc_initialize (dp)) {
|
||||
printf("SCSI cannot initialize device\n");
|
||||
return NOT_OK;
|
||||
}
|
||||
p = cmd_buf; /* build SCSI command */
|
||||
if (dp->flags & EXTENDED_RDWR) { /* use extended commands */
|
||||
*p++ = (op == DISK_READ)? CMD_XREAD: CMD_XWRITE;
|
||||
*p++ = lun << 5;
|
||||
*p++ = (block >> 24) & 0xff;
|
||||
*p++ = (block >> 16) & 0xff;
|
||||
*p++ = (block >> 8) & 0xff;
|
||||
*p++ = (block >> 0) & 0xff;
|
||||
*p++ = 0;
|
||||
*p++ = (len >> 8) & 0xff;
|
||||
*p++ = (len >> 0) & 0xff;
|
||||
*p = 0;
|
||||
} else { /* use short (SASI) commands */
|
||||
*p++ = (op == DISK_READ)? CMD_READ: CMD_WRITE;
|
||||
*p++ = (lun << 5) | ((block >> 16) & 0x1f);
|
||||
*p++ = (block >> 8) & 0xff;
|
||||
*p++ = (block >> 0) & 0xff;
|
||||
*p++ = len;
|
||||
*p = 0;
|
||||
}
|
||||
if (op == DISK_READ)
|
||||
ret = exec_scsi_hi (cmd_buf, (U8 *)ram_adr, (U8 *)0, dp);
|
||||
else
|
||||
ret = exec_scsi_hi (cmd_buf, (U8 *)0, (U8 *)ram_adr, dp);
|
||||
if (OK == ret) return OK;
|
||||
dp->stat &= ~INITIALIZED;
|
||||
}
|
||||
printf("SCSI %s, block %d failed even after retries\n",
|
||||
op == DISK_READ? "READ": "WRITE", block);
|
||||
return NOT_OK;
|
||||
}
|
||||
|
||||
/*===========================================================================*
|
||||
* sc_initialize *
|
||||
*===========================================================================*/
|
||||
/* Execute the list of initialization commands for the given drive.
|
||||
*/
|
||||
int
|
||||
sc_initialize (dp)
|
||||
struct drive *dp;
|
||||
{
|
||||
const struct cmd_desc *cp;
|
||||
|
||||
for (cp = dp->init; cp != 0; cp = cp->chain)
|
||||
if (OK != exec_scsi_hi (cp->cmd, 0, cp->odata, dp)) {
|
||||
dp->stat &= ~INITIALIZED;
|
||||
return NOT_OK;
|
||||
}
|
||||
dp->stat |= INITIALIZED;
|
||||
return OK;
|
||||
}
|
||||
|
||||
/*===========================================================================*
|
||||
* exec_scsi_hi *
|
||||
*===========================================================================*/
|
||||
/* Execute a "high-level" SCSI command. This means execute a low level
|
||||
* command and, if it fails, execute a request sense to find out why.
|
||||
*/
|
||||
PRIVATE int
|
||||
exec_scsi_hi(cmd, data_in, data_out, dp)
|
||||
U8 *cmd, *data_out, *data_in;
|
||||
struct drive *dp;
|
||||
{
|
||||
scsi_args.ptr[CMD_IX] = (long)cmd;
|
||||
scsi_args.ptr[STAT_IX] = (long)stat_buf;
|
||||
scsi_args.ptr[IMSG_IX] = (long)msg_buf;
|
||||
scsi_args.ptr[IDATA_IX] = (long)data_in;
|
||||
scsi_args.ptr[ODATA_IX] = (long)data_out;
|
||||
if (OK != exec_scsi_low (&scsi_args, dp->adr))
|
||||
return NOT_OK;
|
||||
*stat_buf &= STAT_MASK; /* strip off lun */
|
||||
if (*stat_buf == 0)
|
||||
/* Success -- this should be the usual case */
|
||||
return OK;
|
||||
if (*stat_buf != CHECK_CONDITION) {
|
||||
/* do not know how to handle this so return error */
|
||||
printf("SCSI device returned unknown status: %d\n", *stat_buf);
|
||||
return NOT_OK;
|
||||
}
|
||||
/* Something funny happened, need to execute request-sense command
|
||||
* to learn more.
|
||||
*/
|
||||
if (OK == get_sense(dp))
|
||||
/* Something funny happened, but the device recovered from it and
|
||||
* the command succeeded.
|
||||
*/
|
||||
return OK;
|
||||
return NOT_OK;
|
||||
}
|
||||
|
||||
/*===========================================================================*
|
||||
* get_sense *
|
||||
*===========================================================================*/
|
||||
/* Execute a "request sense" SCSI command and check results. When a SCSI
|
||||
* command returns CHECK_CONDITION, a request-sense command must be executed.
|
||||
* A request-sense command provides information about the original command.
|
||||
* The original command might have succeeded, in which case it does not
|
||||
* need to be retried and OK is returned. Examples: read error corrected
|
||||
* with error correction code, or error corrected by retries performed by
|
||||
* the SCSI device. The original command also could have failed, in
|
||||
* which case NOT_OK is returned.
|
||||
*/
|
||||
#define XLOGICAL_ADR \
|
||||
(sense_buf[3]<<24 | sense_buf[4]<<16 | sense_buf[5]<<8 | sense_buf[6])
|
||||
#define LOGICAL_ADR \
|
||||
(sense_buf[1]<<16 | sense_buf[2]<<8 | sense_buf[3])
|
||||
|
||||
PRIVATE int
|
||||
get_sense (dp)
|
||||
struct drive *dp;
|
||||
{
|
||||
U8 *p;
|
||||
|
||||
p = cmd_buf; /* build SCSI command */
|
||||
*p++ = CMD_SENSE;
|
||||
*p++ = dp->lun << 5;
|
||||
*p++ = 0;
|
||||
*p++ = 0;
|
||||
*p++ = (dp->flags & EXTENDED_SENSE)? SENSE_LEN: 0;
|
||||
*p = 0;
|
||||
scsi_args.ptr[IDATA_IX] = (long)sense_buf;
|
||||
scsi_args.ptr[ODATA_IX] = 0;
|
||||
scsi_args.ptr[CMD_IX] = (long)cmd_buf;
|
||||
scsi_args.ptr[STAT_IX] = (long)stat_buf;
|
||||
scsi_args.ptr[IMSG_IX] = (long)msg_buf;
|
||||
if (OK != exec_scsi_low (&scsi_args, dp->adr)) {
|
||||
printf("SCSI SENSE command failed\n");
|
||||
return NOT_OK;
|
||||
}
|
||||
if ((*stat_buf & STAT_MASK) != 0) {
|
||||
printf("SCSI SENSE returned wrong status %d\n", *stat_buf);
|
||||
return NOT_OK;
|
||||
}
|
||||
if (0 == (dp->flags & EXTENDED_SENSE)) {
|
||||
printf("SCSI request sense, code 0x%x, log_adr 0x%x\n",
|
||||
sense_buf[0], LOGICAL_ADR);
|
||||
return NOT_OK;
|
||||
}
|
||||
switch (sense_buf[SENSE_KEY] & 0xf) {
|
||||
case NO_SENSE:
|
||||
case UNIT_ATTN: /* reset */
|
||||
return NOT_OK; /* must retry command */
|
||||
case RECOVERY_ERR:
|
||||
/* eventually, we probably do not want to hear about these. */
|
||||
printf("SCSI ok with recovery, code 0x%x, logical address 0x%x\n",
|
||||
sense_buf[ADD_SENSE_CODE], XLOGICAL_ADR);
|
||||
return OK; /* orig command was ok with recovery */
|
||||
default:
|
||||
printf("SCSI failure: key 0x%x code 0x%x log adr 0x%x sense buf 0x%x\n",
|
||||
sense_buf[SENSE_KEY], sense_buf[ADD_SENSE_CODE],
|
||||
XLOGICAL_ADR, sense_buf);
|
||||
return NOT_OK; /* orig command failed */
|
||||
}
|
||||
}
|
|
@ -0,0 +1,418 @@
|
|||
/****************************************************************************
|
||||
* NS32K Monitor SCSI low-level driver
|
||||
* Bruce Culbertson
|
||||
* 8 March 1990
|
||||
*
|
||||
* Adapted from Minix SCSI driver. Do not use DMA -- makes 32016 and pc532
|
||||
* versions compatible. Do not use interrupts -- makes it harder for the
|
||||
* user code to bomb this code.
|
||||
****************************************************************************/
|
||||
#include "so.h"
|
||||
|
||||
#define OK 0
|
||||
#define NOT_OK OK+1
|
||||
#define PRIVATE
|
||||
#define PUBLIC
|
||||
#define WR_ADR(adr,val) (*((volatile unsigned char *)(adr))=(val))
|
||||
#define RD_ADR(adr) (*((volatile unsigned char *)(adr)))
|
||||
#define AIC6250 0
|
||||
#define DP8490 1
|
||||
#define MAX_CACHE 0x10000
|
||||
|
||||
/* SCSI bus phases
|
||||
*/
|
||||
#define PH_ODATA 0
|
||||
#define PH_IDATA 1
|
||||
#define PH_CMD 2
|
||||
#define PH_STAT 3
|
||||
#define PH_IMSG 7
|
||||
#define PH_NONE 8
|
||||
#define PH_IN(phase) ((phase) & 1)
|
||||
|
||||
/* NCR5380 SCSI controller registers
|
||||
*/
|
||||
#define SC_CTL 0x30000000 /* base for control registers */
|
||||
#define SC_DMA 0x38000000 /* base for data registers */
|
||||
#define SC_CURDATA SC_CTL+0
|
||||
#define SC_OUTDATA SC_CTL+0
|
||||
#define SC_ICMD SC_CTL+1
|
||||
#define SC_MODE SC_CTL+2
|
||||
#define SC_TCMD SC_CTL+3
|
||||
#define SC_STAT1 SC_CTL+4
|
||||
#define SC_STAT2 SC_CTL+5
|
||||
#define SC_START_SEND SC_CTL+5
|
||||
#define SC_INDATA SC_CTL+6
|
||||
#define SC_RESETIP SC_CTL+7
|
||||
#define SC_START_RCV SC_CTL+7
|
||||
|
||||
/* Bits in NCR5380 registers
|
||||
*/
|
||||
#define SC_A_RST 0x80
|
||||
#define SC_A_SEL 0x04
|
||||
#define SC_S_SEL 0x02
|
||||
#define SC_S_REQ 0x20
|
||||
#define SC_S_BSY 0x40
|
||||
#define SC_S_BSYERR 0x04
|
||||
#define SC_S_PHASE 0x08
|
||||
#define SC_S_IRQ 0x10
|
||||
#define SC_S_DRQ 0x40
|
||||
#define SC_M_DMA 0x02
|
||||
#define SC_M_BSY 0x04
|
||||
#define SC_ENABLE_DB 0x01
|
||||
|
||||
/* Status of interrupt routine, returned in m1_i1 field of message.
|
||||
*/
|
||||
#define ISR_NOTDONE 0
|
||||
#define ISR_OK 1
|
||||
#define ISR_BSYERR 2
|
||||
#define ISR_RSTERR 3
|
||||
#define ISR_BADPHASE 4
|
||||
#define ISR_TIMEOUT 5
|
||||
|
||||
#define ICU_ADR 0xfffffe00
|
||||
#define ICU_IO (ICU_ADR+20)
|
||||
#define ICU_DIR (ICU_ADR+21)
|
||||
#define ICU_DATA (ICU_ADR+19)
|
||||
#define ICU_SCSI_BIT 0x80
|
||||
|
||||
/* Miscellaneous
|
||||
*/
|
||||
#define MAX_WAIT 2000000
|
||||
#define SC_LOG_LEN 32
|
||||
|
||||
PRIVATE struct scsi_args *sc_ptrs;
|
||||
PRIVATE char sc_cur_phase,
|
||||
sc_reset_done,
|
||||
sc_have_msg,
|
||||
sc_accept_int,
|
||||
sc_dma_dir;
|
||||
|
||||
long sc_dma_port = SC_DMA,
|
||||
sc_dma_adr;
|
||||
|
||||
#ifdef DEBUG
|
||||
struct sc_log {
|
||||
unsigned char stat1, stat2;
|
||||
} sc_log [SC_LOG_LEN],
|
||||
*sc_log_head = sc_log;
|
||||
int sc_spurious_int;
|
||||
#endif
|
||||
unsigned char
|
||||
sc_watchdog_error; /* watch dog error */
|
||||
|
||||
/* error messages */
|
||||
char *scsi_errors[] = {
|
||||
0, /* ISR_NOTDONE */
|
||||
0, /* ISR_OK */
|
||||
"busy error", /* ISR_BSYERR */
|
||||
"reset error", /* ISR_RSTERR */
|
||||
"NULL pointer for current phase", /* ISR_BADPHASE */
|
||||
"timeout", /* ISR_TIMEOUT */
|
||||
};
|
||||
|
||||
/*===========================================================================*
|
||||
* exec_scsi_low *
|
||||
*===========================================================================*/
|
||||
/* Execute a generic SCSI command. Passed pointers to eight buffers:
|
||||
* data-out, data-in, command, status, dummy, dummy, message-out, message-in.
|
||||
*/
|
||||
PUBLIC
|
||||
int
|
||||
exec_scsi_low (args, scsi_adr)
|
||||
struct scsi_args *args;
|
||||
long scsi_adr;
|
||||
{
|
||||
int ret;
|
||||
|
||||
sc_ptrs = args; /* make pointers globally accessible */
|
||||
scCtlrSelect (DP8490);
|
||||
if (!sc_reset_done) sc_reset();
|
||||
/* TCMD has some undocumented behavior in initiator mode. I think the
|
||||
* data bus cannot be enabled if i/o is asserted.
|
||||
*/
|
||||
WR_ADR (SC_TCMD, 0);
|
||||
if (OK != sc_wait_bus_free ()) { /* bus-free phase */
|
||||
printf("SCSI: bus not free\n");
|
||||
return NOT_OK;
|
||||
}
|
||||
sc_cur_phase = PH_NONE;
|
||||
sc_have_msg = 0;
|
||||
if (OK != sc_select (scsi_adr)) /* select phase */
|
||||
return NOT_OK;
|
||||
sc_watchdog_error = 0;
|
||||
ret = sc_receive (); /* isr does the rest */
|
||||
if (ret == ISR_OK) return OK;
|
||||
else {
|
||||
sc_reset();
|
||||
printf("SCSI: %s\n", scsi_errors[ret]);
|
||||
return NOT_OK;
|
||||
}
|
||||
}
|
||||
|
||||
/*===========================================================================*
|
||||
* sc_reset *
|
||||
*===========================================================================*/
|
||||
/*
|
||||
* Reset SCSI bus.
|
||||
*/
|
||||
PRIVATE
|
||||
sc_reset()
|
||||
{
|
||||
volatile int i;
|
||||
|
||||
WR_ADR (SC_MODE, 0); /* get into harmless state */
|
||||
WR_ADR (SC_OUTDATA, 0);
|
||||
WR_ADR (SC_ICMD, SC_A_RST); /* assert RST on SCSI bus */
|
||||
i = 200; /* wait 25 usec */
|
||||
while (i--);
|
||||
WR_ADR (SC_ICMD, 0); /* deassert RST, get off bus */
|
||||
sc_reset_done = 1;
|
||||
}
|
||||
|
||||
/*===========================================================================*
|
||||
* sc_wait_bus_free *
|
||||
*===========================================================================*/
|
||||
PRIVATE int
|
||||
sc_wait_bus_free()
|
||||
{
|
||||
int i = MAX_WAIT;
|
||||
volatile int j;
|
||||
|
||||
while (i--) {
|
||||
/* Must be clear for 2 usec, so read twice */
|
||||
if (RD_ADR (SC_STAT1) & (SC_S_BSY | SC_S_SEL)) continue;
|
||||
for (j = 0; j < 25; ++j);
|
||||
if (RD_ADR (SC_STAT1) & (SC_S_BSY | SC_S_SEL)) continue;
|
||||
return OK;
|
||||
}
|
||||
sc_reset_done = 0;
|
||||
return NOT_OK;
|
||||
}
|
||||
|
||||
/*===========================================================================*
|
||||
* sc_select *
|
||||
*===========================================================================*/
|
||||
/* This duplicates much of the work that the interrupt routine would do on a
|
||||
* phase mismatch and, in fact, the original plan was to just do the select,
|
||||
* let a phase mismatch occur, and let the interrupt routine do the rest.
|
||||
* That didn't work because the 5380 did not reliably generate the phase
|
||||
* mismatch interrupt after selection.
|
||||
*/
|
||||
PRIVATE int
|
||||
sc_select(adr)
|
||||
long adr;
|
||||
{
|
||||
int i, stat1;
|
||||
long new_ptr;
|
||||
|
||||
WR_ADR (SC_OUTDATA, adr); /* SCSI bus address */
|
||||
WR_ADR (SC_ICMD, SC_A_SEL | SC_ENABLE_DB);
|
||||
for (i = 0;; ++i) { /* wait for target to assert SEL */
|
||||
stat1 = RD_ADR (SC_STAT1);
|
||||
if (stat1 & SC_S_BSY) break; /* select successful */
|
||||
if (i > MAX_WAIT) { /* timeout */
|
||||
printf("SCSI: SELECT timeout\n");
|
||||
sc_reset();
|
||||
return NOT_OK;
|
||||
}
|
||||
}
|
||||
WR_ADR (SC_ICMD, 0); /* clear SEL, disable data out */
|
||||
WR_ADR (SC_OUTDATA, 0);
|
||||
for (i = 0;; ++i) { /* wait for target to assert REQ */
|
||||
if (stat1 & SC_S_REQ) break; /* target requesting transfer */
|
||||
if (i > MAX_WAIT) { /* timeout */
|
||||
printf("SCSI: REQ timeout\n");
|
||||
sc_reset();
|
||||
return NOT_OK;
|
||||
}
|
||||
stat1 = RD_ADR (SC_STAT1);
|
||||
}
|
||||
sc_cur_phase = (stat1 >> 2) & 7; /* get new phase from controller */
|
||||
if (sc_cur_phase != PH_CMD) {
|
||||
printf("SCSI: bad phase = %d\n", sc_cur_phase);
|
||||
sc_reset();
|
||||
return NOT_OK;
|
||||
}
|
||||
new_ptr = sc_ptrs->ptr[PH_CMD];
|
||||
if (new_ptr == 0) {
|
||||
printf("SCSI: NULL command pointer\n");
|
||||
sc_reset();
|
||||
return NOT_OK;
|
||||
}
|
||||
sc_accept_int = 1;
|
||||
sc_dma_setup (DISK_WRITE, new_ptr);
|
||||
WR_ADR (SC_TCMD, PH_CMD);
|
||||
WR_ADR (SC_ICMD, SC_ENABLE_DB);
|
||||
WR_ADR (SC_MODE, SC_M_BSY | SC_M_DMA);
|
||||
WR_ADR (SC_START_SEND, 0);
|
||||
return OK;
|
||||
}
|
||||
|
||||
/*===========================================================================*
|
||||
* scsi_interrupt *
|
||||
*===========================================================================*/
|
||||
/* SCSI interrupt handler.
|
||||
*/
|
||||
PUBLIC
|
||||
int
|
||||
scsi_interrupt()
|
||||
{
|
||||
unsigned char stat2, dummy;
|
||||
long new_ptr;
|
||||
int ret = ISR_NOTDONE;
|
||||
|
||||
stat2 = RD_ADR (SC_STAT2); /* get status before clearing request */
|
||||
|
||||
# ifdef DEBUG /* debugging log of interrupts */
|
||||
sc_log_head->stat1 = RD_ADR (SC_STAT1);
|
||||
sc_log_head->stat2 = stat2;
|
||||
if (++sc_log_head >= sc_log + SC_LOG_LEN) sc_log_head = sc_log;
|
||||
sc_log_head->stat1 = sc_log_head->stat2 = 0xff;
|
||||
# endif
|
||||
|
||||
for (;;) {
|
||||
dummy = RD_ADR (SC_RESETIP); /* clear interrupt request */
|
||||
if (!sc_accept_int || /* return if spurious interrupt */
|
||||
(!sc_watchdog_error &&
|
||||
(stat2 & SC_S_BSYERR) == 0 && (stat2 & SC_S_PHASE) == 1))
|
||||
{
|
||||
# ifdef DEBUG
|
||||
++sc_spurious_int;
|
||||
# endif
|
||||
return ret;
|
||||
}
|
||||
RD_ADR (SC_MODE) &= ~SC_M_DMA; /* clear DMA mode */
|
||||
WR_ADR (SC_ICMD, 0); /* disable data bus */
|
||||
if (sc_cur_phase != PH_NONE) { /* if did DMA, save the new pointer */
|
||||
new_ptr = sc_dma_adr; /* fetch new pointer from DMA cntlr */
|
||||
if (sc_cur_phase == PH_IMSG && /* have message? */
|
||||
new_ptr != sc_ptrs->ptr[PH_IMSG]) sc_have_msg = 1;
|
||||
sc_ptrs->ptr[sc_cur_phase] = /* save pointer */
|
||||
new_ptr;
|
||||
}
|
||||
if (sc_watchdog_error) ret = ISR_TIMEOUT;
|
||||
else if (stat2 & SC_S_BSYERR) { /* target deasserted BSY? */
|
||||
if (sc_have_msg) ret = ISR_OK;
|
||||
else ret = ISR_BSYERR;
|
||||
} else if (!(stat2 & SC_S_PHASE)) { /* if phase mismatch, setup new phase */
|
||||
sc_cur_phase = /* get new phase from controller */
|
||||
(RD_ADR (SC_STAT1) >> 2) & 7;
|
||||
new_ptr = sc_ptrs->ptr[sc_cur_phase];
|
||||
if (new_ptr == 0) ret = ISR_BADPHASE;
|
||||
else {
|
||||
WR_ADR (SC_TCMD, sc_cur_phase); /* write new phase into TCMD */
|
||||
if (PH_IN (sc_cur_phase)) { /* set DMA controller */
|
||||
sc_dma_setup (DISK_READ, new_ptr);
|
||||
RD_ADR (SC_MODE) |= SC_M_DMA;
|
||||
WR_ADR (SC_START_RCV, 0); /* tell SCSI to start DMA */
|
||||
} else {
|
||||
sc_dma_setup (DISK_WRITE, new_ptr);
|
||||
RD_ADR (SC_MODE) |= SC_M_DMA;
|
||||
WR_ADR (SC_ICMD, SC_ENABLE_DB);
|
||||
WR_ADR (SC_START_SEND, 0);
|
||||
}
|
||||
}
|
||||
} else ret = ISR_RSTERR;
|
||||
if (ret != ISR_NOTDONE) { /* if done, send message to task */
|
||||
sc_watchdog_error = 0;
|
||||
sc_accept_int = 0;
|
||||
WR_ADR (SC_MODE, 0); /* clear monbsy, dma */
|
||||
break; /* reti re-enables ints */
|
||||
}
|
||||
if (0 == ((stat2 = /* check for another interrupt */
|
||||
RD_ADR (SC_STAT2)) & SC_S_IRQ))
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*===========================================================================*
|
||||
* sc_dma_setup *
|
||||
*===========================================================================*/
|
||||
/* Fake DMA setup. Just store pointers and direction in global variables.
|
||||
*
|
||||
* The pseudo-DMA is subtler than it looks because of the cache.
|
||||
*
|
||||
* 1) When accessing I/O devices through a cache, some mechanism is
|
||||
* necessary to ensure you access the device rather than the cache.
|
||||
* On the 32532, the IODEC signal is supposed to be asserted for I/O
|
||||
* addresses to accomplish this. However, a bug makes this much
|
||||
* slower than necessary and severely hurts pseudo-DMA performance.
|
||||
* Hence, IODEC is not asserted for the SCSI DMA port.
|
||||
*
|
||||
* 2) Because of (1), we must devise our own method of forcing the
|
||||
* SCSI DMA port to be read. 0x8000000 addresses have been decoded
|
||||
* to all access this port. By always using new addresses to access
|
||||
* the DMA port (wrapping only after reading MAX_CACHE bytes), we
|
||||
* force cache misses and, hence, device reads. Since the cache
|
||||
* is write-through, we do not need to worry about writes.
|
||||
*
|
||||
* 3) It is possible to miss the last few bytes of a transfer if
|
||||
* bus transfer size is not considered. The loop in sc_receive()
|
||||
* transfers data until the interrupt signal is asserted. If
|
||||
* bytes are transferred, the attempt to move the first byte of a
|
||||
* double word causes the whole word to be read into the cache.
|
||||
* Then the byte is transferred. If reading the double word
|
||||
* completed the SCSI transfer, then the loop exits since
|
||||
* interrupt is asserted. However, the last few bytes have only
|
||||
* been moved into the cache -- they have not been moved to the
|
||||
* DMA destination.
|
||||
*
|
||||
* 4) It is also possible to miss the first few bytes of a transfer.
|
||||
* If the address used to access pseudo-dma port is not double word
|
||||
* aligned, the whole double word is read into the cache, and then
|
||||
* data is moved from the middle of the word (i.e. something other
|
||||
* than the first bytes read from the SCSI controller) by the
|
||||
* pseudo-dma loop in sc_receive().
|
||||
*/
|
||||
sc_dma_setup (dir, adr)
|
||||
int dir;
|
||||
long adr;
|
||||
{
|
||||
if (sc_dma_port > SC_DMA + MAX_CACHE) sc_dma_port = SC_DMA;
|
||||
sc_dma_dir = dir;
|
||||
sc_dma_adr = adr;
|
||||
}
|
||||
|
||||
/*===========================================================================*
|
||||
* sc_receive *
|
||||
*===========================================================================*/
|
||||
/* Replacement for Minix receive(), which waits for a message. This code
|
||||
* spins, waiting for data to transfer or interrupt requests to handle.
|
||||
* See sc_dma_setup for details.
|
||||
*/
|
||||
int
|
||||
sc_receive()
|
||||
{
|
||||
int stat2, isr_ret;
|
||||
|
||||
for (;;) {
|
||||
stat2 = RD_ADR (SC_STAT2);
|
||||
if (stat2 & SC_S_IRQ) {
|
||||
if (ISR_NOTDONE != (isr_ret = scsi_interrupt())) break;
|
||||
} else if (stat2 & SC_S_DRQ) { /* test really not necessary on pc532 */
|
||||
if (sc_dma_dir == DISK_READ)
|
||||
*((long *)sc_dma_adr)++ = *((volatile long *)sc_dma_port)++;
|
||||
else *((volatile long *)sc_dma_port)++ = *((long *)sc_dma_adr)++;
|
||||
}
|
||||
}
|
||||
return isr_ret;
|
||||
}
|
||||
|
||||
/*===========================================================================*
|
||||
* scCtlrSelect
|
||||
*===========================================================================*/
|
||||
/* Select a SCSI device.
|
||||
*/
|
||||
scCtlrSelect (ctlr)
|
||||
int ctlr;
|
||||
{
|
||||
RD_ADR (ICU_IO) &= ~ICU_SCSI_BIT; /* i/o, not port */
|
||||
RD_ADR (ICU_DIR) &= ~ICU_SCSI_BIT; /* output */
|
||||
if (ctlr == DP8490)
|
||||
RD_ADR (ICU_DATA) &= ~ICU_SCSI_BIT; /* select = 0 for 8490 */
|
||||
else
|
||||
RD_ADR (ICU_DATA) |= ICU_SCSI_BIT; /* select = 1 for AIC6250 */
|
||||
}
|
|
@ -0,0 +1,195 @@
|
|||
/*
|
||||
* Copyright (c) 1988 University of Utah.
|
||||
* Copyright (c) 1990, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Van Jacobson of Lawrence Berkeley Laboratory and the Systems
|
||||
* Programming Group of the University of Utah Computer Science Department.
|
||||
*
|
||||
* 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. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. 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.
|
||||
*
|
||||
* from: Utah $Hdr: sd.c 1.9 92/12/21$
|
||||
* from: @(#)sd.c 8.1 (Berkeley) 6/10/93
|
||||
*
|
||||
* $Id: sd.c,v 1.1 1994/05/30 19:58:58 phil Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
* SCSI CCS disk driver
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/disklabel.h>
|
||||
#include "stand.h"
|
||||
#include "samachdep.h"
|
||||
|
||||
struct sd_softc {
|
||||
int sc_ctlr;
|
||||
int sc_unit;
|
||||
int sc_part;
|
||||
char sc_retry;
|
||||
char sc_alive;
|
||||
struct disklabel sc_label;
|
||||
} sd_softc[NSCSI][NSD];
|
||||
|
||||
#ifdef SD_DEBUG
|
||||
int debug = SD_DEBUG;
|
||||
#endif
|
||||
|
||||
#define SDRETRY 2
|
||||
|
||||
sdinit(ctlr, unit)
|
||||
int ctlr, unit;
|
||||
{
|
||||
register struct sd_softc *ss = &sd_softc[ctlr][unit];
|
||||
|
||||
/* HP version does test_unit_ready
|
||||
* followed by read_capacity to get blocksize
|
||||
*/
|
||||
ss->sc_alive = 1;
|
||||
return (1);
|
||||
}
|
||||
|
||||
sdreset(ctlr, unit)
|
||||
int ctlr, unit;
|
||||
{
|
||||
}
|
||||
|
||||
char io_buf[MAXBSIZE];
|
||||
|
||||
sdgetinfo(ss)
|
||||
register struct sd_softc *ss;
|
||||
{
|
||||
register struct disklabel *lp;
|
||||
char *msg, *getdisklabel();
|
||||
int sdstrategy(), i, err;
|
||||
|
||||
lp = &sd_softc[ss->sc_ctlr][ss->sc_unit].sc_label;
|
||||
bzero((caddr_t)lp, sizeof *lp);
|
||||
lp->d_secsize = DEV_BSIZE;
|
||||
lp->d_secpercyl = 1;
|
||||
lp->d_npartitions = MAXPARTITIONS;
|
||||
lp->d_partitions[ss->sc_part].p_offset = 0;
|
||||
lp->d_partitions[ss->sc_part].p_size = 0x7fffffff;
|
||||
|
||||
if (err = sdstrategy(ss, F_READ,
|
||||
LABELSECTOR, DEV_BSIZE, io_buf, &i) < 0) {
|
||||
printf("sdgetinfo: sdstrategy error %d\n", err);
|
||||
return 0;
|
||||
}
|
||||
|
||||
msg = getdisklabel(io_buf, lp);
|
||||
if (msg) {
|
||||
printf("sd(%d,%d,%d): %s\n",
|
||||
ss->sc_ctlr, ss->sc_unit, ss->sc_part, msg);
|
||||
return 0;
|
||||
}
|
||||
return(1);
|
||||
}
|
||||
|
||||
sdopen(f, ctlr, unit, part)
|
||||
struct open_file *f;
|
||||
int ctlr, unit, part;
|
||||
{
|
||||
register struct sd_softc *ss;
|
||||
register struct disklabel *lp;
|
||||
|
||||
#ifdef SD_DEBUG
|
||||
if (debug)
|
||||
printf("sdopen: ctlr=%d unit=%d part=%d\n",
|
||||
ctlr, unit, part);
|
||||
#endif
|
||||
|
||||
if (ctlr >= NSCSI || !scsialive(ctlr))
|
||||
return (EADAPT);
|
||||
if (unit >= NSD)
|
||||
return (ECTLR);
|
||||
ss = &sd_softc[ctlr][unit]; /* XXX alloc()? keep pointers? */
|
||||
ss->sc_part = part;
|
||||
ss->sc_unit = unit;
|
||||
ss->sc_ctlr = ctlr;
|
||||
if (!ss->sc_alive) {
|
||||
if (!sdinit(ctlr, unit))
|
||||
return (ENXIO);
|
||||
if (!sdgetinfo(ss))
|
||||
return (ERDLAB);
|
||||
}
|
||||
lp = &sd_softc[ctlr][unit].sc_label;
|
||||
if (part >= lp->d_npartitions || lp->d_partitions[part].p_size == 0)
|
||||
return (EPART);
|
||||
|
||||
f->f_devdata = (void *)ss;
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
sdstrategy(ss, func, dblk, size, buf, rsize)
|
||||
register struct sd_softc *ss;
|
||||
int func;
|
||||
daddr_t dblk; /* block number */
|
||||
u_int size; /* request size in bytes */
|
||||
char *buf;
|
||||
u_int *rsize; /* out: bytes transferred */
|
||||
{
|
||||
register int ctlr = ss->sc_ctlr;
|
||||
register int unit = ss->sc_unit;
|
||||
register int part = ss->sc_part;
|
||||
register struct partition *pp = &ss->sc_label.d_partitions[part];
|
||||
u_int nblk = size >> DEV_BSHIFT;
|
||||
u_int blk = dblk + pp->p_offset;
|
||||
char stat;
|
||||
|
||||
if (size == 0)
|
||||
return(0);
|
||||
|
||||
ss->sc_retry = 0;
|
||||
|
||||
#ifdef SD_DEBUG
|
||||
if (debug)
|
||||
printf("sdstrategy(%d,%d): size=%d blk=%d nblk=%d\n",
|
||||
ctlr, unit, size, blk, nblk);
|
||||
#endif
|
||||
|
||||
retry:
|
||||
if (func == F_READ)
|
||||
stat = scsi_tt_read(ctlr, unit, buf, size, blk, nblk);
|
||||
else
|
||||
stat = scsi_tt_write(ctlr, unit, buf, size, blk, nblk);
|
||||
if (stat) {
|
||||
printf("sd(%d,%d,%d): block=%x, error=0x%x\n",
|
||||
ctlr, unit, ss->sc_part, blk, stat);
|
||||
if (++ss->sc_retry > SDRETRY)
|
||||
return(EIO);
|
||||
goto retry;
|
||||
}
|
||||
*rsize = size;
|
||||
|
||||
return(0);
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
#ifndef _SO_H_INCLUDE
|
||||
#define _SO_H_INCLUDE
|
||||
|
||||
/* Definitions for standalone I/O lib */
|
||||
|
||||
#define DUART0 0x28000000
|
||||
#define DUART1 0x28000020
|
||||
#define DUART2 0x28000040
|
||||
#define DUART3 0x28000060
|
||||
#define PARRDU 0x28000080
|
||||
#define PARCLU 0x280000A0
|
||||
#define SCSI_POLLED 0x30000000
|
||||
#define SCSI_DMA 0x38000000
|
||||
#define ICU_ADDR 0xFFFFFE00
|
||||
|
||||
/* Which UART to use by default */
|
||||
#define DEFAULT_UART 0
|
||||
|
||||
/* Which SCSI device to use by default */
|
||||
#define DEFAULT_SCSI_ADR 1
|
||||
#define DEFAULT_SCSI_LUN 0
|
||||
|
||||
/* Low level scsi operation codes */
|
||||
#define DISK_READ 3
|
||||
#define DISK_WRITE 4
|
||||
|
||||
/* The size of a disk block */
|
||||
#define DBLKSIZE 512
|
||||
|
||||
/* Some disk address that will never be used */
|
||||
#define INSANE_BADDR 0x800000
|
||||
|
||||
struct scsi_args {
|
||||
long ptr [8];
|
||||
};
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL 0L
|
||||
#endif
|
||||
|
||||
/*
|
||||
* The next macro defines where the "break" area in memory ends for
|
||||
* malloc() and friends. The area between edata and this address will
|
||||
* then be reserved and should not be used for anything else (or you will
|
||||
* no doubt have big problems). Depending on where your program's end-of-data
|
||||
* is, you may wish to locate this in such a way as to usurp a minimum
|
||||
* amount of memory.
|
||||
*/
|
||||
#define BREAK_END_ADDR ((char *)0x400000) /* to 4MB */
|
||||
|
||||
/* Selectivly enable inline functions */
|
||||
#ifndef NO_INLINE
|
||||
#define Inline inline
|
||||
#else
|
||||
#define Inline
|
||||
#endif
|
||||
|
||||
extern void fatal(), warn();
|
||||
extern long ulimit(int, long);
|
||||
extern int brk(char *);
|
||||
extern char *sbrk(int);
|
||||
|
||||
extern int sc_rdwt();
|
||||
|
||||
#endif /* _SO_H_INCLUDE */
|
|
@ -0,0 +1,84 @@
|
|||
/*-
|
||||
* Copyright (c) 1994 Philip L. Budne.
|
||||
* 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. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by Philip L. Budne.
|
||||
* 4. The name of Philip L. Budne may not be used to endorse or promote
|
||||
* products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY PHILIP NELSON ``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 PHILIP NELSON 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.
|
||||
*
|
||||
* srt0.s
|
||||
*
|
||||
* $Id: srt0.s,v 1.1 1994/05/30 19:59:00 phil Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
* srt0.s -- standalone C startup
|
||||
* Phil Budne, May 10, 1994
|
||||
*
|
||||
* from: pc532 kernel locore.s
|
||||
* Phil Nelson, Dec 6, 1992
|
||||
*
|
||||
*/
|
||||
|
||||
#define PSR_S 0x200
|
||||
#define PSR_I 0x800
|
||||
|
||||
.data
|
||||
.globl _howto, _bootdev
|
||||
__save_sp: .long 0
|
||||
__save_fp: .long 0
|
||||
_bootdev: .long 0
|
||||
_howto: .long 0
|
||||
|
||||
.text
|
||||
.globl begin
|
||||
begin:
|
||||
bicpsrw PSR_I /* make sure interrupts are off. */
|
||||
bicpsrw PSR_S /* make sure we are using sp0. */
|
||||
lprd sb, 0 /* gcc expects this. */
|
||||
sprd sp, __save_sp(pc) /* save monitor's sp. */
|
||||
sprd fp, __save_fp(pc) /* save monitor's fp. */
|
||||
/* sprd intbase, __old_intbase(pc) /* save monitor's intbase. */
|
||||
movqd 0, _howto(pc)
|
||||
|
||||
restart:
|
||||
/* Zero the bss segment. */
|
||||
addr _end(pc),r0 # setup to zero the bss segment.
|
||||
addr _edata(pc),r1
|
||||
subd r1,r0 # compute _end - _edata
|
||||
movd r0,tos # push length
|
||||
addr _edata(pc),tos # push address
|
||||
|
||||
movqd 0,_bootdev(pc) # XXX trash bootdev
|
||||
bsr _bzero # zero the bss segment
|
||||
bsr _main
|
||||
/* fall */
|
||||
|
||||
.globl __rtt
|
||||
__rtt: lprd sp, __save_sp(pc) /* restore monitor's sp. */
|
||||
lprd fp, __save_fp(pc) /* restore monitor's fp. */
|
||||
/* XXX just return to monitor??? */
|
||||
movqd 3, _howto /* RB_SINGLE|RB_ASKNAME */
|
||||
br restart
|
|
@ -0,0 +1,193 @@
|
|||
/*-
|
||||
* Copyright (c) 1994 Philip L. Budne.
|
||||
* 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. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by Philip L. Budne.
|
||||
* 4. The name of Philip L. Budne may not be used to endorse or promote
|
||||
* products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY PHILIP BUDNE ``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 PHILIP BUDNE 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.
|
||||
*
|
||||
* test.c
|
||||
*
|
||||
* $Id: test.c,v 1.1 1994/05/30 19:59:01 phil Exp $
|
||||
*/
|
||||
|
||||
/*-
|
||||
* Allow test of "boot" (and presumably other "stand" utils)
|
||||
* under user mode.
|
||||
*
|
||||
* Phil Budne <phil@ultimate.com> May 10, 1994
|
||||
*/
|
||||
|
||||
/* my /sys/sys/syscall.h is out of sync w.r.t. lseek?? */
|
||||
#include "/usr/include/sys/syscall.h"
|
||||
#include <sys/types.h>
|
||||
|
||||
extern int errno;
|
||||
|
||||
int testing = 1;
|
||||
int bootdev;
|
||||
int howto;
|
||||
|
||||
_open( char *fname, int mode )
|
||||
{
|
||||
return syscall( SYS_open, fname, mode );
|
||||
}
|
||||
|
||||
_read( int fd, char *buf, int len )
|
||||
{
|
||||
return syscall( SYS_read, fd, buf, len );
|
||||
}
|
||||
|
||||
_write( int fd, char *buf, int len )
|
||||
{
|
||||
return syscall( SYS_write, fd, buf, len );
|
||||
}
|
||||
|
||||
/*
|
||||
* I'd like to strangle the jerk who thought it
|
||||
* was a cool idea to change lseek, rather than creating
|
||||
* a new "qseek" to handle long long offsets
|
||||
*/
|
||||
_lseek( int fd, off_t pos, int whence )
|
||||
{
|
||||
return syscall( SYS_lseek, fd, 0, pos, whence );
|
||||
}
|
||||
|
||||
int fd = -1;
|
||||
|
||||
opendisk(int unit)
|
||||
{
|
||||
char fname[32];
|
||||
static int _unit = -1;
|
||||
|
||||
if (unit == _unit)
|
||||
return;
|
||||
|
||||
if (fd >= 0) {
|
||||
close(fd);
|
||||
fd = -1;
|
||||
}
|
||||
_unit = unit;
|
||||
|
||||
#if 0
|
||||
sprintf( fname, "/dev/r%s%dc", "sd", unit );
|
||||
#else
|
||||
strcpy( fname, "/dev/rsd0c" );
|
||||
#endif
|
||||
fd = _open( fname, 0 );
|
||||
if (fd < 0) {
|
||||
printf("open %s failed\n", fname );
|
||||
return;
|
||||
}
|
||||
printf("opened %s (fd %d)\n", fname, fd );
|
||||
}
|
||||
|
||||
void
|
||||
bzero( char *addr, int len )
|
||||
{
|
||||
while (len-- > 0)
|
||||
*addr++ = '\0';
|
||||
}
|
||||
|
||||
/* XXX TEMP; would like to use code more like hp300 scsi.c */
|
||||
|
||||
void
|
||||
scsiinit(void)
|
||||
{
|
||||
}
|
||||
|
||||
int
|
||||
scsialive(int ctlr)
|
||||
{
|
||||
return 1; /* controller always alive! */
|
||||
}
|
||||
|
||||
#define BPS 512
|
||||
scsi_tt_read(ctlr, slave, buf, len, blk, nblk)
|
||||
char *buf;
|
||||
{
|
||||
int pos;
|
||||
#if 0
|
||||
printf("scsi_tt_read(ctlr %d, slave %d, buf 0x%x, len %d, blk %d, nblk %d)\n",
|
||||
ctlr, slave, buf, len, blk, nblk);
|
||||
#endif
|
||||
|
||||
opendisk(slave);
|
||||
|
||||
pos = _lseek( fd, blk * BPS, 0 );
|
||||
if (pos != blk * BPS) {
|
||||
printf("lseek pos %d error %d\n", pos, errno );
|
||||
return errno;
|
||||
}
|
||||
if (_read( fd, buf, nblk * BPS ) != nblk * BPS) {
|
||||
printf("read errno %d\n", errno );
|
||||
return errno;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
scsi_tt_write()
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <dev/cons.h>
|
||||
|
||||
scnprobe(cp)
|
||||
struct consdev *cp;
|
||||
{
|
||||
/* the only game in town */
|
||||
cp->cn_pri = CN_NORMAL; /* XXX remote? */
|
||||
}
|
||||
|
||||
scninit(cp)
|
||||
struct consdev *cp;
|
||||
{
|
||||
}
|
||||
|
||||
scnputchar(c)
|
||||
int c;
|
||||
{
|
||||
char c2;
|
||||
c2 = c;
|
||||
_write(0, &c2, 1);
|
||||
}
|
||||
|
||||
scngetchar()
|
||||
{
|
||||
char c;
|
||||
_read(0, &c, 1);
|
||||
return c;
|
||||
}
|
||||
|
||||
_rtt() {
|
||||
syscall( SYS_exit, 1 );
|
||||
}
|
||||
|
||||
alloc(int size)
|
||||
{
|
||||
return malloc(size);
|
||||
}
|
|
@ -0,0 +1,89 @@
|
|||
/*-
|
||||
* Copyright (c) 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. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. 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.
|
||||
*
|
||||
* from: @(#)gets.c 8.1 (Berkeley) 6/11/93
|
||||
*
|
||||
* $Id: tgets.c,v 1.1 1994/05/30 19:59:02 phil Exp $
|
||||
*/
|
||||
|
||||
tgets(buf)
|
||||
char *buf;
|
||||
{
|
||||
register int c;
|
||||
int i;
|
||||
register char *lp = buf;
|
||||
|
||||
for (i = 2400000; i > 0; i--) {
|
||||
c = tgetchar() & 0177;
|
||||
if (c) {
|
||||
for (;;) {
|
||||
switch (c) {
|
||||
case '\n':
|
||||
case '\r':
|
||||
*lp = '\0';
|
||||
return;
|
||||
case '\b':
|
||||
case '\177':
|
||||
if (lp > buf) {
|
||||
lp--;
|
||||
putchar('\b');
|
||||
putchar(' ');
|
||||
putchar('\b');
|
||||
}
|
||||
break;
|
||||
case '#':
|
||||
if (lp > buf)
|
||||
--lp;
|
||||
break;
|
||||
case 'r'&037: {
|
||||
register char *p;
|
||||
|
||||
putchar('\n');
|
||||
for (p = buf; p < lp; ++p)
|
||||
putchar(*p);
|
||||
break;
|
||||
}
|
||||
case '@':
|
||||
case 'u'&037:
|
||||
case 'w'&037:
|
||||
lp = buf;
|
||||
putchar('\n');
|
||||
break;
|
||||
default:
|
||||
*lp++ = c;
|
||||
}
|
||||
c = getchar() & 0177;
|
||||
}
|
||||
}
|
||||
}
|
||||
return(0);
|
||||
}
|
Loading…
Reference in New Issue