summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2013-10-29 22:13:29 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2013-10-29 22:13:29 +0000
commitb0946c8d4a4f54a184639a1847fb7819e45d395f (patch)
tree74c310b95834a9c955ee03aa358dc40fca047094 /sys
parent7bccb952d754b43da6325a72cde4c099ca1898d1 (diff)
Get boot device and partition from NVRAM. Boot filename still defaults to
"bsd", since the PROM boot_filename has to point to the bootloader itself (I store mine as /vmunix).
Diffstat (limited to 'sys')
-rw-r--r--sys/arch/luna88k/stand/boot/Makefile17
-rw-r--r--sys/arch/luna88k/stand/boot/conf.c16
-rw-r--r--sys/arch/luna88k/stand/boot/cons.c144
-rw-r--r--sys/arch/luna88k/stand/boot/init_main.c127
4 files changed, 136 insertions, 168 deletions
diff --git a/sys/arch/luna88k/stand/boot/Makefile b/sys/arch/luna88k/stand/boot/Makefile
index 6cdac46e7aa..209edc213d1 100644
--- a/sys/arch/luna88k/stand/boot/Makefile
+++ b/sys/arch/luna88k/stand/boot/Makefile
@@ -1,11 +1,10 @@
-# $OpenBSD: Makefile,v 1.2 2013/10/29 21:49:07 miod Exp $
+# $OpenBSD: Makefile,v 1.3 2013/10/29 22:13:28 miod Exp $
# $NetBSD: Makefile,v 1.9 2013/01/22 15:48:40 tsutsui Exp $
# @(#)Makefile 8.2 (Berkeley) 8/15/93
NOMAN= # defined
S= ${.CURDIR}/../../../..
-LIBSADIR= ${S}/lib/libsa
CPPFLAGS+= -nostdinc -D_STANDALONE
CPPFLAGS+= -I${.CURDIR} -I${.OBJDIR} -I${S} -I${S}/arch
@@ -42,15 +41,17 @@ SRCS+= dev_net.c
PROG= boot
-NEWVERSWHAT= "${PROG}"
-
### find out what to use for libkern
.PATH: ${S}/lib/libkern
SRCS+= memcpy.c strlen.c
SRCS+= muldi3.c negdi2.c ashrdi3.c
### find out what to use for libsa
+.PATH: ${S}/lib/libsa
+SRCS+= strtol.c
+
SAREL=
+SADST= .
USE_LOADFILE= yes
.include "${S}/lib/libsa/Makefile.inc"
@@ -62,14 +63,6 @@ ${PROG}: ${LDSCRIPT} ${OBJS} ${LIBS}
CLEANFILES+= ${PROG}.elf
-plop:
- echo ${OBJS}
-
-cleandir distclean: cleanlibdir
-
-cleanlibdir:
- -rm -rf lib
-
.if ${MACHINE} != "luna88k"
.if !make(obj)
.BEGIN:
diff --git a/sys/arch/luna88k/stand/boot/conf.c b/sys/arch/luna88k/stand/boot/conf.c
index 8fdf488d7af..aaa41d3b17c 100644
--- a/sys/arch/luna88k/stand/boot/conf.c
+++ b/sys/arch/luna88k/stand/boot/conf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: conf.c,v 1.1 2013/10/28 22:13:12 miod Exp $ */
+/* $OpenBSD: conf.c,v 1.2 2013/10/29 22:13:28 miod Exp $ */
/* $NetBSD: conf.c,v 1.3 2013/01/16 15:46:20 tsutsui Exp $ */
/*
@@ -35,6 +35,8 @@
#include <sys/param.h>
#include <sys/socket.h>
+#include <dev/cons.h>
+
#include <net/if.h>
#include <netinet/in.h>
#include <netinet/in_systm.h>
@@ -110,3 +112,15 @@ struct fs_ops file_system_nfs[] = { FS_OPS(nfs) };
#define MAX_NFSYS 5
struct fs_ops file_system[MAX_NFSYS];
int nfsys = 1; /* we always know which one we want */
+
+/*
+ * Console configuration
+ */
+
+struct consdev constab[] = {
+ { bmccnprobe, bmccninit, bmccngetc, bmccnputc },
+ { siocnprobe, siocninit, siocngetc, siocnputc },
+ { 0 },
+};
+
+struct consdev *cn_tab;
diff --git a/sys/arch/luna88k/stand/boot/cons.c b/sys/arch/luna88k/stand/boot/cons.c
deleted file mode 100644
index 723d2352cf5..00000000000
--- a/sys/arch/luna88k/stand/boot/cons.c
+++ /dev/null
@@ -1,144 +0,0 @@
-/* $OpenBSD: cons.c,v 1.1 2013/10/28 22:13:12 miod Exp $ */
-/* $NetBSD: cons.c,v 1.1 2013/01/05 17:44:24 tsutsui Exp $ */
-
-/*
- * Copyright (c) 1992 OMRON Corporation.
- *
- * This code is derived from software contributed to Berkeley by
- * OMRON Corporation.
- *
- * 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.
- *
- * @(#)cons.c 8.1 (Berkeley) 6/10/93
- */
-/*
- * Copyright (c) 1992, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * OMRON Corporation.
- *
- * 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.
- *
- * @(#)cons.c 8.1 (Berkeley) 6/10/93
- */
-
-#include <sys/param.h>
-#include <dev/cons.h>
-#include <luna88k/stand/boot/samachdep.h>
-
-#define NBMC 1
-#define NSIO 1
-#define NROM 0 /* XXX doesn't work with framebuffer/keyboard? */
-
-/* XXX - all this could be autoconfig()ed */
-
-struct consdev constab[] = {
-#if NBMC > 0
- { bmccnprobe, bmccninit, bmccngetc, bmccnputc },
-#endif
-#if NSIO > 0
- { siocnprobe, siocninit, siocngetc, siocnputc },
-#endif
-#if NROM > 0
- { romcnprobe, romcninit, romcngetc, romcnputc },
-#endif
- { 0 },
-};
-/* end XXX */
-
-struct consdev *cn_tab; /* physical console device info */
-
-void
-cninit(void)
-{
- struct consdev *cp;
-
- /*
- * Collect information about all possible consoles
- * and find the one with highest priority
- */
- for (cp = constab; cp->cn_probe; cp++) {
- (*cp->cn_probe)(cp);
- if (cp->cn_pri > CN_DEAD &&
- (cn_tab == NULL || cp->cn_pri > cn_tab->cn_pri))
- cn_tab = cp;
- }
- /*
- * No console, we can handle it
- */
- if ((cp = cn_tab) == NULL)
- return;
- /*
- * Turn on console
- */
- (*cp->cn_init)(cp);
-}
-
-int
-cngetc(void)
-{
- if (cn_tab == NULL)
- return(0);
- return((*cn_tab->cn_getc)(cn_tab->cn_dev));
-}
-
-void
-cnputc(int c)
-{
- if (cn_tab == NULL)
- return;
- if (c) {
- (*cn_tab->cn_putc)(cn_tab->cn_dev, c);
- if (c == '\n')
- (*cn_tab->cn_putc)(cn_tab->cn_dev, '\r');
- }
-}
diff --git a/sys/arch/luna88k/stand/boot/init_main.c b/sys/arch/luna88k/stand/boot/init_main.c
index d7741edded0..517f6f13a24 100644
--- a/sys/arch/luna88k/stand/boot/init_main.c
+++ b/sys/arch/luna88k/stand/boot/init_main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: init_main.c,v 1.3 2013/10/29 21:49:07 miod Exp $ */
+/* $OpenBSD: init_main.c,v 1.4 2013/10/29 22:13:28 miod Exp $ */
/* $NetBSD: init_main.c,v 1.6 2013/03/05 15:34:53 tsutsui Exp $ */
/*
@@ -70,6 +70,32 @@
*
* @(#)init_main.c 8.2 (Berkeley) 8/15/93
*/
+/*
+ * Mach Operating System
+ * Copyright (c) 1993-1991 Carnegie Mellon University
+ * Copyright (c) 1991 OMRON Corporation
+ * 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 <sys/param.h>
#include <machine/board.h>
@@ -79,7 +105,9 @@
#include "dev_net.h"
static void get_fuse_rom_data(void);
+static void get_nvram_data(void);
static int get_plane_numbers(void);
+static const char *nvram_by_symbol(char *);
int cpuspeed; /* for DELAY() macro */
int machtype;
@@ -116,11 +144,20 @@ struct fuse_rom_byte {
#define FUSE_ROM_BYTES (FUSE_ROM_SPACE / sizeof(struct fuse_rom_byte))
char fuse_rom_data[FUSE_ROM_BYTES];
+#define NNVSYM 8
+#define NVSYMLEN 16
+#define NVVALLEN 16
+struct nvram_t {
+ char symbol[1 + NVSYMLEN];
+ char value[1 + NVVALLEN];
+} nvram[NNVSYM];
+
int
main(void)
{
int status = ST_NORMAL;
const char *machstr;
+ const char *nvv;
int unit, part;
/* Determine the machine type from FUSE ROM data. */
@@ -141,24 +178,33 @@ main(void)
cpuspeed = MHZ_33;
}
- nplane = get_plane_numbers();
-
+ nplane = get_plane_numbers();
cninit();
- printf("\nOpenBSD/%s boot 0.2\n\n", machstr);
-
- /*
- * IO configuration
- */
+ printf("\nOpenBSD/%s boot 0.3\n\n", machstr);
#ifdef SUPPORT_ETHERNET
try_bootp = 1;
#endif
- unit = 0; /* XXX should parse monitor's Boot-file constant */
- part = 0;
+ /* Determine the 'auto-boot' device from NVRAM data */
+ get_nvram_data();
+
+ nvv = nvram_by_symbol("boot_unit");
+ if (nvv != NULL)
+ unit = (int)strtol(nvv, NULL, 10);
+ else
+ unit = 0;
+ nvv = nvram_by_symbol("boot_partition");
+ if (nvv != NULL)
+ part = (int)strtol(nvv, NULL, 10);
+ else
+ part = 0;
+
+ nvv = nvram_by_symbol("boot_device");
+
snprintf(default_file, sizeof(default_file),
- "sd(%d,%d)%s", unit, part, "bsd");
+ "%s(%d,%d)%s", nvv != NULL ? nvv : "sd", unit, part, "bsd");
/* auto-boot? (SW1) */
if ((dipswitch & 0x8000) != 0) {
@@ -224,6 +270,65 @@ get_fuse_rom_data(void)
}
}
+/* Get data from NVRAM */
+
+void
+get_nvram_data(void)
+{
+ int i, j;
+ u_int8_t *page;
+ char buf[NVSYMLEN], *data;
+
+ if (machtype == LUNA_88K) {
+ data = (char *)(NVRAM_ADDR + 0x80);
+
+ for (i = 0; i < NNVSYM; i++) {
+ for (j = 0; j < NVSYMLEN; j++) {
+ buf[j] = *data;
+ data += 4;
+ }
+ strncpy(nvram[i].symbol, buf, sizeof(nvram[i].symbol));
+
+ for (j = 0; j < NVVALLEN; j++) {
+ buf[j] = *data;
+ data += 4;
+ }
+ strncpy(nvram[i].value, buf, sizeof(nvram[i].value));
+ }
+ } else if (machtype == LUNA_88K2) {
+ page = (u_int8_t *)(NVRAM_ADDR_88K2 + 0x20);
+
+ for (i = 0; i < NNVSYM; i++) {
+ *page = (u_int8_t)i;
+
+ data = (char *)NVRAM_ADDR_88K2;
+ strncpy(nvram[i].symbol, data, sizeof(nvram[i].symbol));
+
+ data = (char *)(NVRAM_ADDR_88K2 + 0x10);
+ strncpy(nvram[i].value, data, sizeof(nvram[i].value));
+ }
+ }
+}
+
+const char *
+nvram_by_symbol(symbol)
+ char *symbol;
+{
+ const char *value;
+ int i;
+
+ value = NULL;
+
+ for (i = 0; i < NNVSYM; i++) {
+ if (strncmp(nvram[i].symbol, symbol, NVSYMLEN) == 0) {
+ value = nvram[i].value;
+ break;
+ }
+ }
+
+ return value;
+}
+
void
_rtt(void)
{