arm32_kvminit.c revision 1.41.2.1 1 /* $NetBSD: arm32_kvminit.c,v 1.41.2.1 2018/09/06 06:55:25 pgoyette Exp $ */
2
3 /*
4 * Copyright (c) 2002, 2003, 2005 Genetec Corporation. All rights reserved.
5 * Written by Hiroyuki Bessho for Genetec Corporation.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. The name of Genetec Corporation may not be used to endorse or
16 * promote products derived from this software without specific prior
17 * written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY GENETEC CORPORATION ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GENETEC CORPORATION
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 *
31 * Copyright (c) 2001 Wasabi Systems, Inc.
32 * All rights reserved.
33 *
34 * Written by Jason R. Thorpe for Wasabi Systems, Inc.
35 *
36 * Redistribution and use in source and binary forms, with or without
37 * modification, are permitted provided that the following conditions
38 * are met:
39 * 1. Redistributions of source code must retain the above copyright
40 * notice, this list of conditions and the following disclaimer.
41 * 2. Redistributions in binary form must reproduce the above copyright
42 * notice, this list of conditions and the following disclaimer in the
43 * documentation and/or other materials provided with the distribution.
44 * 3. All advertising materials mentioning features or use of this software
45 * must display the following acknowledgement:
46 * This product includes software developed for the NetBSD Project by
47 * Wasabi Systems, Inc.
48 * 4. The name of Wasabi Systems, Inc. may not be used to endorse
49 * or promote products derived from this software without specific prior
50 * written permission.
51 *
52 * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
53 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
54 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
55 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC
56 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
57 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
58 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
59 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
60 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
61 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
62 * POSSIBILITY OF SUCH DAMAGE.
63 *
64 * Copyright (c) 1997,1998 Mark Brinicombe.
65 * Copyright (c) 1997,1998 Causality Limited.
66 * All rights reserved.
67 *
68 * Redistribution and use in source and binary forms, with or without
69 * modification, are permitted provided that the following conditions
70 * are met:
71 * 1. Redistributions of source code must retain the above copyright
72 * notice, this list of conditions and the following disclaimer.
73 * 2. Redistributions in binary form must reproduce the above copyright
74 * notice, this list of conditions and the following disclaimer in the
75 * documentation and/or other materials provided with the distribution.
76 * 3. All advertising materials mentioning features or use of this software
77 * must display the following acknowledgement:
78 * This product includes software developed by Mark Brinicombe
79 * for the NetBSD Project.
80 * 4. The name of the company nor the name of the author may be used to
81 * endorse or promote products derived from this software without specific
82 * prior written permission.
83 *
84 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
85 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
86 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
87 * IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
88 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
89 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
90 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
91 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
92 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
93 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
94 * SUCH DAMAGE.
95 *
96 * Copyright (c) 2007 Microsoft
97 * All rights reserved.
98 *
99 * Redistribution and use in source and binary forms, with or without
100 * modification, are permitted provided that the following conditions
101 * are met:
102 * 1. Redistributions of source code must retain the above copyright
103 * notice, this list of conditions and the following disclaimer.
104 * 2. Redistributions in binary form must reproduce the above copyright
105 * notice, this list of conditions and the following disclaimer in the
106 * documentation and/or other materials provided with the distribution.
107 * 3. All advertising materials mentioning features or use of this software
108 * must display the following acknowledgement:
109 * This product includes software developed by Microsoft
110 *
111 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
112 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
113 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
114 * IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTERS BE LIABLE FOR ANY DIRECT,
115 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
116 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
117 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
118 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
119 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
120 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
121 * SUCH DAMAGE.
122 */
123
124 #include "opt_arm_debug.h"
125 #include "opt_fdt.h"
126 #include "opt_multiprocessor.h"
127
128 #include <sys/cdefs.h>
129 __KERNEL_RCSID(0, "$NetBSD: arm32_kvminit.c,v 1.41.2.1 2018/09/06 06:55:25 pgoyette Exp $");
130
131 #include <sys/param.h>
132 #include <sys/device.h>
133 #include <sys/kernel.h>
134 #include <sys/reboot.h>
135 #include <sys/bus.h>
136
137 #include <dev/cons.h>
138
139 #include <uvm/uvm_extern.h>
140
141 #include <arm/locore.h>
142 #include <arm/db_machdep.h>
143 #include <arm/undefined.h>
144 #include <arm/bootconfig.h>
145 #include <arm/arm32/machdep.h>
146
147 #if defined(FDT)
148 #include <arch/evbarm/fdt/platform.h>
149 #endif
150
151 #ifdef MULTIPROCESSOR
152 #ifndef __HAVE_CPU_UAREA_ALLOC_IDLELWP
153 #error __HAVE_CPU_UAREA_ALLOC_IDLELWP required to not waste pages for idlestack
154 #endif
155 #endif
156
157 #ifdef VERBOSE_INIT_ARM
158 #define VPRINTF(...) printf(__VA_ARGS__)
159 #else
160 #define VPRINTF(...) do { } while (/* CONSTCOND */ 0)
161 #endif
162
163 struct bootmem_info bootmem_info;
164
165 extern void *msgbufaddr;
166 paddr_t msgbufphys;
167 paddr_t physical_start;
168 paddr_t physical_end;
169
170 extern char etext[];
171 extern char __data_start[], _edata[];
172 extern char __bss_start[], __bss_end__[];
173 extern char _end[];
174
175 /* Page tables for mapping kernel VM */
176 #define KERNEL_L2PT_VMDATA_NUM 8 /* start with 32MB of KVM */
177
178 u_long kern_vtopdiff __attribute__((__section__(".data")));
179
180 void
181 arm32_bootmem_init(paddr_t memstart, psize_t memsize, vsize_t kernelstart)
182 {
183 struct bootmem_info * const bmi = &bootmem_info;
184 pv_addr_t *pv = bmi->bmi_freeblocks;
185
186 /*
187 * FDT/generic boot fills in kern_vtopdiff early
188 */
189 #if defined(KERNEL_BASE_VOFFSET)
190 kern_vtopdiff = KERNEL_BASE_VOFFSET;
191 #else
192 KASSERT(memstart == kernelstart);
193 kern_vtopdiff = KERNEL_BASE + memstart;
194 #endif
195
196 VPRINTF("%s: memstart=%#lx, memsize=%#lx, kernelstart=%#lx\n",
197 __func__, memstart, memsize, kernelstart);
198
199 physical_start = bmi->bmi_start = memstart;
200 physical_end = bmi->bmi_end = memstart + memsize;
201 #ifndef ARM_HAS_LPAE
202 if (physical_end == 0) {
203 physical_end = -PAGE_SIZE;
204 memsize -= PAGE_SIZE;
205 bmi->bmi_end -= PAGE_SIZE;
206 VPRINTF("%s: memsize shrunk by a page to avoid ending at 4GB\n",
207 __func__);
208 }
209 #endif
210 physmem = memsize / PAGE_SIZE;
211
212 /*
213 * Let's record where the kernel lives.
214 */
215 bmi->bmi_kernelstart = kernelstart;
216 bmi->bmi_kernelend = KERN_VTOPHYS(round_page((vaddr_t)_end));
217
218 #if defined(FDT)
219 fdt_add_reserved_memory_range(bmi->bmi_kernelstart,
220 bmi->bmi_kernelend - bmi->bmi_kernelstart);
221 #endif
222
223 VPRINTF("%s: kernelend=%#lx\n", __func__, bmi->bmi_kernelend);
224
225 /*
226 * Now the rest of the free memory must be after the kernel.
227 */
228 pv->pv_pa = bmi->bmi_kernelend;
229 pv->pv_va = KERN_PHYSTOV(pv->pv_pa);
230 pv->pv_size = bmi->bmi_end - bmi->bmi_kernelend;
231 bmi->bmi_freepages += pv->pv_size / PAGE_SIZE;
232 VPRINTF("%s: adding %lu free pages: [%#lx..%#lx] (VA %#lx)\n",
233 __func__, pv->pv_size / PAGE_SIZE, pv->pv_pa,
234 pv->pv_pa + pv->pv_size - 1, pv->pv_va);
235 pv++;
236
237 #if !defined(FDT)
238 /*
239 * Add a free block for any memory before the kernel.
240 */
241 if (bmi->bmi_start < bmi->bmi_kernelstart) {
242 pv->pv_pa = bmi->bmi_start;
243 pv->pv_va = KERN_PHYSTOV(pv->pv_pa);
244 pv->pv_size = bmi->bmi_kernelstart - pv->pv_pa;
245 bmi->bmi_freepages += pv->pv_size / PAGE_SIZE;
246 VPRINTF("%s: adding %lu free pages: [%#lx..%#lx] (VA %#lx)\n",
247 __func__, pv->pv_size / PAGE_SIZE, pv->pv_pa,
248 pv->pv_pa + pv->pv_size - 1, pv->pv_va);
249 pv++;
250 }
251 #endif
252
253 bmi->bmi_nfreeblocks = pv - bmi->bmi_freeblocks;
254
255 SLIST_INIT(&bmi->bmi_freechunks);
256 SLIST_INIT(&bmi->bmi_chunks);
257 }
258
259 static bool
260 concat_pvaddr(pv_addr_t *acc_pv, pv_addr_t *pv)
261 {
262 if (acc_pv->pv_pa + acc_pv->pv_size == pv->pv_pa
263 && acc_pv->pv_va + acc_pv->pv_size == pv->pv_va
264 && acc_pv->pv_prot == pv->pv_prot
265 && acc_pv->pv_cache == pv->pv_cache) {
266 VPRINTF("%s: appending pv %p (%#lx..%#lx) to %#lx..%#lx\n",
267 __func__, pv, pv->pv_pa, pv->pv_pa + pv->pv_size + 1,
268 acc_pv->pv_pa, acc_pv->pv_pa + acc_pv->pv_size + 1);
269 acc_pv->pv_size += pv->pv_size;
270 return true;
271 }
272
273 return false;
274 }
275
276 static void
277 add_pages(struct bootmem_info *bmi, pv_addr_t *pv)
278 {
279 pv_addr_t **pvp = &SLIST_FIRST(&bmi->bmi_chunks);
280 while ((*pvp) != NULL && (*pvp)->pv_va <= pv->pv_va) {
281 pv_addr_t * const pv0 = (*pvp);
282 KASSERT(SLIST_NEXT(pv0, pv_list) == NULL || pv0->pv_pa < SLIST_NEXT(pv0, pv_list)->pv_pa);
283 if (concat_pvaddr(pv0, pv)) {
284 VPRINTF("%s: %s pv %p (%#lx..%#lx) to %#lx..%#lx\n",
285 __func__, "appending", pv,
286 pv->pv_pa, pv->pv_pa + pv->pv_size - 1,
287 pv0->pv_pa, pv0->pv_pa + pv0->pv_size - pv->pv_size - 1);
288 pv = SLIST_NEXT(pv0, pv_list);
289 if (pv != NULL && concat_pvaddr(pv0, pv)) {
290 VPRINTF("%s: %s pv %p (%#lx..%#lx) to %#lx..%#lx\n",
291 __func__, "merging", pv,
292 pv->pv_pa, pv->pv_pa + pv->pv_size - 1,
293 pv0->pv_pa,
294 pv0->pv_pa + pv0->pv_size - pv->pv_size - 1);
295 SLIST_REMOVE_AFTER(pv0, pv_list);
296 SLIST_INSERT_HEAD(&bmi->bmi_freechunks, pv, pv_list);
297 }
298 return;
299 }
300 KASSERT(pv->pv_va != (*pvp)->pv_va);
301 pvp = &SLIST_NEXT(*pvp, pv_list);
302 }
303 KASSERT((*pvp) == NULL || pv->pv_va < (*pvp)->pv_va);
304 pv_addr_t * const new_pv = SLIST_FIRST(&bmi->bmi_freechunks);
305 KASSERT(new_pv != NULL);
306 SLIST_REMOVE_HEAD(&bmi->bmi_freechunks, pv_list);
307 *new_pv = *pv;
308 SLIST_NEXT(new_pv, pv_list) = *pvp;
309 (*pvp) = new_pv;
310
311 VPRINTF("%s: adding pv %p (pa %#lx, va %#lx, %lu pages) ",
312 __func__, new_pv, new_pv->pv_pa, new_pv->pv_va,
313 new_pv->pv_size / PAGE_SIZE);
314 if (SLIST_NEXT(new_pv, pv_list)) {
315 VPRINTF("before pa %#lx\n", SLIST_NEXT(new_pv, pv_list)->pv_pa);
316 } else {
317 VPRINTF("at tail\n");
318 }
319 }
320
321 static void
322 valloc_pages(struct bootmem_info *bmi, pv_addr_t *pv, size_t npages,
323 int prot, int cache, bool zero_p)
324 {
325 size_t nbytes = npages * PAGE_SIZE;
326 pv_addr_t *free_pv = bmi->bmi_freeblocks;
327 size_t free_idx = 0;
328 static bool l1pt_found;
329
330 KASSERT(npages > 0);
331
332 /*
333 * If we haven't allocated the kernel L1 page table and we are aligned
334 * at a L1 table boundary, alloc the memory for it.
335 */
336 if (!l1pt_found
337 && (free_pv->pv_pa & (L1_TABLE_SIZE - 1)) == 0
338 && free_pv->pv_size >= L1_TABLE_SIZE) {
339 l1pt_found = true;
340 valloc_pages(bmi, &kernel_l1pt, L1_TABLE_SIZE / PAGE_SIZE,
341 VM_PROT_READ|VM_PROT_WRITE, PTE_PAGETABLE, true);
342 add_pages(bmi, &kernel_l1pt);
343 }
344
345 while (nbytes > free_pv->pv_size) {
346 free_pv++;
347 free_idx++;
348 if (free_idx == bmi->bmi_nfreeblocks) {
349 panic("%s: could not allocate %zu bytes",
350 __func__, nbytes);
351 }
352 }
353
354 /*
355 * As we allocate the memory, make sure that we don't walk over
356 * our current first level translation table.
357 */
358 KASSERT((armreg_ttbr_read() & ~(L1_TABLE_SIZE - 1)) != free_pv->pv_pa);
359
360 #if defined(FDT)
361 fdt_add_reserved_memory_range(free_pv->pv_pa, nbytes);
362 #endif
363 pv->pv_pa = free_pv->pv_pa;
364 pv->pv_va = free_pv->pv_va;
365 pv->pv_size = nbytes;
366 pv->pv_prot = prot;
367 pv->pv_cache = cache;
368
369 /*
370 * If PTE_PAGETABLE uses the same cache modes as PTE_CACHE
371 * just use PTE_CACHE.
372 */
373 if (cache == PTE_PAGETABLE
374 && pte_l1_s_cache_mode == pte_l1_s_cache_mode_pt
375 && pte_l2_l_cache_mode == pte_l2_l_cache_mode_pt
376 && pte_l2_s_cache_mode == pte_l2_s_cache_mode_pt)
377 pv->pv_cache = PTE_CACHE;
378
379 free_pv->pv_pa += nbytes;
380 free_pv->pv_va += nbytes;
381 free_pv->pv_size -= nbytes;
382 if (free_pv->pv_size == 0) {
383 --bmi->bmi_nfreeblocks;
384 for (; free_idx < bmi->bmi_nfreeblocks; free_idx++) {
385 free_pv[0] = free_pv[1];
386 }
387 }
388
389 bmi->bmi_freepages -= npages;
390
391 if (zero_p)
392 memset((void *)pv->pv_va, 0, nbytes);
393 }
394
395 void
396 arm32_kernel_vm_init(vaddr_t kernel_vm_base, vaddr_t vectors, vaddr_t iovbase,
397 const struct pmap_devmap *devmap, bool mapallmem_p)
398 {
399 struct bootmem_info * const bmi = &bootmem_info;
400 #ifdef MULTIPROCESSOR
401 const size_t cpu_num = arm_cpu_max;
402 #else
403 const size_t cpu_num = 1;
404 #endif
405 #ifdef ARM_HAS_VBAR
406 const bool map_vectors_p = false;
407 #elif defined(CPU_ARMV7) || defined(CPU_ARM11)
408 const bool map_vectors_p = vectors == ARM_VECTORS_HIGH
409 || (armreg_pfr1_read() & ARM_PFR1_SEC_MASK) == 0;
410 #else
411 const bool map_vectors_p = true;
412 #endif
413
414 #ifdef __HAVE_MM_MD_DIRECT_MAPPED_PHYS
415 KASSERT(mapallmem_p);
416 #ifdef ARM_MMU_EXTENDED
417 /*
418 * The direct map VA space ends at the start of the kernel VM space.
419 */
420 pmap_directlimit = kernel_vm_base;
421 #else
422 KASSERT(kernel_vm_base - KERNEL_BASE >= physical_end - physical_start);
423 #endif /* ARM_MMU_EXTENDED */
424 #endif /* __HAVE_MM_MD_DIRECT_MAPPED_PHYS */
425
426 /*
427 * Calculate the number of L2 pages needed for mapping the
428 * kernel + data + stuff. Assume 2 L2 pages for kernel, 1 for vectors,
429 * and 1 for IO
430 */
431 size_t kernel_size = bmi->bmi_kernelend;
432 kernel_size -= (bmi->bmi_kernelstart & -L2_S_SEGSIZE);
433 kernel_size += L1_TABLE_SIZE_REAL;
434 kernel_size += PAGE_SIZE * KERNEL_L2PT_VMDATA_NUM;
435 if (map_vectors_p) {
436 kernel_size += PAGE_SIZE; /* L2PT for VECTORS */
437 }
438 if (iovbase) {
439 kernel_size += PAGE_SIZE; /* L2PT for IO */
440 }
441 kernel_size +=
442 cpu_num * (ABT_STACK_SIZE + FIQ_STACK_SIZE + IRQ_STACK_SIZE
443 + UND_STACK_SIZE + UPAGES) * PAGE_SIZE;
444 kernel_size += round_page(MSGBUFSIZE);
445 kernel_size += 0x10000; /* slop */
446 if (!mapallmem_p) {
447 kernel_size += PAGE_SIZE
448 * ((kernel_size + L2_S_SEGSIZE - 1) / L2_S_SEGSIZE);
449 }
450 kernel_size = round_page(kernel_size);
451
452 /*
453 * Now we know how many L2 pages it will take.
454 */
455 const size_t KERNEL_L2PT_KERNEL_NUM =
456 round_page(kernel_size + L2_S_SEGSIZE - 1) / L2_S_SEGSIZE;
457
458 VPRINTF("%s: %zu L2 pages are needed to map %#zx kernel bytes\n",
459 __func__, KERNEL_L2PT_KERNEL_NUM, kernel_size);
460
461 KASSERT(KERNEL_L2PT_KERNEL_NUM + KERNEL_L2PT_VMDATA_NUM < __arraycount(bmi->bmi_l2pts));
462 pv_addr_t * const kernel_l2pt = bmi->bmi_l2pts;
463 pv_addr_t * const vmdata_l2pt = kernel_l2pt + KERNEL_L2PT_KERNEL_NUM;
464 pv_addr_t msgbuf;
465 pv_addr_t text;
466 pv_addr_t data;
467 pv_addr_t chunks[KERNEL_L2PT_KERNEL_NUM+KERNEL_L2PT_VMDATA_NUM+11];
468 #if ARM_MMU_XSCALE == 1
469 pv_addr_t minidataclean;
470 #endif
471
472 /*
473 * We need to allocate some fixed page tables to get the kernel going.
474 *
475 * We are going to allocate our bootstrap pages from the beginning of
476 * the free space that we just calculated. We allocate one page
477 * directory and a number of page tables and store the physical
478 * addresses in the bmi_l2pts array in bootmem_info.
479 *
480 * The kernel page directory must be on a 16K boundary. The page
481 * tables must be on 4K boundaries. What we do is allocate the
482 * page directory on the first 16K boundary that we encounter, and
483 * the page tables on 4K boundaries otherwise. Since we allocate
484 * at least 3 L2 page tables, we are guaranteed to encounter at
485 * least one 16K aligned region.
486 */
487
488 VPRINTF("%s: allocating page tables for", __func__);
489 for (size_t i = 0; i < __arraycount(chunks); i++) {
490 SLIST_INSERT_HEAD(&bmi->bmi_freechunks, &chunks[i], pv_list);
491 }
492
493 kernel_l1pt.pv_pa = 0;
494 kernel_l1pt.pv_va = 0;
495
496 /*
497 * Allocate the L2 pages, but if we get to a page that is aligned for
498 * an L1 page table, we will allocate the pages for it first and then
499 * allocate the L2 page.
500 */
501
502 if (map_vectors_p) {
503 /*
504 * First allocate L2 page for the vectors.
505 */
506 VPRINTF(" vector");
507 valloc_pages(bmi, &bmi->bmi_vector_l2pt, 1,
508 VM_PROT_READ|VM_PROT_WRITE, PTE_PAGETABLE, true);
509 add_pages(bmi, &bmi->bmi_vector_l2pt);
510 }
511
512 /*
513 * Now allocate L2 pages for the kernel
514 */
515 VPRINTF(" kernel");
516 for (size_t idx = 0; idx < KERNEL_L2PT_KERNEL_NUM; ++idx) {
517 valloc_pages(bmi, &kernel_l2pt[idx], 1,
518 VM_PROT_READ|VM_PROT_WRITE, PTE_PAGETABLE, true);
519 add_pages(bmi, &kernel_l2pt[idx]);
520 }
521
522 /*
523 * Now allocate L2 pages for the initial kernel VA space.
524 */
525 VPRINTF(" vm");
526 for (size_t idx = 0; idx < KERNEL_L2PT_VMDATA_NUM; ++idx) {
527 valloc_pages(bmi, &vmdata_l2pt[idx], 1,
528 VM_PROT_READ|VM_PROT_WRITE, PTE_PAGETABLE, true);
529 add_pages(bmi, &vmdata_l2pt[idx]);
530 }
531
532 /*
533 * If someone wanted a L2 page for I/O, allocate it now.
534 */
535 if (iovbase) {
536 VPRINTF(" io");
537 valloc_pages(bmi, &bmi->bmi_io_l2pt, 1,
538 VM_PROT_READ|VM_PROT_WRITE, PTE_PAGETABLE, true);
539 add_pages(bmi, &bmi->bmi_io_l2pt);
540 }
541
542 VPRINTF("%s: allocating stacks\n", __func__);
543
544 /* Allocate stacks for all modes and CPUs */
545 valloc_pages(bmi, &abtstack, ABT_STACK_SIZE * cpu_num,
546 VM_PROT_READ|VM_PROT_WRITE, PTE_CACHE, true);
547 add_pages(bmi, &abtstack);
548 valloc_pages(bmi, &fiqstack, FIQ_STACK_SIZE * cpu_num,
549 VM_PROT_READ|VM_PROT_WRITE, PTE_CACHE, true);
550 add_pages(bmi, &fiqstack);
551 valloc_pages(bmi, &irqstack, IRQ_STACK_SIZE * cpu_num,
552 VM_PROT_READ|VM_PROT_WRITE, PTE_CACHE, true);
553 add_pages(bmi, &irqstack);
554 valloc_pages(bmi, &undstack, UND_STACK_SIZE * cpu_num,
555 VM_PROT_READ|VM_PROT_WRITE, PTE_CACHE, true);
556 add_pages(bmi, &undstack);
557 valloc_pages(bmi, &idlestack, UPAGES * cpu_num, /* SVC32 */
558 VM_PROT_READ|VM_PROT_WRITE, PTE_CACHE, true);
559 add_pages(bmi, &idlestack);
560 valloc_pages(bmi, &kernelstack, UPAGES, /* SVC32 */
561 VM_PROT_READ|VM_PROT_WRITE, PTE_CACHE, true);
562 add_pages(bmi, &kernelstack);
563
564 /* Allocate the message buffer from the end of memory. */
565 const size_t msgbuf_pgs = round_page(MSGBUFSIZE) / PAGE_SIZE;
566 valloc_pages(bmi, &msgbuf, msgbuf_pgs,
567 VM_PROT_READ|VM_PROT_WRITE, PTE_CACHE, false);
568 add_pages(bmi, &msgbuf);
569 msgbufphys = msgbuf.pv_pa;
570 msgbufaddr = (void *)msgbuf.pv_va;
571
572 if (map_vectors_p) {
573 /*
574 * Allocate a page for the system vector page.
575 * This page will just contain the system vectors and can be
576 * shared by all processes.
577 */
578 valloc_pages(bmi, &systempage, 1, VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE,
579 PTE_CACHE, true);
580 }
581 systempage.pv_va = vectors;
582
583 /*
584 * If the caller needed a few extra pages for some reason, allocate
585 * them now.
586 */
587 #if ARM_MMU_XSCALE == 1
588 #if (ARM_NMMUS > 1)
589 if (xscale_use_minidata)
590 #endif
591 valloc_pages(bmi, &minidataclean, 1,
592 VM_PROT_READ|VM_PROT_WRITE, 0, true);
593 #endif
594
595 /*
596 * Ok we have allocated physical pages for the primary kernel
597 * page tables and stacks. Let's just confirm that.
598 */
599 if (kernel_l1pt.pv_va == 0
600 && (!kernel_l1pt.pv_pa || (kernel_l1pt.pv_pa & (L1_TABLE_SIZE - 1)) != 0))
601 panic("%s: Failed to allocate or align the kernel "
602 "page directory", __func__);
603
604
605 VPRINTF("Creating L1 page table at 0x%08lx\n", kernel_l1pt.pv_pa);
606
607 /*
608 * Now we start construction of the L1 page table
609 * We start by mapping the L2 page tables into the L1.
610 * This means that we can replace L1 mappings later on if necessary
611 */
612 vaddr_t l1pt_va = kernel_l1pt.pv_va;
613 paddr_t l1pt_pa = kernel_l1pt.pv_pa;
614
615 if (map_vectors_p) {
616 /* Map the L2 pages tables in the L1 page table */
617 pmap_link_l2pt(l1pt_va, systempage.pv_va & -L2_S_SEGSIZE,
618 &bmi->bmi_vector_l2pt);
619 VPRINTF("%s: adding L2 pt (VA %#lx, PA %#lx) "
620 "for VA %#lx\n (vectors)",
621 __func__, bmi->bmi_vector_l2pt.pv_va,
622 bmi->bmi_vector_l2pt.pv_pa, systempage.pv_va);
623 }
624
625 const vaddr_t kernel_base =
626 KERN_PHYSTOV(bmi->bmi_kernelstart & -L2_S_SEGSIZE);
627 for (size_t idx = 0; idx < KERNEL_L2PT_KERNEL_NUM; idx++) {
628 pmap_link_l2pt(l1pt_va, kernel_base + idx * L2_S_SEGSIZE,
629 &kernel_l2pt[idx]);
630 VPRINTF("%s: adding L2 pt (VA %#lx, PA %#lx) for VA %#lx (kernel)\n",
631 __func__, kernel_l2pt[idx].pv_va,
632 kernel_l2pt[idx].pv_pa, kernel_base + idx * L2_S_SEGSIZE);
633 }
634
635 for (size_t idx = 0; idx < KERNEL_L2PT_VMDATA_NUM; idx++) {
636 pmap_link_l2pt(l1pt_va, kernel_vm_base + idx * L2_S_SEGSIZE,
637 &vmdata_l2pt[idx]);
638 VPRINTF("%s: adding L2 pt (VA %#lx, PA %#lx) for VA %#lx (vm)\n",
639 __func__, vmdata_l2pt[idx].pv_va, vmdata_l2pt[idx].pv_pa,
640 kernel_vm_base + idx * L2_S_SEGSIZE);
641 }
642 if (iovbase) {
643 pmap_link_l2pt(l1pt_va, iovbase & -L2_S_SEGSIZE, &bmi->bmi_io_l2pt);
644 VPRINTF("%s: adding L2 pt (VA %#lx, PA %#lx) for VA %#lx (io)\n",
645 __func__, bmi->bmi_io_l2pt.pv_va, bmi->bmi_io_l2pt.pv_pa,
646 iovbase & -L2_S_SEGSIZE);
647 }
648
649 /* update the top of the kernel VM */
650 pmap_curmaxkvaddr =
651 kernel_vm_base + (KERNEL_L2PT_VMDATA_NUM * L2_S_SEGSIZE);
652
653 VPRINTF("Mapping kernel\n");
654
655 extern char etext[];
656 size_t totalsize = bmi->bmi_kernelend - bmi->bmi_kernelstart;
657 size_t textsize = KERN_VTOPHYS((uintptr_t)etext) - bmi->bmi_kernelstart;
658
659 textsize = (textsize + PGOFSET) & ~PGOFSET;
660
661 /* start at offset of kernel in RAM */
662
663 text.pv_pa = bmi->bmi_kernelstart;
664 text.pv_va = KERN_PHYSTOV(bmi->bmi_kernelstart);
665 text.pv_size = textsize;
666 text.pv_prot = VM_PROT_READ | VM_PROT_EXECUTE;
667 text.pv_cache = PTE_CACHE;
668
669 VPRINTF("%s: adding chunk for kernel text %#lx..%#lx (VA %#lx)\n",
670 __func__, text.pv_pa, text.pv_pa + text.pv_size - 1, text.pv_va);
671
672 add_pages(bmi, &text);
673
674 data.pv_pa = text.pv_pa + textsize;
675 data.pv_va = text.pv_va + textsize;
676 data.pv_size = totalsize - textsize;
677 data.pv_prot = VM_PROT_READ|VM_PROT_WRITE;
678 data.pv_cache = PTE_CACHE;
679
680 VPRINTF("%s: adding chunk for kernel data/bss %#lx..%#lx (VA %#lx)\n",
681 __func__, data.pv_pa, data.pv_pa + data.pv_size - 1, data.pv_va);
682
683 add_pages(bmi, &data);
684
685 VPRINTF("Listing Chunks\n");
686
687 pv_addr_t *lpv;
688 SLIST_FOREACH(lpv, &bmi->bmi_chunks, pv_list) {
689 VPRINTF("%s: pv %p: chunk VA %#lx..%#lx "
690 "(PA %#lx, prot %d, cache %d)\n",
691 __func__, lpv, lpv->pv_va, lpv->pv_va + lpv->pv_size - 1,
692 lpv->pv_pa, lpv->pv_prot, lpv->pv_cache);
693 }
694 VPRINTF("\nMapping Chunks\n");
695
696 pv_addr_t cur_pv;
697 pv_addr_t *pv = SLIST_FIRST(&bmi->bmi_chunks);
698 if (!mapallmem_p || pv->pv_pa == bmi->bmi_start) {
699 cur_pv = *pv;
700 KASSERTMSG(cur_pv.pv_va >= KERNEL_BASE, "%#lx", cur_pv.pv_va);
701 pv = SLIST_NEXT(pv, pv_list);
702 } else {
703 cur_pv.pv_va = KERNEL_BASE;
704 cur_pv.pv_pa = KERN_VTOPHYS(cur_pv.pv_va);
705 cur_pv.pv_size = pv->pv_pa - cur_pv.pv_pa;
706 cur_pv.pv_prot = VM_PROT_READ | VM_PROT_WRITE;
707 cur_pv.pv_cache = PTE_CACHE;
708 }
709 while (pv != NULL) {
710 if (mapallmem_p) {
711 if (concat_pvaddr(&cur_pv, pv)) {
712 pv = SLIST_NEXT(pv, pv_list);
713 continue;
714 }
715 if (cur_pv.pv_pa + cur_pv.pv_size < pv->pv_pa) {
716 /*
717 * See if we can extend the current pv to emcompass the
718 * hole, and if so do it and retry the concatenation.
719 */
720 if (cur_pv.pv_prot == (VM_PROT_READ|VM_PROT_WRITE)
721 && cur_pv.pv_cache == PTE_CACHE) {
722 cur_pv.pv_size = pv->pv_pa - cur_pv.pv_va;
723 continue;
724 }
725
726 /*
727 * We couldn't so emit the current chunk and then
728 */
729 VPRINTF("%s: mapping chunk VA %#lx..%#lx "
730 "(PA %#lx, prot %d, cache %d)\n",
731 __func__,
732 cur_pv.pv_va, cur_pv.pv_va + cur_pv.pv_size - 1,
733 cur_pv.pv_pa, cur_pv.pv_prot, cur_pv.pv_cache);
734 pmap_map_chunk(l1pt_va, cur_pv.pv_va, cur_pv.pv_pa,
735 cur_pv.pv_size, cur_pv.pv_prot, cur_pv.pv_cache);
736
737 /*
738 * set the current chunk to the hole and try again.
739 */
740 cur_pv.pv_pa += cur_pv.pv_size;
741 cur_pv.pv_va += cur_pv.pv_size;
742 cur_pv.pv_size = pv->pv_pa - cur_pv.pv_va;
743 cur_pv.pv_prot = VM_PROT_READ | VM_PROT_WRITE;
744 cur_pv.pv_cache = PTE_CACHE;
745 continue;
746 }
747 }
748
749 /*
750 * The new pv didn't concatenate so emit the current one
751 * and use the new pv as the current pv.
752 */
753 VPRINTF("%s: mapping chunk VA %#lx..%#lx "
754 "(PA %#lx, prot %d, cache %d)\n",
755 __func__, cur_pv.pv_va, cur_pv.pv_va + cur_pv.pv_size - 1,
756 cur_pv.pv_pa, cur_pv.pv_prot, cur_pv.pv_cache);
757 pmap_map_chunk(l1pt_va, cur_pv.pv_va, cur_pv.pv_pa,
758 cur_pv.pv_size, cur_pv.pv_prot, cur_pv.pv_cache);
759 cur_pv = *pv;
760 pv = SLIST_NEXT(pv, pv_list);
761 }
762
763 /*
764 * If we are mapping all of memory, let's map the rest of memory.
765 */
766 if (mapallmem_p && cur_pv.pv_pa + cur_pv.pv_size < bmi->bmi_end) {
767 if (cur_pv.pv_prot == (VM_PROT_READ | VM_PROT_WRITE)
768 && cur_pv.pv_cache == PTE_CACHE) {
769 cur_pv.pv_size = bmi->bmi_end - cur_pv.pv_pa;
770 } else {
771 KASSERTMSG(cur_pv.pv_va + cur_pv.pv_size <= kernel_vm_base,
772 "%#lx >= %#lx", cur_pv.pv_va + cur_pv.pv_size,
773 kernel_vm_base);
774 VPRINTF("%s: mapping chunk VA %#lx..%#lx "
775 "(PA %#lx, prot %d, cache %d)\n",
776 __func__, cur_pv.pv_va, cur_pv.pv_va + cur_pv.pv_size - 1,
777 cur_pv.pv_pa, cur_pv.pv_prot, cur_pv.pv_cache);
778 pmap_map_chunk(l1pt_va, cur_pv.pv_va, cur_pv.pv_pa,
779 cur_pv.pv_size, cur_pv.pv_prot, cur_pv.pv_cache);
780 cur_pv.pv_pa += cur_pv.pv_size;
781 cur_pv.pv_va += cur_pv.pv_size;
782 cur_pv.pv_size = bmi->bmi_end - cur_pv.pv_pa;
783 cur_pv.pv_prot = VM_PROT_READ | VM_PROT_WRITE;
784 cur_pv.pv_cache = PTE_CACHE;
785 }
786 }
787
788 // The amount we can direct is limited by the start of the
789 // virtual part of the kernel address space. Don't overrun
790 // into it.
791 if (mapallmem_p && cur_pv.pv_va + cur_pv.pv_size > kernel_vm_base) {
792 cur_pv.pv_size = kernel_vm_base - cur_pv.pv_va;
793 }
794
795 /*
796 * Now we map the final chunk.
797 */
798 VPRINTF("%s: mapping last chunk VA %#lx..%#lx (PA %#lx, prot %d, cache %d)\n",
799 __func__, cur_pv.pv_va, cur_pv.pv_va + cur_pv.pv_size - 1,
800 cur_pv.pv_pa, cur_pv.pv_prot, cur_pv.pv_cache);
801 pmap_map_chunk(l1pt_va, cur_pv.pv_va, cur_pv.pv_pa,
802 cur_pv.pv_size, cur_pv.pv_prot, cur_pv.pv_cache);
803
804 /*
805 * Now we map the stuff that isn't directly after the kernel
806 */
807 if (map_vectors_p) {
808 /* Map the vector page. */
809 pmap_map_entry(l1pt_va, systempage.pv_va, systempage.pv_pa,
810 VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE, PTE_CACHE);
811 }
812
813 /* Map the Mini-Data cache clean area. */
814 #if ARM_MMU_XSCALE == 1
815 #if (ARM_NMMUS > 1)
816 if (xscale_use_minidata)
817 #endif
818 xscale_setup_minidata(l1pt_va, minidataclean.pv_va,
819 minidataclean.pv_pa);
820 #endif
821
822 /*
823 * Map integrated peripherals at same address in first level page
824 * table so that we can continue to use console.
825 */
826 if (devmap)
827 pmap_devmap_bootstrap(l1pt_va, devmap);
828
829 /* Tell the user about where all the bits and pieces live. */
830 VPRINTF("%22s Physical Virtual Num\n", " ");
831 VPRINTF("%22s Starting Ending Starting Ending Pages\n", " ");
832
833 #ifdef VERBOSE_INIT_ARM
834 static const char mem_fmt[] =
835 "%20s: 0x%08lx 0x%08lx 0x%08lx 0x%08lx %u\n";
836 static const char mem_fmt_nov[] =
837 "%20s: 0x%08lx 0x%08lx %zu\n";
838 #endif
839
840 VPRINTF(mem_fmt, "SDRAM", bmi->bmi_start, bmi->bmi_end - 1,
841 KERN_PHYSTOV(bmi->bmi_start), KERN_PHYSTOV(bmi->bmi_end - 1),
842 (int)physmem);
843 VPRINTF(mem_fmt, "text section",
844 text.pv_pa, text.pv_pa + text.pv_size - 1,
845 text.pv_va, text.pv_va + text.pv_size - 1,
846 (int)(text.pv_size / PAGE_SIZE));
847 VPRINTF(mem_fmt, "data section",
848 KERN_VTOPHYS((vaddr_t)__data_start), KERN_VTOPHYS((vaddr_t)_edata),
849 (vaddr_t)__data_start, (vaddr_t)_edata,
850 (int)((round_page((vaddr_t)_edata)
851 - trunc_page((vaddr_t)__data_start)) / PAGE_SIZE));
852 VPRINTF(mem_fmt, "bss section",
853 KERN_VTOPHYS((vaddr_t)__bss_start), KERN_VTOPHYS((vaddr_t)__bss_end__),
854 (vaddr_t)__bss_start, (vaddr_t)__bss_end__,
855 (int)((round_page((vaddr_t)__bss_end__)
856 - trunc_page((vaddr_t)__bss_start)) / PAGE_SIZE));
857 VPRINTF(mem_fmt, "L1 page directory",
858 kernel_l1pt.pv_pa, kernel_l1pt.pv_pa + L1_TABLE_SIZE - 1,
859 kernel_l1pt.pv_va, kernel_l1pt.pv_va + L1_TABLE_SIZE - 1,
860 L1_TABLE_SIZE / PAGE_SIZE);
861 VPRINTF(mem_fmt, "ABT stack (CPU 0)",
862 abtstack.pv_pa, abtstack.pv_pa + (ABT_STACK_SIZE * PAGE_SIZE) - 1,
863 abtstack.pv_va, abtstack.pv_va + (ABT_STACK_SIZE * PAGE_SIZE) - 1,
864 ABT_STACK_SIZE);
865 VPRINTF(mem_fmt, "FIQ stack (CPU 0)",
866 fiqstack.pv_pa, fiqstack.pv_pa + (FIQ_STACK_SIZE * PAGE_SIZE) - 1,
867 fiqstack.pv_va, fiqstack.pv_va + (FIQ_STACK_SIZE * PAGE_SIZE) - 1,
868 FIQ_STACK_SIZE);
869 VPRINTF(mem_fmt, "IRQ stack (CPU 0)",
870 irqstack.pv_pa, irqstack.pv_pa + (IRQ_STACK_SIZE * PAGE_SIZE) - 1,
871 irqstack.pv_va, irqstack.pv_va + (IRQ_STACK_SIZE * PAGE_SIZE) - 1,
872 IRQ_STACK_SIZE);
873 VPRINTF(mem_fmt, "UND stack (CPU 0)",
874 undstack.pv_pa, undstack.pv_pa + (UND_STACK_SIZE * PAGE_SIZE) - 1,
875 undstack.pv_va, undstack.pv_va + (UND_STACK_SIZE * PAGE_SIZE) - 1,
876 UND_STACK_SIZE);
877 VPRINTF(mem_fmt, "IDLE stack (CPU 0)",
878 idlestack.pv_pa, idlestack.pv_pa + (UPAGES * PAGE_SIZE) - 1,
879 idlestack.pv_va, idlestack.pv_va + (UPAGES * PAGE_SIZE) - 1,
880 UPAGES);
881 VPRINTF(mem_fmt, "SVC stack",
882 kernelstack.pv_pa, kernelstack.pv_pa + (UPAGES * PAGE_SIZE) - 1,
883 kernelstack.pv_va, kernelstack.pv_va + (UPAGES * PAGE_SIZE) - 1,
884 UPAGES);
885 VPRINTF(mem_fmt, "Message Buffer",
886 msgbuf.pv_pa, msgbuf.pv_pa + (msgbuf_pgs * PAGE_SIZE) - 1,
887 msgbuf.pv_va, msgbuf.pv_va + (msgbuf_pgs * PAGE_SIZE) - 1,
888 (int)msgbuf_pgs);
889 if (map_vectors_p) {
890 VPRINTF(mem_fmt, "Exception Vectors",
891 systempage.pv_pa, systempage.pv_pa + PAGE_SIZE - 1,
892 systempage.pv_va, systempage.pv_va + PAGE_SIZE - 1,
893 1);
894 }
895 for (size_t i = 0; i < bmi->bmi_nfreeblocks; i++) {
896 pv = &bmi->bmi_freeblocks[i];
897
898 VPRINTF(mem_fmt_nov, "Free Memory",
899 pv->pv_pa, pv->pv_pa + pv->pv_size - 1,
900 pv->pv_size / PAGE_SIZE);
901 }
902 /*
903 * Now we have the real page tables in place so we can switch to them.
904 * Once this is done we will be running with the REAL kernel page
905 * tables.
906 */
907
908 VPRINTF("TTBR0=%#x", armreg_ttbr_read());
909 #ifdef _ARM_ARCH_6
910 VPRINTF(" TTBR1=%#x TTBCR=%#x CONTEXTIDR=%#x",
911 armreg_ttbr1_read(), armreg_ttbcr_read(),
912 armreg_contextidr_read());
913 #endif
914 VPRINTF("\n");
915
916 /* Switch tables */
917 VPRINTF("switching to new L1 page table @%#lx...", l1pt_pa);
918
919 #ifdef ARM_MMU_EXTENDED
920 cpu_domains((DOMAIN_CLIENT << (PMAP_DOMAIN_KERNEL*2))
921 | (DOMAIN_CLIENT << (PMAP_DOMAIN_USER*2)));
922 #else
923 cpu_domains((DOMAIN_CLIENT << (PMAP_DOMAIN_KERNEL*2)) | DOMAIN_CLIENT);
924 #endif
925 cpu_idcache_wbinv_all();
926 VPRINTF(" ttb");
927 #ifdef ARM_MMU_EXTENDED
928 /*
929 * TTBCR should have been initialized by the MD start code.
930 */
931 KASSERT((armreg_contextidr_read() & 0xff) == 0);
932 KASSERT(armreg_ttbcr_read() == __SHIFTIN(1, TTBCR_S_N));
933 /*
934 * Disable lookups via TTBR0 until there is an activated pmap.
935 */
936 armreg_ttbcr_write(armreg_ttbcr_read() | TTBCR_S_PD0);
937 cpu_setttb(l1pt_pa, KERNEL_PID);
938 arm_isb();
939 #else
940 cpu_setttb(l1pt_pa, true);
941 cpu_domains(DOMAIN_CLIENT << (PMAP_DOMAIN_KERNEL*2));
942 #endif
943 cpu_tlb_flushID();
944
945 #ifdef ARM_MMU_EXTENDED
946 VPRINTF(" (TTBCR=%#x TTBR0=%#x TTBR1=%#x)",
947 armreg_ttbcr_read(), armreg_ttbr_read(), armreg_ttbr1_read());
948 #else
949 VPRINTF(" (TTBR0=%#x)", armreg_ttbr_read());
950 #endif
951
952 #ifdef MULTIPROCESSOR
953 /*
954 * Kick the secondaries to load the TTB. After which they'll go
955 * back to sleep to wait for the final kick so they will hatch.
956 */
957 VPRINTF(" hatchlings");
958 cpu_boot_secondary_processors();
959 #endif
960
961 VPRINTF(" OK\n");
962 }
963