1 /* $NetBSD: rmixl_cpunode.c,v 1.3 2011/07/01 19:01:30 dyoung Exp $ */ 2 3 /* 4 * Copyright (c) 1994,1995 Mark Brinicombe. 5 * Copyright (c) 1994 Brini. 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions 10 * are met: 11 * 1. Redistributions of source code must retain the above copyright 12 * notice, this list of conditions and the following disclaimer. 13 * 2. Redistributions in binary form must reproduce the above copyright 14 * notice, this list of conditions and the following disclaimer in the 15 * documentation and/or other materials provided with the distribution. 16 * 3. All advertising materials mentioning features or use of this software 17 * must display the following acknowledgement: 18 * This product includes software developed by Brini. 19 * 4. The name of the company nor the name of the author may be used to 20 * endorse or promote products derived from this software without specific 21 * prior written permission. 22 * 23 * THIS SOFTWARE IS PROVIDED BY BRINI ``AS IS'' AND ANY EXPRESS OR IMPLIED 24 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 25 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 26 * IN NO EVENT SHALL BRINI OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 27 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 28 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 29 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33 * SUCH DAMAGE. 34 * 35 * RiscBSD kernel project 36 * 37 * mainbus.c 38 * 39 * cpunode configuration 40 * 41 * Created : 15/12/94 42 */ 43 44 #include <sys/cdefs.h> 45 __KERNEL_RCSID(0, "$NetBSD: rmixl_cpunode.c,v 1.3 2011/07/01 19:01:30 dyoung Exp $"); 46 47 #include <sys/param.h> 48 #include <sys/systm.h> 49 #include <sys/kernel.h> 50 #include <sys/conf.h> 51 #include <sys/malloc.h> 52 #include <sys/device.h> 53 54 #include <evbmips/rmixl/autoconf.h> 55 56 #include <mips/rmi/rmixlvar.h> 57 #include <mips/rmi/rmixl_cpunodevar.h> 58 59 #include <sys/bus.h> 60 #include "locators.h" 61 62 static int cpunode_rmixl_match(device_t, cfdata_t, void *); 63 static void cpunode_rmixl_attach(device_t, device_t, void *); 64 static int cpunode_rmixl_print(void *, const char *); 65 66 CFATTACH_DECL_NEW(cpunode_rmixl, sizeof(struct cpunode_softc), 67 cpunode_rmixl_match, cpunode_rmixl_attach, NULL, NULL); 68 69 static int 70 cpunode_rmixl_match(device_t parent, cfdata_t cf, void *aux) 71 { 72 struct mainbus_attach_args *ma = aux; 73 74 if (!cpu_rmixl(mips_options.mips_cpu)) 75 return 0; 76 77 /* XXX for now attach one node only */ 78 if (ma->ma_node != 0) 79 return 0; 80 81 return 1; 82 } 83 84 static void 85 cpunode_rmixl_attach(device_t parent, device_t self, void *aux) 86 { 87 u_int sz; 88 u_int ncores; 89 struct cpunode_softc *sc = device_private(self); 90 struct mainbus_attach_args *ma = aux; 91 struct cpunode_attach_args na; 92 const u_int cpu_cidflags = mips_options.mips_cpu->cpu_cidflags; 93 94 aprint_naive("\n"); 95 aprint_normal("\n"); 96 97 sc->sc_dev = self; 98 sc->sc_node = ma->ma_node; 99 sc->sc_attached = 1; 100 101 switch (cpu_cidflags & MIPS_CIDFL_RMI_TYPE) { 102 case CIDFL_RMI_TYPE_XLR: 103 case CIDFL_RMI_TYPE_XLS: 104 /* 105 * L2 is unified on XLR, XLS 106 */ 107 sz = (size_t)MIPS_CIDFL_RMI_L2SZ(cpu_cidflags); 108 aprint_normal("%s: %dKB/32B %d-banked 8-way set associative" 109 " unified L2 cache\n", device_xname(self), 110 sz/1024, sz/(256 * 1024)); 111 break; 112 case CIDFL_RMI_TYPE_XLP: 113 /* TBD */ 114 break; 115 } 116 117 ncores = MIPS_CIDFL_RMI_NCORES(cpu_cidflags); 118 aprint_normal("%s: %d %s on node\n", device_xname(self), ncores, 119 ncores == 1 ? "core" : "cores"); 120 121 /* 122 * Attach cpu (RMI thread) devices 123 */ 124 for (int i=0; i < ncores; i++) { 125 na.na_name = "cpucore"; 126 na.na_node = ma->ma_node; 127 na.na_core = i; 128 config_found(self, &na, cpunode_rmixl_print); 129 } 130 131 /* 132 * Attach obio 133 */ 134 na.na_name = "obio"; 135 config_found(self, &na, NULL); 136 } 137 138 static int 139 cpunode_rmixl_print(void *aux, const char *pnp) 140 { 141 struct cpunode_attach_args *na = aux; 142 143 if (pnp != NULL) 144 aprint_normal("%s:", pnp); 145 aprint_normal(" core %d", na->na_core); 146 147 return (UNCONF); 148 } 149