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