]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/alpha/alpha/autoconf.c
This commit was generated by cvs2svn to compensate for changes in r40767,
[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  *      $Id: autoconf.c,v 1.11 1998/10/06 08:38:04 dfr Exp $
27  */
28
29 #include "opt_bootp.h"
30 #include "opt_ffs.h"
31 #include "opt_cd9660.h"
32 #include "opt_mfs.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
47 #include <machine/cons.h>
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 #include "scbus.h"
62
63 static void     configure __P((void *));
64 SYSINIT(configure, SI_SUB_CONFIGURE, SI_ORDER_FIRST, configure, NULL)
65
66 static void     configure_finish __P((void));
67 static void     configure_start __P((void));
68 device_t        isa_bus_device = 0;
69 struct cam_sim *boot_sim = 0;
70
71 extern void xpt_init __P((void));
72
73 static void
74 configure_start()
75 {
76 #if NSCBUS > 0
77         xpt_init();
78 #endif
79 }
80
81 static void
82 configure_finish()
83 {
84 }
85
86 extern void pci_configure(void);
87
88 static int
89 atoi(const char *s)
90 {
91     int n = 0;
92     while (*s >= '0' && *s <= '9')
93         n = n * 10 + (*s++ - '0');
94     return n;
95 }
96
97 static const char *
98 bootdev_field(int which)
99 {
100         char *p = bootinfo.booted_dev;
101         char *q;
102         static char field[128];
103
104         /* Skip characters to find the right field */
105         for (; which; which--) {
106                 while (*p != ' ' && *p != '\0')
107                         p++;
108                 if (*p)
109                         p++;
110         }
111
112         /* Copy out the field and return it */
113         q = field;
114         while (*p != ' ' && *p != '\0')
115                 *q++ = *p++;
116         *q = '\0';
117
118         return field;
119 }
120
121 static const char *
122 bootdev_protocol(void)
123 {
124         return bootdev_field(0);
125 }
126
127 static int
128 bootdev_bus(void)
129 {
130         return atoi(bootdev_field(1));
131 }
132
133 static int
134 bootdev_slot(void)
135 {
136         return atoi(bootdev_field(2));
137 }
138
139 static int
140 bootdev_channel(void)
141 {
142         return atoi(bootdev_field(3));
143 }
144
145 static const char *
146 bootdev_remote_address(void)
147 {
148         return bootdev_field(4);
149 }
150
151 static int
152 bootdev_unit(void)
153 {
154         return atoi(bootdev_field(5));
155 }
156
157 static int
158 bootdev_boot_dev_type(void)
159 {
160         return atoi(bootdev_field(6));
161 }
162
163 static const char *
164 bootdev_ctrl_dev_type(void)
165 {
166         return bootdev_field(7);
167 }
168
169 void
170 alpha_register_pci_scsi(int bus, int slot, struct cam_sim *sim)
171 {
172         if (!strcmp(bootdev_protocol(), "SCSI")) {
173                 int boot_slot = bootdev_slot();
174                 if (bus == boot_slot / 1000
175                     && slot == boot_slot % 1000)
176                         boot_sim = sim;
177         }
178 }
179
180 /*
181  * Determine i/o configuration for a machine.
182  */
183 static void
184 configure(void *dummy)
185 {
186         configure_start();
187
188         device_add_child(root_bus, platform.iobus, 0, 0);
189
190         root_bus_configure();
191
192         if((hwrpb->rpb_type != ST_DEC_3000_300) &&
193            (hwrpb->rpb_type != ST_DEC_3000_500)){
194                 pci_configure();
195
196                 /*
197                  * Probe ISA devices after everything.
198                  */
199                 if (isa_bus_device)
200                         bus_generic_attach(isa_bus_device);
201         } 
202         configure_finish();
203
204         cninit_finish();
205
206         /*
207          * Now we're ready to handle (pending) interrupts.
208          * XXX this is slightly misplaced.
209          */
210         spl0();
211
212         cold = 0;
213 }
214
215 void
216 cpu_rootconf()
217 {
218 #ifdef MFS_ROOT
219         if (!mountrootfsname) {
220                 extern u_char *mfs_getimage __P((void));
221
222                 if (bootverbose)
223                         printf("Considering MFS root f/s.\n");
224                 if (mfs_getimage())
225                         mountrootfsname = "mfs";
226                 else if (bootverbose)
227                         printf("No MFS image available as root f/s.\n");
228         }
229 #endif
230
231 #if defined(FFS) || defined(FFS_ROOT)
232         if (!mountrootfsname) {
233                 static char rootname[] = "da0a";
234
235                 if (bootverbose)
236                         printf("Considering UFS root f/s.\n");
237                 mountrootfsname = "ufs";
238
239                 if (boot_sim) {
240                         struct cam_path *path;
241                         struct cam_periph *periph;
242             
243                         xpt_create_path(&path, NULL,
244                                         cam_sim_path(boot_sim),
245                                         bootdev_unit() / 100, 0);
246                         periph = cam_periph_find(path, "da");
247
248                         if (periph)
249                                 rootdev = makedev(4, dkmakeminor(periph->unit_number,
250                                                                  COMPATIBILITY_SLICE, 0));
251
252                         xpt_free_path(path);
253                 }
254
255                 rootdevs[0] = rootdev;
256                 rootname[2] += dkunit(minor(rootdev));
257                 rootdevnames[0] = rootname;
258         }
259 #endif
260 }
261
262 void
263 cpu_dumpconf()
264 {
265 }