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