1 /* $OpenBSD: mainbus.c,v 1.10 2017/01/19 15:09:04 visa Exp $ */ 2 3 /* 4 * Copyright (c) 2001-2003 Opsycon AB (www.opsycon.se / www.opsycon.com) 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: 9 * 1. Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * 2. Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * 15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS 16 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 19 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25 * SUCH DAMAGE. 26 * 27 */ 28 29 #include <sys/param.h> 30 #include <sys/systm.h> 31 #include <sys/device.h> 32 33 #include <machine/autoconf.h> 34 35 int mainbus_match(struct device *, void *, void *); 36 void mainbus_attach(struct device *, struct device *, void *); 37 int mainbus_print(void *, const char *); 38 39 const struct cfattach mainbus_ca = { 40 sizeof(struct device), mainbus_match, mainbus_attach 41 }; 42 43 struct cfdriver mainbus_cd = { 44 NULL, "mainbus", DV_DULL 45 }; 46 47 int 48 mainbus_match(struct device *parent, void *cfdata, void *aux) 49 { 50 static int mainbus_attached = 0; 51 52 if (mainbus_attached != 0) 53 return 0; 54 55 return mainbus_attached = 1; 56 } 57 58 void 59 mainbus_attach(struct device *parent, struct device *self, void *aux) 60 { 61 struct cpu_attach_args caa; 62 63 printf(": %s %s\n", sys_platform->vendor, sys_platform->product); 64 65 bzero(&caa, sizeof caa); 66 caa.caa_maa.maa_name = "cpu"; 67 caa.caa_hw = &bootcpu_hwinfo; 68 config_found(self, &caa, mainbus_print); 69 70 #ifdef MULTIPROCESSOR 71 if (sys_platform->config_secondary_cpus != NULL) 72 sys_platform->config_secondary_cpus(self, mainbus_print); 73 #endif 74 75 caa.caa_maa.maa_name = "bonito"; 76 config_found(self, &caa.caa_maa, mainbus_print); 77 78 caa.caa_maa.maa_name = "htb"; 79 config_found(self, &caa.caa_maa, mainbus_print); 80 81 caa.caa_maa.maa_name = "leioc"; 82 config_found(self, &caa.caa_maa, mainbus_print); 83 84 if (md_startclock == NULL) { 85 caa.caa_maa.maa_name = "clock"; 86 config_found(self, &caa.caa_maa, mainbus_print); 87 } 88 89 caa.caa_maa.maa_name = "apm"; 90 config_found(self, &caa.caa_maa, mainbus_print); 91 } 92 93 int 94 mainbus_print(void *aux, const char *pnp) 95 { 96 return pnp != NULL ? QUIET : UNCONF; 97 } 98