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