xref: /csrg-svn/sys/i386/i386/swapgeneric.c (revision 41059)
140468Sbill /*	swapgeneric.c	1.5	86/11/25	*/
240468Sbill 
340468Sbill #include "../machine/pte.h"
440468Sbill 
540468Sbill #include "param.h"
640468Sbill #include "conf.h"
740468Sbill #include "buf.h"
840468Sbill #include "vm.h"
940468Sbill #include "systm.h"
1040468Sbill #include "reboot.h"
1140468Sbill 
1240468Sbill /*
1340468Sbill  * Generic configuration;  all in one
1440468Sbill  */
15*41059Swilliam dev_t	rootdev = 0;
16*41059Swilliam dev_t	argdev = 1;
17*41059Swilliam dev_t	dumpdev = 1;
1840468Sbill int	nswap;
1940468Sbill struct	swdevt swdevt[] = {
20*41059Swilliam 	{ 1,	0,	4*4096 },
21*41059Swilliam 	{ 0,	1,	0 },
2240468Sbill };
2340468Sbill long	dumplo;
2440468Sbill int	dmmin, dmmax, dmtext;
2540468Sbill 
26*41059Swilliam extern	struct driver wddriver;
2740468Sbill 
2840468Sbill struct	genericconf {
2940468Sbill 	caddr_t	gc_driver;
3040468Sbill 	char	*gc_name;
3140468Sbill 	dev_t	gc_root;
3240468Sbill } genericconf[] = {
33*41059Swilliam 	{ (caddr_t)&wddriver,	"wd",	makedev(1, 0),	},
3440468Sbill 	{ 0 },
3540468Sbill };
3640468Sbill 
3740468Sbill setconf()
3840468Sbill {
39*41059Swilliam #ifdef notdef
4040468Sbill 	register struct genericconf *gc;
4140468Sbill 	int unit, swaponroot = 0;
4240468Sbill 
4340468Sbill 	if (rootdev != NODEV)
4440468Sbill 		goto doswap;
4540468Sbill 	if (boothowto & RB_ASKNAME) {
4640468Sbill 		char name[128];
4740468Sbill retry:
4840468Sbill 		printf("root device? ");
4940468Sbill 		gets(name);
5040468Sbill 		for (gc = genericconf; gc->gc_driver; gc++)
5140468Sbill 			if (gc->gc_name[0] == name[0] &&
5240468Sbill 			    gc->gc_name[1] == name[1])
5340468Sbill 				goto gotit;
5440468Sbill 		goto bad;
5540468Sbill gotit:
5640468Sbill 		if (name[3] == '*') {
5740468Sbill 			name[3] = name[4];
5840468Sbill 			swaponroot++;
5940468Sbill 		}
6040468Sbill 		if (name[2] >= '0' && name[2] <= '7' && name[3] == 0) {
6140468Sbill 			unit = name[2] - '0';
6240468Sbill 			goto found;
6340468Sbill 		}
6440468Sbill 		printf("bad/missing unit number\n");
6540468Sbill bad:
6640468Sbill 		printf("use dk%%d\n");
6740468Sbill 		goto retry;
6840468Sbill 	}
6940468Sbill 	unit = 0;
7040468Sbill 	for (gc = genericconf; gc->gc_driver; gc++) {
7140468Sbill 		for (ui = vbdinit; ui->ui_driver; ui++) {
7240468Sbill 			if (ui->ui_alive == 0)
7340468Sbill 				continue;
7440468Sbill 			if (ui->ui_unit == 0 && ui->ui_driver ==
7540468Sbill 			    (struct vba_driver *)gc->gc_driver) {
7640468Sbill 				printf("root on %s0\n",
7740468Sbill 				    ui->ui_driver->ud_dname);
7840468Sbill 				goto found;
7940468Sbill 			}
8040468Sbill 		}
8140468Sbill 	}
8240468Sbill 	printf("no suitable root\n");
8340468Sbill 	asm("halt");
8440468Sbill found:
8540468Sbill 	gc->gc_root = makedev(major(gc->gc_root), unit*8);
8640468Sbill 	rootdev = gc->gc_root;
8740468Sbill doswap:
8840468Sbill 	swdevt[0].sw_dev = argdev = dumpdev =
8940468Sbill 	    makedev(major(rootdev), minor(rootdev)+1);
9040468Sbill 	/* swap size and dumplo set during autoconfigure */
9140468Sbill 	if (swaponroot)
9240468Sbill 		rootdev = dumpdev;
93*41059Swilliam #endif
9440468Sbill }
9540468Sbill 
9640468Sbill gets(cp)
9740468Sbill 	char *cp;
9840468Sbill {
9940468Sbill 	register char *lp;
10040468Sbill 	register c;
10140468Sbill 
10240468Sbill 	lp = cp;
10340468Sbill 	for (;;) {
10440468Sbill 		printf("%c", c = cngetc()&0177);
10540468Sbill 		switch (c) {
10640468Sbill 		case '\n':
10740468Sbill 		case '\r':
10840468Sbill 			*lp++ = '\0';
10940468Sbill 			return;
11040468Sbill 		case '\b':
11140468Sbill 		case '\177':
11240468Sbill 			if (lp > cp) {
11340468Sbill 				printf(" \b");
11440468Sbill 				lp--;
11540468Sbill 			}
11640468Sbill 			continue;
11740468Sbill 		case '#':
11840468Sbill 			lp--;
11940468Sbill 			if (lp < cp)
12040468Sbill 				lp = cp;
12140468Sbill 			continue;
12240468Sbill 		case '@':
12340468Sbill 		case 'u'&037:
12440468Sbill 			lp = cp;
12540468Sbill 			printf("%c", '\n');
12640468Sbill 			continue;
12740468Sbill 		default:
12840468Sbill 			*lp++ = c;
12940468Sbill 		}
13040468Sbill 	}
13140468Sbill }
132