1 /* $NetBSD: autoconf.c,v 1.3 2002/09/25 22:21:10 thorpej Exp $ */ 2 3 /*- 4 * Copyright (c) 2000 The NetBSD Foundation, Inc. 5 * All rights reserved. 6 * 7 * This code is derived from software contributed to The NetBSD Foundation 8 * by Tohru Nishimura. 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 NetBSD 21 * Foundation, Inc. and its contributors. 22 * 4. Neither the name of The NetBSD Foundation nor the names of its 23 * contributors may be used to endorse or promote products derived 24 * from this software without specific prior written permission. 25 * 26 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 27 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 28 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 29 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE 30 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 31 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 32 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 33 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 34 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 35 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 36 * POSSIBILITY OF SUCH DAMAGE. 37 */ 38 39 #include <sys/cdefs.h> /* RCS ID & Copyright macro defns */ 40 41 __KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.3 2002/09/25 22:21:10 thorpej Exp $"); 42 43 #include <sys/param.h> 44 #include <sys/systm.h> 45 #include <sys/buf.h> 46 #include <sys/conf.h> 47 #include <sys/reboot.h> 48 #include <sys/device.h> 49 50 #include <machine/disklabel.h> 51 #include <machine/cpu.h> 52 53 #include <luna68k/luna68k/isr.h> 54 55 /* 56 * The following several variables are related to 57 * the configuration process, and are used in initializing 58 * the machine. 59 */ 60 struct device *booted_device; /* set by device drivers (if found) */ 61 62 static struct device *find_dev_byname __P((char *)); 63 64 /* 65 * Determine mass storage and memory configuration for a machine. 66 */ 67 void 68 cpu_configure() 69 { 70 booted_device = NULL; /* set by device drivers (if found) */ 71 72 (void)splhigh(); 73 isrinit(); 74 if (config_rootfound("mainbus", NULL) == NULL) 75 panic("autoconfig failed, no root"); 76 77 spl0(); 78 } 79 80 void 81 cpu_rootconf() 82 { 83 #if 1 /* XXX to be reworked with helps of 2nd stage loaders XXX */ 84 int i; 85 char *devname, *cp; 86 extern char bootarg[64]; 87 88 cp = bootarg; 89 devname = "sd0"; 90 for (i = 0; i < sizeof(bootarg); i++) { 91 if (*cp == '\0') 92 break; 93 if (*cp == 'E' && memcmp("ENADDR=", cp, 7) == 0) { 94 devname = "le0"; 95 break; 96 } 97 cp++; 98 } 99 booted_device = find_dev_byname(devname); 100 101 #endif 102 printf("boot device: %s\n", 103 (booted_device) ? booted_device->dv_xname : "<unknown>"); 104 105 setroot(booted_device, 0); /* XXX partition 'a' XXX */ 106 } 107 108 static struct device * 109 find_dev_byname(name) 110 char *name; 111 { 112 struct device *dv; 113 114 for (dv = alldevs.tqh_first; dv != NULL; dv = dv->dv_list.tqe_next) { 115 if (!strcmp(dv->dv_xname, name)) { 116 return dv; 117 } 118 } 119 return NULL; 120 } 121