Exemple #1
0
/*ARGSUSED*/
int
bootprog(char *bpath, char *bargs, boolean_t user_specified_filename)
{
	boolean_t	once = B_FALSE;

	systype = set_fstype(v2path, bpath);

loop:
	/*
	 * Beware: the following code may be executed twice, with different
	 * bpath's if we discover a redirection file.
	 */

	if (verbosemode) {
		printf("device path '%s'\n", bpath);
		if (strcmp(bpath, v2path) != 0)
			printf("client path '%s'\n", v2path);
	}

	if (mountroot(bpath) != SUCCESS)
		prom_panic("Could not mount filesystem.");

	/*
	 * kernname (default-name) might have changed if mountroot() called
	 * boot_nfs_mountroot(), and it called set_default_filename().
	 */
	if (!user_specified_filename)
		(void) strcpy(filename, kernname);

	if (verbosemode)
		printf("standalone = `%s', args = `%s'\n", filename, bargs);

	set_client_bootargs(filename, bargs);

	if (!once &&
	    (strcmp(systype, "ufs") == 0 || strcmp(systype, "hsfs") == 0)) {
		char redirect[OBP_MAXPATHLEN];

		post_mountroot(filename, redirect);

		/*
		 * If we return at all, it's because we discovered
		 * a redirection file - the 'redirect' string now contains
		 * the name of the disk slice we should be looking at.
		 *
		 * Unmount the filesystem, tweak the boot path and retry
		 * the whole operation one more time.
		 */
		closeall(1);
		once = B_TRUE;
		redirect_boot_path(bpath, redirect);
		if (verbosemode)
			printf("%sboot: using '%s'\n", systype, bpath);

		goto loop;
		/*NOTREACHED*/
	}

	return (0);
}
Exemple #2
0
/*ARGSUSED*/
int
main(void *cookie, char **argv, int argc)
{
	/*
	 * bpath is the boot device path buffer.
	 * bargs is the boot arguments buffer.
	 */
	static char	bpath[OBP_MAXPATHLEN], bargs[OBP_MAXPATHLEN];
	boolean_t	user_specified_filename;

	prom_init("boot", cookie);
	fiximp();

	system_check();

	dprintf("\nboot: V%d /boot interface.\n", BO_VERSION);
#ifdef HALTBOOT
	prom_enter_mon();
#endif /* HALTBOOT */

	init_memlists();

#ifdef DEBUG_LISTS
	dprintf("Physmem avail:\n");
	if (debug) print_memlist(pfreelistp);
	dprintf("Virtmem avail:\n");
	if (debug) print_memlist(vfreelistp);
	dprintf("Phys installed:\n");
	if (debug) print_memlist(pinstalledp);
	prom_enter_mon();
#endif /* DEBUG_LISTS */

	/*
	 * Initialize the default filename (exported as "default-name" and
	 * used by kadb).
	 */
	set_default_filename(defname);

	/*
	 * Parse the arguments ASAP in case there are any flags which may
	 * affect execution.
	 */

	/*
	 * filename is the path to the standalone.  Initialize it to the empty
	 * string so we can tell whether the user specified it in the
	 * arguments.
	 */
	filename[0] = '\0';

	/*
	 * Fetch the boot arguments from the PROM and split the filename off
	 * if it's there.
	 */
	init_bootargs(filename, sizeof (filename), bargs, sizeof (bargs));

	/*
	 * kadb was delivered as a standalone, and as such, people got used to
	 * typing `boot kadb'.  kmdb isn't a standalone - it is loaded by krtld
	 * as just another kernel module.  For compatibility, though, when we
	 * see an attempt to `boot kadb' or `boot kmdb', we'll transform that
	 * into a `boot -k' (or equivalent).
	 */
	if (strcmp(filename, "kmdb") == 0 || strcmp(filename, "kadb") == 0) {
		boothowto |= RB_KMDB;
		*filename = '\0'; /* let boot figure out which unix to use */
	}

	bootflags(bargs, sizeof (bargs));

	user_specified_filename = (filename[0] != '\0');

	/* Fetch the boot path from the PROM. */
	(void) strncpy(bpath, prom_bootpath(), sizeof (bpath) - 1);
	bpath[sizeof (bpath) - 1] = '\0';

	dprintf("arch: %s\n", is_sun4v ? "sun4v" : "sun4u");
	dprintf("bootpath: 0x%p %s\n", (void *)bpath, bpath);
	dprintf("bootargs: 0x%p %s\n", (void *)bargs, bargs);
	dprintf("filename: 0x%p %s\n", (void *)filename, filename);
	dprintf("kernname: 0x%p %s\n", (void *)kernname, kernname);

	/*
	 * *v2path will be exported to the standalone as the boot-path boot
	 * property.
	 */
	v2path = bpath;

	/*
	 * Our memory lists should be "up" by this time
	 */

	setup_bootops();

	/*
	 * If bpath is a network card, set v2path to a copy of bpath with the
	 * options stripped off.
	 */
	mangle_os_bootpath(bpath);

	/*
	 * Not necessary on sun4v as nvram is virtual
	 * and kept by the guest manager on the SP.
	 */
	if (!is_sun4v) {
		retain_nvram_page();
	}

	if (bootprog(bpath, bargs, user_specified_filename) == 0) {
		post_mountroot(filename, NULL);
		/*NOTREACHED*/
	}

	return (0);
}