Exemple #1
0
void
cmdline_parse(void)
{
	char *p;

	/*
	 * If the boot commandline has been manually entered, it
	 * may end with a '\r' character.
	 */
	for (p = bootargs; *p != '\0'; p++)
		;
	if (p != bootargs)
		if (*--p == '\r')
			*p = '\0';

	/*
	 * Skip boot device ``foo(ctrl,dev,lun)'' and filename,
	 * i.e. eat everything until whitespace.
	 */
	p = stws(bootargs);
	while (*p != '\0') {
		if (*p++ == '-')
			while (*p != ' ' && *p != '\0')
				switch (*p++) {
				case 'a':
					boothowto |= RB_ASKNAME;
					break;
				case 'b':
					boothowto |= RB_KDB;
					break;
				case 'c':
					boothowto |= RB_CONFIG;
					break;
				case 's':
					boothowto |= RB_SINGLE;
					break;
				}
		p = stws(p);
	}

	/*
	 * Now parse the boot device. We are only interested in the
	 * device type, since the PROM has cracked the controller, unit
	 * and partition numbers for us already, and we do not care about
	 * our own filename...
	 *
	 * Actually we rely upon the fact that all device strings are
	 * exactly 4 characters long, and appears at the beginning of the
	 * commandline, so we can simply use its numerical value, as a
	 * word, to tell device types apart.
	 */
	bcopy(bootargs, &bootdevtype, sizeof(int));
}
Exemple #2
0
void
cmdline_parse(void)
{
	char *p;

	/*
	 * If the boot commandline has been manually entered, it
	 * may end with a '\r' character.
	 */
	for (p = bootargs; *p != '\0'; p++)
		;
	if (p != bootargs)
		if (*--p == '\r')
			*p = '\0';

	/*
	 * Skip boot device ``foo(ctrl,dev,lun)'' and filename,
	 * i.e. eat everything until whitespace.
	 */
	p = stws(bootargs);
	while (*p != '\0') {
		if (*p++ == '-')
			while (*p != ' ' && *p != '\0')
				switch (*p++) {
				case 'a':
					boothowto |= RB_ASKNAME;
					break;
				case 'b':
					boothowto |= RB_KDB;
					break;
				case 'c':
					boothowto |= RB_CONFIG;
					break;
				case 's':
					boothowto |= RB_SINGLE;
					break;
				}
		p = stws(p);
	}

	/*
	 * Now parse the boot device. We are only interested in the
	 * device type, since the PROM has cracked the controller, unit
	 * and partition numbers for us already, and we do not care about
	 * our own filename...
	 *
	 * However, in the sd() or st() cases, we need to figure out the
	 * SCSI controller name (if not the default one) and address, if
	 * provided.
	 *
	 * Note that we will override bootdev at this point. If no boot
	 * controller number or address was provided, bootdev will be set
	 * to zero anyway.
	 */
	if (memcmp(bootargs, "sd", 2) == 0 ||
	    memcmp(bootargs, "st", 2) == 0) {
		/*
		 * Either
		 *   sd(bootdev,bootunit,bootlun)
		 * or
		 *   sd(ctrl(bootdev,id),bootunit,bootlun)
		 * We already know bootdev, bootunit and bootlun.
		 * All we need here is to figure out the controller type
		 * and address.
		 */
		if (bootargs[7] == '(') {
			bcopy(bootargs + 3, &bootdevtype, sizeof(uint32_t));
			bootdev = strtoi(bootargs + 8);
		}
	} else {
		bcopy(bootargs, &bootdevtype, sizeof(int));
		bootdev = strtoi(bootargs + 5);
	}

	/* fill the holes */
	bootctrlpaddr = platform->get_boot_device(&bootdevtype, bootdev);
}