Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/luna68k/stand/boot Add support to pass boothowto an...
details: https://anonhg.NetBSD.org/src/rev/e2b6fec4def6
branches: trunk
changeset: 325904:e2b6fec4def6
user: tsutsui <tsutsui%NetBSD.org@localhost>
date: Sat Jan 11 08:08:23 2014 +0000
description:
Add support to pass boothowto and bootdev info from bootloader to kernel.
Bootloader side changes:
- make boot command parse boothowto flags (-ads etc.)
- pass boothowto and bootdev info to the kernel via %d7 and %d6
as the old 4.4BSD/luna68k kernel expected
- remove unused and now unnecessary "howto" (how_to_boot) command
- export and tweak make_device() in devopen.c to prepare bootdev info
- remove unused and commented out get_boot_device()
diffstat:
sys/arch/luna68k/stand/boot/boot.c | 153 ++++++++-----------------------
sys/arch/luna68k/stand/boot/conf.c | 9 +-
sys/arch/luna68k/stand/boot/devopen.c | 26 ++--
sys/arch/luna68k/stand/boot/init_main.c | 5 +-
sys/arch/luna68k/stand/boot/parse.c | 8 +-
sys/arch/luna68k/stand/boot/samachdep.h | 10 +-
6 files changed, 74 insertions(+), 137 deletions(-)
diffs (truncated from 386 to 300 lines):
diff -r 12ebf70b65b0 -r e2b6fec4def6 sys/arch/luna68k/stand/boot/boot.c
--- a/sys/arch/luna68k/stand/boot/boot.c Sat Jan 11 08:07:16 2014 +0000
+++ b/sys/arch/luna68k/stand/boot/boot.c Sat Jan 11 08:08:23 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: boot.c,v 1.5 2014/01/10 11:12:03 tsutsui Exp $ */
+/* $NetBSD: boot.c,v 1.6 2014/01/11 08:08:23 tsutsui Exp $ */
/*
* Copyright (c) 1992 OMRON Corporation.
@@ -76,6 +76,7 @@
*/
#include <sys/param.h>
+#include <sys/boot_flag.h>
#include <sys/reboot.h>
#include <sys/exec.h>
#include <luna68k/stand/boot/samachdep.h>
@@ -83,142 +84,68 @@
#include <luna68k/stand/boot/status.h>
#include <lib/libsa/loadfile.h>
-int howto;
-
-#if 0
-static int get_boot_device(const char *, int *, int *, int *);
-#endif
-
-struct exec header;
-
-char *how_to_info[] = {
- "RB_ASKNAME ask for file name to reboot from",
- "RB_SINGLE reboot to single user only",
- "RB_NOSYNC dont sync before reboot",
- "RB_HALT don't reboot, just halt",
- "RB_INITNAME name given for /etc/init (unused)",
- "RB_DFLTROOT use compiled-in rootdev",
- "RB_KDB give control to kernel debugger",
- "RB_RDONLY mount root fs read-only"
-};
-
-int
-how_to_boot(int argc, char *argv[])
-{
- int i, h = howto;
-
- if (argc < 2) {
- printf("howto: 0x%s\n\n", hexstr(howto, 2));
-
- if (h == 0) {
- printf("\t%s\n", "RB_AUTOBOOT flags for system auto-booting itself");
- } else {
- for (i = 0; i < 8; i++, h >>= 1) {
- if (h & 0x01) {
- printf("\t%s\n", how_to_info[i]);
- }
- }
- }
-
- printf("\n");
- }
- return ST_NORMAL;
-}
-
-#if 0
-int
-get_boot_device(const char *s, int *devp, int *unitp, int *partp)
-{
- const char *p = s;
- int unit, part;
-
- uint = 0;
- part = 0;
-
- while (*p != '(') {
- if (*p == '\0')
- goto error;
- p++;
- }
-
- p++;
- for (; *p != ',' && *p != ')') {
- if (*p == '\0')
- goto error;
- if (*p >= '0' && *p <= '9')
- unit = (unit * 10) + (*p - '0');
- }
-
- if (*p == ',')
- p++;
- for (; *p != ')'; p++) {
- if (*p == '\0')
- goto error;
- if (*p >= '0' && *p <= '9')
- part = (part * 10) + (*p - '0');
- }
-
- *devp = 0; /* XXX not yet */
- *unitp = unit;
- *partp = part;
-
- return 0;
-
-error:
- return -1;
-}
-#endif
-
int
boot(int argc, char *argv[])
{
- char *line;
+ char *line, *opts;
+ int i, howto;
+ char c;
- if (argc < 2)
+ line = NULL;
+ howto = 0;
+ for (i = 1; i < argc; i++) {
+ if (argv[i][0] == '-') {
+ opts = argv[i];
+ while ((c = *++opts) && c != '\0')
+ BOOT_FLAG(c, howto);
+ } else if (line == NULL)
+ line = argv[i];
+ }
+ if (line == NULL)
line = default_file;
- else
- line = argv[1];
- printf("Booting %s\n", line);
+ printf("Booting %s", line);
+ if (howto != 0)
+ printf(" (howto 0x%x)", howto);
+ printf("\n");
- return bootnetbsd(line);
+ return bootnetbsd(line, howto);
}
int
-bootnetbsd(char *line)
+bootnetbsd(char *line, int howto)
{
int io;
-#if 0
- int dev, unit, part;
-#endif
u_long marks[MARK_MAX];
- void (*entry)(void);
-
-#if 0
- if (get_boot_device(line, &dev, &unit, &part) != 0) {
- printf("Bad file name %s\n", line);
- return ST_ERROR;
- }
-#endif
/* Note marks[MARK_START] is passed as an load address offset */
memset(marks, 0, sizeof(marks));
io = loadfile(line, marks, LOAD_KERNEL);
if (io >= 0) {
+ int dev = 0, unit = 0, part = 0;
+ uint adpt, ctlr, id;
+ uint32_t bootdev;
+
+ make_device(line, &dev, &unit, &part, NULL);
+ adpt = dev2adpt[dev];
+ ctlr = CTLR(unit);
+ id = TARGET(unit);
+ bootdev = MAKEBOOTDEV(0, adpt, ctlr, id, part);
#ifdef DEBUG
printf("entry = 0x%lx\n", marks[MARK_ENTRY]);
printf("ssym = 0x%lx\n", marks[MARK_SYM]);
printf("esym = 0x%lx\n", marks[MARK_END]);
#endif
-
- /*
- * XXX TODO: fill bootinfo about symbols, boot device etc.
- */
-
- entry = (void *)marks[MARK_ENTRY];
-
- (*entry)();
+ __asm volatile (
+ "movl %0,%%d7;"
+ "movl %1,%%d6;"
+ "movl %2,%%a0;"
+ "jbsr %%a0@"
+ :
+ : "g" (howto), "g" (bootdev),
+ "g" ((void *)marks[MARK_ENTRY])
+ : "d6", "d7", "a0");
}
printf("Booting kernel failed. (%s)\n", strerror(errno));
diff -r 12ebf70b65b0 -r e2b6fec4def6 sys/arch/luna68k/stand/boot/conf.c
--- a/sys/arch/luna68k/stand/boot/conf.c Sat Jan 11 08:07:16 2014 +0000
+++ b/sys/arch/luna68k/stand/boot/conf.c Sat Jan 11 08:08:23 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: conf.c,v 1.3 2013/01/16 15:46:20 tsutsui Exp $ */
+/* $NetBSD: conf.c,v 1.4 2014/01/11 08:08:23 tsutsui Exp $ */
/*
* Copyright (c) 1982, 1986, 1990, 1993
@@ -43,6 +43,7 @@
#include <lib/libsa/nfs.h>
#include <lib/libsa/ufs.h>
+#include <machine/bootinfo.h>
#include <luna68k/stand/boot/samachdep.h>
#define xxstrategy \
@@ -80,6 +81,12 @@
};
int ndevs = __arraycount(devsw);
+/* XXX: These indices must sync with the above devsw */
+const int dev2adpt[] = {
+ LUNA68K_BOOTADPT_SPC,
+ LUNA68K_BOOTADPT_LANCE,
+};
+
#ifdef SUPPORT_ETHERNET
extern struct netif_driver le_netif_driver;
struct netif_driver *netif_drivers[] = {
diff -r 12ebf70b65b0 -r e2b6fec4def6 sys/arch/luna68k/stand/boot/devopen.c
--- a/sys/arch/luna68k/stand/boot/devopen.c Sat Jan 11 08:07:16 2014 +0000
+++ b/sys/arch/luna68k/stand/boot/devopen.c Sat Jan 11 08:08:23 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: devopen.c,v 1.5 2014/01/10 11:12:03 tsutsui Exp $ */
+/* $NetBSD: devopen.c,v 1.6 2014/01/11 08:08:23 tsutsui Exp $ */
/*
* Copyright (c) 1992 OMRON Corporation.
@@ -76,8 +76,6 @@
#define MAXDEVNAME 16
-static int make_device(const char *, int *, int *, int *, char **);
-
int
devopen(struct open_file *f, const char *fname, char **file)
{
@@ -125,7 +123,7 @@
{
const char *cp;
struct devsw *dp;
- int major, unit = 0, part = 0;
+ int dev, unit = 0, part = 0;
int i;
char devname[MAXDEVNAME + 1];
@@ -147,7 +145,7 @@
if (dp->dv_name == NULL) {
return (-1);
}
- major = dp - devsw;
+ dev = dp - devsw;
/* get mixed controller and unit number */
for (; *cp != ',' && *cp != ')'; cp++) {
if (*cp == '\0')
@@ -178,17 +176,19 @@
return (-1);
}
/* check out end of dev spec */
- *devp = major;
+ *devp = dev;
*unitp = unit;
*partp = part;
- cp++;
- if (*cp == '\0')
- *fname = "netbsd";
- else
- *fname = __UNCONST(cp); /* XXX */
+ if (fname != NULL) {
+ cp++;
+ if (*cp == '\0')
+ *fname = "netbsd";
+ else
+ *fname = __UNCONST(cp); /* XXX */
+ }
#ifdef DEBUG
- printf("%s: major = %d, unit = %d, part = %d, fname = %s\n",
- __func__, major, unit, part, *fname);
+ printf("%s: dev = %d, unit = %d, part = %d, fname = %s\n",
+ __func__, dev, unit, part, fname != NULL ? *fname : "");
#endif
return 0;
diff -r 12ebf70b65b0 -r e2b6fec4def6 sys/arch/luna68k/stand/boot/init_main.c
--- a/sys/arch/luna68k/stand/boot/init_main.c Sat Jan 11 08:07:16 2014 +0000
+++ b/sys/arch/luna68k/stand/boot/init_main.c Sat Jan 11 08:08:23 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: init_main.c,v 1.9 2014/01/10 11:12:03 tsutsui Exp $ */
+/* $NetBSD: init_main.c,v 1.10 2014/01/11 08:08:23 tsutsui Exp $ */
/*
Home |
Main Index |
Thread Index |
Old Index