diff options
author | Per Fogelstrom <pefo@cvs.openbsd.org> | 1997-02-06 16:02:48 +0000 |
---|---|---|
committer | Per Fogelstrom <pefo@cvs.openbsd.org> | 1997-02-06 16:02:48 +0000 |
commit | 8a091f472ca262aca4d0e922a0e313259359681d (patch) | |
tree | b4d26db683b405c63989ccecc3840da916abe1d4 /sys/arch/wgrisc/stand | |
parent | e9cbad18615f2e1fe42a5075063877f29370c0f8 (diff) |
Import of WGRISC port. (Willowglen R3081 board)
Diffstat (limited to 'sys/arch/wgrisc/stand')
-rw-r--r-- | sys/arch/wgrisc/stand/Makefile | 96 | ||||
-rw-r--r-- | sys/arch/wgrisc/stand/boot.c | 114 | ||||
-rw-r--r-- | sys/arch/wgrisc/stand/conf.c | 70 | ||||
-rw-r--r-- | sys/arch/wgrisc/stand/filesystem.c | 44 | ||||
-rw-r--r-- | sys/arch/wgrisc/stand/libsa/Makefile | 14 | ||||
-rw-r--r-- | sys/arch/wgrisc/stand/libsa/devopen.c | 128 | ||||
-rw-r--r-- | sys/arch/wgrisc/stand/libsa/getenv.c | 45 | ||||
-rw-r--r-- | sys/arch/wgrisc/stand/libsa/getputchar.c | 69 | ||||
-rw-r--r-- | sys/arch/wgrisc/stand/rz.c | 174 | ||||
-rw-r--r-- | sys/arch/wgrisc/stand/start.S | 129 |
10 files changed, 883 insertions, 0 deletions
diff --git a/sys/arch/wgrisc/stand/Makefile b/sys/arch/wgrisc/stand/Makefile new file mode 100644 index 00000000000..a7dd6383200 --- /dev/null +++ b/sys/arch/wgrisc/stand/Makefile @@ -0,0 +1,96 @@ +# $NetBSD: Makefile,v 1.5 1995/01/18 06:53:36 mellon Exp $ +# @(#)Makefile 8.3 (Berkeley) 2/16/94 + +DESTDIR= +STAND= ../../stand +#VPATH= ${STAND} + +# RELOC=80200000 allows for boot prog up to 1D0000 (1900544) bytes long +RELOC= 80200000 + +S= ../../.. + +DEFS= -DSTANDALONE -DDEBUG +CFLAGS= -O2 ${INCPATH} ${DEFS} +AFLAGS= -O2 ${INCPATH} ${DEFS} -DLOCORE + +.PATH: ${S}/arch/${MACHINE_ARCH}/${MACHINE_ARCH} +.PATH: ${S}/stand ${S}/lib/libsa + +#INCPATH=-I. -I/sys +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} +#KERNLIB= ${.CURDIR}/../compile/libkern.a + +.include "$S/lib/libsa/Makefile.inc" +LIBSA= ${SA_LIB} + +# not yet: need to write libsa/Makefile.inc first +LIBS= ${.OBJDIR}/libdrive.a ${.CURDIR}/libsa/libsa.a ${KERNLIB} +#LIBS= libdrive.a libsa/libsa.a ../../libkern/obj/libkern.a + +DRIVERS= rz.c +SRCS= ${DRIVERS} +#STUFF= callvec.c devopen.c getenv.c gets.c strcmp.c +STUFF= + +ALL= boot + +.s.o: + ${CPP} -E ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} | \ + ${AS} -o ${.TARGET} + +all: ${ALL} + +boot: ${LIBS} + +#libsa/libsa.a:: +# cd libsa; make + +${.OBJDIR}/libdrive.a: conf.o ${DRIVERS:.c=.o} + ar crv $@ $? + ranlib $@ + +# depend on DEFS + +#before other deps on bootconf.o +bootconf.o: conf.o + rm -f bootconf.c + ln -s ${.CURDIR}/conf.c bootconf.c + ${CC} -c ${CFLAGS} -DBOOT bootconf.c + rm -f bootconf.c + + +# bootable from real disks + +boot: start.o boot.o bootconf.o filesystem.o ${LIBS} + /usr/gnu/ld -N -Ttext ${RELOC} -e __start start.o boot.o bootconf.o filesystem.o ${LIBS} -o boot.elf + elf2ecoff boot.elf boot + +start.o: ${.CURDIR}/start.S + +# ${CPP} -E ${CFLAGS:M-[ID]*} -DLOCORE ${AINC} ${.IMPSRC} | \ +# ${AS} -o ${.TARGET} + +mkboot: ${.CURDIR}/mkboot.c + ${CC} ${CFLAGS} -o mkboot ${.CURDIR}/mkboot.c + +# utilities + +clean:: + rm -f .depend *.o *.exe *.i errs make.out core* + rm -f a.out ${ALL} + rm -f libdrive.a + cd libsa; make cleandir + +install: + +depend: ${SRCS} + mkdep ${INCPATH} ${DEFS} ${SRCS} + cd libsa; make depend + +.include <bsd.dep.mk> +.include <bsd.obj.mk> diff --git a/sys/arch/wgrisc/stand/boot.c b/sys/arch/wgrisc/stand/boot.c new file mode 100644 index 00000000000..170f6f923de --- /dev/null +++ b/sys/arch/wgrisc/stand/boot.c @@ -0,0 +1,114 @@ +/* $NetBSD: boot.c,v 1.6 1995/06/28 10:22:32 jonathan Exp $ */ + +/* + * Copyright (c) 1992, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Ralph Campbell. + * + * 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. + * + * @(#)boot.c 8.1 (Berkeley) 6/10/93 + */ + +#include <sys/param.h> +#include <sys/exec.h> +#include <stand.h> + + +char line[1024]; + +/* + * This gets arguments from the PROM, calls other routines to open + * and load the program to boot, and then transfers execution to that + * new program. + * Argv[0] should be something like "rz(0,0,0)vmunix" on a DECstation 3100. + * Argv[0,1] should be something like "boot 5/rz0/vmunix" on a DECstation 5000. + * The argument "-a" means vmunix should do an automatic reboot. + */ +int +main(argc, argv) + int argc; + char **argv; +{ + char *cp; + int ask, entry; + int i; + + ask = 1; + + for(i = 0; i < argc; i++) + printf("Arg %d:%s\n",i,argv[i]); + + do { + printf("Boot: "); + if (ask) { + gets(line); + cp = line; + argv[0] = cp; + argc = 1; + } else + printf("%s\n", cp); + } while(ask && line[0] == '\0'); + + entry = loadfile(cp); + if (entry == -1) { + gets(line); + return 0; + } + + printf("Starting at 0x%x\n\n", entry); + ((void (*)())entry)(argc, argv, 0, 0); +} + +/* + * Open 'filename', read in program and return the entry point or -1 if error. + */ +loadfile(fname) + register char *fname; +{ + struct devices *dp; + int fd, i, n; + struct exec aout; + + if ((fd = open(fname, 0)) < 0) { + printf("open(%s) failed: %d\n", fname, errno); + goto err; + } + + /* read the exec header */ + i = read(fd, (char *)&aout, sizeof(aout)); + +cerr: + (void) close(fd); +err: + printf("Can't boot '%s'\n", fname); + return (-1); +} diff --git a/sys/arch/wgrisc/stand/conf.c b/sys/arch/wgrisc/stand/conf.c new file mode 100644 index 00000000000..cecbc70b64c --- /dev/null +++ b/sys/arch/wgrisc/stand/conf.c @@ -0,0 +1,70 @@ +/* $NetBSD: conf.c,v 1.5 1995/01/18 06:53:39 mellon Exp $ */ + +/* + * Copyright (c) 1992, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Ralph Campbell. + * + * 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. + * + * @(#)conf.c 8.1 (Berkeley) 6/10/93 + */ + +#include <stand.h> + +int errno; + +extern void nullsys(); +extern int nodev(), noioctl(); + +int rzstrategy(), rzopen(); +#ifdef SMALL +#define rzclose 0 +#else /*!SMALL*/ +int rzclose(); +#endif /*!SMALL*/ + +#define rzioctl noioctl + +#ifndef BOOT +int tzstrategy(), tzopen(), tzclose(); +#endif +#define tzioctl noioctl + + +struct devsw devsw[] = { + { "rz", rzstrategy, rzopen, rzclose, rzioctl }, /*0*/ +#ifndef BOOT + { "tz", tzstrategy, tzopen, tzclose, tzioctl }, /*1*/ +#endif +}; + +int ndevs = (sizeof(devsw)/sizeof(devsw[0])); diff --git a/sys/arch/wgrisc/stand/filesystem.c b/sys/arch/wgrisc/stand/filesystem.c new file mode 100644 index 00000000000..514e6e809bf --- /dev/null +++ b/sys/arch/wgrisc/stand/filesystem.c @@ -0,0 +1,44 @@ +/* $NetBSD: filesystem.c,v 1.2 1995/02/16 02:33:05 cgd Exp $ */ + +/* + * 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 + */ + +#include <lib/libsa/stand.h> +#include <lib/libsa/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); + diff --git a/sys/arch/wgrisc/stand/libsa/Makefile b/sys/arch/wgrisc/stand/libsa/Makefile new file mode 100644 index 00000000000..d147171311d --- /dev/null +++ b/sys/arch/wgrisc/stand/libsa/Makefile @@ -0,0 +1,14 @@ +# $NetBSD: Makefile,v 1.5 1995/01/18 06:53:51 mellon Exp $ +# @(#)Makefile 8.2 (Berkeley) 2/16/94 + +LIB= sa +SRCS= alloc.c bcopy.c bzero.c close.c dev.c disklabel.c getfile.c \ + getputchar.c ioctl.c lseek.c open.c printf.c read.c ufs.c write.c \ + devopen.c getenv.c gets.c strcat.c strcmp.c strcpy.c strlen.c + +.PATH: ../../../../lib/libsa ../../../../lib/libkern +NOPROFILE=noprofile + +.include <bsd.lib.mk> + +CFLAGS=-O2 -I../../include -I/sys -DSMALL diff --git a/sys/arch/wgrisc/stand/libsa/devopen.c b/sys/arch/wgrisc/stand/libsa/devopen.c new file mode 100644 index 00000000000..79b35f8f595 --- /dev/null +++ b/sys/arch/wgrisc/stand/libsa/devopen.c @@ -0,0 +1,128 @@ +/* $NetBSD: devopen.c,v 1.5 1995/01/18 06:53:54 mellon Exp $ */ + +/*- + * Copyright (c) 1992, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Ralph Campbell. + * + * 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. + * + * @(#)devopen.c 8.1 (Berkeley) 6/10/93 + */ + +#include <lib/libsa/stand.h> + +/* + * Decode the string 'fname', open the device and return the remaining + * file name if any. + */ +devopen(f, fname, file) + struct open_file *f; + const char *fname; + char **file; /* out */ +{ + register char *cp; + register char *ncp; + register struct devsw *dp; + register int c, i; + int ctlr = 0, unit = 0, part = 0; + char namebuf[20]; + int rc; + + cp = fname; + ncp = namebuf; + + /* expect a string like 'rz(0,0,0)vmunix' */ + while ((c = *cp) != '\0') { + if (c == '(') { + cp++; + break; + } + if (ncp < namebuf + sizeof(namebuf) - 1) + *ncp++ = c; + cp++; + } + + /* get controller number */ + if ((c = *cp) >= '0' && c <= '9') { + ctlr = c - '0'; + c = *++cp; + } + + if (c == ',') { + /* get SCSI device number */ + if ((c = *++cp) >= '0' && c <= '9') { + unit = c - '0'; + c = *++cp; + } + + if (c == ',') { + /* get partition number */ + if ((c = *++cp) >= '0' && c <= '9') { + part = c - '0'; + c = *++cp; + } + } + } + if (c != ')') + return (ENXIO); + cp++; + *ncp = '\0'; + +#ifdef SMALL + if (strcmp (namebuf, "rz")) { + printf ("Unknown device: %s\n", namebuf); + return ENXIO; + } + dp = devsw; + i = 0; +#else + for (dp = devsw, i = 0; i < ndevs; dp++, i++) + if (dp->dv_name && strcmp(namebuf, dp->dv_name) == 0) + goto fnd; + printf("Unknown device '%s'\nKnown devices are:", namebuf); + for (dp = devsw, i = 0; i < ndevs; dp++, i++) + if (dp->dv_name) + printf(" %s", dp->dv_name); + printf("\n"); + return (ENXIO); + +fnd: +#endif + rc = (dp->dv_open)(f, ctlr, unit, part); + if (rc) + return (rc); + + f->f_dev = dp; + if (file && *cp != '\0') + *file = cp; + return (0); +} diff --git a/sys/arch/wgrisc/stand/libsa/getenv.c b/sys/arch/wgrisc/stand/libsa/getenv.c new file mode 100644 index 00000000000..7e063cd4ad5 --- /dev/null +++ b/sys/arch/wgrisc/stand/libsa/getenv.c @@ -0,0 +1,45 @@ +/* $NetBSD: getenv.c,v 1.5 1995/01/18 06:53:55 mellon Exp $ */ + +/*- + * Copyright (c) 1992, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Ralph Campbell. + * + * 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. + * + * @(#)getenv.c 8.1 (Berkeley) 6/10/93 + */ + +char * +getenv(s) + char *s; +{ +} diff --git a/sys/arch/wgrisc/stand/libsa/getputchar.c b/sys/arch/wgrisc/stand/libsa/getputchar.c new file mode 100644 index 00000000000..dbfae22d4d6 --- /dev/null +++ b/sys/arch/wgrisc/stand/libsa/getputchar.c @@ -0,0 +1,69 @@ +/* $NetBSD: getenv.c,v 1.5 1995/01/18 06:53:55 mellon Exp $ */ + +/*- + * Copyright (c) 1992, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Ralph Campbell. + * + * 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. + * + * @(#)getenv.c 8.1 (Berkeley) 6/10/93 + */ + +getchar() +{ + char buf[4]; + int cnt; + + if(Bios_Read(0, &buf, 1, &cnt) != 0) + return(-1); + return(buf[0] & 255); +} + +putchar(c) +char c; +{ + char buf[4]; + int cnt; + + if(c == '\n') { + buf[0] = '\r'; + buf[1] = c; + cnt = 2; + } + else { + buf[0] = c; + cnt = 1; + } + if(Bios_Write(1, &buf, cnt, &cnt) != 0) + return(-1); + return(0); +} diff --git a/sys/arch/wgrisc/stand/rz.c b/sys/arch/wgrisc/stand/rz.c new file mode 100644 index 00000000000..1094aef4705 --- /dev/null +++ b/sys/arch/wgrisc/stand/rz.c @@ -0,0 +1,174 @@ +/* $NetBSD: rz.c,v 1.6 1995/06/28 10:22:35 jonathan Exp $ */ + +/* + * Copyright (c) 1992, 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 Ralph Campbell. + * + * 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. + * + * @(#)rz.c 8.1 (Berkeley) 6/10/93 + */ + +#include <stdarg.h> + +#include <stand.h> +#include <sys/param.h> +#include <sys/disklabel.h> + +struct rz_softc { + int sc_fd; /* PROM file id */ + int sc_ctlr; /* controller number */ + int sc_unit; /* disk unit number */ + int sc_part; /* disk partition number */ + struct disklabel sc_label; /* disk label for this disk */ +}; + +int +rzstrategy(devdata, rw, bn, reqcnt, addr, cnt) + void *devdata; + int rw; + daddr_t bn; + u_int reqcnt; + char *addr; + u_int *cnt; /* out: number of bytes transfered */ +{ + register struct rz_softc *sc = (struct rz_softc *)devdata; + register int part = sc->sc_part; + register struct partition *pp = &sc->sc_label.d_partitions[part]; + register int s; + long offset; + + offset = bn * DEV_BSIZE; + +#ifdef DEBUG +/*XXX*/printf("rz:%x %d\n", offset, reqcnt); +#endif + + /* + * Partial-block transfers not handled. + */ + if (reqcnt & (DEV_BSIZE - 1)) { + *cnt = 0; + return (EINVAL); + } + + offset += pp->p_offset * DEV_BSIZE; + + if (Bios_Seek(sc->sc_fd, &offset, 0) != 0) + return (EIO); + s = Bios_Read(sc->sc_fd, addr, reqcnt, &reqcnt); + if (s != 0) + return (EIO); + + *cnt = reqcnt; + return (0); +} + +int +rzopen(struct open_file *f, ...) +{ + int ctlr, unit, part; + + struct rz_softc *sc; + struct disklabel *lp; + int i, fd; + char *msg; + char buf[DEV_BSIZE]; + int cnt; + static char device[] = "scsi()disk(0)rdisk()"; + va_list ap; + + va_start(ap, f); + + ctlr = va_arg(ap, int); + unit = va_arg(ap, int); + part = va_arg(ap, int); + if (unit >= 8 || part >= 8) + return (ENXIO); +#if 0 + device[5] = '0' + unit; +#endif + /* NOTE: only support reads for now */ + + i = Bios_Open(device, 0, &fd); + if (i != 0) { + printf("boot init failed error code %d\n", i); + return (ENXIO); + } + + sc = alloc(sizeof(struct rz_softc)); + bzero(sc, sizeof(struct rz_softc)); + f->f_devdata = (void *)sc; + + sc->sc_fd = fd; + sc->sc_ctlr = ctlr; + sc->sc_unit = unit; + sc->sc_part = part; + + /* try to read disk label and partition table information */ + lp = &sc->sc_label; + lp->d_secsize = DEV_BSIZE; + lp->d_secpercyl = 1; + lp->d_npartitions = MAXPARTITIONS; + lp->d_partitions[part].p_offset = 0; + lp->d_partitions[part].p_size = 0x7fffffff; + i = rzstrategy(sc, F_READ, (daddr_t)LABELSECTOR, DEV_BSIZE, buf, &cnt); + if (i || cnt != DEV_BSIZE) { + printf("rz%d: error reading disk label\n", unit); + goto bad; + } else { + msg = getdisklabel(buf, lp); + if (msg) { + printf("rz%d: %s\n", unit, msg); + goto bad; + } + } + + if (part >= lp->d_npartitions || lp->d_partitions[part].p_size == 0) { + bad: +#ifndef SMALL + free(sc, sizeof(struct rz_softc)); +#endif + return (ENXIO); + } + return (0); +} + +#ifndef SMALL +rzclose(f) + struct open_file *f; +{ + free(f->f_devdata, sizeof(struct rz_softc)); + f->f_devdata = (void *)0; + return (0); +} +#endif diff --git a/sys/arch/wgrisc/stand/start.S b/sys/arch/wgrisc/stand/start.S new file mode 100644 index 00000000000..09114a91b7e --- /dev/null +++ b/sys/arch/wgrisc/stand/start.S @@ -0,0 +1,129 @@ +/* $NetBSD: start.S,v 1.1 1995/01/18 06:19:01 mellon Exp $ */ + +/* + * Copyright (c) 1992, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Ralph Campbell. + * + * 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. + * + */ + +/* + * start.S - + * + * Contains code that is the first executed at boot time. + */ + +#include <machine/regdef.h> +#include <machine/cpu.h> +#include <machine/asm.h> + +/* + * Frame required for the debugger (if we have any) + */ +#define START_FRAME ((4 * 4) + 4 + 4) + + .globl __start +__start: + .set noreorder +#ifdef __GP_SUPPORT__ + la gp, _C_LABEL (_gp) +#endif + la sp, __start - START_FRAME # Stack below program + sw zero, START_FRAME - 4(sp) # Zero out old ra for debugger + sw zero, START_FRAME - 8(sp) # Zero out old fp for debugger + move s0, a0 # save argc + move s1, a1 # save argv + + la a0, _C_LABEL (edata) # clear BSS + la a1, _C_LABEL (end) + jal _C_LABEL(bzero) # bzero(edata, end - edata) + subu a1, a1, a0 + + move a0, s0 # restore argc + jal _C_LABEL(main) # main(argc, argv) + move a1, s1 # restore argv + + j _C_LABEL(Bios_Restart) # restart... + nop + +/* dummy routine for gcc2 */ + .globl _C_LABEL(__main) +_C_LABEL(__main): + j ra + nop + +#define Bios_Call(Name,Offset) \ +LEAF(Name); \ + lw v0,0x80001020; \ + lw v0,Offset(v0); \ + jr v0 ; \ + nop ; \ + END(Name) + +Bios_Call(Bios_Load, 0x00) +Bios_Call(Bios_Invoke, 0x04) +Bios_Call(Bios_Execute, 0x08) +Bios_Call(Bios_Halt, 0x0c) +Bios_Call(Bios_PowerDown, 0x10) +Bios_Call(Bios_Restart, 0x14) +Bios_Call(Bios_Reboot, 0x18) +Bios_Call(Bios_EnterInteractiveMode, 0x1c) +Bios_Call(Bios_Unused1, 0x20) +Bios_Call(Bios_GetPeer, 0x24) +Bios_Call(Bios_GetChild, 0x28) +Bios_Call(Bios_GetParent, 0x2c) +Bios_Call(Bios_GetConfigurationData, 0x30) +Bios_Call(Bios_AddChild, 0x34) +Bios_Call(Bios_DeleteComponent, 0x38) +Bios_Call(Bios_GetComponent, 0x3c) +Bios_Call(Bios_SaveConfiguration, 0x40) +Bios_Call(Bios_GetSystemId, 0x44) +Bios_Call(Bios_GetMemoryDescriptor, 0x48) +Bios_Call(Bios_Unused2, 0x4c) +Bios_Call(Bios_GetTime, 0x50) +Bios_Call(Bios_GetRelativeTime, 0x54) +Bios_Call(Bios_GetDirectoryEntry, 0x58) +Bios_Call(Bios_Open, 0x5c) +Bios_Call(Bios_Close, 0x60) +Bios_Call(Bios_Read, 0x64) +Bios_Call(Bios_GetReadStatus, 0x68) +Bios_Call(Bios_Write, 0x6c) +Bios_Call(Bios_Seek, 0x70) +Bios_Call(Bios_Mount, 0x74) +Bios_Call(Bios_GetEnvironmentVariable, 0x78) +Bios_Call(Bios_SetEnvironmentVariable, 0x7c) +Bios_Call(Bios_GetFileInformation, 0x80) +Bios_Call(Bios_SetFileInformation, 0x84) +Bios_Call(Bios_FlushAllCaches, 0x88) +Bios_Call(Bios_TestUnicodeCharacter, 0x8c) +Bios_Call(Bios_GetDisplayStatus, 0x90) |