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