1 /* $NetBSD: mainbus.c,v 1.15 2001/06/13 15:08:05 soda 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 struct cfattach mainbus_ca = { 51 sizeof(struct mainbus_softc), mbmatch, mbattach 52 }; 53 54 void mb_intr_establish __P((struct confargs *, int (*)(void *), void *)); 55 void mb_intr_disestablish __P((struct confargs *)); 56 caddr_t mb_cvtaddr __P((struct confargs *)); 57 int mb_matchname __P((struct confargs *, char *)); 58 59 static int mainbus_found; 60 61 static int 62 mbmatch(parent, match, aux) 63 struct device *parent; 64 struct cfdata *match; 65 void *aux; 66 { 67 68 if (mainbus_found) 69 return (0); 70 71 return (1); 72 } 73 74 static void 75 mbattach(parent, self, aux) 76 struct device *parent; 77 struct device *self; 78 void *aux; 79 { 80 struct mainbus_softc *sc = (struct mainbus_softc *)self; 81 struct confargs nca; 82 int i; 83 84 mainbus_found = 1; 85 86 printf("\n"); 87 88 sc->sc_bus.ab_dv = (struct device *)sc; 89 sc->sc_bus.ab_type = BUS_MAIN; 90 sc->sc_bus.ab_intr_establish = mb_intr_establish; 91 sc->sc_bus.ab_intr_disestablish = mb_intr_disestablish; 92 sc->sc_bus.ab_cvtaddr = mb_cvtaddr; 93 sc->sc_bus.ab_matchname = mb_matchname; 94 95 /* 96 * Try to find and attach all of the CPUs in the machine. 97 * ( Right now only one CPU so code is simple ) 98 */ 99 100 nca.ca_name = "cpu"; 101 nca.ca_slot = 0; 102 nca.ca_offset = 0; 103 nca.ca_bus = &sc->sc_bus; 104 config_found(self, &nca, mbprint); 105 106 for (i = 0; platform->mainbusdevs[i] != NULL; i++) { 107 nca.ca_name = platform->mainbusdevs[i]; 108 nca.ca_slot = 0; 109 nca.ca_offset = 0; 110 nca.ca_bus = &sc->sc_bus; 111 config_found(self, &nca, mbprint); 112 } 113 } 114 115 static int 116 mbprint(aux, pnp) 117 void *aux; 118 const char *pnp; 119 { 120 121 if (pnp) 122 return (QUIET); 123 return (UNCONF); 124 } 125 126 void 127 mb_intr_establish(ca, handler, val) 128 struct confargs *ca; 129 int (*handler) __P((void *)); 130 void *val; 131 { 132 133 panic("can never mb_intr_establish"); 134 } 135 136 void 137 mb_intr_disestablish(ca) 138 struct confargs *ca; 139 { 140 141 panic("can never mb_intr_disestablish"); 142 } 143 144 caddr_t 145 mb_cvtaddr(ca) 146 struct confargs *ca; 147 { 148 149 return (NULL); 150 } 151 152 int 153 mb_matchname(ca, name) 154 struct confargs *ca; 155 char *name; 156 { 157 158 return (strcmp(name, ca->ca_name) == 0); 159 } 160