* The fundamental initialization of PMAP stuff. * * Some things already happened in locore.S and some things could happen * before pmap_bootstrap_prepare() is called, so let's recall what is done: * 1. Caches are disabled. * 2. We are running on virtual addresses already with 'boot_pt1' * as L1 page table. * 3. So far, all virtual addresses can be converted to physical ones and *
| 771 | * does save neither physical memory and KVA. |
| 772 | */ |
| 773 | void |
| 774 | pmap_bootstrap_prepare(vm_paddr_t last) |
| 775 | { |
| 776 | vm_paddr_t pt2pg_pa, pt2tab_pa, pa, size; |
| 777 | vm_offset_t pt2pg_va; |
| 778 | pt1_entry_t *pte1p; |
| 779 | pt2_entry_t *pte2p; |
| 780 | u_int i; |
| 781 | uint32_t l1_attr; |
| 782 | |
| 783 | /* |
| 784 | * Now, we are going to make real kernel mapping. Note that we are |
| 785 | * already running on some mapping made in locore.S and we expect |
| 786 | * that it's large enough to ensure nofault access to physical memory |
| 787 | * allocated herein before switch. |
| 788 | * |
| 789 | * As kernel image and everything needed before are and will be mapped |
| 790 | * by section mappings, we align last physical address to PTE1_SIZE. |
| 791 | */ |
| 792 | last_paddr = pte1_roundup(last); |
| 793 | |
| 794 | /* |
| 795 | * Allocate and zero page(s) for kernel L1 page table. |
| 796 | * |
| 797 | * Note that it's first allocation on space which was PTE1_SIZE |
| 798 | * aligned and as such base_pt1 is aligned to NB_IN_PT1 too. |
| 799 | */ |
| 800 | base_pt1 = pmap_preboot_get_pages(NPG_IN_PT1); |
| 801 | kern_pt1 = (pt1_entry_t *)KERNEL_P2V(base_pt1); |
| 802 | bzero((void*)kern_pt1, NB_IN_PT1); |
| 803 | pte1_sync_range(kern_pt1, NB_IN_PT1); |
| 804 | |
| 805 | /* Allocate and zero page(s) for kernel PT2TAB. */ |
| 806 | pt2tab_pa = pmap_preboot_get_pages(NPG_IN_PT2TAB); |
| 807 | kern_pt2tab = (pt2_entry_t *)KERNEL_P2V(pt2tab_pa); |
| 808 | bzero(kern_pt2tab, NB_IN_PT2TAB); |
| 809 | pte2_sync_range(kern_pt2tab, NB_IN_PT2TAB); |
| 810 | |
| 811 | /* Allocate and zero page(s) for kernel L2 page tables. */ |
| 812 | pt2pg_pa = pmap_preboot_get_pages(NKPT2PG); |
| 813 | pt2pg_va = KERNEL_P2V(pt2pg_pa); |
| 814 | size = NKPT2PG * PAGE_SIZE; |
| 815 | bzero((void*)pt2pg_va, size); |
| 816 | pte2_sync_range((pt2_entry_t *)pt2pg_va, size); |
| 817 | |
| 818 | /* |
| 819 | * Add a physical memory segment (vm_phys_seg) corresponding to the |
| 820 | * preallocated pages for kernel L2 page tables so that vm_page |
| 821 | * structures representing these pages will be created. The vm_page |
| 822 | * structures are required for promotion of the corresponding kernel |
| 823 | * virtual addresses to section mappings. |
| 824 | */ |
| 825 | vm_phys_add_seg(pt2tab_pa, pmap_preboot_get_pages(0)); |
| 826 | |
| 827 | /* |
| 828 | * Insert allocated L2 page table pages to PT2TAB and make |
| 829 | * link to all PT2s in L1 page table. See how kernel_vm_end |
| 830 | * is initialized. |
no test coverage detected