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