12b1e924bSJohn Baldwin /*-
22b1e924bSJohn Baldwin * Copyright (c) 1990 The Regents of the University of California.
32b1e924bSJohn Baldwin * All rights reserved.
42b1e924bSJohn Baldwin *
52b1e924bSJohn Baldwin * This code is derived from software contributed to Berkeley by
62b1e924bSJohn Baldwin * William Jolitz.
72b1e924bSJohn Baldwin *
82b1e924bSJohn Baldwin * Redistribution and use in source and binary forms, with or without
92b1e924bSJohn Baldwin * modification, are permitted provided that the following conditions
102b1e924bSJohn Baldwin * are met:
112b1e924bSJohn Baldwin * 1. Redistributions of source code must retain the above copyright
122b1e924bSJohn Baldwin * notice, this list of conditions and the following disclaimer.
132b1e924bSJohn Baldwin * 2. Redistributions in binary form must reproduce the above copyright
142b1e924bSJohn Baldwin * notice, this list of conditions and the following disclaimer in the
152b1e924bSJohn Baldwin * documentation and/or other materials provided with the distribution.
16fbbd9655SWarner Losh * 3. Neither the name of the University nor the names of its contributors
172b1e924bSJohn Baldwin * may be used to endorse or promote products derived from this software
182b1e924bSJohn Baldwin * without specific prior written permission.
192b1e924bSJohn Baldwin *
202b1e924bSJohn Baldwin * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
212b1e924bSJohn Baldwin * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
222b1e924bSJohn Baldwin * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
232b1e924bSJohn Baldwin * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
242b1e924bSJohn Baldwin * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
252b1e924bSJohn Baldwin * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
262b1e924bSJohn Baldwin * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
272b1e924bSJohn Baldwin * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
282b1e924bSJohn Baldwin * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
292b1e924bSJohn Baldwin * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
302b1e924bSJohn Baldwin * SUCH DAMAGE.
312b1e924bSJohn Baldwin */
322b1e924bSJohn Baldwin
332b1e924bSJohn Baldwin #include <sys/cdefs.h>
342b1e924bSJohn Baldwin /*
352b1e924bSJohn Baldwin * Setup the system to run on the current machine.
362b1e924bSJohn Baldwin *
372b1e924bSJohn Baldwin * Configure() is called at boot time and initializes the vba
382b1e924bSJohn Baldwin * device tables and the memory controller monitoring. Available
392b1e924bSJohn Baldwin * devices are determined (from possibilities mentioned in ioconf.c),
402b1e924bSJohn Baldwin * and the drivers are initialized.
412b1e924bSJohn Baldwin */
422b1e924bSJohn Baldwin #include "opt_bootp.h"
432b1e924bSJohn Baldwin #include "opt_isa.h"
442b1e924bSJohn Baldwin #include "opt_bus.h"
452b1e924bSJohn Baldwin
462b1e924bSJohn Baldwin #include <sys/param.h>
472b1e924bSJohn Baldwin #include <sys/systm.h>
482b1e924bSJohn Baldwin #include <sys/bus.h>
492b1e924bSJohn Baldwin #include <sys/conf.h>
502b1e924bSJohn Baldwin #include <sys/reboot.h>
512b1e924bSJohn Baldwin #include <sys/kernel.h>
522b1e924bSJohn Baldwin #include <sys/malloc.h>
532b1e924bSJohn Baldwin #include <sys/mount.h>
542b1e924bSJohn Baldwin #include <sys/cons.h>
552b1e924bSJohn Baldwin
562b1e924bSJohn Baldwin #include <sys/socket.h>
572b1e924bSJohn Baldwin #include <net/if.h>
582b1e924bSJohn Baldwin #include <net/if_dl.h>
592b1e924bSJohn Baldwin #include <net/if_types.h>
602b1e924bSJohn Baldwin #include <net/if_var.h>
612b1e924bSJohn Baldwin #include <net/ethernet.h>
622b1e924bSJohn Baldwin #include <netinet/in.h>
632b1e924bSJohn Baldwin
642b1e924bSJohn Baldwin #include <machine/md_var.h>
652b1e924bSJohn Baldwin
662b1e924bSJohn Baldwin #ifdef DEV_ISA
672b1e924bSJohn Baldwin #include <isa/isavar.h>
682b1e924bSJohn Baldwin
692b1e924bSJohn Baldwin device_t isa_bus_device = 0;
702b1e924bSJohn Baldwin #endif
712b1e924bSJohn Baldwin
722b1e924bSJohn Baldwin static void configure_first(void *);
732b1e924bSJohn Baldwin static void configure(void *);
742b1e924bSJohn Baldwin static void configure_final(void *);
752b1e924bSJohn Baldwin
762b1e924bSJohn Baldwin SYSINIT(configure1, SI_SUB_CONFIGURE, SI_ORDER_FIRST, configure_first, NULL);
772b1e924bSJohn Baldwin /* SI_ORDER_SECOND is hookable */
782b1e924bSJohn Baldwin SYSINIT(configure2, SI_SUB_CONFIGURE, SI_ORDER_THIRD, configure, NULL);
792b1e924bSJohn Baldwin /* SI_ORDER_MIDDLE is hookable */
802b1e924bSJohn Baldwin SYSINIT(configure3, SI_SUB_CONFIGURE, SI_ORDER_ANY, configure_final, NULL);
812b1e924bSJohn Baldwin
822b1e924bSJohn Baldwin /*
832b1e924bSJohn Baldwin * Determine i/o configuration for a machine.
842b1e924bSJohn Baldwin */
852b1e924bSJohn Baldwin static void
configure_first(void * dummy)86*4e78ff70SEd Maste configure_first(void *dummy)
872b1e924bSJohn Baldwin {
882b1e924bSJohn Baldwin
892b1e924bSJohn Baldwin /* nexus0 is the top of the x86 device tree */
902b1e924bSJohn Baldwin device_add_child(root_bus, "nexus", 0);
912b1e924bSJohn Baldwin }
922b1e924bSJohn Baldwin
932b1e924bSJohn Baldwin static void
configure(void * dummy)94*4e78ff70SEd Maste configure(void *dummy)
952b1e924bSJohn Baldwin {
962b1e924bSJohn Baldwin
972b1e924bSJohn Baldwin /* initialize new bus architecture */
982b1e924bSJohn Baldwin root_bus_configure();
992b1e924bSJohn Baldwin
1002b1e924bSJohn Baldwin #ifdef DEV_ISA
1012b1e924bSJohn Baldwin /*
1022b1e924bSJohn Baldwin * Explicitly probe and attach ISA last. The isa bus saves
1032b1e924bSJohn Baldwin * it's device node at attach time for us here.
1042b1e924bSJohn Baldwin */
1052b1e924bSJohn Baldwin if (isa_bus_device)
1062b1e924bSJohn Baldwin isa_probe_children(isa_bus_device);
1072b1e924bSJohn Baldwin #endif
1082b1e924bSJohn Baldwin }
1092b1e924bSJohn Baldwin
1102b1e924bSJohn Baldwin static void
configure_final(void * dummy)111*4e78ff70SEd Maste configure_final(void *dummy)
1122b1e924bSJohn Baldwin {
1132b1e924bSJohn Baldwin
1142b1e924bSJohn Baldwin cninit_finish();
1152b1e924bSJohn Baldwin
1162b375b4eSYoshihiro Takahashi if (bootverbose)
1172b1e924bSJohn Baldwin printf("Device configuration finished.\n");
1182b375b4eSYoshihiro Takahashi
1192b1e924bSJohn Baldwin cold = 0;
1202b1e924bSJohn Baldwin }
121