| @@ -1,17 +1,17 @@ | | | @@ -1,17 +1,17 @@ |
1 | /* $NetBSD: cpu.c,v 1.102 2020/10/10 03:05:04 thorpej Exp $ */ | | 1 | /* $NetBSD: cpu.c,v 1.103 2020/10/15 01:00:01 thorpej Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 1998, 1999, 2000, 2001 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 1998, 1999, 2000, 2001, 2020 The NetBSD Foundation, Inc. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * This code is derived from software contributed to The NetBSD Foundation | | 7 | * This code is derived from software contributed to The NetBSD Foundation |
8 | * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, | | 8 | * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, |
9 | * NASA Ames Research Center. | | 9 | * NASA Ames Research Center. |
10 | * | | 10 | * |
11 | * Redistribution and use in source and binary forms, with or without | | 11 | * Redistribution and use in source and binary forms, with or without |
12 | * modification, are permitted provided that the following conditions | | 12 | * modification, are permitted provided that the following conditions |
13 | * are met: | | 13 | * are met: |
14 | * 1. Redistributions of source code must retain the above copyright | | 14 | * 1. Redistributions of source code must retain the above copyright |
15 | * notice, this list of conditions and the following disclaimer. | | 15 | * notice, this list of conditions and the following disclaimer. |
16 | * 2. Redistributions in binary form must reproduce the above copyright | | 16 | * 2. Redistributions in binary form must reproduce the above copyright |
17 | * notice, this list of conditions and the following disclaimer in the | | 17 | * notice, this list of conditions and the following disclaimer in the |
| @@ -49,38 +49,39 @@ | | | @@ -49,38 +49,39 @@ |
49 | * Carnegie Mellon requests users of this software to return to | | 49 | * Carnegie Mellon requests users of this software to return to |
50 | * | | 50 | * |
51 | * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU | | 51 | * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU |
52 | * School of Computer Science | | 52 | * School of Computer Science |
53 | * Carnegie Mellon University | | 53 | * Carnegie Mellon University |
54 | * Pittsburgh PA 15213-3890 | | 54 | * Pittsburgh PA 15213-3890 |
55 | * | | 55 | * |
56 | * any improvements or extensions that they make and grant Carnegie the | | 56 | * any improvements or extensions that they make and grant Carnegie the |
57 | * rights to redistribute these changes. | | 57 | * rights to redistribute these changes. |
58 | */ | | 58 | */ |
59 | | | 59 | |
60 | #include <sys/cdefs.h> /* RCS ID & Copyright macro defns */ | | 60 | #include <sys/cdefs.h> /* RCS ID & Copyright macro defns */ |
61 | | | 61 | |
62 | __KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.102 2020/10/10 03:05:04 thorpej Exp $"); | | 62 | __KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.103 2020/10/15 01:00:01 thorpej Exp $"); |
63 | | | 63 | |
64 | #include "opt_ddb.h" | | 64 | #include "opt_ddb.h" |
65 | #include "opt_multiprocessor.h" | | 65 | #include "opt_multiprocessor.h" |
66 | | | 66 | |
67 | #include <sys/param.h> | | 67 | #include <sys/param.h> |
68 | #include <sys/systm.h> | | 68 | #include <sys/systm.h> |
69 | #include <sys/device.h> | | 69 | #include <sys/device.h> |
70 | #include <sys/kmem.h> | | 70 | #include <sys/kmem.h> |
71 | #include <sys/proc.h> | | 71 | #include <sys/proc.h> |
72 | #include <sys/atomic.h> | | 72 | #include <sys/atomic.h> |
73 | #include <sys/cpu.h> | | 73 | #include <sys/cpu.h> |
| | | 74 | #include <sys/sysctl.h> |
74 | | | 75 | |
75 | #include <uvm/uvm_extern.h> | | 76 | #include <uvm/uvm_extern.h> |
76 | | | 77 | |
77 | #include <machine/autoconf.h> | | 78 | #include <machine/autoconf.h> |
78 | #include <machine/cpuvar.h> | | 79 | #include <machine/cpuvar.h> |
79 | #include <machine/rpb.h> | | 80 | #include <machine/rpb.h> |
80 | #include <machine/prom.h> | | 81 | #include <machine/prom.h> |
81 | #include <machine/alpha.h> | | 82 | #include <machine/alpha.h> |
82 | | | 83 | |
83 | struct cpu_info cpu_info_primary __cacheline_aligned = { | | 84 | struct cpu_info cpu_info_primary __cacheline_aligned = { |
84 | .ci_curlwp = &lwp0 | | 85 | .ci_curlwp = &lwp0 |
85 | }; | | 86 | }; |
86 | struct cpu_info *cpu_info_list = &cpu_info_primary; | | 87 | struct cpu_info *cpu_info_list = &cpu_info_primary; |
| @@ -137,53 +138,171 @@ static int cpumatch(device_t, cfdata_t, | | | @@ -137,53 +138,171 @@ static int cpumatch(device_t, cfdata_t, |
137 | static void cpuattach(device_t, device_t, void *); | | 138 | static void cpuattach(device_t, device_t, void *); |
138 | | | 139 | |
139 | CFATTACH_DECL_NEW(cpu, sizeof(struct cpu_softc), | | 140 | CFATTACH_DECL_NEW(cpu, sizeof(struct cpu_softc), |
140 | cpumatch, cpuattach, NULL, NULL); | | 141 | cpumatch, cpuattach, NULL, NULL); |
141 | | | 142 | |
142 | static void cpu_announce_extensions(struct cpu_info *); | | 143 | static void cpu_announce_extensions(struct cpu_info *); |
143 | | | 144 | |
144 | extern struct cfdriver cpu_cd; | | 145 | extern struct cfdriver cpu_cd; |
145 | | | 146 | |
146 | static const char * const lcaminor[] = { | | 147 | static const char * const lcaminor[] = { |
147 | "", | | 148 | "", |
148 | "21066", "21066", | | 149 | "21066", "21066", |
149 | "21068", "21068", | | 150 | "21068", "21068", |
150 | "21066A", "21068A", 0 | | 151 | "21066A", "21068A", |
| | | 152 | NULL |
151 | }; | | 153 | }; |
152 | | | 154 | |
153 | const struct cputable_struct { | | 155 | const struct cputable_struct { |
154 | int cpu_major_code; | | 156 | const char *cpu_evname; |
155 | const char *cpu_major_name; | | 157 | const char *cpu_major_name; |
156 | const char * const *cpu_minor_names; | | 158 | const char * const *cpu_minor_names; |
157 | } cpunametable[] = { | | 159 | } cpunametable[] = { |
158 | { PCS_PROC_EV3, "EV3", NULL }, | | 160 | [PCS_PROC_EV3] ={ "EV3", NULL, NULL }, |
159 | { PCS_PROC_EV4, "21064", NULL }, | | 161 | [PCS_PROC_EV4] ={ "EV4", "21064", NULL }, |
160 | { PCS_PROC_SIMULATION, "Sim", NULL }, | | 162 | [PCS_PROC_SIMULATION]={ "Sim", NULL, NULL }, |
161 | { PCS_PROC_LCA4, "LCA", lcaminor }, | | 163 | [PCS_PROC_LCA4] ={ "LCA4", NULL, lcaminor }, |
162 | { PCS_PROC_EV5, "21164", NULL }, | | 164 | [PCS_PROC_EV5] ={ "EV5", "21164", NULL }, |
163 | { PCS_PROC_EV45, "21064A", NULL }, | | 165 | [PCS_PROC_EV45] ={ "EV45", "21064A", NULL }, |
164 | { PCS_PROC_EV56, "21164A", NULL }, | | 166 | [PCS_PROC_EV56] ={ "EV56", "21164A", NULL }, |
165 | { PCS_PROC_EV6, "21264", NULL }, | | 167 | [PCS_PROC_EV6] ={ "EV6", "21264", NULL }, |
166 | { PCS_PROC_PCA56, "PCA56", NULL }, | | 168 | [PCS_PROC_PCA56] ={ "PCA56", "21164PC", NULL }, |
167 | { PCS_PROC_PCA57, "PCA57", NULL }, | | 169 | [PCS_PROC_PCA57] ={ "PCA57", "21164PC"/*XXX*/,NULL }, |
168 | { PCS_PROC_EV67, "21264A", NULL }, | | 170 | [PCS_PROC_EV67] ={ "EV67", "21264A", NULL }, |
169 | { PCS_PROC_EV68CB, "21264C", NULL }, | | 171 | [PCS_PROC_EV68CB] ={ "EV68CB", "21264C", NULL }, |
170 | { PCS_PROC_EV68AL, "21264B", NULL }, | | 172 | [PCS_PROC_EV68AL] ={ "EV68AL", "21264B", NULL }, |
171 | { PCS_PROC_EV68CX, "21264D", NULL }, | | 173 | [PCS_PROC_EV68CX] ={ "EV68CX", "21264D", NULL }, |
172 | { PCS_PROC_EV7, "21364", NULL }, | | 174 | [PCS_PROC_EV7] ={ "EV7", "21364", NULL }, |
173 | { PCS_PROC_EV79, "EV79", NULL }, | | 175 | [PCS_PROC_EV79] ={ "EV79", NULL, NULL }, |
174 | { PCS_PROC_EV69, "EV69", NULL }, | | 176 | [PCS_PROC_EV69] ={ "EV69", NULL, NULL }, |
175 | }; | | 177 | }; |
176 | | | 178 | |
| | | 179 | static bool |
| | | 180 | cpu_description(const struct cpu_softc * const sc, |
| | | 181 | char * const buf, size_t const buflen) |
| | | 182 | { |
| | | 183 | const char * const *s; |
| | | 184 | const char *ev; |
| | | 185 | int i; |
| | | 186 | |
| | | 187 | const uint32_t major = sc->sc_major_type; |
| | | 188 | const uint32_t minor = sc->sc_minor_type; |
| | | 189 | |
| | | 190 | if (major < __arraycount(cpunametable) && |
| | | 191 | (ev = cpunametable[major].cpu_evname) != NULL) { |
| | | 192 | s = cpunametable[major].cpu_minor_names; |
| | | 193 | for (i = 0; s != NULL && s[i] != NULL; i++) { |
| | | 194 | if (i == minor && strlen(s[i]) != 0) { |
| | | 195 | break; |
| | | 196 | } |
| | | 197 | } |
| | | 198 | if (s == NULL || s[i] == NULL) { |
| | | 199 | s = &cpunametable[major].cpu_major_name; |
| | | 200 | i = 0; |
| | | 201 | if (s[i] == NULL) { |
| | | 202 | s = NULL; |
| | | 203 | } |
| | | 204 | } |
| | | 205 | |
| | | 206 | /* |
| | | 207 | * Example strings: |
| | | 208 | * |
| | | 209 | * Sim-0 |
| | | 210 | * 21068-3 (LCA4) [uses minor table] |
| | | 211 | * 21264C-5 (EV68CB) |
| | | 212 | * 21164PC-1 (PCA56) |
| | | 213 | */ |
| | | 214 | if (s != NULL) { |
| | | 215 | snprintf(buf, buflen, "%s-%d (%s)", s[i], minor, ev); |
| | | 216 | } else { |
| | | 217 | snprintf(buf, buflen, "%s-%d", ev, minor); |
| | | 218 | } |
| | | 219 | return true; |
| | | 220 | } |
| | | 221 | |
| | | 222 | snprintf(buf, buflen, "UNKNOWN CPU TYPE (%u:%u)", major, minor); |
| | | 223 | return false; |
| | | 224 | } |
| | | 225 | |
| | | 226 | static int |
| | | 227 | cpu_sysctl_model(SYSCTLFN_ARGS) |
| | | 228 | { |
| | | 229 | struct sysctlnode node = *rnode; |
| | | 230 | const struct cpu_softc * const sc = node.sysctl_data; |
| | | 231 | char model[32]; |
| | | 232 | |
| | | 233 | cpu_description(sc, model, sizeof(model)); |
| | | 234 | node.sysctl_data = model; |
| | | 235 | return sysctl_lookup(SYSCTLFN_CALL(&node)); |
| | | 236 | } |
| | | 237 | |
| | | 238 | static int |
| | | 239 | cpu_sysctl_amask_bit(SYSCTLFN_ARGS, unsigned long const bit) |
| | | 240 | { |
| | | 241 | struct sysctlnode node = *rnode; |
| | | 242 | const struct cpu_softc * const sc = node.sysctl_data; |
| | | 243 | |
| | | 244 | bool result = (sc->sc_amask & bit) ? true : false; |
| | | 245 | node.sysctl_data = &result; |
| | | 246 | return sysctl_lookup(SYSCTLFN_CALL(&node)); |
| | | 247 | } |
| | | 248 | |
| | | 249 | static int |
| | | 250 | cpu_sysctl_bwx(SYSCTLFN_ARGS) |
| | | 251 | { |
| | | 252 | return cpu_sysctl_amask_bit(SYSCTLFN_CALL(rnode), ALPHA_AMASK_BWX); |
| | | 253 | } |
| | | 254 | |
| | | 255 | static int |
| | | 256 | cpu_sysctl_fix(SYSCTLFN_ARGS) |
| | | 257 | { |
| | | 258 | return cpu_sysctl_amask_bit(SYSCTLFN_CALL(rnode), ALPHA_AMASK_FIX); |
| | | 259 | } |
| | | 260 | |
| | | 261 | static int |
| | | 262 | cpu_sysctl_cix(SYSCTLFN_ARGS) |
| | | 263 | { |
| | | 264 | return cpu_sysctl_amask_bit(SYSCTLFN_CALL(rnode), ALPHA_AMASK_CIX); |
| | | 265 | } |
| | | 266 | |
| | | 267 | static int |
| | | 268 | cpu_sysctl_mvi(SYSCTLFN_ARGS) |
| | | 269 | { |
| | | 270 | return cpu_sysctl_amask_bit(SYSCTLFN_CALL(rnode), ALPHA_AMASK_MVI); |
| | | 271 | } |
| | | 272 | |
| | | 273 | static int |
| | | 274 | cpu_sysctl_pat(SYSCTLFN_ARGS) |
| | | 275 | { |
| | | 276 | return cpu_sysctl_amask_bit(SYSCTLFN_CALL(rnode), ALPHA_AMASK_PAT); |
| | | 277 | } |
| | | 278 | |
| | | 279 | static int |
| | | 280 | cpu_sysctl_pmi(SYSCTLFN_ARGS) |
| | | 281 | { |
| | | 282 | return cpu_sysctl_amask_bit(SYSCTLFN_CALL(rnode), ALPHA_AMASK_PMI); |
| | | 283 | } |
| | | 284 | |
| | | 285 | static int |
| | | 286 | cpu_sysctl_primary(SYSCTLFN_ARGS) |
| | | 287 | { |
| | | 288 | struct sysctlnode node = *rnode; |
| | | 289 | const struct cpu_softc * const sc = node.sysctl_data; |
| | | 290 | |
| | | 291 | bool result = CPU_IS_PRIMARY(sc->sc_ci); |
| | | 292 | node.sysctl_data = &result; |
| | | 293 | return sysctl_lookup(SYSCTLFN_CALL(&node)); |
| | | 294 | } |
| | | 295 | |
177 | /* | | 296 | /* |
178 | * The following is an attempt to map out how booting secondary CPUs | | 297 | * The following is an attempt to map out how booting secondary CPUs |
179 | * works. | | 298 | * works. |
180 | * | | 299 | * |
181 | * As we find processors during the autoconfiguration sequence, all | | 300 | * As we find processors during the autoconfiguration sequence, all |
182 | * processors have idle stacks and PCBs created for them, including | | 301 | * processors have idle stacks and PCBs created for them, including |
183 | * the primary (although the primary idles on lwp0's PCB until its | | 302 | * the primary (although the primary idles on lwp0's PCB until its |
184 | * idle PCB is created). | | 303 | * idle PCB is created). |
185 | * | | 304 | * |
186 | * Right before calling uvm_scheduler(), main() calls, on lwp0's | | 305 | * Right before calling uvm_scheduler(), main() calls, on lwp0's |
187 | * context, cpu_boot_secondary_processors(). This is our key to | | 306 | * context, cpu_boot_secondary_processors(). This is our key to |
188 | * actually spin up the additional processor's we've found. We | | 307 | * actually spin up the additional processor's we've found. We |
189 | * run through our cpu_info[] array looking for secondary processors | | 308 | * run through our cpu_info[] array looking for secondary processors |
| @@ -209,152 +328,136 @@ cpumatch(device_t parent, cfdata_t cfdat | | | @@ -209,152 +328,136 @@ cpumatch(device_t parent, cfdata_t cfdat |
209 | if (strcmp(ma->ma_name, cpu_cd.cd_name) != 0) | | 328 | if (strcmp(ma->ma_name, cpu_cd.cd_name) != 0) |
210 | return (0); | | 329 | return (0); |
211 | | | 330 | |
212 | /* XXX CHECK SLOT? */ | | 331 | /* XXX CHECK SLOT? */ |
213 | /* XXX CHECK PRIMARY? */ | | 332 | /* XXX CHECK PRIMARY? */ |
214 | | | 333 | |
215 | return (1); | | 334 | return (1); |
216 | } | | 335 | } |
217 | | | 336 | |
218 | static void | | 337 | static void |
219 | cpuattach(device_t parent, device_t self, void *aux) | | 338 | cpuattach(device_t parent, device_t self, void *aux) |
220 | { | | 339 | { |
221 | struct cpu_softc * const sc = device_private(self); | | 340 | struct cpu_softc * const sc = device_private(self); |
222 | struct mainbus_attach_args *ma = aux; | | 341 | const struct mainbus_attach_args * const ma = aux; |
223 | int i; | | | |
224 | const char * const *s; | | | |
225 | struct pcs *p; | | | |
226 | uint32_t major, minor; | | | |
227 | struct cpu_info *ci; | | 342 | struct cpu_info *ci; |
| | | 343 | char model[32]; |
| | | 344 | |
| | | 345 | const bool primary = ma->ma_slot == hwrpb->rpb_primary_cpu_id; |
228 | | | 346 | |
229 | sc->sc_dev = self; | | 347 | sc->sc_dev = self; |
230 | | | 348 | |
231 | p = LOCATE_PCS(hwrpb, ma->ma_slot); | | 349 | const struct pcs * const p = LOCATE_PCS(hwrpb, ma->ma_slot); |
232 | major = PCS_CPU_MAJORTYPE(p); | | 350 | sc->sc_major_type = PCS_CPU_MAJORTYPE(p); |
233 | minor = PCS_CPU_MINORTYPE(p); | | 351 | sc->sc_minor_type = PCS_CPU_MINORTYPE(p); |
234 | | | 352 | |
235 | aprint_normal(": ID %d%s, ", ma->ma_slot, | | 353 | const bool recognized = cpu_description(sc, model, sizeof(model)); |
236 | ma->ma_slot == hwrpb->rpb_primary_cpu_id ? " (primary)" : ""); | | 354 | |
237 | | | 355 | aprint_normal(": ID %d%s, ", ma->ma_slot, primary ? " (primary)" : ""); |
238 | for(i = 0; i < __arraycount(cpunametable); ++i) { | | 356 | if (recognized) { |
239 | if (cpunametable[i].cpu_major_code == major) { | | 357 | aprint_normal("%s", model); |
240 | aprint_normal("%s-%d", | | 358 | } else { |
241 | cpunametable[i].cpu_major_name, minor); | | 359 | aprint_error("%s", model); |
242 | s = cpunametable[i].cpu_minor_names; | | | |
243 | for(i = 0; s && s[i]; ++i) { | | | |
244 | if (i == minor && strlen(s[i]) != 0) { | | | |
245 | aprint_normal(" (%s)", s[i]); | | | |
246 | goto recognized; | | | |
247 | } | | | |
248 | } | | | |
249 | goto recognized; | | | |
250 | } | | | |
251 | } | | 360 | } |
252 | aprint_error("UNKNOWN CPU TYPE (%d:%d)", major, minor); | | | |
253 | | | 361 | |
254 | recognized: | | | |
255 | aprint_naive("\n"); | | 362 | aprint_naive("\n"); |
256 | aprint_normal("\n"); | | 363 | aprint_normal("\n"); |
257 | | | 364 | |
258 | #ifdef DEBUG | | | |
259 | if (p->pcs_proc_var != 0) { | | 365 | if (p->pcs_proc_var != 0) { |
260 | bool needcomma = false; | | 366 | bool needcomma = false; |
261 | const char *vaxfp = ""; | | 367 | const char *vaxfp = ""; |
262 | const char *ieeefp = ""; | | 368 | const char *ieeefp = ""; |
263 | const char *pe = ""; | | 369 | const char *pe = ""; |
264 | | | 370 | |
265 | if (p->pcs_proc_var & PCS_VAR_VAXFP) { | | 371 | if (p->pcs_proc_var & PCS_VAR_VAXFP) { |
| | | 372 | sc->sc_vax_fp = true; |
266 | vaxfp = "VAX FP support"; | | 373 | vaxfp = "VAX FP support"; |
267 | needcomma = true; | | 374 | needcomma = true; |
268 | } | | 375 | } |
269 | if (p->pcs_proc_var & PCS_VAR_IEEEFP) { | | 376 | if (p->pcs_proc_var & PCS_VAR_IEEEFP) { |
| | | 377 | sc->sc_ieee_fp = true; |
270 | ieeefp = ", IEEE FP support"; | | 378 | ieeefp = ", IEEE FP support"; |
271 | if (!needcomma) | | 379 | if (!needcomma) |
272 | ieeefp += 2; | | 380 | ieeefp += 2; |
273 | needcomma = true; | | 381 | needcomma = true; |
274 | } | | 382 | } |
275 | if (p->pcs_proc_var & PCS_VAR_PE) { | | 383 | if (p->pcs_proc_var & PCS_VAR_PE) { |
| | | 384 | sc->sc_primary_eligible = true; |
276 | pe = ", Primary Eligible"; | | 385 | pe = ", Primary Eligible"; |
277 | if (!needcomma) | | 386 | if (!needcomma) |
278 | pe += 2; | | 387 | pe += 2; |
279 | needcomma = true; | | 388 | needcomma = true; |
280 | } | | 389 | } |
281 | aprint_debug_dev(sc->sc_dev, "%s%s%s", vaxfp, ieeefp, pe); | | 390 | aprint_debug_dev(sc->sc_dev, "%s%s%s", vaxfp, ieeefp, pe); |
282 | if (p->pcs_proc_var & PCS_VAR_RESERVED) | | 391 | if (p->pcs_proc_var & PCS_VAR_RESERVED) |
283 | aprint_debug("%sreserved bits: %#lx", | | 392 | aprint_debug("%sreserved bits: %#lx", |
284 | needcomma ? ", " : "", | | 393 | needcomma ? ", " : "", |
285 | p->pcs_proc_var & PCS_VAR_RESERVED); | | 394 | p->pcs_proc_var & PCS_VAR_RESERVED); |
286 | aprint_debug("\n"); | | 395 | aprint_debug("\n"); |
287 | } | | 396 | } |
288 | #endif | | | |
289 | | | 397 | |
290 | if (ma->ma_slot > ALPHA_WHAMI_MAXID) { | | 398 | if (ma->ma_slot > ALPHA_WHAMI_MAXID) { |
291 | if (ma->ma_slot == hwrpb->rpb_primary_cpu_id) | | 399 | if (primary) |
292 | panic("cpu_attach: primary CPU ID too large"); | | 400 | panic("cpu_attach: primary CPU ID too large"); |
293 | aprint_error_dev(sc->sc_dev, | | 401 | aprint_error_dev(sc->sc_dev, |
294 | "processor ID too large, ignoring\n"); | | 402 | "processor ID too large, ignoring\n"); |
295 | return; | | 403 | return; |
296 | } | | 404 | } |
297 | | | 405 | |
298 | if (ma->ma_slot == hwrpb->rpb_primary_cpu_id) | | 406 | if (primary) { |
299 | ci = &cpu_info_primary; | | 407 | ci = &cpu_info_primary; |
300 | else { | | 408 | } else { |
301 | /* | | 409 | /* |
302 | * kmem_zalloc() will guarante cache line alignment for | | 410 | * kmem_zalloc() will guarante cache line alignment for |
303 | * all allocations >= CACHE_LINE_SIZE. | | 411 | * all allocations >= CACHE_LINE_SIZE. |
304 | */ | | 412 | */ |
305 | ci = kmem_zalloc(sizeof(*ci), KM_SLEEP); | | 413 | ci = kmem_zalloc(sizeof(*ci), KM_SLEEP); |
306 | KASSERT(((uintptr_t)ci & (CACHE_LINE_SIZE - 1)) == 0); | | 414 | KASSERT(((uintptr_t)ci & (CACHE_LINE_SIZE - 1)) == 0); |
307 | } | | 415 | } |
308 | #if defined(MULTIPROCESSOR) | | 416 | #if defined(MULTIPROCESSOR) |
309 | cpu_info[ma->ma_slot] = ci; | | 417 | cpu_info[ma->ma_slot] = ci; |
310 | #endif | | 418 | #endif |
311 | ci->ci_cpuid = ma->ma_slot; | | 419 | ci->ci_cpuid = ma->ma_slot; |
312 | ci->ci_softc = sc; | | 420 | ci->ci_softc = sc; |
313 | ci->ci_pcc_freq = hwrpb->rpb_cc_freq; | | 421 | ci->ci_pcc_freq = hwrpb->rpb_cc_freq; |
314 | | | 422 | |
315 | /* | | 423 | sc->sc_ci = ci; |
316 | * Though we could (should?) attach the LCA cpus' PCI | | | |
317 | * bus here there is no good reason to do so, and | | | |
318 | * the bus attachment code is easier to understand | | | |
319 | * and more compact if done the 'normal' way. | | | |
320 | */ | | | |
321 | | | 424 | |
322 | #if defined(MULTIPROCESSOR) | | 425 | #if defined(MULTIPROCESSOR) |
323 | /* | | 426 | /* |
324 | * Make sure the processor is available for use. | | 427 | * Make sure the processor is available for use. |
325 | */ | | 428 | */ |
326 | if ((p->pcs_flags & PCS_PA) == 0) { | | 429 | if ((p->pcs_flags & PCS_PA) == 0) { |
327 | if (ma->ma_slot == hwrpb->rpb_primary_cpu_id) | | 430 | if (primary) |
328 | panic("cpu_attach: primary not available?!"); | | 431 | panic("cpu_attach: primary not available?!"); |
329 | aprint_normal_dev(sc->sc_dev, | | 432 | aprint_normal_dev(sc->sc_dev, |
330 | "processor not available for use\n"); | | 433 | "processor not available for use\n"); |
331 | return; | | 434 | return; |
332 | } | | 435 | } |
333 | | | 436 | |
334 | /* Make sure the processor has valid PALcode. */ | | 437 | /* Make sure the processor has valid PALcode. */ |
335 | if ((p->pcs_flags & PCS_PV) == 0) { | | 438 | if ((p->pcs_flags & PCS_PV) == 0) { |
336 | if (ma->ma_slot == hwrpb->rpb_primary_cpu_id) | | 439 | if (primary) |
337 | panic("cpu_attach: primary has invalid PALcode?!"); | | 440 | panic("cpu_attach: primary has invalid PALcode?!"); |
338 | aprint_error_dev(sc->sc_dev, "PALcode not valid\n"); | | 441 | aprint_error_dev(sc->sc_dev, "PALcode not valid\n"); |
339 | return; | | 442 | return; |
340 | } | | 443 | } |
341 | #endif /* MULTIPROCESSOR */ | | 444 | #endif /* MULTIPROCESSOR */ |
342 | | | 445 | |
343 | /* | | 446 | /* |
344 | * If we're the primary CPU, no more work to do; we're already | | 447 | * If we're the primary CPU, no more work to do; we're already |
345 | * running! | | 448 | * running! |
346 | */ | | 449 | */ |
347 | if (ma->ma_slot == hwrpb->rpb_primary_cpu_id) { | | 450 | if (primary) { |
348 | cpu_announce_extensions(ci); | | 451 | cpu_announce_extensions(ci); |
349 | #if defined(MULTIPROCESSOR) | | 452 | #if defined(MULTIPROCESSOR) |
350 | ci->ci_flags |= CPUF_PRIMARY|CPUF_RUNNING; | | 453 | ci->ci_flags |= CPUF_PRIMARY|CPUF_RUNNING; |
351 | atomic_or_ulong(&cpus_booted, (1UL << ma->ma_slot)); | | 454 | atomic_or_ulong(&cpus_booted, (1UL << ma->ma_slot)); |
352 | atomic_or_ulong(&cpus_running, (1UL << ma->ma_slot)); | | 455 | atomic_or_ulong(&cpus_running, (1UL << ma->ma_slot)); |
353 | #endif /* MULTIPROCESSOR */ | | 456 | #endif /* MULTIPROCESSOR */ |
354 | } else { | | 457 | } else { |
355 | #if defined(MULTIPROCESSOR) | | 458 | #if defined(MULTIPROCESSOR) |
356 | int error; | | 459 | int error; |
357 | | | 460 | |
358 | error = mi_cpu_attach(ci); | | 461 | error = mi_cpu_attach(ci); |
359 | if (error != 0) { | | 462 | if (error != 0) { |
360 | aprint_error_dev(sc->sc_dev, | | 463 | aprint_error_dev(sc->sc_dev, |
| @@ -377,57 +480,208 @@ recognized: | | | @@ -377,57 +480,208 @@ recognized: |
377 | #else /* ! MULTIPROCESSOR */ | | 480 | #else /* ! MULTIPROCESSOR */ |
378 | aprint_normal_dev(sc->sc_dev, "processor off-line; " | | 481 | aprint_normal_dev(sc->sc_dev, "processor off-line; " |
379 | "multiprocessor support not present in kernel\n"); | | 482 | "multiprocessor support not present in kernel\n"); |
380 | #endif /* MULTIPROCESSOR */ | | 483 | #endif /* MULTIPROCESSOR */ |
381 | } | | 484 | } |
382 | | | 485 | |
383 | evcnt_attach_dynamic(&sc->sc_evcnt_clock, EVCNT_TYPE_INTR, | | 486 | evcnt_attach_dynamic(&sc->sc_evcnt_clock, EVCNT_TYPE_INTR, |
384 | NULL, device_xname(sc->sc_dev), "clock"); | | 487 | NULL, device_xname(sc->sc_dev), "clock"); |
385 | evcnt_attach_dynamic(&sc->sc_evcnt_device, EVCNT_TYPE_INTR, | | 488 | evcnt_attach_dynamic(&sc->sc_evcnt_device, EVCNT_TYPE_INTR, |
386 | NULL, device_xname(sc->sc_dev), "device"); | | 489 | NULL, device_xname(sc->sc_dev), "device"); |
387 | #if defined(MULTIPROCESSOR) | | 490 | #if defined(MULTIPROCESSOR) |
388 | alpha_ipi_init(ci); | | 491 | alpha_ipi_init(ci); |
389 | #endif | | 492 | #endif |
| | | 493 | |
| | | 494 | struct sysctllog **log = &sc->sc_sysctllog; |
| | | 495 | const struct sysctlnode *rnode, *cnode; |
| | | 496 | int error; |
| | | 497 | |
| | | 498 | error = sysctl_createv(log, 0, NULL, &rnode, CTLFLAG_PERMANENT, |
| | | 499 | CTLTYPE_NODE, device_xname(sc->sc_dev), |
| | | 500 | SYSCTL_DESCR("cpu properties"), |
| | | 501 | NULL, 0, |
| | | 502 | NULL, 0, CTL_HW, CTL_CREATE, CTL_EOL); |
| | | 503 | if (error) |
| | | 504 | return; |
| | | 505 | |
| | | 506 | error = sysctl_createv(log, 0, &rnode, &cnode, |
| | | 507 | CTLFLAG_PERMANENT, CTLTYPE_STRING, "model", |
| | | 508 | SYSCTL_DESCR("cpu model"), |
| | | 509 | cpu_sysctl_model, 0, |
| | | 510 | (void *)sc, 0, CTL_CREATE, CTL_EOL); |
| | | 511 | if (error) |
| | | 512 | return; |
| | | 513 | |
| | | 514 | error = sysctl_createv(log, 0, &rnode, &cnode, |
| | | 515 | CTLFLAG_PERMANENT, CTLTYPE_INT, "major", |
| | | 516 | SYSCTL_DESCR("cpu major type"), |
| | | 517 | NULL, 0, |
| | | 518 | &sc->sc_major_type, 0, CTL_CREATE, CTL_EOL); |
| | | 519 | if (error) |
| | | 520 | return; |
| | | 521 | |
| | | 522 | error = sysctl_createv(log, 0, &rnode, &cnode, |
| | | 523 | CTLFLAG_PERMANENT, CTLTYPE_INT, "minor", |
| | | 524 | SYSCTL_DESCR("cpu minor type"), |
| | | 525 | NULL, 0, |
| | | 526 | &sc->sc_minor_type, 0, CTL_CREATE, CTL_EOL); |
| | | 527 | if (error) |
| | | 528 | return; |
| | | 529 | |
| | | 530 | error = sysctl_createv(log, 0, &rnode, &cnode, |
| | | 531 | CTLFLAG_PERMANENT, CTLTYPE_LONG, "implver", |
| | | 532 | SYSCTL_DESCR("cpu implementation version"), |
| | | 533 | NULL, 0, |
| | | 534 | &sc->sc_implver, 0, CTL_CREATE, CTL_EOL); |
| | | 535 | if (error) |
| | | 536 | return; |
| | | 537 | |
| | | 538 | error = sysctl_createv(log, 0, &rnode, &cnode, |
| | | 539 | CTLFLAG_PERMANENT|CTLFLAG_HEX, CTLTYPE_LONG, "amask", |
| | | 540 | SYSCTL_DESCR("architecture extensions mask"), |
| | | 541 | NULL, 0, |
| | | 542 | &sc->sc_amask, 0, CTL_CREATE, CTL_EOL); |
| | | 543 | if (error) |
| | | 544 | return; |
| | | 545 | |
| | | 546 | error = sysctl_createv(log, 0, &rnode, &cnode, |
| | | 547 | CTLFLAG_PERMANENT, CTLTYPE_BOOL, "bwx", |
| | | 548 | SYSCTL_DESCR("cpu supports BWX extension"), |
| | | 549 | cpu_sysctl_bwx, 0, |
| | | 550 | (void *)sc, 0, CTL_CREATE, CTL_EOL); |
| | | 551 | if (error) |
| | | 552 | return; |
| | | 553 | |
| | | 554 | error = sysctl_createv(log, 0, &rnode, &cnode, |
| | | 555 | CTLFLAG_PERMANENT, CTLTYPE_BOOL, "fix", |
| | | 556 | SYSCTL_DESCR("cpu supports FIX extension"), |
| | | 557 | cpu_sysctl_fix, 0, |
| | | 558 | (void *)sc, 0, CTL_CREATE, CTL_EOL); |
| | | 559 | if (error) |
| | | 560 | return; |
| | | 561 | |
| | | 562 | error = sysctl_createv(log, 0, &rnode, &cnode, |
| | | 563 | CTLFLAG_PERMANENT, CTLTYPE_BOOL, "cix", |
| | | 564 | SYSCTL_DESCR("cpu supports CIX extension"), |
| | | 565 | cpu_sysctl_cix, 0, |
| | | 566 | (void *)sc, 0, CTL_CREATE, CTL_EOL); |
| | | 567 | if (error) |
| | | 568 | return; |
| | | 569 | |
| | | 570 | error = sysctl_createv(log, 0, &rnode, &cnode, |
| | | 571 | CTLFLAG_PERMANENT, CTLTYPE_BOOL, "mvi", |
| | | 572 | SYSCTL_DESCR("cpu supports MVI extension"), |
| | | 573 | cpu_sysctl_mvi, 0, |
| | | 574 | (void *)sc, 0, CTL_CREATE, CTL_EOL); |
| | | 575 | if (error) |
| | | 576 | return; |
| | | 577 | |
| | | 578 | error = sysctl_createv(log, 0, &rnode, &cnode, |
| | | 579 | CTLFLAG_PERMANENT, CTLTYPE_BOOL, "pat", |
| | | 580 | SYSCTL_DESCR("cpu supports PAT extension"), |
| | | 581 | cpu_sysctl_pat, 0, |
| | | 582 | (void *)sc, 0, CTL_CREATE, CTL_EOL); |
| | | 583 | if (error) |
| | | 584 | return; |
| | | 585 | |
| | | 586 | error = sysctl_createv(log, 0, &rnode, &cnode, |
| | | 587 | CTLFLAG_PERMANENT, CTLTYPE_BOOL, "pmi", |
| | | 588 | SYSCTL_DESCR("cpu supports PMI extension"), |
| | | 589 | cpu_sysctl_pmi, 0, |
| | | 590 | (void *)sc, 0, CTL_CREATE, CTL_EOL); |
| | | 591 | if (error) |
| | | 592 | return; |
| | | 593 | |
| | | 594 | error = sysctl_createv(log, 0, &rnode, &cnode, |
| | | 595 | CTLFLAG_PERMANENT, CTLTYPE_BOOL, "vax_fp", |
| | | 596 | SYSCTL_DESCR("cpu supports VAX FP"), |
| | | 597 | NULL, 0, |
| | | 598 | &sc->sc_vax_fp, 0, CTL_CREATE, CTL_EOL); |
| | | 599 | if (error) |
| | | 600 | return; |
| | | 601 | |
| | | 602 | error = sysctl_createv(log, 0, &rnode, &cnode, |
| | | 603 | CTLFLAG_PERMANENT, CTLTYPE_BOOL, "ieee_fp", |
| | | 604 | SYSCTL_DESCR("cpu supports IEEE FP"), |
| | | 605 | NULL, 0, |
| | | 606 | &sc->sc_ieee_fp, 0, CTL_CREATE, CTL_EOL); |
| | | 607 | if (error) |
| | | 608 | return; |
| | | 609 | |
| | | 610 | error = sysctl_createv(log, 0, &rnode, &cnode, |
| | | 611 | CTLFLAG_PERMANENT, CTLTYPE_BOOL, "primary_eligible", |
| | | 612 | SYSCTL_DESCR("cpu is primary-eligible"), |
| | | 613 | NULL, 0, |
| | | 614 | &sc->sc_primary_eligible, 0, CTL_CREATE, CTL_EOL); |
| | | 615 | if (error) |
| | | 616 | return; |
| | | 617 | |
| | | 618 | error = sysctl_createv(log, 0, &rnode, &cnode, |
| | | 619 | CTLFLAG_PERMANENT, CTLTYPE_BOOL, "primary", |
| | | 620 | SYSCTL_DESCR("cpu is the primary cpu"), |
| | | 621 | cpu_sysctl_primary, 0, |
| | | 622 | (void *)sc, 0, CTL_CREATE, CTL_EOL); |
| | | 623 | if (error) |
| | | 624 | return; |
| | | 625 | |
| | | 626 | error = sysctl_createv(log, 0, &rnode, &cnode, |
| | | 627 | CTLFLAG_PERMANENT, CTLTYPE_LONG, "cpu_id", |
| | | 628 | SYSCTL_DESCR("hardware cpu ID"), |
| | | 629 | NULL, 0, |
| | | 630 | &sc->sc_ci->ci_cpuid, 0, CTL_CREATE, CTL_EOL); |
| | | 631 | if (error) |
| | | 632 | return; |
| | | 633 | |
| | | 634 | error = sysctl_createv(log, 0, &rnode, &cnode, |
| | | 635 | CTLFLAG_PERMANENT, CTLTYPE_LONG, "pcc_freq", |
| | | 636 | SYSCTL_DESCR("PCC frequency"), |
| | | 637 | NULL, 0, |
| | | 638 | &sc->sc_ci->ci_pcc_freq, 0, CTL_CREATE, CTL_EOL); |
| | | 639 | if (error) |
| | | 640 | return; |
390 | } | | 641 | } |
391 | | | 642 | |
392 | static void | | 643 | static void |
393 | cpu_announce_extensions(struct cpu_info *ci) | | 644 | cpu_announce_extensions(struct cpu_info *ci) |
394 | { | | 645 | { |
395 | u_long implver, amask = 0; | | 646 | u_long implver, amask = 0; |
396 | char bits[64]; | | 647 | char bits[64]; |
397 | | | 648 | |
398 | implver = alpha_implver(); | | 649 | implver = alpha_implver(); |
399 | if (implver >= ALPHA_IMPLVER_EV5) | | 650 | if (implver >= ALPHA_IMPLVER_EV5) |
400 | amask = (~alpha_amask(ALPHA_AMASK_ALL)) & ALPHA_AMASK_ALL; | | 651 | amask = (~alpha_amask(ALPHA_AMASK_ALL)) & ALPHA_AMASK_ALL; |
401 | | | 652 | |
| | | 653 | ci->ci_softc->sc_implver = implver; |
| | | 654 | ci->ci_softc->sc_amask = amask; |
| | | 655 | |
402 | if (ci->ci_cpuid == hwrpb->rpb_primary_cpu_id) { | | 656 | if (ci->ci_cpuid == hwrpb->rpb_primary_cpu_id) { |
403 | cpu_implver = implver; | | 657 | cpu_implver = implver; |
404 | cpu_amask = amask; | | 658 | cpu_amask = amask; |
405 | } else { | | 659 | } else { |
406 | if (implver < cpu_implver) | | 660 | if (implver < cpu_implver) |
407 | aprint_error_dev(ci->ci_softc->sc_dev, | | 661 | aprint_error_dev(ci->ci_softc->sc_dev, |
408 | "WARNING: IMPLVER %lu < %lu\n", | | 662 | "WARNING: IMPLVER %lu < %lu\n", |
409 | implver, cpu_implver); | | 663 | implver, cpu_implver); |
410 | | | 664 | |
411 | /* | | 665 | /* |
412 | * Cap the system architecture mask to the intersection | | 666 | * Cap the system architecture mask to the intersection |
413 | * of features supported by all processors in the system. | | 667 | * of features supported by all processors in the system. |
414 | */ | | 668 | */ |
415 | cpu_amask &= amask; | | 669 | cpu_amask &= amask; |
416 | } | | 670 | } |
417 | | | 671 | |
418 | if (amask) { | | 672 | if (amask) { |
419 | snprintb(bits, sizeof(bits), | | 673 | snprintb(bits, sizeof(bits), |
420 | ALPHA_AMASK_BITS, cpu_amask); | | 674 | ALPHA_AMASK_BITS, amask); |
421 | aprint_normal_dev(ci->ci_softc->sc_dev, | | 675 | aprint_normal_dev(ci->ci_softc->sc_dev, |
422 | "Architecture extensions: %s\n", bits); | | 676 | "Architecture extensions: %s\n", bits); |
423 | } | | 677 | } |
424 | } | | 678 | } |
425 | | | 679 | |
426 | #if defined(MULTIPROCESSOR) | | 680 | #if defined(MULTIPROCESSOR) |
427 | void | | 681 | void |
428 | cpu_boot_secondary_processors(void) | | 682 | cpu_boot_secondary_processors(void) |
429 | { | | 683 | { |
430 | struct cpu_info *ci; | | 684 | struct cpu_info *ci; |
431 | u_long i; | | 685 | u_long i; |
432 | bool did_patch = false; | | 686 | bool did_patch = false; |
433 | | | 687 | |