/*-
* Copyright (c) 1998 Michael Smith <msmith@freebsd.org>
* All rights reserved.
*
* 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
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
*/
__FBSDID("$FreeBSD$");
/*
* Loading modules, booting the system
*/
#include <stand.h>
#include <string.h>
#include "bootstrap.h"
static char *getbootfile(int try);
/* List of kernel names to try (may be overwritten by boot.config) XXX should move from here? */
static int autoboot_tried;
/*
* The user wants us to boot.
*/
static int
{
/*
* See if the user has specified an explicit kernel to boot.
*/
/* XXX maybe we should discard everything and start again? */
return(CMD_ERROR);
}
return(CMD_ERROR);
/* we have consumed all arguments */
argc = 1;
}
/*
* See if there is a kernel module already loaded
*/
/* we have consumed all arguments */
argc = 1;
/*
* Loaded anything yet?
*/
command_errmsg = "no bootable kernel";
return(CMD_ERROR);
}
/*
* If we were given arguments, discard any previous.
* XXX should we merge arguments? Hard to DWIM.
*/
if (argc > 1) {
}
/* Hook for platform-specific autoloading of modules */
if (archsw.arch_autoload() != 0)
return(CMD_ERROR);
/* Call the exec handler from the loader matching the kernel */
return(CMD_ERROR);
}
/*
* Autoboot after a delay
*/
static int
{
int howlong;
howlong = -1;
switch(argc) {
case 3:
/* FALLTHROUGH */
case 2:
if (*cp != 0) {
return(CMD_ERROR);
}
/* FALLTHROUGH */
case 1:
}
command_errmsg = "too many arguments";
return(CMD_ERROR);
}
/*
* Called before we go interactive. If we think we can autoboot, and
* we haven't tried already, try now.
*/
void
autoboot_maybe(void)
{
char *cp;
/* compatibility with sparc prom, check for autoboot? */
return;
}
int
{
int c, yes;
char *kernelname;
autoboot_tried = 1;
if (timeout == -1) {
timeout = 10;
/* try to get a delay from the environment */
}
}
bf_run("start");
command_errmsg = "no valid kernel found";
return(CMD_ERROR);
}
}
if (timeout >= 0) {
yes = 0;
printf("%s\n", (prompt == NULL) ? "Hit [Enter] to boot immediately, or any other key for command prompt." : prompt);
for (;;) {
if (ischar()) {
c = getchar();
if ((c == '\r') || (c == '\n'))
yes = 1;
break;
}
yes = 1;
break;
}
printf("\rBooting [%s] in %d second%s... ",
}
}
} else {
yes = 1;
}
if (yes)
putchar('\n');
if (yes) {
argv[0] = "boot";
}
return(CMD_OK);
}
/*
* Scrounge for the name of the (try)'th file we will try to boot.
*/
static char *
{
/* we use dynamic storage */
}
/*
* Try $bootfile, then try our builtin default
*/
if (spec)
spec++; /* skip over the leading ';' */
try--;
}
} else {
}
}
}
return(name);
}
/*
* which should be be the root filesystem, and parse it to find
* out what the kernel ought to think the root filesystem is.
*
* If we're successful, set vfs.root.mountfrom to <vfstype>:<path>
* so that the kernel can tell both which VFS and which node to use
* to mount the device. If this variable's already set, don't
* overwrite it.
*/
int
{
return(0);
error = 1;
goto notfound;
continue;
/* skip device name */
;
if (*cp == 0) /* misformatted */
continue;
/* delimit and save */
*cp++ = 0;
/* skip whitespace up to mountpoint */
cp++;
/* must have /<space> to be root */
continue;
/* skip whitespace up to fstype */
cp += 2;
cp++;
if (*cp == 0) /* misformatted */
continue;
/* skip text to end of fstype and delimit */
cp++;
*cp = 0;
/* skip whitespace up to mount options */
cp += 1;
cp++;
if (*cp == 0) /* misformatted */
continue;
/* skip text to end of mount options and delimit */
cp++;
*cp = 0;
/* Build the <fstype>:<device> and save it in vfs.root.mountfrom */
/* Don't override vfs.root.mountfrom.options if it is already set */
/* save mount options */
}
error = 0;
break;
}
if (error) {
const char *currdev;
error = 0;
}
}
return(error);
}
static int
{
char *cp;
else
return 1;
return 0;
}