ofrootfound();
if(system_type == OFWMACH) { ofrootfound(); }
static struct devmap * findtype __P((char **));void makebootdev __P((char *cp));int getpno __P((char **));/* * The following several variables are related to * the configuration process, and are used in initializing * the machine. */int	cold = 1;	/* if 1, still working on cold-start */char	bootdev[16];	/* to hold boot dev name */struct device *bootdv = NULL;/* *  Configure all devices found that we know about. *  This is done at boot time. */voidconfigure(){	(void)splhigh();	/* To be really sure.. */	if(config_rootfound("mainbus", "mainbus") == 0)		panic("no mainbus found");	ofrootfound();	(void)spl0();	setroot();	swapconf();	cold = 0;}/* * Configure swap space and related parameters. */voidswapconf(){	register struct swdevt *swp;	register int nblks;	for (swp = swdevt; swp->sw_dev != NODEV; swp++) {		if (bdevsw[major(swp->sw_dev)].d_psize) {			nblks =			  (*bdevsw[major(swp->sw_dev)].d_psize)(swp->sw_dev);			if (nblks != -1 &&			    (swp->sw_nblks == 0 || swp->sw_nblks > nblks))				swp->sw_nblks = nblks;			swp->sw_nblks = ctod(dtoc(swp->sw_nblks));		}	}#if 0	dumpconf();#endif}static	struct nam2blk {	char *name;	int  maj;} nam2blk[] = {	{ "sd",		2 },	/* 2 = sd */	{ "ofdisk",	4 },	/* 2 = ofdisk */};static intfindblkmajor(dv)	struct device *dv;{	char *name = dv->dv_xname;	register int i;	for (i = 0; i < sizeof(nam2blk)/sizeof(nam2blk[0]); ++i)		if (strncmp(name, nam2blk[i].name, strlen(nam2blk[0].name)) == 0)			return (nam2blk[i].maj);	 return (-1);}static struct device *getdisk(str, len, defpart, devp)	char *str;	int len, defpart;	dev_t *devp;{	register struct device *dv;	if ((dv = parsedisk(str, len, defpart, devp)) == NULL) {		printf("use one of:");		for (dv = alldevs.tqh_first; dv != NULL;		    dv = dv->dv_list.tqe_next) {			if (dv->dv_class == DV_DISK)				printf(" %s[a-h]", dv->dv_xname);#ifdef NFSCLIENT			if (dv->dv_class == DV_IFNET)				printf(" %s", dv->dv_xname); #endif		}		printf("\n");	}	return (dv);}struct device *parsedisk(str, len, defpart, devp)	char *str;	int len, defpart;	dev_t *devp;{	register struct device *dv;	register char *cp, c;	int majdev, part;	if (len == 0)		return (NULL);	cp = str + len - 1;	c = *cp;	if (c >= 'a' && (c - 'a') < MAXPARTITIONS) {		part = c - 'a';		*cp = '\0';	} else		part = defpart;	for (dv = alldevs.tqh_first; dv != NULL; dv = dv->dv_list.tqe_next) {		if (dv->dv_class == DV_DISK &&		    strcmp(str, dv->dv_xname) == 0) {			majdev = findblkmajor(dv);			if (majdev < 0)				panic("parsedisk");			*devp = MAKEDISKDEV(majdev, dv->dv_unit, part);			break;		}#ifdef NFSCLIENT		if (dv->dv_class == DV_IFNET &&		    strcmp(str, dv->dv_xname) == 0) {			*devp = NODEV;			break;		}#endif	}	*cp = c;	return (dv);}/* * Attempt to find the device from which we were booted. * If we can do so, and not instructed not to do so, * change rootdev to correspond to the load device. */voidsetroot(){	int  majdev, mindev, unit, part, len;	dev_t temp;	struct swdevt *swp;	struct device *dv;	dev_t nrootdev, nswapdev = NODEV;	char buf[128];#if defined(NFSCLIENT)	extern char *nfsbootdevname;#endifprintf("bootpath: '%s'\n", bootpath);	makebootdev(bootpath);	if(boothowto & RB_DFLTROOT)		return;		/* Boot compiled in */	/* Lookup boot device from boot if not set by configuration */	if(bootdv == NULL) {		bootdv = parsedisk(bootdev, strlen(bootdev), 0, &temp);	}	if(bootdv == NULL) {		printf("boot device: lookup '%s' failed.\n", bootdev);		boothowto |= RB_ASKNAME; /* Don't Panic :-) */		/* boothowto |= RB_SINGLE; */	}	else {		printf("boot device: %s.\n", bootdv->dv_xname);	}	if (boothowto & RB_ASKNAME) {		for (;;) {			printf("root device ");			if (bootdv != NULL)				 printf("(default %s%c)",					bootdv->dv_xname,					bootdv->dv_class == DV_DISK						? 'a' : ' ');			printf(": ");			len = getsn(buf, sizeof(buf));			if (len == 0 && bootdv != NULL) {				strcpy(buf, bootdv->dv_xname);				len = strlen(buf);			}			if (len > 0 && buf[len - 1] == '*') {				buf[--len] = '\0';				dv = getdisk(buf, len, 1, &nrootdev);				if (dv != NULL) {					bootdv = dv;					nswapdev = nrootdev;					goto gotswap;				}			}			dv = getdisk(buf, len, 0, &nrootdev);			if (dv != NULL) {				bootdv = dv;				break;			}		}		/*		 * because swap must be on same device as root, for		 * network devices this is easy.		 */		if (bootdv->dv_class == DV_IFNET) {			goto gotswap;		}		for (;;) {			printf("swap device ");			if (bootdv != NULL)				printf("(default %s%c)",					bootdv->dv_xname,					bootdv->dv_class == DV_DISK?'b':' ');			printf(": ");			len = getsn(buf, sizeof(buf));			if (len == 0 && bootdv != NULL) {				switch (bootdv->dv_class) {				case DV_IFNET:					nswapdev = NODEV;					break;				case DV_DISK:					nswapdev = MAKEDISKDEV(major(nrootdev),					    DISKUNIT(nrootdev), 1);					break;				case DV_TAPE:				case DV_TTY:				case DV_DULL:				case DV_CPU:					break;				}				break;			}			dv = getdisk(buf, len, 1, &nswapdev);			if (dv) {				if (dv->dv_class == DV_IFNET)					nswapdev = NODEV;				break;			}		}gotswap:		rootdev = nrootdev;		dumpdev = nswapdev;		swdevt[0].sw_dev = nswapdev;		swdevt[1].sw_dev = NODEV;	}	else if(mountroot == NULL) {		/*		 * `swap generic': Use the device the ROM told us to use.		 */		if (bootdv == NULL)			panic("boot device not known");		majdev = findblkmajor(bootdv);		if (majdev >= 0) {			/*			 * Root and Swap are on disk.			 * Boot is always from partition 0.			 */			rootdev = MAKEDISKDEV(majdev, bootdv->dv_unit, 0);			nswapdev = MAKEDISKDEV(majdev, bootdv->dv_unit, 1);			dumpdev = nswapdev;		}		else {			/*			 *  Root and Swap are on net.			 */				nswapdev = dumpdev = NODEV;		}		swdevt[0].sw_dev = nswapdev;		swdevt[1].sw_dev = NODEV;	} else {		/*		 * `root DEV swap DEV': honour rootdev/swdevt.		 * rootdev/swdevt/mountroot already properly set.		 */		return;	}	switch (bootdv->dv_class) {#if defined(NFSCLIENT)	case DV_IFNET:		mountroot = nfs_mountroot;		nfsbootdevname = bootdv->dv_xname;		return;#endif	case DV_DISK:		mountroot = dk_mountroot;		majdev = major(rootdev);		mindev = minor(rootdev);		unit = DISKUNIT(rootdev);		part = DISKPART(rootdev);		printf("root on %s%c\n", bootdv->dv_xname, part + 'a');		break;	default:		printf("can't figure root, hope your kernel is right\n");		return;	}	/*	 * XXX: What is this doing?	 */	temp = NODEV;	for (swp = swdevt; swp->sw_dev != NODEV; swp++) {		if (majdev == major(swp->sw_dev) &&		    unit == DISKUNIT(swp->sw_dev)) {			temp = swdevt[0].sw_dev;			swdevt[0].sw_dev = swp->sw_dev;			swp->sw_dev = temp;			break;		}	}	if (swp->sw_dev == NODEV)		return;	/*	 * If dumpdev was the same as the old primary swap device, move	 * it to the new primary swap device.	 */	if (temp == dumpdev)		dumpdev = swdevt[0].sw_dev;}/* * find a device matching "name" and unit number */struct device *getdevunit(name, unit)	char *name;	int unit;{	struct device *dev = alldevs.tqh_first;	char num[10], fullname[16];	int lunit;	/* compute length of name and decimal expansion of unit number */	sprintf(num, "%d", unit);	lunit = strlen(num);	if (strlen(name) + lunit >= sizeof(fullname) - 1)		panic("config_attach: device name too long");	strcpy(fullname, name);	strcat(fullname, num);	while (strcmp(dev->dv_xname, fullname) != 0) {		if ((dev = dev->dv_list.tqe_next) == NULL)			return NULL;	}	return dev;}struct devmap {	char *att;	char *dev;	int   type;};#define	T_BUS	0#define	T_SCSI	1#define	T_DISK	2static struct devmap *findtype(s)	char **s;{	static struct devmap devmap[] = {		{ "/pci", NULL, T_BUS },		{ "/scsi@", "sd", T_SCSI },		{ "/disk@", "sd", T_DISK },		{ NULL, NULL }	};	struct devmap *dp = &devmap[0];	while (dp->att) {		if (strncmp (*s, dp->att, strlen(dp->att)) == 0) {			*s += strlen(dp->att);			break;		}		dp++;	}	return(dp);}