1 1.6 chs /* $NetBSD: autoconf.c,v 1.6 2012/10/27 17:17:50 chs Exp $ */ 2 1.1 matt 3 1.1 matt /* 4 1.1 matt * Copyright 2002 Wasabi Systems, Inc. 5 1.1 matt * All rights reserved. 6 1.1 matt * 7 1.1 matt * Written by Simon Burge for Wasabi Systems, Inc. 8 1.1 matt * 9 1.1 matt * Redistribution and use in source and binary forms, with or without 10 1.1 matt * modification, are permitted provided that the following conditions 11 1.1 matt * are met: 12 1.1 matt * 1. Redistributions of source code must retain the above copyright 13 1.1 matt * notice, this list of conditions and the following disclaimer. 14 1.1 matt * 2. Redistributions in binary form must reproduce the above copyright 15 1.1 matt * notice, this list of conditions and the following disclaimer in the 16 1.1 matt * documentation and/or other materials provided with the distribution. 17 1.1 matt * 3. All advertising materials mentioning features or use of this software 18 1.1 matt * must display the following acknowledgement: 19 1.1 matt * This product includes software developed for the NetBSD Project by 20 1.1 matt * Wasabi Systems, Inc. 21 1.1 matt * 4. The name of Wasabi Systems, Inc. may not be used to endorse 22 1.1 matt * or promote products derived from this software without specific prior 23 1.1 matt * written permission. 24 1.1 matt * 25 1.1 matt * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND 26 1.1 matt * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 27 1.1 matt * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 28 1.1 matt * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC 29 1.1 matt * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 30 1.1 matt * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 31 1.1 matt * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 32 1.1 matt * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 33 1.1 matt * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 34 1.1 matt * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 35 1.1 matt * POSSIBILITY OF SUCH DAMAGE. 36 1.1 matt */ 37 1.1 matt 38 1.1 matt #include <sys/cdefs.h> 39 1.6 chs __KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.6 2012/10/27 17:17:50 chs Exp $"); 40 1.1 matt 41 1.1 matt #include <sys/param.h> 42 1.1 matt #include <sys/systm.h> 43 1.1 matt #include <sys/buf.h> 44 1.1 matt #include <sys/conf.h> 45 1.1 matt #include <sys/device.h> 46 1.1 matt #include <sys/cpu.h> 47 1.1 matt 48 1.1 matt static void findroot(void); 49 1.1 matt 50 1.1 matt void 51 1.1 matt cpu_configure(void) 52 1.1 matt { 53 1.1 matt 54 1.1 matt intr_init(); 55 1.1 matt 56 1.1 matt /* Kick off autoconfiguration. */ 57 1.1 matt (void)splhigh(); 58 1.1 matt if (config_rootfound("mainbus", NULL) == NULL) 59 1.1 matt panic("no mainbus found"); 60 1.1 matt 61 1.1 matt /* 62 1.1 matt * Hardware interrupts will be enabled in 63 1.1 matt * sys/arch/mips/mips/mips3_clockintr.c:mips3_initclocks() 64 1.1 matt * to avoid hardclock(9) by CPU INT5 before softclockintr is 65 1.1 matt * initialized in initclocks(). 66 1.1 matt */ 67 1.1 matt } 68 1.1 matt 69 1.1 matt void 70 1.1 matt cpu_rootconf(void) 71 1.1 matt { 72 1.1 matt findroot(); 73 1.1 matt 74 1.1 matt printf("boot device: %s\n", 75 1.6 chs booted_device ? device_xname(booted_device) : "<unknown>"); 76 1.1 matt 77 1.5 mlelstv rootconf(); 78 1.1 matt } 79 1.1 matt 80 1.1 matt extern char bootstring[]; 81 1.1 matt extern int netboot; 82 1.1 matt 83 1.1 matt static void 84 1.1 matt findroot(void) 85 1.1 matt { 86 1.3 dyoung device_t dv; 87 1.3 dyoung deviter_t di; 88 1.1 matt 89 1.1 matt if (booted_device) 90 1.1 matt return; 91 1.1 matt 92 1.3 dyoung if ((booted_device == NULL) && netboot == 0) { 93 1.3 dyoung for (dv = deviter_first(&di, DEVITER_F_ROOT_FIRST); dv != NULL; 94 1.3 dyoung dv = deviter_next(&di)) { 95 1.1 matt if (device_class(dv) == DV_DISK && 96 1.1 matt device_is_a(dv, "wd")) 97 1.1 matt booted_device = dv; 98 1.3 dyoung } 99 1.3 dyoung deviter_release(&di); 100 1.3 dyoung } 101 1.1 matt 102 1.1 matt /* 103 1.1 matt * XXX Match up MBR boot specification with BSD disklabel for root? 104 1.1 matt */ 105 1.1 matt booted_partition = 0; 106 1.1 matt 107 1.1 matt return; 108 1.1 matt } 109 1.1 matt 110 1.1 matt void 111 1.6 chs device_register(device_t dev, void *aux) 112 1.1 matt { 113 1.2 macallan prop_dictionary_t dict; 114 1.2 macallan 115 1.1 matt if ((booted_device == NULL) && (netboot == 1)) 116 1.1 matt if (device_class(dev) == DV_IFNET) 117 1.1 matt booted_device = dev; 118 1.4 macallan if (device_is_a(dev, "genfb") || device_is_a(dev, "voyagerfb")) { 119 1.2 macallan dict = device_properties(dev); 120 1.2 macallan /* 121 1.2 macallan * this is a hack 122 1.2 macallan * is_console and address need to be checked against reality 123 1.2 macallan */ 124 1.2 macallan prop_dictionary_set_bool(dict, "is_console", 1); 125 1.2 macallan prop_dictionary_set_uint32(dict, "width", 1024); 126 1.2 macallan prop_dictionary_set_uint32(dict, "height", 600); 127 1.2 macallan prop_dictionary_set_uint32(dict, "depth", 16); 128 1.2 macallan prop_dictionary_set_uint32(dict, "linebytes", 2048); 129 1.2 macallan prop_dictionary_set_uint32(dict, "address", 0x04000000); 130 1.2 macallan } 131 1.1 matt } 132