MCPcopy Create free account
hub / github.com/F-Stack/f-stack / pmap_init

Function pmap_init

freebsd/arm/arm/pmap-v6.c:1715–1792  ·  view source on GitHub ↗

* Initialize the pmap module. * Called by vm_init, to initialize any structures that the pmap * system needs to map virtual memory. */

Source from the content-addressed store, hash-verified

1713 * system needs to map virtual memory.
1714 */
1715void
1716pmap_init(void)
1717{
1718 vm_size_t s;
1719 pt2_entry_t *pte2p, pte2;
1720 u_int i, pte1_idx, pv_npg;
1721
1722 PDEBUG(1, printf("%s: phys_start = %#x\n", __func__, PHYSADDR));
1723
1724 /*
1725 * Initialize the vm page array entries for kernel pmap's
1726 * L2 page table pages allocated in advance.
1727 */
1728 pte1_idx = pte1_index(KERNBASE - PT2MAP_SIZE);
1729 pte2p = kern_pt2tab_entry(KERNBASE - PT2MAP_SIZE);
1730 for (i = 0; i < nkpt2pg + NPG_IN_PT2TAB; i++, pte2p++) {
1731 vm_paddr_t pa;
1732 vm_page_t m;
1733
1734 pte2 = pte2_load(pte2p);
1735 KASSERT(pte2_is_valid(pte2), ("%s: no valid entry", __func__));
1736
1737 pa = pte2_pa(pte2);
1738 m = PHYS_TO_VM_PAGE(pa);
1739 KASSERT(m >= vm_page_array &&
1740 m < &vm_page_array[vm_page_array_size],
1741 ("%s: L2 page table page is out of range", __func__));
1742
1743 m->pindex = pte1_idx;
1744 m->phys_addr = pa;
1745 pte1_idx += NPT2_IN_PG;
1746 }
1747
1748 /*
1749 * Initialize the address space (zone) for the pv entries. Set a
1750 * high water mark so that the system can recover from excessive
1751 * numbers of pv entries.
1752 */
1753 TUNABLE_INT_FETCH("vm.pmap.shpgperproc", &shpgperproc);
1754 pv_entry_max = shpgperproc * maxproc + vm_cnt.v_page_count;
1755 TUNABLE_INT_FETCH("vm.pmap.pv_entries", &pv_entry_max);
1756 pv_entry_max = roundup(pv_entry_max, _NPCPV);
1757 pv_entry_high_water = 9 * (pv_entry_max / 10);
1758
1759 /*
1760 * Are large page mappings enabled?
1761 */
1762 TUNABLE_INT_FETCH("vm.pmap.sp_enabled", &sp_enabled);
1763 if (sp_enabled) {
1764 KASSERT(MAXPAGESIZES > 1 && pagesizes[1] == 0,
1765 ("%s: can't assign to pagesizes[1]", __func__));
1766 pagesizes[1] = PTE1_SIZE;
1767 }
1768
1769 /*
1770 * Calculate the size of the pv head table for sections.
1771 * Handle the possibility that "vm_phys_segs[...].end" is zero.
1772 * Note that the table is only for sections which could be promoted.

Callers

nothing calls this directly

Calls 12

pte1_indexFunction · 0.85
kern_pt2tab_entryFunction · 0.85
pte2_loadFunction · 0.85
pte2_is_validFunction · 0.85
pte2_paFunction · 0.85
PHYS_TO_VM_PAGEFunction · 0.85
pte1_truncFunction · 0.85
kva_allocFunction · 0.85
pmap_pte2list_initFunction · 0.85
printfFunction · 0.50
kmem_mallocFunction · 0.50
panicFunction · 0.50

Tested by

no test coverage detected