Parse bootflags and attempt to find the root device from the boot command line
This commit is contained in:
parent
bf69eb6def
commit
4cad781e16
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: autoconf.h,v 1.2 2000/08/15 04:56:45 wdk Exp $ */
|
/* $NetBSD: autoconf.h,v 1.3 2000/08/16 21:54:43 wdk Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1994, 1995 Carnegie-Mellon University.
|
* Copyright (c) 1994, 1995 Carnegie-Mellon University.
|
||||||
@ -27,6 +27,9 @@
|
|||||||
* rights to redistribute these changes.
|
* rights to redistribute these changes.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifndef _MIPSCO_AUTOCONF_H_
|
||||||
|
#define _MIPSCO_AUTOCONF_H_
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Machine-dependent structures of autoconfiguration
|
* Machine-dependent structures of autoconfiguration
|
||||||
*/
|
*/
|
||||||
@ -47,3 +50,6 @@ struct confargs {
|
|||||||
#define cf_addr cf_loc[0]
|
#define cf_addr cf_loc[0]
|
||||||
|
|
||||||
int badaddr __P((void *, u_int));
|
int badaddr __P((void *, u_int));
|
||||||
|
void makebootdev __P((char *));
|
||||||
|
|
||||||
|
#endif /* !_MIPSCO_AUTOCONF_H_ */
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: autoconf.c,v 1.2 2000/08/15 04:56:46 wdk Exp $ */
|
/* $NetBSD: autoconf.c,v 1.3 2000/08/16 21:54:44 wdk Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1988 University of Utah.
|
* Copyright (c) 1988 University of Utah.
|
||||||
@ -65,6 +65,7 @@
|
|||||||
|
|
||||||
#include <machine/cpu.h>
|
#include <machine/cpu.h>
|
||||||
#include <machine/mainboard.h>
|
#include <machine/mainboard.h>
|
||||||
|
#include <machine/autoconf.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The following several variables are related to
|
* The following several variables are related to
|
||||||
@ -113,7 +114,9 @@ cpu_rootconf()
|
|||||||
setroot(booted_device, booted_partition);
|
setroot(booted_device, booted_partition);
|
||||||
}
|
}
|
||||||
|
|
||||||
dev_t bootdev = 0; /* should be dev_t, but not until 32 bits */
|
dev_t bootdev = NULL;
|
||||||
|
char boot_class;
|
||||||
|
int boot_id, boot_lun, boot_part;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Attempt to find the device from which we were booted.
|
* Attempt to find the device from which we were booted.
|
||||||
@ -123,6 +126,16 @@ findroot(devpp, partp)
|
|||||||
struct device **devpp;
|
struct device **devpp;
|
||||||
int *partp;
|
int *partp;
|
||||||
{
|
{
|
||||||
|
struct device *dv;
|
||||||
|
|
||||||
|
for (dv = TAILQ_FIRST(&alldevs); dv; dv = TAILQ_NEXT(dv, dv_list)) {
|
||||||
|
if (dv->dv_class == boot_class && dv->dv_unit == boot_id) {
|
||||||
|
*devpp = dv;
|
||||||
|
*partp = boot_part;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Default to "not found".
|
* Default to "not found".
|
||||||
*/
|
*/
|
||||||
@ -131,3 +144,28 @@ findroot(devpp, partp)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
makebootdev(cp)
|
||||||
|
char *cp;
|
||||||
|
{
|
||||||
|
boot_class = -1;
|
||||||
|
boot_id = boot_lun = boot_part = 0;
|
||||||
|
|
||||||
|
if (strlen(cp) < 6)
|
||||||
|
return;
|
||||||
|
if (strncmp(cp, "dk", 2) == 0 && cp[4] == '(') { /* Disk */
|
||||||
|
cp += 5;
|
||||||
|
if (*cp >= '0' && *cp <= '9')
|
||||||
|
boot_lun = *cp++ - '0';
|
||||||
|
if (*cp == ',')
|
||||||
|
cp += 1;
|
||||||
|
if (*cp >= '0' && *cp <= '9')
|
||||||
|
boot_id = *cp++ - '0';
|
||||||
|
if (*cp == ',')
|
||||||
|
cp += 1;
|
||||||
|
if (*cp >= '0' && *cp <= '9')
|
||||||
|
boot_part = *cp - '0';
|
||||||
|
boot_class = DV_DISK;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: machdep.c,v 1.2 2000/08/15 04:56:46 wdk Exp $ */
|
/* $NetBSD: machdep.c,v 1.3 2000/08/16 21:54:44 wdk Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1988 University of Utah.
|
* Copyright (c) 1988 University of Utah.
|
||||||
@ -43,7 +43,7 @@
|
|||||||
|
|
||||||
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
|
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
|
||||||
|
|
||||||
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.2 2000/08/15 04:56:46 wdk Exp $");
|
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.3 2000/08/16 21:54:44 wdk Exp $");
|
||||||
|
|
||||||
/* from: Utah Hdr: machdep.c 1.63 91/04/24 */
|
/* from: Utah Hdr: machdep.c 1.63 91/04/24 */
|
||||||
|
|
||||||
@ -86,6 +86,7 @@ __KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.2 2000/08/15 04:56:46 wdk Exp $");
|
|||||||
#include <machine/intr.h>
|
#include <machine/intr.h>
|
||||||
#include <machine/mainboard.h>
|
#include <machine/mainboard.h>
|
||||||
#include <machine/sysconf.h>
|
#include <machine/sysconf.h>
|
||||||
|
#include <machine/autoconf.h>
|
||||||
#include <dev/clock_subr.h>
|
#include <dev/clock_subr.h>
|
||||||
#include <dev/cons.h>
|
#include <dev/cons.h>
|
||||||
|
|
||||||
@ -207,7 +208,7 @@ mach_init(argc, argv, envp)
|
|||||||
caddr_t kernend, v;
|
caddr_t kernend, v;
|
||||||
vsize_t size;
|
vsize_t size;
|
||||||
char *cp;
|
char *cp;
|
||||||
extern u_long bootdev;
|
int i;
|
||||||
extern char edata[], end[];
|
extern char edata[], end[];
|
||||||
|
|
||||||
/* clear the BSS segment */
|
/* clear the BSS segment */
|
||||||
@ -219,8 +220,7 @@ mach_init(argc, argv, envp)
|
|||||||
*/
|
*/
|
||||||
uvm_setpagesize();
|
uvm_setpagesize();
|
||||||
|
|
||||||
boothowto = RB_SINGLE;
|
consinit();
|
||||||
bootdev = 0;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The MIPS Rc3230 series machine have a really ugly memory
|
* The MIPS Rc3230 series machine have a really ugly memory
|
||||||
@ -273,16 +273,64 @@ mach_init(argc, argv, envp)
|
|||||||
*/
|
*/
|
||||||
mips_vector_init();
|
mips_vector_init();
|
||||||
|
|
||||||
|
/* Look at argv[0] and compute bootdev */
|
||||||
|
makebootdev(argv[0]);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Look at arguments passed to us and compute boothowto.
|
||||||
|
*/
|
||||||
|
boothowto = RB_SINGLE;
|
||||||
|
for (i = 1; i < argc; i++) {
|
||||||
|
for (cp = argv[i]; *cp; cp++) {
|
||||||
|
switch (*cp) {
|
||||||
|
case 'a': /* autoboot */
|
||||||
|
case 'A':
|
||||||
|
boothowto &= ~RB_SINGLE;
|
||||||
|
break;
|
||||||
|
|
||||||
|
#if defined(KGDB) || defined(DDB)
|
||||||
|
case 'd': /* break into the kernel debugger ASAP */
|
||||||
|
case 'D':
|
||||||
|
boothowto |= RB_KDB;
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
case 'm': /* mini root present in memory */
|
||||||
|
case 'M':
|
||||||
|
boothowto |= RB_MINIROOT;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'n': /* ask for names */
|
||||||
|
boothowto |= RB_ASKNAME;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'N': /* don't ask for names */
|
||||||
|
boothowto &= ~RB_ASKNAME;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 's': /* single-user (default) */
|
||||||
|
case 'S':
|
||||||
|
boothowto |= RB_SINGLE;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case '-': /* Ignore superfluous '-' */
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
printf("bootflag '%c' not recognised", *cp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef DDB
|
#ifdef DDB
|
||||||
/*
|
/*
|
||||||
* Initialize machine-dependent DDB commands, in case of early panic.
|
* Initialize machine-dependent DDB commands, in case of early panic.
|
||||||
*/
|
*/
|
||||||
db_machine_init();
|
db_machine_init();
|
||||||
#endif
|
|
||||||
|
|
||||||
boothowto &= ~RB_ASKNAME; /* for lack of cn_getc */
|
if (boothowto & RB_KDB)
|
||||||
#ifdef KADB
|
Debugger();
|
||||||
boothowto |= RB_KDB;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef MFS
|
#ifdef MFS
|
||||||
|
Loading…
Reference in New Issue
Block a user