autoconf.c revision 1.17
11.17Schs/* $NetBSD: autoconf.c,v 1.17 2012/10/27 17:17:51 chs Exp $ */ 21.1Ssimonb 31.1Ssimonb/* 41.1Ssimonb * Copyright 2002 Wasabi Systems, Inc. 51.1Ssimonb * All rights reserved. 61.1Ssimonb * 71.1Ssimonb * Written by Simon Burge for Wasabi Systems, Inc. 81.1Ssimonb * 91.1Ssimonb * Redistribution and use in source and binary forms, with or without 101.1Ssimonb * modification, are permitted provided that the following conditions 111.1Ssimonb * are met: 121.1Ssimonb * 1. Redistributions of source code must retain the above copyright 131.1Ssimonb * notice, this list of conditions and the following disclaimer. 141.1Ssimonb * 2. Redistributions in binary form must reproduce the above copyright 151.1Ssimonb * notice, this list of conditions and the following disclaimer in the 161.1Ssimonb * documentation and/or other materials provided with the distribution. 171.1Ssimonb * 3. All advertising materials mentioning features or use of this software 181.1Ssimonb * must display the following acknowledgement: 191.1Ssimonb * This product includes software developed for the NetBSD Project by 201.1Ssimonb * Wasabi Systems, Inc. 211.1Ssimonb * 4. The name of Wasabi Systems, Inc. may not be used to endorse 221.1Ssimonb * or promote products derived from this software without specific prior 231.1Ssimonb * written permission. 241.1Ssimonb * 251.1Ssimonb * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND 261.1Ssimonb * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 271.1Ssimonb * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 281.1Ssimonb * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC 291.1Ssimonb * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 301.1Ssimonb * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 311.1Ssimonb * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 321.1Ssimonb * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 331.1Ssimonb * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 341.1Ssimonb * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 351.1Ssimonb * POSSIBILITY OF SUCH DAMAGE. 361.1Ssimonb */ 371.4Slukem 381.4Slukem#include <sys/cdefs.h> 391.17Schs__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.17 2012/10/27 17:17:51 chs Exp $"); 401.1Ssimonb 411.1Ssimonb#include <sys/param.h> 421.1Ssimonb#include <sys/systm.h> 431.1Ssimonb#include <sys/buf.h> 441.1Ssimonb#include <sys/conf.h> 451.1Ssimonb#include <sys/device.h> 461.12Sad#include <sys/cpu.h> 471.1Ssimonb 481.1Ssimonbstatic void findroot(void); 491.1Ssimonb 501.1Ssimonbvoid 511.14Sceggercpu_configure(void) 521.1Ssimonb{ 531.1Ssimonb 541.1Ssimonb intr_init(); 551.1Ssimonb 561.1Ssimonb /* Kick off autoconfiguration. */ 571.1Ssimonb (void)splhigh(); 581.6She if (config_rootfound("mainbus", NULL) == NULL) 591.1Ssimonb panic("no mainbus found"); 601.10Stsutsui 611.10Stsutsui /* 621.10Stsutsui * Hardware interrupts will be enabled in 631.10Stsutsui * sys/arch/mips/mips/mips3_clockintr.c:mips3_initclocks() 641.10Stsutsui * to avoid hardclock(9) by CPU INT5 before softclockintr is 651.10Stsutsui * initialized in initclocks(). 661.10Stsutsui */ 671.1Ssimonb} 681.1Ssimonb 691.1Ssimonbvoid 701.14Sceggercpu_rootconf(void) 711.1Ssimonb{ 721.1Ssimonb findroot(); 731.1Ssimonb 741.1Ssimonb printf("boot device: %s\n", 751.17Schs booted_device ? device_xname(booted_device) : "<unknown>"); 761.1Ssimonb 771.16Smlelstv rootconf(); 781.1Ssimonb} 791.1Ssimonb 801.1Ssimonbextern char bootstring[]; 811.1Ssimonbextern int netboot; 821.1Ssimonb 831.1Ssimonbstatic void 841.1Ssimonbfindroot(void) 851.1Ssimonb{ 861.15Sdyoung device_t dv; 871.15Sdyoung deviter_t di; 881.1Ssimonb 891.1Ssimonb if (booted_device) 901.1Ssimonb return; 911.1Ssimonb 921.15Sdyoung if ((booted_device == NULL) && netboot == 0) { 931.15Sdyoung for (dv = deviter_first(&di, DEVITER_F_ROOT_FIRST); dv != NULL; 941.15Sdyoung dv = deviter_next(&di)) { 951.8Sthorpej if (device_class(dv) == DV_DISK && 961.9Sthorpej device_is_a(dv, "wd")) 971.1Ssimonb booted_device = dv; 981.15Sdyoung } 991.15Sdyoung deviter_release(&di); 1001.15Sdyoung } 1011.1Ssimonb 1021.1Ssimonb /* 1031.1Ssimonb * XXX Match up MBR boot specification with BSD disklabel for root? 1041.1Ssimonb */ 1051.1Ssimonb booted_partition = 0; 1061.1Ssimonb 1071.1Ssimonb return; 1081.1Ssimonb} 1091.1Ssimonb 1101.1Ssimonbvoid 1111.17Schsdevice_register(device_t dev, void *aux) 1121.1Ssimonb{ 1131.1Ssimonb if ((booted_device == NULL) && (netboot == 1)) 1141.8Sthorpej if (device_class(dev) == DV_IFNET) 1151.1Ssimonb booted_device = dev; 1161.1Ssimonb} 117