141061Swilliam /*- 241061Swilliam * Copyright (c) 1990 The Regents of the University of California. 341061Swilliam * All rights reserved. 441061Swilliam * 541061Swilliam * This code is derived from software contributed to Berkeley by 641061Swilliam * William Jolitz. 741061Swilliam * 849605Sbostic * %sccs.include.redist.c% 941061Swilliam * 10*63502Smckusick * @(#)swapgeneric.c 5.7 (Berkeley) 06/16/93 1141061Swilliam */ 1240468Sbill 1356511Sbostic #include <machine/pte.h> 1440468Sbill 1556511Sbostic #include <sys/param.h> 1656511Sbostic #include <sys/conf.h> 1756511Sbostic #include <sys/buf.h> 1856511Sbostic #include <sys/vm.h> 1956511Sbostic #include <sys/systm.h> 2056511Sbostic #include <sys/reboot.h> 2140468Sbill 2240468Sbill /* 2340468Sbill * Generic configuration; all in one 2440468Sbill */ 2543599Sdonahn dev_t rootdev = makedev(0,0); 2643599Sdonahn dev_t dumpdev = makedev(0,1); 2740468Sbill int nswap; 2840468Sbill struct swdevt swdevt[] = { 2943599Sdonahn { 1, 0, 0 }, 30*63502Smckusick { NODEV, 1, 0 }, 3140468Sbill }; 3240468Sbill long dumplo; 3340468Sbill int dmmin, dmmax, dmtext; 3440468Sbill 3541059Swilliam extern struct driver wddriver; 3640468Sbill 3740468Sbill struct genericconf { 3840468Sbill caddr_t gc_driver; 3940468Sbill char *gc_name; 4040468Sbill dev_t gc_root; 4140468Sbill } genericconf[] = { 4243599Sdonahn { (caddr_t)&wddriver, "wd", makedev(0, 0), }, 4340468Sbill { 0 }, 4440468Sbill }; 4540468Sbill 4640468Sbill setconf() 4740468Sbill { 4841059Swilliam #ifdef notdef 4940468Sbill register struct genericconf *gc; 5040468Sbill int unit, swaponroot = 0; 5140468Sbill 5240468Sbill if (rootdev != NODEV) 5340468Sbill goto doswap; 5440468Sbill if (boothowto & RB_ASKNAME) { 5540468Sbill char name[128]; 5640468Sbill retry: 5740468Sbill printf("root device? "); 5840468Sbill gets(name); 5940468Sbill for (gc = genericconf; gc->gc_driver; gc++) 6040468Sbill if (gc->gc_name[0] == name[0] && 6140468Sbill gc->gc_name[1] == name[1]) 6240468Sbill goto gotit; 6340468Sbill goto bad; 6440468Sbill gotit: 6540468Sbill if (name[3] == '*') { 6640468Sbill name[3] = name[4]; 6740468Sbill swaponroot++; 6840468Sbill } 6940468Sbill if (name[2] >= '0' && name[2] <= '7' && name[3] == 0) { 7040468Sbill unit = name[2] - '0'; 7140468Sbill goto found; 7240468Sbill } 7340468Sbill printf("bad/missing unit number\n"); 7440468Sbill bad: 7540468Sbill printf("use dk%%d\n"); 7640468Sbill goto retry; 7740468Sbill } 7840468Sbill unit = 0; 7940468Sbill for (gc = genericconf; gc->gc_driver; gc++) { 8040468Sbill for (ui = vbdinit; ui->ui_driver; ui++) { 8140468Sbill if (ui->ui_alive == 0) 8240468Sbill continue; 8340468Sbill if (ui->ui_unit == 0 && ui->ui_driver == 8440468Sbill (struct vba_driver *)gc->gc_driver) { 8540468Sbill printf("root on %s0\n", 8640468Sbill ui->ui_driver->ud_dname); 8740468Sbill goto found; 8840468Sbill } 8940468Sbill } 9040468Sbill } 9140468Sbill printf("no suitable root\n"); 9240468Sbill asm("halt"); 9340468Sbill found: 9440468Sbill gc->gc_root = makedev(major(gc->gc_root), unit*8); 9540468Sbill rootdev = gc->gc_root; 9640468Sbill doswap: 9740468Sbill swdevt[0].sw_dev = argdev = dumpdev = 9840468Sbill makedev(major(rootdev), minor(rootdev)+1); 9940468Sbill /* swap size and dumplo set during autoconfigure */ 10040468Sbill if (swaponroot) 10140468Sbill rootdev = dumpdev; 10241059Swilliam #endif 10340468Sbill } 10440468Sbill 10540468Sbill gets(cp) 10640468Sbill char *cp; 10740468Sbill { 10840468Sbill register char *lp; 10940468Sbill register c; 11040468Sbill 11140468Sbill lp = cp; 11240468Sbill for (;;) { 11340468Sbill printf("%c", c = cngetc()&0177); 11440468Sbill switch (c) { 11540468Sbill case '\n': 11640468Sbill case '\r': 11740468Sbill *lp++ = '\0'; 11840468Sbill return; 11940468Sbill case '\b': 12040468Sbill case '\177': 12140468Sbill if (lp > cp) { 12240468Sbill printf(" \b"); 12340468Sbill lp--; 12440468Sbill } 12540468Sbill continue; 12640468Sbill case '#': 12740468Sbill lp--; 12840468Sbill if (lp < cp) 12940468Sbill lp = cp; 13040468Sbill continue; 13140468Sbill case '@': 13240468Sbill case 'u'&037: 13340468Sbill lp = cp; 13440468Sbill printf("%c", '\n'); 13540468Sbill continue; 13640468Sbill default: 13740468Sbill *lp++ = c; 13840468Sbill } 13940468Sbill } 14040468Sbill } 141