Home | History | Annotate | Line # | Download | only in rmixl
autoconf.c revision 1.6.2.2
      1  1.6.2.2  jdolecek /*	$NetBSD: autoconf.c,v 1.6.2.2 2017/12/03 11:36:10 jdolecek Exp $	*/
      2      1.2      matt 
      3      1.2      matt /*
      4      1.2      matt  * Copyright 2002 Wasabi Systems, Inc.
      5      1.2      matt  * All rights reserved.
      6      1.2      matt  *
      7      1.2      matt  * Written by Simon Burge for Wasabi Systems, Inc.
      8      1.2      matt  *
      9      1.2      matt  * Redistribution and use in source and binary forms, with or without
     10      1.2      matt  * modification, are permitted provided that the following conditions
     11      1.2      matt  * are met:
     12      1.2      matt  * 1. Redistributions of source code must retain the above copyright
     13      1.2      matt  *    notice, this list of conditions and the following disclaimer.
     14      1.2      matt  * 2. Redistributions in binary form must reproduce the above copyright
     15      1.2      matt  *    notice, this list of conditions and the following disclaimer in the
     16      1.2      matt  *    documentation and/or other materials provided with the distribution.
     17      1.2      matt  * 3. All advertising materials mentioning features or use of this software
     18      1.2      matt  *    must display the following acknowledgement:
     19      1.2      matt  *      This product includes software developed for the NetBSD Project by
     20      1.2      matt  *      Wasabi Systems, Inc.
     21      1.2      matt  * 4. The name of Wasabi Systems, Inc. may not be used to endorse
     22      1.2      matt  *    or promote products derived from this software without specific prior
     23      1.2      matt  *    written permission.
     24      1.2      matt  *
     25      1.2      matt  * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
     26      1.2      matt  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     27      1.2      matt  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     28      1.2      matt  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL WASABI SYSTEMS, INC
     29      1.2      matt  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     30      1.2      matt  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     31      1.2      matt  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     32      1.2      matt  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     33      1.2      matt  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     34      1.2      matt  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     35      1.2      matt  * POSSIBILITY OF SUCH DAMAGE.
     36      1.2      matt  */
     37      1.2      matt 
     38      1.2      matt #include <sys/cdefs.h>
     39  1.6.2.2  jdolecek __KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.6.2.2 2017/12/03 11:36:10 jdolecek Exp $");
     40      1.2      matt 
     41      1.2      matt #include <sys/param.h>
     42      1.2      matt #include <sys/systm.h>
     43      1.2      matt #include <sys/buf.h>
     44      1.2      matt #include <sys/conf.h>
     45      1.2      matt #include <sys/device.h>
     46      1.2      matt #include <sys/cpu.h>
     47      1.2      matt 
     48      1.2      matt static void	findroot(void);
     49      1.2      matt 
     50      1.2      matt void
     51      1.5      matt cpu_configure(void)
     52      1.2      matt {
     53      1.2      matt 
     54      1.2      matt 	intr_init();
     55      1.2      matt 
     56      1.2      matt 	/* Kick off autoconfiguration. */
     57      1.2      matt 	(void)splhigh();
     58      1.2      matt 	if (config_rootfound("mainbus", NULL) == NULL)
     59      1.2      matt 		panic("no mainbus found");
     60      1.2      matt 
     61      1.2      matt 	/*
     62      1.2      matt 	 * Hardware interrupts will be enabled in
     63      1.2      matt 	 * sys/arch/mips/mips/mips3_clockintr.c:mips3_initclocks()
     64      1.2      matt 	 * to avoid hardclock(9) by CPU INT5 before softclockintr is
     65      1.2      matt 	 * initialized in initclocks().
     66      1.2      matt 	 */
     67      1.2      matt }
     68      1.2      matt 
     69      1.2      matt void
     70      1.5      matt cpu_rootconf(void)
     71      1.2      matt {
     72      1.2      matt 	findroot();
     73      1.2      matt 
     74      1.2      matt 	printf("boot device: %s\n",
     75  1.6.2.1       tls 		booted_device ? device_xname(booted_device) : "<unknown>");
     76      1.2      matt 
     77      1.6   mlelstv 	rootconf();
     78      1.2      matt }
     79      1.2      matt 
     80      1.2      matt extern char	bootstring[];
     81      1.2      matt extern int	netboot;
     82      1.2      matt 
     83      1.2      matt static void
     84      1.2      matt findroot(void)
     85      1.2      matt {
     86      1.2      matt 	if (booted_device)
     87      1.2      matt 		return;
     88      1.2      matt 
     89      1.3     rmind 	if ((booted_device == NULL) && netboot == 0) {
     90  1.6.2.2  jdolecek 		device_t dv;
     91  1.6.2.2  jdolecek 		deviter_t di;
     92  1.6.2.2  jdolecek 
     93      1.3     rmind 		for (dv = deviter_first(&di, DEVITER_F_ROOT_FIRST); dv != NULL;
     94      1.3     rmind 		    dv = deviter_next(&di)) {
     95  1.6.2.2  jdolecek 			if (device_class(dv) == DV_DISK
     96  1.6.2.2  jdolecek 			    && (device_is_a(dv, "wd")
     97  1.6.2.2  jdolecek 				|| device_is_a(dv, "sd")
     98  1.6.2.2  jdolecek 				|| device_is_a(dv, "ld")))
     99      1.3     rmind 				booted_device = dv;
    100      1.3     rmind 		}
    101      1.3     rmind 		deviter_release(&di);
    102      1.3     rmind 	}
    103      1.4      matt 
    104      1.2      matt 	/*
    105      1.2      matt 	 * XXX Match up MBR boot specification with BSD disklabel for root?
    106      1.2      matt 	 */
    107      1.2      matt 	booted_partition = 0;
    108      1.2      matt }
    109      1.2      matt 
    110      1.2      matt void
    111      1.5      matt device_register(device_t dev, void *aux)
    112      1.2      matt {
    113      1.3     rmind 
    114      1.2      matt 	if ((booted_device == NULL) && (netboot == 1))
    115      1.2      matt 		if (device_class(dev) == DV_IFNET)
    116      1.2      matt 			booted_device = dev;
    117      1.2      matt }
    118