/*-
* Copyright (c) 1999 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Jonathan Stone, Michael Hitch and Simon Burge.
*
* 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.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
*/
/*
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Ralph Campbell.
*
* 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.
*
* @(#)boot.c 8.1 (Berkeley) 6/10/93
*/
/*
* We won't go overboard with gzip'd kernel names. After all we can
* still boot a gzip'd kernel called "netbsd.pmax" - it doesn't need
* the .gz suffix.
*/
char *kernelnames[] = {
"netbsd.pmax",
"netbsd", "netbsd.gz",
"netbsd.bak",
"netbsd.old",
"onetbsd",
"gennetbsd",
#ifdef notyet
"netbsd.el",
#endif /*notyet*/
NULL
};
static char *devname(char *);
int main(int, char **);
/*
* This gets arguments from the first stage boot loader, calls PROM routines
* to open and load the program to boot, and then transfers execution to
* that new program.
*
* Argv[0] should be something like "rz(0,0,0)netbsd" on a DECstation 3100.
* Argv[0,1] should be something like "boot 5/rz0/netbsd" on a DECstation 5000.
* The argument "-a" means netbsd should do an automatic reboot.
*/
int
main(int argc, char **argv)
{
char *name, **namep, *dev, *kernel;
char bootname[PATH_MAX], bootpath[PATH_MAX];
int entry, win;
u_long marks[MARK_MAX];
struct btinfo_symtab bi_syms;
struct btinfo_bootpath bi_bpath;
/*
* Check whether or not fname is a device name only or a full
* bootpath including the kernel name. This code to do this
* is copied from loadfile() in the first stage bootblocks.
* Returns the kernel name, or NULL if no kernel name specified.
*
* NOTE: fname will be modified if it's of the form N/rzY
* without a trailing slash.
*/
static char *
devname(char *fname)
{
char c;
while ((c = *fname++) != '\0') {
if (c == ')')
break;
if (c != '/')
continue;
while ((c = *fname++) != '\0')
if (c == '/')
break;
/*
* Make "N/rzY" with no trailing '/' valid by adding
* the extra '/' before appending 'boot.pmax' to the path.
*/
if (c != '/') {
fname--;
*fname++ = '/';
*fname = '\0';
}
break;
}
return (*fname == '\0' ? NULL : fname);
}