summaryrefslogtreecommitdiff
path: root/sys/arch/mvme88k/stand/libsa
diff options
context:
space:
mode:
authorDale S. Rahn <rahnds@cvs.openbsd.org>1997-03-03 19:32:35 +0000
committerDale S. Rahn <rahnds@cvs.openbsd.org>1997-03-03 19:32:35 +0000
commit90ff5a441368313fa226376473fea6908c2c3539 (patch)
tree38e1de6dcfb2805194734736d7209f51e06fa9e1 /sys/arch/mvme88k/stand/libsa
parent7848f1c3b3e234584c90f67e60c6164590478f49 (diff)
Third try at importing the mvme88k port. This is a working kernel
from nivas. Userland and compiler still need to be worked on. Make certain what directory the import is done from.
Diffstat (limited to 'sys/arch/mvme88k/stand/libsa')
-rw-r--r--sys/arch/mvme88k/stand/libsa/Makefile49
-rw-r--r--sys/arch/mvme88k/stand/libsa/Makefile,v72
-rw-r--r--sys/arch/mvme88k/stand/libsa/Makefile.inc12
-rw-r--r--sys/arch/mvme88k/stand/libsa/SRT0.S90
-rw-r--r--sys/arch/mvme88k/stand/libsa/SRT1.c123
-rw-r--r--sys/arch/mvme88k/stand/libsa/bug.c136
-rw-r--r--sys/arch/mvme88k/stand/libsa/clock.c79
-rw-r--r--sys/arch/mvme88k/stand/libsa/clock.h6
-rw-r--r--sys/arch/mvme88k/stand/libsa/clockreg.h71
-rw-r--r--sys/arch/mvme88k/stand/libsa/config.h66
-rw-r--r--sys/arch/mvme88k/stand/libsa/dev_disk.c132
-rw-r--r--sys/arch/mvme88k/stand/libsa/dev_disk.h6
-rw-r--r--sys/arch/mvme88k/stand/libsa/devopen.c32
-rw-r--r--sys/arch/mvme88k/stand/libsa/dvma.c68
-rw-r--r--sys/arch/mvme88k/stand/libsa/dvma.h6
-rw-r--r--sys/arch/mvme88k/stand/libsa/exec_sun.c212
-rw-r--r--sys/arch/mvme88k/stand/libsa/gets.c141
-rw-r--r--sys/arch/mvme88k/stand/libsa/log1130
-rw-r--r--sys/arch/mvme88k/stand/libsa/log239
-rw-r--r--sys/arch/mvme88k/stand/libsa/netif_sun.c284
-rw-r--r--sys/arch/mvme88k/stand/libsa/panic.c31
-rw-r--r--sys/arch/mvme88k/stand/libsa/promboot.c93
-rw-r--r--sys/arch/mvme88k/stand/libsa/promboot.h5
-rw-r--r--sys/arch/mvme88k/stand/libsa/promcons.c71
-rw-r--r--sys/arch/mvme88k/stand/libsa/promdev.c193
-rw-r--r--sys/arch/mvme88k/stand/libsa/promdev.h4
26 files changed, 2151 insertions, 0 deletions
diff --git a/sys/arch/mvme88k/stand/libsa/Makefile b/sys/arch/mvme88k/stand/libsa/Makefile
new file mode 100644
index 00000000000..8aa02095e63
--- /dev/null
+++ b/sys/arch/mvme88k/stand/libsa/Makefile
@@ -0,0 +1,49 @@
+# $Id: Makefile,v 1.1 1997/03/03 19:30:35 rahnds Exp $
+
+LIB=sa
+
+CLEANFILES+=SRT0.o SRT1.o
+
+NOPIC=nopic
+NOPROFILE=noprofile
+
+# Logically src/sys
+S=${.CURDIR}/../../../..
+DIR_SA=$S/lib/libsa
+DIR_KERN=$S/lib/libkern
+
+SRC_net= nfs.c rpc.c net.c ether.c arp.c in_cksum.c netif.c \
+ bootparam.c rarp.c
+
+
+#SRC_sa = alloc.c bcopy.c memcpy.c close.c getfile.c open.c \
+# printf.c read.c strerror.c ufs.c globals.c lseek.c \
+# closeall.c dev.c dkcksum.c nullfs.c fstat.c
+
+SRC_sa = alloc.c bcopy.c close.c getfile.c open.c \
+ printf.c read.c strerror.c ufs.c globals.c lseek.c \
+ dev.c
+
+SRC_kern= ashrdi3.c bcmp.c bzero.c strcmp.c strlen.c
+
+SRC_here= clock.c devopen.c dvma.c \
+ gets.c panic.c \
+ promboot.c promcons.c
+
+SRCS= ${SRC_net} ${SRC_sa} ${SRC_kern} ${SRC_here}
+
+# DBG= -DDEBUG -DNETIF_DEBUG -DNFS_DEBUG -DRPC_DEBUG \
+# -DNET_DEBUG -DRARP_DEBUG -DETHER_DEBUG
+
+#DEFS= -DCOMPAT_UFS
+INCL= -I. -I${S}/lib/libsa -I${S}
+COPTS= #-fno-defer-pop
+CFLAGS= ${COPTS} ${DEFS} ${DBG} ${INCL}
+
+.PATH: ${DIR_SA} ${DIR_KERN} ../../sun3
+
+all: libsa.a SRT0.o SRT1.o
+
+install:
+
+.include <bsd.lib.mk>
diff --git a/sys/arch/mvme88k/stand/libsa/Makefile,v b/sys/arch/mvme88k/stand/libsa/Makefile,v
new file mode 100644
index 00000000000..00ad6d0e157
--- /dev/null
+++ b/sys/arch/mvme88k/stand/libsa/Makefile,v
@@ -0,0 +1,72 @@
+head 1.1;
+access;
+symbols;
+locks
+ build:1.1; strict;
+comment @# @;
+
+
+1.1
+date 96.02.03.01.43.48; author build; state Exp;
+branches;
+next ;
+
+
+desc
+@back up
+@
+
+
+1.1
+log
+@Initial revision
+@
+text
+@# $Id: Makefile,v,v 1.1 1997/03/03 19:30:37 rahnds Exp $
+
+LIB=sa
+
+CLEANFILES+=SRT0.o SRT1.o
+
+NOPIC=nopic
+NOPROFILE=noprofile
+
+# Logically src/sys
+S=${.CURDIR}/../../../..
+DIR_SA=$S/lib/libsa
+DIR_KERN=$S/lib/libkern
+
+SRC_net= nfs.c rpc.c net.c ether.c arp.c in_cksum.c netif.c \
+ bootparam.c rarp.c
+
+
+SRC_sa = alloc.c bcopy.c memcpy.c close.c getfile.c open.c \
+ printf.c read.c strerror.c ufs.c globals.c lseek.c \
+ closeall.c dev.c dkcksum.c nullfs.c fstat.c
+
+SRC_kern= ashrdi3.c bcmp.c bzero.c strcmp.c strlen.c
+
+SRC_sun3= exec_sun.c
+
+SRC_here= clock.c devopen.c dvma.c \
+ gets.c panic.c \
+ promboot.c promcons.c
+
+SRCS= ${SRC_net} ${SRC_sa} ${SRC_kern} ${SRC_sun3} ${SRC_here}
+
+# DBG= -DDEBUG -DNETIF_DEBUG -DNFS_DEBUG -DRPC_DEBUG \
+# -DNET_DEBUG -DRARP_DEBUG -DETHER_DEBUG
+
+#DEFS= -DCOMPAT_UFS
+INCL= -I. -I${S}/lib/libsa -I${S}
+COPTS= #-fno-defer-pop
+CFLAGS= -O2 ${COPTS} ${DEFS} ${DBG} ${INCL}
+
+.PATH: ${DIR_SA} ${DIR_KERN} ../../sun3
+
+all: libsa.a SRT0.o SRT1.o
+
+install:
+
+.include <bsd.lib.mk>
+@
diff --git a/sys/arch/mvme88k/stand/libsa/Makefile.inc b/sys/arch/mvme88k/stand/libsa/Makefile.inc
new file mode 100644
index 00000000000..c402951fa76
--- /dev/null
+++ b/sys/arch/mvme88k/stand/libsa/Makefile.inc
@@ -0,0 +1,12 @@
+LIB_SA_DIR=${S}/arch/${MACHINE}/stand/libsa
+
+LIBSA_DIR!= cd ${LIB_SA_DIR}; \
+ printf "xxx:\n\techo \$${.OBJDIR}\n" | ${MAKE} -r -s -f - xxx
+
+LIBSA=${LIBSA_DIR}/libsa.a
+
+$(LIBSA): .NOTMAIN __always_make_libsa
+ @echo making sure the libsa is up to date...
+ @(cd ${LIB_SA_DIR}; ${MAKE})
+
+__always_make_libsa: .NOTMAIN
diff --git a/sys/arch/mvme88k/stand/libsa/SRT0.S b/sys/arch/mvme88k/stand/libsa/SRT0.S
new file mode 100644
index 00000000000..7156aa32830
--- /dev/null
+++ b/sys/arch/mvme88k/stand/libsa/SRT0.S
@@ -0,0 +1,90 @@
+| $Id: SRT0.S,v 1.1 1997/03/03 19:30:35 rahnds Exp $
+
+| Copyright (c) 1996 Nivas Madhur
+| Copyright (c) 1995 Theo de Raadt
+|
+| 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 under OpenBSD by
+| Theo de Raadt for Willowglen Singapore.
+| 4. 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.
+|
+| Copyright (c) 1995 Gordon W. Ross
+| 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.
+| 4. All advertising materials mentioning features or use of this software
+| must display the following acknowledgement:
+| This product includes software developed by Gordon Ross
+|
+| 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.
+
+; SRT0.S - Stand-alone Run-Time startup code, part 0
+ .file "SRT0.S"
+ .text
+ .globl _stack
+_stack:
+ .globl _start
+_start:
+ .word __estack
+ .word _start
+
+ align 8
+ or.u r10, r0, hi16(_devlun)
+ st r2, r0, lo16(_devlun)
+ or.u r10, r0, hi16(_ctrlun)
+ st r3, r0, lo16(_ctrlun)
+ or.u r10, r0, hi16(_oparg)
+ st r8, r0, lo16(_oparg)
+ or.u r10, r0, hi16(_opargend)
+ st r9, r0, lo16(_opargend)
+; enable SFU1 - 88k disables SFU1 on a reset
+ ldcr r10, cr1
+ xor r10, r10, 0x8
+ stcr r10, cr1
+
+; Call the run-time startup C code, which will:
+; call main & call exit - exit passes control back to
+; to the Bug.
+ bsr __start
+
+; The end.
diff --git a/sys/arch/mvme88k/stand/libsa/SRT1.c b/sys/arch/mvme88k/stand/libsa/SRT1.c
new file mode 100644
index 00000000000..312751c6974
--- /dev/null
+++ b/sys/arch/mvme88k/stand/libsa/SRT1.c
@@ -0,0 +1,123 @@
+/* $Id: SRT1.c,v 1.1 1997/03/03 19:30:35 rahnds Exp $ */
+
+/*
+ * Copyright (c) 1996 Nivas Madhur
+ * Copyright (c) 1995 Theo de Raadt
+ *
+ * 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 under OpenBSD by
+ * Theo de Raadt for Willowglen Singapore.
+ * 4. 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.
+ *
+ * Copyright (c) 1995 Gordon W. Ross
+ * 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.
+ * 4. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by Gordon Ross
+ *
+ * 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.
+ */
+
+/* SRT1.c - Stand-alone Run-time startup code, part 1 */
+
+#include <stdarg.h>
+#include <sys/types.h>
+
+#include "config.h"
+
+extern char *edata, *end;
+
+int devlun = 0;
+int ctrlun = 0;
+int oparg = 0;
+int opargend = 0;
+
+getvbr()
+{
+ asm volatile ("ldcr r2, cr7");
+}
+
+void
+exit()
+{
+ /*
+ * Return to the Bug
+ */
+
+ asm volatile ("or r9, r0, 0x63; tb0 0, r0, 496");
+ /* NOTREACHED */
+}
+
+struct brdid brdid;
+int cputyp;
+
+/*
+ * This is called by SRT0.S
+ * to do final prep for main
+ */
+_start()
+{
+ struct brdid *p;
+
+ /* Clear BSS */
+
+ bzero(edata, end - edata);
+
+ asm volatile("or r9, r0, 0x70\n
+ tb0 0, r0, 496\n
+ st r2, %0" : "=m" (p));
+
+ bcopy(p, &brdid, sizeof brdid);
+ cputyp = brdid.model;
+
+ main(0);
+ exit();
+}
+
+/*
+ * Boot programs in C++ ? Not likely!
+ */
+__main()
+{}
diff --git a/sys/arch/mvme88k/stand/libsa/bug.c b/sys/arch/mvme88k/stand/libsa/bug.c
new file mode 100644
index 00000000000..e0ac46017bf
--- /dev/null
+++ b/sys/arch/mvme88k/stand/libsa/bug.c
@@ -0,0 +1,136 @@
+/*
+ * Copyright (c) 1995 Theo de Raadt
+ * 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 Theo de Raadt
+ * 4. 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.
+ *
+ * bug routines -- assumes that the necessary sections of memory
+ * are preserved.
+ */
+#include <sys/types.h>
+#include <machine/prom.h>
+
+#define MVMEPROM_CALL(x) \
+ asm volatile (__CONCAT("trap #15; .short ", __STRING(x)) )
+
+/* returns 0 if no characters ready to read */
+int
+mvmeprom_instat()
+{
+ u_short ret;
+
+ MVMEPROM_CALL(MVMEPROM_INSTAT);
+ asm volatile ("movew ccr,%0": "=d" (ret));
+ return (!(ret & 0x4));
+}
+
+void
+mvmeprom_outstr(start, end)
+ char *start, *end;
+{
+ asm volatile ("movl %0, sp@-" : "=a" (start));
+ asm volatile ("movl %0, sp@-" : "=a" (end));
+ MVMEPROM_CALL(MVMEPROM_OUTSTR);
+}
+
+void
+mvmeprom_outln(start, end)
+ char *start, *end;
+{
+ asm volatile ("movl %0, sp@-" : "=a" (start));
+ asm volatile ("movl %0, sp@-" : "=a" (end));
+ MVMEPROM_CALL(MVMEPROM_OUTSTRCRLF);
+}
+
+/* returns 0: success, nonzero: error */
+int
+mvmeprom_diskrd(arg)
+ struct mvmeprom_dskio *arg;
+{
+ int ret;
+
+ asm volatile ("movel %0, sp@-"::"d" (arg));
+ MVMEPROM_CALL(MVMEPROM_DSKRD);
+ asm volatile ("movew ccr,%0": "=d" (ret));
+ return (!(ret & 0x4));
+}
+
+/* returns 0: success, nonzero: error */
+int
+mvmeprom_diskwr(arg)
+ struct mvmeprom_dskio *arg;
+{
+ int ret;
+
+ asm volatile ("movel %0, sp@-"::"d" (arg));
+ MVMEPROM_CALL(MVMEPROM_DSKWR);
+ asm volatile ("movew ccr,%0": "=d" (ret));
+ return (!(ret & 0x4));
+}
+
+#ifdef NOTYET
+mvmeprom_diskcfig() {}
+mvmeprom_diskfmt(){}
+mvmeprom_diskctrl(){}
+#endif
+
+/* BUG - timing routine */
+void
+mvmeprom_delay(msec)
+ int msec;
+{
+ asm volatile ("movel %0,sp@-" : :"d" (msec));
+ MVMEPROM_CALL(MVMEPROM_DELAY);
+}
+
+/* BUG - return to bug routine */
+void
+mvmeprom_return()
+{
+ MVMEPROM_CALL(MVMEPROM_EXIT);
+ /*NOTREACHED*/
+}
+
+/* BUG - query board routines */
+struct mvmeprom_brdid *
+mvmeprom_getbrdid()
+{
+ struct mvmeprom_brdid *id;
+
+ asm volatile ("clrl sp@-");
+ MVMEPROM_CALL(MVMEPROM_GETBRDID);
+ asm volatile ("movel sp@+,%0": "=d" (id):);
+ return (id);
+}
+
+void
+mvmeprom_rtc_rd(ptime)
+ struct mvmeprom_time *ptime;
+{
+ asm volatile ("movel %0,sp@-" : :"a" (ptime));
+ MVMEPROM_CALL(MVMEPROM_RTC_RD);
+}
diff --git a/sys/arch/mvme88k/stand/libsa/clock.c b/sys/arch/mvme88k/stand/libsa/clock.c
new file mode 100644
index 00000000000..683bd48f849
--- /dev/null
+++ b/sys/arch/mvme88k/stand/libsa/clock.c
@@ -0,0 +1,79 @@
+#include <sys/types.h>
+
+#include "clockreg.h"
+#include "config.h"
+#include "clock.h"
+
+/*
+ * BCD to decimal and decimal to BCD.
+ */
+#define FROMBCD(x) (((x) >> 4) * 10 + ((x) & 0xf))
+#define TOBCD(x) (((x) / 10 * 16) + ((x) % 10))
+
+#define SECDAY (24 * 60 * 60)
+#define SECYR (SECDAY * 365)
+#define LEAPYEAR(y) (((y) & 3) == 0)
+
+/*
+ * This code is defunct after 2068.
+ * Will Unix still be here then??
+ */
+const short dayyr[12] =
+{0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334};
+
+static u_long
+chiptotime(sec, min, hour, day, mon, year)
+ register int sec, min, hour, day, mon, year;
+{
+ register int days, yr;
+
+ sec = FROMBCD(sec);
+ min = FROMBCD(min);
+ hour = FROMBCD(hour);
+ day = FROMBCD(day);
+ mon = FROMBCD(mon);
+ year = FROMBCD(year) + YEAR0;
+ if (year < 70)
+ year = 70;
+
+ /* simple sanity checks */
+ if (year < 70 || mon < 1 || mon > 12 || day < 1 || day > 31)
+ return (0);
+ days = 0;
+ for (yr = 70; yr < year; yr++)
+ days += LEAPYEAR(yr) ? 366 : 365;
+ days += dayyr[mon - 1] + day - 1;
+ if (LEAPYEAR(yr) && mon > 2)
+ days++;
+ /* now have days since Jan 1, 1970; the rest is easy... */
+ return (days * SECDAY + hour * 3600 + min * 60 + sec);
+}
+
+time_t
+getsecs()
+{
+ extern int cputyp;
+ register struct clockreg *cl;
+ int sec, min, hour, day, mon, year;
+
+ if (cputyp == CPU_147)
+ cl = (struct clockreg *) CLOCK_ADDR_147;
+ else
+ cl = (struct clockreg *) CLOCK_ADDR_16x;
+
+ cl->cl_csr |= CLK_READ; /* enable read (stop time) */
+ sec = cl->cl_sec;
+ min = cl->cl_min;
+ hour = cl->cl_hour;
+ day = cl->cl_mday;
+ mon = cl->cl_month;
+ year = cl->cl_year;
+ cl->cl_csr &= ~CLK_READ;/* time wears on */
+ return (chiptotime(sec, min, hour, day, mon, year));
+}
+
+int
+getticks()
+{
+ return getsecs() * 100;
+}
diff --git a/sys/arch/mvme88k/stand/libsa/clock.h b/sys/arch/mvme88k/stand/libsa/clock.h
new file mode 100644
index 00000000000..d61bc9b03b8
--- /dev/null
+++ b/sys/arch/mvme88k/stand/libsa/clock.h
@@ -0,0 +1,6 @@
+
+extern int hz;
+
+time_t getsecs();
+int getticks();
+
diff --git a/sys/arch/mvme88k/stand/libsa/clockreg.h b/sys/arch/mvme88k/stand/libsa/clockreg.h
new file mode 100644
index 00000000000..7eb7eba2b81
--- /dev/null
+++ b/sys/arch/mvme88k/stand/libsa/clockreg.h
@@ -0,0 +1,71 @@
+/* $Id: clockreg.h,v 1.1 1997/03/03 19:30:37 rahnds Exp $ */
+
+/*
+ * Copyright (c) 1992, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This software was developed by the Computer Systems Engineering group
+ * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
+ * contributed to Berkeley.
+ *
+ * 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, Lawrence Berkeley Laboratory.
+ *
+ * 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.
+ *
+ * @(#)clockreg.h 8.1 (Berkeley) 6/11/93
+ */
+
+/*
+ * Mostek MK48T02 clock.
+ */
+struct clockreg {
+ volatile u_char cl_csr; /* control register */
+ volatile u_char cl_sec; /* seconds (0..59; BCD) */
+ volatile u_char cl_min; /* minutes (0..59; BCD) */
+ volatile u_char cl_hour;/* hour (0..23; BCD) */
+ volatile u_char cl_wday;/* weekday (1..7) */
+ volatile u_char cl_mday;/* day in month (1..31; BCD) */
+ volatile u_char cl_month; /* month (1..12; BCD) */
+ volatile u_char cl_year;/* year (0..99; BCD) */
+};
+/* bits in cl_csr */
+#define CLK_WRITE 0x80 /* want to write */
+#define CLK_READ 0x40 /* want to read (freeze clock) */
+
+/*
+ * Sun chose the year `68' as their base count, so that
+ * cl_year==0 means 1968.
+ */
+#define YEAR0 68
+
+#define CLOCK_ADDR_147 (0xfffe07f8) /* PA of clock */
+#define CLOCK_ADDR_16x (0xfffc1ff8) /* PA of clock */
diff --git a/sys/arch/mvme88k/stand/libsa/config.h b/sys/arch/mvme88k/stand/libsa/config.h
new file mode 100644
index 00000000000..0aad19e505f
--- /dev/null
+++ b/sys/arch/mvme88k/stand/libsa/config.h
@@ -0,0 +1,66 @@
+/* $Id: config.h,v 1.1 1997/03/03 19:30:37 rahnds Exp $ */
+
+/*
+ * Copyright (c) 1995 Theo de Raadt
+ * 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 Theo de Raadt
+ * 4. 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.
+ */
+
+/* configuration information for base-line code */
+
+#define ETHER_ADDR_147 (0xfffe0778)
+#define ETHER_ADDR_16X (0xfffc0000+7980)
+#define ERAM_ADDR (0xfffe0774)
+#define LANCE_REG_ADDR (0xfffe1800)
+#define INTEL_REG_ADDR (0xfff46000)
+
+#define CPU_147 0x147
+#define CPU_162 0x162
+#define CPU_167 0x167
+#define CPU_172 0x172
+#define CPU_177 0x177
+
+struct brdid {
+ u_long eye_catcher;
+ u_char rev;
+ u_char month;
+ u_char day;
+ u_char year;
+ u_short size;
+ u_short rsv1;
+ u_short model;
+ u_short suffix;
+ u_short options;
+ u_char family;
+ u_char cpu;
+ u_short ctrlun;
+ u_short devlun;
+ u_short devtype;
+ u_short devnum;
+ u_long bug;
+};
diff --git a/sys/arch/mvme88k/stand/libsa/dev_disk.c b/sys/arch/mvme88k/stand/libsa/dev_disk.c
new file mode 100644
index 00000000000..65c1db4ac64
--- /dev/null
+++ b/sys/arch/mvme88k/stand/libsa/dev_disk.c
@@ -0,0 +1,132 @@
+/* $Id: dev_disk.c,v 1.1 1997/03/03 19:30:36 rahnds Exp $ */
+
+/*
+ * Copyright (c) 1993 Paul Kranenburg
+ * 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 Paul Kranenburg.
+ * 4. 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.
+ */
+
+/*
+ * This module implements a "raw device" interface suitable for
+ * use by the stand-alone I/O library UFS file-system code, and
+ * possibly for direct access (i.e. boot from tape).
+ *
+ * The implementation is deceptively simple because it uses the
+ * drivers provided by the Sun PROM monitor. Note that only the
+ * PROM driver used to load the boot program is available here.
+ */
+
+#include <sys/types.h>
+#include <machine/mon.h>
+#include <machine/saio.h>
+
+#include "stand.h"
+
+#include "dvma.h"
+#include "promdev.h"
+
+int
+disk_open(f, devname)
+ struct open_file *f;
+ char *devname; /* Device part of file name (or NULL). */
+{
+ struct saioreq *sip;
+ int error;
+
+#ifdef DEBUG_PROM
+ printf("disk_open: %s\n", devname);
+#endif
+
+ if ((error = prom_iopen(&sip)) != 0)
+ return (error);
+
+ f->f_devdata = sip;
+ return 0;
+}
+
+int
+disk_close(f)
+ struct open_file *f;
+{
+ struct saioreq *sip;
+
+ sip = f->f_devdata;
+ prom_iclose(sip);
+ f->f_devdata = NULL;
+ return 0;
+}
+
+int
+disk_strategy(devdata, flag, dblk, size, buf, rsize)
+ void *devdata;
+ int flag;
+ daddr_t dblk;
+ u_int size;
+ char *buf;
+ u_int *rsize;
+{
+ struct saioreq *si;
+ struct boottab *ops;
+ char *dmabuf;
+ int si_flag, xcnt;
+
+ si = devdata;
+ ops = si->si_boottab;
+
+#ifdef DEBUG_PROM
+ printf("disk_strategy: size=%d dblk=%d\n", size, dblk);
+#else
+ twiddle();
+#endif
+
+ dmabuf = dvma_mapin(buf, size);
+
+ si->si_bn = dblk;
+ si->si_ma = dmabuf;
+ si->si_cc = size;
+
+ si_flag = (flag == F_READ) ? SAIO_F_READ : SAIO_F_WRITE;
+ xcnt = (*ops->b_strategy)(si, si_flag);
+ dvma_mapout(dmabuf, size);
+
+#ifdef DEBUG_PROM
+ printf("disk_strategy: xcnt = %x\n", xcnt);
+#endif
+
+ if (xcnt <= 0)
+ return (EIO);
+
+ *rsize = xcnt;
+ return (0);
+}
+
+int
+disk_ioctl()
+{
+ return EIO;
+}
+
diff --git a/sys/arch/mvme88k/stand/libsa/dev_disk.h b/sys/arch/mvme88k/stand/libsa/dev_disk.h
new file mode 100644
index 00000000000..9f05f74bd82
--- /dev/null
+++ b/sys/arch/mvme88k/stand/libsa/dev_disk.h
@@ -0,0 +1,6 @@
+
+int disk_open __P((struct open_file *, ...));
+int disk_close __P((struct open_file *));
+int disk_strategy __P((void *, int, daddr_t, u_int, char *, u_int *));
+int disk_ioctl();
+
diff --git a/sys/arch/mvme88k/stand/libsa/devopen.c b/sys/arch/mvme88k/stand/libsa/devopen.c
new file mode 100644
index 00000000000..92c083983cb
--- /dev/null
+++ b/sys/arch/mvme88k/stand/libsa/devopen.c
@@ -0,0 +1,32 @@
+
+#include <sys/param.h>
+#include <stand.h>
+#include "promboot.h"
+
+/*
+ * Open the device named by the combined device/file name
+ * given as the "fname" arg, something like: "sd()bsd"
+ *
+ * However, Sun PROMs don't really let you choose which
+ * device you will talk to. You can only open the device
+ * that was used to load the boot program. Therefore, we
+ * do not accept a "device" part in the "fname" string.
+ * Pass the PROM device name to open in case it needs it.
+ */
+int
+devopen(f, fname, file)
+ struct open_file *f;
+ const char *fname;
+ char **file;
+{
+ struct devsw *dp;
+ char *cp, *path, *devname;
+ int error;
+
+ *file = (char*)fname;
+ dp = &devsw[0];
+ f->f_dev = dp;
+ error = (*dp->dv_open)(f, prom_bootdev);
+
+ return (error);
+}
diff --git a/sys/arch/mvme88k/stand/libsa/dvma.c b/sys/arch/mvme88k/stand/libsa/dvma.c
new file mode 100644
index 00000000000..11526106c2a
--- /dev/null
+++ b/sys/arch/mvme88k/stand/libsa/dvma.c
@@ -0,0 +1,68 @@
+
+/*
+ * The easiest way to deal with the need for DVMA mappings is
+ * to just map the first four megabytes of RAM into DVMA space.
+ * That way, dvma_mapin can just compute the DVMA alias address,
+ * and dvma_mapout does nothing.
+ */
+
+#include <sys/param.h>
+
+#define DVMA_BASE 0x00000000
+#define DVMA_MASK 0x00ffFFff
+#define DVMA_MAPLEN 0x400000 /* 4 MB */
+
+void
+dvma_init()
+{
+#if 0
+ int segva, sme;
+
+ for (segva = 0; segva < DVMA_MAPLEN; segva += NBSG) {
+ sme = get_segmap(segva);
+ set_segmap((DVMA_BASE | segva), sme);
+ }
+#endif
+}
+
+/* Convert a local address to a DVMA address. */
+char *
+dvma_mapin(char *addr, int len)
+{
+ int va = (int)addr;
+
+ va |= DVMA_BASE;
+ return ((char *) va);
+}
+
+/* Convert a DVMA address to a local address. */
+char *
+dvma_mapout(char *dmabuf, int len)
+{
+ if (dmabuf < (char*)DVMA_BASE)
+ panic("dvma_mapout");
+ return (dmabuf - DVMA_BASE);
+}
+
+extern char *alloc(int len);
+char *
+dvma_alloc(int len)
+{
+ char *mem;
+
+ mem = alloc(len);
+ if (!mem)
+ return(mem);
+ return(dvma_mapin(mem, len));
+}
+
+extern void free(void *ptr, int len);
+void
+dvma_free(char *dvma, int len)
+{
+ char *mem;
+
+ mem = dvma_mapout(dvma, len);
+ if (mem)
+ free(mem, len);
+}
diff --git a/sys/arch/mvme88k/stand/libsa/dvma.h b/sys/arch/mvme88k/stand/libsa/dvma.h
new file mode 100644
index 00000000000..2b8be37cbe0
--- /dev/null
+++ b/sys/arch/mvme88k/stand/libsa/dvma.h
@@ -0,0 +1,6 @@
+
+char * dvma_mapin(char *pkt, int len);
+void dvma_mapout(char *dmabuf, int len);
+
+char * dvma_alloc(int len);
+
diff --git a/sys/arch/mvme88k/stand/libsa/exec_sun.c b/sys/arch/mvme88k/stand/libsa/exec_sun.c
new file mode 100644
index 00000000000..5708b413541
--- /dev/null
+++ b/sys/arch/mvme88k/stand/libsa/exec_sun.c
@@ -0,0 +1,212 @@
+/* $Id: exec_sun.c,v 1.1 1997/03/03 19:30:36 rahnds Exp $ */
+
+/*-
+ * Copyright (c) 1995 Theo de Raadt
+ * 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 Theo de Raadt
+ * 4. 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.
+ *
+ * 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.
+ *
+ * @(#)boot.c 8.1 (Berkeley) 6/10/93
+ */
+
+#include <sys/param.h>
+#include <sys/reboot.h>
+#include <a.out.h>
+
+#include "stand.h"
+
+extern int debug;
+
+extern u_int bootdev;
+
+/*ARGSUSED*/
+exec_sun(file, loadaddr, howto)
+ char *file;
+ char *loadaddr;
+ int howto;
+{
+ register int io;
+ struct exec x;
+ int cc, magic;
+ void (*entry)();
+ register char *cp;
+ register int *ip;
+ int textlen;
+
+#ifdef DEBUG
+ printf("exec_sun: file=%s loadaddr=0x%x\n", file, loadaddr);
+#endif
+
+ io = open(file, 0);
+ if (io < 0)
+ return(-1);
+
+ /*
+ * Read in the exec header, and validate it.
+ */
+ if (read(io, (char *)&x, sizeof(x)) != sizeof(x))
+ goto shread;
+ if (N_BADMAG(x)) {
+ errno = EFTYPE;
+ goto closeout;
+ }
+
+ cp = loadaddr;
+ textlen = x.a_text;
+ magic = N_GETMAGIC(x);
+ if (magic == ZMAGIC) {
+ cp += sizeof(x);
+ textlen -= sizeof(x);
+ }
+ entry = (void (*)())cp;
+
+ /*
+ * Leave a copy of the exec header before the text.
+ * The sun3 kernel uses this to verify that the
+ * symbols were loaded by this boot program.
+ */
+ bcopy(&x, cp - sizeof(x), sizeof(x));
+
+ /*
+ * Read in the text segment.
+ */
+ printf("%x", x.a_text);
+ if (read(io, cp, textlen) != textlen)
+ goto shread;
+ cp += textlen;
+
+ /*
+ * NMAGIC may have a gap between text and data.
+ */
+ if (magic == NMAGIC) {
+ register int mask = N_PAGSIZ(x) - 1;
+ while ((int)cp & mask)
+ *cp++ = 0;
+ }
+
+ /*
+ * Read in the data segment.
+ */
+ printf("+%x", x.a_data);
+ if (read(io, cp, x.a_data) != x.a_data)
+ goto shread;
+ cp += x.a_data;
+
+ /*
+ * Zero out the BSS section.
+ * (Kernel does not do it itself)
+ */
+ printf("+%x", x.a_bss);
+ cc = x.a_bss;
+ while ((int)cp & 3) {
+ *cp++ = 0;
+ --cc;
+ }
+ ip = (int *)cp;
+ cp += cc;
+ while ((char *)ip < cp)
+ *ip++ = 0;
+
+ /*
+ * Read in the symbol table and strings.
+ * (Always set the symtab size word.)
+ */
+ *ip++ = x.a_syms;
+ cp = (char *)ip;
+
+ if (x.a_syms > 0) {
+
+ /* Symbol table and string table length word. */
+ cc = x.a_syms;
+ printf("+[%x", cc);
+ cc += sizeof(int); /* strtab length too */
+ if (read(io, cp, cc) != cc)
+ goto shread;
+ cp += x.a_syms;
+ ip = (int *)cp; /* points to strtab length */
+ cp += sizeof(int);
+
+ /* String table. Length word includes itself. */
+ cc = *ip;
+ printf("+%x]", cc);
+ cc -= sizeof(int);
+ if (cc <= 0)
+ goto shread;
+ if (read(io, cp, cc) != cc)
+ goto shread;
+ cp += cc;
+ }
+ printf("=%x\n", cp - loadaddr);
+ close(io);
+
+ if (debug) {
+ printf("Debug mode - enter c to continue\n");
+ asm(" trap #0");
+ }
+
+ printf("Starting program at 0x%x\n", (int)entry);
+ (*entry)(howto, bootdev, cp, 0, 0);
+ panic("exec returned");
+
+shread:
+ printf("exec: short read\n");
+ errno = EIO;
+closeout:
+ close(io);
+ return(-1);
+}
diff --git a/sys/arch/mvme88k/stand/libsa/gets.c b/sys/arch/mvme88k/stand/libsa/gets.c
new file mode 100644
index 00000000000..071acc0d9fa
--- /dev/null
+++ b/sys/arch/mvme88k/stand/libsa/gets.c
@@ -0,0 +1,141 @@
+/* $Id: gets.c,v 1.1 1997/03/03 19:30:35 rahnds Exp $ */
+
+/*-
+ * Copyright (c) 1995 Theo de Raadt
+ * 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 Theo de Raadt
+ * 4. 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.
+ *
+ * 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.
+ *
+ * @(#)gets.c 8.1 (Berkeley) 6/11/93
+ */
+
+#include "stand.h"
+
+/*
+ * This implementation assumes that getchar() does echo, because
+ * on some machines, it is hard to keep echo from being done.
+ * Those that need it can do echo in their getchar() function.
+ *
+ * Yes, the code below will echo CR, DEL, and other control chars,
+ * but sending CR or DEL here is harmless. All the other editing
+ * characters will be followed by a newline, so it doesn't matter.
+ * (Most terminals will not show them anyway.)
+ */
+
+void
+gets(buf)
+ char *buf;
+{
+ register int c;
+ register char *lp;
+
+top:
+ lp = buf;
+
+ for (;;) {
+ c = getchar() & 0177;
+
+ putchar(c);
+
+ switch (c) {
+
+ default:
+ *lp++ = c;
+ continue;
+
+ case '\177':
+ putchar('\b');
+ /* fall through */
+ case '\b':
+ putchar(' ');
+ putchar('\b');
+ /* fall through */
+ case '#':
+ if (lp > buf)
+ lp--;
+ continue;
+
+ /*
+ * This is not very useful in a boot program.
+ * (It costs you 52 bytes on m68k, gcc -O3).
+ */
+ case 'r'&037: {
+ register char *p;
+ putchar('\n');
+ for (p = buf; p < lp; ++p)
+ putchar(*p);
+ continue;
+ }
+
+ case '@':
+ case 'u'&037:
+ case 'w'&037:
+ putchar('\n');
+ goto top;
+
+ case '\r':
+ putchar('\n');
+ /* fall through */
+ case '\n':
+ *lp = '\0';
+ return;
+
+ } /* switch */
+ }
+ /*NOTREACHED*/
+}
diff --git a/sys/arch/mvme88k/stand/libsa/log1 b/sys/arch/mvme88k/stand/libsa/log1
new file mode 100644
index 00000000000..17047779eef
--- /dev/null
+++ b/sys/arch/mvme88k/stand/libsa/log1
@@ -0,0 +1,130 @@
+nfs.o nfs.o
+rpc.o rpc.o
+net.o net.o
+ether.o ether.o
+arp.o arp.o
+in_cksum.o in_cksum.o
+netif.o netif.o
+bootparam.o bootparam.o
+rarp.o rarp.o
+alloc.o alloc.o
+bcopy.o bcopy.o
+memcpy.o memcpy.o
+close.o close.o
+getfile.o getfile.o
+open.o open.o
+printf.o printf.o
+read.o read.o
+strerror.o strerror.o
+ufs.o ufs.o
+globals.o globals.o
+lseek.o lseek.o
+closeall.o closeall.o
+dev.o dev.o
+dkcksum.o dkcksum.o
+nullfs.o nullfs.o
+fstat.o fstat.o
+ashrdi3.o ashrdi3.o
+bcmp.o bcmp.o
+bzero.o bzero.o
+strcmp.o strcmp.o
+strlen.o strlen.o
+exec_sun.o exec_sun.o
+clock.o clock.o
+devopen.o devopen.o
+dvma.o dvma.o
+gets.o gets.o
+panic.o panic.o
+promboot.o promboot.o
+promcons.o promcons.o
+ufs.o ashrdi3.o
+dvma.o alloc.o
+nfs.o alloc.o
+ufs.o alloc.o
+net.o arp.o
+net.o arp.o
+arp.o globals.o
+ether.o globals.o
+rarp.o globals.o
+arp.o bcmp.o
+ether.o bcmp.o
+rarp.o bcmp.o
+arp.o bcopy.o
+bootparam.o bcopy.o
+ether.o bcopy.o
+exec_sun.o bcopy.o
+memcpy.o bcopy.o
+net.o bcopy.o
+nfs.o bcopy.o
+rarp.o bcopy.o
+ufs.o bcopy.o
+arp.o bzero.o
+net.o bzero.o
+netif.o bzero.o
+nfs.o bzero.o
+rarp.o bzero.o
+rpc.o bzero.o
+ufs.o bzero.o
+closeall.o close.o
+exec_sun.o close.o
+open.o devopen.o
+dvma.o alloc.o
+nfs.o alloc.o
+ufs.o alloc.o
+gets.o promcons.o
+getfile.o gets.o
+net.o clock.o
+net.o in_cksum.o
+arp.o net.o
+ether.o netif.o
+ether.o netif.o
+net.o globals.o
+rarp.o globals.o
+exec_sun.o open.o
+getfile.o open.o
+arp.o panic.o
+exec_sun.o panic.o
+net.o panic.o
+netif.o panic.o
+arp.o printf.o
+bootparam.o printf.o
+exec_sun.o printf.o
+getfile.o printf.o
+net.o printf.o
+netif.o printf.o
+nfs.o printf.o
+panic.o printf.o
+rarp.o printf.o
+rpc.o printf.o
+gets.o promcons.o
+printf.o promcons.o
+exec_sun.o read.o
+arp.o ether.o
+net.o ether.o
+rarp.o ether.o
+rpc.o net.o
+bootparam.o rpc.o
+nfs.o rpc.o
+bootparam.o rpc.o
+bootparam.o rpc.o
+bootparam.o rpc.o
+nfs.o rpc.o
+arp.o ether.o
+net.o ether.o
+rarp.o ether.o
+arp.o net.o
+rarp.o net.o
+rpc.o net.o
+rpc.o net.o
+bootparam.o netif.o
+nfs.o netif.o
+rarp.o netif.o
+strerror.o printf.o
+ufs.o strcmp.o
+rpc.o strerror.o
+bootparam.o strlen.o
+nfs.o strlen.o
+ufs.o strlen.o
+nfs.o printf.o
+read.o printf.o
+ufs.o printf.o
diff --git a/sys/arch/mvme88k/stand/libsa/log2 b/sys/arch/mvme88k/stand/libsa/log2
new file mode 100644
index 00000000000..31ecde33da0
--- /dev/null
+++ b/sys/arch/mvme88k/stand/libsa/log2
@@ -0,0 +1,39 @@
+promboot.o
+dvma.o
+exec_sun.o
+fstat.o
+nullfs.o
+dkcksum.o
+dev.o
+closeall.o
+lseek.o
+ufs.o
+read.o
+getfile.o
+close.o
+memcpy.o
+rarp.o
+bootparam.o
+nfs.o
+gets.o
+strlen.o
+strcmp.o
+ashrdi3.o
+open.o
+alloc.o
+rpc.o
+devopen.o
+strerror.o
+arp.o
+net.o
+clock.o
+in_cksum.o
+ether.o
+bcmp.o
+globals.o
+bcopy.o
+netif.o
+panic.o
+bzero.o
+printf.o
+promcons.o
diff --git a/sys/arch/mvme88k/stand/libsa/netif_sun.c b/sys/arch/mvme88k/stand/libsa/netif_sun.c
new file mode 100644
index 00000000000..5201318a14a
--- /dev/null
+++ b/sys/arch/mvme88k/stand/libsa/netif_sun.c
@@ -0,0 +1,284 @@
+/* $Id: netif_sun.c,v 1.1 1997/03/03 19:30:36 rahnds Exp $ */
+
+/*
+ * Copyright (c) 1995 Gordon W. Ross
+ * 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.
+ * 4. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by Gordon W. Ross
+ *
+ * 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.
+ */
+
+/*
+ * The Sun PROM has a fairly general set of network drivers,
+ * so it is easiest to just replace the netif module with
+ * this adaptation to the PROM network interface.
+ */
+
+#include <sys/param.h>
+#include <sys/socket.h>
+#include <string.h>
+#include <time.h>
+
+#include <net/if.h>
+
+#include <netinet/in.h>
+#include <netinet/if_ether.h>
+#include <netinet/in_systm.h>
+
+#include <machine/control.h>
+#include <machine/idprom.h>
+#include <machine/mon.h>
+#include <machine/saio.h>
+
+#include "stand.h"
+#include "net.h"
+#include "netif.h"
+
+#include "clock.h"
+#include "dvma.h"
+#include "promdev.h"
+
+static struct netif netif_prom;
+
+#ifdef NETIF_DEBUG
+int netif_debug;
+#endif
+
+struct iodesc sockets[SOPEN_MAX];
+
+struct iodesc *
+socktodesc(sock)
+ int sock;
+{
+ if (sock != 0) {
+ return(NULL);
+ }
+ return (sockets);
+}
+
+int
+netif_open(machdep_hint)
+ void *machdep_hint;
+{
+ struct saioreq *si;
+ struct iodesc *io;
+ int fd, error;
+
+ /* find a free socket */
+ io = sockets;
+ if (io->io_netif) {
+#ifdef DEBUG
+ printf("netif_open: device busy\n");
+#endif
+ return (-1);
+ }
+ bzero(io, sizeof(*io));
+
+ /*
+ * Note: Sun PROMs will do RARP on open, but does not tell
+ * you the IP address it gets, so it is just noise to us...
+ */
+ if ((error = prom_iopen(&si)) != 0) {
+#ifdef DEBUG
+ printf("netif_open: prom_iopen, error=%d\n", error);
+#endif
+ return (-1);
+ }
+ if (si->si_sif == NULL) {
+#ifdef DEBUG
+ printf("netif_open: not a network device\n");
+#endif
+ prom_iclose(si);
+ return (-1);
+ }
+
+ netif_prom.devdata = si;
+ io->io_netif = &netif_prom;
+
+ /* Put our ethernet address in io->myea */
+ sun3_getether(io->myea);
+
+ return(0);
+}
+
+int
+netif_close(fd)
+ int fd;
+{
+ struct iodesc *io;
+ struct netif *ni;
+
+ if (fd != 0) {
+ errno = EBADF;
+ return(-1);
+ }
+
+ io = sockets;
+ ni = io->io_netif;
+ if (ni != NULL) {
+ prom_iclose(ni->devdata);
+ ni->devdata = NULL;
+ io->io_netif = NULL;
+ }
+ return(0);
+}
+
+/*
+ * Send a packet. The ether header is already there.
+ * Return the length sent (or -1 on error).
+ */
+int
+netif_put(desc, pkt, len)
+ struct iodesc *desc;
+ void *pkt;
+ int len;
+{
+ struct saioreq *si;
+ struct saif *sif;
+ char *dmabuf;
+ int rv, sendlen;
+
+#ifdef NETIF_DEBUG
+ if (netif_debug) {
+ struct ether_header *eh;
+
+ printf("netif_put: desc=0x%x pkt=0x%x len=%d\n",
+ desc, pkt, len);
+ eh = pkt;
+ printf("dst: %s ", ether_sprintf(eh->ether_dhost));
+ printf("src: %s ", ether_sprintf(eh->ether_shost));
+ printf("type: 0x%x\n", eh->ether_type & 0xFFFF);
+ }
+#endif
+
+ si = desc->io_netif->devdata;
+ sif = si->si_sif;
+ sendlen = len;
+ if (sendlen < 60) {
+ sendlen = 60;
+#ifdef NETIF_DEBUG
+ printf("netif_put: length padded to %d\n", sendlen);
+#endif
+ }
+
+#ifdef PARANOID
+ if (sif == NULL)
+ panic("netif_put: no saif ptr\n");
+#endif
+
+ dmabuf = dvma_mapin(pkt, sendlen);
+ rv = sif->sif_xmit(si->si_devdata, dmabuf, sendlen);
+ dvma_mapout(dmabuf, sendlen);
+
+#ifdef NETIF_DEBUG
+ if (netif_debug)
+ printf("netif_put: xmit returned %d\n", rv);
+#endif
+ if (rv == 0) rv = len;
+ else rv = -1;
+
+ return rv;
+}
+
+/*
+ * Receive a packet, including the ether header.
+ * Return the total length received (or -1 on error).
+ */
+int
+netif_get(desc, pkt, maxlen, timo)
+ struct iodesc *desc;
+ void *pkt;
+ int maxlen;
+ time_t timo;
+{
+ struct saioreq *si;
+ struct saif *sif;
+ char *dmabuf;
+ int tick0, tmo_ticks;
+ int len;
+
+#ifdef NETIF_DEBUG
+ if (netif_debug)
+ printf("netif_get: pkt=0x%x, maxlen=%d, tmo=%d\n",
+ pkt, maxlen, timo);
+#endif
+
+ si = desc->io_netif->devdata;
+ sif = si->si_sif;
+
+#ifdef PARANOID
+ if (sif == NULL)
+ panic("netif_get: no saif ptr\n");
+#endif
+
+ tmo_ticks = timo * hz;
+ tick0 = getticks();
+
+ dmabuf = dvma_mapin(pkt, maxlen);
+ do len = sif->sif_poll(si->si_devdata, dmabuf);
+ while ((len == 0) && ((getticks() - tick0) < tmo_ticks));
+ dvma_mapout(dmabuf, maxlen);
+
+#ifdef NETIF_DEBUG
+ if (netif_debug)
+ printf("netif_get: received len=%d\n", len);
+#endif
+
+ if (len < 12)
+ return -1;
+
+#ifdef NETIF_DEBUG
+ if (netif_debug) {
+ struct ether_header *eh = pkt;
+
+ printf("dst: %s ", ether_sprintf(eh->ether_dhost));
+ printf("src: %s ", ether_sprintf(eh->ether_shost));
+ printf("type: 0x%x\n", eh->ether_type & 0xFFFF);
+ }
+#endif
+
+ return len;
+}
+
+static struct idprom sun3_idprom;
+
+sun3_getether(ea)
+ u_char *ea;
+{
+ u_char *src, *dst;
+ int len, x;
+
+ if (sun3_idprom.idp_format == 0) {
+ dst = (char*)&sun3_idprom;
+ src = (char*)IDPROM_BASE;
+ len = IDPROM_SIZE;
+ do {
+ x = get_control_byte(src++);
+ *dst++ = x;
+ } while (--len > 0);
+ }
+ MACPY(sun3_idprom.idp_etheraddr, ea);
+}
+
diff --git a/sys/arch/mvme88k/stand/libsa/panic.c b/sys/arch/mvme88k/stand/libsa/panic.c
new file mode 100644
index 00000000000..f7c83a6d8e7
--- /dev/null
+++ b/sys/arch/mvme88k/stand/libsa/panic.c
@@ -0,0 +1,31 @@
+
+#include <stdarg.h>
+#include "stand.h"
+
+extern volatile void abort();
+extern int _estack[];
+
+__dead void
+panic(const char *fmt, ...)
+{
+ va_list ap;
+
+ va_start(ap, fmt);
+ printf(fmt, ap);
+ printf("\n");
+ va_end(ap);
+ stackdump(0);
+ abort();
+}
+
+stackdump(dummy)
+ int dummy;
+{
+ int *ip;
+
+ printf("stackdump:\n");
+ for (ip = &dummy; ip < _estack; ip += 4) {
+ printf("%x: %x %x %x %x\n",
+ (int)ip, ip[0], ip[1], ip[2], ip[3]);
+ }
+}
diff --git a/sys/arch/mvme88k/stand/libsa/promboot.c b/sys/arch/mvme88k/stand/libsa/promboot.c
new file mode 100644
index 00000000000..fc4aea53e82
--- /dev/null
+++ b/sys/arch/mvme88k/stand/libsa/promboot.c
@@ -0,0 +1,93 @@
+/* $Id: promboot.c,v 1.1 1997/03/03 19:30:36 rahnds Exp $ */
+
+/*
+ * Copyright (c) 1995 Theo de Raadt
+ * 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 Theo de Raadt
+ * 4. 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.
+ */
+
+#include <sys/param.h>
+#include <sys/reboot.h>
+#include "stand.h"
+#include "promboot.h"
+
+char prom_bootdev[32];
+char prom_bootfile[32];
+int prom_boothow;
+int debug;
+
+void
+prom_get_boot_info()
+{
+ char c, *src, *dst;
+ extern int devlun, ctrlun;
+ extern char *oparg, *opargend;
+
+#ifdef DEBUG
+ printf("prom_get_boot_info\n");
+#endif
+
+ /* Get kernel filename */
+ src = oparg;
+ while (src && (*src == ' ' || *src == '\t'))
+ src++;
+
+ dst = prom_bootfile;
+ if (src && *src != '-') {
+ while (src && *src) {
+ if (*src == ' ' || *src == '\t')
+ break;
+ *dst++ = *src++;
+ }
+ }
+ *dst = '\0';
+
+ /* Get boothowto flags */
+ while (src && (*src == ' ' || *src == '\t'))
+ src++;
+ if (src && (*src == '-')) {
+ while (*src) {
+ switch (*src++) {
+ case 'a':
+ prom_boothow |= RB_ASKNAME;
+ break;
+ case 's':
+ prom_boothow |= RB_SINGLE;
+ break;
+ case 'd':
+ prom_boothow |= RB_KDB;
+ debug = 1;
+ break;
+ }
+ }
+ }
+#ifdef DEBUG
+ printf("promboot: device=\"%s\" file=\"%s\" how=0x%x\n",
+ prom_bootdev, prom_bootfile, prom_boothow);
+#endif
+}
diff --git a/sys/arch/mvme88k/stand/libsa/promboot.h b/sys/arch/mvme88k/stand/libsa/promboot.h
new file mode 100644
index 00000000000..86b5aace21c
--- /dev/null
+++ b/sys/arch/mvme88k/stand/libsa/promboot.h
@@ -0,0 +1,5 @@
+
+extern char prom_bootdev[];
+extern char prom_bootfile[];
+extern int prom_boothow;
+
diff --git a/sys/arch/mvme88k/stand/libsa/promcons.c b/sys/arch/mvme88k/stand/libsa/promcons.c
new file mode 100644
index 00000000000..77ece569969
--- /dev/null
+++ b/sys/arch/mvme88k/stand/libsa/promcons.c
@@ -0,0 +1,71 @@
+/* $Id: promcons.c,v 1.1 1997/03/03 19:30:36 rahnds Exp $ */
+
+/*
+ * Copyright (c) 1996 Nivas Madhur
+ * Copyright (c) 1995 Theo de Raadt
+ * 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 Theo de Raadt
+ * 4. 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.
+ */
+
+#include <stdarg.h>
+#include <sys/types.h>
+
+int
+getchar()
+{
+ char c;
+
+ __asm volatile("or r9, r0, 0\n
+ tb0 0, r0, 496\n
+ st.b r2, %0" : "=m" (c));
+ return (c);
+}
+
+peekchar()
+{
+ int have = 0;
+
+ __asm volatile("or r9, r0, 1\n
+ tb0 0, r0, 496\n
+ bb1 2, r2, 1f\n
+ or r2,r0, 1\n
+ st r2, %0\n1:" : "=m" (have) :);
+ return (have);
+}
+
+void
+putchar(c)
+ int c;
+{
+ if (c == '\n')
+ putchar('\r');
+ __asm volatile("or r9, r0, 0x20\n
+ or r2, r0, %0\n
+ tb0 0, r0, 496\n" : : "r" (c));
+}
+
diff --git a/sys/arch/mvme88k/stand/libsa/promdev.c b/sys/arch/mvme88k/stand/libsa/promdev.c
new file mode 100644
index 00000000000..7ba01390c31
--- /dev/null
+++ b/sys/arch/mvme88k/stand/libsa/promdev.c
@@ -0,0 +1,193 @@
+/* $Id: promdev.c,v 1.1 1997/03/03 19:30:36 rahnds Exp $ */
+
+/*
+ * Copyright (c) 1995 Gordon W. Ross
+ * Copyright (c) 1993 Paul Kranenburg
+ * 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 Paul Kranenburg.
+ * 4. 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.
+ */
+
+#include <sys/param.h>
+#include <machine/mon.h>
+#include <machine/pte.h>
+#include <machine/saio.h>
+
+#include <dvma.h>
+#include <stand.h>
+
+struct saioreq prom_si;
+static int promdev_inuse;
+
+static char *
+prom_mapin(u_long physaddr, int length, int maptype);
+
+int
+prom_iopen(void **devdatap)
+{
+ struct bootparam *bp;
+ struct boottab *ops;
+ struct devinfo *dip;
+ struct saioreq *si;
+ char *p;
+ int error;
+
+ if (promdev_inuse)
+ return(EMFILE);
+
+ bp = *romp->bootParam;
+ ops = bp->bootDevice;
+ dip = ops->b_devinfo;
+
+#ifdef DEBUG_PROM
+ printf("Boot device type: %s\n", ops->b_desc);
+#endif
+
+ dvma_init();
+
+ si = &prom_si;
+ bzero((caddr_t)si, sizeof(*si));
+ si->si_boottab = ops;
+ si->si_ctlr = bp->ctlrNum;
+ si->si_unit = bp->unitNum;
+ si->si_boff = bp->partNum;
+
+ if (si->si_ctlr > dip->d_stdcount) {
+ printf("Invalid controller number\n");
+ return(ENXIO);
+ }
+
+ if (dip->d_devbytes) {
+ si->si_devaddr = prom_mapin(dip->d_stdaddrs[si->si_ctlr],
+ dip->d_devbytes, dip->d_devtype);
+#ifdef DEBUG_PROM
+ printf("prom_iopen: devaddr=0x%x pte=0x%x\n",
+ si->si_devaddr, get_pte(si->si_devaddr));
+#endif
+ }
+
+ if (dip->d_dmabytes) {
+ si->si_dmaaddr = dvma_alloc(dip->d_dmabytes);
+#ifdef DEBUG_PROM
+ printf("prom_iopen: dmaaddr=0x%x\n", si->si_dmaaddr);
+#endif
+ }
+
+ /* OK, call the PROM device open routine. */
+ error = (*ops->b_open)(si);
+ if (error != 0) {
+ printf("prom_iopen: \"%s\" error=%d\n",
+ ops->b_desc, error);
+ return (ENXIO);
+ }
+#ifdef DEBUG_PROM
+ printf("prom_iopen: succeeded, error=%d\n", error);
+#endif
+
+ *devdatap = si;
+ promdev_inuse++;
+ return (0);
+}
+
+void
+prom_iclose(void *devdata)
+{
+ struct boottab *ops;
+ struct devinfo *dip;
+ struct saioreq *si;
+
+ if (promdev_inuse == 0)
+ return;
+
+ si = devdata;
+ ops = si->si_boottab;
+ dip = ops->b_devinfo;
+
+ (*ops->b_close)(si);
+
+ if (si->si_dmaaddr) {
+ dvma_free(si->si_dmaaddr, dip->d_dmabytes);
+ si->si_dmaaddr = NULL;
+ }
+
+ promdev_inuse = 0;
+}
+
+struct mapinfo {
+ int maptype;
+ int pgtype;
+ int base;
+};
+
+static struct mapinfo
+prom_mapinfo[] = {
+ { MAP_MAINMEM, PGT_OBMEM, 0 },
+ { MAP_OBIO, PGT_OBIO, 0 },
+ { MAP_MBMEM, PGT_OBMEM, 0 }, /* XXX - Sun2 Multibus? */
+ { MAP_MBIO, PGT_OBIO, 0 }, /* XXX - Sun2 Multibus? */
+ { MAP_VME16A16D, PGT_VME_D16, 0xFFFF0000 },
+ { MAP_VME16A32D, PGT_VME_D32, 0xFFFF0000 },
+ { MAP_VME24A16D, PGT_VME_D16, 0xFF000000 },
+ { MAP_VME24A32D, PGT_VME_D32, 0xFF000000 },
+ { MAP_VME32A16D, PGT_VME_D16, 0 },
+ { MAP_VME32A32D, PGT_VME_D32, 0 },
+};
+static prom_mapinfo_cnt = sizeof(prom_mapinfo) / sizeof(prom_mapinfo[0]);
+
+/* The virtual address we will use for PROM device mappings. */
+static int prom_devmap = MONSHORTSEG;
+
+static char *
+prom_mapin(physaddr, length, maptype)
+ u_long physaddr;
+ int length, maptype;
+{
+ int i, pa, pte, va;
+
+ if (length > (4*NBPG))
+ panic("prom_mapin: length=%d\n", length);
+
+ for (i = 0; i < prom_mapinfo_cnt; i++)
+ if (prom_mapinfo[i].maptype == maptype)
+ goto found;
+ panic("prom_mapin: invalid maptype %d\n", maptype);
+found:
+
+ pte = prom_mapinfo[i].pgtype;
+ pte |= PG_PERM;
+ pa = prom_mapinfo[i].base;
+ pa += physaddr;
+ pte |= PA_PGNUM(pa);
+
+ va = prom_devmap;
+ do {
+ set_pte(va, pte);
+ va += NBPG;
+ pte += 1;
+ length -= NBPG;
+ } while (length > 0);
+ return ((char*)prom_devmap);
+}
diff --git a/sys/arch/mvme88k/stand/libsa/promdev.h b/sys/arch/mvme88k/stand/libsa/promdev.h
new file mode 100644
index 00000000000..e3ae5ba2d7c
--- /dev/null
+++ b/sys/arch/mvme88k/stand/libsa/promdev.h
@@ -0,0 +1,4 @@
+
+int prom_iopen(struct saioreq **sipp);
+void prom_iclose(struct saioreq *sip);
+