autoconf.c revision 1.2.4.2 1 /* $NetBSD: autoconf.c,v 1.2.4.2 2007/12/03 19:04:38 ad Exp $ */
2 /* NetBSD: autoconf.c,v 1.75 2003/12/30 12:33:22 pk Exp */
3
4 /*-
5 * Copyright (c) 1990 The Regents of the University of California.
6 * All rights reserved.
7 *
8 * This code is derived from software contributed to Berkeley by
9 * William Jolitz.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 * 3. Neither the name of the University nor the names of its contributors
20 * may be used to endorse or promote products derived from this software
21 * without specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 * SUCH DAMAGE.
34 *
35 * @(#)autoconf.c 7.1 (Berkeley) 5/9/91
36 */
37
38 /*
39 * Setup the system to run on the current machine.
40 *
41 * Configure() is called at boot time and initializes the vba
42 * device tables and the memory controller monitoring. Available
43 * devices are determined (from possibilities mentioned in ioconf.c),
44 * and the drivers are initialized.
45 */
46
47 #include <sys/cdefs.h>
48 __KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.2.4.2 2007/12/03 19:04:38 ad Exp $");
49
50 #include "opt_xen.h"
51 #include "opt_compat_oldboot.h"
52 #include "opt_multiprocessor.h"
53 #include "opt_nfs_boot.h"
54 #include "xennet_hypervisor.h"
55 #include "xennet_xenbus.h"
56
57 #include <sys/param.h>
58 #include <sys/systm.h>
59 #include <sys/buf.h>
60 #include <sys/disklabel.h>
61 #include <sys/disk.h>
62 #include <sys/conf.h>
63 #ifdef COMPAT_OLDBOOT
64 #include <sys/reboot.h>
65 #endif
66 #include <sys/device.h>
67 #include <sys/malloc.h>
68 #include <sys/vnode.h>
69 #include <sys/fcntl.h>
70 #include <sys/dkio.h>
71 #include <sys/proc.h>
72 #include <sys/user.h>
73 #include <sys/kauth.h>
74
75 #ifdef NFS_BOOT_BOOTSTATIC
76 #include <net/if.h>
77 #include <net/if_ether.h>
78 #include <netinet/in.h>
79 #include <nfs/rpcv2.h>
80 #include <nfs/nfsproto.h>
81 #include <nfs/nfs.h>
82 #include <nfs/nfsmount.h>
83 #include <nfs/nfsdiskless.h>
84 #include <xen/if_xennetvar.h>
85 #endif
86
87 #include <machine/pte.h>
88 #include <machine/cpu.h>
89 #include <machine/gdt.h>
90 #include <machine/pcb.h>
91 #include <machine/bootinfo.h>
92
93 static void findroot(void);
94 static int is_valid_disk(struct device *);
95 static void handle_wedges(struct device *, int);
96
97 struct disklist *x86_alldisks;
98 int x86_ndisks;
99
100 #include "bios32.h"
101 #if NBIOS32 > 0
102 #include <machine/bios32.h>
103 #endif
104
105 #include "opt_pcibios.h"
106 #ifdef PCIBIOS
107 #include <dev/pci/pcireg.h>
108 #include <dev/pci/pcivar.h>
109 #include <i386/pci/pcibios.h>
110 #endif
111
112 #include "opt_kvm86.h"
113 #ifdef KVM86
114 #include <machine/kvm86.h>
115 #endif
116
117 /*
118 * Determine i/o configuration for a machine.
119 */
120 void
121 cpu_configure(void)
122 {
123
124 startrtclock();
125
126 #if NBIOS32 > 0 && defined(DOM0OPS)
127 #ifdef XEN3
128 if (xen_start_info.flags & SIF_INITDOMAIN)
129 #endif
130 bios32_init();
131 #endif /* NBIOS32 > 0 && DOM0OPS */
132 #ifdef PCIBIOS
133 pcibios_init();
134 #endif
135
136 #ifdef KVM86
137 kvm86_init();
138 #endif
139
140 if (config_rootfound("mainbus", NULL) == NULL)
141 panic("configure: mainbus not configured");
142
143 #ifdef INTRDEBUG
144 intr_printconfig();
145 #endif
146
147 /* resync cr0 after FPU configuration */
148 lwp0.l_addr->u_pcb.pcb_cr0 = rcr0();
149 #ifdef MULTIPROCESSOR
150 /* propagate this to the idle pcb's. */
151 cpu_init_idle_lwps();
152 #endif
153
154 spl0();
155 }
156
157 void
158 cpu_rootconf(void)
159 {
160 findroot();
161
162 if (booted_wedge) {
163 KASSERT(booted_device != NULL);
164 printf("boot device: %s (%s)\n",
165 booted_wedge->dv_xname, booted_device->dv_xname);
166 setroot(booted_wedge, 0);
167 } else {
168 printf("boot device: %s\n",
169 booted_device ? booted_device->dv_xname : "<unknown>");
170 setroot(booted_device, booted_partition);
171 }
172 }
173
174
175 /*
176 * Attempt to find the device from which we were booted.
177 * If we can do so, and not instructed not to do so,
178 * change rootdev to correspond to the load device.
179 */
180 void
181 findroot(void)
182 {
183 struct device *dv;
184 union xen_cmdline_parseinfo xcp;
185
186 if (booted_device)
187 return;
188
189 xen_parse_cmdline(XEN_PARSE_BOOTDEV, &xcp);
190
191 TAILQ_FOREACH(dv, &alldevs, dv_list) {
192 if (is_valid_disk(dv) == 0)
193 continue;
194
195 if (xcp.xcp_bootdev[0] == 0) {
196 handle_wedges(dv, 0);
197 break;
198 }
199
200 if (strncmp(xcp.xcp_bootdev, dv->dv_xname,
201 strlen(dv->dv_xname)))
202 continue;
203
204 if (strlen(xcp.xcp_bootdev) > strlen(dv->dv_xname)) {
205 booted_partition = toupper(
206 xcp.xcp_bootdev[strlen(dv->dv_xname)]) - 'A';
207 }
208
209 booted_device = dv;
210 break;
211 }
212 }
213
214 #include "pci.h"
215
216 #include <dev/isa/isavar.h>
217 #if NPCI > 0
218 #include <dev/pci/pcivar.h>
219 #endif
220
221
222 #if defined(NFS_BOOT_BOOTSTATIC) && defined(DOM0OPS)
223 static int
224 dom0_bootstatic_callback(struct nfs_diskless *nd)
225 {
226 #if 0
227 struct ifnet *ifp = nd->nd_ifp;
228 #endif
229 union xen_cmdline_parseinfo xcp;
230 struct sockaddr_in *sin;
231
232 memset(&xcp, 0, sizeof(xcp.xcp_netinfo));
233 xcp.xcp_netinfo.xi_ifno = 0; /* XXX first interface hardcoded */
234 xcp.xcp_netinfo.xi_root = nd->nd_root.ndm_host;
235 xen_parse_cmdline(XEN_PARSE_NETINFO, &xcp);
236
237 nd->nd_myip.s_addr = ntohl(xcp.xcp_netinfo.xi_ip[0]);
238 nd->nd_gwip.s_addr = ntohl(xcp.xcp_netinfo.xi_ip[2]);
239 nd->nd_mask.s_addr = ntohl(xcp.xcp_netinfo.xi_ip[3]);
240
241 sin = (struct sockaddr_in *) &nd->nd_root.ndm_saddr;
242 memset((void *)sin, 0, sizeof(*sin));
243 sin->sin_len = sizeof(*sin);
244 sin->sin_family = AF_INET;
245 sin->sin_addr.s_addr = ntohl(xcp.xcp_netinfo.xi_ip[1]);
246
247 if (nd->nd_myip.s_addr == 0)
248 return NFS_BOOTSTATIC_NOSTATIC;
249 else
250 return (NFS_BOOTSTATIC_HAS_MYIP|NFS_BOOTSTATIC_HAS_GWIP|
251 NFS_BOOTSTATIC_HAS_MASK|NFS_BOOTSTATIC_HAS_SERVADDR|
252 NFS_BOOTSTATIC_HAS_SERVER);
253 }
254 #endif
255
256 void
257 device_register(struct device *dev, void *aux)
258 {
259 /*
260 * Handle network interfaces here, the attachment information is
261 * not available driver independently later.
262 * For disks, there is nothing useful available at attach time.
263 */
264 #if NXENNET_HYPERVISOR > 0 || NXENNET_XENBUS > 0 || defined(DOM0OPS)
265 if (device_class(dev) == DV_IFNET) {
266 union xen_cmdline_parseinfo xcp;
267
268 xen_parse_cmdline(XEN_PARSE_BOOTDEV, &xcp);
269 if (strncmp(xcp.xcp_bootdev, dev->dv_xname, 16) == 0) {
270 #ifdef NFS_BOOT_BOOTSTATIC
271 #ifdef DOM0OPS
272 if (xen_start_info.flags & SIF_PRIVILEGED) {
273 nfs_bootstatic_callback = dom0_bootstatic_callback;
274 } else
275 #endif
276 #if NXENNET_HYPERVISOR > 0 || NXENNET_XENBUS > 0
277 nfs_bootstatic_callback = xennet_bootstatic_callback;
278 #endif
279 #endif
280 goto found;
281 }
282 }
283 #endif
284 if (device_class(dev) == DV_IFNET) {
285 struct btinfo_netif *bin = lookup_bootinfo(BTINFO_NETIF);
286 if (bin == NULL)
287 return;
288
289 /*
290 * We don't check the driver name against the device name
291 * passed by the boot ROM. The ROM should stay usable
292 * if the driver gets obsoleted.
293 * The physical attachment information (checked below)
294 * must be sufficient to identify the device.
295 */
296
297 if (bin->bus == BI_BUS_ISA &&
298 device_is_a(device_parent(dev), "isa")) {
299 struct isa_attach_args *iaa = aux;
300
301 /* compare IO base address */
302 /* XXXJRT what about multiple I/O addrs? */
303 if (iaa->ia_nio > 0 &&
304 bin->addr.iobase == iaa->ia_io[0].ir_addr)
305 goto found;
306 }
307 #if NPCI > 0
308 if (bin->bus == BI_BUS_PCI &&
309 device_is_a(device_parent(dev), "pci")) {
310 struct pci_attach_args *paa = aux;
311 int b, d, f;
312
313 /*
314 * Calculate BIOS representation of:
315 *
316 * <bus,device,function>
317 *
318 * and compare.
319 */
320 pci_decompose_tag(paa->pa_pc, paa->pa_tag, &b, &d, &f);
321 if (bin->addr.tag == ((b << 8) | (d << 3) | f))
322 goto found;
323 }
324 #endif
325 }
326 return;
327
328 found:
329 if (booted_device) {
330 /* XXX should be a "panic()" */
331 printf("warning: double match for boot device (%s, %s)\n",
332 booted_device->dv_xname, dev->dv_xname);
333 return;
334 }
335 booted_device = dev;
336 }
337
338 static void
339 handle_wedges(struct device *dv, int par)
340 {
341 if (config_handle_wedges(dv, par) == 0)
342 return;
343 booted_device = dv;
344 booted_partition = par;
345 }
346
347 static int
348 is_valid_disk(struct device *dv)
349 {
350
351 if (device_class(dv) != DV_DISK)
352 return (0);
353
354 return (device_is_a(dv, "dk") ||
355 device_is_a(dv, "sd") ||
356 device_is_a(dv, "wd") ||
357 device_is_a(dv, "ld") ||
358 device_is_a(dv, "ed") ||
359 device_is_a(dv, "xbd"));
360 }
361 /* $NetBSD: autoconf.c,v 1.2.4.2 2007/12/03 19:04:38 ad Exp $ */
362 /* NetBSD: autoconf.c,v 1.75 2003/12/30 12:33:22 pk Exp */
363
364 /*-
365 * Copyright (c) 1990 The Regents of the University of California.
366 * All rights reserved.
367 *
368 * This code is derived from software contributed to Berkeley by
369 * William Jolitz.
370 *
371 * Redistribution and use in source and binary forms, with or without
372 * modification, are permitted provided that the following conditions
373 * are met:
374 * 1. Redistributions of source code must retain the above copyright
375 * notice, this list of conditions and the following disclaimer.
376 * 2. Redistributions in binary form must reproduce the above copyright
377 * notice, this list of conditions and the following disclaimer in the
378 * documentation and/or other materials provided with the distribution.
379 * 3. Neither the name of the University nor the names of its contributors
380 * may be used to endorse or promote products derived from this software
381 * without specific prior written permission.
382 *
383 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
384 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
385 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
386 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
387 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
388 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
389 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
390 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
391 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
392 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
393 * SUCH DAMAGE.
394 *
395 * @(#)autoconf.c 7.1 (Berkeley) 5/9/91
396 */
397
398 /*
399 * Setup the system to run on the current machine.
400 *
401 * Configure() is called at boot time and initializes the vba
402 * device tables and the memory controller monitoring. Available
403 * devices are determined (from possibilities mentioned in ioconf.c),
404 * and the drivers are initialized.
405 */
406
407 #include <sys/cdefs.h>
408 __KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.2.4.2 2007/12/03 19:04:38 ad Exp $");
409
410 #include "opt_xen.h"
411 #include "opt_compat_oldboot.h"
412 #include "opt_multiprocessor.h"
413 #include "opt_nfs_boot.h"
414 #include "xennet_hypervisor.h"
415 #include "xennet_xenbus.h"
416
417 #include <sys/param.h>
418 #include <sys/systm.h>
419 #include <sys/buf.h>
420 #include <sys/disklabel.h>
421 #include <sys/disk.h>
422 #include <sys/conf.h>
423 #ifdef COMPAT_OLDBOOT
424 #include <sys/reboot.h>
425 #endif
426 #include <sys/device.h>
427 #include <sys/malloc.h>
428 #include <sys/vnode.h>
429 #include <sys/fcntl.h>
430 #include <sys/dkio.h>
431 #include <sys/proc.h>
432 #include <sys/user.h>
433 #include <sys/kauth.h>
434
435 #ifdef NFS_BOOT_BOOTSTATIC
436 #include <net/if.h>
437 #include <net/if_ether.h>
438 #include <netinet/in.h>
439 #include <nfs/rpcv2.h>
440 #include <nfs/nfsproto.h>
441 #include <nfs/nfs.h>
442 #include <nfs/nfsmount.h>
443 #include <nfs/nfsdiskless.h>
444 #include <xen/if_xennetvar.h>
445 #endif
446
447 #include <machine/pte.h>
448 #include <machine/cpu.h>
449 #include <machine/gdt.h>
450 #include <machine/pcb.h>
451 #include <machine/bootinfo.h>
452
453 static void findroot(void);
454 static int is_valid_disk(struct device *);
455 static void handle_wedges(struct device *, int);
456
457 struct disklist *x86_alldisks;
458 int x86_ndisks;
459
460 #include "bios32.h"
461 #if NBIOS32 > 0
462 #include <machine/bios32.h>
463 #endif
464
465 #include "opt_pcibios.h"
466 #ifdef PCIBIOS
467 #include <dev/pci/pcireg.h>
468 #include <dev/pci/pcivar.h>
469 #include <i386/pci/pcibios.h>
470 #endif
471
472 #include "opt_kvm86.h"
473 #ifdef KVM86
474 #include <machine/kvm86.h>
475 #endif
476
477 /*
478 * Determine i/o configuration for a machine.
479 */
480 void
481 cpu_configure(void)
482 {
483
484 startrtclock();
485
486 #if NBIOS32 > 0 && defined(DOM0OPS)
487 #ifdef XEN3
488 if (xen_start_info.flags & SIF_INITDOMAIN)
489 #endif
490 bios32_init();
491 #endif /* NBIOS32 > 0 && DOM0OPS */
492 #ifdef PCIBIOS
493 pcibios_init();
494 #endif
495
496 #ifdef KVM86
497 kvm86_init();
498 #endif
499
500 if (config_rootfound("mainbus", NULL) == NULL)
501 panic("configure: mainbus not configured");
502
503 #ifdef INTRDEBUG
504 intr_printconfig();
505 #endif
506
507 /* resync cr0 after FPU configuration */
508 lwp0.l_addr->u_pcb.pcb_cr0 = rcr0();
509 #ifdef MULTIPROCESSOR
510 /* propagate this to the idle pcb's. */
511 cpu_init_idle_lwps();
512 #endif
513
514 spl0();
515 }
516
517 void
518 cpu_rootconf(void)
519 {
520 findroot();
521
522 if (booted_wedge) {
523 KASSERT(booted_device != NULL);
524 printf("boot device: %s (%s)\n",
525 booted_wedge->dv_xname, booted_device->dv_xname);
526 setroot(booted_wedge, 0);
527 } else {
528 printf("boot device: %s\n",
529 booted_device ? booted_device->dv_xname : "<unknown>");
530 setroot(booted_device, booted_partition);
531 }
532 }
533
534
535 /*
536 * Attempt to find the device from which we were booted.
537 * If we can do so, and not instructed not to do so,
538 * change rootdev to correspond to the load device.
539 */
540 void
541 findroot(void)
542 {
543 struct device *dv;
544 union xen_cmdline_parseinfo xcp;
545
546 if (booted_device)
547 return;
548
549 xen_parse_cmdline(XEN_PARSE_BOOTDEV, &xcp);
550
551 TAILQ_FOREACH(dv, &alldevs, dv_list) {
552 if (is_valid_disk(dv) == 0)
553 continue;
554
555 if (xcp.xcp_bootdev[0] == 0) {
556 handle_wedges(dv, 0);
557 break;
558 }
559
560 if (strncmp(xcp.xcp_bootdev, dv->dv_xname,
561 strlen(dv->dv_xname)))
562 continue;
563
564 if (strlen(xcp.xcp_bootdev) > strlen(dv->dv_xname)) {
565 booted_partition = toupper(
566 xcp.xcp_bootdev[strlen(dv->dv_xname)]) - 'A';
567 }
568
569 booted_device = dv;
570 break;
571 }
572 }
573
574 #include "pci.h"
575
576 #include <dev/isa/isavar.h>
577 #if NPCI > 0
578 #include <dev/pci/pcivar.h>
579 #endif
580
581
582 #if defined(NFS_BOOT_BOOTSTATIC) && defined(DOM0OPS)
583 static int
584 dom0_bootstatic_callback(struct nfs_diskless *nd)
585 {
586 #if 0
587 struct ifnet *ifp = nd->nd_ifp;
588 #endif
589 union xen_cmdline_parseinfo xcp;
590 struct sockaddr_in *sin;
591
592 memset(&xcp, 0, sizeof(xcp.xcp_netinfo));
593 xcp.xcp_netinfo.xi_ifno = 0; /* XXX first interface hardcoded */
594 xcp.xcp_netinfo.xi_root = nd->nd_root.ndm_host;
595 xen_parse_cmdline(XEN_PARSE_NETINFO, &xcp);
596
597 nd->nd_myip.s_addr = ntohl(xcp.xcp_netinfo.xi_ip[0]);
598 nd->nd_gwip.s_addr = ntohl(xcp.xcp_netinfo.xi_ip[2]);
599 nd->nd_mask.s_addr = ntohl(xcp.xcp_netinfo.xi_ip[3]);
600
601 sin = (struct sockaddr_in *) &nd->nd_root.ndm_saddr;
602 memset((void *)sin, 0, sizeof(*sin));
603 sin->sin_len = sizeof(*sin);
604 sin->sin_family = AF_INET;
605 sin->sin_addr.s_addr = ntohl(xcp.xcp_netinfo.xi_ip[1]);
606
607 if (nd->nd_myip.s_addr == 0)
608 return NFS_BOOTSTATIC_NOSTATIC;
609 else
610 return (NFS_BOOTSTATIC_HAS_MYIP|NFS_BOOTSTATIC_HAS_GWIP|
611 NFS_BOOTSTATIC_HAS_MASK|NFS_BOOTSTATIC_HAS_SERVADDR|
612 NFS_BOOTSTATIC_HAS_SERVER);
613 }
614 #endif
615
616 void
617 device_register(struct device *dev, void *aux)
618 {
619 /*
620 * Handle network interfaces here, the attachment information is
621 * not available driver independently later.
622 * For disks, there is nothing useful available at attach time.
623 */
624 #if NXENNET_HYPERVISOR > 0 || NXENNET_XENBUS > 0 || defined(DOM0OPS)
625 if (device_class(dev) == DV_IFNET) {
626 union xen_cmdline_parseinfo xcp;
627
628 xen_parse_cmdline(XEN_PARSE_BOOTDEV, &xcp);
629 if (strncmp(xcp.xcp_bootdev, dev->dv_xname, 16) == 0) {
630 #ifdef NFS_BOOT_BOOTSTATIC
631 #ifdef DOM0OPS
632 if (xen_start_info.flags & SIF_PRIVILEGED) {
633 nfs_bootstatic_callback = dom0_bootstatic_callback;
634 } else
635 #endif
636 #if NXENNET_HYPERVISOR > 0 || NXENNET_XENBUS > 0
637 nfs_bootstatic_callback = xennet_bootstatic_callback;
638 #endif
639 #endif
640 goto found;
641 }
642 }
643 #endif
644 if (device_class(dev) == DV_IFNET) {
645 struct btinfo_netif *bin = lookup_bootinfo(BTINFO_NETIF);
646 if (bin == NULL)
647 return;
648
649 /*
650 * We don't check the driver name against the device name
651 * passed by the boot ROM. The ROM should stay usable
652 * if the driver gets obsoleted.
653 * The physical attachment information (checked below)
654 * must be sufficient to identify the device.
655 */
656
657 if (bin->bus == BI_BUS_ISA &&
658 device_is_a(device_parent(dev), "isa")) {
659 struct isa_attach_args *iaa = aux;
660
661 /* compare IO base address */
662 /* XXXJRT what about multiple I/O addrs? */
663 if (iaa->ia_nio > 0 &&
664 bin->addr.iobase == iaa->ia_io[0].ir_addr)
665 goto found;
666 }
667 #if NPCI > 0
668 if (bin->bus == BI_BUS_PCI &&
669 device_is_a(device_parent(dev), "pci")) {
670 struct pci_attach_args *paa = aux;
671 int b, d, f;
672
673 /*
674 * Calculate BIOS representation of:
675 *
676 * <bus,device,function>
677 *
678 * and compare.
679 */
680 pci_decompose_tag(paa->pa_pc, paa->pa_tag, &b, &d, &f);
681 if (bin->addr.tag == ((b << 8) | (d << 3) | f))
682 goto found;
683 }
684 #endif
685 }
686 return;
687
688 found:
689 if (booted_device) {
690 /* XXX should be a "panic()" */
691 printf("warning: double match for boot device (%s, %s)\n",
692 booted_device->dv_xname, dev->dv_xname);
693 return;
694 }
695 booted_device = dev;
696 }
697
698 static void
699 handle_wedges(struct device *dv, int par)
700 {
701 if (config_handle_wedges(dv, par) == 0)
702 return;
703 booted_device = dv;
704 booted_partition = par;
705 }
706
707 static int
708 is_valid_disk(struct device *dv)
709 {
710
711 if (device_class(dv) != DV_DISK)
712 return (0);
713
714 return (device_is_a(dv, "dk") ||
715 device_is_a(dv, "sd") ||
716 device_is_a(dv, "wd") ||
717 device_is_a(dv, "ld") ||
718 device_is_a(dv, "ed") ||
719 device_is_a(dv, "xbd"));
720 }
721