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 * 841061Swilliam * %sccs.include.386.c% 941061Swilliam * 10*43599Sdonahn * @(#)swapgeneric.c 5.3 (Berkeley) 06/23/90 1141061Swilliam */ 1240468Sbill 13*43599Sdonahn /* swapgeneric.c 1.5 86/11/25 */ 1441061Swilliam 1540468Sbill #include "../machine/pte.h" 1640468Sbill 1740468Sbill #include "param.h" 1840468Sbill #include "conf.h" 1940468Sbill #include "buf.h" 2040468Sbill #include "vm.h" 2140468Sbill #include "systm.h" 2240468Sbill #include "reboot.h" 2340468Sbill 2440468Sbill /* 2540468Sbill * Generic configuration; all in one 2640468Sbill */ 27*43599Sdonahn dev_t rootdev = makedev(0,0); 28*43599Sdonahn dev_t argdev = makedev(0,1); 29*43599Sdonahn dev_t dumpdev = makedev(0,1); 3040468Sbill int nswap; 3140468Sbill struct swdevt swdevt[] = { 32*43599Sdonahn { 1, 0, 0 }, 3341059Swilliam { 0, 1, 0 }, 3440468Sbill }; 3540468Sbill long dumplo; 3640468Sbill int dmmin, dmmax, dmtext; 3740468Sbill 3841059Swilliam extern struct driver wddriver; 3940468Sbill 4040468Sbill struct genericconf { 4140468Sbill caddr_t gc_driver; 4240468Sbill char *gc_name; 4340468Sbill dev_t gc_root; 4440468Sbill } genericconf[] = { 45*43599Sdonahn { (caddr_t)&wddriver, "wd", makedev(0, 0), }, 4640468Sbill { 0 }, 4740468Sbill }; 4840468Sbill 4940468Sbill setconf() 5040468Sbill { 5141059Swilliam #ifdef notdef 5240468Sbill register struct genericconf *gc; 5340468Sbill int unit, swaponroot = 0; 5440468Sbill 5540468Sbill if (rootdev != NODEV) 5640468Sbill goto doswap; 5740468Sbill if (boothowto & RB_ASKNAME) { 5840468Sbill char name[128]; 5940468Sbill retry: 6040468Sbill printf("root device? "); 6140468Sbill gets(name); 6240468Sbill for (gc = genericconf; gc->gc_driver; gc++) 6340468Sbill if (gc->gc_name[0] == name[0] && 6440468Sbill gc->gc_name[1] == name[1]) 6540468Sbill goto gotit; 6640468Sbill goto bad; 6740468Sbill gotit: 6840468Sbill if (name[3] == '*') { 6940468Sbill name[3] = name[4]; 7040468Sbill swaponroot++; 7140468Sbill } 7240468Sbill if (name[2] >= '0' && name[2] <= '7' && name[3] == 0) { 7340468Sbill unit = name[2] - '0'; 7440468Sbill goto found; 7540468Sbill } 7640468Sbill printf("bad/missing unit number\n"); 7740468Sbill bad: 7840468Sbill printf("use dk%%d\n"); 7940468Sbill goto retry; 8040468Sbill } 8140468Sbill unit = 0; 8240468Sbill for (gc = genericconf; gc->gc_driver; gc++) { 8340468Sbill for (ui = vbdinit; ui->ui_driver; ui++) { 8440468Sbill if (ui->ui_alive == 0) 8540468Sbill continue; 8640468Sbill if (ui->ui_unit == 0 && ui->ui_driver == 8740468Sbill (struct vba_driver *)gc->gc_driver) { 8840468Sbill printf("root on %s0\n", 8940468Sbill ui->ui_driver->ud_dname); 9040468Sbill goto found; 9140468Sbill } 9240468Sbill } 9340468Sbill } 9440468Sbill printf("no suitable root\n"); 9540468Sbill asm("halt"); 9640468Sbill found: 9740468Sbill gc->gc_root = makedev(major(gc->gc_root), unit*8); 9840468Sbill rootdev = gc->gc_root; 9940468Sbill doswap: 10040468Sbill swdevt[0].sw_dev = argdev = dumpdev = 10140468Sbill makedev(major(rootdev), minor(rootdev)+1); 10240468Sbill /* swap size and dumplo set during autoconfigure */ 10340468Sbill if (swaponroot) 10440468Sbill rootdev = dumpdev; 10541059Swilliam #endif 10640468Sbill } 10740468Sbill 10840468Sbill gets(cp) 10940468Sbill char *cp; 11040468Sbill { 11140468Sbill register char *lp; 11240468Sbill register c; 11340468Sbill 11440468Sbill lp = cp; 11540468Sbill for (;;) { 11640468Sbill printf("%c", c = cngetc()&0177); 11740468Sbill switch (c) { 11840468Sbill case '\n': 11940468Sbill case '\r': 12040468Sbill *lp++ = '\0'; 12140468Sbill return; 12240468Sbill case '\b': 12340468Sbill case '\177': 12440468Sbill if (lp > cp) { 12540468Sbill printf(" \b"); 12640468Sbill lp--; 12740468Sbill } 12840468Sbill continue; 12940468Sbill case '#': 13040468Sbill lp--; 13140468Sbill if (lp < cp) 13240468Sbill lp = cp; 13340468Sbill continue; 13440468Sbill case '@': 13540468Sbill case 'u'&037: 13640468Sbill lp = cp; 13740468Sbill printf("%c", '\n'); 13840468Sbill continue; 13940468Sbill default: 14040468Sbill *lp++ = c; 14140468Sbill } 14240468Sbill } 14340468Sbill } 144