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: stable/11/sys/x86/x86/autoconf.c 332304 2018-04-08 20:52:09Z emaste $"); 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 68297530Sjhb#ifdef PC98 6920641Sbde#include <machine/bootinfo.h> 70297530Sjhb#endif 717090Sbde#include <machine/md_var.h> 7227288Sfsmp 7371785Speter#ifdef DEV_ISA 7450769Sdfr#include <isa/isavar.h> 7555117Sbde 7646915Speterdevice_t isa_bus_device = 0; 7755117Sbde#endif 7846915Speter 7992770Salfredstatic void configure_first(void *); 8092770Salfredstatic void configure(void *); 8192770Salfredstatic void configure_final(void *); 8212604Sbde 8342817SpeterSYSINIT(configure1, SI_SUB_CONFIGURE, SI_ORDER_FIRST, configure_first, NULL); 8442817Speter/* SI_ORDER_SECOND is hookable */ 8542817SpeterSYSINIT(configure2, SI_SUB_CONFIGURE, SI_ORDER_THIRD, configure, NULL); 8642817Speter/* SI_ORDER_MIDDLE is hookable */ 8742817SpeterSYSINIT(configure3, SI_SUB_CONFIGURE, SI_ORDER_ANY, configure_final, NULL); 8842817Speter 894Srgrimes/* 904Srgrimes * Determine i/o configuration for a machine. 914Srgrimes */ 9210665Sbdestatic void 93332304Semasteconfigure_first(void *dummy) 9442817Speter{ 95146794Smarcel 96297530Sjhb /* nexus0 is the top of the x86 device tree */ 97146794Smarcel device_add_child(root_bus, "nexus", 0); 9842817Speter} 9942817Speter 10042817Speterstatic void 101332304Semasteconfigure(void *dummy) 1024Srgrimes{ 1034Srgrimes 10438779Snsouch /* initialize new bus architecture */ 10538779Snsouch root_bus_configure(); 10638779Snsouch 10771785Speter#ifdef DEV_ISA 10850184Speter /* 10950184Speter * Explicitly probe and attach ISA last. The isa bus saves 11050184Speter * it's device node at attach time for us here. 11150184Speter */ 11245720Speter if (isa_bus_device) 11350769Sdfr isa_probe_children(isa_bus_device); 11450769Sdfr#endif 11542817Speter} 11631337Sbde 11742817Speterstatic void 118332304Semasteconfigure_final(void *dummy) 11942817Speter{ 12022564Sbde 12187620Sguido cninit_finish(); 12210665Sbde 12320641Sbde if (bootverbose) { 124107867Sphk#ifdef PC98 125107867Sphk int i; 126137528Snyan 12720641Sbde /* 12820641Sbde * Print out the BIOS's idea of the disk geometries. 12920641Sbde */ 13020641Sbde printf("BIOS Geometries:\n"); 13120641Sbde for (i = 0; i < N_BIOS_GEOM; i++) { 13220641Sbde unsigned long bios_geom; 13320641Sbde int max_cylinder, max_head, max_sector; 13420641Sbde 13520641Sbde bios_geom = bootinfo.bi_bios_geom[i]; 13620641Sbde 13720641Sbde /* 13820641Sbde * XXX the bootstrap punts a 1200K floppy geometry 13920641Sbde * when the get-disk-geometry interrupt fails. Skip 14020641Sbde * drives that have this geometry. 14120641Sbde */ 142136028Snyan if (bios_geom == 0x4f020f) 14320641Sbde continue; 14420641Sbde 14520641Sbde printf(" %x:%08lx ", i, bios_geom); 14620641Sbde max_cylinder = bios_geom >> 16; 14720641Sbde max_head = (bios_geom >> 8) & 0xff; 14820641Sbde max_sector = bios_geom & 0xff; 14920641Sbde printf( 15020641Sbde "0..%d=%d cylinders, 0..%d=%d heads, 1..%d=%d sectors\n", 15120641Sbde max_cylinder, max_cylinder + 1, 15220641Sbde max_head, max_head + 1, 15320641Sbde max_sector, max_sector); 15420641Sbde } 15520641Sbde printf(" %d accounted for\n", bootinfo.bi_n_bios_used); 156107867Sphk#endif 15720641Sbde 15816075Sjoerg printf("Device configuration finished.\n"); 15920641Sbde } 16029675Sgibbs cold = 0; 16129675Sgibbs} 162