1 /* $NetBSD: mainbus.c,v 1.6 2002/03/13 13:12:29 simonb Exp $ */ 2 3 /* 4 * Copyright (c) 2000 Soren S. Jorvang 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 3. All advertising materials mentioning features or use of this software 16 * must display the following acknowledgement: 17 * This product includes software developed for the 18 * NetBSD Project. See http://www.netbsd.org/ for 19 * information about NetBSD. 20 * 4. The name of the author may not be used to endorse or promote products 21 * derived from this software without specific prior written permission. 22 * 23 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 24 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 25 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 26 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 27 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 28 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 32 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 */ 34 35 #include <sys/param.h> 36 #include <sys/systm.h> 37 #include <sys/device.h> 38 39 #include <mips/cpuregs.h> 40 41 #include <machine/autoconf.h> 42 #include <machine/machtype.h> 43 44 #include <dev/arcbios/arcbios.h> 45 #include <dev/arcbios/arcbiosvar.h> 46 47 #include "locators.h" 48 49 static int mainbus_match(struct device *, struct cfdata *, void *); 50 static void mainbus_attach(struct device *, struct device *, void *); 51 static int mainbus_search(struct device *, struct cfdata *, void *); 52 int mainbus_print(void *, const char *); 53 54 struct cfattach mainbus_ca = { 55 sizeof(struct device), mainbus_match, mainbus_attach 56 }; 57 58 static int 59 mainbus_match(parent, match, aux) 60 struct device *parent; 61 struct cfdata *match; 62 void *aux; 63 { 64 return 1; 65 } 66 67 static void 68 mainbus_attach(parent, self, aux) 69 struct device *parent; 70 struct device *self; 71 void *aux; 72 { 73 struct mainbus_attach_args ma; 74 75 printf(": %s [%s, %s], %d processor%s", arcbios_system_identifier, 76 arcbios_sysid_vendor, arcbios_sysid_product, 77 ncpus, ncpus == 1 ? "" : "s"); 78 79 printf("\n"); 80 81 config_search(mainbus_search, self, &ma); 82 } 83 84 static int 85 mainbus_search(parent, cf, aux) 86 struct device *parent; 87 struct cfdata *cf; 88 void *aux; 89 { 90 struct mainbus_attach_args *ma = aux; 91 92 do { 93 ma->ma_name = NULL; 94 ma->ma_addr = cf->cf_loc[MAINBUSCF_ADDR]; 95 ma->ma_iot = 0; 96 ma->ma_ioh = MIPS_PHYS_TO_KSEG1(ma->ma_addr); 97 if ((*cf->cf_attach->ca_match)(parent, cf, ma) > 0) 98 config_attach(parent, cf, ma, mainbus_print); 99 } while (cf->cf_fstate == FSTATE_STAR); 100 101 return 0; 102 } 103 104 int 105 mainbus_print(aux, pnp) 106 void *aux; 107 const char *pnp; 108 { 109 struct mainbus_attach_args *ma = aux; 110 111 if (pnp != 0) 112 return QUIET; 113 114 if (ma->ma_addr != MAINBUSCF_ADDR_DEFAULT) 115 printf(" addr 0x%lx", ma->ma_addr); 116 117 return UNCONF; 118 } 119