1*41061Swilliam /*- 2*41061Swilliam * Copyright (c) 1990 The Regents of the University of California. 3*41061Swilliam * All rights reserved. 4*41061Swilliam * 5*41061Swilliam * This code is derived from software contributed to Berkeley by 6*41061Swilliam * William Jolitz. 7*41061Swilliam * 8*41061Swilliam * %sccs.include.386.c% 9*41061Swilliam * 10*41061Swilliam * @(#)swapgeneric.c 5.2 (Berkeley) 04/24/90 11*41061Swilliam */ 1240468Sbill 13*41061Swilliam 1440468Sbill #include "../machine/pte.h" 1540468Sbill 1640468Sbill #include "param.h" 1740468Sbill #include "conf.h" 1840468Sbill #include "buf.h" 1940468Sbill #include "vm.h" 2040468Sbill #include "systm.h" 2140468Sbill #include "reboot.h" 2240468Sbill 2340468Sbill /* 2440468Sbill * Generic configuration; all in one 2540468Sbill */ 2641059Swilliam dev_t rootdev = 0; 2741059Swilliam dev_t argdev = 1; 2841059Swilliam dev_t dumpdev = 1; 2940468Sbill int nswap; 3040468Sbill struct swdevt swdevt[] = { 3141059Swilliam { 1, 0, 4*4096 }, 3241059Swilliam { 0, 1, 0 }, 3340468Sbill }; 3440468Sbill long dumplo; 3540468Sbill int dmmin, dmmax, dmtext; 3640468Sbill 3741059Swilliam extern struct driver wddriver; 3840468Sbill 3940468Sbill struct genericconf { 4040468Sbill caddr_t gc_driver; 4140468Sbill char *gc_name; 4240468Sbill dev_t gc_root; 4340468Sbill } genericconf[] = { 4441059Swilliam { (caddr_t)&wddriver, "wd", makedev(1, 0), }, 4540468Sbill { 0 }, 4640468Sbill }; 4740468Sbill 4840468Sbill setconf() 4940468Sbill { 5041059Swilliam #ifdef notdef 5140468Sbill register struct genericconf *gc; 5240468Sbill int unit, swaponroot = 0; 5340468Sbill 5440468Sbill if (rootdev != NODEV) 5540468Sbill goto doswap; 5640468Sbill if (boothowto & RB_ASKNAME) { 5740468Sbill char name[128]; 5840468Sbill retry: 5940468Sbill printf("root device? "); 6040468Sbill gets(name); 6140468Sbill for (gc = genericconf; gc->gc_driver; gc++) 6240468Sbill if (gc->gc_name[0] == name[0] && 6340468Sbill gc->gc_name[1] == name[1]) 6440468Sbill goto gotit; 6540468Sbill goto bad; 6640468Sbill gotit: 6740468Sbill if (name[3] == '*') { 6840468Sbill name[3] = name[4]; 6940468Sbill swaponroot++; 7040468Sbill } 7140468Sbill if (name[2] >= '0' && name[2] <= '7' && name[3] == 0) { 7240468Sbill unit = name[2] - '0'; 7340468Sbill goto found; 7440468Sbill } 7540468Sbill printf("bad/missing unit number\n"); 7640468Sbill bad: 7740468Sbill printf("use dk%%d\n"); 7840468Sbill goto retry; 7940468Sbill } 8040468Sbill unit = 0; 8140468Sbill for (gc = genericconf; gc->gc_driver; gc++) { 8240468Sbill for (ui = vbdinit; ui->ui_driver; ui++) { 8340468Sbill if (ui->ui_alive == 0) 8440468Sbill continue; 8540468Sbill if (ui->ui_unit == 0 && ui->ui_driver == 8640468Sbill (struct vba_driver *)gc->gc_driver) { 8740468Sbill printf("root on %s0\n", 8840468Sbill ui->ui_driver->ud_dname); 8940468Sbill goto found; 9040468Sbill } 9140468Sbill } 9240468Sbill } 9340468Sbill printf("no suitable root\n"); 9440468Sbill asm("halt"); 9540468Sbill found: 9640468Sbill gc->gc_root = makedev(major(gc->gc_root), unit*8); 9740468Sbill rootdev = gc->gc_root; 9840468Sbill doswap: 9940468Sbill swdevt[0].sw_dev = argdev = dumpdev = 10040468Sbill makedev(major(rootdev), minor(rootdev)+1); 10140468Sbill /* swap size and dumplo set during autoconfigure */ 10240468Sbill if (swaponroot) 10340468Sbill rootdev = dumpdev; 10441059Swilliam #endif 10540468Sbill } 10640468Sbill 10740468Sbill gets(cp) 10840468Sbill char *cp; 10940468Sbill { 11040468Sbill register char *lp; 11140468Sbill register c; 11240468Sbill 11340468Sbill lp = cp; 11440468Sbill for (;;) { 11540468Sbill printf("%c", c = cngetc()&0177); 11640468Sbill switch (c) { 11740468Sbill case '\n': 11840468Sbill case '\r': 11940468Sbill *lp++ = '\0'; 12040468Sbill return; 12140468Sbill case '\b': 12240468Sbill case '\177': 12340468Sbill if (lp > cp) { 12440468Sbill printf(" \b"); 12540468Sbill lp--; 12640468Sbill } 12740468Sbill continue; 12840468Sbill case '#': 12940468Sbill lp--; 13040468Sbill if (lp < cp) 13140468Sbill lp = cp; 13240468Sbill continue; 13340468Sbill case '@': 13440468Sbill case 'u'&037: 13540468Sbill lp = cp; 13640468Sbill printf("%c", '\n'); 13740468Sbill continue; 13840468Sbill default: 13940468Sbill *lp++ = c; 14040468Sbill } 14140468Sbill } 14240468Sbill } 143