1 /* $NetBSD: mainbus.c,v 1.2 2000/02/08 16:17:34 tsutsui Exp $ */ 2 3 /* 4 * Copyright (c) 1994, 1995 Carnegie-Mellon University. 5 * All rights reserved. 6 * 7 * Author: Chris G. Demetriou 8 * DECstation port: Jonathan Stone 9 * 10 * Permission to use, copy, modify and distribute this software and 11 * its documentation is hereby granted, provided that both the copyright 12 * notice and this permission notice appear in all copies of the 13 * software, derivative works or modified versions, and any portions 14 * thereof, and that both notices appear in supporting documentation. 15 * 16 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" 17 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND 18 * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. 19 * 20 * Carnegie Mellon requests users of this software to return to 21 * 22 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU 23 * School of Computer Science 24 * Carnegie Mellon University 25 * Pittsburgh PA 15213-3890 26 * 27 * any improvements or extensions that they make and grant Carnegie the 28 * rights to redistribute these changes. 29 */ 30 31 #include <sys/param.h> 32 #include <sys/systm.h> 33 #include <sys/device.h> 34 35 #include <machine/autoconf.h> 36 #include <machine/cpu.h> 37 38 #include <news68k/news68k/machid.h> 39 40 struct mainbus_softc { 41 struct device sc_dev; 42 }; 43 44 /* Definition of the mainbus driver. */ 45 static int mainbus_match __P((struct device *, struct cfdata *, void *)); 46 static void mainbus_attach __P((struct device *, struct device *, void *)); 47 static int mainbus_search __P((struct device *, struct cfdata *, void *)); 48 static int mainbus_print __P((void *, const char *)); 49 50 struct cfattach mainbus_ca = { 51 sizeof(struct mainbus_softc), mainbus_match, mainbus_attach 52 }; 53 54 static int mainbus_found; 55 56 static int 57 mainbus_match(parent, cfdata, aux) 58 struct device *parent; 59 struct cfdata *cfdata; 60 void *aux; 61 { 62 63 if (mainbus_found) 64 return 0; 65 66 return 1; 67 } 68 69 static void 70 mainbus_attach(parent, self, aux) 71 struct device *parent; 72 struct device *self; 73 void *aux; 74 { 75 struct mainbus_attach_args ma; 76 77 mainbus_found = 1; 78 printf("\n"); 79 80 config_search(mainbus_search, self, &ma); 81 } 82 83 static int 84 mainbus_search(parent, cf, aux) 85 struct device *parent; 86 struct cfdata *cf; 87 void *aux; 88 { 89 struct mainbus_attach_args *ma = aux; 90 91 ma->ma_name = cf->cf_driver->cd_name; 92 ma->ma_systype = cf->cf_systype; 93 94 if ((*cf->cf_attach->ca_match)(parent, cf, ma) > 0) 95 config_attach(parent, cf, ma, mainbus_print); 96 97 return 0; 98 } 99 100 static int 101 mainbus_print(aux, cp) 102 void *aux; 103 const char *cp; 104 { 105 struct mainbus_attach_args *ma = aux; 106 107 if (cp) 108 printf("%s at %s", ma->ma_name, cp); 109 110 return (UNCONF); 111 } 112