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