1 /* $NetBSD: mainbus.c,v 1.17 2002/10/02 04:59:47 thorpej Exp $ */ 2 /* $OpenBSD: mainbus.c,v 1.4 1998/10/15 21:30:15 imp Exp $ */ 3 /* NetBSD: mainbus.c,v 1.3 1995/06/28 02:45:10 cgd Exp */ 4 5 /* 6 * Copyright (c) 1997 Per Fogelstrom. 7 * Copyright (c) 1994, 1995 Carnegie-Mellon University. 8 * All rights reserved. 9 * 10 * Author: Chris G. Demetriou 11 * 12 * Permission to use, copy, modify and distribute this software and 13 * its documentation is hereby granted, provided that both the copyright 14 * notice and this permission notice appear in all copies of the 15 * software, derivative works or modified versions, and any portions 16 * thereof, and that both notices appear in supporting documentation. 17 * 18 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" 19 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND 20 * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. 21 * 22 * Carnegie Mellon requests users of this software to return to 23 * 24 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU 25 * School of Computer Science 26 * Carnegie Mellon University 27 * Pittsburgh PA 15213-3890 28 * 29 * any improvements or extensions that they make and grant Carnegie the 30 * rights to redistribute these changes. 31 */ 32 33 #include <sys/param.h> 34 #include <sys/systm.h> 35 #include <sys/device.h> 36 37 #include <machine/autoconf.h> 38 #include <machine/platform.h> 39 40 struct mainbus_softc { 41 struct device sc_dv; 42 struct abus sc_bus; 43 }; 44 45 /* Definition of the mainbus driver. */ 46 static int mbmatch __P((struct device *, struct cfdata *, void *)); 47 static void mbattach __P((struct device *, struct device *, void *)); 48 static int mbprint __P((void *, const char *)); 49 50 CFATTACH_DECL(mainbus, sizeof(struct mainbus_softc), 51 mbmatch, mbattach, NULL, NULL); 52 53 void mb_intr_establish __P((struct confargs *, int (*)(void *), void *)); 54 void mb_intr_disestablish __P((struct confargs *)); 55 caddr_t mb_cvtaddr __P((struct confargs *)); 56 int mb_matchname __P((struct confargs *, char *)); 57 58 static int mainbus_found; 59 60 static int 61 mbmatch(parent, match, aux) 62 struct device *parent; 63 struct cfdata *match; 64 void *aux; 65 { 66 67 if (mainbus_found) 68 return (0); 69 70 return (1); 71 } 72 73 static void 74 mbattach(parent, self, aux) 75 struct device *parent; 76 struct device *self; 77 void *aux; 78 { 79 struct mainbus_softc *sc = (struct mainbus_softc *)self; 80 struct confargs nca; 81 int i; 82 83 mainbus_found = 1; 84 85 printf("\n"); 86 87 sc->sc_bus.ab_dv = (struct device *)sc; 88 sc->sc_bus.ab_type = BUS_MAIN; 89 sc->sc_bus.ab_intr_establish = mb_intr_establish; 90 sc->sc_bus.ab_intr_disestablish = mb_intr_disestablish; 91 sc->sc_bus.ab_cvtaddr = mb_cvtaddr; 92 sc->sc_bus.ab_matchname = mb_matchname; 93 94 /* 95 * Try to find and attach all of the CPUs in the machine. 96 * ( Right now only one CPU so code is simple ) 97 */ 98 99 nca.ca_name = "cpu"; 100 nca.ca_slot = 0; 101 nca.ca_offset = 0; 102 nca.ca_bus = &sc->sc_bus; 103 config_found(self, &nca, mbprint); 104 105 for (i = 0; platform->mainbusdevs[i] != NULL; i++) { 106 nca.ca_name = platform->mainbusdevs[i]; 107 nca.ca_slot = 0; 108 nca.ca_offset = 0; 109 nca.ca_bus = &sc->sc_bus; 110 config_found(self, &nca, mbprint); 111 } 112 } 113 114 static int 115 mbprint(aux, pnp) 116 void *aux; 117 const char *pnp; 118 { 119 120 if (pnp) 121 return (QUIET); 122 return (UNCONF); 123 } 124 125 void 126 mb_intr_establish(ca, handler, val) 127 struct confargs *ca; 128 int (*handler) __P((void *)); 129 void *val; 130 { 131 132 panic("can never mb_intr_establish"); 133 } 134 135 void 136 mb_intr_disestablish(ca) 137 struct confargs *ca; 138 { 139 140 panic("can never mb_intr_disestablish"); 141 } 142 143 caddr_t 144 mb_cvtaddr(ca) 145 struct confargs *ca; 146 { 147 148 return (NULL); 149 } 150 151 int 152 mb_matchname(ca, name) 153 struct confargs *ca; 154 char *name; 155 { 156 157 return (strcmp(name, ca->ca_name) == 0); 158 } 159