1 /* $NetBSD: mainbus.c,v 1.27 1998/06/24 01:10:35 ross Exp $ */ 2 3 /* 4 * Copyright (c) 1994, 1995, 1996 Carnegie-Mellon University. 5 * All rights reserved. 6 * 7 * Author: Chris G. Demetriou 8 * 9 * Permission to use, copy, modify and distribute this software and 10 * its documentation is hereby granted, provided that both the copyright 11 * notice and this permission notice appear in all copies of the 12 * software, derivative works or modified versions, and any portions 13 * thereof, and that both notices appear in supporting documentation. 14 * 15 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" 16 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND 17 * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. 18 * 19 * Carnegie Mellon requests users of this software to return to 20 * 21 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU 22 * School of Computer Science 23 * Carnegie Mellon University 24 * Pittsburgh PA 15213-3890 25 * 26 * any improvements or extensions that they make and grant Carnegie the 27 * rights to redistribute these changes. 28 */ 29 30 #include <sys/cdefs.h> /* RCS ID & Copyright macro defns */ 31 32 __KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.27 1998/06/24 01:10:35 ross Exp $"); 33 34 #include <sys/param.h> 35 #include <sys/systm.h> 36 #include <sys/device.h> 37 #include <sys/reboot.h> 38 39 #include <machine/autoconf.h> 40 #include <machine/rpb.h> 41 #include <machine/conf.h> 42 43 /* Definition of the mainbus driver. */ 44 static int mbmatch __P((struct device *, struct cfdata *, void *)); 45 static void mbattach __P((struct device *, struct device *, void *)); 46 static int mbprint __P((void *, const char *)); 47 48 struct cfattach mainbus_ca = { 49 sizeof(struct device), mbmatch, mbattach 50 }; 51 52 /* There can be only one. */ 53 int mainbus_found; 54 55 static int 56 mbmatch(parent, cf, aux) 57 struct device *parent; 58 struct cfdata *cf; 59 void *aux; 60 { 61 62 if (mainbus_found) 63 return (0); 64 65 return (1); 66 } 67 68 static void 69 mbattach(parent, self, aux) 70 struct device *parent; 71 struct device *self; 72 void *aux; 73 { 74 struct mainbus_attach_args ma; 75 struct pcs *pcsp; 76 int i, cpuattachcnt; 77 extern int ncpus; 78 79 mainbus_found = 1; 80 81 printf("\n"); 82 83 /* 84 * Try to find and attach all of the CPUs in the machine. 85 */ 86 cpuattachcnt = 0; 87 for (i = 0; i < hwrpb->rpb_pcs_cnt; i++) { 88 pcsp = LOCATE_PCS(hwrpb, i); 89 if ((pcsp->pcs_flags & PCS_PP) == 0) 90 continue; 91 92 ma.ma_name = "cpu"; 93 ma.ma_slot = i; 94 if (config_found(self, &ma, mbprint) != NULL) 95 cpuattachcnt++; 96 } 97 if (ncpus != cpuattachcnt) 98 printf("WARNING: %d cpus in machine, %d attached\n", 99 ncpus, cpuattachcnt); 100 101 if (platform.iobus != NULL) { 102 ma.ma_name = platform.iobus; 103 ma.ma_slot = 0; /* meaningless */ 104 config_found(self, &ma, mbprint); 105 } 106 } 107 108 static int 109 mbprint(aux, pnp) 110 void *aux; 111 const char *pnp; 112 { 113 struct mainbus_attach_args *ma = aux; 114 115 if (pnp) 116 printf("%s at %s", ma->ma_name, pnp); 117 118 return (UNCONF); 119 } 120