summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys/arch/mvme88k/stand/Makefile8
-rw-r--r--sys/arch/mvme88k/stand/bugcrt/Makefile16
-rw-r--r--sys/arch/mvme88k/stand/bugcrt/Makefile.inc7
-rw-r--r--sys/arch/mvme88k/stand/bugcrt/crt0.S27
-rw-r--r--sys/arch/mvme88k/stand/libsa/Makefile8
-rw-r--r--sys/arch/mvme88k/stand/libsa/config.h63
-rw-r--r--sys/arch/mvme88k/stand/libsa/fault.c152
-rw-r--r--sys/arch/mvme88k/stand/libsa/libsa.h7
-rw-r--r--sys/arch/mvme88k/stand/libsa/setjmp.S79
-rw-r--r--sys/arch/mvme88k/stand/netboot/Makefile7
-rw-r--r--sys/arch/mvme88k/stand/netboot/boot.c29
-rw-r--r--sys/arch/mvme88k/stand/netboot/conf.c16
-rw-r--r--sys/arch/mvme88k/stand/netboot/config.h90
-rw-r--r--sys/arch/mvme88k/stand/netboot/dev_net.c23
-rw-r--r--sys/arch/mvme88k/stand/netboot/devices.c99
-rw-r--r--sys/arch/mvme88k/stand/netboot/if_ie.c135
-rw-r--r--sys/arch/mvme88k/stand/netboot/if_iereg.h163
-rw-r--r--sys/arch/mvme88k/stand/netboot/if_le.c422
-rw-r--r--sys/arch/mvme88k/stand/netboot/if_lereg.h45
-rw-r--r--sys/arch/mvme88k/stand/netboot/netif.c299
-rw-r--r--sys/arch/mvme88k/stand/netboot/version.c5
-rw-r--r--sys/arch/mvme88k/stand/sboot/Makefile49
-rw-r--r--sys/arch/mvme88k/stand/sboot/TODO3
-rw-r--r--sys/arch/mvme88k/stand/sboot/XBUG.S69
-rw-r--r--sys/arch/mvme88k/stand/sboot/XSRT0.S67
-rw-r--r--sys/arch/mvme88k/stand/sboot/clock.c118
-rw-r--r--sys/arch/mvme88k/stand/sboot/clockreg.h65
-rw-r--r--sys/arch/mvme88k/stand/sboot/devices.c160
-rw-r--r--sys/arch/mvme88k/stand/sboot/devopen.c69
-rw-r--r--sys/arch/mvme88k/stand/sboot/etherfun.c217
-rw-r--r--sys/arch/mvme88k/stand/sboot/etherfun.h126
-rw-r--r--sys/arch/mvme88k/stand/sboot/if_le.c350
-rw-r--r--sys/arch/mvme88k/stand/sboot/if_lereg.h172
-rw-r--r--sys/arch/mvme88k/stand/sboot/oc_cksum.S187
-rw-r--r--sys/arch/mvme88k/stand/sboot/sboot.c147
-rw-r--r--sys/arch/mvme88k/stand/sboot/sboot.h97
-rw-r--r--sys/arch/mvme88k/stand/sboot/srec.c159
-rw-r--r--sys/arch/mvme88k/stand/sboot/version.c6
38 files changed, 1376 insertions, 2385 deletions
diff --git a/sys/arch/mvme88k/stand/Makefile b/sys/arch/mvme88k/stand/Makefile
index b7a566f762e..ee09f5e15c1 100644
--- a/sys/arch/mvme88k/stand/Makefile
+++ b/sys/arch/mvme88k/stand/Makefile
@@ -1,9 +1,9 @@
-# $OpenBSD: Makefile,v 1.7 2004/01/28 08:46:29 miod Exp $
+# $OpenBSD: Makefile,v 1.8 2013/05/12 10:43:45 miod Exp $
.if ${MACHINE} == "mvme88k"
-SUBDIR= bugcrt libbug libsa libz wrtvid bootsd bootxx bootst netboot tftpboot
-# not really written yet...
-# SUBDIR+= sboot
+SUBDIR= bugcrt libbug libsa libz
+SUBDIR+= bootxx bootsd wrtvid bootst
+SUBDIR+= netboot sboot tftpboot
.endif
SUBDIR+=installboot
diff --git a/sys/arch/mvme88k/stand/bugcrt/Makefile b/sys/arch/mvme88k/stand/bugcrt/Makefile
index 8683797724a..e8821d2a538 100644
--- a/sys/arch/mvme88k/stand/bugcrt/Makefile
+++ b/sys/arch/mvme88k/stand/bugcrt/Makefile
@@ -1,17 +1,16 @@
-# $OpenBSD: Makefile,v 1.14 2013/01/05 11:20:56 miod Exp $
+# $OpenBSD: Makefile,v 1.15 2013/05/12 10:43:45 miod Exp $
S=${.CURDIR}/../../../..
CFLAGS+=-I${.CURDIR}/../../include -I${.CURDIR}/../libbug -I${S}/lib/libsa
-STAGE1_CFLAGS=-DSTAGE1
-STAGE2_CFLAGS=-DSTAGE2
-NETBOOT_CFLAGS=-DNETBOOT
+STAGE1_CFLAGS= -DLOAD_FROM_VID
+STAGE2_CFLAGS= -DLOAD_FROM_BOOTXX
+NETBOOT_CFLAGS= -DNETBOOT
+SREC_CFLAGS= -DSREC
SRCS=crt0.S
-OBJS=stage1crt.o stage2crt.o netcrt.o
+OBJS=stage1crt.o stage2crt.o netcrt.o sreccrt.o
NOPIE=
-CLEANFILES+=stage1crt.out stage2crt.out netcrt.out ${OBJS}
-
all: ${OBJS}
stage1crt.o: crt0.S
@@ -23,6 +22,9 @@ stage2crt.o: crt0.S
netcrt.o: crt0.S
${CC} ${CFLAGS} ${NETBOOT_CFLAGS} -c ${.CURDIR}/crt0.S -o ${.TARGET}
+sreccrt.o: crt0.S
+ ${CC} ${CFLAGS} ${SREC_CFLAGS} -c ${.CURDIR}/crt0.S -o ${.TARGET}
+
install:
lint tags:
diff --git a/sys/arch/mvme88k/stand/bugcrt/Makefile.inc b/sys/arch/mvme88k/stand/bugcrt/Makefile.inc
index 34c7287512b..87a1d85ba90 100644
--- a/sys/arch/mvme88k/stand/bugcrt/Makefile.inc
+++ b/sys/arch/mvme88k/stand/bugcrt/Makefile.inc
@@ -1,4 +1,4 @@
-# $OpenBSD: Makefile.inc,v 1.6 2008/04/02 21:53:17 miod Exp $
+# $OpenBSD: Makefile.inc,v 1.7 2013/05/12 10:43:45 miod Exp $
BUG_CRT_DIR=${S}/arch/mvme88k/stand/bugcrt
@@ -8,6 +8,7 @@ BUGCRT_DIR!= cd ${BUG_CRT_DIR}; \
STAGE1_CRT=${BUGCRT_DIR}/stage1crt.o
STAGE2_CRT=${BUGCRT_DIR}/stage2crt.o
NETBOOT_CRT=${BUGCRT_DIR}/netcrt.o
+SREC_CRT=${BUGCRT_DIR}/sreccrt.o
$(STAGE1_CRT): .NOTMAIN __always_make_bugcrt
@echo making sure stage1crt.o is up to date...
@@ -21,4 +22,8 @@ $(NETBOOT_CRT): .NOTMAIN __always_make_bugcrt
@echo making sure netcrt.o is up to date...
@(cd ${BUG_CRT_DIR}; ${MAKE} netcrt.o)
+$(SREC_CRT): .NOTMAIN __always_make_bugcrt
+ @echo making sure sreccrt.o is up to date...
+ @(cd ${BUG_CRT_DIR}; ${MAKE} sreccrt.o)
+
__always_make_bugcrt: .NOTMAIN
diff --git a/sys/arch/mvme88k/stand/bugcrt/crt0.S b/sys/arch/mvme88k/stand/bugcrt/crt0.S
index eaf2f1ec259..ccf04144fd1 100644
--- a/sys/arch/mvme88k/stand/bugcrt/crt0.S
+++ b/sys/arch/mvme88k/stand/bugcrt/crt0.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: crt0.S,v 1.2 2013/01/05 11:20:56 miod Exp $ */
+/* $OpenBSD: crt0.S,v 1.3 2013/05/12 10:43:45 miod Exp $ */
/*
* Copyright (c) 2008 Miodrag Vallat.
@@ -23,7 +23,7 @@
.text
ASGLOBAL(__start)
-#ifdef STAGE1
+#ifdef LOAD_FROM_VID
/*
* Binaries loaded *from disk* by the BUG start with two special words.
*
@@ -41,9 +41,9 @@ ASGLOBAL(__start)
.long _ASM_LABEL(__start)
.long _ASM_LABEL(real_start) - _ASM_LABEL(__start)
-#endif /* STAGE1 */
+#endif /* LOAD_FROM_VID */
-#ifdef STAGE2
+#ifdef LOAD_FROM_BOOTXX
/*
* bootxx runs the second-stage binary at its entry + 8, in case
* it contains the special two words.
@@ -52,9 +52,18 @@ ASGLOBAL(__start)
NOP
#endif
+#ifdef SREC
+ /*
+ * Get the address of real_start in %r6, as if we had been loaded
+ * as a regular boot block.
+ */
+ bsr.n _ASM_LABEL(real_start)
+ or %r6, %r0, %r1
+#endif
+
ASLOCAL(real_start)
/*
- * Registers on entry:
+ * Registers on entry, unless loaded from S-Records:
* r2 boot device lun
* r3 boot controller lun
* r4 cold/warm boot mode (`IPL\01')
@@ -70,7 +79,7 @@ ASLOCAL(real_start)
* r31 stack, as setup above
*/
-#if defined(STAGE2) || defined(NETBOOT)
+#if defined(LOAD_FROM_BOOTXX) || defined(NETBOOT) || defined(SREC)
/*
* We first relocate ourselves to our preferred address.
@@ -124,7 +133,7 @@ reloc_done:
ASLOCAL(__start_relocated)
-#endif /* STAGE2 || NETBOOT */
+#endif /* LOAD_FROM_BOOTXX || NETBOOT || SREC */
/*
* Clear BSS.
@@ -145,6 +154,8 @@ ASLOCAL(__start_relocated)
*/
clr %r31, %r6, 4<0>
+#ifndef SREC
+
/*
* Save our arguments so that all registers are available to
* C code.
@@ -175,6 +186,8 @@ ASLOCAL(__start_relocated)
st.b %r0, %r9, %r0
#endif
+#endif /* !SREC */
+
/*
* PSR when booted from the BUG has SFU1..SFU7 disabled.
* Enable SFU1 (the FPU) for the C code to be able to use it
diff --git a/sys/arch/mvme88k/stand/libsa/Makefile b/sys/arch/mvme88k/stand/libsa/Makefile
index efd16b1f73f..f8a5c6f44ef 100644
--- a/sys/arch/mvme88k/stand/libsa/Makefile
+++ b/sys/arch/mvme88k/stand/libsa/Makefile
@@ -1,4 +1,4 @@
-# $OpenBSD: Makefile,v 1.14 2012/08/21 14:46:19 pascal Exp $
+# $OpenBSD: Makefile,v 1.15 2013/05/12 10:43:45 miod Exp $
LIB=sa
@@ -9,16 +9,16 @@ NOPIE=
# Logically src/sys
S=${.CURDIR}/../../../..
-SRCS= board.c bugdev.c clock.c parse_args.c exec_mvme.c
+SRCS= board.c bugdev.c clock.c exec_mvme.c fault.c parse_args.c setjmp.S
.PATH: ${S}/lib/libsa
SRCS+= alloc.c memcpy.c exit.c getfile.c gets.c globals.c \
printf.c strerror.c memset.c memcmp.c strncpy.c strcmp.c strlen.c \
- strlcpy.c strlcat.c snprintf.c \
+ strlcpy.c strlcat.c snprintf.c strchr.c \
close.c closeall.c dev.c dkcksum.c \
lseek.c open.c nullfs.c read.c fstat.c \
ufs.c cread.c
-SRCS+= arp.c ether.c in_cksum.c net.c netif.c rpc.c nfs.c \
+SRCS+= arp.c ether.c in_cksum.c net.c rpc.c nfs.c \
rarp.c bootparam.c
SRCS+= loadfile.c
diff --git a/sys/arch/mvme88k/stand/libsa/config.h b/sys/arch/mvme88k/stand/libsa/config.h
deleted file mode 100644
index f39a1e97f5c..00000000000
--- a/sys/arch/mvme88k/stand/libsa/config.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/* $OpenBSD: config.h,v 1.4 2003/06/04 21:47:59 deraadt 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.
- *
- * 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
-#define CPU_187 0x187
-
-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/fault.c b/sys/arch/mvme88k/stand/libsa/fault.c
new file mode 100644
index 00000000000..9b12d96752a
--- /dev/null
+++ b/sys/arch/mvme88k/stand/libsa/fault.c
@@ -0,0 +1,152 @@
+/* $OpenBSD: fault.c,v 1.1 2013/05/12 10:43:45 miod Exp $ */
+
+/*
+ * Copyright (c) 2013 Miodrag Vallat.
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+/*
+ * Standalone code to recover from faults. Allows for hardware detection.
+ */
+
+#include <sys/param.h>
+
+#include <machine/asm.h>
+#include <machine/asm_macro.h>
+#include <machine/prom.h>
+#include <machine/psl.h>
+
+#include "stand.h"
+#include "libsa.h"
+
+typedef struct label_t {
+ long val[19];
+} label_t;
+
+extern int setjmp(label_t *);
+extern void longjmp(label_t *);
+
+static label_t badaddr_jmpbuf;
+static uint32_t badaddr_psr;
+
+static uint32_t bug_vbr;
+static uint32_t vector_page[512 * 2] __attribute__ ((__aligned__(0x1000)));
+
+static __inline__ uint32_t
+get_vbr()
+{
+ uint32_t vbr;
+ __asm__ __volatile__ ("ldcr %0, %%cr7" : "=r"(vbr));
+ return vbr;
+}
+
+static __inline__ void
+set_vbr(uint32_t vbr)
+{
+ __asm__ __volatile__ ("stcr %0, %%cr7" :: "r"(vbr));
+}
+
+/*
+ * This is an horribly crude logic to recover from data access exceptions
+ * by longjmp'ing back to badaddr(). We should theoretically at least use
+ * an `rte' somewhere to unfreeze the scoreboard. But since we restore a
+ * PSR with interrupts disabled, this turns out to be safe.
+ */
+static void
+libsa_fault_handler(void)
+{
+ set_psr(badaddr_psr | PSR_IND); /* undo SFRZ */
+ flush_pipeline();
+
+ longjmp(&badaddr_jmpbuf);
+ /* NOTREACHED */
+}
+
+static __inline__ uint32_t
+br(uint32_t delta)
+{
+ return 0xc0000000 | (((int32_t)delta >> 2) & 0x03ffffff);
+}
+
+static void
+libsa_fault_init()
+{
+ int vec;
+ uint32_t *insn;
+ uint32_t br_insn;
+
+ bug_vbr = get_vbr();
+
+ insn = vector_page;
+ br_insn = br(bug_vbr - (uint32_t)&vector_page - 4);
+ for (vec = 512; vec != 0; vec--) {
+ *insn++ = 0xf4005800; /* nop */
+ *insn++ = br_insn; /* br into bug vbr page */
+ }
+
+ /* override data access exception */
+ vector_page[3 * 2 + 1] =
+ br((uint32_t)&libsa_fault_handler -
+ (uint32_t)&vector_page[3 * 2 + 1]);
+}
+
+int
+badaddr(void *addr, int len)
+{
+ int rc;
+
+ if (vector_page[0] == 0)
+ libsa_fault_init();
+
+ badaddr_psr = get_psr();
+ set_psr(badaddr_psr | PSR_IND);
+
+ set_vbr((uint32_t)&vector_page);
+
+ if (setjmp(&badaddr_jmpbuf) == 0) {
+ switch (len) {
+ case 1:
+ (void)*(volatile uint8_t *)addr;
+ rc = 0;
+ break;
+ case 2:
+ if ((uint32_t)addr & 1)
+ rc = 1;
+ else {
+ (void)*(volatile uint16_t *)addr;
+ rc = 0;
+ }
+ break;
+ case 4:
+ if ((uint32_t)addr & 3)
+ rc = 1;
+ else {
+ (void)*(volatile uint32_t *)addr;
+ rc = 0;
+ }
+ break;
+ default:
+ rc = 1;
+ break;
+ }
+ } else {
+ rc = 1;
+ }
+
+ set_vbr(bug_vbr);
+ flush_pipeline();
+ set_psr(badaddr_psr);
+
+ return rc;
+}
diff --git a/sys/arch/mvme88k/stand/libsa/libsa.h b/sys/arch/mvme88k/stand/libsa/libsa.h
index 8653ee3d3ac..660afccb761 100644
--- a/sys/arch/mvme88k/stand/libsa/libsa.h
+++ b/sys/arch/mvme88k/stand/libsa/libsa.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: libsa.h,v 1.6 2011/03/13 00:13:53 deraadt Exp $ */
+/* $OpenBSD: libsa.h,v 1.7 2013/05/12 10:43:45 miod Exp $ */
/*
* libsa prototypes
@@ -7,7 +7,7 @@
#include "libbug.h"
/* board.c */
-void board_setup();
+void board_setup(void);
/* bugdev.c */
int bugscopen(struct open_file *, ...);
@@ -18,6 +18,9 @@ int bugscstrategy(void *, int, daddr32_t, size_t, void *, size_t *);
/* exec_mvme.c */
void exec_mvme(char *, int);
+/* fault.c */
+int badaddr(void *, int);
+
/* parse_args.c */
int parse_args(char **, int *);
diff --git a/sys/arch/mvme88k/stand/libsa/setjmp.S b/sys/arch/mvme88k/stand/libsa/setjmp.S
new file mode 100644
index 00000000000..30f19dd1d9e
--- /dev/null
+++ b/sys/arch/mvme88k/stand/libsa/setjmp.S
@@ -0,0 +1,79 @@
+/* $OpenBSD: setjmp.S,v 1.1 2013/05/12 10:43:45 miod Exp $ */
+/*
+ * Mach Operating System
+ * Copyright (c) 1993-1992 Carnegie Mellon University
+ * Copyright (c) 1991 OMRON Corporation
+ * Copyright (c) 1996 Nivas Madhur
+ * Copyright (c) 1998 Steve Murphree, Jr.
+ * All Rights Reserved.
+ *
+ * Permission to use, copy, modify and distribute this software and its
+ * documentation is hereby granted, provided that both the copyright
+ * notice and this permission notice appear in all copies of the
+ * software, derivative works or modified versions, and any portions
+ * thereof, and that both notices appear in supporting documentation.
+ *
+ * CARNEGIE MELLON AND OMRON ALLOW FREE USE OF THIS SOFTWARE IN ITS "AS IS"
+ * CONDITION. CARNEGIE MELLON AND OMRON DISCLAIM ANY LIABILITY OF ANY KIND
+ * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
+ *
+ * Carnegie Mellon requests users of this software to return to
+ *
+ * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
+ * School of Computer Science
+ * Carnegie Mellon University
+ * Pittsburgh PA 15213-3890
+ *
+ * any improvements or extensions that they make and grant Carnegie the
+ * rights to redistribute these changes.
+ */
+
+#include <machine/asm.h>
+
+/* int setjmp(label_t *); */
+ENTRY(setjmp)
+ st %r1, %r2, 0
+ st %r14, %r2, 4
+ st %r15, %r2, 2*4
+ st %r16, %r2, 3*4
+ st %r17, %r2, 4*4
+ st %r18, %r2, 5*4
+ st %r19, %r2, 6*4
+ st %r20, %r2, 7*4
+ st %r21, %r2, 8*4
+ st %r22, %r2, 9*4
+ st %r23, %r2, 10*4
+ st %r24, %r2, 11*4
+ st %r25, %r2, 12*4
+ st %r26, %r2, 13*4
+ st %r27, %r2, 14*4
+ st %r28, %r2, 15*4
+ st %r29, %r2, 16*4
+ st %r30, %r2, 17*4
+ st %r31, %r2, 18*4
+ jmp.n %r1
+ or %r2, %r0, %r0
+
+/* void longjmp(label_t*); */
+ENTRY(longjmp)
+ ld %r1, %r2, 0
+ ld %r14, %r2, 4
+ ld %r15, %r2, 2*4
+ ld %r16, %r2, 3*4
+ ld %r17, %r2, 4*4
+ ld %r18, %r2, 5*4
+ ld %r19, %r2, 6*4
+ ld %r20, %r2, 7*4
+ ld %r21, %r2, 8*4
+ ld %r22, %r2, 9*4
+ ld %r23, %r2, 10*4
+ ld %r24, %r2, 11*4
+ ld %r25, %r2, 12*4
+ ld %r26, %r2, 13*4
+ ld %r27, %r2, 14*4
+ ld %r28, %r2, 15*4
+ ld %r29, %r2, 16*4
+ ld %r30, %r2, 17*4
+ ld %r31, %r2, 18*4
+ jmp.n %r1
+ or %r2, %r0, 1
diff --git a/sys/arch/mvme88k/stand/netboot/Makefile b/sys/arch/mvme88k/stand/netboot/Makefile
index 49ac0a5a259..7dcdf357cfd 100644
--- a/sys/arch/mvme88k/stand/netboot/Makefile
+++ b/sys/arch/mvme88k/stand/netboot/Makefile
@@ -1,4 +1,4 @@
-# $OpenBSD: Makefile,v 1.19 2013/01/16 20:45:09 miod Exp $
+# $OpenBSD: Makefile,v 1.20 2013/05/12 10:43:45 miod Exp $
SIZE?= size
STRIP?= strip
@@ -16,9 +16,10 @@ CLEANFILES+=netboot netboot.bin
.include "${S}/arch/mvme88k/stand/libsa/Makefile.inc"
.include "${S}/arch/mvme88k/stand/libz/Makefile.inc"
-SRCS= boot.c conf.c version.c devopen.c dev_net.c
+SRCS= boot.c devices.c version.c
+SRCS+= conf.c dev_net.c devopen.c netif.c
SRCS+= if_ie.c
-#SRCS+= if_le.c
+SRCS+= if_le.c
OBJS= ${SRCS:S/.c/.o/g}
LIBS= ${LIBSA} ${LIBBUG} ${LIBZ}
LDFLAGS=-N -T ${S}/arch/mvme88k/stand/ld.script -Ttext ${STAGE2_RELOC}
diff --git a/sys/arch/mvme88k/stand/netboot/boot.c b/sys/arch/mvme88k/stand/netboot/boot.c
index 68efb279d70..a5b1bb2f033 100644
--- a/sys/arch/mvme88k/stand/netboot/boot.c
+++ b/sys/arch/mvme88k/stand/netboot/boot.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: boot.c,v 1.10 2013/01/05 11:20:56 miod Exp $ */
+/* $OpenBSD: boot.c,v 1.11 2013/05/12 10:43:45 miod Exp $ */
/*-
* Copyright (c) 1995 Theo de Raadt
@@ -56,14 +56,15 @@
*/
#include <sys/param.h>
-#include <sys/reboot.h>
#include <machine/prom.h>
#include "stand.h"
#include "libsa.h"
+#include "config.h"
+
extern const char *version;
-char line[80];
+char line[128];
int
main()
@@ -75,6 +76,14 @@ main()
printf("\n>> OpenBSD/mvme88k netboot [%s]\n", version);
+ if (probe_ethernet() == 0) {
+ printf("Sorry, this Ethernet device is supported by the BUG"
+ " but not by the OpenBSD\n"
+ "boot blocks yet. Consider trying to netboot `tftpboot'"
+ " instead.\n");
+ return 1;
+ }
+
ret = parse_args(&file, &howto);
for (;;) {
@@ -87,17 +96,17 @@ main()
while (cp < (line + sizeof(line) - 1) && *cp)
cp++;
bugargs.arg_end = cp;
- ret =parse_args(&file, &howto);
+ ret = parse_args(&file, &howto);
+
+ if (ret) {
+ printf("returning to BUG\n");
+ break;
+ }
}
}
- if (ret) {
- printf("boot: -q returning to MVME-Bug\n");
- break;
- }
exec_mvme(file, howto);
printf("boot: %s: %s\n", file, strerror(errno));
ask = 1;
}
- _rtt();
- return (0);
+ return 0;
}
diff --git a/sys/arch/mvme88k/stand/netboot/conf.c b/sys/arch/mvme88k/stand/netboot/conf.c
index ab297f36ce4..d5794736801 100644
--- a/sys/arch/mvme88k/stand/netboot/conf.c
+++ b/sys/arch/mvme88k/stand/netboot/conf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: conf.c,v 1.3 1999/09/27 19:30:01 smurph Exp $ */
+/* $OpenBSD: conf.c,v 1.4 2013/05/12 10:43:45 miod Exp $ */
#include <sys/types.h>
#include <netinet/in.h>
@@ -14,21 +14,9 @@ struct fs_ops file_system[] = {
int nfsys = sizeof(file_system) / sizeof(file_system[0]);
struct devsw devsw[] = {
- { "net", net_strategy, net_open, net_close, net_ioctl },
+ { "net", net_strategy, net_open, net_close, net_ioctl },
};
int ndevs = sizeof(devsw) / sizeof(devsw[0]);
-/*
-extern struct netif_driver le_driver;
-*/
-extern struct netif_driver ie_driver;
-
-struct netif_driver *netif_drivers[] = {
- &ie_driver,
-/*
- &le_driver,
-*/
-};
-int n_netif_drivers = sizeof(netif_drivers) / sizeof(netif_drivers[0]);
/* XXX */
diff --git a/sys/arch/mvme88k/stand/netboot/config.h b/sys/arch/mvme88k/stand/netboot/config.h
index 1ff6a4153a6..6d3e9d6d3c0 100644
--- a/sys/arch/mvme88k/stand/netboot/config.h
+++ b/sys/arch/mvme88k/stand/netboot/config.h
@@ -1,64 +1,46 @@
-/* $OpenBSD: config.h,v 1.3 2003/06/04 04:11:37 deraadt Exp $ */
+/* $OpenBSD: config.h,v 1.4 2013/05/12 10:43:45 miod Exp $ */
/*
- * Copyright (c) 1995 Theo de Raadt
- * All rights reserved.
+ * Copyright (c) 2013 Miodrag Vallat.
*
- * 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.
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
*
- * 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 SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-/* configuration information for base-line code */
+/* MVME187/MVME197 on-board */
-#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)
+struct ie_configuration {
+ int clun;
+ u_int phys_addr;
+ u_char eaddr[6];
+};
+
+extern struct ie_configuration ie_config[];
+extern int nie_config;
+
+#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
-#define CPU_187 0x187
-#define CPU_188 0x188
-#define CPU_197 0x197
+/* MVME376 */
-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;
+struct le_configuration {
+ int clun;
+ u_int phys_addr; /* registers */
+ u_int buf_addr; /* buffers if off-memory */
+ u_int buf_size; /* buffer memory size */
+ u_char eaddr[6];
};
+
+extern struct le_configuration le_config[];
+extern int nle_config;
+
+extern int probe_ethernet(void);
+extern void display_ethernet(void);
diff --git a/sys/arch/mvme88k/stand/netboot/dev_net.c b/sys/arch/mvme88k/stand/netboot/dev_net.c
index 8f4958d46ad..0bb308d74e2 100644
--- a/sys/arch/mvme88k/stand/netboot/dev_net.c
+++ b/sys/arch/mvme88k/stand/netboot/dev_net.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dev_net.c,v 1.5 2013/01/16 20:45:09 miod Exp $ */
+/* $OpenBSD: dev_net.c,v 1.6 2013/05/12 10:43:45 miod Exp $ */
/*
* Copyright (c) 1995 Gordon W. Ross
@@ -180,24 +180,3 @@ net_mountroot(f, devname)
return (error);
}
-
-/*
- * machdep_common_ether: get ethernet address
- */
-void
-machdep_common_ether(ether)
- u_char *ether;
-{
- u_char *ea;
-
- ea = (u_char *) ETHER_ADDR_16X;
-
- if (ea[0] + ea[1] + ea[2] + ea[3] + ea[4] + ea[5] == 0)
- panic("ERROR: ethernet address not set!");
- ether[0] = ea[0];
- ether[1] = ea[1];
- ether[2] = ea[2];
- ether[3] = ea[3];
- ether[4] = ea[4];
- ether[5] = ea[5];
-}
diff --git a/sys/arch/mvme88k/stand/netboot/devices.c b/sys/arch/mvme88k/stand/netboot/devices.c
new file mode 100644
index 00000000000..3646c7405ec
--- /dev/null
+++ b/sys/arch/mvme88k/stand/netboot/devices.c
@@ -0,0 +1,99 @@
+/* $OpenBSD: devices.c,v 1.1 2013/05/12 10:43:45 miod Exp $ */
+
+/*
+ * Copyright (c) 2013 Miodrag Vallat.
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <sys/param.h>
+#include <sys/types.h>
+
+#include <netinet/in.h>
+
+#include <machine/prom.h>
+
+#include "stand.h"
+#include "libsa.h"
+#include "netif.h"
+#include "config.h"
+
+#include "if_lereg.h"
+
+/*
+ * For netboot, we only intend to use the interface we have been booted from;
+ * although we carry the list of all BUG-recognized Ethernet devices for which
+ * we have drivers, we will select the appropriate instance from the BUG
+ * arguments.
+ */
+
+struct ie_configuration ie_config[] = {
+ { .clun = 0x00, .phys_addr = INTEL_REG_ADDR }
+};
+int nie_config = sizeof(ie_config) / sizeof(ie_config[0]);
+
+#define VLE(u,a) \
+ { .clun = 0x02 + (u), .phys_addr = (a), \
+ .buf_addr = VLEMEMBASE - (u) * VLEMEMSIZE, .buf_size = VLEMEMSIZE }
+struct le_configuration le_config[] = {
+ VLE(0, 0xffff1200),
+ VLE(1, 0xffff1400),
+ VLE(2, 0xffff1600),
+ VLE(3, 0xffff5400),
+ VLE(4, 0xffff5600),
+ VLE(5, 0xffffa400)
+};
+
+int nle_config = sizeof(le_config) / sizeof(le_config[0]);
+
+extern struct netif_driver le_driver;
+extern struct netif_driver ie_driver;
+
+struct netif_driver *netif_drivers[] = {
+ &ie_driver,
+ &le_driver,
+};
+int n_netif_drivers = sizeof(netif_drivers) / sizeof(netif_drivers[0]);
+
+static struct netif_stats bugif_stats;
+static struct netif_dif bugif_dif = {
+ .dif_unit = 0,
+ .dif_nsel = 1,
+ .dif_stats = &bugif_stats
+};
+
+int
+probe_ethernet()
+{
+ int n;
+
+ for (n = 0; n < nie_config; n++)
+ if (ie_config[n].clun == bugargs.ctrl_lun) {
+ bcopy(mvmeprom_brdid()->etheraddr,
+ ie_config[n].eaddr, 6);
+ ie_driver.netif_nifs = 1;
+ ie_driver.netif_ifs = &bugif_dif;
+ break;
+ }
+
+ for (n = 0; n < nle_config; n++)
+ if (le_config[n].clun == bugargs.ctrl_lun) {
+ le_read_etheraddr(le_config[n].phys_addr,
+ le_config[n].eaddr);
+ le_driver.netif_nifs = 1;
+ le_driver.netif_ifs = &bugif_dif;
+ break;
+ }
+
+ return ie_driver.netif_nifs + le_driver.netif_nifs;
+}
diff --git a/sys/arch/mvme88k/stand/netboot/if_ie.c b/sys/arch/mvme88k/stand/netboot/if_ie.c
index 5c2c89fa2a2..da7685952fd 100644
--- a/sys/arch/mvme88k/stand/netboot/if_ie.c
+++ b/sys/arch/mvme88k/stand/netboot/if_ie.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_ie.c,v 1.9 2009/01/18 21:49:11 miod Exp $ */
+/* $OpenBSD: if_ie.c,v 1.10 2013/05/12 10:43:45 miod Exp $ */
/*
* Copyright (c) 1995 Theo de Raadt
@@ -48,13 +48,11 @@
#include "net.h"
#include "i82586.h"
-#include "if_iereg.h"
int ie_debug = 0;
void ie_stop(struct netif *);
void ie_end(struct netif *);
-void ie_error(struct netif *, char *, volatile struct iereg *);
int ie_get(struct iodesc *, void *, size_t, time_t);
void ie_init(struct iodesc *, void *);
int ie_match(struct netif *, void *);
@@ -62,17 +60,6 @@ int ie_poll(struct iodesc *, void *, int);
int ie_probe(struct netif *, void *);
int ie_put(struct iodesc *, void *, size_t);
void ie_reset(struct netif *, u_char *);
-extern void machdep_common_ether(u_char *);
-
-struct netif_stats ie_stats;
-
-struct netif_dif ie0_dif = {
- 0, /* unit */
- 1, /* nsel */
- &ie_stats,
- 0,
- 0,
-};
struct netif_driver ie_driver = {
"ie", /* netif_bname */
@@ -82,74 +69,41 @@ struct netif_driver ie_driver = {
ie_get, /* get */
ie_put, /* put */
ie_end, /* end */
- &ie0_dif, /* netif_ifs */
- 1, /* netif_nifs */
-};
-
-struct ie_configuration {
- u_int phys_addr;
- int used;
-} ie_config[] = {
- { INTEL_REG_ADDR, 0 }
+ NULL, /* netif_ifs - will be filled later */
+ 0, /* netif_nifs - will be filled later */
};
-int nie_config = sizeof(ie_config) / (sizeof(ie_config[0]));
-
struct {
struct iereg *sc_reg; /* IE registers */
struct iemem *sc_mem; /* RAM */
-} ie_softc;
+} ie_softc;
int
-ie_match(nif, machdep_hint)
- struct netif *nif;
- void *machdep_hint;
+ie_match(struct netif *nif, void *machdep_hint)
{
- char *name;
- int i, val = 0;
-
- name = machdep_hint;
- if (name && !bcmp(ie_driver.netif_bname, name, 2))
- val += 10;
- for (i = 0; i < nie_config; i++) {
- if (ie_config[i].used)
- continue;
- if (ie_debug)
- printf("ie%d: ie_match --> %d\n", i, val + 1);
- ie_config[i].used++;
- return (val + 1);
+ const char *name = machdep_hint;
+
+ if (name == NULL) {
+ if (ie_config[nif->nif_unit].clun == bugargs.ctrl_lun)
+ return 1;
+ } else {
+ if (bcmp(ie_driver.netif_bname, name, 2) == 0) {
+ if (nif->nif_unit == name[2] - '0')
+ return 1;
+ }
}
- if (ie_debug)
- printf("ie%d: ie_match --> 0\n", i);
- return (0);
-}
-
-int
-ie_probe(nif, machdep_hint)
- struct netif *nif;
- void *machdep_hint;
-{
- /* the set unit is the current unit */
- if (ie_debug)
- printf("ie%d: ie_probe called\n", nif->nif_unit);
- return (0);
-/* return (1);*/
+ return 0;
}
-void
-ie_error(nif, str, ier)
- struct netif *nif;
- char *str;
- volatile struct iereg *ier;
+int
+ie_probe(struct netif *nif, void *machdep_hint)
{
- panic("ie%d: unknown error", nif->nif_unit);
+ return 0;
}
void
-ieack(ier, iem)
- volatile struct iereg *ier;
- struct iemem *iem;
+ieack(volatile struct iereg *ier, struct iemem *iem)
{
/* ack the `interrupt' */
iem->im_scb.ie_command = iem->im_scb.ie_status & IE_ST_WHENCE;
@@ -159,9 +113,7 @@ ieack(ier, iem)
}
void
-ie_reset(nif, myea)
- struct netif *nif;
- u_char *myea;
+ie_reset(struct netif *nif, u_char *myea)
{
volatile struct iereg *ier = ie_softc.sc_reg;
struct iemem *iem = ie_softc.sc_mem;
@@ -286,10 +238,7 @@ ie_reset(nif, myea)
}
int
-ie_poll(desc, pkt, len)
- struct iodesc *desc;
- void *pkt;
- int len;
+ie_poll(struct iodesc *desc, void *pkt, int len)
{
volatile struct iereg *ier = ie_softc.sc_reg;
struct iemem *iem = ie_softc.sc_mem;
@@ -302,7 +251,8 @@ ie_poll(desc, pkt, len)
return (0);
/* printf("slot %d: %x\n", slot, status); */
- if ((status & (IE_FD_COMPLETE | IE_FD_OK)) == (IE_FD_COMPLETE | IE_FD_OK)) {
+ if ((status & (IE_FD_COMPLETE | IE_FD_OK)) ==
+ (IE_FD_COMPLETE | IE_FD_OK)) {
if (status & IE_FD_OK) {
length = iem->im_rbd[slot].ie_rbd_actual & 0x3fff;
if (length > len)
@@ -351,10 +301,7 @@ ie_poll(desc, pkt, len)
}
int
-ie_put(desc, pkt, len)
- struct iodesc *desc;
- void *pkt;
- size_t len;
+ie_put(struct iodesc *desc, void *pkt, size_t len)
{
volatile struct iereg *ier = ie_softc.sc_reg;
struct iemem *iem = ie_softc.sc_mem;
@@ -406,11 +353,7 @@ ie_put(desc, pkt, len)
}
int
-ie_get(desc, pkt, len, timeout)
- struct iodesc *desc;
- void *pkt;
- size_t len;
- time_t timeout;
+ie_get(struct iodesc *desc, void *pkt, size_t len, time_t timeout)
{
time_t t;
int cc;
@@ -426,28 +369,29 @@ ie_get(desc, pkt, len, timeout)
* init ie device. return 0 on failure, 1 if ok.
*/
void
-ie_init(desc, machdep_hint)
- struct iodesc *desc;
- void *machdep_hint;
+ie_init(struct iodesc *desc, void *machdep_hint)
{
struct netif *nif = desc->io_netif;
if (ie_debug)
- printf("ie%d: ie_init called\n", desc->io_netif->nif_unit);
- machdep_common_ether(desc->myea);
+ printf("ie%d: ie_init called\n", nif->nif_unit);
+ bcopy(ie_config[nif->nif_unit].eaddr, desc->myea, 6);
bzero(&ie_softc, sizeof(ie_softc));
- ie_softc.sc_reg =
- (struct iereg *) ie_config[desc->io_netif->nif_unit].phys_addr;
+ ie_softc.sc_reg = (struct iereg *) ie_config[nif->nif_unit].phys_addr;
/* use 64KB below HEAP as buffers */
ie_softc.sc_mem = (struct iemem *)(HEAP_START - 0x10000);
- ie_reset(desc->io_netif, desc->myea);
+ ie_reset(nif, desc->myea);
+#if 0
printf("device: %s%d attached to %s\n", nif->nif_driver->netif_bname,
nif->nif_unit, ether_sprintf(desc->myea));
+#endif
+ bugargs.ctrl_lun = ie_config[nif->nif_unit].clun;
+ bugargs.dev_lun = 0;
+ bugargs.ctrl_addr = ie_config[nif->nif_unit].phys_addr;
}
void
-ie_stop(nif)
- struct netif *nif;
+ie_stop(struct netif *nif)
{
volatile struct iereg *ier = ie_softc.sc_reg;
struct iemem *iem = ie_softc.sc_mem;
@@ -479,13 +423,10 @@ ie_stop(nif)
}
void
-ie_end(nif)
- struct netif *nif;
+ie_end(struct netif *nif)
{
if (ie_debug)
printf("ie%d: ie_end called\n", nif->nif_unit);
ie_stop(nif);
-
- /* *(u_char *) 0xfff42002 = 0; */
}
diff --git a/sys/arch/mvme88k/stand/netboot/if_iereg.h b/sys/arch/mvme88k/stand/netboot/if_iereg.h
deleted file mode 100644
index 35a1f5d4f5a..00000000000
--- a/sys/arch/mvme88k/stand/netboot/if_iereg.h
+++ /dev/null
@@ -1,163 +0,0 @@
-/* $OpenBSD: if_iereg.h,v 1.2 1998/08/22 08:38:01 smurph Exp $ */
-
-/*
- * if_sunie.h
- *
- * sun's ie interface
- */
-
-/*
- * programming notes:
- *
- * the ie chip operates in a 24 bit address space.
- *
- * most ie interfaces appear to be divided into two parts:
- * - generic 586 stuff
- * - board specific
- *
- * generic:
- * the generic stuff of the ie chip is all done with data structures
- * that live in the chip's memory address space. the chip expects
- * its main data structure (the sys conf ptr -- SCP) to be at a fixed
- * address in its 24 bit space: 0xfffff4
- *
- * the SCP points to another structure called the ISCP.
- * the ISCP points to another structure called the SCB.
- * the SCB has a status field, a linked list of "commands", and
- * a linked list of "receive buffers". these are data structures that
- * live in memory, not registers.
- *
- * board:
- * to get the chip to do anything, you first put a command in the
- * command data structure list. then you have to signal "attention"
- * to the chip to get it to look at the command. how you
- * signal attention depends on what board you have... on PC's
- * there is an i/o port number to do this, on sun's there is a
- * register bit you toggle.
- *
- * to get data from the chip you program it to interrupt...
- *
- *
- * sun issues:
- *
- * there are 3 kinds of sun "ie" interfaces:
- * 1 - a VME/multibus card
- * 2 - an on-board interface (sun3's, sun-4/100's, and sun-4/200's)
- * 3 - another VME board called the 3E
- *
- * the VME boards lives in vme16 space. only 16 and 8 bit accesses
- * are allowed, so functions that copy data must be aware of this.
- *
- * the chip is an intel chip. this means that the byte order
- * on all the "short"s in the chip's data structures is wrong.
- * so, constants described in the intel docs are swapped for the sun.
- * that means that any buffer pointers you give the chip must be
- * swapped to intel format. yuck.
- *
- * VME/multibus interface:
- * for the multibus interface the board ignores the top 4 bits
- * of the chip address. the multibus interface seems to have its
- * own MMU like page map (without protections or valid bits, etc).
- * there are 256 pages of physical memory on the board (each page
- * is 1024 bytes). there are 1024 slots in the page map. so,
- * a 1024 byte page takes up 10 bits of address for the offset,
- * and if there are 1024 slots in the page that is another 10 bits
- * of the address. that makes a 20 bit address, and as stated
- * earlier the board ignores the top 4 bits, so that accounts
- * for all 24 bits of address.
- *
- * note that the last entry of the page map maps the top of the
- * 24 bit address space and that the SCP is supposed to be at
- * 0xfffff4 (taking into account allignment). so,
- * for multibus, that entry in the page map has to be used for the SCP.
- *
- * the page map effects BOTH how the ie chip sees the
- * memory, and how the host sees it.
- *
- * the page map is part of the "register" area of the board
- *
- * on-board interface:
- *
- * <fill in useful info later>
- *
- *
- * VME3E interface:
- *
- * <fill in useful info later>
- *
- */
-
-/*
- * PART 1: VME/multibus defs
- */
-#define IEVME_PAGESIZE 1024 /* bytes */
-#define IEVME_PAGSHIFT 10 /* bits */
-#define IEVME_NPAGES 256 /* number of pages on chip */
-#define IEVME_MAPSZ 1024 /* number of entries in the map */
-
-/*
- * PTE for the page map
- */
-#define IEVME_SBORDR 0x8000 /* sun byte order */
-#define IEVME_IBORDR 0x0000 /* intel byte ordr */
-
-#define IEVME_P2MEM 0x2000 /* memory is on P2 */
-#define IEVME_OBMEM 0x0000 /* memory is on board */
-
-#define IEVME_PGMASK 0x0fff /* gives the physical page frame number */
-
-struct ievme {
- u_short pgmap[IEVME_MAPSZ];
- u_short xxx[32]; /* prom */
- u_short status; /* see below for bits */
- u_short xxx2; /* filler */
- u_short pectrl; /* parity control (see below) */
- u_short peaddr; /* low 16 bits of address */
-};
-/*
- * status bits
- */
-#define IEVME_RESET 0x8000 /* reset board */
-#define IEVME_ONAIR 0x4000 /* go out of loopback 'on-air' */
-#define IEVME_ATTEN 0x2000 /* attention */
-#define IEVME_IENAB 0x1000 /* interrupt enable */
-#define IEVME_PEINT 0x0800 /* parity error interrupt enable */
-#define IEVME_PERR 0x0200 /* parity error flag */
-#define IEVME_INT 0x0100 /* interrupt flag */
-#define IEVME_P2EN 0x0020 /* enable p2 bus */
-#define IEVME_256K 0x0010 /* 256kb rams */
-#define IEVME_HADDR 0x000f /* mask for bits 17-20 of address */
-
-/*
- * parity control
- */
-#define IEVME_PARACK 0x0100 /* parity error ack */
-#define IEVME_PARSRC 0x0080 /* parity error source */
-#define IEVME_PAREND 0x0040 /* which end of the data got the error */
-#define IEVME_PARADR 0x000f /* mask to get bits 17-20 of parity address */
-
-
-/*
- * PART 2: the on-board interface
- */
-struct ieob {
- u_char obctrl;
-};
-#define IEOB_NORSET 0x80 /* don't reset the board */
-#define IEOB_ONAIR 0x40 /* put us on the air */
-#define IEOB_ATTEN 0x20 /* attention! */
-#define IEOB_IENAB 0x10 /* interrupt enable */
-#define IEOB_XXXXX 0x08 /* free bit */
-#define IEOB_XCVRL2 0x04 /* level 2 transceiver? */
-#define IEOB_BUSERR 0x02 /* bus error */
-#define IEOB_INT 0x01 /* interrupt */
-
-#define IEOB_ADBASE 0xff000000 /* KVA base addr of 24 bit address space */
-
-/*
- * PART 3: the 3E board
- */
-
-/*
- * not supported (yet?)
- */
diff --git a/sys/arch/mvme88k/stand/netboot/if_le.c b/sys/arch/mvme88k/stand/netboot/if_le.c
index c607c3bd53e..968dc4cfd15 100644
--- a/sys/arch/mvme88k/stand/netboot/if_le.c
+++ b/sys/arch/mvme88k/stand/netboot/if_le.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_le.c,v 1.7 2009/01/18 21:49:11 miod Exp $ */
+/* $OpenBSD: if_le.c,v 1.8 2013/05/12 10:43:45 miod Exp $ */
/*
* Copyright (c) 1995 Theo de Raadt
@@ -53,6 +53,36 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
+/*-
+ * Copyright (c) 1982, 1992, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)if_le.c 8.2 (Berkeley) 10/30/93
+ */
#include <sys/param.h>
#include <sys/types.h>
@@ -71,8 +101,10 @@
int le_debug = 0;
+void le_wrcsr(u_int16_t, u_int16_t);
+u_int16_t le_rdcsr(u_int16_t);
void le_end(struct netif *);
-void le_error(struct netif *, char *, volatile struct lereg1 *);
+void le_error(struct netif *, const char *, u_int16_t);
int le_get(struct iodesc *, void *, size_t, time_t);
void le_init(struct iodesc *, void *);
int le_match(struct netif *, void *);
@@ -81,16 +113,6 @@ int le_probe(struct netif *, void *);
int le_put(struct iodesc *, void *, size_t);
void le_reset(struct netif *, u_char *);
-struct netif_stats le_stats;
-
-struct netif_dif le0_dif = {
- 0, /* unit */
- 1, /* nsel */
- &le_stats,
- 0,
- 0,
-};
-
struct netif_driver le_driver = {
"le", /* netif_bname */
le_match, /* match */
@@ -99,100 +121,106 @@ struct netif_driver le_driver = {
le_get, /* get */
le_put, /* put */
le_end, /* end */
- &le0_dif, /* netif_ifs */
- 1, /* netif_nifs */
+ NULL, /* netif_ifs - will be filled later */
+ 0, /* netif_nifs - will be filled later */
};
-struct le_configuration {
- unsigned int phys_addr;
- int used;
-} le_config[] = {
- { LANCE_REG_ADDR, 0 }
-};
-
-int nle_config = sizeof(le_config) / (sizeof(le_config[0]));
-
struct {
struct lereg1 *sc_r1; /* LANCE registers */
+ struct vlereg1 *sc_vr1; /* MVME376 registers */
struct lereg2 *sc_r2; /* RAM */
int next_rmd;
int next_tmd;
-} le_softc;
+} le_softc;
int
-le_match(nif, machdep_hint)
- struct netif *nif;
- void *machdep_hint;
+le_match(struct netif *nif, void *machdep_hint)
{
- char *name;
- int i, val = 0;
-
- name = machdep_hint;
- if (name && !bcmp(le_driver.netif_bname, name, 2))
- val += 10;
- for (i = 0; i < nle_config; i++) {
- if (le_config[i].used)
- continue;
- if (le_debug)
- printf("le%d: le_match --> %d\n", i, val + 1);
- le_config[i].used++;
- return val + 1;
+ const char *name = machdep_hint;
+
+ if (name == NULL) {
+ if (le_config[nif->nif_unit].clun == bugargs.ctrl_lun)
+ return 1;
+ } else {
+ if (bcmp(le_driver.netif_bname, name, 2) == 0) {
+ if (nif->nif_unit == name[2] - '0')
+ return 1;
+ }
}
- if (le_debug)
- printf("le%d: le_match --> 0\n", i);
+
return 0;
}
int
-le_probe(nif, machdep_hint)
- struct netif *nif;
- void *machdep_hint;
+le_probe(struct netif *nif, void *machdep_hint)
{
+ return 0;
+}
- /* the set unit is the current unit */
- if (le_debug)
- printf("le%d: le_probe called\n", nif->nif_unit);
+void
+le_wrcsr(u_int16_t port, u_int16_t val)
+{
+ if (le_softc.sc_r1 != NULL) {
+ le_softc.sc_r1->ler1_rap = port;
+ le_softc.sc_r1->ler1_rdp = val;
+ } else {
+ le_softc.sc_vr1->ler1_rap = port;
+ le_softc.sc_vr1->ler1_rdp = val;
+ }
+}
- return 1;
+u_int16_t
+le_rdcsr(u_int16_t port)
+{
+ u_int16_t val;
+
+ if (le_softc.sc_r1 != NULL) {
+ le_softc.sc_r1->ler1_rap = port;
+ val = le_softc.sc_r1->ler1_rdp;
+ } else {
+ le_softc.sc_vr1->ler1_rap = port;
+ val = le_softc.sc_vr1->ler1_rdp;
+ }
+ return (val);
}
void
-le_error(nif, str, ler1)
- struct netif *nif;
- char *str;
- volatile struct lereg1 *ler1;
+le_error(struct netif *nif, const char *str, u_int16_t stat)
{
- /* ler1->ler1_rap = LE_CSRO done in caller */
- if (ler1->ler1_rdp & LE_C0_BABL)
+ struct netif_driver *drv = nif->nif_driver;
+
+ if (stat & LE_C0_BABL)
panic("le%d: been babbling, found by '%s'", nif->nif_unit, str);
- if (ler1->ler1_rdp & LE_C0_CERR) {
- le_stats.collision_error++;
- ler1->ler1_rdp = LE_C0_CERR;
+ if (stat & LE_C0_CERR) {
+ drv->netif_ifs[nif->nif_unit].dif_stats->collision_error++;
+ le_wrcsr(LE_CSR0, LE_C0_CERR);
}
- if (ler1->ler1_rdp & LE_C0_MISS) {
- le_stats.missed++;
- ler1->ler1_rdp = LE_C0_MISS;
+ if (stat & LE_C0_MISS) {
+ drv->netif_ifs[nif->nif_unit].dif_stats->missed++;
+ le_wrcsr(LE_CSR0, LE_C0_MISS);
}
- if (ler1->ler1_rdp & LE_C0_MERR) {
- printf("le%d: memory error in '%s'\n", nif->nif_unit, str);
- panic("memory error");
+ if (stat & LE_C0_MERR) {
+ panic("le%d: memory error in '%s'", nif->nif_unit, str);
}
}
void
-le_reset(nif, myea)
- struct netif *nif;
- u_char *myea;
+le_reset(struct netif *nif, u_char *myea)
{
- struct lereg1 *ler1 = le_softc.sc_r1;
struct lereg2 *ler2 = le_softc.sc_r2;
unsigned int a;
- int timo = 100000, stat, i;
+ int timo = 100000, i;
+ u_int16_t stat;
if (le_debug)
printf("le%d: le_reset called\n", nif->nif_unit);
- ler1->ler1_rap = LE_CSR0;
- ler1->ler1_rdp = LE_C0_STOP; /* do nothing until we are finished */
+
+ if (le_softc.sc_vr1 != NULL) {
+ le_softc.sc_vr1->ler1_csr = 0;
+ CDELAY;
+ le_softc.sc_vr1->ler1_csr = HW_RS | 0x0f;
+ }
+ le_wrcsr(LE_CSR0, LE_C0_STOP);
bzero(ler2, sizeof(*ler2));
@@ -204,97 +232,89 @@ le_reset(nif, myea)
ler2->ler2_padr[4] = myea[5];
ler2->ler2_padr[5] = myea[4];
-
ler2->ler2_ladrf0 = 0;
ler2->ler2_ladrf1 = 0;
- a = (u_int) ler2->ler2_rmd;
- ler2->ler2_rlen = LE_RLEN | (a >> 16);
- ler2->ler2_rdra = a & LE_ADDR_LOW_MASK;
+ a = (u_int)ler2->ler2_rmd;
+ ler2->ler2_rlen = LE_RLEN | LE_ADDR_HIGH(a);
+ ler2->ler2_rdra = LE_ADDR_LOW(a);
- a = (u_int) ler2->ler2_tmd;
- ler2->ler2_tlen = LE_TLEN | (a >> 16);
- ler2->ler2_tdra = a & LE_ADDR_LOW_MASK;
+ a = (u_int)ler2->ler2_tmd;
+ ler2->ler2_tlen = LE_TLEN | LE_ADDR_HIGH(a);
+ ler2->ler2_tdra = LE_ADDR_LOW(a);
- ler1->ler1_rap = LE_CSR1;
- a = (u_int) ler2;
- ler1->ler1_rdp = a & LE_ADDR_LOW_MASK;
- ler1->ler1_rap = LE_CSR2;
- ler1->ler1_rdp = a >> 16;
+ a = (u_int)ler2;
+ le_wrcsr(LE_CSR1, LE_ADDR_LOW(a));
+ le_wrcsr(LE_CSR2, LE_ADDR_HIGH(a));
for (i = 0; i < LERBUF; i++) {
- a = (u_int) & ler2->ler2_rbuf[i];
- ler2->ler2_rmd[i].rmd0 = a & LE_ADDR_LOW_MASK;
+ a = (u_int)&ler2->ler2_rbuf[i];
+ ler2->ler2_rmd[i].rmd0 = LE_ADDR_LOW(a);
ler2->ler2_rmd[i].rmd1_bits = LE_R1_OWN;
- ler2->ler2_rmd[i].rmd1_hadr = a >> 16;
+ ler2->ler2_rmd[i].rmd1_hadr = LE_ADDR_HIGH(a);
ler2->ler2_rmd[i].rmd2 = -LEMTU;
ler2->ler2_rmd[i].rmd3 = 0;
}
for (i = 0; i < LETBUF; i++) {
- a = (u_int) & ler2->ler2_tbuf[i];
- ler2->ler2_tmd[i].tmd0 = a & LE_ADDR_LOW_MASK;
+ a = (u_int)&ler2->ler2_tbuf[i];
+ ler2->ler2_tmd[i].tmd0 = LE_ADDR_LOW(a);
ler2->ler2_tmd[i].tmd1_bits = 0;
- ler2->ler2_tmd[i].tmd1_hadr = a >> 16;
+ ler2->ler2_tmd[i].tmd1_hadr = LE_ADDR_HIGH(a);
ler2->ler2_tmd[i].tmd2 = 0;
ler2->ler2_tmd[i].tmd3 = 0;
}
- ler1->ler1_rap = LE_CSR3;
- ler1->ler1_rdp = LE_C3_BSWP;
+ le_wrcsr(LE_CSR3, LE_C3_BSWP);
- ler1->ler1_rap = LE_CSR0;
- ler1->ler1_rdp = LE_C0_INIT;
+ le_wrcsr(LE_CSR0, LE_C0_INIT);
do {
+ stat = le_rdcsr(LE_CSR0);
if (--timo == 0) {
printf("le%d: init timeout, stat = 0x%x\n",
nif->nif_unit, stat);
break;
}
- stat = ler1->ler1_rdp;
} while ((stat & LE_C0_IDON) == 0);
- ler1->ler1_rdp = LE_C0_IDON;
+ le_wrcsr(LE_CSR0, LE_C0_IDON);
le_softc.next_rmd = 0;
le_softc.next_tmd = 0;
- ler1->ler1_rap = LE_CSR0;
- ler1->ler1_rdp = LE_C0_STRT;
+ le_wrcsr(LE_CSR0, LE_C0_STRT);
}
int
-le_poll(desc, pkt, len)
- struct iodesc *desc;
- void *pkt;
- int len;
+le_poll(struct iodesc *desc, void *pkt, int len)
{
- struct lereg1 *ler1 = le_softc.sc_r1;
+ struct netif *nif = desc->io_netif;
struct lereg2 *ler2 = le_softc.sc_r2;
unsigned int a;
int length;
struct lermd *rmd;
+ u_int16_t stat;
-
- ler1->ler1_rap = LE_CSR0;
- if ((ler1->ler1_rdp & LE_C0_RINT) != 0)
- ler1->ler1_rdp = LE_C0_RINT;
+ stat = le_rdcsr(LE_CSR0);
+ if ((stat & LE_C0_RINT) != 0)
+ le_wrcsr(LE_CSR0, LE_C0_RINT);
rmd = &ler2->ler2_rmd[le_softc.next_rmd];
if (rmd->rmd1_bits & LE_R1_OWN) {
return (0);
}
- if (ler1->ler1_rdp & LE_C0_ERR)
- le_error(desc->io_netif, "le_poll", ler1);
+ if (stat & LE_C0_ERR)
+ le_error(nif, "le_poll", stat);
if (rmd->rmd1_bits & LE_R1_ERR) {
- printf("le%d_poll: rmd status 0x%x\n", desc->io_netif->nif_unit,
- rmd->rmd1_bits);
+ printf("le%d_poll: rmd status 0x%x\n",
+ nif->nif_unit, rmd->rmd1_bits);
length = 0;
goto cleanup;
}
- if ((rmd->rmd1_bits & (LE_R1_STP | LE_R1_ENP)) != (LE_R1_STP | LE_R1_ENP))
+ if ((rmd->rmd1_bits & (LE_R1_STP | LE_R1_ENP)) !=
+ (LE_R1_STP | LE_R1_ENP))
panic("le_poll: chained packet");
length = rmd->rmd3;
if (length >= LEMTU) {
length = 0;
- panic("csr0 when bad things happen: %x", ler1->ler1_rdp);
+ panic("csr0 when bad things happen: %x", stat);
goto cleanup;
}
if (!length)
@@ -312,9 +332,9 @@ le_poll(desc, pkt, len)
bcopy((void *)&ler2->ler2_rbuf[le_softc.next_rmd], pkt, length);
}
cleanup:
- a = (u_int) & ler2->ler2_rbuf[le_softc.next_rmd];
- rmd->rmd0 = a & LE_ADDR_LOW_MASK;
- rmd->rmd1_hadr = a >> 16;
+ a = (u_int)&ler2->ler2_rbuf[le_softc.next_rmd];
+ rmd->rmd0 = LE_ADDR_LOW(a);
+ rmd->rmd1_hadr = LE_ADDR_HIGH(a);
rmd->rmd2 = -LEMTU;
le_softc.next_rmd =
(le_softc.next_rmd == (LERBUF - 1)) ? 0 : (le_softc.next_rmd + 1);
@@ -323,23 +343,22 @@ cleanup:
}
int
-le_put(desc, pkt, len)
- struct iodesc *desc;
- void *pkt;
- size_t len;
+le_put(struct iodesc *desc, void *pkt, size_t len)
{
- volatile struct lereg1 *ler1 = le_softc.sc_r1;
+ struct netif *nif = desc->io_netif;
+ struct netif_driver *drv = nif->nif_driver;
volatile struct lereg2 *ler2 = le_softc.sc_r2;
volatile struct letmd *tmd;
- int timo = 100000, stat, i;
+ int timo = 100000;
unsigned int a;
+ u_int16_t stat;
- ler1->ler1_rap = LE_CSR0;
- if (ler1->ler1_rdp & LE_C0_ERR)
- le_error(desc->io_netif, "le_put(way before xmit)", ler1);
+ stat = le_rdcsr(LE_CSR0);
+ if (stat & LE_C0_ERR)
+ le_error(nif, "le_put(way before xmit)", stat);
tmd = &ler2->ler2_tmd[le_softc.next_tmd];
while (tmd->tmd1_bits & LE_T1_OWN) {
- printf("le%d: output buffer busy\n", desc->io_netif->nif_unit);
+ printf("le%d: output buffer busy\n", nif->nif_unit);
}
bcopy(pkt, (void *)ler2->ler2_tbuf[le_softc.next_tmd], len);
if (len < 64)
@@ -347,51 +366,55 @@ le_put(desc, pkt, len)
else
tmd->tmd2 = -len;
tmd->tmd3 = 0;
- if (ler1->ler1_rdp & LE_C0_ERR)
- le_error(desc->io_netif, "le_put(before xmit)", ler1);
+ stat = le_rdcsr(LE_CSR0);
+ if (stat & LE_C0_ERR)
+ le_error(nif, "le_put(before xmit)", stat);
tmd->tmd1_bits = LE_T1_STP | LE_T1_ENP | LE_T1_OWN;
- a = (u_int) & ler2->ler2_tbuf[le_softc.next_tmd];
- tmd->tmd0 = a & LE_ADDR_LOW_MASK;
- tmd->tmd1_hadr = a >> 16;
- ler1->ler1_rdp = LE_C0_TDMD;
- if (ler1->ler1_rdp & LE_C0_ERR)
- le_error(desc->io_netif, "le_put(after xmit)", ler1);
+ a = (u_int)&ler2->ler2_tbuf[le_softc.next_tmd];
+ tmd->tmd0 = LE_ADDR_LOW(a);
+ tmd->tmd1_hadr = LE_ADDR_HIGH(a);
+ le_wrcsr(LE_CSR0, LE_C0_TDMD);
+ stat = le_rdcsr(LE_CSR0);
+ if (stat & LE_C0_ERR)
+ le_error(nif, "le_put(after xmit)", stat);
do {
+ stat = le_rdcsr(LE_CSR0);
if (--timo == 0) {
printf("le%d: transmit timeout, stat = 0x%x\n",
- desc->io_netif->nif_unit, stat);
- if (ler1->ler1_rdp & LE_C0_ERR)
- le_error(desc->io_netif, "le_put(timeout)", ler1);
+ nif->nif_unit, stat);
+ if (stat & LE_C0_ERR)
+ le_error(nif, "le_put(timeout)", stat);
break;
}
- stat = ler1->ler1_rdp;
} while ((stat & LE_C0_TINT) == 0);
- ler1->ler1_rdp = LE_C0_TINT;
- if (ler1->ler1_rdp & LE_C0_ERR) {
- if ((ler1->ler1_rdp & (LE_C0_BABL | LE_C0_CERR | LE_C0_MISS |
- LE_C0_MERR)) !=
+ le_wrcsr(LE_CSR0, LE_C0_TINT);
+ stat = le_rdcsr(LE_CSR0);
+ if (stat & LE_C0_ERR) {
+ if ((stat &
+ (LE_C0_BABL | LE_C0_CERR | LE_C0_MISS | LE_C0_MERR)) !=
LE_C0_CERR)
- printf("le_put: xmit error, buf %d\n", le_softc.next_tmd);
- le_error(desc->io_netif, "le_put(xmit error)", ler1);
+ printf("le_put: xmit error, buf %d\n",
+ le_softc.next_tmd);
+ le_error(nif, "le_put(xmit error)", stat);
}
le_softc.next_tmd = 0;
/* (le_softc.next_tmd == (LETBUF - 1)) ? 0 : le_softc.next_tmd + 1;*/
if (tmd->tmd1_bits & LE_T1_DEF)
- le_stats.deferred++;
+ drv->netif_ifs[nif->nif_unit].dif_stats->deferred++;
if (tmd->tmd1_bits & LE_T1_ONE)
- le_stats.collisions++;
+ drv->netif_ifs[nif->nif_unit].dif_stats->collisions++;
if (tmd->tmd1_bits & LE_T1_MORE)
- le_stats.collisions += 2;
+ drv->netif_ifs[nif->nif_unit].dif_stats->collisions += 2;
if (tmd->tmd1_bits & LE_T1_ERR) {
- printf("le%d: transmit error, error = 0x%x\n", desc->io_netif->nif_unit,
- tmd->tmd3);
+ printf("le%d: transmit error, error = 0x%x\n",
+ nif->nif_unit, tmd->tmd3);
return -1;
}
if (le_debug) {
printf("le%d: le_put() successful: sent %d\n",
- desc->io_netif->nif_unit, len);
+ nif->nif_unit, len);
printf("le%d: le_put(): tmd1_bits: %x tmd3: %x\n",
- desc->io_netif->nif_unit,
+ nif->nif_unit,
(unsigned int) tmd->tmd1_bits,
(unsigned int) tmd->tmd3);
}
@@ -399,11 +422,7 @@ le_put(desc, pkt, len)
}
int
-le_get(desc, pkt, len, timeout)
- struct iodesc *desc;
- void *pkt;
- size_t len;
- time_t timeout;
+le_get(struct iodesc *desc, void *pkt, size_t len, time_t timeout)
{
time_t t;
int cc;
@@ -419,32 +438,95 @@ le_get(desc, pkt, len, timeout)
* init le device. return 0 on failure, 1 if ok.
*/
void
-le_init(desc, machdep_hint)
- struct iodesc *desc;
- void *machdep_hint;
+le_init(struct iodesc *desc, void *machdep_hint)
{
struct netif *nif = desc->io_netif;
if (le_debug)
- printf("le%d: le_init called\n", desc->io_netif->nif_unit);
- machdep_common_ether(desc->myea);
+ printf("le%d: le_init called\n", nif->nif_unit);
+ bcopy(le_config[nif->nif_unit].eaddr, desc->myea, 6);
bzero(&le_softc, sizeof(le_softc));
- le_softc.sc_r1 =
- (struct lereg1 *) le_config[desc->io_netif->nif_unit].phys_addr;
- le_softc.sc_r2 = (struct lereg2 *)(HEAP_START - LEMEMSIZE);
- le_reset(desc->io_netif, desc->myea);
+ /* no on-board le on mvme88k */
+ le_softc.sc_r1 = NULL;
+ le_softc.sc_vr1 = (struct vlereg1 *)le_config[nif->nif_unit].phys_addr;
+ if (le_config[nif->nif_unit].buf_size != 0) {
+ le_softc.sc_r2 =
+ (struct lereg2 *)le_config[nif->nif_unit].buf_addr;
+ } else {
+ le_softc.sc_r2 = (struct lereg2 *)(HEAP_START - LEMEMSIZE);
+ }
+ le_reset(nif, desc->myea);
+#if 0
printf("device: %s%d attached to %s\n", nif->nif_driver->netif_bname,
nif->nif_unit, ether_sprintf(desc->myea));
+#endif
+ bugargs.ctrl_lun = le_config[nif->nif_unit].clun;
+ bugargs.dev_lun = 0;
+ bugargs.ctrl_addr = le_config[nif->nif_unit].phys_addr;
}
void
-le_end(nif)
- struct netif *nif;
+le_end(struct netif *nif)
{
- struct lereg1 *ler1 = le_softc.sc_r1;
-
if (le_debug)
printf("le%d: le_end called\n", nif->nif_unit);
- ler1->ler1_rap = LE_CSR0;
- ler1->ler1_rdp = LE_C0_STOP;
+ le_wrcsr(LE_CSR0, LE_C0_STOP);
+}
+
+void nvram_cmd(struct vlereg1 *, u_char, u_short);
+u_int16_t nvram_read(struct vlereg1 *, u_char);
+
+/* send command to the nvram controller */
+void
+nvram_cmd(struct vlereg1 *reg1, u_char cmd, u_short addr)
+{
+ int i;
+
+ for (i = 0; i < 8; i++) {
+ reg1->ler1_ear = ((cmd | (addr << 1)) >> i);
+ CDELAY;
+ }
+}
+
+/* read nvram one bit at a time */
+u_int16_t
+nvram_read(struct vlereg1 *reg1, u_char nvram_addr)
+{
+ u_short val = 0, mask = 0x04000;
+ u_int16_t wbit;
+
+ ENABLE_NVRAM(reg1->ler1_csr);
+ nvram_cmd(reg1, NVRAM_RCL, 0);
+ DISABLE_NVRAM(reg1->ler1_csr);
+ CDELAY;
+ ENABLE_NVRAM(reg1->ler1_csr);
+ nvram_cmd(reg1, NVRAM_READ, nvram_addr);
+ for (wbit = 0; wbit < 15; wbit++) {
+ if (reg1->ler1_ear & 0x01)
+ val |= mask;
+ else
+ val &= ~mask;
+ mask = mask >> 1;
+ CDELAY;
+ }
+ if (reg1->ler1_ear & 0x01)
+ val |= 0x8000;
+ else
+ val &= 0x7fff;
+ CDELAY;
+ DISABLE_NVRAM(reg1->ler1_csr);
+ return (val);
+}
+
+void
+le_read_etheraddr(u_int phys_addr, u_char *enaddr)
+{
+ struct vlereg1 *reg1 = (struct vlereg1 *)phys_addr;
+ u_int16_t ival[3];
+ int i;
+
+ for (i = 0; i < 3; i++) {
+ ival[i] = nvram_read(reg1, i);
+ }
+ memcpy(enaddr, &ival[0], 6);
}
diff --git a/sys/arch/mvme88k/stand/netboot/if_lereg.h b/sys/arch/mvme88k/stand/netboot/if_lereg.h
index a44f313d49e..c624c123e0e 100644
--- a/sys/arch/mvme88k/stand/netboot/if_lereg.h
+++ b/sys/arch/mvme88k/stand/netboot/if_lereg.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_lereg.h,v 1.5 2009/01/18 21:49:11 miod Exp $ */
+/* $OpenBSD: if_lereg.h,v 1.6 2013/05/12 10:43:45 miod Exp $ */
/*-
* Copyright (c) 1982, 1992, 1993
@@ -40,13 +40,14 @@
#define LETBUFLOG2 0
#define LE_TLEN (LETBUFLOG2 << 13)
-#define LEMEMSIZE 16384 /* memory needed to fulfill above settings */
+#define LEMEMSIZE 0x4000 /* memory needed to fulfill above settings */
/* Local Area Network Controller for Ethernet (LANCE) registers */
struct lereg1 {
- volatile u_short ler1_rdp; /* register data port */
- volatile u_short ler1_rap; /* register address port */
+ volatile u_int16_t ler1_rdp; /* data port */
+ volatile u_int16_t ler1_rap; /* address port */
};
+
/* register addresses */
#define LE_CSR0 0 /* Control and status register */
#define LE_CSR1 1 /* low address of init block */
@@ -167,5 +168,39 @@ struct lereg2 {
#define LE_T3_BITS \
"\20\20BUFF\17UFLO\16RES\15LCOL\14LCAR\13RTRY"
+#define LE_ADDR_LOW(x) ((x) & 0xffff)
+#define LE_ADDR_HIGH(x) (((x) >> 16) & 0x00ff)
+
+#define VLEMEMSIZE 0x00040000
+#define VLEMEMBASE 0xfd6c0000
+
+/*
+ * LANCE registers for MVME376
+ */
+struct vlereg1 {
+ volatile u_int16_t ler1_csr; /* board control/status register */
+ volatile u_int16_t ler1_vec; /* interrupt vector register */
+ volatile u_int16_t ler1_rdp; /* data port */
+ volatile u_int16_t ler1_rap; /* register select port */
+ volatile u_int16_t ler1_ear; /* ethernet address register */
+};
-#define LE_ADDR_LOW_MASK (0xffff)
+#define NVRAM_EN 0x0008 /* NVRAM enable bit (active low) */
+#define INTR_EN 0x0010 /* interrupt enable bit (active low) */
+#define PARITYB 0x0020 /* parity error clear bit */
+#define HW_RS 0x0040 /* hardware reset bit (active low) */
+#define SYSFAILB 0x0080 /* SYSFAIL bit */
+
+#define NVRAM_RWEL 0xe0 /* Reset write enable latch */
+#define NVRAM_STO 0x60 /* Store ram to eeprom */
+#define NVRAM_SLP 0xa0 /* Novram into low power mode */
+#define NVRAM_WRITE 0x20 /* Writes word from location x */
+#define NVRAM_SWEL 0xc0 /* Set write enable latch */
+#define NVRAM_RCL 0x40 /* Recall eeprom data into ram */
+#define NVRAM_READ 0x00 /* Reads word from location x */
+
+#define CDELAY mvmeprom_delay(10)
+#define ENABLE_NVRAM(csr) (csr) = (HW_RS | 0x0f) & ~(NVRAM_EN)
+#define DISABLE_NVRAM(csr) (csr) = (HW_RS | 0x0f) | (NVRAM_EN)
+
+void le_read_etheraddr(u_int, u_char *);
diff --git a/sys/arch/mvme88k/stand/netboot/netif.c b/sys/arch/mvme88k/stand/netboot/netif.c
new file mode 100644
index 00000000000..f53aacae987
--- /dev/null
+++ b/sys/arch/mvme88k/stand/netboot/netif.c
@@ -0,0 +1,299 @@
+/* $OpenBSD: netif.c,v 1.1 2013/05/12 10:43:45 miod Exp $ */
+/* $NetBSD: netif.c,v 1.7 1996/10/13 02:29:03 christos Exp $ */
+
+/*
+ * This is a copy of sys/lib/libsa/netif.c, with the `used' and `sel'
+ * gets-in-the-way-of-getting-things-done logic removed, and nif_select()
+ * returning an error instead of panicing if it can't find a proper
+ * interface.
+ */
+
+/*
+ * Copyright (c) 1993 Adam Glass
+ * 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 Adam Glass.
+ * 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 Adam Glass ``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.
+ */
+
+#include <sys/param.h>
+#include <sys/types.h>
+#include <sys/mount.h>
+
+#include <netinet/in.h>
+#include <netinet/in_systm.h>
+
+#include "stand.h"
+#include "net.h"
+#include "netif.h"
+
+struct iodesc sockets[SOPEN_MAX];
+#ifdef NETIF_DEBUG
+int netif_debug = 0;
+#endif
+
+/*
+ * netif_init:
+ *
+ * initialize the generic network interface layer
+ */
+
+void
+netif_init(void)
+{
+#ifdef NETIF_DEBUG
+ if (netif_debug)
+ printf("netif_init: called\n");
+#endif
+}
+
+static int
+netif_match(struct netif *nif, void *machdep_hint)
+{
+ struct netif_driver *drv = nif->nif_driver;
+
+#if 0
+ if (netif_debug)
+ printf("%s%d: netif_match\n", drv->netif_bname, nif->nif_unit);
+#endif
+ return drv->netif_match(nif, machdep_hint);
+}
+
+struct netif *
+netif_select(void *machdep_hint)
+{
+ int d, u, unit_done;
+ struct netif_driver *drv;
+ struct netif cur_if;
+ static struct netif best_if;
+ int best_val;
+ int val;
+
+ best_val = 0;
+ best_if.nif_driver = NULL;
+
+#ifdef NETIF_DEBUG
+ if (netif_debug)
+ printf("netif_select: %d interfaces\n", n_netif_drivers);
+#endif
+
+ for (d = 0; d < n_netif_drivers; d++) {
+ cur_if.nif_driver = netif_drivers[d];
+ drv = cur_if.nif_driver;
+
+ for (u = 0; u < drv->netif_nifs; u++) {
+ cur_if.nif_unit = u;
+ unit_done = 0;
+
+#ifdef NETIF_DEBUG
+ if (netif_debug)
+ printf("\t%s%d:", drv->netif_bname,
+ cur_if.nif_unit);
+#endif
+
+ val = netif_match(&cur_if, machdep_hint);
+#ifdef NETIF_DEBUG
+ if (netif_debug)
+ printf(" %d\n", val);
+#endif
+ if (val > best_val) {
+ best_val = val;
+ best_if = cur_if;
+ }
+ }
+ }
+
+ if (best_if.nif_driver == NULL)
+ return NULL;
+
+#ifdef NETIF_DEBUG
+ if (netif_debug)
+ printf("netif_select: %s%d wins\n",
+ best_if.nif_driver->netif_bname,
+ best_if.nif_unit);
+#endif
+ return &best_if;
+}
+
+int
+netif_probe(struct netif *nif, void *machdep_hint)
+{
+ struct netif_driver *drv = nif->nif_driver;
+
+#ifdef NETIF_DEBUG
+ if (netif_debug)
+ printf("%s%d: netif_probe\n", drv->netif_bname, nif->nif_unit);
+#endif
+ return drv->netif_probe(nif, machdep_hint);
+}
+
+void
+netif_attach(struct netif *nif, struct iodesc *desc, void *machdep_hint)
+{
+ struct netif_driver *drv = nif->nif_driver;
+
+#ifdef NETIF_DEBUG
+ if (netif_debug)
+ printf("%s%d: netif_attach\n", drv->netif_bname, nif->nif_unit);
+#endif
+ desc->io_netif = nif;
+#ifdef PARANOID
+ if (drv->netif_init == NULL)
+ panic("%s%d: no netif_init support", drv->netif_bname,
+ nif->nif_unit);
+#endif
+ drv->netif_init(desc, machdep_hint);
+ bzero(drv->netif_ifs[nif->nif_unit].dif_stats,
+ sizeof(struct netif_stats));
+}
+
+void
+netif_detach(struct netif *nif)
+{
+ struct netif_driver *drv = nif->nif_driver;
+
+#ifdef NETIF_DEBUG
+ if (netif_debug)
+ printf("%s%d: netif_detach\n", drv->netif_bname, nif->nif_unit);
+#endif
+#ifdef PARANOID
+ if (drv->netif_end == NULL)
+ panic("%s%d: no netif_end support", drv->netif_bname,
+ nif->nif_unit);
+#endif
+ drv->netif_end(nif);
+}
+
+ssize_t
+netif_get(struct iodesc *desc, void *pkt, size_t len, time_t timo)
+{
+#ifdef NETIF_DEBUG
+ struct netif *nif = desc->io_netif;
+#endif
+ struct netif_driver *drv = desc->io_netif->nif_driver;
+ ssize_t rv;
+
+#ifdef NETIF_DEBUG
+ if (netif_debug)
+ printf("%s%d: netif_get\n", drv->netif_bname, nif->nif_unit);
+#endif
+#ifdef PARANOID
+ if (drv->netif_get == NULL)
+ panic("%s%d: no netif_get support", drv->netif_bname,
+ nif->nif_unit);
+#endif
+ rv = drv->netif_get(desc, pkt, len, timo);
+#ifdef NETIF_DEBUG
+ if (netif_debug)
+ printf("%s%d: netif_get returning %d\n", drv->netif_bname,
+ nif->nif_unit, rv);
+#endif
+ return rv;
+}
+
+ssize_t
+netif_put(struct iodesc *desc, void *pkt, size_t len)
+{
+#ifdef NETIF_DEBUG
+ struct netif *nif = desc->io_netif;
+#endif
+ struct netif_driver *drv = desc->io_netif->nif_driver;
+ ssize_t rv;
+
+#ifdef NETIF_DEBUG
+ if (netif_debug)
+ printf("%s%d: netif_put\n", drv->netif_bname, nif->nif_unit);
+#endif
+#ifdef PARANOID
+ if (drv->netif_put == NULL)
+ panic("%s%d: no netif_put support", drv->netif_bname,
+ nif->nif_unit);
+#endif
+ rv = drv->netif_put(desc, pkt, len);
+#ifdef NETIF_DEBUG
+ if (netif_debug)
+ printf("%s%d: netif_put returning %d\n", drv->netif_bname,
+ nif->nif_unit, rv);
+#endif
+ return rv;
+}
+
+struct iodesc *
+socktodesc(sock)
+ int sock;
+{
+ if (sock >= SOPEN_MAX) {
+ errno = EBADF;
+ return (NULL);
+ }
+ return (&sockets[sock]);
+}
+
+int
+netif_open(void *machdep_hint)
+{
+ int fd;
+ struct iodesc *s;
+ struct netif *nif;
+
+ /* find a free socket */
+ for (fd = 0, s = sockets; fd < SOPEN_MAX; fd++, s++)
+ if (s->io_netif == (struct netif *)0)
+ goto fnd;
+ errno = EMFILE;
+ return (-1);
+
+fnd:
+ bzero(s, sizeof(*s));
+ netif_init();
+ nif = netif_select(machdep_hint);
+ if (!nif) {
+ errno = ENXIO;
+ return (-1);
+ }
+ if (netif_probe(nif, machdep_hint)) {
+ printf("netboot: couldn't probe %s%d\n",
+ nif->nif_driver->netif_bname, nif->nif_unit);
+ errno = EINVAL;
+ return(-1);
+ }
+ netif_attach(nif, s, machdep_hint);
+
+ return(fd);
+}
+
+int
+netif_close(int sock)
+{
+ if (sock >= SOPEN_MAX) {
+ errno = EBADF;
+ return(-1);
+ }
+ netif_detach(sockets[sock].io_netif);
+ sockets[sock].io_netif = (struct netif *)0;
+
+ return(0);
+}
diff --git a/sys/arch/mvme88k/stand/netboot/version.c b/sys/arch/mvme88k/stand/netboot/version.c
index 809a222880a..329ae45af81 100644
--- a/sys/arch/mvme88k/stand/netboot/version.c
+++ b/sys/arch/mvme88k/stand/netboot/version.c
@@ -1,6 +1,7 @@
-/* $OpenBSD: version.c,v 1.9 2013/01/05 11:20:56 miod Exp $ */
+/* $OpenBSD: version.c,v 1.10 2013/05/12 10:43:45 miod Exp $ */
/*
+ * 1.10 MVME376 support
* 1.9 ELF toolchain
* 1.8 compiled with gcc 3.3.5
* 1.7 allocation area changed to fix netboot buffers overwriting stack
@@ -9,4 +10,4 @@
* 1.4 kernel loaded with loadfile, a.out and ELF formats
* 1.3 rewritten startup code and general cleanup
*/
-const char *version = "1.9";
+const char *version = "1.10";
diff --git a/sys/arch/mvme88k/stand/sboot/Makefile b/sys/arch/mvme88k/stand/sboot/Makefile
index 3ffbce8d6e7..466ced86e6a 100644
--- a/sys/arch/mvme88k/stand/sboot/Makefile
+++ b/sys/arch/mvme88k/stand/sboot/Makefile
@@ -1,42 +1,43 @@
-# $OpenBSD: Makefile,v 1.7 2012/12/01 21:08:50 miod Exp $
+# $OpenBSD: Makefile,v 1.8 2013/05/12 10:43:45 miod Exp $
S= ${.CURDIR}/../../../..
-INCL?= -I${.CURDIR} -I${.CURDIR}/../libsa -I${S}/lib/libsa -I${S}
-COPTS?= ${DEFS} ${INCL}
+DEFS= -DSUN_BOOTPARAMS -D_STANDALONE
+INCPATH=-I${.CURDIR} -I${.CURDIR}/../libsa -I${.CURDIR}/../libbug \
+ -I${S} -I${S}/lib/libsa -I${.CURDIR}/../netboot
+CFLAGS+=${DEFS} ${INCPATH} ${COPTS}
+.include "${S}/arch/mvme88k/stand/bugcrt/Makefile.inc"
+.include "${S}/arch/mvme88k/stand/libbug/Makefile.inc"
.include "${S}/arch/mvme88k/stand/libsa/Makefile.inc"
+.include "${S}/arch/mvme88k/stand/libz/Makefile.inc"
-SRCS= sboot.c clock.c etherfun.c if_le.c
+OBJCOPY?= objcopy
-OBJS= ${SRCS:S/.c/.o/g}
-CLEANFILES+=XBUG.o XSRT0.o oc_cksum.o sboot.tmp rboot.tmp srec sboot rboot
-MDEC_DIR?=/usr/mdec
-NOPIE=
+SRCS= sboot.c devices.c devopen.c version.c
-all: sboot rboot
+.PATH: ${S}/arch/mvme88k/stand/netboot
-sboot.tmp: XSRT0.o oc_cksum.o ${OBJS} ${LIBSA}
- ld -N -s -static -T 0x4000 XSRT0.o ${OBJS} oc_cksum.o \
- -o sboot.tmp ${LIBSA} # `cc -print-libgcc-file-name`
+SRCS+= conf.c dev_net.c netif.c
+SRCS+= if_ie.c
+SRCS+= if_le.c
-rboot.tmp: XBUG.o XSRT0.o oc_cksum.o ${OBJS} ${LIBSA}
- ld -N -s -static -Ttext 0xffa00000 -Tdata 0x4000 \
- XBUG.o XSRT0.o ${OBJS} oc_cksum.o -o rboot.tmp ${LIBSA} \
- # `cc -print-libgcc-file-name`
+OBJS= ${SRCS:S/.c/.o/g}
+LIBS= ${LIBSA} ${LIBBUG} ${LIBZ}
+LDFLAGS= -N -T ${S}/arch/mvme88k/stand/ld.script -Ttext ${STAGE1_RELOC}
+LDFLAGS+= -warn-common
+NOPIE=
-srec: srec.c
- ${CC} ${.CURDIR}/srec.c -o srec
+CLEANFILES+=sboot.tmp sboot
-sboot: sboot.tmp srec
- dd ibs=32 skip=1 if=sboot.tmp | ${.OBJDIR}/srec 4 0x4000 sboot > sboot
+all: sboot
-rboot: rboot.tmp srec
- dd ibs=32 skip=1 if=rboot.tmp | ${.OBJDIR}/srec 4 0x4000 rboot > rboot
+sboot: ${SREC_CRT} ${OBJS} ${LIBS}
+ ${LD} ${LDFLAGS} -Ttext ${STAGE1_RELOC} ${SREC_CRT} ${OBJS} -o $@.tmp \
+ ${LIBS} `${CC} -print-libgcc-file-name`
+ ${OBJCOPY} -S -O srec $@.tmp $@
install:
${INSTALL} ${INSTALL_COPY} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
sboot ${DESTDIR}${MDEC_DIR}/sboot
- ${INSTALL} ${INSTALL_COPY} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
- rboot ${DESTDIR}${MDEC_DIR}/rboot
.include <bsd.prog.mk>
diff --git a/sys/arch/mvme88k/stand/sboot/TODO b/sys/arch/mvme88k/stand/sboot/TODO
deleted file mode 100644
index e2a21dbc37c..00000000000
--- a/sys/arch/mvme88k/stand/sboot/TODO
+++ /dev/null
@@ -1,3 +0,0 @@
-This needs some work. It is still the mvme68k code.
-Anybody want to jump in? S-records are cool because
-one could boot from a terminal session. SLOW though.
diff --git a/sys/arch/mvme88k/stand/sboot/XBUG.S b/sys/arch/mvme88k/stand/sboot/XBUG.S
deleted file mode 100644
index 2ddf3454eea..00000000000
--- a/sys/arch/mvme88k/stand/sboot/XBUG.S
+++ /dev/null
@@ -1,69 +0,0 @@
-/* $OpenBSD: XBUG.S,v 1.5 2006/05/16 22:52:26 miod Exp $ */
-
-/*
- * 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.
- *
- * 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.
- */
-
-/*
- * Theo says: I wrote a bootrom for the MVME147 *years* ago. To write
- * this ROM I copied a few chunks from the old bootrom, like this piece:
- *
- * "watch this, the moto bastard struck here, shouldn't have hired people
- * from intel I tried to tell them...
- * "BOOT"
- * offset from baseaddr to entry point.
- * offset from baseaddr to first word after checksum
- * garbage
- * checksum made with CS command
- * No need to change any of this unless you try to take our names out
- * of there. Ie. don't touch."
- */
-
- .text
-bootlabel: .ascii "BOOT"
- .long bootstart-0xffa00000 | for rom install
- .long bootlabelend - bootlabel
- .asciz "VME147 rboot Copyright (c) 1995 Theo de Raadt"
- .align 2
-bootstart: jmp bssclr
- .word 0x229c | XXX bitching cksum!
-bootlabelend:
- .word 0
-
- | clear bss and the kernel location
-bssclr: movl #_edata,a0
- movl #_end - _edata,d0
-1: clrb a0@+
- subql #1,d0
- bpl 1b
-
- | rip the data segment from ROM into ram..
- movl #_etext,a2 | start of data
- movl #0x4000,a1 | shovel address
- movl #_edata - _etext,d0
-1: movb a2@+,a1@+
- subql #1,d0
- bpl 1b
-
- bra start
diff --git a/sys/arch/mvme88k/stand/sboot/XSRT0.S b/sys/arch/mvme88k/stand/sboot/XSRT0.S
deleted file mode 100644
index 589235811cd..00000000000
--- a/sys/arch/mvme88k/stand/sboot/XSRT0.S
+++ /dev/null
@@ -1,67 +0,0 @@
-/* $OpenBSD: XSRT0.S,v 1.4 2006/05/16 22:52:26 miod Exp $ */
-
-/*
- * 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.
- *
- * 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 Charles D. Cranor
- * 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 Charles D. Cranor.
- * 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.
- */
-
- | start at 0x4000, load at 0xa000, stack at 0x9ff0.
- .text
- .globl start
-start: movb #0,_reboot
- jra Ldoit
-restart: movb #1,_reboot | fall through
-
-Ldoit: movl #0x00006ff0,sp
- jsr _main
-
- .globl ___main
-___main: rts
diff --git a/sys/arch/mvme88k/stand/sboot/clock.c b/sys/arch/mvme88k/stand/sboot/clock.c
deleted file mode 100644
index 180a7c746db..00000000000
--- a/sys/arch/mvme88k/stand/sboot/clock.c
+++ /dev/null
@@ -1,118 +0,0 @@
-/* $OpenBSD: clock.c,v 1.5 2012/12/05 23:20:14 deraadt Exp $ */
-
-/*
- * Copyright (c) 1992, 1993
- * The Regents of the University of California. All rights reserved.
- * Copyright (c) 1994 Gordon W. Ross
- * Copyright (c) 1993 Adam Glass
- *
- * 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. 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.
- *
- * @(#)clock.c 8.1 (Berkeley) 6/11/93
- */
-
-/*
- * Clock driver.
- */
-
-#include <sys/types.h>
-#include "sboot.h"
-#include "clockreg.h"
-
-static struct clockreg *clockreg = (struct clockreg *) CLOCK_ADDR;
-
-/*
- * 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);
-}
-
-/*
- * Set up the system's time, given a `reasonable' time value.
- */
-u_long
-time()
-{
- register struct clockreg *cl = clockreg;
- int sec, min, hour, day, mon, year;
-
- 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));
-}
diff --git a/sys/arch/mvme88k/stand/sboot/clockreg.h b/sys/arch/mvme88k/stand/sboot/clockreg.h
deleted file mode 100644
index 78f7954215d..00000000000
--- a/sys/arch/mvme88k/stand/sboot/clockreg.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/* $OpenBSD: clockreg.h,v 1.3 2003/06/02 23:27:53 millert 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. 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
diff --git a/sys/arch/mvme88k/stand/sboot/devices.c b/sys/arch/mvme88k/stand/sboot/devices.c
new file mode 100644
index 00000000000..9b0cd1364db
--- /dev/null
+++ b/sys/arch/mvme88k/stand/sboot/devices.c
@@ -0,0 +1,160 @@
+/* $OpenBSD: devices.c,v 1.1 2013/05/12 10:43:45 miod Exp $ */
+
+/*
+ * Copyright (c) 2013 Miodrag Vallat.
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <sys/param.h>
+#include <sys/types.h>
+
+#include <netinet/in.h>
+#include <netinet/in_systm.h>
+
+#include <machine/prom.h>
+
+#include "stand.h"
+#include "libsa.h"
+#include "net.h"
+#include "netif.h"
+#include "config.h"
+
+#include "if_lereg.h"
+
+/*
+ * For sboot, we can't assume anything about BUG network support, and
+ * need to build the list of available devices ourselves.
+ */
+
+static uint32_t vle_addr[] = {
+ 0xffff1200,
+ 0xffff1400,
+ 0xffff1600,
+ 0xffff5400,
+ 0xffff5600,
+ 0xffffa400
+};
+
+struct ie_configuration ie_config[1];
+int nie_config;
+
+struct le_configuration le_config[0 + sizeof(vle_addr) / sizeof(vle_addr[0])];
+int nle_config;
+
+extern struct netif_driver le_driver;
+extern struct netif_driver ie_driver;
+
+struct netif_driver *netif_drivers[] = {
+ &ie_driver,
+ &le_driver,
+};
+int n_netif_drivers = sizeof(netif_drivers) / sizeof(netif_drivers[0]);
+
+#define MAXIFACES ((sizeof(ie_config) / sizeof(ie_config[0])) + \
+ (sizeof(le_config) / sizeof(le_config[0])))
+
+static struct netif_stats if_stats[MAXIFACES];
+static struct netif_dif if_dif[MAXIFACES];
+
+static void
+add_if(struct netif_driver *drv)
+{
+ static struct netif_stats *stats = if_stats;
+ static struct netif_dif *dif = if_dif;
+
+ dif->dif_unit = drv->netif_nifs;
+ dif->dif_nsel = 1;
+ dif->dif_stats = stats;
+
+ if (drv->netif_nifs == 0)
+ drv->netif_ifs = dif;
+ drv->netif_nifs++;
+
+ stats++;
+ dif++;
+}
+
+/*
+ * Figure out what devices are available.
+ */
+int
+probe_ethernet()
+{
+ struct mvmeprom_brdid *brdid;
+ uint n;
+
+ brdid = mvmeprom_brdid();
+
+ /* On-board Ethernet */
+ switch (brdid->model) {
+ case BRD_187:
+ case BRD_197:
+ case BRD_8120:
+ ie_config[nie_config].clun = 0;
+ ie_config[nie_config].phys_addr = INTEL_REG_ADDR;
+ bcopy(brdid->etheraddr, ie_config[nie_config].eaddr, 6);
+ add_if(&ie_driver);
+ nie_config++;
+ break;
+ }
+
+ /* MVME376 */
+ for (n = 0; n < sizeof(vle_addr) / sizeof(vle_addr[0]); n++) {
+ if (badaddr((void *)vle_addr[n], 2) == 0) {
+ le_config[nle_config].clun = 2 + n;
+ le_config[nle_config].phys_addr = vle_addr[n];
+ le_config[nle_config].buf_addr =
+ VLEMEMBASE - n * VLEMEMSIZE;
+ le_config[nle_config].buf_size = VLEMEMSIZE;
+ le_read_etheraddr(vle_addr[n],
+ le_config[nle_config].eaddr);
+ add_if(&le_driver);
+ nle_config++;
+ }
+ }
+
+ return nie_config + nle_config;
+}
+
+/*
+ * Mimic the NIOT;H BUG command (except for `P-Address' field), adding our
+ * own driver names.
+ */
+void
+display_ethernet()
+{
+ struct mvmeprom_brdid *brdid;
+ int i;
+
+ brdid = mvmeprom_brdid();
+
+ printf("Network Controllers/Nodes Supported\n");
+ printf("Driver CLUN DLUN Name Address Ethernet Address\n");
+
+ for (i = 0; i < nie_config; i++) {
+ printf("ie%d %x 0 VME%x",
+ i, ie_config[i].clun, brdid->model);
+ /* @#$%! MVME8120 - and I don't even have one to test (miod) */
+ if (brdid->model < 0x1000)
+ printf(" ");
+ printf(" $%x %s\n",
+ ie_config[i].phys_addr, ether_sprintf(ie_config[i].eaddr));
+ }
+
+ for (i = 0; i < nle_config; i++) {
+ printf("le%d %x 0 VME376 $%x %s\n",
+ i, le_config[i].clun, le_config[i].phys_addr,
+ ether_sprintf(le_config[i].eaddr));
+ }
+}
diff --git a/sys/arch/mvme88k/stand/sboot/devopen.c b/sys/arch/mvme88k/stand/sboot/devopen.c
new file mode 100644
index 00000000000..e2fa4aa60a4
--- /dev/null
+++ b/sys/arch/mvme88k/stand/sboot/devopen.c
@@ -0,0 +1,69 @@
+/* $OpenBSD: devopen.c,v 1.1 2013/05/12 10:43:45 miod Exp $ */
+
+/*
+ * Copyright (c) 2013 Miodrag Vallat.
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+
+#include <sys/param.h>
+#include <sys/types.h>
+
+#include <netinet/in.h>
+
+#include <machine/prom.h>
+
+#include "stand.h"
+#include "libsa.h"
+#include "netif.h"
+#include "config.h"
+
+/*
+ * A replacement for libsa devopen() to recognize an Ethernet interface
+ * name, followed by a digit and a colon, as an optional prefix.
+ */
+int
+devopen(struct open_file *f, const char *fname, char **file)
+{
+ struct devsw *dp;
+ const char *prefix;
+ char *colon;
+
+ prefix = NULL;
+ *file = (char *)fname;
+
+ colon = strchr(fname, ':');
+ if (colon != NULL) {
+ int i;
+
+ for (i = 0; i < n_netif_drivers; i++) {
+ struct netif_driver *drv = netif_drivers[i];
+
+ /* out of lazyness, only allow one digit for the
+ interface number */
+ if (colon != fname + strlen(drv->netif_bname) + 1)
+ continue;
+ if (bcmp(fname, drv->netif_bname,
+ strlen(drv->netif_bname)) != 0)
+ continue;
+
+ prefix = fname;
+ *file = colon + 1;
+ }
+ }
+
+ dp = &devsw[0];
+ f->f_dev = dp;
+ return (*dp->dv_open)(f, prefix);
+}
diff --git a/sys/arch/mvme88k/stand/sboot/etherfun.c b/sys/arch/mvme88k/stand/sboot/etherfun.c
deleted file mode 100644
index f19bb5918f5..00000000000
--- a/sys/arch/mvme88k/stand/sboot/etherfun.c
+++ /dev/null
@@ -1,217 +0,0 @@
-/* $OpenBSD: etherfun.c,v 1.4 2012/12/05 23:20:14 deraadt Exp $ */
-
-/*
- *
- * Copyright (c) 1995 Charles D. Cranor and Seth Widoff
- * 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 Charles D. Cranor
- * and Seth Widoff.
- * 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.
- */
-/* etherfun.c */
-
-#include <sys/types.h>
-#include "sboot.h"
-#include "etherfun.h"
-
-/* Construct and send a rev arp packet */
-void
-do_rev_arp()
-{
- int i;
-
- for (i = 0; i < 6; i++)
- eh->ether_dhost[i] = 0xff;
-
- bcopy(myea, eh->ether_shost, 6);
- eh->ether_type = ETYPE_RARP;
-
- rarp->ar_hrd = 1; /* hardware type is 1 */
- rarp->ar_pro = PTYPE_IP;
- rarp->ar_hln = 6; /* length of hardware address is 6 bytes */
- rarp->ar_pln = 4; /* length of ip address is 4 byte */
- rarp->ar_op = OPCODE_RARP;
- bcopy(myea, rarp->arp_sha, sizeof(myea));
- bcopy(myea, rarp->arp_tha, sizeof(myea));
- for (i = 0; i < 4; i++)
- rarp->arp_spa[i] = rarp->arp_tpa[i] = 0x00;
-
- le_put(buf, 76);
-}
-
-/* Receive and disassemble the rev_arp reply */
-int
-get_rev_arp()
-{
- le_get(buf, sizeof(buf), 6);
- if (eh->ether_type == ETYPE_RARP && rarp->ar_op == OPCODE_REPLY) {
- bcopy(rarp->arp_tpa, myip, sizeof(rarp->arp_tpa));
- bcopy(rarp->arp_spa, servip, sizeof(rarp->arp_spa));
- bcopy(rarp->arp_sha, servea, sizeof(rarp->arp_sha));
- return (1);
- }
- return (0);
-}
-
-/* Try to get a reply to a rev arp request */
-int
-rev_arp()
-{
- int tries = 0;
- while (tries < 5) {
- do_rev_arp();
- if (get_rev_arp())
- return (1);
- tries++;
- }
- return (0);
-}
-
-/*
- * Send a tftp read request or acknowledgement
- * mesgtype 0 is a read request, 1 is an
- * acknowledgement
- */
-void
-do_send_tftp(mesgtype)
- int mesgtype;
-{
- u_long res, iptmp, lcv;
- char *tot;
-
- if (mesgtype == 0) {
- tot = tftp_r + (sizeof(MSG) - 1);
- myport = (u_short) time();
- if (myport < 1000)
- myport += 1000;
- servport = FTP_PORT; /* to start */
- } else {
- tot = (char *) tftp_a + 4;
- }
-
- bcopy(servea, eh->ether_dhost, sizeof(servea));
- bcopy(myea, eh->ether_shost, sizeof(myea));
- eh->ether_type = ETYPE_IP;
-
- iph->ip_v = IP_VERSION;
- iph->ip_hl = IP_HLEN;
- iph->ip_tos = 0; /* type of service is 0 */
- iph->ip_id = 0; /* id field is 0 */
- iph->ip_off = IP_DF;
- iph->ip_ttl = 3; /* time to live is 3 seconds/hops */
- iph->ip_p = IPP_UDP;
- bcopy(myip, iph->ip_src, sizeof(myip));
- bcopy(servip, iph->ip_dst, sizeof(servip));
- iph->ip_sum = 0;
- iph->ip_len = tot - (char *) iph;
- res = oc_cksum(iph, sizeof(struct ip), 0);
- iph->ip_sum = 0xffff & ~res;
- udph->uh_sport = myport;
- udph->uh_dport = servport;
- udph->uh_sum = 0;
-
- if (mesgtype) {
- tftp_a->op_code = FTPOP_ACKN;
- tftp_a->block = (u_short) (mesgtype);
- } else {
- bcopy(myip, &iptmp, sizeof(iptmp));
- bcopy(MSG, tftp_r, (sizeof(MSG) - 1));
- for (lcv = 9; lcv >= 2; lcv--) {
- tftp_r[lcv] = "0123456789ABCDEF"[iptmp & 0xF];
-
- iptmp = iptmp >> 4;
- }
- }
-
- udph->uh_ulen = tot - (char *) udph;
-
- le_put(buf, tot - buf);
-}
-
-/* Attempt to tftp a file and read it into memory */
-int
-do_get_file()
-{
- int fail = 0, oldlen;
- char *loadat = (char *) LOAD_ADDR;
- last_ack = 0;
-
- do_send_tftp(READ);
- while (1) {
- if (le_get(buf, sizeof(buf), 5) == 0) {
- /* timeout occurred */
- if (last_ack)
- do_send_tftp(last_ack);
- else
- do_send_tftp(READ);
-
- fail++;
- if (fail > 5) {
- printf("\n");
- return (1);
- }
- } else {
- printf("%x \r", tftp->info.block * 512);
- if ((eh->ether_type != ETYPE_IP) || (iph->ip_p != IPP_UDP)) {
- fail++;
- continue;
- }
- if (servport == FTP_PORT)
- servport = udph->uh_sport;
- if (tftp->info.op_code == FTPOP_ERR) {
- printf("TFTP: Download error %d: %s\n",
- tftp->info.block, tftp->data);
- return (1);
- }
- if (tftp->info.block != last_ack + 1) {
- /* we received the wrong block */
- if (tftp->info.block < last_ack + 1) {
- /* nack whatever we received */
- do_send_tftp(tftp->info.block);
- } else {
- /* nack the last confirmed block */
- do_send_tftp(last_ack);
- }
- fail++;
- } else {/* we got the right block */
- fail = 0;
- last_ack++;
- oldlen = udph->uh_ulen;
- do_send_tftp(last_ack);
- /* printf("bcopy %x %x %d\n", &tftp->data,
- * loadat, oldlen - 12); */
- bcopy(&tftp->data, loadat, oldlen - 12);
- loadat += oldlen - 12;
- if (oldlen < (8 + 4 + 512)) {
- printf("\n");
- return (0);
- }
- }
- }
- }
- printf("\n");
- return (0);
-}
diff --git a/sys/arch/mvme88k/stand/sboot/etherfun.h b/sys/arch/mvme88k/stand/sboot/etherfun.h
deleted file mode 100644
index e43043c3e4b..00000000000
--- a/sys/arch/mvme88k/stand/sboot/etherfun.h
+++ /dev/null
@@ -1,126 +0,0 @@
-/* $OpenBSD: etherfun.h,v 1.3 2006/05/16 22:52:26 miod Exp $ */
-
-/*
- *
- * Copyright (c) 1995 Charles D. Cranor and Seth Widoff
- * 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 Charles D. Cranor
- * and Seth Widoff.
- * 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.
- */
-/* etherfun.h */
-
-/* constants */
-/* ether header */
-#define ETYPE_RARP 0x8035 /* ethertype is RARP */
-#define ETYPE_IP 0x800 /* ethertype is IP */
-
-/* rev arp */
-#define PTYPE_IP 0x800 /* Protocol type is IP */
-#define OPCODE_RARP 3 /* Optype is REVARP request */
-#define OPCODE_REPLY 4 /* Optype is REVARP reply */
-
-/* ip header */
-#define IPP_UDP 17 /* IP Protocol is UDP */
-#define IP_VERSION 4 /* IP version number */
-#define IP_HLEN 5 /* IP header length is a fixed 50 bytes */
-#define N 1536
-
-/* tftp header */
-#define FTPOP_ACKN 4 /* Opcode is acknowledge */
-#define FTPOP_ERR 5 /* Opcode is Error */
-#define FTP_PORT 69 /* Standard TFTP port number */
-#define MSG "\0\1xxxxxxxx.mvme68k\0octet\0" /* implicit NULL */
-
-/* data structures */
-
-struct ether_header {
- u_char ether_dhost[6];
- u_char ether_shost[6];
- u_short ether_type;
-};
-
-struct ether_arp {
- u_short ar_hrd; /* format of hardware address */
- u_short ar_pro; /* format of protocol address */
- u_char ar_hln; /* length of hardware address */
- u_char ar_pln; /* length of protocol address */
- u_short ar_op;
- u_char arp_sha[6]; /* sender hardware address */
- u_char arp_spa[4]; /* sender protocol address */
- u_char arp_tha[6]; /* target hardware address */
- u_char arp_tpa[4]; /* target protocol address */
-};
-
-struct ip {
- u_char ip_v:4, /* version */
- ip_hl:4; /* header length */
- u_char ip_tos; /* type of service */
- short ip_len; /* total length */
- u_short ip_id; /* identification */
- short ip_off; /* fragment offset field */
-#define IP_DF 0x4000 /* dont fragment flag */
-#define IP_MF 0x2000 /* more fragments flag */
-#define IP_OFFMASK 0x1fff /* mask for fragmenting bits */
- u_char ip_ttl; /* time to live */
- u_char ip_p; /* protocol */
- u_short ip_sum; /* checksum */
- u_char ip_src[4];
- u_char ip_dst[4]; /* source and dest address */
-};
-
-struct udp {
- u_short uh_sport;
- u_short uh_dport;
- short uh_ulen;
- u_short uh_sum;
-};
-
-struct tftph {
- u_short op_code;
- u_short block;
-};
-
-struct tftphr {
- struct tftph info;
- char data[1];
-};
-
-/* globals */
-int last_ack;
-char buf[N];
-struct ether_header *eh = (struct ether_header *)buf;
-struct ether_arp *rarp = (struct ether_arp *)
- (buf + sizeof(struct ether_header));
-struct ip *iph = (struct ip *)(buf + sizeof(struct ether_header));
-struct udp *udph = (struct udp *)
- (buf + sizeof(struct ether_header) + sizeof(struct ip));
-char *tftp_r = buf + sizeof(struct ether_header) + sizeof(struct ip) +
- sizeof(struct udp);
-struct tftph *tftp_a = (struct tftph *)(buf + sizeof(struct ether_header) +
- sizeof(struct ip) + sizeof(struct udp));
-struct tftphr *tftp = (struct tftphr *)(buf + sizeof(struct ether_header) +
- sizeof(struct ip) + sizeof(struct udp));
diff --git a/sys/arch/mvme88k/stand/sboot/if_le.c b/sys/arch/mvme88k/stand/sboot/if_le.c
deleted file mode 100644
index 4a883e8b186..00000000000
--- a/sys/arch/mvme88k/stand/sboot/if_le.c
+++ /dev/null
@@ -1,350 +0,0 @@
-/* $OpenBSD: if_le.c,v 1.5 2012/12/05 23:20:14 deraadt Exp $ */
-
-/*
- * 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.
- *
- * 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 Adam Glass
- * 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 Adam Glass.
- * 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 Adam Glass ``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.
- */
-
-#include <sys/types.h>
-#include "sboot.h"
-#include "if_lereg.h"
-
-struct {
- struct lereg1 *sc_r1; /* LANCE registers */
- struct lereg2 *sc_r2; /* RAM */
- int next_rmd;
- int next_tmd;
-} le_softc;
-
-void
-le_error(str, ler1)
- char *str;
- struct lereg1 *ler1;
-{
- /* ler1->ler1_rap = LE_CSRO done in caller */
- if (ler1->ler1_rdp & LE_C0_BABL) {
- printf("le0: been babbling, found by '%s'\n", str);
- callrom();
- }
- if (ler1->ler1_rdp & LE_C0_CERR) {
- ler1->ler1_rdp = LE_C0_CERR;
- }
- if (ler1->ler1_rdp & LE_C0_MISS) {
- ler1->ler1_rdp = LE_C0_MISS;
- }
- if (ler1->ler1_rdp & LE_C0_MERR) {
- printf("le0: memory error in '%s'\n", str);
- callrom();
- }
-}
-
-void
-le_reset(myea)
- u_char *myea;
-{
- struct lereg1 *ler1 = le_softc.sc_r1;
- struct lereg2 *ler2 = le_softc.sc_r2;
- unsigned int a;
- int timo = 100000, stat, i;
-
- ler1->ler1_rap = LE_CSR0;
- ler1->ler1_rdp = LE_C0_STOP; /* do nothing until we are finished */
-
- bzero(ler2, sizeof(*ler2));
-
- ler2->ler2_mode = LE_MODE_NORMAL;
- ler2->ler2_padr[0] = myea[1];
- ler2->ler2_padr[1] = myea[0];
- ler2->ler2_padr[2] = myea[3];
- ler2->ler2_padr[3] = myea[2];
- ler2->ler2_padr[4] = myea[5];
- ler2->ler2_padr[5] = myea[4];
-
-
- ler2->ler2_ladrf0 = 0;
- ler2->ler2_ladrf1 = 0;
-
- a = (u_int) ler2->ler2_rmd;
- ler2->ler2_rlen = LE_RLEN | (a >> 16);
- ler2->ler2_rdra = a & LE_ADDR_LOW_MASK;
-
- a = (u_int) ler2->ler2_tmd;
- ler2->ler2_tlen = LE_TLEN | (a >> 16);
- ler2->ler2_tdra = a & LE_ADDR_LOW_MASK;
-
- ler1->ler1_rap = LE_CSR1;
- a = (u_int) ler2;
- ler1->ler1_rdp = a & LE_ADDR_LOW_MASK;
- ler1->ler1_rap = LE_CSR2;
- ler1->ler1_rdp = a >> 16;
-
- for (i = 0; i < LERBUF; i++) {
- a = (u_int) & ler2->ler2_rbuf[i];
- ler2->ler2_rmd[i].rmd0 = a & LE_ADDR_LOW_MASK;
- ler2->ler2_rmd[i].rmd1_bits = LE_R1_OWN;
- ler2->ler2_rmd[i].rmd1_hadr = a >> 16;
- ler2->ler2_rmd[i].rmd2 = -LEMTU;
- ler2->ler2_rmd[i].rmd3 = 0;
- }
- for (i = 0; i < LETBUF; i++) {
- a = (u_int) & ler2->ler2_tbuf[i];
- ler2->ler2_tmd[i].tmd0 = a & LE_ADDR_LOW_MASK;
- ler2->ler2_tmd[i].tmd1_bits = 0;
- ler2->ler2_tmd[i].tmd1_hadr = a >> 16;
- ler2->ler2_tmd[i].tmd2 = 0;
- ler2->ler2_tmd[i].tmd3 = 0;
- }
-
- ler1->ler1_rap = LE_CSR3;
- ler1->ler1_rdp = LE_C3_BSWP;
-
- ler1->ler1_rap = LE_CSR0;
- ler1->ler1_rdp = LE_C0_INIT;
- do {
- if (--timo == 0) {
- printf("le0: init timeout, stat = 0x%x\n", stat);
- break;
- }
- stat = ler1->ler1_rdp;
- } while ((stat & LE_C0_IDON) == 0);
-
- ler1->ler1_rdp = LE_C0_IDON;
- le_softc.next_rmd = 0;
- le_softc.next_tmd = 0;
- ler1->ler1_rap = LE_CSR0;
- ler1->ler1_rdp = LE_C0_STRT;
-}
-
-int
-le_poll(pkt, len)
- void *pkt;
- int len;
-{
- struct lereg1 *ler1 = le_softc.sc_r1;
- struct lereg2 *ler2 = le_softc.sc_r2;
- unsigned int a;
- int length;
- struct lermd *rmd;
-
- ler1->ler1_rap = LE_CSR0;
- if ((ler1->ler1_rdp & LE_C0_RINT) != 0)
- ler1->ler1_rdp = LE_C0_RINT;
- rmd = &ler2->ler2_rmd[le_softc.next_rmd];
- if (rmd->rmd1_bits & LE_R1_OWN) {
- return (0);
- }
- if (ler1->ler1_rdp & LE_C0_ERR)
- le_error("le_poll", ler1);
- if (rmd->rmd1_bits & LE_R1_ERR) {
- printf("le0_poll: rmd status 0x%x\n", rmd->rmd1_bits);
- length = 0;
- goto cleanup;
- }
- if ((rmd->rmd1_bits & (LE_R1_STP | LE_R1_ENP)) != (LE_R1_STP | LE_R1_ENP)) {
- printf("le_poll: chained packet\n");
- callrom();
- }
- length = rmd->rmd3;
- if (length >= LEMTU) {
- length = 0;
- printf("csr0 when bad things happen: %x\n", ler1->ler1_rdp);
- callrom();
- goto cleanup;
- }
- if (!length)
- goto cleanup;
- length -= 4;
- if (length > 0)
- bcopy((char *) &ler2->ler2_rbuf[le_softc.next_rmd], pkt, length);
-
-cleanup:
- a = (u_int) & ler2->ler2_rbuf[le_softc.next_rmd];
- rmd->rmd0 = a & LE_ADDR_LOW_MASK;
- rmd->rmd1_hadr = a >> 16;
- rmd->rmd2 = -LEMTU;
- le_softc.next_rmd =
- (le_softc.next_rmd == (LERBUF - 1)) ? 0 : (le_softc.next_rmd + 1);
- rmd->rmd1_bits = LE_R1_OWN;
- return length;
-}
-
-int
-le_put(pkt, len)
- u_char *pkt;
- size_t len;
-{
- struct lereg1 *ler1 = le_softc.sc_r1;
- struct lereg2 *ler2 = le_softc.sc_r2;
- struct letmd *tmd;
- int timo = 100000, stat, i;
- unsigned int a;
-
- ler1->ler1_rap = LE_CSR0;
- if (ler1->ler1_rdp & LE_C0_ERR)
- le_error("le_put(way before xmit)", ler1);
- tmd = &ler2->ler2_tmd[le_softc.next_tmd];
- while (tmd->tmd1_bits & LE_T1_OWN) {
- printf("le0: output buffer busy\n");
- }
- bcopy(pkt, (char *) ler2->ler2_tbuf[le_softc.next_tmd], len);
- if (len < 64)
- tmd->tmd2 = -64;
- else
- tmd->tmd2 = -len;
- tmd->tmd3 = 0;
- if (ler1->ler1_rdp & LE_C0_ERR)
- le_error("le_put(before xmit)", ler1);
- tmd->tmd1_bits = LE_T1_STP | LE_T1_ENP | LE_T1_OWN;
- a = (u_int) & ler2->ler2_tbuf[le_softc.next_tmd];
- tmd->tmd0 = a & LE_ADDR_LOW_MASK;
- tmd->tmd1_hadr = a >> 16;
- ler1->ler1_rdp = LE_C0_TDMD;
- if (ler1->ler1_rdp & LE_C0_ERR)
- le_error("le_put(after xmit)", ler1);
- do {
- if (--timo == 0) {
- printf("le0: transmit timeout, stat = 0x%x\n",
- stat);
- if (ler1->ler1_rdp & LE_C0_ERR)
- le_error("le_put(timeout)", ler1);
- break;
- }
- stat = ler1->ler1_rdp;
- } while ((stat & LE_C0_TINT) == 0);
- ler1->ler1_rdp = LE_C0_TINT;
- if (ler1->ler1_rdp & LE_C0_ERR) {
- if ((ler1->ler1_rdp & (LE_C0_BABL | LE_C0_CERR | LE_C0_MISS | LE_C0_MERR)) !=
- LE_C0_CERR)
- printf("le_put: xmit error, buf %d\n", le_softc.next_tmd);
- le_error("le_put(xmit error)", ler1);
- }
- le_softc.next_tmd = 0;
-/* (le_softc.next_tmd == (LETBUF - 1)) ? 0 : le_softc.next_tmd + 1;*/
- if (tmd->tmd1_bits & LE_T1_ERR) {
- printf("le0: transmit error, error = 0x%x\n",
- tmd->tmd3);
- return -1;
- }
- return len;
-}
-
-int
-le_get(pkt, len, timeout)
- u_char *pkt;
- size_t len;
- u_long timeout;
-{
- int cc;
- int now, then;
- int stopat = time() + timeout;
- then = 0;
-
- cc = 0;
- while ((now = time()) < stopat && !cc) {
- cc = le_poll(pkt, len);
- if (then != now) {
-#ifdef LE_DEBUG
- printf("%d \r", stopat - now);
-#endif
- then = now;
- }
- if (cc && (pkt[0] != myea[0] || pkt[1] != myea[1] ||
- pkt[2] != myea[2] || pkt[3] != myea[3] ||
- pkt[4] != myea[4] || pkt[5] != myea[5])) {
- cc = 0; /* ignore broadcast / multicast */
-#ifdef LE_DEBUG
- printf("reject (%d sec left)\n", stopat - now);
-#endif
- }
- }
-#ifdef LE_DEBUG
- printf("\n");
-#endif
- return cc;
-}
-
-void
-le_init()
-{
- caddr_t addr;
- int *ea = (int *) LANCE_ADDR;
- u_long *eram = (u_long *) ERAM_ADDR;
- u_long e = *ea;
- if ((e & 0x2fffff00) == 0x2fffff00) {
- printf("ERROR: ethernet address not set! Use LSAD.\n");
- callrom();
- }
- myea[0] = 0x08;
- myea[1] = 0x00;
- myea[2] = 0x3e;
- e = e >> 8;
- myea[5] = e & 0xff;
- e = e >> 8;
- myea[4] = e & 0xff;
- e = e >> 8;
- myea[3] = e;
- printf("le0: ethernet address: %x:%x:%x:%x:%x:%x\n",
- myea[0], myea[1], myea[2], myea[3], myea[4], myea[5]);
- bzero(&le_softc, sizeof(le_softc));
- le_softc.sc_r1 = (struct lereg1 *) LANCE_REG_ADDR;
- le_softc.sc_r2 = (struct lereg2 *) (*eram - (1024 * 1024));
- le_reset(myea);
-}
-
-void
-le_end()
-{
- struct lereg1 *ler1 = le_softc.sc_r1;
-
- ler1->ler1_rap = LE_CSR0;
- ler1->ler1_rdp = LE_C0_STOP;
-}
diff --git a/sys/arch/mvme88k/stand/sboot/if_lereg.h b/sys/arch/mvme88k/stand/sboot/if_lereg.h
deleted file mode 100644
index 28f068fd87f..00000000000
--- a/sys/arch/mvme88k/stand/sboot/if_lereg.h
+++ /dev/null
@@ -1,172 +0,0 @@
-/* $OpenBSD: if_lereg.h,v 1.5 2006/05/16 22:52:26 miod Exp $ */
-
-/*-
- * Copyright (c) 1982, 1992, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * @(#)if_lereg.h 8.2 (Berkeley) 10/30/93
- */
-
-#define LEMTU 1518
-#define LEMINSIZE 60 /* should be 64 if mode DTCR is set */
-#define LERBUF 8
-#define LERBUFLOG2 3
-#define LE_RLEN (LERBUFLOG2 << 13)
-#define LETBUF 1
-#define LETBUFLOG2 0
-#define LE_TLEN (LETBUFLOG2 << 13)
-
-/* Local Area Network Controller for Ethernet (LANCE) registers */
-struct lereg1 {
- volatile u_short ler1_rdp; /* register data port */
- volatile u_short ler1_rap; /* register address port */
-};
-
-/* register addresses */
-#define LE_CSR0 0 /* Control and status register */
-#define LE_CSR1 1 /* low address of init block */
-#define LE_CSR2 2 /* high address of init block */
-#define LE_CSR3 3 /* Bus master and control */
-
-/* Control and status register 0 (csr0) */
-#define LE_C0_ERR 0x8000 /* error summary */
-#define LE_C0_BABL 0x4000 /* transmitter timeout error */
-#define LE_C0_CERR 0x2000 /* collision */
-#define LE_C0_MISS 0x1000 /* missed a packet */
-#define LE_C0_MERR 0x0800 /* memory error */
-#define LE_C0_RINT 0x0400 /* receiver interrupt */
-#define LE_C0_TINT 0x0200 /* transmitter interrupt */
-#define LE_C0_IDON 0x0100 /* initialization done */
-#define LE_C0_INTR 0x0080 /* interrupt condition */
-#define LE_C0_INEA 0x0040 /* interrupt enable */
-#define LE_C0_RXON 0x0020 /* receiver on */
-#define LE_C0_TXON 0x0010 /* transmitter on */
-#define LE_C0_TDMD 0x0008 /* transmit demand */
-#define LE_C0_STOP 0x0004 /* disable all external activity */
-#define LE_C0_STRT 0x0002 /* enable external activity */
-#define LE_C0_INIT 0x0001 /* begin initialization */
-
-#define LE_C0_BITS \
- "\20\20ERR\17BABL\16CERR\15MISS\14MERR\13RINT\
-\12TINT\11IDON\10INTR\07INEA\06RXON\05TXON\04TDMD\03STOP\02STRT\01INIT"
-
-/* Control and status register 3 (csr3) */
-#define LE_C3_BSWP 0x4 /* byte swap */
-#define LE_C3_ACON 0x2 /* ALE control, eh? */
-#define LE_C3_BCON 0x1 /* byte control */
-/*
- * Current size is 13,758 bytes with 8 x 1518 receive buffers and
- * 1 x 1518 transmit buffer.
- */
-struct lereg2 {
- /* initialization block */
- volatile u_short ler2_mode; /* mode */
- volatile u_char ler2_padr[6]; /* physical address */
-#ifdef new_code
- volatile u_short ler2_ladrf[4]; /* logical address filter */
-#else
- volatile u_long ler2_ladrf0; /* logical address filter */
- volatile u_long ler2_ladrf1; /* logical address filter */
-#endif
- volatile u_short ler2_rdra; /* receive descriptor addr */
- volatile u_short ler2_rlen; /* rda high and ring size */
- volatile u_short ler2_tdra; /* transmit descriptor addr */
- volatile u_short ler2_tlen; /* tda high and ring size */
- /* receive message descriptors. bits/hadr are byte order dependent. */
- struct lermd {
- volatile u_short rmd0; /* low address of packet */
- volatile u_char rmd1_bits; /* descriptor bits */
- volatile u_char rmd1_hadr; /* high address of packet */
- volatile short rmd2; /* buffer byte count */
- volatile u_short rmd3; /* message byte count */
- } ler2_rmd[LERBUF];
- /* transmit message descriptors */
- struct letmd {
- volatile u_short tmd0; /* low address of packet */
- volatile u_char tmd1_bits; /* descriptor bits */
- volatile u_char tmd1_hadr; /* high address of packet */
- volatile short tmd2; /* buffer byte count */
- volatile u_short tmd3; /* transmit error bits */
- } ler2_tmd[LETBUF];
- volatile char ler2_rbuf[LERBUF][LEMTU];
- volatile char ler2_tbuf[LETBUF][LEMTU];
-};
-
-/* Initialzation block (mode) */
-#define LE_MODE_PROM 0x8000 /* promiscuous mode */
-/* 0x7f80 reserved, must be zero */
-#define LE_MODE_INTL 0x0040 /* internal loopback */
-#define LE_MODE_DRTY 0x0020 /* disable retry */
-#define LE_MODE_COLL 0x0010 /* force a collision */
-#define LE_MODE_DTCR 0x0008 /* disable transmit CRC */
-#define LE_MODE_LOOP 0x0004 /* loopback mode */
-#define LE_MODE_DTX 0x0002 /* disable transmitter */
-#define LE_MODE_DRX 0x0001 /* disable receiver */
-#define LE_MODE_NORMAL 0 /* none of the above */
-
-
-/* Receive message descriptor 1 (rmd1_bits) */
-#define LE_R1_OWN 0x80 /* LANCE owns the packet */
-#define LE_R1_ERR 0x40 /* error summary */
-#define LE_R1_FRAM 0x20 /* framing error */
-#define LE_R1_OFLO 0x10 /* overflow error */
-#define LE_R1_CRC 0x08 /* CRC error */
-#define LE_R1_BUFF 0x04 /* buffer error */
-#define LE_R1_STP 0x02 /* start of packet */
-#define LE_R1_ENP 0x01 /* end of packet */
-
-#define LE_R1_BITS \
- "\20\10OWN\7ERR\6FRAM\5OFLO\4CRC\3BUFF\2STP\1ENP"
-
-/* Transmit message descriptor 1 (tmd1_bits) */
-#define LE_T1_OWN 0x80 /* LANCE owns the packet */
-#define LE_T1_ERR 0x40 /* error summary */
-#define LE_T1_MORE 0x10 /* multiple collisions */
-#define LE_T1_ONE 0x08 /* single collision */
-#define LE_T1_DEF 0x04 /* defferred transmit */
-#define LE_T1_STP 0x02 /* start of packet */
-#define LE_T1_ENP 0x01 /* end of packet */
-
-#define LE_T1_BITS \
- "\20\10OWN\7ERR\6RES\5MORE\4ONE\3DEF\2STP\1ENP"
-
-/* Transmit message descriptor 3 (tmd3) */
-#define LE_T3_BUFF 0x8000 /* buffer error */
-#define LE_T3_UFLO 0x4000 /* underflow error */
-#define LE_T3_LCOL 0x1000 /* late collision */
-#define LE_T3_LCAR 0x0800 /* loss of carrier */
-#define LE_T3_RTRY 0x0400 /* retry error */
-#define LE_T3_TDR_MASK 0x03ff /* time domain reflectometry counter */
-
-#define LE_XMD2_ONES 0xf000
-
-#define LE_T3_BITS \
- "\20\20BUFF\17UFLO\16RES\15LCOL\14LCAR\13RTRY"
-
-
-#define LE_ADDR_LOW_MASK (0xffff)
-
diff --git a/sys/arch/mvme88k/stand/sboot/oc_cksum.S b/sys/arch/mvme88k/stand/sboot/oc_cksum.S
deleted file mode 100644
index 680dbef3f56..00000000000
--- a/sys/arch/mvme88k/stand/sboot/oc_cksum.S
+++ /dev/null
@@ -1,187 +0,0 @@
-| $OpenBSD: oc_cksum.S,v 1.3 2006/05/16 22:52:26 miod Exp $
-
-| Copyright (c) 1988 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.
-|
-| @(#)oc_cksum.s 7.2 (Berkeley) 11/3/90
-|
-|
-| oc_cksum: ones complement 16 bit checksum for MC68020.
-|
-| oc_cksum (buffer, count, strtval)
-|
-| Do a 16 bit ones complement sum of 'count' bytes from 'buffer'.
-| 'strtval' is the starting value of the sum (usually zero).
-|
-| It simplifies life in in_cksum if strtval can be >= 2^16.
-| This routine will work as long as strtval is < 2^31.
-|
-| Performance
-| -----------
-| This routine is intended for MC 68020s but should also work
-| for 68030s. It (deliberately) does not worry about the alignment
-| of the buffer so will only work on a 68010 if the buffer is
-| aligned on an even address. (Also, a routine written to use
-| 68010 "loop mode" would almost certainly be faster than this
-| code on a 68010).
-|
-| We do not worry about alignment because this routine is frequently
-| called with small counts: 20 bytes for IP header checksums and 40
-| bytes for TCP ack checksums. For these small counts, testing for
-| bad alignment adds ~10% to the per-call cost. Since, by the nature
-| of the kernel allocator, the data we are called with is almost
-| always longword aligned, there is no benefit to this added cost
-| and we are better off letting the loop take a big performance hit
-| in the rare cases where we are handed an unaligned buffer.
-|
-| Loop unrolling constants of 2, 4, 8, 16, 32 and 64 times were
-| tested on random data on four different types of processors (see
-| list below -- 64 was the largest unrolling because anything more
-| overflows the 68020 Icache). On all the processors, the
-| throughput asymptote was located between 8 and 16 (closer to 8).
-| However, 16 was substantially better than 8 for small counts.
-| (It is clear why this happens for a count of 40: unroll-8 pays a
-| loop branch cost and unroll-16 does not. But the tests also showed
-| that 16 was better than 8 for a count of 20. It is not obvious to
-| me why.) So, since 16 was good for both large and small counts,
-| the loop below is unrolled 16 times.
-|
-| The processors tested and their average time to checksum 1024 bytes
-| of random data were:
-| Sun 3/50 (15MHz) 190 us/KB
-| Sun 3/180 (16.6MHz) 175 us/KB
-| Sun 3/60 (20MHz) 134 us/KB
-| Sun 3/280 (25MHz) 95 us/KB
-|
-| The cost of calling this routine was typically 10% of the per-
-| kilobyte cost. E.g., checksumming zero bytes on a 3/60 cost 9us
-| and each additional byte cost 125ns. With the high fixed cost,
-| it would clearly be a gain to "inline" this routine -- the
-| subroutine call adds 400% overhead to an IP header checksum.
-| However, in absolute terms, inlining would only gain 10us per
-| packet -- a 1% effect for a 1ms ethernet packet. This is not
-| enough gain to be worth the effort.
-
-#include <machine/asm.h>
-
- .text
-
- .text; .even; .globl _oc_cksum; _oc_cksum:
- movl sp@(4),a0 | get buffer ptr
- movl sp@(8),d1 | get byte count
- movl sp@(12),d0 | get starting value
- movl d2,sp@- | free a reg
-
- | test for possible 1, 2 or 3 bytes of excess at end
- | of buffer. The usual case is no excess (the usual
- | case is header checksums) so we give that the faster
- | 'not taken' leg of the compare. (We do the excess
- | first because we are about the trash the low order
- | bits of the count in d1.)
-
- btst #0,d1
- jne L5 | if one or three bytes excess
- btst #1,d1
- jne L7 | if two bytes excess
-L1:
- movl d1,d2
- lsrl #6,d1 | make cnt into # of 64 byte chunks
- andl #0x3c,d2 | then find fractions of a chunk
- negl d2
- andb #0xf,cc | clear X
- jmp pc@(L3-.-2:b,d2)
-L2:
- movl a0@+,d2
- addxl d2,d0
- movl a0@+,d2
- addxl d2,d0
- movl a0@+,d2
- addxl d2,d0
- movl a0@+,d2
- addxl d2,d0
- movl a0@+,d2
- addxl d2,d0
- movl a0@+,d2
- addxl d2,d0
- movl a0@+,d2
- addxl d2,d0
- movl a0@+,d2
- addxl d2,d0
- movl a0@+,d2
- addxl d2,d0
- movl a0@+,d2
- addxl d2,d0
- movl a0@+,d2
- addxl d2,d0
- movl a0@+,d2
- addxl d2,d0
- movl a0@+,d2
- addxl d2,d0
- movl a0@+,d2
- addxl d2,d0
- movl a0@+,d2
- addxl d2,d0
- movl a0@+,d2
- addxl d2,d0
-L3:
- dbra d1,L2 | (NB- dbra does not affect X)
-
- movl d0,d1 | fold 32 bit sum to 16 bits
- swap d1 | (NB- swap does not affect X)
- addxw d1,d0
- jcc L4
- addw #1,d0
-L4:
- andl #0xffff,d0
- movl sp@+,d2
- rts
-
-L5: | deal with 1 or 3 excess bytes at the end of the buffer.
- btst #1,d1
- jeq L6 | if 1 excess
-
- | 3 bytes excess
- clrl d2
- movw a0@(-3,d1:l),d2 | add in last full word then drop
- addl d2,d0 | through to pick up last byte
-
-L6: | 1 byte excess
- clrl d2
- movb a0@(-1,d1:l),d2
- lsll #8,d2
- addl d2,d0
- jra L1
-
-L7: | 2 bytes excess
- clrl d2
- movw a0@(-2,d1:l),d2
- addl d2,d0
- jra L1
diff --git a/sys/arch/mvme88k/stand/sboot/sboot.c b/sys/arch/mvme88k/stand/sboot/sboot.c
index 5ee58e6afd0..4094194c23c 100644
--- a/sys/arch/mvme88k/stand/sboot/sboot.c
+++ b/sys/arch/mvme88k/stand/sboot/sboot.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sboot.c,v 1.5 2012/12/05 23:20:14 deraadt Exp $ */
+/* $OpenBSD: sboot.c,v 1.6 2013/05/12 10:43:45 miod Exp $ */
/*
* Copyright (c) 1995 Theo de Raadt
@@ -54,116 +54,57 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/types.h>
-#include "sboot.h"
+#include <sys/param.h>
+#include <machine/prom.h>
-void
+#include "stand.h"
+#include "libsa.h"
+
+#include "config.h"
+
+extern const char *version;
+char line[128];
+
+int
main()
{
- char buf[128];
+ int howto, ret;
+ char *cp, *file;
- buf[0] = '0';
- printf("\nsboot: MVME147 bootstrap program\n");
- while (1) {
- printf(">>> ");
- gets(buf);
- do_cmd(buf);
- }
- /* not reached */
-}
+ board_setup();
-/*
- * exit to rom
- */
-void
-callrom()
-{
- asm("trap #15; .word 0x0063");
-}
+ printf("\n>> OpenBSD/mvme88k sboot [%s]\n", version);
-/*
- * do_cmd: do a command
- */
-void
-do_cmd(buf)
- char *buf;
-{
- switch (*buf) {
- case '\0':
- break;
- case 'a':
- if (rev_arp()) {
- printf("My ip address is: %d.%d.%d.%d\n", myip[0],
- myip[1], myip[2], myip[3]);
- printf("Server ip address is: %d.%d.%d.%d\n", servip[0],
- servip[1], servip[2], servip[3]);
- } else {
- printf("Failed.\n");
- }
- break;
- case 'q':
- printf("exiting to ROM\n");
- callrom();
- break;
- case 'f':
- if (do_get_file() == 1) {
- printf("Download Failed\n");
- } else {
- printf("Download was a success!\n");
- }
- break;
- case 'b':
- le_init();
- if (rev_arp()) {
- printf("client IP address %d.%d.%d.%d\n", myip[0],
- myip[1], myip[2], myip[3]);
- printf("server IP address %d.%d.%d.%d\n", servip[0],
- servip[1], servip[2], servip[3]);
- } else {
- printf("REVARP: Failed.\n");
- return;
- }
- if (do_get_file() == 1) {
- printf("Download Failed\n");
- return;
- } else {
- printf("received secondary boot program.\n");
- }
- if (*++buf == '\0')
- buf = "bsd";
- go(buf);
- break;
- case 'h':
- case '?':
- printf("valid commands\n");
- printf("a - send a RARP\n");
- printf("b - boot the system\n");
- printf("q - exit to ROM\n");
- printf("f - ftp the boot file\n");
- printf("g - execute the boot file\n");
- printf("h - help\n");
- printf("i - init LANCE enet chip\n");
- break;
- case 'i':
- le_init();
- break;
- case 'g':
- go(buf);
- break;
- default:
- printf("sboot: %s: Unknown command\n", buf);
+ if (probe_ethernet() == 0) {
+ printf("Sorry, no supported Ethernet device found\n");
+ return 1;
}
-}
-go(buf)
- char *buf;
-{
- void (*entry)() = (void (*))LOAD_ADDR;
+ /*
+ * Display Ethernet devices.
+ */
+ display_ethernet();
+
+ howto = 0;
- printf("jumping to boot program at 0x%x.\n", entry);
+ for (;;) {
+ printf("boot: ");
+ gets(line);
+ if (line[0]) {
+ bugargs.arg_start = line;
+ cp = line;
+ while (cp < (line + sizeof(line) - 1) && *cp)
+ cp++;
+ bugargs.arg_end = cp;
+ ret = parse_args(&file, &howto);
- asm("clrl d0; clrl d1"); /* XXX network device */
- asm("movl %0, a3" : : "a" (buf) : "a3");
- asm("movl %0, a4" : : "a" (buf + strlen(buf)) : "a4");
- asm("jmp %0@" : : "a" (entry));
+ if (ret) {
+ printf("returning to BUG\n");
+ break;
+ }
+ exec_mvme(file, howto);
+ printf("boot: %s: %s\n", file, strerror(errno));
+ }
+ }
+ return 0;
}
diff --git a/sys/arch/mvme88k/stand/sboot/sboot.h b/sys/arch/mvme88k/stand/sboot/sboot.h
deleted file mode 100644
index cae5e14f282..00000000000
--- a/sys/arch/mvme88k/stand/sboot/sboot.h
+++ /dev/null
@@ -1,97 +0,0 @@
-/* $OpenBSD: sboot.h,v 1.5 2006/05/16 22:52:26 miod Exp $ */
-
-/*
- * Copyright (c) 1995 Charles D. Cranor and Seth Widoff
- * 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 Charles D. Cranor
- * and Seth Widoff.
- * 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.
- */
-
-/*
- * sboot.h: stuff for MVME147's serial line boot
- */
-
-typedef unsigned short u_short;
-typedef unsigned long u_long;
-typedef unsigned char u_char;
-typedef unsigned int u_int;
-typedef u_long size_t;
-typedef char *caddr_t;
-extern caddr_t end;
-
-#define NULL ((char *)0)
-
-void bcopy(const void *, void *, size_t); /* libc_sa */
-void *memset(void *, int, size_t); /* libc_sa */
-int printf(const char *, ...); /* libc_sa */
-
-/* console */
-void puts(char *);
-void putchar(char);
-char cngetc(void);
-void ngets(char *, int);
-
-/* sboot */
-void callrom(void);
-void do_cmd(char *);
-
-/* le */
-#define LANCE_ADDR 0xfffe0778
-#define ERAM_ADDR 0xfffe0774
-#define LANCE_REG_ADDR 0xfffe1800
-void le_end(void);
-void le_init(void);
-int le_get(u_char *, size_t, u_long);
-int le_put(u_char *, size_t);
-
-/* etherfun */
-#define READ 0
-#define ACKN 1
-void do_rev_arp(void);
-int get_rev_arp(void);
-int rev_arp(void);
-void do_send_tftp(int);
-int do_get_file(void);
-void tftp_file(char *, u_long);
-
-/* clock */
-u_long time(void);
-
-/* checksum */
-u_long oc_cksum(void *, u_long, u_long);
-
-#define CONS_ZS_ADDR (0xfffe3002)
-#define CLOCK_ADDR (0xfffe07f8)
-#define LOAD_ADDR 0x7000
-
-unsigned char myea[6]; /* my ether addr */
-unsigned char myip[4];
-unsigned char servip[4];
-unsigned char servea[6];
-u_short myport;
-u_short servport;
-unsigned char reboot;
diff --git a/sys/arch/mvme88k/stand/sboot/srec.c b/sys/arch/mvme88k/stand/sboot/srec.c
deleted file mode 100644
index 88da9770543..00000000000
--- a/sys/arch/mvme88k/stand/sboot/srec.c
+++ /dev/null
@@ -1,159 +0,0 @@
-/* $OpenBSD: srec.c,v 1.3 2006/05/16 22:52:26 miod Exp $ */
-
-/*
- * Public domain, believed to be by Mike Price.
- *
- * convert binary file to Srecord format
- */
-#include <stdio.h>
-#include <ctype.h>
-
-int get32();
-void put32();
-void sput();
-void put();
-int checksum();
-
-int mask;
-int size;
-
-main(argc, argv)
- int argc;
- char *argv[];
-{
- char buf[32];
- int cc;
- int base;
- int addr;
- char *name;
-
- if (argc != 4) {
- fprintf(stderr, "usage: %s {size} {hex_addr} {name}\n", argv[0]);
- fprintf(stderr, "Size = 2, 3, or 4 byte address\n");
- exit(1);
- }
- sscanf(argv[1], "%x", &size);
- mask = (1 << (size * 8)) - 1;
- if (!mask)
- mask = (-1);
- sscanf(argv[2], "%x", &base);
- name = argv[3];
-
- if (size == 2)
- printf("S0%02X%04X", 2 + strlen(name) + 1, 0);
- if (size == 3)
- printf("S0%02X%06X", 3 + strlen(name) + 1, 0);
- if (size == 4)
- printf("S0%02X%08X", 4 + strlen(name) + 1, 0);
- sput(name);
- printf("%02X\n", checksum(0, name, strlen(name), size));
-
- addr = base;
- for (;;) {
- cc = get32(buf);
- if (cc > 0) {
- put32(cc, addr, buf, size, mask);
- addr += cc;
- } else
- break;
- }
-
- buf[0] = base >> 8;
- buf[1] = base;
- printf("S%d%02X", 11 - size, 2 + 1);
- switch (size) {
- case 2:
- printf("%04X", base & mask);
- break;
- case 3:
- printf("%06X", base & mask);
- break;
- case 4:
- printf("%08X", base & mask);
- break;
- }
-
- /*
- * kludge -> some sizes need an extra count (1 if size == 3, 2 if
- * size == 4). Don't ask why.
- */
- printf("%02X\n", checksum(base, (char *) 0, 0, size) +
- (size - 2));
- exit (0);
-}
-
-int
-get32(buf)
- char buf[];
-{
- char *cp = buf;
- int i;
- int c;
-
- for (i = 0; i < 32; ++i) {
- if ((c = getchar()) != EOF)
- *cp++ = c;
- else
- break;
- }
- return (cp - buf);
-}
-
-void
-put32(len, addr, buf, size, mask)
- int len;
- int addr;
- char buf[];
- int size, mask;
-{
- char *cp = buf;
- int i;
-
- if (size == 2)
- printf("S1%02X%04X", 2 + len + 1, addr & mask);
- if (size == 3)
- printf("S2%02X%06X", 3 + len + 1, addr & mask);
- if (size == 4)
- printf("S3%02X%08X", 4 + len + 1, addr & mask);
- for (i = 0; i < len; ++i)
- put(*cp++);
- printf("%02X\n", checksum(addr, buf, len, size));
-}
-
-void
-sput(s)
- char *s;
-{
- while (*s != '\0')
- put(*s++);
-}
-
-void
-put(c)
- int c;
-{
- printf("%02X", c & 0xff);
-}
-
-int
-checksum(addr, buf, len, size)
- int addr;
- char buf[];
- int len;
- int size;
-{
- char *cp = buf;
- int sum = 0xff - 1 - size - (len & 0xff);
- int i;
-
- if (size == 4)
- sum -= (addr >> 24) & 0xff;
- if (size >= 3)
- sum -= (addr >> 16) & 0xff;
- sum -= (addr >> 8) & 0xff;
- sum -= addr & 0xff;
- for (i = 0; i < len; ++i) {
- sum -= *cp++ & 0xff;
- }
- return (sum & 0xff);
-}
diff --git a/sys/arch/mvme88k/stand/sboot/version.c b/sys/arch/mvme88k/stand/sboot/version.c
new file mode 100644
index 00000000000..b48e3c2e71b
--- /dev/null
+++ b/sys/arch/mvme88k/stand/sboot/version.c
@@ -0,0 +1,6 @@
+/* $OpenBSD: version.c,v 1.1 2013/05/12 10:43:45 miod Exp $ */
+
+/*
+ * 1.1 Initial release
+ */
+const char *version = "1.1";