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