* Bootstrap the system enough to run with virtual memory. */
| 945 | * Bootstrap the system enough to run with virtual memory. |
| 946 | */ |
| 947 | void |
| 948 | pmap_bootstrap(vm_offset_t l0pt, vm_offset_t l1pt, vm_paddr_t kernstart, |
| 949 | vm_size_t kernlen) |
| 950 | { |
| 951 | vm_offset_t freemempos; |
| 952 | vm_offset_t dpcpu, msgbufpv; |
| 953 | vm_paddr_t start_pa, pa, min_pa; |
| 954 | uint64_t kern_delta; |
| 955 | int i; |
| 956 | |
| 957 | /* Verify that the ASID is set through TTBR0. */ |
| 958 | KASSERT((READ_SPECIALREG(tcr_el1) & TCR_A1) == 0, |
| 959 | ("pmap_bootstrap: TCR_EL1.A1 != 0")); |
| 960 | |
| 961 | kern_delta = KERNBASE - kernstart; |
| 962 | |
| 963 | printf("pmap_bootstrap %lx %lx %lx\n", l1pt, kernstart, kernlen); |
| 964 | printf("%lx\n", l1pt); |
| 965 | printf("%lx\n", (KERNBASE >> L1_SHIFT) & Ln_ADDR_MASK); |
| 966 | |
| 967 | /* Set this early so we can use the pagetable walking functions */ |
| 968 | kernel_pmap_store.pm_l0 = (pd_entry_t *)l0pt; |
| 969 | PMAP_LOCK_INIT(kernel_pmap); |
| 970 | kernel_pmap->pm_l0_paddr = l0pt - kern_delta; |
| 971 | kernel_pmap->pm_cookie = COOKIE_FROM(-1, INT_MIN); |
| 972 | kernel_pmap->pm_stage = PM_STAGE1; |
| 973 | kernel_pmap->pm_levels = 4; |
| 974 | kernel_pmap->pm_ttbr = kernel_pmap->pm_l0_paddr; |
| 975 | kernel_pmap->pm_asid_set = &asids; |
| 976 | |
| 977 | /* Assume the address we were loaded to is a valid physical address */ |
| 978 | min_pa = KERNBASE - kern_delta; |
| 979 | |
| 980 | physmap_idx = physmem_avail(physmap, nitems(physmap)); |
| 981 | physmap_idx /= 2; |
| 982 | |
| 983 | /* |
| 984 | * Find the minimum physical address. physmap is sorted, |
| 985 | * but may contain empty ranges. |
| 986 | */ |
| 987 | for (i = 0; i < physmap_idx * 2; i += 2) { |
| 988 | if (physmap[i] == physmap[i + 1]) |
| 989 | continue; |
| 990 | if (physmap[i] <= min_pa) |
| 991 | min_pa = physmap[i]; |
| 992 | } |
| 993 | |
| 994 | freemempos = KERNBASE + kernlen; |
| 995 | freemempos = roundup2(freemempos, PAGE_SIZE); |
| 996 | |
| 997 | /* Create a direct map region early so we can use it for pa -> va */ |
| 998 | freemempos = pmap_bootstrap_dmap(l1pt, min_pa, freemempos); |
| 999 | |
| 1000 | start_pa = pa = KERNBASE - kern_delta; |
| 1001 | |
| 1002 | /* |
| 1003 | * Create the l2 tables up to VM_MAX_KERNEL_ADDRESS. We assume that the |
| 1004 | * loader allocated the first and only l2 page table page used to map |
no test coverage detected