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