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

Function startup_alloc

freebsd/vm/uma_core.c:1652–1687  ·  view source on GitHub ↗

* This function is intended to be used early on in place of page_alloc() so * that we may use the boot time page cache to satisfy allocations before * the VM is ready. */

Source from the content-addressed store, hash-verified

1650 * the VM is ready.
1651 */
1652static void *
1653startup_alloc(uma_zone_t zone, vm_size_t bytes, int domain, uint8_t *pflag,
1654 int wait)
1655{
1656 vm_paddr_t pa;
1657 vm_page_t m;
1658 void *mem;
1659 int pages;
1660 int i;
1661
1662 pages = howmany(bytes, PAGE_SIZE);
1663 KASSERT(pages > 0, ("%s can't reserve 0 pages", __func__));
1664
1665 *pflag = UMA_SLAB_BOOT;
1666 m = vm_page_alloc_contig_domain(NULL, 0, domain,
1667 malloc2vm_flags(wait) | VM_ALLOC_NOOBJ | VM_ALLOC_WIRED, pages,
1668 (vm_paddr_t)0, ~(vm_paddr_t)0, 1, 0, VM_MEMATTR_DEFAULT);
1669 if (m == NULL)
1670 return (NULL);
1671
1672 pa = VM_PAGE_TO_PHYS(m);
1673 for (i = 0; i < pages; i++, pa += PAGE_SIZE) {
1674#if defined(__aarch64__) || defined(__amd64__) || defined(__mips__) || \
1675 defined(__riscv) || defined(__powerpc64__)
1676 if ((wait & M_NODUMP) == 0)
1677 dump_add_page(pa);
1678#endif
1679 }
1680 /* Allocate KVA and indirectly advance bootmem. */
1681 mem = (void *)pmap_map(&bootmem, m->phys_addr,
1682 m->phys_addr + (pages * PAGE_SIZE), VM_PROT_READ | VM_PROT_WRITE);
1683 if ((wait & M_ZERO) != 0)
1684 bzero(mem, pages * PAGE_SIZE);
1685
1686 return (mem);
1687}
1688
1689static void
1690startup_free(void *mem, vm_size_t bytes)

Callers 1

uma_startup1Function · 0.85

Calls 6

malloc2vm_flagsFunction · 0.85
dump_add_pageFunction · 0.85
bzeroFunction · 0.85
page_allocFunction · 0.85
pmap_mapFunction · 0.50

Tested by

no test coverage detected