1 /* $NetBSD: autoconf.c,v 1.20 2023/12/20 06:13:59 thorpej Exp $ */ 2 3 /* 4 * Copyright (c) 1994-1998 Mark Brinicombe. 5 * Copyright (c) 1994 Brini. 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions 10 * are met: 11 * 1. Redistributions of source code must retain the above copyright 12 * notice, this list of conditions and the following disclaimer. 13 * 2. Redistributions in binary form must reproduce the above copyright 14 * notice, this list of conditions and the following disclaimer in the 15 * documentation and/or other materials provided with the distribution. 16 * 3. All advertising materials mentioning features or use of this software 17 * must display the following acknowledgement: 18 * This product includes software developed by Mark Brinicombe for 19 * the NetBSD project. 20 * 4. The name of the company nor the name of the author may be used to 21 * endorse or promote products derived from this software without specific 22 * prior written permission. 23 * 24 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 25 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 26 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 27 * IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 28 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 29 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 30 * 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 * RiscBSD kernel project 37 * 38 * autoconf.c 39 * 40 * Autoconfiguration functions 41 * 42 * Created : 08/10/94 43 */ 44 45 #include <sys/cdefs.h> 46 __KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.20 2023/12/20 06:13:59 thorpej Exp $"); 47 48 #include "opt_md.h" 49 50 #include <sys/param.h> 51 #include <sys/systm.h> 52 #include <sys/reboot.h> 53 #include <sys/disklabel.h> 54 #include <sys/device.h> 55 #include <sys/conf.h> 56 #include <sys/kernel.h> 57 #include <machine/bootconfig.h> 58 #include <machine/intr.h> 59 60 61 #include "podulebus.h" 62 63 extern char *booted_kernel; 64 65 extern dev_t dumpdev; 66 67 void isa_intr_init(void); 68 69 #ifndef MEMORY_DISK_IS_ROOT 70 static void get_device(char *name); 71 static void set_root_device(void); 72 #endif 73 74 #ifndef MEMORY_DISK_IS_ROOT 75 /* Decode a device name to a major and minor number */ 76 77 static void 78 get_device(char *name) 79 { 80 int unit, part; 81 char devname[16], *cp; 82 device_t dv; 83 84 if (strncmp(name, "/dev/", 5) == 0) 85 name += 5; 86 87 if (devsw_name2blk(name, devname, sizeof(devname)) == -1) 88 return; 89 90 name += strlen(devname); 91 unit = part = 0; 92 93 cp = name; 94 while (*cp >= '0' && *cp <= '9') 95 unit = (unit * 10) + (*cp++ - '0'); 96 if (cp == name) 97 return; 98 99 if (*cp >= 'a' && *cp <= ('a' + MAXPARTITIONS)) 100 part = *cp - 'a'; 101 else if (*cp != '\0' && *cp != ' ') 102 return; 103 104 if ((dv = device_find_by_driver_unit(devname, unit)) != NULL) { 105 booted_device = dv; 106 booted_partition = part; 107 } 108 } 109 110 111 /* Set the rootdev variable from the root specifier in the boot args */ 112 113 static void 114 set_root_device(void) 115 { 116 char *ptr; 117 118 if (booted_kernel) 119 get_device(booted_kernel); 120 if (boot_args && 121 get_bootconf_option(boot_args, "root", BOOTOPT_TYPE_STRING, &ptr)) 122 get_device(ptr); 123 } 124 #endif 125 126 /* 127 * Set up the root device from the boot args 128 */ 129 void 130 cpu_rootconf(void) 131 { 132 #ifndef MEMORY_DISK_IS_ROOT 133 set_root_device(); 134 135 printf("boot device: %s\n", 136 booted_device != NULL ? device_xname(booted_device) : "<unknown>"); 137 #endif 138 rootconf(); 139 } 140 141 142 /* 143 * void cpu_configure() 144 * 145 * Configure all the root devices 146 * The root devices are expected to configure their own children 147 */ 148 149 void 150 cpu_configure(void) 151 { 152 /* 153 * Configure all the roots. 154 * We have to have a mainbus 155 */ 156 157 /* 158 * Since the ICU is not standard on the ARM we don't know 159 * if we have one until we find a bridge. 160 * Since various PCI interrupts could be routed via the ICU 161 * (for PCI devices in the bridge) we need to set up the ICU 162 * now so that these interrupts can be established correctly 163 * i.e. This is a hack. 164 */ 165 166 config_rootfound("mainbus", NULL); 167 #if NPODULEBUS > 0 168 config_rootfound("podulebus", NULL); 169 #endif /* NPODULEBUS */ 170 171 #if defined(DEBUG) 172 /* Debugging information */ 173 printf("ipl_bio=%08x ipl_net=%08x ipl_tty=%08x ipl_vm=%08x\n", 174 irqmasks[IPL_BIO], irqmasks[IPL_NET], irqmasks[IPL_TTY], 175 irqmasks[IPL_VM]); 176 printf("ipl_audio=%08x ipl_imp=%08x ipl_high=%08x ipl_serial=%08x\n", 177 irqmasks[IPL_AUDIO], irqmasks[IPL_CLOCK], irqmasks[IPL_HIGH], 178 irqmasks[IPL_SERIAL]); 179 #endif /* defined(DEBUG) */ 180 181 /* Time to start taking interrupts so lets open the flood gates .... */ 182 (void)spl0(); 183 } 184 185 void 186 device_register(device_t dev, void *aux) 187 { 188 } 189 /* End of autoconf.c */ 190