Home | History | Annotate | Line # | Download | only in ev64260
autoconf.c revision 1.5
      1 /*	$NetBSD: autoconf.c,v 1.5 2003/07/15 01:37:35 lukem Exp $	*/
      2 
      3 /*-
      4  * Copyright (c) 1990 The Regents of the University of California.
      5  * All rights reserved.
      6  *
      7  * This code is derived from software contributed to Berkeley by
      8  * William Jolitz.
      9  *
     10  * Redistribution and use in source and binary forms, with or without
     11  * modification, are permitted provided that the following conditions
     12  * are met:
     13  * 1. Redistributions of source code must retain the above copyright
     14  *    notice, this list of conditions and the following disclaimer.
     15  * 2. Redistributions in binary form must reproduce the above copyright
     16  *    notice, this list of conditions and the following disclaimer in the
     17  *    documentation and/or other materials provided with the distribution.
     18  * 3. All advertising materials mentioning features or use of this software
     19  *    must display the following acknowledgement:
     20  *	This product includes software developed by the University of
     21  *	California, Berkeley and its contributors.
     22  * 4. Neither the name of the University nor the names of its contributors
     23  *    may be used to endorse or promote products derived from this software
     24  *    without specific prior written permission.
     25  *
     26  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     27  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     28  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     29  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     30  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     31  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     32  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     33  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     34  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     35  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     36  * SUCH DAMAGE.
     37  *
     38  *	@(#)autoconf.c	7.1 (Berkeley) 5/9/91
     39  */
     40 
     41 /*
     42  * Setup the system to run on the current machine.
     43  *
     44  * Configure() is called at boot time and initializes the vba
     45  * device tables and the memory controller monitoring.  Available
     46  * devices are determined (from possibilities mentioned in ioconf.c),
     47  * and the drivers are initialized.
     48  */
     49 
     50 #include <sys/cdefs.h>
     51 __KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.5 2003/07/15 01:37:35 lukem Exp $");
     52 
     53 #include <sys/param.h>
     54 #include <sys/systm.h>
     55 #include <sys/buf.h>
     56 #include <sys/disklabel.h>
     57 #include <sys/conf.h>
     58 #include <sys/reboot.h>
     59 #include <sys/device.h>
     60 
     61 struct device *booted_device;
     62 int booted_partition;
     63 
     64 void findroot __P((void));
     65 
     66 /*
     67  * Determine i/o configuration for a machine.
     68  */
     69 void
     70 cpu_configure()
     71 {
     72         extern void init_interrupt __P((void));
     73         extern void calc_delayconst __P((void));
     74 
     75 	extintr_disable();
     76 
     77         init_interrupt();
     78         calc_delayconst();
     79 
     80 	if (config_rootfound("mainbus", NULL) == NULL)
     81 		panic("configure: mainbus not configured");
     82 
     83 	printf("biomask %x.%x.%x.%x netmask %x.%x.%x.%x ttymask %x.%x.%x.%x\n",
     84 	    imask[IPL_BIO].bits[0], imask[IPL_BIO].bits[1],
     85 	    imask[IPL_BIO].bits[2], imask[IPL_BIO].bits[3],
     86 	    imask[IPL_NET].bits[0], imask[IPL_NET].bits[1],
     87 	    imask[IPL_NET].bits[2], imask[IPL_NET].bits[3],
     88 	    imask[IPL_TTY].bits[0], imask[IPL_TTY].bits[1],
     89 	    imask[IPL_TTY].bits[2], imask[IPL_TTY].bits[3]);
     90 
     91 	curcpu()->ci_cpl = IPL_NONE;
     92 	extintr_enable();
     93 
     94 	spl0();
     95 }
     96 
     97 void
     98 cpu_rootconf()
     99 {
    100 	findroot();
    101 
    102 	printf("boot device: %s\n",
    103 	    booted_device ? booted_device->dv_xname : "<unknown>");
    104 
    105 	setroot(booted_device, booted_partition);
    106 }
    107 
    108 dev_t	bootdev = 0;
    109 
    110 /*
    111  * Attempt to find the device from which we were booted.
    112  * If we can do so, and not instructed not to do so,
    113  * change rootdev to correspond to the load device.
    114  */
    115 void
    116 findroot(void)
    117 {
    118 	struct device *dv;
    119 	const char *name;
    120 	char buf[32];
    121 
    122 #if 0
    123 	printf("howto %x bootdev %x ", boothowto, bootdev);
    124 #endif
    125 
    126 	if ((bootdev & B_MAGICMASK) != (u_long)B_DEVMAGIC)
    127 		return;
    128 
    129 
    130 	name = devsw_blk2name(B_TYPE(bootdev));
    131 	if (name == NULL)
    132 		return;
    133 
    134 	sprintf(buf, "%s%d", name, B_UNIT(bootdev));
    135 	TAILQ_FOREACH(dv, &alldevs, dv_list) {
    136 		if (strcmp(buf, dv->dv_xname) == 0) {
    137 			booted_device = dv;
    138 			booted_partition = B_PARTITION(bootdev);
    139 			return;
    140 		}
    141 	}
    142 }
    143 
    144 void
    145 device_register(struct device *dev, void *aux)
    146 {
    147 }
    148