autoconf.c revision 137528
14Srgrimes/*- 24Srgrimes * Copyright (c) 1990 The Regents of the University of California. 34Srgrimes * All rights reserved. 44Srgrimes * 54Srgrimes * This code is derived from software contributed to Berkeley by 64Srgrimes * William Jolitz. 74Srgrimes * 84Srgrimes * Redistribution and use in source and binary forms, with or without 94Srgrimes * modification, are permitted provided that the following conditions 104Srgrimes * are met: 114Srgrimes * 1. Redistributions of source code must retain the above copyright 124Srgrimes * notice, this list of conditions and the following disclaimer. 134Srgrimes * 2. Redistributions in binary form must reproduce the above copyright 144Srgrimes * notice, this list of conditions and the following disclaimer in the 154Srgrimes * documentation and/or other materials provided with the distribution. 164Srgrimes * 4. Neither the name of the University nor the names of its contributors 174Srgrimes * may be used to endorse or promote products derived from this software 184Srgrimes * without specific prior written permission. 194Srgrimes * 204Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 214Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 224Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 234Srgrimes * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 244Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 254Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 264Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 274Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 284Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 294Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 304Srgrimes * SUCH DAMAGE. 314Srgrimes * 32620Srgrimes * from: @(#)autoconf.c 7.1 (Berkeley) 5/9/91 334Srgrimes */ 344Srgrimes 35115683Sobrien#include <sys/cdefs.h> 36115683Sobrien__FBSDID("$FreeBSD: head/sys/i386/i386/autoconf.c 137528 2004-11-10 12:28:06Z nyan $"); 37115683Sobrien 384Srgrimes/* 394Srgrimes * Setup the system to run on the current machine. 404Srgrimes * 418876Srgrimes * Configure() is called at boot time and initializes the vba 424Srgrimes * device tables and the memory controller monitoring. Available 434Srgrimes * devices are determined (from possibilities mentioned in ioconf.c), 444Srgrimes * and the drivers are initialized. 454Srgrimes */ 46131840Sbrian#include "opt_bootp.h" 4771785Speter#include "opt_isa.h" 4845720Speter#include "opt_bus.h" 4925164Speter 502056Swollman#include <sys/param.h> 512056Swollman#include <sys/systm.h> 5245720Speter#include <sys/bus.h> 532056Swollman#include <sys/conf.h> 542056Swollman#include <sys/reboot.h> 552056Swollman#include <sys/kernel.h> 5636809Sbde#include <sys/malloc.h> 5712604Sbde#include <sys/mount.h> 5849558Sphk#include <sys/cons.h> 594Srgrimes 6083651Speter#include <sys/socket.h> 6183651Speter#include <net/if.h> 6283651Speter#include <net/if_dl.h> 6383651Speter#include <net/if_types.h> 6483651Speter#include <net/if_var.h> 6583651Speter#include <net/ethernet.h> 6683651Speter#include <netinet/in.h> 6783651Speter 6820641Sbde#include <machine/bootinfo.h> 697090Sbde#include <machine/md_var.h> 7027288Sfsmp 7171785Speter#ifdef DEV_ISA 7250769Sdfr#include <isa/isavar.h> 7355117Sbde 7446915Speterdevice_t isa_bus_device = 0; 7555117Sbde#endif 7646915Speter 7792770Salfredstatic void configure_first(void *); 7892770Salfredstatic void configure(void *); 7992770Salfredstatic void configure_final(void *); 8012604Sbde 8142817SpeterSYSINIT(configure1, SI_SUB_CONFIGURE, SI_ORDER_FIRST, configure_first, NULL); 8242817Speter/* SI_ORDER_SECOND is hookable */ 8342817SpeterSYSINIT(configure2, SI_SUB_CONFIGURE, SI_ORDER_THIRD, configure, NULL); 8442817Speter/* SI_ORDER_MIDDLE is hookable */ 8542817SpeterSYSINIT(configure3, SI_SUB_CONFIGURE, SI_ORDER_ANY, configure_final, NULL); 8642817Speter 874Srgrimes/* 884Srgrimes * Determine i/o configuration for a machine. 894Srgrimes */ 9010665Sbdestatic void 9142817Speterconfigure_first(dummy) 9242817Speter void *dummy; 9342817Speter{ 9442817Speter} 9542817Speter 9642817Speterstatic void 9710665Sbdeconfigure(dummy) 9810653Sdg void *dummy; 994Srgrimes{ 1004Srgrimes 10129675Sgibbs /* 102121994Sjhb * Enable interrupts on the processor. The interrupts are still 103121994Sjhb * disabled in the interrupt controllers until interrupt handlers 104121994Sjhb * are registered. 10529675Sgibbs */ 10625172Speter enable_intr(); 10712791Sgibbs 10845720Speter /* nexus0 is the top of the i386 device tree */ 10954073Smdodd device_add_child(root_bus, "nexus", 0); 11012791Sgibbs 11138779Snsouch /* initialize new bus architecture */ 11238779Snsouch root_bus_configure(); 11338779Snsouch 11471785Speter#ifdef DEV_ISA 11550184Speter /* 11650184Speter * Explicitly probe and attach ISA last. The isa bus saves 11750184Speter * it's device node at attach time for us here. 11850184Speter */ 11945720Speter if (isa_bus_device) 12050769Sdfr isa_probe_children(isa_bus_device); 12150769Sdfr#endif 12242817Speter} 12331337Sbde 12442817Speterstatic void 12542817Speterconfigure_final(dummy) 12642817Speter void *dummy; 12742817Speter{ 12822564Sbde 12987620Sguido cninit_finish(); 13010665Sbde 13120641Sbde if (bootverbose) { 132107867Sphk#ifdef PC98 133107867Sphk int i; 134137528Snyan 13520641Sbde /* 13620641Sbde * Print out the BIOS's idea of the disk geometries. 13720641Sbde */ 13820641Sbde printf("BIOS Geometries:\n"); 13920641Sbde for (i = 0; i < N_BIOS_GEOM; i++) { 14020641Sbde unsigned long bios_geom; 14120641Sbde int max_cylinder, max_head, max_sector; 14220641Sbde 14320641Sbde bios_geom = bootinfo.bi_bios_geom[i]; 14420641Sbde 14520641Sbde /* 14620641Sbde * XXX the bootstrap punts a 1200K floppy geometry 14720641Sbde * when the get-disk-geometry interrupt fails. Skip 14820641Sbde * drives that have this geometry. 14920641Sbde */ 150136028Snyan if (bios_geom == 0x4f020f) 15120641Sbde continue; 15220641Sbde 15320641Sbde printf(" %x:%08lx ", i, bios_geom); 15420641Sbde max_cylinder = bios_geom >> 16; 15520641Sbde max_head = (bios_geom >> 8) & 0xff; 15620641Sbde max_sector = bios_geom & 0xff; 15720641Sbde printf( 15820641Sbde "0..%d=%d cylinders, 0..%d=%d heads, 1..%d=%d sectors\n", 15920641Sbde max_cylinder, max_cylinder + 1, 16020641Sbde max_head, max_head + 1, 16120641Sbde max_sector, max_sector); 16220641Sbde } 16320641Sbde printf(" %d accounted for\n", bootinfo.bi_n_bios_used); 164107867Sphk#endif 16520641Sbde 16616075Sjoerg printf("Device configuration finished.\n"); 16720641Sbde } 16829675Sgibbs cold = 0; 16929675Sgibbs} 170