Detect and spin up non-boot CPUs. Mostly from OpenBSD.diff -r1.16 -r1.17 src/sys/arch/hp700/dev/cpu.c
(skrll)
--- src/sys/arch/hp700/dev/Attic/cpu.c 2010/12/08 09:48:27 1.16
+++ src/sys/arch/hp700/dev/Attic/cpu.c 2011/01/23 21:53:39 1.17
@@ -1,16 +1,16 @@ | @@ -1,16 +1,16 @@ | |||
1 | /* $NetBSD: cpu.c,v 1.16 2010/12/08 09:48:27 skrll Exp $ */ | 1 | /* $NetBSD: cpu.c,v 1.17 2011/01/23 21:53:39 skrll Exp $ */ | |
2 | 2 | |||
3 | /* $OpenBSD: cpu.c,v 1.28 2004/12/28 05:18:25 mickey Exp $ */ | 3 | /* $OpenBSD: cpu.c,v 1.29 2009/02/08 18:33:28 miod Exp $ */ | |
4 | 4 | |||
5 | /* | 5 | /* | |
6 | * Copyright (c) 1998-2003 Michael Shalayeff | 6 | * Copyright (c) 1998-2003 Michael Shalayeff | |
7 | * All rights reserved. | 7 | * All rights reserved. | |
8 | * | 8 | * | |
9 | * Redistribution and use in source and binary forms, with or without | 9 | * Redistribution and use in source and binary forms, with or without | |
10 | * modification, are permitted provided that the following conditions | 10 | * modification, are permitted provided that the following conditions | |
11 | * are met: | 11 | * are met: | |
12 | * 1. Redistributions of source code must retain the above copyright | 12 | * 1. Redistributions of source code must retain the above copyright | |
13 | * notice, this list of conditions and the following disclaimer. | 13 | * notice, this list of conditions and the following disclaimer. | |
14 | * 2. Redistributions in binary form must reproduce the above copyright | 14 | * 2. Redistributions in binary form must reproduce the above copyright | |
15 | * notice, this list of conditions and the following disclaimer in the | 15 | * notice, this list of conditions and the following disclaimer in the | |
16 | * documentation and/or other materials provided with the distribution. | 16 | * documentation and/or other materials provided with the distribution. | |
@@ -19,91 +19,108 @@ | @@ -19,91 +19,108 @@ | |||
19 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | 19 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |
20 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | 20 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | |
21 | * IN NO EVENT SHALL THE AUTHOR OR HIS RELATIVES BE LIABLE FOR ANY DIRECT, | 21 | * IN NO EVENT SHALL THE AUTHOR OR HIS RELATIVES BE LIABLE FOR ANY DIRECT, | |
22 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 22 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | |
23 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | 23 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |
24 | * SERVICES; LOSS OF MIND, USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 24 | * SERVICES; LOSS OF MIND, USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
25 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | 25 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | |
26 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | 26 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | |
27 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF | 27 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF | |
28 | * THE POSSIBILITY OF SUCH DAMAGE. | 28 | * THE POSSIBILITY OF SUCH DAMAGE. | |
29 | */ | 29 | */ | |
30 | 30 | |||
31 | #include <sys/cdefs.h> | 31 | #include <sys/cdefs.h> | |
32 | __KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.16 2010/12/08 09:48:27 skrll Exp $"); | 32 | __KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.17 2011/01/23 21:53:39 skrll Exp $"); | |
33 | ||||
34 | #include "opt_multiprocessor.h" | |||
33 | 35 | |||
34 | #include <sys/param.h> | 36 | #include <sys/param.h> | |
35 | #include <sys/systm.h> | 37 | #include <sys/systm.h> | |
36 | #include <sys/device.h> | 38 | #include <sys/device.h> | |
37 | #include <sys/reboot.h> | 39 | #include <sys/reboot.h> | |
38 | 40 | |||
41 | #include <uvm/uvm.h> | |||
42 | ||||
39 | #include <machine/cpufunc.h> | 43 | #include <machine/cpufunc.h> | |
40 | #include <machine/pdc.h> | 44 | #include <machine/pdc.h> | |
41 | #include <machine/iomod.h> | 45 | #include <machine/iomod.h> | |
42 | #include <machine/autoconf.h> | 46 | #include <machine/autoconf.h> | |
43 | 47 | |||
44 | #include <hp700/hp700/intr.h> | 48 | #include <hp700/hp700/intr.h> | |
45 | #include <hp700/hp700/machdep.h> | 49 | #include <hp700/hp700/machdep.h> | |
46 | #include <hp700/dev/cpudevs.h> | 50 | #include <hp700/dev/cpudevs.h> | |
47 | 51 | |||
48 | struct cpu_softc { | 52 | struct cpu_softc { | |
49 | device_t sc_dev; | 53 | device_t sc_dev; | |
50 | hppa_hpa_t sc_hpa; | 54 | hppa_hpa_t sc_hpa; | |
51 | void *sc_ih; | 55 | void *sc_ih; | |
52 | }; | 56 | }; | |
53 | 57 | |||
54 | #ifdef MULTIPROCESSOR | 58 | #ifdef MULTIPROCESSOR | |
55 | int hppa_ncpus; | 59 | int hppa_ncpus; | |
60 | ||||
61 | struct cpu_info *cpu_hatch_info; | |||
62 | static volatile int start_secondary_cpu; | |||
56 | #endif | 63 | #endif | |
57 | 64 | |||
58 | int cpumatch(device_t, cfdata_t, void *); | 65 | int cpumatch(device_t, cfdata_t, void *); | |
59 | void cpuattach(device_t, device_t, void *); | 66 | void cpuattach(device_t, device_t, void *); | |
60 | 67 | |||
61 | CFATTACH_DECL_NEW(cpu, sizeof(struct cpu_softc), | 68 | CFATTACH_DECL_NEW(cpu, sizeof(struct cpu_softc), | |
62 | cpumatch, cpuattach, NULL, NULL); | 69 | cpumatch, cpuattach, NULL, NULL); | |
63 | 70 | |||
64 | static int cpu_attached; | |||
65 | ||||
66 | int | 71 | int | |
67 | cpumatch(device_t parent, cfdata_t cf, void *aux) | 72 | cpumatch(device_t parent, cfdata_t cf, void *aux) | |
68 | { | 73 | { | |
69 | struct confargs *ca = aux; | 74 | struct confargs *ca = aux; | |
70 | 75 | |||
71 | /* there will be only one for now XXX */ | |||
72 | /* probe any 1.0, 1.1 or 2.0 */ | 76 | /* probe any 1.0, 1.1 or 2.0 */ | |
73 | if (cpu_attached || | 77 | if (ca->ca_type.iodc_type != HPPA_TYPE_NPROC || | |
74 | ca->ca_type.iodc_type != HPPA_TYPE_NPROC || | |||
75 | ca->ca_type.iodc_sv_model != HPPA_NPROC_HPPA) | 78 | ca->ca_type.iodc_sv_model != HPPA_NPROC_HPPA) | |
76 | return 0; | 79 | return 0; | |
77 | 80 | |||
81 | if (cf->cf_unit >= MAXCPUS) | |||
82 | return 0; | |||
83 | ||||
78 | return 1; | 84 | return 1; | |
79 | } | 85 | } | |
80 | 86 | |||
81 | void | 87 | void | |
82 | cpuattach(device_t parent, device_t self, void *aux) | 88 | cpuattach(device_t parent, device_t self, void *aux) | |
83 | { | 89 | { | |
84 | /* machdep.c */ | 90 | /* machdep.c */ | |
85 | extern struct pdc_cache pdc_cache; | 91 | extern struct pdc_cache pdc_cache; | |
86 | extern struct pdc_btlb pdc_btlb; | 92 | extern struct pdc_btlb pdc_btlb; | |
87 | extern struct pdc_model pdc_model; | 93 | extern struct pdc_model pdc_model; | |
88 | extern u_int cpu_ticksnum, cpu_ticksdenom; | 94 | extern u_int cpu_ticksnum, cpu_ticksdenom; | |
89 | 95 | |||
90 | struct cpu_softc *sc = device_private(self); | 96 | struct cpu_softc *sc = device_private(self); | |
91 | struct confargs *ca = aux; | 97 | struct confargs *ca = aux; | |
92 | const char lvls[4][4] = { "0", "1", "1.5", "2" }; | 98 | struct cpu_info *ci; | |
99 | static const char lvls[4][4] = { "0", "1", "1.5", "2" }; | |||
93 | u_int mhz = 100 * cpu_ticksnum / cpu_ticksdenom; | 100 | u_int mhz = 100 * cpu_ticksnum / cpu_ticksdenom; | |
101 | int cpuno = device_unit(self); | |||
102 | ||||
103 | #ifdef MULTIPROCESSOR | |||
104 | struct pglist mlist; | |||
105 | struct vm_page *m; | |||
106 | int error; | |||
107 | #endif | |||
94 | 108 | |||
95 | sc->sc_dev = self; | 109 | sc->sc_dev = self; | |
96 | cpu_attached = 1; | 110 | ||
111 | ci = &cpus[cpuno]; | |||
112 | ci->ci_cpuid = cpuno; | |||
113 | ci->ci_hpa = ca->ca_hpa; | |||
97 | 114 | |||
98 | /* Print the CPU chip name, nickname, and rev. */ | 115 | /* Print the CPU chip name, nickname, and rev. */ | |
99 | aprint_normal(": %s", hppa_cpu_info->hci_chip_name); | 116 | aprint_normal(": %s", hppa_cpu_info->hci_chip_name); | |
100 | if (hppa_cpu_info->hci_chip_nickname != NULL) | 117 | if (hppa_cpu_info->hci_chip_nickname != NULL) | |
101 | aprint_normal(" (%s)", hppa_cpu_info->hci_chip_nickname); | 118 | aprint_normal(" (%s)", hppa_cpu_info->hci_chip_nickname); | |
102 | aprint_normal(" rev %d", cpu_revision); | 119 | aprint_normal(" rev %d", cpu_revision); | |
103 | 120 | |||
104 | /* Print the CPU type, spec, level, category, and speed. */ | 121 | /* Print the CPU type, spec, level, category, and speed. */ | |
105 | aprint_normal("\n%s: %s, PA-RISC %s", self->dv_xname, | 122 | aprint_normal("\n%s: %s, PA-RISC %s", self->dv_xname, | |
106 | hppa_cpu_info->hci_chip_type, | 123 | hppa_cpu_info->hci_chip_type, | |
107 | hppa_cpu_info->hci_chip_spec); | 124 | hppa_cpu_info->hci_chip_spec); | |
108 | aprint_normal(", lev %s, cat %c, ", | 125 | aprint_normal(", lev %s, cat %c, ", | |
109 | lvls[pdc_model.pa_lvl], "AB"[pdc_model.mc]); | 126 | lvls[pdc_model.pa_lvl], "AB"[pdc_model.mc]); | |
@@ -141,30 +158,134 @@ cpuattach(device_t parent, device_t self | @@ -141,30 +158,134 @@ cpuattach(device_t parent, device_t self | |||
141 | aprint_normal("\n%s: no floating point support", | 158 | aprint_normal("\n%s: no floating point support", | |
142 | self->dv_xname); | 159 | self->dv_xname); | |
143 | else | 160 | else | |
144 | #endif /* !FPEMUL */ | 161 | #endif /* !FPEMUL */ | |
145 | { | 162 | { | |
146 | aprint_normal("\n%s: %s floating point, rev %d", self->dv_xname, | 163 | aprint_normal("\n%s: %s floating point, rev %d", self->dv_xname, | |
147 | hppa_mod_info(HPPA_TYPE_FPU, (fpu_version >> 16) & 0x1f), | 164 | hppa_mod_info(HPPA_TYPE_FPU, (fpu_version >> 16) & 0x1f), | |
148 | (fpu_version >> 11) & 0x1f); | 165 | (fpu_version >> 11) & 0x1f); | |
149 | } | 166 | } | |
150 | 167 | |||
151 | aprint_normal("\n"); | 168 | aprint_normal("\n"); | |
152 | 169 | |||
153 | /* sanity against luser amongst config editors */ | 170 | /* sanity against luser amongst config editors */ | |
154 | if (ca->ca_irq == 31) { | 171 | if (ca->ca_irq != 31) { | |
155 | sc->sc_ih = hp700_intr_establish(IPL_CLOCK, clock_intr, | |||
156 | NULL /*clockframe*/, &int_reg_cpu, ca->ca_irq); | |||
157 | } else { | |||
158 | aprint_error_dev(self, "bad irq number %d\n", ca->ca_irq); | 172 | aprint_error_dev(self, "bad irq number %d\n", ca->ca_irq); | |
173 | return; | |||
159 | } | 174 | } | |
175 | ||||
176 | sc->sc_ih = hp700_intr_establish(IPL_CLOCK, clock_intr, | |||
177 | NULL /*clockframe*/, &int_reg_cpu, 31); | |||
178 | ||||
179 | #ifdef MULTIPROCESSOR | |||
180 | ||||
181 | /* Allocate stack for spin up and FPU emulation. */ | |||
182 | TAILQ_INIT(&mlist); | |||
183 | error = uvm_pglistalloc(PAGE_SIZE, 0, -1L, PAGE_SIZE, 0, &mlist, 1, | |||
184 | 0); | |||
185 | ||||
186 | if (error) { | |||
187 | aprint_error(": unable to allocate CPU stack!\n"); | |||
188 | return; | |||
189 | } | |||
190 | m = TAILQ_FIRST(&mlist); | |||
191 | ci->ci_stack = VM_PAGE_TO_PHYS(m); | |||
192 | ||||
193 | if (ci->ci_hpa == hppa_mcpuhpa) { | |||
194 | ci->ci_flags |= CPUF_PRIMARY|CPUF_RUNNING; | |||
195 | } else { | |||
196 | int err; | |||
197 | ||||
198 | err = mi_cpu_attach(ci); | |||
199 | if (err) { | |||
200 | aprint_error_dev(self, | |||
201 | "mi_cpu_attach failed with %d\n", err); | |||
202 | return; | |||
203 | } | |||
204 | } | |||
205 | ||||
206 | #endif | |||
160 | 207 | |||
161 | /* | 208 | /* | |
162 | * Set the allocatable bits in the CPU interrupt registers. | 209 | * Set the allocatable bits in the CPU interrupt registers. | |
163 | * These should only be used by major chipsets, like ASP and | 210 | * These should only be used by major chipsets, like ASP and | |
164 | * LASI, and the bits used appear to be important - the | 211 | * LASI, and the bits used appear to be important - the | |
165 | * ASP doesn't seem to like to use interrupt bits above 28 | 212 | * ASP doesn't seem to like to use interrupt bits above 28 | |
166 | * or below 27. | 213 | * or below 27. | |
167 | */ | 214 | */ | |
168 | int_reg_cpu.int_reg_allocatable_bits = | 215 | int_reg_cpu.int_reg_allocatable_bits = | |
169 | (1 << 28) | (1 << 27) | (1 << 26); | 216 | (1 << 28) | (1 << 27) | (1 << 26); | |
170 | } | 217 | } | |
218 | ||||
219 | ||||
220 | #ifdef MULTIPROCESSOR | |||
221 | void | |||
222 | cpu_boot_secondary_processors(void) | |||
223 | { | |||
224 | struct cpu_info *ci; | |||
225 | struct iomod *cpu; | |||
226 | int i, j; | |||
227 | ||||
228 | for (i = 0; i < HPPA_MAXCPUS; i++) { | |||
229 | ||||
230 | ci = &cpus[i]; | |||
231 | if (ci->ci_cpuid == 0) | |||
232 | continue; | |||
233 | ||||
234 | if (ci->ci_data.cpu_idlelwp == NULL) | |||
235 | continue; | |||
236 | ||||
237 | if (ci->ci_flags & CPUF_PRIMARY) | |||
238 | continue; | |||
239 | ||||
240 | /* Release the specified CPU by triggering an EIR{0}. */ | |||
241 | cpu_hatch_info = ci; | |||
242 | cpu = (struct iomod *)(ci->ci_hpa); | |||
243 | cpu->io_eir = 0; | |||
244 | membar_sync(); | |||
245 | ||||
246 | /* Wait for CPU to wake up... */ | |||
247 | j = 0; | |||
248 | while (!(ci->ci_flags & CPUF_RUNNING) && j++ < 10000) | |||
249 | delay(1000); | |||
250 | if (!(ci->ci_flags & CPUF_RUNNING)) | |||
251 | printf("failed to hatch cpu %i!\n", ci->ci_cpuid); | |||
252 | } | |||
253 | ||||
254 | /* Release secondary CPUs. */ | |||
255 | start_secondary_cpu = 1; | |||
256 | membar_sync(); | |||
257 | } | |||
258 | ||||
259 | void | |||
260 | cpu_hw_init(void) | |||
261 | { | |||
262 | struct cpu_info *ci = curcpu(); | |||
263 | ||||
264 | /* Purge TLB and flush caches. */ | |||
265 | ptlball(); | |||
266 | fcacheall(); | |||
267 | ||||
268 | /* Enable address translations. */ | |||
269 | ci->ci_psw = PSW_I | PSW_Q | PSW_P | PSW_C | PSW_D; | |||
270 | ci->ci_psw |= (cpus[0].ci_psw & PSW_O); | |||
271 | ||||
272 | ci->ci_curlwp = ci->ci_data.cpu_idlelwp; | |||
273 | } | |||
274 | ||||
275 | void | |||
276 | cpu_hatch(void) | |||
277 | { | |||
278 | struct cpu_info *ci = curcpu(); | |||
279 | ||||
280 | ci->ci_flags |= CPUF_RUNNING; | |||
281 | ||||
282 | /* Wait for additional CPUs to spinup. */ | |||
283 | while (!start_secondary_cpu) | |||
284 | ; | |||
285 | ||||
286 | /* Spin for now */ | |||
287 | for (;;) | |||
288 | ; | |||
289 | ||||
290 | } | |||
291 | #endif |
--- src/sys/arch/hp700/hp700/Attic/genassym.cf 2011/01/23 09:44:58 1.30
+++ src/sys/arch/hp700/hp700/Attic/genassym.cf 2011/01/23 21:53:39 1.31
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | # $NetBSD: genassym.cf,v 1.30 2011/01/23 09:44:58 skrll Exp $ | 1 | # $NetBSD: genassym.cf,v 1.31 2011/01/23 21:53:39 skrll Exp $ | |
2 | 2 | |||
3 | # $OpenBSD: genassym.cf,v 1.18 2001/09/20 18:31:14 mickey Exp $ | 3 | # $OpenBSD: genassym.cf,v 1.18 2001/09/20 18:31:14 mickey Exp $ | |
4 | 4 | |||
5 | # | 5 | # | |
6 | # Copyright (c) 1982, 1990, 1993 | 6 | # Copyright (c) 1982, 1990, 1993 | |
7 | # The Regents of the University of California. All rights reserved. | 7 | # The Regents of the University of California. All rights reserved. | |
8 | # | 8 | # | |
9 | # Redistribution and use in source and binary forms, with or without | 9 | # Redistribution and use in source and binary forms, with or without | |
10 | # modification, are permitted provided that the following conditions | 10 | # modification, are permitted provided that the following conditions | |
11 | # are met: | 11 | # are met: | |
12 | # 1. Redistributions of source code must retain the above copyright | 12 | # 1. Redistributions of source code must retain the above copyright | |
13 | # notice, this list of conditions and the following disclaimer. | 13 | # notice, this list of conditions and the following disclaimer. | |
14 | # 2. Redistributions in binary form must reproduce the above copyright | 14 | # 2. Redistributions in binary form must reproduce the above copyright | |
@@ -91,29 +91,29 @@ member INT_REG_BITS_MAP int_reg_bits_map | @@ -91,29 +91,29 @@ member INT_REG_BITS_MAP int_reg_bits_map | |||
91 | export INT_REG_BIT_REG | 91 | export INT_REG_BIT_REG | |
92 | 92 | |||
93 | # struct cpu_info fields | 93 | # struct cpu_info fields | |
94 | define CI_CPL offsetof(struct cpu_info, ci_cpl) | 94 | define CI_CPL offsetof(struct cpu_info, ci_cpl) | |
95 | define CI_IPENDING offsetof(struct cpu_info, ci_ipending) | 95 | define CI_IPENDING offsetof(struct cpu_info, ci_ipending) | |
96 | #define CI_INTR_DEPTH offsetof(struct cpu_info, ci_intr_depth) | 96 | #define CI_INTR_DEPTH offsetof(struct cpu_info, ci_intr_depth) | |
97 | #define CI_SOFTLWPS offsetof(struct cpu_info, ci_softlwps) | 97 | #define CI_SOFTLWPS offsetof(struct cpu_info, ci_softlwps) | |
98 | define CI_MTX_COUNT offsetof(struct cpu_info, ci_mtx_count) | 98 | define CI_MTX_COUNT offsetof(struct cpu_info, ci_mtx_count) | |
99 | define CI_TRAPSAVE offsetof(struct cpu_info, ci_trapsave) | 99 | define CI_TRAPSAVE offsetof(struct cpu_info, ci_trapsave) | |
100 | define CI_PSW offsetof(struct cpu_info, ci_psw) | 100 | define CI_PSW offsetof(struct cpu_info, ci_psw) | |
101 | define CI_FPU_STATE offsetof(struct cpu_info, ci_fpu_state) | 101 | define CI_FPU_STATE offsetof(struct cpu_info, ci_fpu_state) | |
102 | ifdef MULTIPROCESSOR | 102 | ifdef MULTIPROCESSOR | |
103 | define CI_CURLWP offsetof(struct cpu_info, ci_curlwp) | 103 | define CI_CURLWP offsetof(struct cpu_info, ci_curlwp) | |
104 | define CI_STACK offsetof(struct cpu_info, ci_stack) | |||
104 | endif | 105 | endif | |
105 | 106 | |||
106 | ||||
107 | define MTX_IPL offsetof(struct kmutex, mtx_ipl) | 107 | define MTX_IPL offsetof(struct kmutex, mtx_ipl) | |
108 | define MTX_LOCK offsetof(struct kmutex, mtx_lock) | 108 | define MTX_LOCK offsetof(struct kmutex, mtx_lock) | |
109 | define MTX_OWNER offsetof(struct kmutex, mtx_owner) | 109 | define MTX_OWNER offsetof(struct kmutex, mtx_owner) | |
110 | define MTX_WAITERS offsetof(struct kmutex, mtx_waiters) | 110 | define MTX_WAITERS offsetof(struct kmutex, mtx_waiters) | |
111 | 111 | |||
112 | define RW_OWNER offsetof(struct krwlock, rw_owner) | 112 | define RW_OWNER offsetof(struct krwlock, rw_owner) | |
113 | define RW_WRITE_LOCKED RW_WRITE_LOCKED | 113 | define RW_WRITE_LOCKED RW_WRITE_LOCKED | |
114 | define RW_WRITE_WANTED RW_WRITE_WANTED | 114 | define RW_WRITE_WANTED RW_WRITE_WANTED | |
115 | define RW_READ_INCR RW_READ_INCR | 115 | define RW_READ_INCR RW_READ_INCR | |
116 | define RW_HAS_WAITERS RW_HAS_WAITERS | 116 | define RW_HAS_WAITERS RW_HAS_WAITERS | |
117 | define RW_THREAD RW_THREAD | 117 | define RW_THREAD RW_THREAD | |
118 | define RW_READER RW_READER | 118 | define RW_READER RW_READER | |
119 | define RW_WRITER RW_WRITER | 119 | define RW_WRITER RW_WRITER |
--- src/sys/arch/hp700/hp700/Attic/locore.S 2011/01/23 09:44:58 1.52
+++ src/sys/arch/hp700/hp700/Attic/locore.S 2011/01/23 21:53:39 1.53
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: locore.S,v 1.52 2011/01/23 09:44:58 skrll Exp $ */ | 1 | /* $NetBSD: locore.S,v 1.53 2011/01/23 21:53:39 skrll Exp $ */ | |
2 | /* $OpenBSD: locore.S,v 1.158 2008/07/28 19:08:46 miod Exp $ */ | 2 | /* $OpenBSD: locore.S,v 1.158 2008/07/28 19:08:46 miod Exp $ */ | |
3 | 3 | |||
4 | /* | 4 | /* | |
5 | * Copyright (c) 1998-2004 Michael Shalayeff | 5 | * Copyright (c) 1998-2004 Michael Shalayeff | |
6 | * All rights reserved. | 6 | * All rights reserved. | |
7 | * | 7 | * | |
8 | * Redistribution and use in source and binary forms, with or without | 8 | * Redistribution and use in source and binary forms, with or without | |
9 | * modification, are permitted provided that the following conditions | 9 | * modification, are permitted provided that the following conditions | |
10 | * are met: | 10 | * are met: | |
11 | * 1. Redistributions of source code must retain the above copyright | 11 | * 1. Redistributions of source code must retain the above copyright | |
12 | * notice, this list of conditions and the following disclaimer. | 12 | * notice, this list of conditions and the following disclaimer. | |
13 | * 2. Redistributions in binary form must reproduce the above copyright | 13 | * 2. Redistributions in binary form must reproduce the above copyright | |
14 | * notice, this list of conditions and the following disclaimer in the | 14 | * notice, this list of conditions and the following disclaimer in the | |
@@ -248,26 +248,38 @@ L$start_zero_tf: | @@ -248,26 +248,38 @@ L$start_zero_tf: | |||
248 | stw %t3, R%lwp0+L_PCB(%t2) /* XXXuvm_lwp_getuarea */ | 248 | stw %t3, R%lwp0+L_PCB(%t2) /* XXXuvm_lwp_getuarea */ | |
249 | ldo NBPG(%t3), %t1 | 249 | ldo NBPG(%t3), %t1 | |
250 | stw %t1, R%lwp0+L_MD_REGS(%t2) | 250 | stw %t1, R%lwp0+L_MD_REGS(%t2) | |
251 | 251 | |||
252 | ldil L%TFF_LAST, %t1 | 252 | ldil L%TFF_LAST, %t1 | |
253 | stw %t1, TF_FLAGS-TRAPFRAME_SIZEOF(%sp) | 253 | stw %t1, TF_FLAGS-TRAPFRAME_SIZEOF(%sp) | |
254 | stw %t3, TF_CR30-TRAPFRAME_SIZEOF(%sp) | 254 | stw %t3, TF_CR30-TRAPFRAME_SIZEOF(%sp) | |
255 | 255 | |||
256 | /* | 256 | /* | |
257 | * disable all coprocessors | 257 | * disable all coprocessors | |
258 | */ | 258 | */ | |
259 | mtctl %r0, %ccr | 259 | mtctl %r0, %ccr | |
260 | 260 | |||
261 | #ifdef MULTIPROCESSOR | |||
262 | ||||
263 | #define PZ_MEM_RENDEZ 0x10 | |||
264 | #define PZ_MEM_RENDEZ_HI 0x28 | |||
265 | ||||
266 | /* Setup SMP rendezvous address. */ | |||
267 | ldil L%hw_cpu_spinup_trampoline, %r1 | |||
268 | ldo R%hw_cpu_spinup_trampoline(%r1), %r1 | |||
269 | stw %r1, PZ_MEM_RENDEZ(%r0) | |||
270 | stw %r0, PZ_MEM_RENDEZ_HI(%r0) | |||
271 | #endif | |||
272 | ||||
261 | /* | 273 | /* | |
262 | * We need to set the Q bit so that we can take TLB misses after we | 274 | * We need to set the Q bit so that we can take TLB misses after we | |
263 | * turn on virtual memory. | 275 | * turn on virtual memory. | |
264 | */ | 276 | */ | |
265 | copy %sp, %arg0 | 277 | copy %sp, %arg0 | |
266 | ldil L%qisnowon, %rp | 278 | ldil L%qisnowon, %rp | |
267 | ldo R%qisnowon(%rp), %rp | 279 | ldo R%qisnowon(%rp), %rp | |
268 | 280 | |||
269 | b kernel_setup | 281 | b kernel_setup | |
270 | ldi PSW_Q|PSW_I, %arg1 | 282 | ldi PSW_Q|PSW_I, %arg1 | |
271 | 283 | |||
272 | qisnowon: | 284 | qisnowon: | |
273 | copy %r4, %arg0 | 285 | copy %r4, %arg0 | |
@@ -401,26 +413,149 @@ LEAF_ENTRY_NOPROFILE(kernel_setup) | @@ -401,26 +413,149 @@ LEAF_ENTRY_NOPROFILE(kernel_setup) | |||
401 | */ | 413 | */ | |
402 | 414 | |||
403 | mtctl %r0, %pcsq | 415 | mtctl %r0, %pcsq | |
404 | mtctl %r0, %pcsq | 416 | mtctl %r0, %pcsq | |
405 | mtctl %rp, %pcoq | 417 | mtctl %rp, %pcoq | |
406 | ldo 4(%rp), %rp | 418 | ldo 4(%rp), %rp | |
407 | mtctl %rp, %pcoq | 419 | mtctl %rp, %pcoq | |
408 | mtctl %arg1, %ipsw | 420 | mtctl %arg1, %ipsw | |
409 | rfi | 421 | rfi | |
410 | nop | 422 | nop | |
411 | nop | 423 | nop | |
412 | EXIT(kernel_setup) | 424 | EXIT(kernel_setup) | |
413 | 425 | |||
426 | ||||
427 | #ifdef MULTIPROCESSOR | |||
428 | /* | |||
429 | * Trampoline to spin up secondary processors. | |||
430 | */ | |||
431 | LEAF_ENTRY_NOPROFILE(hw_cpu_spinup_trampoline) | |||
432 | ||||
433 | /* | |||
434 | * disable interrupts and turn off all bits in the psw so that | |||
435 | * we start in a known state. | |||
436 | */ | |||
437 | rsm RESET_PSW, %r0 | |||
438 | nop ! nop ! nop ! nop ! nop ! nop | |||
439 | ||||
440 | /* go to virtual mode... | |||
441 | /* get things ready for the kernel to run in virtual mode */ | |||
442 | ldi HPPA_PID_KERNEL, %r1 | |||
443 | mtctl %r1, %pidr1 | |||
444 | mtctl %r1, %pidr2 | |||
445 | #if pbably_not_worth_it | |||
446 | mtctl %r0, %pidr3 | |||
447 | mtctl %r0, %pidr4 | |||
448 | #endif | |||
449 | mtsp %r0, %sr0 | |||
450 | mtsp %r0, %sr1 | |||
451 | mtsp %r0, %sr2 | |||
452 | mtsp %r0, %sr3 | |||
453 | mtsp %r0, %sr4 | |||
454 | mtsp %r0, %sr5 | |||
455 | mtsp %r0, %sr6 | |||
456 | mtsp %r0, %sr7 | |||
457 | ||||
458 | /* | |||
459 | * disable all coprocessors | |||
460 | */ | |||
461 | mtctl %r0, %ccr | |||
462 | ||||
463 | /* | |||
464 | * to keep the spl() routines consistent we need to put the correct | |||
465 | * spl level into eiem, and reset any pending interrupts | |||
466 | */ | |||
467 | ldi -1, %r1 | |||
468 | mtctl %r0, %eiem /* disable interrupts */ | |||
469 | mtctl %r1, %eirr | |||
470 | ||||
471 | /* | |||
472 | * load address of interrupt vector table | |||
473 | */ | |||
474 | ldil L%ivaaddr, %t2 | |||
475 | ldo R%ivaaddr(%t2), %t2 | |||
476 | mtctl %t2, %iva | |||
477 | ||||
478 | /* | |||
479 | * set up the dp pointer so that we can do quick references off of it | |||
480 | */ | |||
481 | ldil L%$global$, %dp | |||
482 | ldo R%$global$(%dp), %dp | |||
483 | ||||
484 | /* | |||
485 | * Store address of cpu_info in CR_CURCPU. | |||
486 | */ | |||
487 | ldil L%cpu_hatch_info, %r3 | |||
488 | ldw R%cpu_hatch_info(%r3), %r3 | |||
489 | mtctl %r3, CR_CURCPU | |||
490 | ||||
491 | /* | |||
492 | * Setup the stack frame for us to call C with and mark this as the | |||
493 | * first frame on the stack. | |||
494 | */ | |||
495 | ldw CI_STACK(%r3), %sp | |||
496 | stw,ma %r0, HPPA_FRAME_SIZE(%sp) | |||
497 | stw %r0, HPPA_FRAME_CRP(%sp) | |||
498 | stw %r0, HPPA_FRAME_PSP(%sp) | |||
499 | ||||
500 | /* Provide CPU with page tables. */ | |||
501 | ldil L%hppa_vtop, %t1 | |||
502 | ldw R%hppa_vtop(%t1), %t1 | |||
503 | mtctl %t1, CR_VTOP | |||
504 | ||||
505 | /* Turn on the Q bit so that we can handle TLB traps. */ | |||
506 | ldil L%qenabled, %t1 | |||
507 | ldo R%qenabled(%t1), %t1 | |||
508 | mtctl %r0, %pcsq | |||
509 | mtctl %r0, %pcsq | |||
510 | mtctl %t1, %pcoq | |||
511 | ldo 4(%t1), %t1 | |||
512 | mtctl %t1, %pcoq | |||
513 | ldi PSW_Q|PSW_I, %t2 | |||
514 | mtctl %t2, %ipsw | |||
515 | rfi | |||
516 | nop | |||
517 | ||||
518 | qenabled: | |||
519 | /* Call C routine to setup CPU. */ | |||
520 | .import cpu_hw_init, code | |||
521 | CALL(cpu_hw_init, %r1) | |||
522 | ||||
523 | /* Switch CPU mode. */ | |||
524 | ldil L%cpu_spinup_vm, %t1 | |||
525 | ldo R%cpu_spinup_vm(%t1), %t1 | |||
526 | mtctl %r0, %pcsq | |||
527 | mtctl %r0, %pcsq | |||
528 | mtctl %t1, %pcoq | |||
529 | ldo 4(%t1), %t1 | |||
530 | mtctl %t1, %pcoq | |||
531 | mfctl CR_CURCPU, %t2 | |||
532 | ldw CI_PSW(%t2), %t2 | |||
533 | mtctl %t2, %ipsw | |||
534 | rfi | |||
535 | nop | |||
536 | ||||
537 | cpu_spinup_vm: | |||
538 | ||||
539 | /* | |||
540 | * Okay, time to return to the land of C. | |||
541 | */ | |||
542 | b cpu_hatch | |||
543 | nop | |||
544 | ||||
545 | EXIT(hw_cpu_spinup_trampoline) | |||
546 | #endif | |||
547 | ||||
548 | ||||
414 | /* | 549 | /* | |
415 | * int pdc_call(iodcio_t func,int pdc_flag, ...) | 550 | * int pdc_call(iodcio_t func,int pdc_flag, ...) | |
416 | */ | 551 | */ | |
417 | ENTRY(pdc_call,160) | 552 | ENTRY(pdc_call,160) | |
418 | 553 | |||
419 | mfctl %eiem, %t1 | 554 | mfctl %eiem, %t1 | |
420 | mtctl %r0, %eiem /* disable interrupts */ | 555 | mtctl %r0, %eiem /* disable interrupts */ | |
421 | stw %rp, HPPA_FRAME_CRP(%sp) | 556 | stw %rp, HPPA_FRAME_CRP(%sp) | |
422 | copy %arg0, %r31 | 557 | copy %arg0, %r31 | |
423 | copy %sp, %ret1 | 558 | copy %sp, %ret1 | |
424 | 559 | |||
425 | ldil L%kernelmapped, %ret0 | 560 | ldil L%kernelmapped, %ret0 | |
426 | ldw R%kernelmapped(%ret0), %ret0 | 561 | ldw R%kernelmapped(%ret0), %ret0 |
--- src/sys/arch/hp700/hp700/Attic/machdep.c 2011/01/23 09:44:58 1.97
+++ src/sys/arch/hp700/hp700/Attic/machdep.c 2011/01/23 21:53:40 1.98
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: machdep.c,v 1.97 2011/01/23 09:44:58 skrll Exp $ */ | 1 | /* $NetBSD: machdep.c,v 1.98 2011/01/23 21:53:40 skrll Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2001, 2002 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2001, 2002 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 Matthew Fredette. | 8 | * by Matthew Fredette. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -48,27 +48,27 @@ | @@ -48,27 +48,27 @@ | |||
48 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | 48 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |
49 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | 49 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | |
50 | * IN NO EVENT SHALL THE AUTHOR OR HIS RELATIVES BE LIABLE FOR ANY DIRECT, | 50 | * IN NO EVENT SHALL THE AUTHOR OR HIS RELATIVES BE LIABLE FOR ANY DIRECT, | |
51 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 51 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | |
52 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | 52 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |
53 | * SERVICES; LOSS OF MIND, USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 53 | * SERVICES; LOSS OF MIND, USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
54 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | 54 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | |
55 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | 55 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | |
56 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF | 56 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF | |
57 | * THE POSSIBILITY OF SUCH DAMAGE. | 57 | * THE POSSIBILITY OF SUCH DAMAGE. | |
58 | */ | 58 | */ | |
59 | 59 | |||
60 | #include <sys/cdefs.h> | 60 | #include <sys/cdefs.h> | |
61 | __KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.97 2011/01/23 09:44:58 skrll Exp $"); | 61 | __KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.98 2011/01/23 21:53:40 skrll Exp $"); | |
62 | 62 | |||
63 | #include "opt_cputype.h" | 63 | #include "opt_cputype.h" | |
64 | #include "opt_ddb.h" | 64 | #include "opt_ddb.h" | |
65 | #include "opt_kgdb.h" | 65 | #include "opt_kgdb.h" | |
66 | #include "opt_modular.h" | 66 | #include "opt_modular.h" | |
67 | #include "opt_useleds.h" | 67 | #include "opt_useleds.h" | |
68 | 68 | |||
69 | #include <sys/param.h> | 69 | #include <sys/param.h> | |
70 | #include <sys/systm.h> | 70 | #include <sys/systm.h> | |
71 | #include <sys/signalvar.h> | 71 | #include <sys/signalvar.h> | |
72 | #include <sys/kernel.h> | 72 | #include <sys/kernel.h> | |
73 | #include <sys/proc.h> | 73 | #include <sys/proc.h> | |
74 | #include <sys/buf.h> | 74 | #include <sys/buf.h> | |
@@ -127,26 +127,29 @@ __KERNEL_RCSID(0, "$NetBSD: machdep.c,v | @@ -127,26 +127,29 @@ __KERNEL_RCSID(0, "$NetBSD: machdep.c,v | |||
127 | 127 | |||
128 | #ifdef PMAPDEBUG | 128 | #ifdef PMAPDEBUG | |
129 | #include <hppa/hppa/hpt.h> | 129 | #include <hppa/hppa/hpt.h> | |
130 | #endif | 130 | #endif | |
131 | 131 | |||
132 | #include "ksyms.h" | 132 | #include "ksyms.h" | |
133 | #include "lcd.h" | 133 | #include "lcd.h" | |
134 | 134 | |||
135 | /* | 135 | /* | |
136 | * Different kinds of flags used throughout the kernel. | 136 | * Different kinds of flags used throughout the kernel. | |
137 | */ | 137 | */ | |
138 | void *msgbufaddr; | 138 | void *msgbufaddr; | |
139 | 139 | |||
140 | /* The primary (aka monarch) cpu HPA */ | |||
141 | hppa_hpa_t hppa_mcpuhpa; | |||
142 | ||||
140 | /* | 143 | /* | |
141 | * cache configuration, for most machines is the same | 144 | * cache configuration, for most machines is the same | |
142 | * numbers, so it makes sense to do defines w/ numbers depending | 145 | * numbers, so it makes sense to do defines w/ numbers depending | |
143 | * on configured CPU types in the kernel | 146 | * on configured CPU types in the kernel | |
144 | */ | 147 | */ | |
145 | int icache_stride, icache_line_mask; | 148 | int icache_stride, icache_line_mask; | |
146 | int dcache_stride, dcache_line_mask; | 149 | int dcache_stride, dcache_line_mask; | |
147 | 150 | |||
148 | /* | 151 | /* | |
149 | * things to not kill | 152 | * things to not kill | |
150 | */ | 153 | */ | |
151 | volatile u_int8_t *machine_ledaddr; | 154 | volatile u_int8_t *machine_ledaddr; | |
152 | int machine_ledword, machine_leds; | 155 | int machine_ledword, machine_leds; | |
@@ -444,28 +447,35 @@ hppa_init(paddr_t start, void *bi) | @@ -444,28 +447,35 @@ hppa_init(paddr_t start, void *bi) | |||
444 | ci->ci_psw = | 447 | ci->ci_psw = | |
445 | PSW_Q | /* Interrupt State Collection Enable */ | 448 | PSW_Q | /* Interrupt State Collection Enable */ | |
446 | PSW_P | /* Protection Identifier Validation Enable */ | 449 | PSW_P | /* Protection Identifier Validation Enable */ | |
447 | PSW_C | /* Instruction Address Translation Enable */ | 450 | PSW_C | /* Instruction Address Translation Enable */ | |
448 | PSW_D; /* Data Address Translation Enable */ | 451 | PSW_D; /* Data Address Translation Enable */ | |
449 | 452 | |||
450 | /* Copy bootinfo */ | 453 | /* Copy bootinfo */ | |
451 | if (bi != NULL) | 454 | if (bi != NULL) | |
452 | memcpy(&bootinfo, bi, sizeof(struct bootinfo)); | 455 | memcpy(&bootinfo, bi, sizeof(struct bootinfo)); | |
453 | 456 | |||
454 | pdc_init(); /* init PDC iface, so we can call em easy */ | 457 | pdc_init(); /* init PDC iface, so we can call em easy */ | |
455 | 458 | |||
456 | cpu_hzticks = (PAGE0->mem_10msec * 100) / hz; | 459 | cpu_hzticks = (PAGE0->mem_10msec * 100) / hz; | |
460 | ||||
457 | delay_init(); /* calculate CPU clock ratio */ | 461 | delay_init(); /* calculate CPU clock ratio */ | |
458 | 462 | |||
463 | /* fetch the monarch/"default" cpu hpa */ | |||
464 | ||||
465 | error = pdcproc_hpa_processor(&hppa_mcpuhpa); | |||
466 | if (error < 0) | |||
467 | panic("%s: PDC_HPA failed", __func__); | |||
468 | ||||
459 | /* cache parameters */ | 469 | /* cache parameters */ | |
460 | error = pdcproc_cache(&pdc_cache); | 470 | error = pdcproc_cache(&pdc_cache); | |
461 | if (error < 0) { | 471 | if (error < 0) { | |
462 | #ifdef DEBUG | 472 | #ifdef DEBUG | |
463 | printf("WARNING: PDC_CACHE error %d\n", error); | 473 | printf("WARNING: PDC_CACHE error %d\n", error); | |
464 | #endif | 474 | #endif | |
465 | } | 475 | } | |
466 | 476 | |||
467 | dcache_line_mask = pdc_cache.dc_conf.cc_line * 16 - 1; | 477 | dcache_line_mask = pdc_cache.dc_conf.cc_line * 16 - 1; | |
468 | dcache_stride = pdc_cache.dc_stride; | 478 | dcache_stride = pdc_cache.dc_stride; | |
469 | icache_line_mask = pdc_cache.ic_conf.cc_line * 16 - 1; | 479 | icache_line_mask = pdc_cache.ic_conf.cc_line * 16 - 1; | |
470 | icache_stride = pdc_cache.ic_stride; | 480 | icache_stride = pdc_cache.ic_stride; | |
471 | 481 |
--- src/sys/arch/hp700/hp700/Attic/mainbus.c 2011/01/13 21:15:15 1.76
+++ src/sys/arch/hp700/hp700/Attic/mainbus.c 2011/01/23 21:53:40 1.77
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: mainbus.c,v 1.76 2011/01/13 21:15:15 skrll Exp $ */ | 1 | /* $NetBSD: mainbus.c,v 1.77 2011/01/23 21:53:40 skrll Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2001, 2002 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2001, 2002 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 Matthew Fredette. | 8 | * by Matthew Fredette. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -48,27 +48,27 @@ | @@ -48,27 +48,27 @@ | |||
48 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | 48 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |
49 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | 49 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | |
50 | * IN NO EVENT SHALL THE AUTHOR OR HIS RELATIVES BE LIABLE FOR ANY DIRECT, | 50 | * IN NO EVENT SHALL THE AUTHOR OR HIS RELATIVES BE LIABLE FOR ANY DIRECT, | |
51 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 51 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | |
52 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | 52 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |
53 | * SERVICES; LOSS OF MIND, USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 53 | * SERVICES; LOSS OF MIND, USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
54 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | 54 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | |
55 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | 55 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | |
56 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF | 56 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF | |
57 | * THE POSSIBILITY OF SUCH DAMAGE. | 57 | * THE POSSIBILITY OF SUCH DAMAGE. | |
58 | */ | 58 | */ | |
59 | 59 | |||
60 | #include <sys/cdefs.h> | 60 | #include <sys/cdefs.h> | |
61 | __KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.76 2011/01/13 21:15:15 skrll Exp $"); | 61 | __KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.77 2011/01/23 21:53:40 skrll Exp $"); | |
62 | 62 | |||
63 | #include "locators.h" | 63 | #include "locators.h" | |
64 | #include "power.h" | 64 | #include "power.h" | |
65 | #include "lcd.h" | 65 | #include "lcd.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/reboot.h> | 70 | #include <sys/reboot.h> | |
71 | #include <sys/extent.h> | 71 | #include <sys/extent.h> | |
72 | #include <sys/mbuf.h> | 72 | #include <sys/mbuf.h> | |
73 | #include <sys/proc.h> | 73 | #include <sys/proc.h> | |
74 | 74 | |||
@@ -1349,61 +1349,55 @@ mb_cpu_mem_callback(device_t self, struc | @@ -1349,61 +1349,55 @@ mb_cpu_mem_callback(device_t self, struc | |||
1349 | if ((ca->ca_type.iodc_type != HPPA_TYPE_NPROC && | 1349 | if ((ca->ca_type.iodc_type != HPPA_TYPE_NPROC && | |
1350 | ca->ca_type.iodc_type != HPPA_TYPE_MEMORY)) | 1350 | ca->ca_type.iodc_type != HPPA_TYPE_MEMORY)) | |
1351 | return NULL; | 1351 | return NULL; | |
1352 | 1352 | |||
1353 | return config_found_sm_loc(self, "gedoens", NULL, ca, mbprint, mbsubmatch); | 1353 | return config_found_sm_loc(self, "gedoens", NULL, ca, mbprint, mbsubmatch); | |
1354 | } | 1354 | } | |
1355 | 1355 | |||
1356 | void | 1356 | void | |
1357 | mbattach(device_t parent, device_t self, void *aux) | 1357 | mbattach(device_t parent, device_t self, void *aux) | |
1358 | { | 1358 | { | |
1359 | struct mainbus_softc *sc = device_private(self); | 1359 | struct mainbus_softc *sc = device_private(self); | |
1360 | struct confargs nca; | 1360 | struct confargs nca; | |
1361 | bus_space_handle_t ioh; | 1361 | bus_space_handle_t ioh; | |
1362 | hppa_hpa_t prochpa; | |||
1363 | int err; | 1362 | int err; | |
1364 | 1363 | |||
1365 | sc->sc_dv = self; | 1364 | sc->sc_dv = self; | |
1366 | mb_attached = 1; | 1365 | mb_attached = 1; | |
1367 | 1366 | |||
1368 | /* fetch the "default" cpu hpa */ | |||
1369 | ||||
1370 | err = pdcproc_hpa_processor(&prochpa); | |||
1371 | if (err < 0) | |||
1372 | panic("mbattach: PDC_HPA failed"); | |||
1373 | ||||
1374 | /* | 1367 | /* | |
1375 | * Map all of Fixed Physical, Local Broadcast, and Global Broadcast | 1368 | * Map all of Fixed Physical, Local Broadcast, and Global Broadcast | |
1376 | * space. These spaces are adjacent and in that order and run to the | 1369 | * space. These spaces are adjacent and in that order and run to the | |
1377 | * end of the address space. | 1370 | * end of the address space. | |
1378 | */ | 1371 | */ | |
1379 | /* | 1372 | /* | |
1380 | * XXX fredette - this may be a copout, or it may be a great idea. I'm | 1373 | * XXX fredette - this may be a copout, or it may be a great idea. I'm | |
1381 | * not sure which yet. | 1374 | * not sure which yet. | |
1382 | */ | 1375 | */ | |
1383 | 1376 | |||
1384 | /* map all the way till the end of the memory */ | 1377 | /* map all the way till the end of the memory */ | |
1385 | if (bus_space_map(&hppa_bustag, prochpa, (~0LU - prochpa + 1), | 1378 | if (bus_space_map(&hppa_bustag, hppa_mcpuhpa, (~0LU - hppa_mcpuhpa + 1), | |
1386 | 0, &ioh)) | 1379 | 0, &ioh)) | |
1387 | panic("%s: cannot map mainbus IO space", __func__); | 1380 | panic("%s: cannot map mainbus IO space", __func__); | |
1388 | 1381 | |||
1389 | /* | 1382 | /* | |
1390 | * Local-Broadcast the HPA to all modules on the bus | 1383 | * Local-Broadcast the HPA to all modules on the bus | |
1391 | */ | 1384 | */ | |
1392 | ((struct iomod *)(prochpa & HPPA_FLEX_MASK))[FPA_IOMOD].io_flex = | 1385 | ((struct iomod *)(hppa_mcpuhpa & HPPA_FLEX_MASK))[FPA_IOMOD].io_flex = | |
1393 | (void *)((prochpa & HPPA_FLEX_MASK) | DMA_ENABLE); | 1386 | (void *)((hppa_mcpuhpa & HPPA_FLEX_MASK) | DMA_ENABLE); | |
1387 | ||||
1388 | sc->sc_hpa = hppa_mcpuhpa; | |||
1394 | 1389 | |||
1395 | sc->sc_hpa = prochpa; | 1390 | aprint_normal(" [flex %lx]\n", hppa_mcpuhpa & HPPA_FLEX_MASK); | |
1396 | aprint_normal(" [flex %lx]\n", prochpa & HPPA_FLEX_MASK); | |||
1397 | 1391 | |||
1398 | /* PDC first */ | 1392 | /* PDC first */ | |
1399 | memset(&nca, 0, sizeof(nca)); | 1393 | memset(&nca, 0, sizeof(nca)); | |
1400 | nca.ca_name = "pdc"; | 1394 | nca.ca_name = "pdc"; | |
1401 | nca.ca_hpa = 0; | 1395 | nca.ca_hpa = 0; | |
1402 | nca.ca_iot = &hppa_bustag; | 1396 | nca.ca_iot = &hppa_bustag; | |
1403 | nca.ca_dmatag = &hppa_dmatag; | 1397 | nca.ca_dmatag = &hppa_dmatag; | |
1404 | config_found(self, &nca, mbprint); | 1398 | config_found(self, &nca, mbprint); | |
1405 | 1399 | |||
1406 | #if NPOWER > 0 | 1400 | #if NPOWER > 0 | |
1407 | /* get some power */ | 1401 | /* get some power */ | |
1408 | memset(&nca, 0, sizeof(nca)); | 1402 | memset(&nca, 0, sizeof(nca)); | |
1409 | nca.ca_name = "power"; | 1403 | nca.ca_name = "power"; |
--- src/sys/arch/hp700/include/Attic/cpu.h 2011/01/23 09:44:58 1.59
+++ src/sys/arch/hp700/include/Attic/cpu.h 2011/01/23 21:53:40 1.60
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: cpu.h,v 1.59 2011/01/23 09:44:58 skrll Exp $ */ | 1 | /* $NetBSD: cpu.h,v 1.60 2011/01/23 21:53:40 skrll Exp $ */ | |
2 | 2 | |||
3 | /* $OpenBSD: cpu.h,v 1.55 2008/07/23 17:39:35 kettenis Exp $ */ | 3 | /* $OpenBSD: cpu.h,v 1.55 2008/07/23 17:39:35 kettenis Exp $ */ | |
4 | 4 | |||
5 | /* | 5 | /* | |
6 | * Copyright (c) 2000-2004 Michael Shalayeff | 6 | * Copyright (c) 2000-2004 Michael Shalayeff | |
7 | * All rights reserved. | 7 | * All rights reserved. | |
8 | * | 8 | * | |
9 | * Redistribution and use in source and binary forms, with or without | 9 | * Redistribution and use in source and binary forms, with or without | |
10 | * modification, are permitted provided that the following conditions | 10 | * modification, are permitted provided that the following conditions | |
11 | * are met: | 11 | * are met: | |
12 | * 1. Redistributions of source code must retain the above copyright | 12 | * 1. Redistributions of source code must retain the above copyright | |
13 | * notice, this list of conditions and the following disclaimer. | 13 | * notice, this list of conditions and the following disclaimer. | |
14 | * 2. Redistributions in binary form must reproduce the above copyright | 14 | * 2. Redistributions in binary form must reproduce the above copyright | |
@@ -243,41 +243,49 @@ int clock_intr(void *); | @@ -243,41 +243,49 @@ int clock_intr(void *); | |||
243 | #include <sys/cpu_data.h> | 243 | #include <sys/cpu_data.h> | |
244 | 244 | |||
245 | /* | 245 | /* | |
246 | * Note that the alignment of ci_trap_save is important since we want to keep | 246 | * Note that the alignment of ci_trap_save is important since we want to keep | |
247 | * it within a single cache line. As a result, it must be kept as the first | 247 | * it within a single cache line. As a result, it must be kept as the first | |
248 | * entry within the cpu_info struct. | 248 | * entry within the cpu_info struct. | |
249 | */ | 249 | */ | |
250 | struct cpu_info { | 250 | struct cpu_info { | |
251 | register_t ci_trapsave[16];/* the "phys" part of frame */ | 251 | register_t ci_trapsave[16];/* the "phys" part of frame */ | |
252 | 252 | |||
253 | struct cpu_data ci_data; /* MI per-cpu data */ | 253 | struct cpu_data ci_data; /* MI per-cpu data */ | |
254 | 254 | |||
255 | #ifndef _KMEMUSER | 255 | #ifndef _KMEMUSER | |
256 | #ifdef MULTIPROCESSOR | |||
257 | struct lwp *ci_curlwp; /* CPU owner */ | |||
258 | #endif | |||
259 | int ci_cpuid; /* CPU index (see cpus[] array) */ | 256 | int ci_cpuid; /* CPU index (see cpus[] array) */ | |
260 | int ci_mtx_count; | 257 | int ci_mtx_count; | |
261 | int ci_mtx_oldspl; | 258 | int ci_mtx_oldspl; | |
262 | int ci_want_resched; | 259 | int ci_want_resched; | |
263 | 260 | |||
264 | volatile int ci_cpl; | 261 | volatile int ci_cpl; | |
265 | volatile int ci_ipending; /* The pending interrupts. */ | 262 | volatile int ci_ipending; /* The pending interrupts. */ | |
266 | u_int ci_intr_depth; /* Nonzero iff running an interrupt. */ | 263 | u_int ci_intr_depth; /* Nonzero iff running an interrupt. */ | |
267 | 264 | |||
265 | hppa_hpa_t ci_hpa; | |||
268 | register_t ci_psw; /* Processor Status Word. */ | 266 | register_t ci_psw; /* Processor Status Word. */ | |
269 | paddr_t ci_fpu_state; /* LWP FPU state address, or zero. */ | 267 | paddr_t ci_fpu_state; /* LWP FPU state address, or zero. */ | |
270 | u_long ci_itmr; | 268 | u_long ci_itmr; | |
269 | ||||
270 | #if defined(MULTIPROCESSOR) | |||
271 | struct lwp *ci_curlwp; /* CPU owner */ | |||
272 | paddr_t ci_stack; /* stack for spin up */ | |||
273 | volatile int ci_flags; /* CPU status flags */ | |||
274 | #define CPUF_PRIMARY 0x0001 /* ... is monarch/primary */ | |||
275 | #define CPUF_RUNNING 0x0002 /* ... is running. */ | |||
276 | ||||
277 | #endif | |||
278 | ||||
271 | #endif /* !_KMEMUSER */ | 279 | #endif /* !_KMEMUSER */ | |
272 | } __aligned(64); | 280 | } __aligned(64); | |
273 | 281 | |||
274 | #endif /* _KERNEL || _KMEMUSER */ | 282 | #endif /* _KERNEL || _KMEMUSER */ | |
275 | 283 | |||
276 | #if defined(_KERNEL) | 284 | #if defined(_KERNEL) | |
277 | 285 | |||
278 | /* | 286 | /* | |
279 | * definitions of cpu-dependent requirements | 287 | * definitions of cpu-dependent requirements | |
280 | * referenced in generic code | 288 | * referenced in generic code | |
281 | */ | 289 | */ | |
282 | 290 | |||
283 | #define cpu_proc_fork(p1, p2) | 291 | #define cpu_proc_fork(p1, p2) | |
@@ -359,26 +367,32 @@ hppa_cpu_hastlbu_p(void) | @@ -359,26 +367,32 @@ hppa_cpu_hastlbu_p(void) | |||
359 | 367 | |||
360 | void delay(u_int); | 368 | void delay(u_int); | |
361 | void hppa_init(paddr_t, void *); | 369 | void hppa_init(paddr_t, void *); | |
362 | void trap(int, struct trapframe *); | 370 | void trap(int, struct trapframe *); | |
363 | void hppa_ras(struct lwp *); | 371 | void hppa_ras(struct lwp *); | |
364 | int spcopy(pa_space_t, const void *, pa_space_t, void *, size_t); | 372 | int spcopy(pa_space_t, const void *, pa_space_t, void *, size_t); | |
365 | int spstrcpy(pa_space_t, const void *, pa_space_t, void *, size_t, | 373 | int spstrcpy(pa_space_t, const void *, pa_space_t, void *, size_t, | |
366 | size_t *); | 374 | size_t *); | |
367 | int copy_on_fault(void); | 375 | int copy_on_fault(void); | |
368 | void lwp_trampoline(void); | 376 | void lwp_trampoline(void); | |
369 | void setfunc_trampoline(void); | 377 | void setfunc_trampoline(void); | |
370 | int cpu_dumpsize(void); | 378 | int cpu_dumpsize(void); | |
371 | int cpu_dump(void); | 379 | int cpu_dump(void); | |
380 | ||||
381 | #ifdef MULTIPROCESSOR | |||
382 | void cpu_boot_secondary_processors(void); | |||
383 | void cpu_hw_init(void); | |||
384 | void cpu_hatch(void); | |||
385 | #endif | |||
372 | #endif /* _KERNEL */ | 386 | #endif /* _KERNEL */ | |
373 | 387 | |||
374 | /* | 388 | /* | |
375 | * Boot arguments stuff | 389 | * Boot arguments stuff | |
376 | */ | 390 | */ | |
377 | 391 | |||
378 | #define BOOTARG_LEN (PAGE_SIZE) | 392 | #define BOOTARG_LEN (PAGE_SIZE) | |
379 | #define BOOTARG_OFF (0x10000) | 393 | #define BOOTARG_OFF (0x10000) | |
380 | 394 | |||
381 | /* | 395 | /* | |
382 | * CTL_MACHDEP definitions. | 396 | * CTL_MACHDEP definitions. | |
383 | */ | 397 | */ | |
384 | #define CPU_CONSDEV 1 /* dev_t: console terminal device */ | 398 | #define CPU_CONSDEV 1 /* dev_t: console terminal device */ |
--- src/sys/arch/hppa/hppa/machdep.h 2011/01/23 09:44:59 1.14
+++ src/sys/arch/hppa/hppa/machdep.h 2011/01/23 21:53:40 1.15
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: machdep.h,v 1.14 2011/01/23 09:44:59 skrll Exp $ */ | 1 | /* $NetBSD: machdep.h,v 1.15 2011/01/23 21:53:40 skrll Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 2002 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2002 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 Matthew Fredette. | 8 | * by Matthew Fredette. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -34,26 +34,29 @@ | @@ -34,26 +34,29 @@ | |||
34 | * to the machine-dependent code. Anything needed by | 34 | * to the machine-dependent code. Anything needed by | |
35 | * machine-independent code is covered in cpu.h or in | 35 | * machine-independent code is covered in cpu.h or in | |
36 | * other headers. | 36 | * other headers. | |
37 | */ | 37 | */ | |
38 | 38 | |||
39 | /* | 39 | /* | |
40 | * XXX there is a lot of stuff in various headers under | 40 | * XXX there is a lot of stuff in various headers under | |
41 | * hp700/include and hppa/include, and a lot of one-off | 41 | * hp700/include and hppa/include, and a lot of one-off | |
42 | * `extern's in C files that could probably be moved here. | 42 | * `extern's in C files that could probably be moved here. | |
43 | */ | 43 | */ | |
44 | 44 | |||
45 | #ifdef _KERNEL | 45 | #ifdef _KERNEL | |
46 | 46 | |||
47 | /* The primary (aka monarch) CPU HPA */ | |||
48 | extern hppa_hpa_t hppa_mcpuhpa; | |||
49 | ||||
47 | /* | 50 | /* | |
48 | * cache configuration, for most machines is the same | 51 | * cache configuration, for most machines is the same | |
49 | * numbers, so it makes sense to do defines w/ numbers depending | 52 | * numbers, so it makes sense to do defines w/ numbers depending | |
50 | * on configured CPU types in the kernel. | 53 | * on configured CPU types in the kernel. | |
51 | */ | 54 | */ | |
52 | extern int icache_stride, icache_line_mask; | 55 | extern int icache_stride, icache_line_mask; | |
53 | extern int dcache_stride, dcache_line_mask; | 56 | extern int dcache_stride, dcache_line_mask; | |
54 | 57 | |||
55 | extern vaddr_t vmmap; /* XXX - See mem.c */ | 58 | extern vaddr_t vmmap; /* XXX - See mem.c */ | |
56 | 59 | |||
57 | /* Kernel virtual address space available: */ | 60 | /* Kernel virtual address space available: */ | |
58 | extern vaddr_t virtual_start, virtual_end; | 61 | extern vaddr_t virtual_start, virtual_end; | |
59 | 62 |