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()
This commit is contained in:
parent
1a578d633f
commit
1b293e5d49
|
@ -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));
|
||||
|
||||
|
|
|
@ -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 @@ struct devsw devsw[] = {
|
|||
};
|
||||
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[] = {
|
||||
|
|
|
@ -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 @@ make_device(const char *str, int *devp, int *unitp, int *partp, char **fname)
|
|||
{
|
||||
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 @@ make_device(const char *str, int *devp, int *unitp, int *partp, char **fname)
|
|||
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 @@ make_device(const char *str, int *devp, int *unitp, int *partp, char **fname)
|
|||
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;
|
||||
|
|
|
@ -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 $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1992 OMRON Corporation.
|
||||
|
@ -179,6 +179,7 @@ main(void)
|
|||
int i, status = 0;
|
||||
const char *machstr;
|
||||
const char *bootdev;
|
||||
uint32_t howto;
|
||||
int unit, part;
|
||||
int bdev, ctlr, id;
|
||||
|
||||
|
@ -307,7 +308,7 @@ main(void)
|
|||
c = awaitkey("%d seconds. ", boot_timeout, true);
|
||||
if (c == '\r' || c == '\n' || c == 0) {
|
||||
printf("auto-boot %s\n", default_file);
|
||||
bootnetbsd(default_file);
|
||||
bootnetbsd(default_file, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: parse.c,v 1.4 2013/01/22 15:48:40 tsutsui Exp $ */
|
||||
/* $NetBSD: parse.c,v 1.5 2014/01/11 08:08:23 tsutsui Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1992 OMRON Corporation.
|
||||
|
@ -100,8 +100,9 @@ exit_program(int argc, char *argv[])
|
|||
|
||||
static const char helpmsg[] =
|
||||
"commands are:\n"
|
||||
"boot [device(unit,part)filename]\n"
|
||||
" (ex. \"boot sd(0,0)netbsd\", \"boot le(0,0)netbsd.old\" etc.)\n"
|
||||
"boot [device(unit,part)filename] [-ads]\n"
|
||||
" (ex. \"boot sd(6,0)netbsd\", \"boot le()netbsd.old\" etc.)\n"
|
||||
" Note unit number for SCSI device is (ctlr) * 10 + (id)."
|
||||
"ls [device(unit, part)[path]]\n"
|
||||
" (ex. \"ls sd(0,0)/bin\")\n"
|
||||
"help\n"
|
||||
|
@ -139,7 +140,6 @@ struct command_entry entries[] = {
|
|||
{ "fsrestore", fsrestore },
|
||||
#endif
|
||||
{ "help", cmd_help },
|
||||
{ "howto", how_to_boot },
|
||||
{ "ls", cmd_ls },
|
||||
{ "screen", screen },
|
||||
#ifdef notyet
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: samachdep.h,v 1.15 2014/01/10 11:12:03 tsutsui Exp $ */
|
||||
/* $NetBSD: samachdep.h,v 1.16 2014/01/11 08:08:23 tsutsui Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1982, 1990, 1993
|
||||
|
@ -54,6 +54,7 @@ typedef struct label_t {
|
|||
/* autoconf.c */
|
||||
void configure(void);
|
||||
void find_devs(void);
|
||||
extern const int dev2adpt[];
|
||||
|
||||
/* awaitkey.c */
|
||||
char awaitkey(const char *, int, bool);
|
||||
|
@ -71,10 +72,8 @@ void bmdadjust(short, short);
|
|||
void bmdclear(void);
|
||||
|
||||
/* boot.c */
|
||||
extern int howto;
|
||||
int how_to_boot(int, char **);
|
||||
int boot(int, char **);
|
||||
int bootnetbsd(char *);
|
||||
int bootnetbsd(char *, int);
|
||||
|
||||
/* clock.c */
|
||||
/* not yet */
|
||||
|
@ -84,6 +83,9 @@ void cninit(void);
|
|||
int cngetc(void);
|
||||
void cnputc(int);
|
||||
|
||||
/* devopen.c */
|
||||
int make_device(const char *, int *, int *, int *, char **);
|
||||
|
||||
/* disklabel.c */
|
||||
extern u_char lbl_buff[];
|
||||
int disklabel(int, char **);
|
||||
|
|
Loading…
Reference in New Issue