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