1 /* $NetBSD: autoconf.c,v 1.8 2001/06/17 00:11:40 cyber Exp $ */ 2 3 /* 4 * Copyright (c) 2000 Soren S. Jorvang. All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: 9 * 1. Redistributions of source code must retain the above copyright 10 * notice, this list of conditions, and the following disclaimer. 11 * 2. Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * 15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25 * SUCH DAMAGE. 26 */ 27 28 #include <sys/param.h> 29 #include <sys/systm.h> 30 #include <sys/buf.h> 31 #include <sys/conf.h> 32 #include <sys/device.h> 33 34 #include <machine/cpu.h> 35 36 extern char bootstring[]; 37 extern int netboot; 38 extern int bootunit; 39 extern int bootpart; 40 41 struct device *booted_device; 42 int booted_partition = 0; 43 44 int cpuspeed = 100; /* Until we know more precisely. */ 45 46 void 47 cpu_configure() 48 { 49 (void)splhigh(); 50 51 if (config_rootfound("mainbus", "mainbus") == NULL) 52 panic("no mainbus found"); 53 54 _splnone(); 55 } 56 57 void 58 cpu_rootconf() 59 { 60 printf("boot device: %s\n", 61 booted_device ? booted_device->dv_xname : "<unknown>"); 62 63 setroot(booted_device, booted_partition); 64 } 65 66 static int hd_iterate = -1; 67 68 void 69 device_register(dev, aux) 70 struct device *dev; 71 void *aux; 72 { 73 if (booted_device) 74 return; 75 76 if ((booted_device == NULL) && (netboot == 1)) 77 if (dev->dv_class == DV_IFNET) 78 booted_device = dev; 79 80 if ((booted_device == NULL) && (netboot == 0)) { 81 if (dev->dv_class == DV_DISK && 82 !strcmp(dev->dv_cfdata->cf_driver->cd_name, "wd")) { 83 hd_iterate++; 84 if (hd_iterate == bootunit) { 85 booted_device = dev; 86 } 87 } 88 /* 89 * XXX Match up MBR boot specification with BSD disklabel for root? 90 */ 91 booted_partition = 0; 92 } 93 } 94 95