bootflags.c revision 10293b58014f6102038e6708a24aa8bdd32edff9
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* Parse the boot arguments.
*/
#include <util/getoptstr.h>
#include "bootprop.h"
#include "debug.h"
int boothowto;
int verbosemode;
char *bootprog;
char *bootfile;
char bootargs[MAXNAMELEN];
char bootprop[MAXPATHLEN];
static char bootfile_buf[MAXNAMELEN];
static char bootprog_buf[MAXNAMELEN];
static int grub_line_present;
/*
* Parse the boot arguments and place results in bootprog, bootfile,
* bootargs, and bootprops. Note that anything unknown is treated as
* [kern-args] and is passed to kernel as is.
*
* The format for the GRUB args is:
* [-B prop=value[,prop=value...]] [kern-args]
*
* The format for the eeprom boot-file is:
* [bootfile [-D path]] [-Vadvk] [kern-args]
*
* The grub line takes precedence
*/
static void
{
struct gos_params params;
char *np;
int c;
/* parse grub bootprog (multiboot) and -B */
if (grub) {
if (dash_B) {
/* copy -B arg to bootprop */
/* move the end string forward */
if (cp) {
*dash_B++ = ' ';
;
} else {
*dash_B = 0;
}
}
/* get the multiboot prog (must be present) */
} else {
/* don't process bootfile_prop if grub line is present */
if (grub_line_present) {
if (args && verbosemode)
printf("grub line specified, ignoring "
"boot-file setting %s in bootenv.rc\n",
args);
return;
}
}
return;
if (*bootfile == '-') {
/* XXX undo strtok, if have additional tokens */
} else {
} else {
/* copy to buf to avoid being overwritten */
(void) strlcpy(bootfile_buf,
bootfile, sizeof (bootfile_buf));
}
/* get the remainder of string */
args = "";
}
extern void check_iopath(void);
switch (c) {
case 'V': /* Undocumented. */
verbosemode = 1;
break;
case 'C': /* Undocumented for checking IO path */
check_iopath();
/* never returns here */
break;
case 'D':
"Ignoring.\n");
break;
}
printf("boot: -D argument too long. "
"Ignoring.\n");
break;
}
break;
/* Consumed by the kernel */
case 'a': /* Undocumented. */
boothowto |= RB_ASKNAME;
break;
case 'd':
break;
case 'v':
boothowto |= RB_VERBOSE;
break;
case 'k':
break;
case '?':
/*
* Error. Either an unrecognized option, or an option
* without an argument. Check for the latter.
*/
switch (params.gos_last_opt) {
case 'D':
printf("boot: -%c flag missing required "
"argument. Ignoring.\n",
break;
default:
/* Unrecognized flag: stop. */
goto done;
}
break;
default:
printf("boot: Ignoring unimplemented option -%c.", c);
}
}
done:
/*
* Construct the arguments for the standalone.
*/
*bootargs = '\0';
/*
* Start with '-' if we encountered an unrecognized option or if we
* need to pass flags to the standalone.
*/
if (c == '?' || (boothowto &
/* These flags are to be passed to the kernel. */
RB_KMDB))) {
*np++ = '-';
if (boothowto & RB_ASKNAME)
*np++ = 'a';
if (boothowto & RB_DEBUGENTER)
*np++ = 'd';
if (boothowto & RB_VERBOSE)
*np++ = 'v';
*np++ = 'k';
/*
* If we didn't encounter an unrecognized flag and there's
* more to copy, add a space to separate these flags.
* (Otherwise, unrecognized flags can be appended since we
* started this word with a dash.)
*/
*np++ = ' ';
}
/*
* Unrecognized flag. gos_errp contains the remaining bootargs
*/
if (c == '?')
else
npres--;
*np = 0;
if (verbosemode) {
if (bootfile)
}
if (!grub)
}
void
get_grub_bootargs(char *args)
{
/* grub args is always present */
}
void
get_eeprom_bootargs(char *args)
{
if (args) /* boot-file prop may not be present */
get_bootargs(args, 0);
}