| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: arm32_kvminit.c,v 1.35 2015/06/01 19:16:44 matt Exp $ */ | | 1 | /* $NetBSD: arm32_kvminit.c,v 1.36 2015/11/25 08:32:33 skrll Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright (c) 2002, 2003, 2005 Genetec Corporation. All rights reserved. | | 4 | * Copyright (c) 2002, 2003, 2005 Genetec Corporation. All rights reserved. |
5 | * Written by Hiroyuki Bessho for Genetec Corporation. | | 5 | * Written by Hiroyuki Bessho for Genetec Corporation. |
6 | * | | 6 | * |
7 | * Redistribution and use in source and binary forms, with or without | | 7 | * Redistribution and use in source and binary forms, with or without |
8 | * modification, are permitted provided that the following conditions | | 8 | * modification, are permitted provided that the following conditions |
9 | * are met: | | 9 | * are met: |
10 | * 1. Redistributions of source code must retain the above copyright | | 10 | * 1. Redistributions of source code must retain the above copyright |
11 | * notice, this list of conditions and the following disclaimer. | | 11 | * notice, this list of conditions and the following disclaimer. |
12 | * 2. Redistributions in binary form must reproduce the above copyright | | 12 | * 2. Redistributions in binary form must reproduce the above copyright |
13 | * notice, this list of conditions and the following disclaimer in the | | 13 | * notice, this list of conditions and the following disclaimer in the |
14 | * documentation and/or other materials provided with the distribution. | | 14 | * documentation and/or other materials provided with the distribution. |
| @@ -114,27 +114,27 @@ | | | @@ -114,27 +114,27 @@ |
114 | * IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTERS BE LIABLE FOR ANY DIRECT, | | 114 | * IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTERS BE LIABLE FOR ANY DIRECT, |
115 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | | 115 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
116 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | | 116 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
117 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | | 117 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
118 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | | 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 | | 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 | | 120 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
121 | * SUCH DAMAGE. | | 121 | * SUCH DAMAGE. |
122 | */ | | 122 | */ |
123 | | | 123 | |
124 | #include "opt_multiprocessor.h" | | 124 | #include "opt_multiprocessor.h" |
125 | | | 125 | |
126 | #include <sys/cdefs.h> | | 126 | #include <sys/cdefs.h> |
127 | __KERNEL_RCSID(0, "$NetBSD: arm32_kvminit.c,v 1.35 2015/06/01 19:16:44 matt Exp $"); | | 127 | __KERNEL_RCSID(0, "$NetBSD: arm32_kvminit.c,v 1.36 2015/11/25 08:32:33 skrll Exp $"); |
128 | | | 128 | |
129 | #include <sys/param.h> | | 129 | #include <sys/param.h> |
130 | #include <sys/device.h> | | 130 | #include <sys/device.h> |
131 | #include <sys/kernel.h> | | 131 | #include <sys/kernel.h> |
132 | #include <sys/reboot.h> | | 132 | #include <sys/reboot.h> |
133 | #include <sys/bus.h> | | 133 | #include <sys/bus.h> |
134 | | | 134 | |
135 | #include <dev/cons.h> | | 135 | #include <dev/cons.h> |
136 | | | 136 | |
137 | #include <uvm/uvm_extern.h> | | 137 | #include <uvm/uvm_extern.h> |
138 | | | 138 | |
139 | #include <arm/locore.h> | | 139 | #include <arm/locore.h> |
140 | #include <arm/db_machdep.h> | | 140 | #include <arm/db_machdep.h> |
| @@ -230,27 +230,27 @@ arm32_bootmem_init(paddr_t memstart, psi | | | @@ -230,27 +230,27 @@ arm32_bootmem_init(paddr_t memstart, psi |
230 | pv->pv_pa = bmi->bmi_start; | | 230 | pv->pv_pa = bmi->bmi_start; |
231 | pv->pv_va = KERN_PHYSTOV(bmi, pv->pv_pa); | | 231 | pv->pv_va = KERN_PHYSTOV(bmi, pv->pv_pa); |
232 | pv->pv_size = bmi->bmi_kernelstart - pv->pv_pa; | | 232 | pv->pv_size = bmi->bmi_kernelstart - pv->pv_pa; |
233 | bmi->bmi_freepages += pv->pv_size / PAGE_SIZE; | | 233 | bmi->bmi_freepages += pv->pv_size / PAGE_SIZE; |
234 | #ifdef VERBOSE_INIT_ARM | | 234 | #ifdef VERBOSE_INIT_ARM |
235 | printf("%s: adding %lu free pages: [%#lx..%#lx] (VA %#lx)\n", | | 235 | printf("%s: adding %lu free pages: [%#lx..%#lx] (VA %#lx)\n", |
236 | __func__, pv->pv_size / PAGE_SIZE, pv->pv_pa, | | 236 | __func__, pv->pv_size / PAGE_SIZE, pv->pv_pa, |
237 | pv->pv_pa + pv->pv_size - 1, pv->pv_va); | | 237 | pv->pv_pa + pv->pv_size - 1, pv->pv_va); |
238 | #endif | | 238 | #endif |
239 | pv++; | | 239 | pv++; |
240 | } | | 240 | } |
241 | | | 241 | |
242 | bmi->bmi_nfreeblocks = pv - bmi->bmi_freeblocks; | | 242 | bmi->bmi_nfreeblocks = pv - bmi->bmi_freeblocks; |
243 | | | 243 | |
244 | SLIST_INIT(&bmi->bmi_freechunks); | | 244 | SLIST_INIT(&bmi->bmi_freechunks); |
245 | SLIST_INIT(&bmi->bmi_chunks); | | 245 | SLIST_INIT(&bmi->bmi_chunks); |
246 | } | | 246 | } |
247 | | | 247 | |
248 | static bool | | 248 | static bool |
249 | concat_pvaddr(pv_addr_t *acc_pv, pv_addr_t *pv) | | 249 | concat_pvaddr(pv_addr_t *acc_pv, pv_addr_t *pv) |
250 | { | | 250 | { |
251 | if (acc_pv->pv_pa + acc_pv->pv_size == pv->pv_pa | | 251 | if (acc_pv->pv_pa + acc_pv->pv_size == pv->pv_pa |
252 | && acc_pv->pv_va + acc_pv->pv_size == pv->pv_va | | 252 | && acc_pv->pv_va + acc_pv->pv_size == pv->pv_va |
253 | && acc_pv->pv_prot == pv->pv_prot | | 253 | && acc_pv->pv_prot == pv->pv_prot |
254 | && acc_pv->pv_cache == pv->pv_cache) { | | 254 | && acc_pv->pv_cache == pv->pv_cache) { |
255 | #ifdef VERBOSE_INIT_ARMX | | 255 | #ifdef VERBOSE_INIT_ARMX |
256 | printf("%s: appending pv %p (%#lx..%#lx) to %#lx..%#lx\n", | | 256 | printf("%s: appending pv %p (%#lx..%#lx) to %#lx..%#lx\n", |
| @@ -586,27 +586,27 @@ arm32_kernel_vm_init(vaddr_t kernel_vm_b | | | @@ -586,27 +586,27 @@ arm32_kernel_vm_init(vaddr_t kernel_vm_b |
586 | */ | | 586 | */ |
587 | valloc_pages(bmi, &systempage, 1, VM_PROT_READ|VM_PROT_WRITE, | | 587 | valloc_pages(bmi, &systempage, 1, VM_PROT_READ|VM_PROT_WRITE, |
588 | PTE_CACHE, true); | | 588 | PTE_CACHE, true); |
589 | } | | 589 | } |
590 | systempage.pv_va = vectors; | | 590 | systempage.pv_va = vectors; |
591 | | | 591 | |
592 | /* | | 592 | /* |
593 | * If the caller needed a few extra pages for some reason, allocate | | 593 | * If the caller needed a few extra pages for some reason, allocate |
594 | * them now. | | 594 | * them now. |
595 | */ | | 595 | */ |
596 | #if ARM_MMU_XSCALE == 1 | | 596 | #if ARM_MMU_XSCALE == 1 |
597 | #if (ARM_NMMUS > 1) | | 597 | #if (ARM_NMMUS > 1) |
598 | if (xscale_use_minidata) | | 598 | if (xscale_use_minidata) |
599 | #endif | | 599 | #endif |
600 | valloc_pages(bmi, &minidataclean, 1, | | 600 | valloc_pages(bmi, &minidataclean, 1, |
601 | VM_PROT_READ|VM_PROT_WRITE, 0, true); | | 601 | VM_PROT_READ|VM_PROT_WRITE, 0, true); |
602 | #endif | | 602 | #endif |
603 | | | 603 | |
604 | /* | | 604 | /* |
605 | * Ok we have allocated physical pages for the primary kernel | | 605 | * Ok we have allocated physical pages for the primary kernel |
606 | * page tables and stacks. Let's just confirm that. | | 606 | * page tables and stacks. Let's just confirm that. |
607 | */ | | 607 | */ |
608 | if (kernel_l1pt.pv_va == 0 | | 608 | if (kernel_l1pt.pv_va == 0 |
609 | && (!kernel_l1pt.pv_pa || (kernel_l1pt.pv_pa & (L1_TABLE_SIZE - 1)) != 0)) | | 609 | && (!kernel_l1pt.pv_pa || (kernel_l1pt.pv_pa & (L1_TABLE_SIZE - 1)) != 0)) |
610 | panic("%s: Failed to allocate or align the kernel " | | 610 | panic("%s: Failed to allocate or align the kernel " |
611 | "page directory", __func__); | | 611 | "page directory", __func__); |
612 | | | 612 | |
| @@ -835,33 +835,33 @@ arm32_kernel_vm_init(vaddr_t kernel_vm_b | | | @@ -835,33 +835,33 @@ arm32_kernel_vm_init(vaddr_t kernel_vm_b |
835 | #endif | | 835 | #endif |
836 | pmap_map_chunk(l1pt_va, cur_pv.pv_va, cur_pv.pv_pa, | | 836 | pmap_map_chunk(l1pt_va, cur_pv.pv_va, cur_pv.pv_pa, |
837 | cur_pv.pv_size, cur_pv.pv_prot, cur_pv.pv_cache); | | 837 | cur_pv.pv_size, cur_pv.pv_prot, cur_pv.pv_cache); |
838 | | | 838 | |
839 | /* | | 839 | /* |
840 | * Now we map the stuff that isn't directly after the kernel | | 840 | * Now we map the stuff that isn't directly after the kernel |
841 | */ | | 841 | */ |
842 | if (map_vectors_p) { | | 842 | if (map_vectors_p) { |
843 | /* Map the vector page. */ | | 843 | /* Map the vector page. */ |
844 | pmap_map_entry(l1pt_va, systempage.pv_va, systempage.pv_pa, | | 844 | pmap_map_entry(l1pt_va, systempage.pv_va, systempage.pv_pa, |
845 | VM_PROT_READ|VM_PROT_WRITE, PTE_CACHE); | | 845 | VM_PROT_READ|VM_PROT_WRITE, PTE_CACHE); |
846 | } | | 846 | } |
847 | | | 847 | |
848 | /* Map the Mini-Data cache clean area. */ | | 848 | /* Map the Mini-Data cache clean area. */ |
849 | #if ARM_MMU_XSCALE == 1 | | 849 | #if ARM_MMU_XSCALE == 1 |
850 | #if (ARM_NMMUS > 1) | | 850 | #if (ARM_NMMUS > 1) |
851 | if (xscale_use_minidata) | | 851 | if (xscale_use_minidata) |
852 | #endif | | 852 | #endif |
853 | xscale_setup_minidata(l1pt_va, minidataclean.pv_va, | | 853 | xscale_setup_minidata(l1pt_va, minidataclean.pv_va, |
854 | minidataclean.pv_pa); | | 854 | minidataclean.pv_pa); |
855 | #endif | | 855 | #endif |
856 | | | 856 | |
857 | /* | | 857 | /* |
858 | * Map integrated peripherals at same address in first level page | | 858 | * Map integrated peripherals at same address in first level page |
859 | * table so that we can continue to use console. | | 859 | * table so that we can continue to use console. |
860 | */ | | 860 | */ |
861 | if (devmap) | | 861 | if (devmap) |
862 | pmap_devmap_bootstrap(l1pt_va, devmap); | | 862 | pmap_devmap_bootstrap(l1pt_va, devmap); |
863 | | | 863 | |
864 | #ifdef VERBOSE_INIT_ARM | | 864 | #ifdef VERBOSE_INIT_ARM |
865 | /* Tell the user about where all the bits and pieces live. */ | | 865 | /* Tell the user about where all the bits and pieces live. */ |
866 | printf("%22s Physical Virtual Num\n", " "); | | 866 | printf("%22s Physical Virtual Num\n", " "); |
867 | printf("%22s Starting Ending Starting Ending Pages\n", " "); | | 867 | printf("%22s Starting Ending Starting Ending Pages\n", " "); |