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