386BSD 0.1 development
[unix-history] / usr / src / sys.386bsd / i386 / i386 / swapgeneric.c
CommitLineData
28a753c6
WJ
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 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed by the University of
19 * California, Berkeley and its contributors.
20 * 4. Neither the name of the University nor the names of its contributors
21 * may be used to endorse or promote products derived from this software
22 * without specific prior written permission.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.
35 *
36 * @(#)swapgeneric.c 5.5 (Berkeley) 5/9/91
37 */
38
39#include "machine/pte.h"
40
41#include "sys/param.h"
42#include "sys/conf.h"
43#include "sys/buf.h"
44#include "sys/vm.h"
45#include "sys/systm.h"
46#include "sys/reboot.h"
47
48/*
49 * Generic configuration; all in one
50 */
51dev_t rootdev = makedev(0,0);
52dev_t dumpdev = makedev(0,1);
53int nswap;
54struct swdevt swdevt[] = {
55 { 1, 0, 0 },
56 { 0, 1, 0 },
57};
58long dumplo;
59int dmmin, dmmax, dmtext;
60
61extern struct driver wddriver;
62
63struct genericconf {
64 caddr_t gc_driver;
65 char *gc_name;
66 dev_t gc_root;
67} genericconf[] = {
68 { (caddr_t)&wddriver, "wd", makedev(0, 0), },
69 { 0 },
70};
71
72setconf()
73{
74#ifdef notdef
75 register struct genericconf *gc;
76 int unit, swaponroot = 0;
77
78 if (rootdev != NODEV)
79 goto doswap;
80 if (boothowto & RB_ASKNAME) {
81 char name[128];
82retry:
83 printf("root device? ");
84 gets(name);
85 for (gc = genericconf; gc->gc_driver; gc++)
86 if (gc->gc_name[0] == name[0] &&
87 gc->gc_name[1] == name[1])
88 goto gotit;
89 goto bad;
90gotit:
91 if (name[3] == '*') {
92 name[3] = name[4];
93 swaponroot++;
94 }
95 if (name[2] >= '0' && name[2] <= '7' && name[3] == 0) {
96 unit = name[2] - '0';
97 goto found;
98 }
99 printf("bad/missing unit number\n");
100bad:
101 printf("use dk%%d\n");
102 goto retry;
103 }
104 unit = 0;
105 for (gc = genericconf; gc->gc_driver; gc++) {
106 for (ui = vbdinit; ui->ui_driver; ui++) {
107 if (ui->ui_alive == 0)
108 continue;
109 if (ui->ui_unit == 0 && ui->ui_driver ==
110 (struct vba_driver *)gc->gc_driver) {
111 printf("root on %s0\n",
112 ui->ui_driver->ud_dname);
113 goto found;
114 }
115 }
116 }
117 printf("no suitable root\n");
118 asm("halt");
119found:
120 gc->gc_root = makedev(major(gc->gc_root), unit*8);
121 rootdev = gc->gc_root;
122doswap:
123 swdevt[0].sw_dev = argdev = dumpdev =
124 makedev(major(rootdev), minor(rootdev)+1);
125 /* swap size and dumplo set during autoconfigure */
126 if (swaponroot)
127 rootdev = dumpdev;
128#endif
129}
130
131gets(cp)
132 char *cp;
133{
134 register char *lp;
135 register c;
136
137 lp = cp;
138 for (;;) {
139 printf("%c", c = cngetc()&0177);
140 switch (c) {
141 case '\n':
142 case '\r':
143 *lp++ = '\0';
144 return;
145 case '\b':
146 case '\177':
147 if (lp > cp) {
148 printf(" \b");
149 lp--;
150 }
151 continue;
152 case '#':
153 lp--;
154 if (lp < cp)
155 lp = cp;
156 continue;
157 case '@':
158 case 'u'&037:
159 lp = cp;
160 printf("%c", '\n');
161 continue;
162 default:
163 *lp++ = c;
164 }
165 }
166}