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