| @@ -1,325 +1,331 @@ | | | @@ -1,325 +1,331 @@ |
1 | /* $NetBSD: ibm4xx_machdep.c,v 1.31 2020/07/06 10:34:23 rin Exp $ */ | | 1 | /* $NetBSD: ibm4xx_machdep.c,v 1.32 2020/07/06 13:10:19 rin Exp $ */ |
2 | /* Original: ibm40x_machdep.c,v 1.3 2005/01/17 17:19:36 shige Exp $ */ | | 2 | /* Original: ibm40x_machdep.c,v 1.3 2005/01/17 17:19:36 shige Exp $ */ |
3 | | | 3 | |
4 | /* | | 4 | /* |
5 | * Copyright 2001, 2002 Wasabi Systems, Inc. | | 5 | * Copyright 2001, 2002 Wasabi Systems, Inc. |
6 | * All rights reserved. | | 6 | * All rights reserved. |
7 | * | | 7 | * |
8 | * Written by Eduardo Horvath and Simon Burge for Wasabi Systems, Inc. | | 8 | * Written by Eduardo Horvath and Simon Burge for Wasabi Systems, Inc. |
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. |
15 | * 2. Redistributions in binary form must reproduce the above copyright | | 15 | * 2. Redistributions in binary form must reproduce the above copyright |
16 | * notice, this list of conditions and the following disclaimer in the | | 16 | * notice, this list of conditions and the following disclaimer in the |
17 | * documentation and/or other materials provided with the distribution. | | 17 | * documentation and/or other materials provided with the distribution. |
18 | * 3. All advertising materials mentioning features or use of this software | | 18 | * 3. All advertising materials mentioning features or use of this software |
19 | * must display the following acknowledgement: | | 19 | * must display the following acknowledgement: |
20 | * This product includes software developed for the NetBSD Project by | | 20 | * This product includes software developed for the NetBSD Project by |
21 | * Wasabi Systems, Inc. | | 21 | * Wasabi Systems, Inc. |
22 | * 4. The name of Wasabi Systems, Inc. may not be used to endorse | | 22 | * 4. The name of Wasabi Systems, Inc. may not be used to endorse |
23 | * or promote products derived from this software without specific prior | | 23 | * or promote products derived from this software without specific prior |
24 | * written permission. | | 24 | * written permission. |
25 | * | | 25 | * |
26 | * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND | | 26 | * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND |
27 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | | 27 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED |
28 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | | 28 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
29 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC | | 29 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC |
30 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | | 30 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
31 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | | 31 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
32 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | | 32 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
33 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | | 33 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
34 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | | 34 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
35 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | | 35 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
36 | * POSSIBILITY OF SUCH DAMAGE. | | 36 | * POSSIBILITY OF SUCH DAMAGE. |
37 | */ | | 37 | */ |
38 | | | 38 | |
39 | /* | | 39 | /* |
40 | * Copyright (C) 1995, 1996 Wolfgang Solfrank. | | 40 | * Copyright (C) 1995, 1996 Wolfgang Solfrank. |
41 | * Copyright (C) 1995, 1996 TooLs GmbH. | | 41 | * Copyright (C) 1995, 1996 TooLs GmbH. |
42 | * All rights reserved. | | 42 | * All rights reserved. |
43 | * | | 43 | * |
44 | * Redistribution and use in source and binary forms, with or without | | 44 | * Redistribution and use in source and binary forms, with or without |
45 | * modification, are permitted provided that the following conditions | | 45 | * modification, are permitted provided that the following conditions |
46 | * are met: | | 46 | * are met: |
47 | * 1. Redistributions of source code must retain the above copyright | | 47 | * 1. Redistributions of source code must retain the above copyright |
48 | * notice, this list of conditions and the following disclaimer. | | 48 | * notice, this list of conditions and the following disclaimer. |
49 | * 2. Redistributions in binary form must reproduce the above copyright | | 49 | * 2. Redistributions in binary form must reproduce the above copyright |
50 | * notice, this list of conditions and the following disclaimer in the | | 50 | * notice, this list of conditions and the following disclaimer in the |
51 | * documentation and/or other materials provided with the distribution. | | 51 | * documentation and/or other materials provided with the distribution. |
52 | * 3. All advertising materials mentioning features or use of this software | | 52 | * 3. All advertising materials mentioning features or use of this software |
53 | * must display the following acknowledgement: | | 53 | * must display the following acknowledgement: |
54 | * This product includes software developed by TooLs GmbH. | | 54 | * This product includes software developed by TooLs GmbH. |
55 | * 4. The name of TooLs GmbH may not be used to endorse or promote products | | 55 | * 4. The name of TooLs GmbH may not be used to endorse or promote products |
56 | * derived from this software without specific prior written permission. | | 56 | * derived from this software without specific prior written permission. |
57 | * | | 57 | * |
58 | * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR | | 58 | * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR |
59 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | | 59 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
60 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | | 60 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
61 | * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | | 61 | * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
62 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | | 62 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
63 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; | | 63 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; |
64 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, | | 64 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
65 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR | | 65 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR |
66 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF | | 66 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
67 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | | 67 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
68 | */ | | 68 | */ |
69 | | | 69 | |
70 | #include <sys/cdefs.h> | | 70 | #include <sys/cdefs.h> |
71 | __KERNEL_RCSID(0, "$NetBSD: ibm4xx_machdep.c,v 1.31 2020/07/06 10:34:23 rin Exp $"); | | 71 | __KERNEL_RCSID(0, "$NetBSD: ibm4xx_machdep.c,v 1.32 2020/07/06 13:10:19 rin Exp $"); |
72 | | | 72 | |
73 | #include "ksyms.h" | | 73 | #include "ksyms.h" |
74 | | | 74 | |
75 | #ifdef _KERNEL_OPT | | 75 | #ifdef _KERNEL_OPT |
76 | #include "opt_ddb.h" | | 76 | #include "opt_ddb.h" |
77 | #include "opt_kgdb.h" | | 77 | #include "opt_kgdb.h" |
78 | #include "opt_modular.h" | | 78 | #include "opt_modular.h" |
79 | #endif | | 79 | #endif |
80 | | | 80 | |
81 | #include <sys/param.h> | | 81 | #include <sys/param.h> |
82 | #include <sys/msgbuf.h> | | 82 | #include <sys/msgbuf.h> |
83 | #include <sys/proc.h> | | 83 | #include <sys/proc.h> |
84 | #include <sys/cpu.h> | | 84 | #include <sys/cpu.h> |
85 | #include <sys/ksyms.h> | | 85 | #include <sys/ksyms.h> |
86 | | | 86 | |
87 | #include <uvm/uvm_extern.h> | | 87 | #include <uvm/uvm_extern.h> |
88 | | | 88 | |
89 | #if defined(DDB) | | 89 | #if defined(DDB) |
90 | #include <machine/db_machdep.h> | | 90 | #include <machine/db_machdep.h> |
91 | #include <ddb/db_extern.h> | | 91 | #include <ddb/db_extern.h> |
92 | #endif | | 92 | #endif |
93 | | | 93 | |
94 | #if defined(KGDB) | | 94 | #if defined(KGDB) |
95 | #include <sys/kgdb.h> | | 95 | #include <sys/kgdb.h> |
96 | #endif | | 96 | #endif |
97 | | | 97 | |
98 | #include <machine/powerpc.h> | | 98 | #include <machine/powerpc.h> |
99 | #include <powerpc/pcb.h> | | 99 | #include <powerpc/pcb.h> |
100 | #include <machine/trap.h> | | 100 | #include <machine/trap.h> |
101 | | | 101 | |
102 | #include <powerpc/spr.h> | | 102 | #include <powerpc/spr.h> |
103 | #include <powerpc/ibm4xx/spr.h> | | 103 | #include <powerpc/ibm4xx/spr.h> |
104 | | | 104 | |
105 | #include <powerpc/ibm4xx/cpu.h> | | 105 | #include <powerpc/ibm4xx/cpu.h> |
106 | | | 106 | |
107 | /* | | 107 | /* |
108 | * Global variables used here and there | | 108 | * Global variables used here and there |
109 | */ | | 109 | */ |
110 | paddr_t msgbuf_paddr; | | 110 | paddr_t msgbuf_paddr; |
111 | vaddr_t msgbuf_vaddr; | | 111 | vaddr_t msgbuf_vaddr; |
112 | char msgbuf[MSGBUFSIZE]; | | 112 | char msgbuf[MSGBUFSIZE]; |
113 | | | 113 | |
114 | #if NKSYMS || defined(DDB) || defined(MODULAR) | | 114 | #if NKSYMS || defined(DDB) || defined(MODULAR) |
115 | void *startsym, *endsym; | | 115 | void *startsym, *endsym; |
116 | #endif | | 116 | #endif |
117 | | | 117 | |
| | | 118 | #ifdef MODULAR |
| | | 119 | register_t cpu_psluserset = PSL_USERSET; |
| | | 120 | register_t cpu_pslusermod = PSL_USERMOD; |
| | | 121 | register_t cpu_pslusermask = PSL_USERMASK; |
| | | 122 | #endif |
| | | 123 | |
118 | /* | | 124 | /* |
119 | * Trap vectors | | 125 | * Trap vectors |
120 | */ | | 126 | */ |
121 | extern const uint32_t defaulttrap[], defaultsize; | | 127 | extern const uint32_t defaulttrap[], defaultsize; |
122 | extern const uint32_t sctrap[], scsize; | | 128 | extern const uint32_t sctrap[], scsize; |
123 | extern const uint32_t accesstrap[], accesssize; | | 129 | extern const uint32_t accesstrap[], accesssize; |
124 | extern const uint32_t criticaltrap[], criticalsize; | | 130 | extern const uint32_t criticaltrap[], criticalsize; |
125 | extern const uint32_t tlbimiss4xx[], tlbim4size; | | 131 | extern const uint32_t tlbimiss4xx[], tlbim4size; |
126 | extern const uint32_t tlbdmiss4xx[], tlbdm4size; | | 132 | extern const uint32_t tlbdmiss4xx[], tlbdm4size; |
127 | extern const uint32_t pitfitwdog[], pitfitwdogsize; | | 133 | extern const uint32_t pitfitwdog[], pitfitwdogsize; |
128 | extern const uint32_t errata51handler[], errata51size; | | 134 | extern const uint32_t errata51handler[], errata51size; |
129 | #if defined(DDB) | | 135 | #if defined(DDB) |
130 | extern const uint32_t ddblow[], ddbsize; | | 136 | extern const uint32_t ddblow[], ddbsize; |
131 | #endif | | 137 | #endif |
132 | static const struct exc_info trap_table[] = { | | 138 | static const struct exc_info trap_table[] = { |
133 | { EXC_SC, sctrap, (uintptr_t)&scsize }, | | 139 | { EXC_SC, sctrap, (uintptr_t)&scsize }, |
134 | { EXC_ALI, accesstrap, (uintptr_t)&accesssize }, | | 140 | { EXC_ALI, accesstrap, (uintptr_t)&accesssize }, |
135 | { EXC_DSI, accesstrap, (uintptr_t)&accesssize }, | | 141 | { EXC_DSI, accesstrap, (uintptr_t)&accesssize }, |
136 | { EXC_MCHK, criticaltrap, (uintptr_t)&criticalsize }, | | 142 | { EXC_MCHK, criticaltrap, (uintptr_t)&criticalsize }, |
137 | { EXC_ITMISS, tlbimiss4xx, (uintptr_t)&tlbim4size }, | | 143 | { EXC_ITMISS, tlbimiss4xx, (uintptr_t)&tlbim4size }, |
138 | { EXC_DTMISS, tlbdmiss4xx, (uintptr_t)&tlbdm4size }, | | 144 | { EXC_DTMISS, tlbdmiss4xx, (uintptr_t)&tlbdm4size }, |
139 | { EXC_PIT, pitfitwdog, (uintptr_t)&pitfitwdogsize }, | | 145 | { EXC_PIT, pitfitwdog, (uintptr_t)&pitfitwdogsize }, |
140 | { EXC_DEBUG, criticaltrap, (uintptr_t)&criticalsize }, | | 146 | { EXC_DEBUG, criticaltrap, (uintptr_t)&criticalsize }, |
141 | { (EXC_DTMISS|EXC_ALI), | | 147 | { (EXC_DTMISS|EXC_ALI), |
142 | errata51handler, (uintptr_t)&errata51size }, | | 148 | errata51handler, (uintptr_t)&errata51size }, |
143 | #if defined(DDB) | | 149 | #if defined(DDB) |
144 | { EXC_PGM, ddblow, (uintptr_t)&ddbsize }, | | 150 | { EXC_PGM, ddblow, (uintptr_t)&ddbsize }, |
145 | #endif | | 151 | #endif |
146 | }; | | 152 | }; |
147 | | | 153 | |
148 | /* | | 154 | /* |
149 | * Install a trap vector. We cannot use memcpy because the | | 155 | * Install a trap vector. We cannot use memcpy because the |
150 | * destination may be zero. | | 156 | * destination may be zero. |
151 | */ | | 157 | */ |
152 | static void | | 158 | static void |
153 | trap_copy(const uint32_t *src, vaddr_t dest, size_t len) | | 159 | trap_copy(const uint32_t *src, vaddr_t dest, size_t len) |
154 | { | | 160 | { |
155 | uint32_t *dest_p = (void *)dest; | | 161 | uint32_t *dest_p = (void *)dest; |
156 | | | 162 | |
157 | while (len > 0) { | | 163 | while (len > 0) { |
158 | *dest_p++ = *src++; | | 164 | *dest_p++ = *src++; |
159 | len -= sizeof(uint32_t); | | 165 | len -= sizeof(uint32_t); |
160 | } | | 166 | } |
161 | } | | 167 | } |
162 | | | 168 | |
163 | /* | | 169 | /* |
164 | * ibm4xx_init: | | 170 | * ibm4xx_init: |
165 | */ | | 171 | */ |
166 | void | | 172 | void |
167 | ibm4xx_init(vaddr_t startkernel, vaddr_t endkernel, void (*handler)(void)) | | 173 | ibm4xx_init(vaddr_t startkernel, vaddr_t endkernel, void (*handler)(void)) |
168 | { | | 174 | { |
169 | /* Initialize cache info for memcpy, etc. */ | | 175 | /* Initialize cache info for memcpy, etc. */ |
170 | cpu_probe_cache(); | | 176 | cpu_probe_cache(); |
171 | | | 177 | |
172 | /* | | 178 | /* |
173 | * Initialize current pcb and pmap pointers. | | 179 | * Initialize current pcb and pmap pointers. |
174 | */ | | 180 | */ |
175 | KASSERT(curcpu() == &cpu_info[0]); | | 181 | KASSERT(curcpu() == &cpu_info[0]); |
176 | KASSERT(lwp0.l_cpu == curcpu()); | | 182 | KASSERT(lwp0.l_cpu == curcpu()); |
177 | KASSERT(curlwp == &lwp0); | | 183 | KASSERT(curlwp == &lwp0); |
178 | | | 184 | |
179 | curpcb = lwp_getpcb(curlwp); | | 185 | curpcb = lwp_getpcb(curlwp); |
180 | memset(curpcb, 0, sizeof(struct pcb)); | | 186 | memset(curpcb, 0, sizeof(struct pcb)); |
181 | | | 187 | |
182 | curpcb->pcb_pm = pmap_kernel(); | | 188 | curpcb->pcb_pm = pmap_kernel(); |
183 | | | 189 | |
184 | for (uintptr_t exc = EXC_RSVD; exc <= EXC_LAST; exc += 0x100) { | | 190 | for (uintptr_t exc = EXC_RSVD; exc <= EXC_LAST; exc += 0x100) { |
185 | trap_copy(defaulttrap, exc, (uintptr_t)&defaultsize); | | 191 | trap_copy(defaulttrap, exc, (uintptr_t)&defaultsize); |
186 | } | | 192 | } |
187 | | | 193 | |
188 | for (size_t i = 0; i < __arraycount(trap_table); i++) { | | 194 | for (size_t i = 0; i < __arraycount(trap_table); i++) { |
189 | KASSERT(trap_table[i].exc_size <= 0x100); | | 195 | KASSERT(trap_table[i].exc_size <= 0x100); |
190 | trap_copy(trap_table[i].exc_addr, trap_table[i].exc_vector, | | 196 | trap_copy(trap_table[i].exc_addr, trap_table[i].exc_vector, |
191 | trap_table[i].exc_size); | | 197 | trap_table[i].exc_size); |
192 | } | | 198 | } |
193 | | | 199 | |
194 | __syncicache((void *)EXC_RST, EXC_LAST - EXC_RST + 0x100); | | 200 | __syncicache((void *)EXC_RST, EXC_LAST - EXC_RST + 0x100); |
195 | | | 201 | |
196 | mtspr(SPR_EVPR, 0); /* Set Exception vector base */ | | 202 | mtspr(SPR_EVPR, 0); /* Set Exception vector base */ |
197 | | | 203 | |
198 | /* Handle trap instruction as PGM exception */ | | 204 | /* Handle trap instruction as PGM exception */ |
199 | mtspr(SPR_DBCR0, mfspr(SPR_DBCR0) & ~DBCR0_TDE); | | 205 | mtspr(SPR_DBCR0, mfspr(SPR_DBCR0) & ~DBCR0_TDE); |
200 | | | 206 | |
201 | /* | | 207 | /* |
202 | * external interrupt handler install | | 208 | * external interrupt handler install |
203 | */ | | 209 | */ |
204 | if (handler) | | 210 | if (handler) |
205 | ibm4xx_install_extint(handler); | | 211 | ibm4xx_install_extint(handler); |
206 | | | 212 | |
207 | /* | | 213 | /* |
208 | * Now enable translation (and machine checks/recoverable interrupts). | | 214 | * Now enable translation (and machine checks/recoverable interrupts). |
209 | */ | | 215 | */ |
210 | __asm volatile ("mfmsr %0; ori %0,%0,%1; mtmsr %0; isync" | | 216 | __asm volatile ("mfmsr %0; ori %0,%0,%1; mtmsr %0; isync" |
211 | : : "r"(0), "K"(PSL_IR|PSL_DR)); | | 217 | : : "r"(0), "K"(PSL_IR|PSL_DR)); |
212 | /* XXXX PSL_ME - With ME set kernel gets stuck... */ | | 218 | /* XXXX PSL_ME - With ME set kernel gets stuck... */ |
213 | | | 219 | |
214 | /* | | 220 | /* |
215 | * turn on console after enable translation | | 221 | * turn on console after enable translation |
216 | */ | | 222 | */ |
217 | consinit(); | | 223 | consinit(); |
218 | | | 224 | |
219 | uvm_md_init(); | | 225 | uvm_md_init(); |
220 | | | 226 | |
221 | /* | | 227 | /* |
222 | * Initialize pmap module. | | 228 | * Initialize pmap module. |
223 | */ | | 229 | */ |
224 | pmap_bootstrap(startkernel, endkernel); | | 230 | pmap_bootstrap(startkernel, endkernel); |
225 | | | 231 | |
226 | /* | | 232 | /* |
227 | * Let's take all the indirect calls via our stubs and patch | | 233 | * Let's take all the indirect calls via our stubs and patch |
228 | * them to be direct calls. | | 234 | * them to be direct calls. |
229 | */ | | 235 | */ |
230 | cpu_fixup_stubs(); | | 236 | cpu_fixup_stubs(); |
231 | | | 237 | |
232 | #if NKSYMS || defined(DDB) || defined(MODULAR) | | 238 | #if NKSYMS || defined(DDB) || defined(MODULAR) |
233 | ksyms_addsyms_elf((uintptr_t)endsym - (uintptr_t)startsym, | | 239 | ksyms_addsyms_elf((uintptr_t)endsym - (uintptr_t)startsym, |
234 | startsym, endsym); | | 240 | startsym, endsym); |
235 | #endif | | 241 | #endif |
236 | } | | 242 | } |
237 | | | 243 | |
238 | void | | 244 | void |
239 | ibm4xx_install_extint(void (*handler)(void)) | | 245 | ibm4xx_install_extint(void (*handler)(void)) |
240 | { | | 246 | { |
241 | extern int extint, extsize; | | 247 | extern int extint, extsize; |
242 | extern u_long extint_call; | | 248 | extern u_long extint_call; |
243 | u_long offset = (u_long)handler - (u_long)&extint_call; | | 249 | u_long offset = (u_long)handler - (u_long)&extint_call; |
244 | int msr; | | 250 | int msr; |
245 | | | 251 | |
246 | #ifdef DIAGNOSTIC | | 252 | #ifdef DIAGNOSTIC |
247 | if (offset > 0x1ffffff) | | 253 | if (offset > 0x1ffffff) |
248 | panic("install_extint: too far away"); | | 254 | panic("install_extint: too far away"); |
249 | #endif | | 255 | #endif |
250 | __asm volatile ("mfmsr %0; wrteei 0" : "=r"(msr)); | | 256 | __asm volatile ("mfmsr %0; wrteei 0" : "=r"(msr)); |
251 | extint_call = (extint_call & 0xfc000003) | offset; | | 257 | extint_call = (extint_call & 0xfc000003) | offset; |
252 | memcpy((void *)EXC_EXI, &extint, (size_t)&extsize); | | 258 | memcpy((void *)EXC_EXI, &extint, (size_t)&extsize); |
253 | __syncicache((void *)&extint_call, sizeof extint_call); | | 259 | __syncicache((void *)&extint_call, sizeof extint_call); |
254 | __syncicache((void *)EXC_EXI, (int)&extsize); | | 260 | __syncicache((void *)EXC_EXI, (int)&extsize); |
255 | __asm volatile ("mtmsr %0" :: "r"(msr)); | | 261 | __asm volatile ("mtmsr %0" :: "r"(msr)); |
256 | } | | 262 | } |
257 | | | 263 | |
258 | /* | | 264 | /* |
259 | * ibm4xx_cpu_startup: | | 265 | * ibm4xx_cpu_startup: |
260 | * Machine dependent startup code. | | 266 | * Machine dependent startup code. |
261 | */ | | 267 | */ |
262 | void | | 268 | void |
263 | ibm4xx_cpu_startup(const char *model) | | 269 | ibm4xx_cpu_startup(const char *model) |
264 | { | | 270 | { |
265 | vaddr_t minaddr, maxaddr; | | 271 | vaddr_t minaddr, maxaddr; |
266 | char pbuf[9]; | | 272 | char pbuf[9]; |
267 | | | 273 | |
268 | KASSERT(curcpu() != NULL); | | 274 | KASSERT(curcpu() != NULL); |
269 | KASSERT(lwp0.l_cpu != NULL); | | 275 | KASSERT(lwp0.l_cpu != NULL); |
270 | KASSERT(curcpu()->ci_intstk != 0); | | 276 | KASSERT(curcpu()->ci_intstk != 0); |
271 | KASSERT(curcpu()->ci_idepth == -1); | | 277 | KASSERT(curcpu()->ci_idepth == -1); |
272 | | | 278 | |
273 | /* | | 279 | /* |
274 | * Initialize error message buffer (at end of core). | | 280 | * Initialize error message buffer (at end of core). |
275 | */ | | 281 | */ |
276 | #if 0 /* For some reason this fails... --Artem | | 282 | #if 0 /* For some reason this fails... --Artem |
277 | * Besides, do we really have to put it at the end of core? | | 283 | * Besides, do we really have to put it at the end of core? |
278 | * Let's use static buffer for now | | 284 | * Let's use static buffer for now |
279 | */ | | 285 | */ |
280 | if (!(msgbuf_vaddr = uvm_km_alloc(kernel_map, round_page(MSGBUFSIZE), | | 286 | if (!(msgbuf_vaddr = uvm_km_alloc(kernel_map, round_page(MSGBUFSIZE), |
281 | 0, UVM_KMF_VAONLY))) | | 287 | 0, UVM_KMF_VAONLY))) |
282 | panic("startup: no room for message buffer"); | | 288 | panic("startup: no room for message buffer"); |
283 | for (i = 0; i < btoc(MSGBUFSIZE); i++) | | 289 | for (i = 0; i < btoc(MSGBUFSIZE); i++) |
284 | pmap_kenter_pa(msgbuf_vaddr + i * PAGE_SIZE, | | 290 | pmap_kenter_pa(msgbuf_vaddr + i * PAGE_SIZE, |
285 | msgbuf_paddr + i * PAGE_SIZE, | | 291 | msgbuf_paddr + i * PAGE_SIZE, |
286 | VM_PROT_READ|VM_PROT_WRITE, 0); | | 292 | VM_PROT_READ|VM_PROT_WRITE, 0); |
287 | initmsgbuf((void *)msgbuf_vaddr, round_page(MSGBUFSIZE)); | | 293 | initmsgbuf((void *)msgbuf_vaddr, round_page(MSGBUFSIZE)); |
288 | #else | | 294 | #else |
289 | initmsgbuf((void *)msgbuf, round_page(MSGBUFSIZE)); | | 295 | initmsgbuf((void *)msgbuf, round_page(MSGBUFSIZE)); |
290 | #endif | | 296 | #endif |
291 | | | 297 | |
292 | printf("%s%s", copyright, version); | | 298 | printf("%s%s", copyright, version); |
293 | if (model != NULL) | | 299 | if (model != NULL) |
294 | printf("Model: %s\n", model); | | 300 | printf("Model: %s\n", model); |
295 | | | 301 | |
296 | format_bytes(pbuf, sizeof(pbuf), ctob(physmem)); | | 302 | format_bytes(pbuf, sizeof(pbuf), ctob(physmem)); |
297 | printf("total memory = %s\n", pbuf); | | 303 | printf("total memory = %s\n", pbuf); |
298 | | | 304 | |
299 | minaddr = 0; | | 305 | minaddr = 0; |
300 | /* | | 306 | /* |
301 | * Allocate a submap for physio | | 307 | * Allocate a submap for physio |
302 | */ | | 308 | */ |
303 | phys_map = uvm_km_suballoc(kernel_map, &minaddr, &maxaddr, | | 309 | phys_map = uvm_km_suballoc(kernel_map, &minaddr, &maxaddr, |
304 | VM_PHYS_SIZE, 0, false, NULL); | | 310 | VM_PHYS_SIZE, 0, false, NULL); |
305 | | | 311 | |
306 | /* | | 312 | /* |
307 | * No need to allocate an mbuf cluster submap. Mbuf clusters | | 313 | * No need to allocate an mbuf cluster submap. Mbuf clusters |
308 | * are allocated via the pool allocator, and we use direct-mapped | | 314 | * are allocated via the pool allocator, and we use direct-mapped |
309 | * pool pages. | | 315 | * pool pages. |
310 | */ | | 316 | */ |
311 | | | 317 | |
312 | format_bytes(pbuf, sizeof(pbuf), ptoa(uvm_availmem(false))); | | 318 | format_bytes(pbuf, sizeof(pbuf), ptoa(uvm_availmem(false))); |
313 | printf("avail memory = %s\n", pbuf); | | 319 | printf("avail memory = %s\n", pbuf); |
314 | } | | 320 | } |
315 | | | 321 | |
316 | /* | | 322 | /* |
317 | * ibm4xx_dumpsys: | | 323 | * ibm4xx_dumpsys: |
318 | * Crash dump handling. | | 324 | * Crash dump handling. |
319 | */ | | 325 | */ |
320 | void | | 326 | void |
321 | ibm4xx_dumpsys(void) | | 327 | ibm4xx_dumpsys(void) |
322 | { | | 328 | { |
323 | | | 329 | |
324 | printf("dumpsys: TBD\n"); | | 330 | printf("dumpsys: TBD\n"); |
325 | } | | 331 | } |