xref: /csrg-svn/sys/i386/i386/swapgeneric.c (revision 40468)
1*40468Sbill /*	swapgeneric.c	1.5	86/11/25	*/
2*40468Sbill 
3*40468Sbill #include "../machine/pte.h"
4*40468Sbill 
5*40468Sbill #include "param.h"
6*40468Sbill #include "conf.h"
7*40468Sbill #include "buf.h"
8*40468Sbill #include "vm.h"
9*40468Sbill #include "systm.h"
10*40468Sbill #include "reboot.h"
11*40468Sbill 
12*40468Sbill #include "../tahoe/cpu.h"
13*40468Sbill #include "../tahoe/cp.h"
14*40468Sbill #include "../tahoe/mtpr.h"
15*40468Sbill #include "../tahoevba/vbavar.h"
16*40468Sbill 
17*40468Sbill /*
18*40468Sbill  * Generic configuration;  all in one
19*40468Sbill  */
20*40468Sbill dev_t	rootdev = NODEV;
21*40468Sbill dev_t	argdev = NODEV;
22*40468Sbill dev_t	dumpdev = NODEV;
23*40468Sbill int	nswap;
24*40468Sbill struct	swdevt swdevt[] = {
25*40468Sbill 	{ -1,	1,	0 },
26*40468Sbill 	{ 0,	0,	0 },
27*40468Sbill };
28*40468Sbill long	dumplo;
29*40468Sbill int	dmmin, dmmax, dmtext;
30*40468Sbill 
31*40468Sbill extern	struct vba_driver vddriver;
32*40468Sbill 
33*40468Sbill struct	genericconf {
34*40468Sbill 	caddr_t	gc_driver;
35*40468Sbill 	char	*gc_name;
36*40468Sbill 	dev_t	gc_root;
37*40468Sbill } genericconf[] = {
38*40468Sbill 	{ (caddr_t)&vddriver,	"dk",	makedev(1, 0),	},
39*40468Sbill 	{ 0 },
40*40468Sbill };
41*40468Sbill 
42*40468Sbill setconf()
43*40468Sbill {
44*40468Sbill 	register struct vba_device *ui;
45*40468Sbill 	register struct genericconf *gc;
46*40468Sbill 	int unit, swaponroot = 0;
47*40468Sbill 
48*40468Sbill 	if (rootdev != NODEV)
49*40468Sbill 		goto doswap;
50*40468Sbill 	if (boothowto & RB_ASKNAME) {
51*40468Sbill 		char name[128];
52*40468Sbill retry:
53*40468Sbill 		printf("root device? ");
54*40468Sbill 		gets(name);
55*40468Sbill 		for (gc = genericconf; gc->gc_driver; gc++)
56*40468Sbill 			if (gc->gc_name[0] == name[0] &&
57*40468Sbill 			    gc->gc_name[1] == name[1])
58*40468Sbill 				goto gotit;
59*40468Sbill 		goto bad;
60*40468Sbill gotit:
61*40468Sbill 		if (name[3] == '*') {
62*40468Sbill 			name[3] = name[4];
63*40468Sbill 			swaponroot++;
64*40468Sbill 		}
65*40468Sbill 		if (name[2] >= '0' && name[2] <= '7' && name[3] == 0) {
66*40468Sbill 			unit = name[2] - '0';
67*40468Sbill 			goto found;
68*40468Sbill 		}
69*40468Sbill 		printf("bad/missing unit number\n");
70*40468Sbill bad:
71*40468Sbill 		printf("use dk%%d\n");
72*40468Sbill 		goto retry;
73*40468Sbill 	}
74*40468Sbill 	unit = 0;
75*40468Sbill 	for (gc = genericconf; gc->gc_driver; gc++) {
76*40468Sbill 		for (ui = vbdinit; ui->ui_driver; ui++) {
77*40468Sbill 			if (ui->ui_alive == 0)
78*40468Sbill 				continue;
79*40468Sbill 			if (ui->ui_unit == 0 && ui->ui_driver ==
80*40468Sbill 			    (struct vba_driver *)gc->gc_driver) {
81*40468Sbill 				printf("root on %s0\n",
82*40468Sbill 				    ui->ui_driver->ud_dname);
83*40468Sbill 				goto found;
84*40468Sbill 			}
85*40468Sbill 		}
86*40468Sbill 	}
87*40468Sbill 	printf("no suitable root\n");
88*40468Sbill 	asm("halt");
89*40468Sbill found:
90*40468Sbill 	gc->gc_root = makedev(major(gc->gc_root), unit*8);
91*40468Sbill 	rootdev = gc->gc_root;
92*40468Sbill doswap:
93*40468Sbill 	swdevt[0].sw_dev = argdev = dumpdev =
94*40468Sbill 	    makedev(major(rootdev), minor(rootdev)+1);
95*40468Sbill 	/* swap size and dumplo set during autoconfigure */
96*40468Sbill 	if (swaponroot)
97*40468Sbill 		rootdev = dumpdev;
98*40468Sbill }
99*40468Sbill 
100*40468Sbill gets(cp)
101*40468Sbill 	char *cp;
102*40468Sbill {
103*40468Sbill 	register char *lp;
104*40468Sbill 	register c;
105*40468Sbill 
106*40468Sbill 	lp = cp;
107*40468Sbill 	for (;;) {
108*40468Sbill 		printf("%c", c = cngetc()&0177);
109*40468Sbill 		switch (c) {
110*40468Sbill 		case '\n':
111*40468Sbill 		case '\r':
112*40468Sbill 			*lp++ = '\0';
113*40468Sbill 			return;
114*40468Sbill 		case '\b':
115*40468Sbill 		case '\177':
116*40468Sbill 			if (lp > cp) {
117*40468Sbill 				printf(" \b");
118*40468Sbill 				lp--;
119*40468Sbill 			}
120*40468Sbill 			continue;
121*40468Sbill 		case '#':
122*40468Sbill 			lp--;
123*40468Sbill 			if (lp < cp)
124*40468Sbill 				lp = cp;
125*40468Sbill 			continue;
126*40468Sbill 		case '@':
127*40468Sbill 		case 'u'&037:
128*40468Sbill 			lp = cp;
129*40468Sbill 			printf("%c", '\n');
130*40468Sbill 			continue;
131*40468Sbill 		default:
132*40468Sbill 			*lp++ = c;
133*40468Sbill 		}
134*40468Sbill 	}
135*40468Sbill }
136