Esempio n. 1
0
int
main(void)
{
	char	c;

	init_devices();

	comcninit();

	opt_subcmd_read(NULL);

	print_banner();

	c = awaitkey();
	if (c != '\r' && c != '\n' && c != '\0') {
		printf("type \"?\" or \"h\" for help.\n");
		bootmenu(); /* does not return */
	}

	command_boot(NULL);
	/*
	 * command_boot() returns only if it failed to boot.
	 * we enter to boot menu in this case.
	 */
	bootmenu();
	
	return 0;
}
Esempio n. 2
0
/**************************************************************************
MAIN - Kick off routine
**************************************************************************/
main()
{
	int c;
	extern char edata[], end[];
	bzero(edata,end-edata);		/* Zero BSS */
#ifdef ASK_BOOT
	while (1) {
		printf("\nBoot from Network (Y/N) ? ");
		c = getchar();
		if ((c >= 'a') && (c <= 'z')) c &= 0x5F;
		if (c == '\r') break;
		putchar(c);
		if (c == 'N')
			exit(0);
		if (c == 'Y')
			break;
		printf(" - bad response\n");
	}
#endif

	/* get the bios's idea about the disks geometry */
#ifdef PC98
	for(c = 0; c < 2; c ++) {
		if (*(unsigned char*)0xa155d & (1 << c)) { /* check DISK_EQUIP */
			bootinfo.bi_bios_geom[c] = get_diskinfo(c + 0x80);
		}
	}
#else /* IBM-PC */
	for(c = 0; c < N_BIOS_GEOM; c ++)
		bootinfo.bi_bios_geom[c] = get_diskinfo(c + 0x80);
#endif /* PC98 */

	gateA20();
#ifdef PC98
	/* set machine type to PC98_SYSTEM_PARAMETER */
	machine_check();
#endif
	printf("\nBOOTP/TFTP/NFS bootstrap loader    ESC for menu\n"
		"\nSearching for adapter...");
	if (!eth_probe()) {
		printf("No adapter found.\n");
		exit(0);
	}
	kernel = DEFAULT_BOOTFILE;
	while (1) {
		if (setjmp(jmp_bootmenu))
			bootmenu();
		else
			load();
	}
}
Esempio n. 3
0
void
boot2(uint32_t boot_biossector)
{
	int currname;
	int c;

	/* Initialize hardware */
	tick_init();

	/* Initialize console */
	cninit(boot_params.bp_consdev);

	print_banner();

	/* try to set default device to what BIOS tells us */
	bios2dev(0x40, &default_devname, &default_unit,
		boot_biossector, &default_partition);

	/* if the user types "boot" without filename */
	default_filename = DEFFILENAME;

	printf("Press return to boot now, any other key for boot menu\n");
	currname = 0;
	for (;;) {
		printf("booting %s - starting in ", 
		    sprint_bootsel(names[currname][0]));

		c = awaitkey(boot_params.bp_timeout, 1);
		if ((c != '\r') && (c != '\n') && (c != '\0')) {
			printf("type \"?\" or \"help\" for help.\n");
			bootmenu(); /* does not return */
		}

		/*
		 * try pairs of names[] entries, foo and foo.gz
		 */
		/* don't print "booting..." again */
		bootit(names[currname][0], 0, 0);
		/* since it failed, try compressed bootfile. */
		bootit(names[currname][1], 0, 1);
		/* since it failed, try switching bootfile. */
		currname = (currname + 1) % NUMNAMES;
	}
}
Esempio n. 4
0
void
doboottypemenu(void)
{
	char input[80], *ic, *oc;
	int choice;

	printf("\n");
	/* Display menu */
	if (bootconf.menuformat == MENUFORMAT_LETTER) {
		for (choice = 0; choice < bootconf.nummenu; choice++)
			printf("    %c. %s\n", choice + 'A',
			    bootconf.desc[choice]);
	} else {
		/* Can't use %2d format string with libsa */
		for (choice = 0; choice < bootconf.nummenu; choice++)
			printf("    %s%d. %s\n",
			    (choice < 9) ?  " " : "",
			    choice + 1,
			    bootconf.desc[choice]);
	}
	choice = -1;
	for (;;) {
		input[0] = '\0';

		if (bootconf.timeout < 0) {
			if (bootconf.menuformat == MENUFORMAT_LETTER)
				printf("\nOption: [%c]:",
				    bootconf.def + 'A');
			else
				printf("\nOption: [%d]:",
				    bootconf.def + 1);

			gets(input);
			choice = getchoicefrominput(input, bootconf.def);
		} else if (bootconf.timeout == 0)
			choice = bootconf.def;
		else  {
			printf("\nChoose an option; RETURN for default; "
			       "SPACE to stop countdown.\n");
			if (bootconf.menuformat == MENUFORMAT_LETTER)
				printf("Option %c will be chosen in ",
				    bootconf.def + 'A');
			else
				printf("Option %d will be chosen in ",
				    bootconf.def + 1);
			input[0] = awaitkey(bootconf.timeout, 1);
			input[1] = '\0';
			choice = getchoicefrominput(input, bootconf.def);
			/* If invalid key pressed, drop to menu */
			if (choice == -1)
				bootconf.timeout = -1;
		}
		if (choice < 0)
			continue;
		if (!strcmp(bootconf.command[choice], "prompt")) {
			printf("type \"?\" or \"help\" for help.\n");
			bootmenu(); /* does not return */
		} else {
			ic = bootconf.command[choice];
			/* Split command string at ; into separate commands */
			do {
				oc = input;
				/* Look for ; separator */
				for (; *ic && *ic != COMMAND_SEPARATOR; ic++)
					*oc++ = *ic;
				if (*input == '\0')
					continue;
				/* Strip out any trailing spaces */
				oc--;
				for (; *oc == ' ' && oc > input; oc--);
				*++oc = '\0';
				if (*ic == COMMAND_SEPARATOR)
					ic++;
				/* Stop silly command strings like ;;; */
				if (*input != '\0')
					docommand(input);
				/* Skip leading spaces */
				for (; *ic == ' '; ic++);
			} while (*ic);
		}
	}
}
Esempio n. 5
0
int
main(void)
{
	extern char twiddle_toggle;
        char c;

	twiddle_toggle = 1;	/* no twiddling until we're ready */

#ifdef SUPPORT_SERIAL
	initio(SUPPORT_SERIAL);
#else
	initio(CONSDEV_PC);
#endif
	gateA20();
	boot_modules_enabled = !(boot_params.bp_flags
				 & X86_BP_FLAGS_NOMODULES);

#ifndef SMALL
	if (!(boot_params.bp_flags & X86_BP_FLAGS_NOBOOTCONF)) {
		parsebootconf(BOOTCONF);
	} else {
		bootconf.timeout = boot_params.bp_timeout;
	}

	/*
	 * If console set in boot.cfg, switch to it.
	 * This will print the banner, so we don't need to explicitly do it
	 */
	if (bootconf.consdev)
		command_consdev(bootconf.consdev);
	else 
		print_banner();

	/* Display the menu, if applicable */
	twiddle_toggle = 0;
	if (bootconf.nummenu > 0) {
		/* Does not return */
		doboottypemenu();
	}
#else
	twiddle_toggle = 0;
	print_banner();
#endif

	printf("Press return to boot now, any other key for boot menu\n");
	printf("booting netbsd - starting in ");

#ifdef SMALL
	c = awaitkey(boot_params.bp_timeout, 1);
#else
	c = awaitkey((bootconf.timeout < 0) ? 0 : bootconf.timeout, 1);
#endif
	if ((c != '\r') && (c != '\n') && (c != '\0') &&
	    ((boot_params.bp_flags & X86_BP_FLAGS_PASSWORD) == 0
	     || check_password((char *)boot_params.bp_password))) {
		printf("type \"?\" or \"help\" for help.\n");
		bootmenu(); /* does not return */
	}

	/*
	 * The file name provided here is just a default.  If the
	 * DHCP server provides a file name, we'll use that instead.
	 */
	bootit("netbsd", 0);

	/*
	 * If that fails, let the BIOS try the next boot device.
	 */
	return (1);
}
Esempio n. 6
0
/*
 * Called from the initial entry point boot_start in biosboot.S
 *
 * biosdev: BIOS drive number the system booted from
 * biossector: Sector number of the NetBSD partition
 */
