]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/alpha/alpha/autoconf.c
This commit was generated by cvs2svn to compensate for changes in r58653,
[FreeBSD/FreeBSD.git] / sys / alpha / alpha / autoconf.c
1 /*-
2  * Copyright (c) 1998 Doug Rabson
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  *
14  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24  * SUCH DAMAGE.
25  *
26  * $FreeBSD$
27  */
28
29 #include "opt_bootp.h"
30 #include "opt_ffs.h"
31 #include "opt_cd9660.h"
32 #include "opt_nfs.h"
33 #include "opt_nfsroot.h"
34
35 #include <sys/param.h>
36 #include <sys/systm.h>
37 #include <sys/conf.h>
38 #include <sys/disklabel.h>
39 #include <sys/diskslice.h> /* for BASE_SLICE, MAX_SLICES */
40 #include <sys/reboot.h>
41 #include <sys/kernel.h>
42 #include <sys/mount.h>
43 #include <sys/sysctl.h>
44 #include <sys/bus.h>
45 #include <sys/devicestat.h>
46 #include <sys/cons.h>
47
48 #include <machine/ipl.h>
49 #include <machine/md_var.h>
50 #include <machine/cpuconf.h>
51 #include <machine/rpb.h>
52 #include <machine/bootinfo.h>
53
54 #include <cam/cam.h>
55 #include <cam/cam_ccb.h>
56 #include <cam/cam_sim.h>
57 #include <cam/cam_periph.h>
58 #include <cam/cam_xpt_sim.h>
59 #include <cam/cam_debug.h>
60
61 static void     configure __P((void *));
62 SYSINIT(configure, SI_SUB_CONFIGURE, SI_ORDER_THIRD, configure, NULL)
63
64 static void     configure_finish __P((void));
65 static void     configure_start __P((void));
66
67 #include "isa.h"
68 #if NISA > 0
69 #include <isa/isavar.h>
70 device_t isa_bus_device = 0;
71 #endif
72
73 extern int nfs_diskless_valid;
74
75 dev_t   rootdev = NODEV;
76 dev_t   dumpdev = NODEV;
77
78 static void
79 configure_start()
80 {
81 }
82
83 static void
84 configure_finish()
85 {
86 }
87
88 #if 0
89
90 static int
91 atoi(const char *s)
92 {
93     int n = 0;
94     while (*s >= '0' && *s <= '9')
95         n = n * 10 + (*s++ - '0');
96     return n;
97 }
98
99 static const char *
100 bootdev_field(int which)
101 {
102         char *p = bootinfo.booted_dev;
103         char *q;
104         static char field[128];
105
106         /* Skip characters to find the right field */
107         for (; which; which--) {
108                 while (*p != ' ' && *p != '\0')
109                         p++;
110                 if (*p)
111                         p++;
112         }
113
114         /* Copy out the field and return it */
115         q = field;
116         while (*p != ' ' && *p != '\0')
117                 *q++ = *p++;
118         *q = '\0';
119
120         return field;
121 }
122
123 static const char *
124 bootdev_protocol(void)
125 {
126         return bootdev_field(0);
127 }
128
129 static int
130 bootdev_slot(void)
131 {
132         return atoi(bootdev_field(2));
133 }
134
135 static int
136 bootdev_unit(void)
137 {
138         return atoi(bootdev_field(5));
139 }
140
141 static int
142 bootdev_bus(void)
143 {
144         return atoi(bootdev_field(1));
145 }
146
147 static int
148 bootdev_channel(void)
149 {
150         return atoi(bootdev_field(3));
151 }
152
153 static const char *
154 bootdev_remote_address(void)
155 {
156         return bootdev_field(4);
157 }
158
159 static int
160 bootdev_boot_dev_type(void)
161 {
162         return atoi(bootdev_field(6));
163 }
164
165 static const char *
166 bootdev_ctrl_dev_type(void)
167 {
168         return bootdev_field(7);
169 }
170
171 #endif
172
173 /*
174  * Determine i/o configuration for a machine.
175  */
176 static void
177 configure(void *dummy)
178 {
179         configure_start();
180
181         device_add_child(root_bus, platform.iobus, 0);
182
183         root_bus_configure();
184
185         if((hwrpb->rpb_type != ST_DEC_3000_300) &&
186            (hwrpb->rpb_type != ST_DEC_3000_500)){
187                 /*
188                  * Probe ISA devices after everything.
189                  */
190 #if NISA > 0
191                 if (isa_bus_device)
192                         isa_probe_children(isa_bus_device);
193 #endif
194         } 
195         configure_finish();
196
197         cninit_finish();
198
199         /*
200          * Now we're ready to handle (pending) interrupts.
201          * XXX this is slightly misplaced.
202          */
203         spl0();
204
205         cold = 0;
206 }
207
208 /*
209  * Do legacy root filesystem discovery.  This isn't really
210  * needed on the Alpha, which has always used the loader.
211  */
212 void
213 cpu_rootconf()
214 {
215         int     order = 0;
216 #if defined(NFS) && defined(NFS_ROOT)
217 #if !defined(BOOTP_NFSROOT)
218         if (nfs_diskless_valid)
219 #endif
220                 rootdevnames[order++] = "nfs:";
221 #endif
222
223 #if defined(FFS) && defined(FFS_ROOT)
224         rootdevnames[order++] = "ufs:da0a";
225 #endif
226 }
227 SYSINIT(cpu_rootconf, SI_SUB_ROOT_CONF, SI_ORDER_FIRST, cpu_rootconf, NULL)