autoconf.c revision 107867
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 * 3. All advertising materials mentioning features or use of this software 174Srgrimes * must display the following acknowledgement: 184Srgrimes * This product includes software developed by the University of 194Srgrimes * California, Berkeley and its contributors. 204Srgrimes * 4. Neither the name of the University nor the names of its contributors 214Srgrimes * may be used to endorse or promote products derived from this software 224Srgrimes * without specific prior written permission. 234Srgrimes * 244Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 254Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 264Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 274Srgrimes * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 284Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 294Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 304Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 314Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 324Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 334Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 344Srgrimes * SUCH DAMAGE. 354Srgrimes * 36620Srgrimes * from: @(#)autoconf.c 7.1 (Berkeley) 5/9/91 3750477Speter * $FreeBSD: head/sys/i386/i386/autoconf.c 107867 2002-12-14 16:11:28Z phk $ 384Srgrimes */ 394Srgrimes 404Srgrimes/* 414Srgrimes * Setup the system to run on the current machine. 424Srgrimes * 438876Srgrimes * Configure() is called at boot time and initializes the vba 444Srgrimes * device tables and the memory controller monitoring. Available 454Srgrimes * devices are determined (from possibilities mentioned in ioconf.c), 464Srgrimes * and the drivers are initialized. 474Srgrimes */ 4832358Seivind#include "opt_bootp.h" 4971785Speter#include "opt_isa.h" 5053888Sdillon#include "opt_nfs.h" 5137272Sjmg#include "opt_nfsroot.h" 5245720Speter#include "opt_bus.h" 5325164Speter 542056Swollman#include <sys/param.h> 552056Swollman#include <sys/systm.h> 5645720Speter#include <sys/bus.h> 572056Swollman#include <sys/conf.h> 582056Swollman#include <sys/reboot.h> 592056Swollman#include <sys/kernel.h> 6036809Sbde#include <sys/malloc.h> 6112604Sbde#include <sys/mount.h> 6249558Sphk#include <sys/cons.h> 634Srgrimes 6483651Speter#include <sys/socket.h> 6583651Speter#include <net/if.h> 6683651Speter#include <net/if_dl.h> 6783651Speter#include <net/if_types.h> 6883651Speter#include <net/if_var.h> 6983651Speter#include <net/ethernet.h> 7083651Speter#include <netinet/in.h> 7183651Speter#include <nfs/rpcv2.h> 7283651Speter#include <nfs/nfsproto.h> 7383651Speter#include <nfsclient/nfs.h> 7483651Speter#include <nfsclient/nfsdiskless.h> 7583651Speter 7620641Sbde#include <machine/bootinfo.h> 777090Sbde#include <machine/md_var.h> 7827288Sfsmp#ifdef APIC_IO 7925164Speter#include <machine/smp.h> 8050197Speter#else 8150197Speter#include <i386/isa/icu.h> 8225164Speter#endif /* APIC_IO */ 8327288Sfsmp 8471785Speter#ifdef DEV_ISA 8550769Sdfr#include <isa/isavar.h> 8655117Sbde 8746915Speterdevice_t isa_bus_device = 0; 8855117Sbde#endif 8946915Speter 9092770Salfredstatic void configure_first(void *); 9192770Salfredstatic void configure(void *); 9292770Salfredstatic void configure_final(void *); 9312604Sbde 9442817SpeterSYSINIT(configure1, SI_SUB_CONFIGURE, SI_ORDER_FIRST, configure_first, NULL); 9542817Speter/* SI_ORDER_SECOND is hookable */ 9642817SpeterSYSINIT(configure2, SI_SUB_CONFIGURE, SI_ORDER_THIRD, configure, NULL); 9742817Speter/* SI_ORDER_MIDDLE is hookable */ 9842817SpeterSYSINIT(configure3, SI_SUB_CONFIGURE, SI_ORDER_ANY, configure_final, NULL); 9942817Speter 10045720Speterdevice_t nexus_dev; 10145720Speter 1024Srgrimes/* 1034Srgrimes * Determine i/o configuration for a machine. 1044Srgrimes */ 10510665Sbdestatic void 10642817Speterconfigure_first(dummy) 10742817Speter void *dummy; 10842817Speter{ 10942817Speter} 11042817Speter 11142817Speterstatic void 11210665Sbdeconfigure(dummy) 11310653Sdg void *dummy; 1144Srgrimes{ 1154Srgrimes 11629675Sgibbs /* 11750184Speter * Activate the ICU's. Note that we are explicitly at splhigh() 11850184Speter * at present as we have no way to disable stray PCI level triggered 11950184Speter * interrupts until the devices have had a driver attached. This 12050184Speter * is particularly a problem when the interrupts are shared. For 12150184Speter * example, if IRQ 10 is shared between a disk and network device 12250184Speter * and the disk device generates an interrupt, if we "activate" 12350184Speter * IRQ 10 when the network driver is set up, then we will get 12450184Speter * recursive interrupt 10's as nothing will know how to turn off 12550184Speter * the disk device's interrupt. 12650184Speter * 12750184Speter * Having the ICU's active means we can probe interrupt routing to 12850184Speter * see if a device causes the corresponding pending bit to be set. 12950184Speter * 13050184Speter * This is all rather inconvenient. 13129675Sgibbs */ 13227288Sfsmp#ifdef APIC_IO 13327288Sfsmp bsp_apic_configure(); 13425172Speter enable_intr(); 13527288Sfsmp#else 13627288Sfsmp enable_intr(); 13725172Speter INTREN(IRQ_SLAVE); 13827288Sfsmp#endif /* APIC_IO */ 13912791Sgibbs 14045720Speter /* nexus0 is the top of the i386 device tree */ 14154073Smdodd device_add_child(root_bus, "nexus", 0); 14212791Sgibbs 14338779Snsouch /* initialize new bus architecture */ 14438779Snsouch root_bus_configure(); 14538779Snsouch 14671785Speter#ifdef DEV_ISA 14750184Speter /* 14850184Speter * Explicitly probe and attach ISA last. The isa bus saves 14950184Speter * it's device node at attach time for us here. 15050184Speter */ 15145720Speter if (isa_bus_device) 15250769Sdfr isa_probe_children(isa_bus_device); 15350769Sdfr#endif 15445720Speter 15531336Sbde /* 15631336Sbde * Now we're ready to handle (pending) interrupts. 15731336Sbde * XXX this is slightly misplaced. 15831336Sbde */ 15931336Sbde spl0(); 16042817Speter} 16131337Sbde 16242817Speterstatic void 16342817Speterconfigure_final(dummy) 16442817Speter void *dummy; 16542817Speter{ 16622564Sbde 16787620Sguido cninit_finish(); 16810665Sbde 16920641Sbde if (bootverbose) { 17027561Sfsmp 17127561Sfsmp#ifdef APIC_IO 17227615Sfsmp imen_dump(); 17327561Sfsmp#endif /* APIC_IO */ 17427561Sfsmp 175107867Sphk#ifdef PC98 176107867Sphk { 177107867Sphk int i; 17820641Sbde /* 17920641Sbde * Print out the BIOS's idea of the disk geometries. 18020641Sbde */ 18120641Sbde printf("BIOS Geometries:\n"); 18220641Sbde for (i = 0; i < N_BIOS_GEOM; i++) { 18320641Sbde unsigned long bios_geom; 18420641Sbde int max_cylinder, max_head, max_sector; 18520641Sbde 18620641Sbde bios_geom = bootinfo.bi_bios_geom[i]; 18720641Sbde 18820641Sbde /* 18920641Sbde * XXX the bootstrap punts a 1200K floppy geometry 19020641Sbde * when the get-disk-geometry interrupt fails. Skip 19120641Sbde * drives that have this geometry. 19220641Sbde */ 19320641Sbde if (bios_geom == 0x4f010f) 19420641Sbde continue; 19520641Sbde 19620641Sbde printf(" %x:%08lx ", i, bios_geom); 19720641Sbde max_cylinder = bios_geom >> 16; 19820641Sbde max_head = (bios_geom >> 8) & 0xff; 19920641Sbde max_sector = bios_geom & 0xff; 20020641Sbde printf( 20120641Sbde "0..%d=%d cylinders, 0..%d=%d heads, 1..%d=%d sectors\n", 20220641Sbde max_cylinder, max_cylinder + 1, 20320641Sbde max_head, max_head + 1, 20420641Sbde max_sector, max_sector); 20520641Sbde } 20620641Sbde printf(" %d accounted for\n", bootinfo.bi_n_bios_used); 207107867Sphk } 208107867Sphk#endif 20920641Sbde 21016075Sjoerg printf("Device configuration finished.\n"); 21120641Sbde } 21229675Sgibbs cold = 0; 21329675Sgibbs} 21416075Sjoerg 21552778Smsmith/* 21652778Smsmith * Do legacy root filesystem discovery. 21752778Smsmith */ 21829675Sgibbsvoid 21929675Sgibbscpu_rootconf() 22029675Sgibbs{ 22153888Sdillon#ifdef BOOTP 22253888Sdillon bootpc_init(); 22353888Sdillon#endif 22483651Speter#if defined(NFSCLIENT) && defined(NFS_ROOT) 22552778Smsmith#if !defined(BOOTP_NFSROOT) 226103770Sjake nfs_setup_diskless(); 22752778Smsmith if (nfs_diskless_valid) 2287731Sphk#endif 22952778Smsmith rootdevnames[0] = "nfs:"; 2304Srgrimes#endif 23129675Sgibbs} 23252778SmsmithSYSINIT(cpu_rootconf, SI_SUB_ROOT_CONF, SI_ORDER_FIRST, cpu_rootconf, NULL) 233