1 /* $NetBSD: autoconf.c,v 1.35 2002/09/27 02:24:18 thorpej 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. All advertising materials mentioning features or use of this software 21 * must display the following acknowledgement: 22 * This product includes software developed by the University of 23 * California, Berkeley and its contributors. 24 * 4. Neither the name of the University nor the names of its contributors 25 * may be used to endorse or promote products derived from this software 26 * without specific prior written permission. 27 * 28 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 29 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 30 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 31 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 32 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 33 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 34 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 35 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 36 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 37 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 38 * SUCH DAMAGE. 39 * 40 * from: Utah $Hdr: autoconf.c 1.36 92/12/20$ 41 * 42 * @(#)autoconf.c 8.2 (Berkeley) 1/12/94 43 */ 44 45 /* 46 * Setup the system to run on the current machine. 47 * 48 * Configure() is called at boot time. 49 */ 50 51 #include <sys/param.h> 52 #include <sys/systm.h> 53 #include <sys/buf.h> 54 #include <sys/dkstat.h> 55 #include <sys/conf.h> 56 #include <sys/reboot.h> 57 #include <sys/device.h> 58 59 #include <machine/vmparam.h> 60 #include <machine/disklabel.h> 61 #include <machine/cpu.h> 62 #include <machine/autoconf.h> 63 #include <machine/pte.h> 64 65 #include <dev/scsipi/scsi_all.h> 66 #include <dev/scsipi/scsipi_all.h> 67 #include <dev/scsipi/scsiconf.h> 68 69 #include <mvme68k/mvme68k/isr.h> 70 71 #ifdef MVME147 72 #include <mvme68k/dev/pccreg.h> 73 #endif 74 #if defined(MVME162) || defined(MVME167) || defined(MVME172) || defined(MVME177) 75 #include <dev/mvme/pcctworeg.h> 76 #endif 77 78 79 struct device *booted_device; /* boot device */ 80 81 /* 82 * Determine mass storage and memory configuration for a machine. 83 */ 84 void 85 cpu_configure() 86 { 87 88 booted_device = NULL; /* set by device drivers (if found) */ 89 90 /* Initialise interrupt handlers */ 91 isrinit(); 92 softintr_init(); 93 94 if (config_rootfound("mainbus", NULL) == NULL) 95 panic("autoconfig failed, no root"); 96 } 97 98 void 99 cpu_rootconf() 100 { 101 102 printf("boot device: %s", 103 (booted_device) ? booted_device->dv_xname : "<unknown>"); 104 105 if (bootpart) 106 printf(" (partition %d)\n", bootpart); 107 else 108 printf("\n"); 109 110 setroot(booted_device, bootpart); 111 } 112 113 void 114 device_register(dev, aux) 115 struct device *dev; 116 void *aux; 117 { 118 static struct device *controller; 119 static int foundboot; 120 struct device *parent = dev->dv_parent; 121 const char *name = dev->dv_cfdata->cf_name; 122 123 if (foundboot) 124 return; 125 126 if (controller == NULL && parent) { 127 const char *pname = parent->dv_cfdata->cf_name; 128 129 switch (machineid) { 130 #ifdef MVME147 131 case MVME_147: 132 /* 133 * We currently only support booting from the 147's 134 * onboard scsi and ethernet. So ensure this 135 * device's parent is the PCC driver. 136 */ 137 if (strcmp(pname, "pcc")) 138 return; 139 140 if (bootaddr == PCC_PADDR(PCC_WDSC_OFF) && 141 strcmp(name, "wdsc") == 0) { 142 controller = dev; 143 return; 144 } 145 146 if (bootaddr == PCC_PADDR(PCC_LE_OFF) && 147 strcmp(name, "le") == 0) { 148 booted_device = dev; 149 foundboot = 1; 150 return; 151 } 152 153 break; 154 #endif /* MVME_147 */ 155 156 #if defined(MVME162) || defined(MVME167) || defined(MVME172) || defined(MVME177) 157 case MVME_162: 158 case MVME_167: 159 case MVME_172: 160 case MVME_177: 161 /* 162 * We currently only support booting from the 16x and 163 * 17x onboard scsi and ethernet. So ensure this 164 * device's parent is the PCCTWO driver. 165 */ 166 if (strcmp(pname, "pcctwo")) 167 return; 168 169 if (bootaddr == PCCTWO_PADDR(PCCTWO_NCRSC_OFF) && 170 strcmp(name, "osiop") == 0) { 171 controller = dev; 172 return; 173 } 174 175 if (bootaddr == PCCTWO_PADDR(PCCTWO_IE_OFF) && 176 strcmp(name, "ie") == 0) { 177 booted_device = dev; 178 foundboot = 1; 179 return; 180 } 181 182 break; 183 #endif /* MVME_162 || MVME_167 || MVME_172 || MVME_177 */ 184 185 default: 186 break; 187 } 188 189 return; 190 } 191 192 /* 193 * Find out which device on the scsibus we booted from 194 */ 195 if (strcmp(name, "sd") == 0 || 196 strcmp(name, "cd") == 0 || 197 strcmp(name, "st") == 0) { 198 struct scsipibus_attach_args *sa = aux; 199 200 if (parent->dv_parent != controller || 201 bootdevlun != sa->sa_periph->periph_target) 202 return; 203 204 booted_device = dev; 205 foundboot = 1; 206 } 207 } 208