1 /* $NetBSD: rmixl_cpunode.c,v 1.6 2022/09/29 07:00:47 skrll 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.6 2022/09/29 07:00:47 skrll 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/device.h> 52 53 #include <evbmips/rmixl/autoconf.h> 54 55 #include <mips/rmi/rmixlvar.h> 56 #include <mips/rmi/rmixl_cpunodevar.h> 57 58 #include <sys/bus.h> 59 #include "locators.h" 60 61 static int cpunode_rmixl_match(device_t, cfdata_t, void *); 62 static void cpunode_rmixl_attach(device_t, device_t, void *); 63 static int cpunode_rmixl_print(void *, const char *); 64 65 CFATTACH_DECL_NEW(cpunode_rmixl, sizeof(struct cpunode_softc), 66 cpunode_rmixl_match, cpunode_rmixl_attach, NULL, NULL); 67 68 static int 69 cpunode_rmixl_match(device_t parent, cfdata_t cf, void *aux) 70 { 71 struct mainbus_attach_args *ma = aux; 72 73 if (!cpu_rmixl(mips_options.mips_cpu)) 74 return 0; 75 76 /* XXX for now attach one node only */ 77 if (ma->ma_node != 0) 78 return 0; 79 80 return 1; 81 } 82 83 static void 84 cpunode_rmixl_attach(device_t parent, device_t self, void *aux) 85 { 86 u_int sz; 87 u_int ncores; 88 struct cpunode_softc *sc = device_private(self); 89 struct mainbus_attach_args *ma = aux; 90 struct cpunode_attach_args na; 91 const u_int cpu_cidflags = mips_options.mips_cpu->cpu_cidflags; 92 93 aprint_naive("\n"); 94 aprint_normal("\n"); 95 96 sc->sc_dev = self; 97 sc->sc_node = ma->ma_node; 98 sc->sc_attached = 1; 99 100 switch (cpu_cidflags & MIPS_CIDFL_RMI_TYPE) { 101 case CIDFL_RMI_TYPE_XLR: 102 case CIDFL_RMI_TYPE_XLS: 103 /* 104 * L2 is unified on XLR, XLS 105 */ 106 sz = (size_t)MIPS_CIDFL_RMI_L2SZ(cpu_cidflags); 107 aprint_normal("%s: %dKB/32B %d-banked 8-way set associative" 108 " unified L2 cache\n", device_xname(self), 109 sz/1024, sz/(256 * 1024)); 110 break; 111 case CIDFL_RMI_TYPE_XLP: 112 /* TBD */ 113 break; 114 } 115 116 ncores = MIPS_CIDFL_RMI_NCORES(cpu_cidflags); 117 aprint_normal("%s: %d %s on node\n", device_xname(self), ncores, 118 ncores == 1 ? "core" : "cores"); 119 120 /* 121 * Attach cpu (RMI thread) devices 122 */ 123 for (int i=0; i < ncores; i++) { 124 na.na_name = "cpucore"; 125 na.na_node = ma->ma_node; 126 na.na_core = i; 127 config_found(self, &na, cpunode_rmixl_print, CFARGS_NONE); 128 } 129 130 /* 131 * Attach obio 132 */ 133 na.na_name = "obio"; 134 config_found(self, &na, NULL, CFARGS_NONE); 135 } 136 137 static int 138 cpunode_rmixl_print(void *aux, const char *pnp) 139 { 140 struct cpunode_attach_args *na = aux; 141 142 if (pnp != NULL) 143 aprint_normal("%s:", pnp); 144 aprint_normal(" core %d", na->na_core); 145 146 return (UNCONF); 147 } 148