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.7 (Berkeley) 12/16/90 7 */ 8 9 #include "sys/param.h" 10 #include "sys/conf.h" 11 #include "sys/buf.h" 12 #include "sys/vm.h" 13 #include "sys/systm.h" 14 #include "sys/reboot.h" 15 16 #include "../include/pte.h" 17 #include "../include/cpu.h" 18 #include "cp.h" 19 #include "../include/mtpr.h" 20 21 #include "../vba/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 extern struct vba_driver hdcdriver; 39 40 struct genericconf { 41 caddr_t gc_driver; 42 char *gc_name; 43 dev_t gc_root; 44 } genericconf[] = { 45 { (caddr_t)&vddriver, "dk", makedev(1, 0), }, 46 { (caddr_t)&hdcdriver, "hd", makedev(2, 0), }, 47 { 0 }, 48 }; 49 50 setconf() 51 { 52 register struct vba_device *ui; 53 register struct genericconf *gc; 54 register char *cp, *gp; 55 int unit, swaponroot = 0; 56 57 if (rootdev != NODEV) 58 goto doswap; 59 unit = 0; 60 if (boothowto & RB_ASKNAME) { 61 char name[128]; 62 retry: 63 printf("root device? "); 64 gets(name); 65 for (gc = genericconf; gc->gc_driver; gc++) 66 for (cp = name, gp = gc->gc_name; *cp == *gp; cp++) 67 if (!*++gp) 68 goto gotit; 69 printf("use"); 70 for (gc = genericconf; gc->gc_driver; gc++) 71 printf(" %s%%d", gc->gc_name); 72 printf("\n"); 73 goto retry; 74 gotit: 75 cp = name + 2; 76 if (*cp < '0' || *cp > '9') { 77 printf("bad/missing unit number\n"); 78 goto retry; 79 } 80 while (*cp >= '0' && *cp <= '9') 81 unit = 10 * unit + *cp++ - '0'; 82 if (*cp == '*') 83 swaponroot++; 84 } 85 for (gc = genericconf; gc->gc_driver; gc++) { 86 for (ui = vbdinit; ui->ui_driver; ui++) { 87 if (ui->ui_alive == 0) 88 continue; 89 if (ui->ui_unit == unit && ui->ui_driver == 90 (struct vba_driver *)gc->gc_driver) { 91 printf("root on %s%d\n", 92 ui->ui_driver->ud_dname, unit); 93 goto found; 94 } 95 } 96 } 97 printf("no suitable root\n"); 98 asm("halt"); 99 found: 100 gc->gc_root = makedev(major(gc->gc_root), unit*8); 101 rootdev = gc->gc_root; 102 doswap: 103 swdevt[0].sw_dev = argdev = dumpdev = 104 makedev(major(rootdev), minor(rootdev)+1); 105 /* swap size and dumplo set during autoconfigure */ 106 if (swaponroot) 107 rootdev = dumpdev; 108 } 109 110 gets(buf) 111 char *buf; 112 { 113 register int c; 114 register char *lp; 115 116 for (lp = buf;;) { 117 printf("%c", c = cngetc()&0177); 118 switch (c) { 119 case '\n': 120 case '\r': 121 *lp = '\0'; 122 return; 123 case '\b': 124 case '\177': 125 if (lp > buf) { 126 --lp; 127 printf("\b \b"); 128 } 129 break; 130 case '#': 131 if (lp > buf) 132 --lp; 133 break; 134 case 'r'&037: 135 *lp = 0; 136 printf("\n"); 137 printf("%s", buf); 138 break; 139 case '@': 140 case 'u'&037: 141 case 'w'&037: 142 lp = buf; 143 printf("%c", '\n'); 144 break; 145 default: 146 *lp++ = c; 147 } 148 } 149 /* NOTREACHED */ 150 } 151