Home | History | Annotate | Line # | Download | only in loongson
autoconf.c revision 1.5
      1  1.5  macallan /*	$NetBSD: autoconf.c,v 1.5 2013/03/13 21:17:43 macallan 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.5  macallan __KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.5 2013/03/13 21:17:43 macallan 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.5  macallan #include <evbmips/loongson/autoconf.h>
     48  1.1    bouyer 
     49  1.1    bouyer static void	findroot(void);
     50  1.1    bouyer 
     51  1.1    bouyer enum devclass bootdev_class = DV_DULL;
     52  1.1    bouyer char          bootdev[16];
     53  1.5  macallan extern const struct platform *sys_platform;
     54  1.1    bouyer 
     55  1.1    bouyer void
     56  1.1    bouyer cpu_configure(void)
     57  1.1    bouyer {
     58  1.1    bouyer 
     59  1.1    bouyer 	intr_init();
     60  1.1    bouyer 
     61  1.1    bouyer 	/* Kick off autoconfiguration. */
     62  1.1    bouyer 	(void)splhigh();
     63  1.1    bouyer 	if (config_rootfound("mainbus", NULL) == NULL)
     64  1.1    bouyer 		panic("no mainbus found");
     65  1.1    bouyer 
     66  1.1    bouyer 	/*
     67  1.1    bouyer 	 * Hardware interrupts will be enabled in
     68  1.1    bouyer 	 * sys/arch/mips/mips/mips3_clockintr.c:mips3_initclocks()
     69  1.1    bouyer 	 * to avoid hardclock(9) by CPU INT5 before softclockintr is
     70  1.1    bouyer 	 * initialized in initclocks().
     71  1.1    bouyer 	 */
     72  1.1    bouyer }
     73  1.1    bouyer 
     74  1.1    bouyer void
     75  1.1    bouyer cpu_rootconf(void)
     76  1.1    bouyer {
     77  1.1    bouyer 	findroot();
     78  1.1    bouyer 
     79  1.1    bouyer 	printf("boot device: %s\n",
     80  1.4       chs 		booted_device ? device_xname(booted_device) : "<unknown>");
     81  1.1    bouyer 
     82  1.3   mlelstv 	rootconf();
     83  1.1    bouyer }
     84  1.1    bouyer 
     85  1.1    bouyer extern char	bootstring[];
     86  1.1    bouyer extern int	netboot;
     87  1.1    bouyer 
     88  1.1    bouyer static void
     89  1.1    bouyer findroot(void)
     90  1.1    bouyer {
     91  1.1    bouyer 	device_t dv;
     92  1.1    bouyer 	deviter_t di;
     93  1.1    bouyer 
     94  1.1    bouyer 	if (booted_device)
     95  1.1    bouyer 		return;
     96  1.1    bouyer 
     97  1.1    bouyer 	if ((booted_device == NULL) && netboot == 0) {
     98  1.1    bouyer 		for (dv = deviter_first(&di, DEVITER_F_ROOT_FIRST); dv != NULL;
     99  1.1    bouyer 		     dv = deviter_next(&di)) {
    100  1.1    bouyer 			if (device_class(dv) == DV_DISK &&
    101  1.1    bouyer 			    device_is_a(dv, "wd"))
    102  1.1    bouyer 				    booted_device = dv;
    103  1.1    bouyer 		}
    104  1.1    bouyer 		deviter_release(&di);
    105  1.1    bouyer 	}
    106  1.1    bouyer 
    107  1.1    bouyer 	/*
    108  1.1    bouyer 	 * XXX Match up MBR boot specification with BSD disklabel for root?
    109  1.1    bouyer 	 */
    110  1.1    bouyer 	booted_partition = 0;
    111  1.1    bouyer 
    112  1.1    bouyer 	return;
    113  1.1    bouyer }
    114  1.1    bouyer 
    115  1.1    bouyer void
    116  1.4       chs device_register(device_t dev, void *aux)
    117  1.1    bouyer {
    118  1.1    bouyer 	prop_dictionary_t dict;
    119  1.1    bouyer 
    120  1.1    bouyer 	if ((booted_device == NULL) && (netboot == 1))
    121  1.1    bouyer 		if (device_class(dev) == DV_IFNET)
    122  1.1    bouyer 			booted_device = dev;
    123  1.5  macallan 
    124  1.5  macallan 	if (sys_platform->device_register != NULL) {
    125  1.5  macallan 		sys_platform->device_register(dev, aux);
    126  1.1    bouyer 	}
    127  1.5  macallan 
    128  1.5  macallan 	/* is this yeeloong specific? */
    129  1.2    nonaka 	if (device_is_a(dev, "lynxfb")) {
    130  1.2    nonaka 		dict = device_properties(dev);
    131  1.2    nonaka 		/*
    132  1.2    nonaka 		 * this is a hack
    133  1.2    nonaka 		 * is_console and address need to be checked against reality
    134  1.2    nonaka 		 */
    135  1.2    nonaka 		prop_dictionary_set_bool(dict, "is_console", 1);
    136  1.2    nonaka 		prop_dictionary_set_uint32(dict, "width", 1024);
    137  1.2    nonaka 		prop_dictionary_set_uint32(dict, "height", 600);
    138  1.2    nonaka 		prop_dictionary_set_uint32(dict, "depth", 16);
    139  1.2    nonaka 		prop_dictionary_set_uint32(dict, "linebytes", 2048);
    140  1.2    nonaka 		prop_dictionary_set_bool(dict, "swapBR", 1);
    141  1.2    nonaka 	}
    142  1.1    bouyer }
    143