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 * from: @(#)swapgeneric.c 5.5 (Berkeley) 5/9/91
37 * $FreeBSD: src/sys/i386/i386/swapgeneric.c,v 1.17.2.2 1999/09/05 08:11:16 peter Exp $
38 */
39
40 #include <sys/param.h>
41 #include <sys/conf.h>
42 #include <sys/buf.h>
43 #include <sys/systm.h>
44 #include <sys/reboot.h>
45 #include <sys/disklabel.h>
46 #include <sys/kernel.h>
47
48 #include <i386/i386/cons.h>
49 #include <machine/md_var.h>
50
51 #include "wd.h"
52 #include "fd.h"
53 #include "sd.h"
54 #include "vn.h"
55 #include "cd.h"
56 #include "mcd.h"
57 #include "scd.h"
58 #include "matcd.h"
59 #include "od.h"
60
61 /*
62 * Generic configuration; all in one
63 */
64 dev_t rootdev = NODEV;
65 dev_t dumpdev = NODEV;
66
67 #ifdef notused
68 int nswap;
69 struct swdevt swdevt[] = {
70 { makedev (0xFF, 0x00000001), 0, 0 },
71 #if NVN > 0
72 { makedev (15, 0x00000001), 0, 0 },
73 #endif
74 { NODEV, 0, 0 }, /* For NFS diskless */
75 { NODEV, 0, 0 },
76 };
77 int dmmin, dmmax, dmtext;
78 #endif
79
80 #ifdef NFS
81 extern int (*mountroot) __P((void));
82 extern int nfs_mountroot __P((void));
83 #endif
84
85 void gets __P((char *));
86
87 struct genericconf {
88 char *gc_name;
89 dev_t gc_root;
90 } genericconf[] = {
91 #if NWD > 0
92 { "wd", makedev(0, 0x00000000), },
93 #endif
94 #if NFD > 0
95 { "fd", makedev(2, 0x00000000), },
96 #endif
97 #if NSD > 0
98 { "sd", makedev(4, 0x00000000), },
99 #endif
100 #if NCD > 0
101 { "cd", makedev(6, 0x00000000), },
102 #endif
103 #if NMCD > 0
104 { "mcd", makedev(7, 0x00000000), },
105 #endif
106 #if NSCD > 0
107 { "scd", makedev(16,0x00000000), },
108 #endif
109 #if NMATCD > 0
110 { "matcd", makedev(17,0x00000000), },
111 #endif
112 #if NOD > 0
113 { "od", makedev(20,0x00000000), },
114 #endif
115 { 0 },
116 };
117
118 void setconf(void)
119 {
120 register struct genericconf *gc;
121 int bd;
122 int unit, swaponroot = 0;
123
124 if (rootdev != NODEV)
125 return;
126 if (boothowto & RB_ASKNAME) {
127 char name[128];
128 retry:
129 printf("root device? ");
130 gets(name);
131 for (gc = genericconf; gc->gc_name; gc++)
132 if (gc->gc_name[0] == name[0] &&
133 gc->gc_name[1] == name[1])
134 goto gotit;
135 goto bad;
136 gotit:
137 if (name[3] == '*') {
138 name[3] = name[4];
139 swaponroot++;
140 }
141 if (name[2] >= '' && name[2] <= '7' && name[3] == 0) {
142 unit = name[2] - '';
143 goto found;
144 }
145 printf("bad/missing unit number\n");
146 bad:
147 printf("use dk%%d\n");
148 goto retry;
149 }
150 #ifdef NFS
151 if (mountroot == nfs_mountroot) {
152 /*
153 * The NFS code in nfs_vfsops.c handles root and swap
154 * for us if we're booting diskless. This is just to
155 * make swapconf() happy.
156 */
157 dumplo = -1;
158 return;
159 }
160 #endif
161 unit = 0;
162 for (gc = genericconf; gc->gc_name; gc++) {
163 for (bd = 0; bd < nblkdev; bd++) {
164 if (!strcmp(bdevsw[bd]->d_name, gc->gc_name)) {
165 printf("root on %s0\n", bdevsw[bd]->d_name);
166 goto found;
167 }
168 }
169 }
170 printf("no suitable root -- press any key to reboot\n\n");
171 cngetc();
172 cpu_reset();
173 for(;;) ;
174 found:
175 gc->gc_root = makedev(major(gc->gc_root), unit * MAXPARTITIONS);
176 rootdev = gc->gc_root;
177 }
178
179 void gets(cp)
180 char *cp;
181 {
182 register char *lp;
183 register c;
184
185 lp = cp;
186 for (;;) {
187 printf("%c", c = cngetc()&0177);
188 switch (c) {
189 case -1:
190 case '\n':
191 case '\r':
192 *lp++ = '\0';
193 return;
194 case '\b':
195 case '\177':
196 if (lp > cp) {
197 printf(" \b");
198 lp--;
199 }
200 continue;
201 case '#':
202 lp--;
203 if (lp < cp)
204 lp = cp;
205 continue;
206 case '@':
207 case 'u'&037:
208 lp = cp;
209 printf("%c", '\n');
210 continue;
211 default:
212 *lp++ = c;
213 }
214 }
215 }
Cache object: d861dce0d3c20d1f3d80a117a44bc21c
|