Home | History | Annotate | Line # | Download | only in virt68k
      1 /*	$NetBSD: autoconf.c,v 1.6 2025/03/09 12:43:09 mlelstv Exp $	*/
      2 
      3 /*
      4  * Copyright (c) 1988 University of Utah.
      5  * Copyright (c) 1982, 1986, 1990, 1993
      6  * 	The Regents of the University of California. All rights reserved.
      7  *
      8  * This code is derived from software contributed to Berkeley by
      9  * the Systems Programming Group of the University of Utah Computer
     10  * Science Department.
     11  *
     12  * Redistribution and use in source and binary forms, with or without
     13  * modification, are permitted provided that the following conditions
     14  * are met:
     15  * 1. Redistributions of source code must retain the above copyright
     16  *    notice, this list of conditions and the following disclaimer.
     17  * 2. Redistributions in binary form must reproduce the above copyright
     18  *    notice, this list of conditions and the following disclaimer in the
     19  *    documentation and/or other materials provided with the distribution.
     20  * 3. Neither the name of the University nor the names of its contributors
     21  *    may be used to endorse or promote products derived from this software
     22  *    without specific prior written permission.
     23  *
     24  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     25  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     26  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     27  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     28  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     29  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     30  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     31  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     32  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     33  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     34  * SUCH DAMAGE.
     35  *
     36  * from: Utah $Hdr: autoconf.c 1.36 92/12/20$
     37  *
     38  *	@(#)autoconf.c  8.2 (Berkeley) 1/12/94
     39  */
     40 
     41 /*
     42  * Setup the system to run on the current machine.
     43  *
     44  * Configure() is called at boot time.
     45  */
     46 
     47 #include <sys/cdefs.h>
     48 __KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.6 2025/03/09 12:43:09 mlelstv Exp $");
     49 
     50 #include <sys/param.h>
     51 #include <sys/systm.h>
     52 #include <sys/buf.h>
     53 #include <sys/conf.h>
     54 #include <sys/reboot.h>
     55 #include <sys/device.h>
     56 
     57 #include <machine/bootinfo.h>
     58 #include <machine/intr.h>
     59 
     60 #include <virt68k/dev/mainbusvar.h>
     61 
     62 /*
     63  * Determine mass storage and memory configuration for a machine.
     64  */
     65 void
     66 cpu_configure(void)
     67 {
     68 
     69 	booted_device = NULL;	/* set by device drivers (if found) */
     70 
     71 	/* Initialise interrupt handlers */
     72 	intr_init();
     73 
     74 	if (config_rootfound("mainbus", NULL) == NULL)
     75 		panic("autoconfig failed, no root");
     76 
     77 	/*
     78 	 * XXX Go ahead and enable interrupts now that we've configured
     79 	 * XXX everything.
     80 	 * XXX
     81 	 * XXX See locore.s, right before main() is called.
     82 	 */
     83 	spl0();
     84 }
     85 
     86 /* Maximum size is NAME=wedgename\0 */
     87 static char bootspec_buf[128 + 6 + 1];
     88 
     89 void
     90 cpu_rootconf(void)
     91 {
     92 
     93 	bootinfo_setup_initrd();
     94 
     95 	if (bootinfo_getarg("root", bootspec_buf, sizeof(bootspec_buf))) {
     96 		if (bootspec_buf[0] != '\0')
     97 			bootspec = bootspec_buf;
     98 	}
     99 
    100 	rootconf();
    101 }
    102 
    103 paddr_t	consdev_addr;
    104 
    105 void
    106 device_register(device_t dev, void *aux)
    107 {
    108 	device_t parent = device_parent(dev);
    109 
    110 	if (device_is_a(parent, "mainbus")) {
    111 		struct mainbus_attach_args *ma = aux;
    112 
    113 		if (ma->ma_addr == consdev_addr) {
    114 			prop_dictionary_set_bool(device_properties(dev),
    115 						 "is-console", true);
    116 		}
    117 	}
    118 }
    119