summaryrefslogtreecommitdiff
path: root/sys/arch/mvme88k
diff options
context:
space:
mode:
Diffstat (limited to 'sys/arch/mvme88k')
-rw-r--r--sys/arch/mvme88k/include/prom.h44
-rw-r--r--sys/arch/mvme88k/stand/libbug/Makefile5
-rw-r--r--sys/arch/mvme88k/stand/libbug/libbug.h4
-rw-r--r--sys/arch/mvme88k/stand/libbug/netcfig.c15
-rw-r--r--sys/arch/mvme88k/stand/libbug/netctrl.c15
-rw-r--r--sys/arch/mvme88k/stand/tftpboot/netdev.c67
-rw-r--r--sys/arch/mvme88k/stand/tftpboot/version.c7
7 files changed, 149 insertions, 8 deletions
diff --git a/sys/arch/mvme88k/include/prom.h b/sys/arch/mvme88k/include/prom.h
index 6eb3116a01e..12762f11942 100644
--- a/sys/arch/mvme88k/include/prom.h
+++ b/sys/arch/mvme88k/include/prom.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: prom.h,v 1.19 2011/03/23 16:54:36 pirofti Exp $ */
+/* $OpenBSD: prom.h,v 1.20 2012/11/25 14:10:47 miod Exp $ */
/*
* Copyright (c) 1998 Steve Murphree, Jr.
* Copyright (c) 1996 Nivas Madhur
@@ -43,6 +43,7 @@
#define MVMEPROM_DSKCFIG 0x12
#define MVMEPROM_DSKFMT 0x14
#define MVMEPROM_DSKCTRL 0x15
+#define MVMEPROM_NETCFIG 0x1a
#define MVMEPROM_NETFOPEN 0x1b
#define MVMEPROM_NETFREAD 0x1c
#define MVMEPROM_NETCTRL 0x1d
@@ -59,7 +60,16 @@
#define MVMEPROM_ENVIRON 0x71
#define MVMEPROM_FORKMPU 0x100
+#define NETCFIG_READ 1
+#define NETCFIG_WRITE 2
+#define NETCFIG_STORE 4
+
+#define NETCTRLCMD_INITIALIZE 0
#define NETCTRLCMD_GETETHER 1
+#define NETCTRLCMD_XMIT 2
+#define NETCTRLCMD_RECV 3
+#define NETCTRLCMD_FLUSH 4
+#define NETCTRLCMD_RESET 5
#define ENVIRONCMD_WRITE 1
#define ENVIRONCMD_READ 2
@@ -75,6 +85,38 @@
#define FORKMPU_NO_MPU -3
#ifndef LOCORE
+struct mvmeprom_netcfig {
+ u_char ctrl;
+ u_char dev;
+ u_short status;
+ u_long ncp_addr;
+ u_long dcp_addr;
+ u_long flags;
+};
+
+struct mvmeprom_ncp {
+ u_long magic;
+#define NETCFIG_MAGIC 0x12301983
+ u_long node_memory_address;
+ u_long boot_load_address;
+ u_long boot_start_address;
+ u_long boot_start_delay;
+ u_long boot_length;
+ u_long boot_offset;
+ u_long trace_buffer_address;
+ u_long client_ip;
+ u_long server_ip;
+ u_long subnet_mask;
+ u_long broadcast_mask;
+ u_long gateway_ip;
+ u_char bootp_retry;
+ u_char tftp_retry;
+ char rarp_control;
+ char update_control;
+ char filename[64];
+ char commandline[64];
+};
+
struct mvmeprom_netctrl {
u_char ctrl;
u_char dev;
diff --git a/sys/arch/mvme88k/stand/libbug/Makefile b/sys/arch/mvme88k/stand/libbug/Makefile
index 7d247a24b3e..8ba44eb6705 100644
--- a/sys/arch/mvme88k/stand/libbug/Makefile
+++ b/sys/arch/mvme88k/stand/libbug/Makefile
@@ -1,4 +1,4 @@
-# $OpenBSD: Makefile,v 1.8 2012/08/21 14:46:19 pascal Exp $
+# $OpenBSD: Makefile,v 1.9 2012/11/25 14:10:47 miod Exp $
LIB=bug
@@ -12,7 +12,8 @@ DIR_SA=$S/lib/libsa
CFLAGS+=-I${.CURDIR}/../../include -I${DIR_SA}
SRCS= delay.c diskrd.c diskwr.c getbrdid.c inchr.c instat.c \
- netfopen.c netfread.c outln.c outstr.c putchar.c return.c rtc_rd.c
+ netcfig.c netctrl.c netfopen.c netfread.c outln.c outstr.c putchar.c \
+ return.c rtc_rd.c
install:
diff --git a/sys/arch/mvme88k/stand/libbug/libbug.h b/sys/arch/mvme88k/stand/libbug/libbug.h
index ff3e7fdd315..a63828794e1 100644
--- a/sys/arch/mvme88k/stand/libbug/libbug.h
+++ b/sys/arch/mvme88k/stand/libbug/libbug.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: libbug.h,v 1.6 2008/04/02 21:53:18 miod Exp $ */
+/* $OpenBSD: libbug.h,v 1.7 2012/11/25 14:10:47 miod Exp $ */
/*
* prototypes and such. note that get/put char are in stand.h
@@ -8,6 +8,8 @@ void mvmeprom_delay(int);
int mvmeprom_diskrd(struct mvmeprom_dskio *);
int mvmeprom_diskwr(struct mvmeprom_dskio *);
struct mvmeprom_brdid *mvmeprom_brdid(void);
+int mvmeprom_netcfig(struct mvmeprom_netcfig *);
+int mvmeprom_netctrl(struct mvmeprom_netctrl *);
int mvmeprom_netfopen(struct mvmeprom_netfopen *);
int mvmeprom_netfread(struct mvmeprom_netfread *);
void mvmeprom_outln(char *, char *);
diff --git a/sys/arch/mvme88k/stand/libbug/netcfig.c b/sys/arch/mvme88k/stand/libbug/netcfig.c
new file mode 100644
index 00000000000..27a8b6e7cf7
--- /dev/null
+++ b/sys/arch/mvme88k/stand/libbug/netcfig.c
@@ -0,0 +1,15 @@
+/* $OpenBSD: netcfig.c,v 1.1 2012/11/25 14:10:47 miod Exp $ */
+/* public domain */
+
+#include <sys/types.h>
+#include <machine/prom.h>
+
+#include "prom.h"
+
+int
+mvmeprom_netcfig(struct mvmeprom_netcfig *cfg)
+{
+ asm volatile ("or r2,r0,%0": : "r" (cfg));
+ MVMEPROM_CALL(MVMEPROM_NETCFIG);
+ return cfg->status;
+}
diff --git a/sys/arch/mvme88k/stand/libbug/netctrl.c b/sys/arch/mvme88k/stand/libbug/netctrl.c
new file mode 100644
index 00000000000..218dbcc2b86
--- /dev/null
+++ b/sys/arch/mvme88k/stand/libbug/netctrl.c
@@ -0,0 +1,15 @@
+/* $OpenBSD: netctrl.c,v 1.1 2012/11/25 14:10:47 miod Exp $ */
+/* public domain */
+
+#include <sys/types.h>
+#include <machine/prom.h>
+
+#include "prom.h"
+
+int
+mvmeprom_netctrl(struct mvmeprom_netctrl *ctrl)
+{
+ asm volatile ("or r2,r0,%0": : "r" (ctrl));
+ MVMEPROM_CALL(MVMEPROM_NETCTRL);
+ return ctrl->status;
+}
diff --git a/sys/arch/mvme88k/stand/tftpboot/netdev.c b/sys/arch/mvme88k/stand/tftpboot/netdev.c
index 9bb15ec9d5c..50020b0aa88 100644
--- a/sys/arch/mvme88k/stand/tftpboot/netdev.c
+++ b/sys/arch/mvme88k/stand/tftpboot/netdev.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: netdev.c,v 1.3 2011/03/13 00:13:53 deraadt Exp $ */
+/* $OpenBSD: netdev.c,v 1.4 2012/11/25 14:10:47 miod Exp $ */
/*
* Copyright (c) 1993 Paul Kranenburg
@@ -101,14 +101,77 @@ int
net_open(struct open_file *f, ...)
{
va_list ap;
+ struct mvmeprom_netcfig ncfg;
struct mvmeprom_netfopen nfo;
+ struct mvmeprom_ncp ncp;
+#if 0
+ struct mvmeprom_netctrl nctrl;
+#endif
struct bugdev_softc *pp = (struct bugdev_softc *)f->f_devdata;
char *filename;
+ const char *failure = NULL;
va_start(ap, f);
filename = va_arg(ap, char *);
va_end(ap);
+ /*
+ * It seems that, after loading tftpboot from the network, the BUG
+ * will reset its current network settings before giving us control
+ * of the system. This causes any network parameter not stored in
+ * the NIOT area to be lost. However, unless we force the `always
+ * send a reverse arp request' setting is set, the BUG will `believe'
+ * it doesn't need to send any (because it had to in order to load
+ * this code), and will fail to connect to the tftp server.
+ *
+ * Unfortunately, updating the in-memory network configuration to
+ * force reverse arp requests to be sent always doesn't work, even
+ * after issueing a `reset device' command.
+ *
+ * The best we can do is recognize this situation, warn the user
+ * and return to the BUG.
+ */
+
+ bzero(&ncp, sizeof ncp);
+ ncfg.ctrl = pp->clun;
+ ncfg.dev = pp->dlun;
+ ncfg.ncp_addr = (u_long)&ncp;
+ ncfg.flags = NETCFIG_READ;
+ if (mvmeprom_netcfig(&ncfg) == 0 && ncp.magic == NETCFIG_MAGIC) {
+ if (ncp.rarp_control != 'A' && ncp.client_ip == 0) {
+#if 0
+ ncp.rarp_control = 'A';
+ ncp.update_control = 'Y';
+
+ bzero(&ncp, sizeof ncp);
+ ncfg.ctrl = pp->clun;
+ ncfg.dev = pp->dlun;
+ ncfg.ncp_addr = (u_long)&ncp;
+ ncfg.flags = NETCFIG_WRITE;
+
+ if (mvmeprom_netcfig(&ncfg) == 0) {
+ bzero(&nctrl, sizeof nctrl);
+ nctrl.ctrl = pp->clun;
+ nctrl.dev = pp->dlun;
+ nctrl.cmd = NETCTRLCMD_RESET;
+ if (mvmeprom_netctrl(&nctrl) != 0)
+ failure = "reset network interface";
+ } else
+ failure = "update NIOT configuration";
+#else
+ printf("Invalid network configuration\n"
+ "Please update the NIOT parameters and set\n"
+ "``BOOTP/RARP Request Control: Always/When-Needed (A/W)'' to `A'\n");
+ _rtt();
+#endif
+ }
+ } else
+ failure = "read NIOT configuration";
+
+ if (failure != NULL)
+ printf("failed to %s (0x%x), "
+ "hope RARP is set to `A'lways\n", failure, ncfg.status);
+
nfo.ctrl = pp->clun;
nfo.dev = pp->dlun;
nfo.status = 0;
@@ -116,7 +179,7 @@ net_open(struct open_file *f, ...)
mvmeprom_netfopen(&nfo);
#ifdef DEBUG
- printf("tftp open(%s): error %x\n", filename, nfo.status);
+ printf("tftp open(%s): 0x%x\n", filename, nfo.status);
#endif
return (nfo.status);
}
diff --git a/sys/arch/mvme88k/stand/tftpboot/version.c b/sys/arch/mvme88k/stand/tftpboot/version.c
index 27c1364858c..97248c0589e 100644
--- a/sys/arch/mvme88k/stand/tftpboot/version.c
+++ b/sys/arch/mvme88k/stand/tftpboot/version.c
@@ -1,6 +1,9 @@
-/* $OpenBSD: version.c,v 1.6 2009/01/18 21:49:11 miod Exp $ */
+/* $OpenBSD: version.c,v 1.7 2012/11/25 14:10:47 miod Exp $ */
/*
+ * 1.7 recognize non-working NIOT configuration and ask the user to
+ * correct it instead of failing to boot silently
+ * tftp server
* 1.6 allocation area changed to fix netboot buffers overwriting stack
* 1.5 perform MVME197 busswitch initialization
* 1.4 rewritten crt code, self-relocatable
@@ -8,4 +11,4 @@
* 1.2 rewritten startup code and general cleanup
* 1.1 initial revision
*/
-char *version = "1.6";
+char *version = "1.7";