void
boot2(int biosdev, uint64_t biossector)
{
	extern char twiddle_toggle;
	int currname;
	char c;

	twiddle_toggle = 1;	/* no twiddling until we're ready */

	initio(boot_params.bp_consdev);

#ifdef SUPPORT_PS2
	biosmca();
#endif
	gateA20();

	boot_modules_enabled = !(boot_params.bp_flags
				 & X86_BP_FLAGS_NOMODULES);
	if (boot_params.bp_flags & X86_BP_FLAGS_RESET_VIDEO)
		biosvideomode();

	vbe_init();

	/* need to remember these */
	boot_biosdev = biosdev;
	boot_biossector = biossector;

	/* try to set default device to what BIOS tells us */
	bios2dev(biosdev, biossector, &default_devname, &default_unit,
		 &default_partition);

	/* if the user types "boot" without filename */
	default_filename = DEFFILENAME;

#ifndef SMALL
	if (!(boot_params.bp_flags & X86_BP_FLAGS_NOBOOTCONF)) {
		parsebootconf(BOOTCONF);
	} else {
		bootconf.timeout = boot_params.bp_timeout;
	}
	

	/*
	 * If console set in boot.cfg, switch to it.
	 * This will print the banner, so we don't need to explicitly do it
	 */
	if (bootconf.consdev)
		command_consdev(bootconf.consdev);
	else 
		print_banner();

	/* Display the menu, if applicable */
	twiddle_toggle = 0;
	if (bootconf.nummenu > 0) {
		/* Does not return */
		doboottypemenu();
	}

#else
	twiddle_toggle = 0;
	print_banner();
#endif

	printf("Press return to boot now, any other key for boot menu\n");
	for (currname = 0; currname < NUMNAMES; currname++) {
		printf("booting %s - starting in ",
		       sprint_bootsel(names[currname][0]));

#ifdef SMALL
		c = awaitkey(boot_params.bp_timeout, 1);
#else
		c = awaitkey((bootconf.timeout < 0) ? 0 : bootconf.timeout, 1);
#endif
		if ((c != '\r') && (c != '\n') && (c != '\0')) {
		    if ((boot_params.bp_flags & X86_BP_FLAGS_PASSWORD) == 0) {
			/* do NOT ask for password */
			bootmenu(); /* does not return */
		    } else {
			/* DO ask for password */
			if (check_password((char *)boot_params.bp_password)) {
			    /* password ok */
			    printf("type \"?\" or \"help\" for help.\n");
			    bootmenu(); /* does not return */
			} else {
			    /* bad password */
			    printf("Wrong password.\n");
			    currname = 0;
			    continue;
			}
		    }
		}

		/*
		 * try pairs of names[] entries, foo and foo.gz
		 */
		/* don't print "booting..." again */
		bootit(names[currname][0], 0, 0);
		/* since it failed, try compressed bootfile. */
		bootit(names[currname][1], 0, 1);
	}

	bootmenu();	/* does not return */
}
Esempio n. 7
0
void
boot(dev_t bootdev)
{
	extern char twiddle_toggle;
	int currname;
	int c;

	consinit(CONSDEV_GLASS, -1);

	twiddle_toggle = 1;	/* no twiddling until we're ready */

	/* set default value: hd0a:netbsd */
	default_devname = "hd";
	default_unit = 0;
	default_partition = 0;
	default_filename = names[0][0];

	diskprobe(probed_disks, sizeof(probed_disks));

	snprintf(bootconfpath, sizeof(bootconfpath), "%s%d%c:%s",
	    default_devname, default_unit, 'a' + default_partition,
	    BOOTCFG_FILENAME);
	parsebootconf(bootconfpath);

#ifdef SUPPORT_CONSDEV
	/*
	 * If console set in boot.cfg, switch to it.
	 * This will print the banner, so we don't need to explicitly do it
	 */
	if (bootcfg_info.consdev)
		bootcmd_consdev(bootcfg_info.consdev);
	else 
#endif
		print_banner();

	printf("\ndisks: %s\n", probed_disks);

	/* Display the menu, if applicable */
	twiddle_toggle = 0;
	if (bootcfg_info.nummenu > 0) {
		/* Does not return */
		doboottypemenu();
	}

	printf("Press return to boot now, any other key for boot menu\n");
	currname = 0;
	for (currname = 0; currname < __arraycount(names); currname++) {
		printf("booting %s - starting in ", 
		    sprint_bootsel(names[currname][0]));

		c = awaitkey((bootcfg_info.timeout < 0) ? 0
		    : bootcfg_info.timeout, 1);
		if ((c != '\r') && (c != '\n') && (c != '\0')) {
			printf("type \"?\" or \"help\" for help.\n");
			bootmenu(); /* does not return */
		}

		/*
		 * try pairs of names[] entries, foo and foo.gz
		 */
		/* don't print "booting..." again */
		bootit(names[currname][0], 0, 0);
		/* since it failed, try compressed bootfile. */
		bootit(names[currname][1], 0, 1);
	}

	bootmenu(); /* does not return */
}
Esempio n. 8
0
void dmw_bootmenu(void)
{
	char *tmp = NULL;

	tmp = getenv("bootmenu_on");
	enter_bootmenu = tmp ? simple_strtoul(tmp, NULL, 10) : 0;
	if (enter_bootmenu != 1) {
		/* no bootmenu */
		return;
	}

	/* init time base */
	time_base = get_timer(0);

	tmp = getenv("menu_enter_keypad_row");
	menu_enter_keypad_row = tmp ? simple_strtoul(tmp, NULL, 10) : -1;
	tmp = getenv("menu_enter_keypad_col");
	menu_enter_keypad_col = tmp ? simple_strtoul(tmp, NULL, 10) : -1;

	tmp = getenv("menu_next_keypad_row");
	menu_next_keypad_row = tmp ? simple_strtoul(tmp, NULL, 10) : -1;
	tmp = getenv("menu_next_keypad_col");
	menu_next_keypad_col = tmp ? simple_strtoul(tmp, NULL, 10) : -1;

	tmp = getenv("menu_next_key_text");
	if (tmp != NULL) {
		strncpy(menu_next_keypad_text, tmp, min(MENU_KEYPAD_TEXT_SIZE, strlen(tmp)));
		bootmenu_setup.next_key_action = &menu_next_keypad_text[0];
	}

	tmp = getenv("menu_enter_key_text");
	if (tmp != NULL) {
		strncpy(menu_enter_keypad_text, tmp, min(MENU_KEYPAD_TEXT_SIZE, strlen(tmp)));
		bootmenu_setup.enter_key_name = &menu_enter_keypad_text[0];
	}

	if ((menu_next_keypad_row == -1) || (menu_next_keypad_col == -1)) {
		bootmenu_setup.next_key_action = "Press [no key defined]";
		bootmenu_setup.next_key = NULL;
	}

	if ((menu_next_keypad_row == -1) || (menu_next_keypad_col == -1)) {
		bootmenu_setup.next_key_action = "Press [no key defined]";
		bootmenu_setup.next_key = no_key;
	}

	if ((menu_enter_keypad_row == -1) || (menu_enter_keypad_col == -1)) {
		bootmenu_setup.enter_key_name = "[no key defined]";
		bootmenu_setup.enter_key = no_key;
	}

	bootmenu_add("Boot Linux", NULL,            "boot");
	/* bootmenu_add("Set console to USB", NULL,    "setenv stdin=usbtty; setenv stdout=usbtty; setenv stderr=usbtty");
	bootmenu_add("Set console to serial", NULL, "setenv stdin=serial; setenv stdout=serial; setenv stderr=serial"); */
	bootmenu_add("Reboot", NULL,                "reset");
	/* bootmenu_add("Power off", NULL,             "reset"); */
	bootmenu_add("Factory reset", NULL,         "defenv; saveenv");
	bootmenu_add("Upgrade from SD card", NULL,  "if mmc rescan 0; then " \
	                                            "if run loadbootscript; then " \
	                                            "run bootscript; fi; fi");
	bootmenu_init(&bootmenu_setup);
	bootmenu();
}