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

Function pmap_mapdev

freebsd/kern/subr_devmap.c:262–291  ·  view source on GitHub ↗

* Map a set of physical memory pages into the kernel virtual address space. * Return a pointer to where it is mapped. * * This uses a pre-established static mapping if one exists for the requested * range, otherwise it allocates kva space and maps the physical pages into it. * * This routine is intended to be used for mapping device memory, NOT real * memory; the mapping type is inherently

Source from the content-addressed store, hash-verified

260 * pmap_kenter_device().
261 */
262void *
263pmap_mapdev(vm_offset_t pa, vm_size_t size)
264{
265 vm_offset_t va, offset;
266 void * rva;
267
268 /* First look in the static mapping table. */
269 if ((rva = devmap_ptov(pa, size)) != NULL)
270 return (rva);
271
272 offset = pa & PAGE_MASK;
273 pa = trunc_page(pa);
274 size = round_page(size + offset);
275
276#if defined(__aarch64__) || defined(__riscv)
277 if (early_boot) {
278 akva_devmap_vaddr = trunc_page(akva_devmap_vaddr - size);
279 va = akva_devmap_vaddr;
280 KASSERT(va >= VM_MAX_KERNEL_ADDRESS - PMAP_MAPDEV_EARLY_SIZE,
281 ("Too many early devmap mappings"));
282 } else
283#endif
284 va = kva_alloc(size);
285 if (!va)
286 panic("pmap_mapdev: Couldn't alloc kernel virtual memory");
287
288 pmap_kenter_device(va, size, pa);
289
290 return ((void *)(va + offset));
291}
292
293#if defined(__aarch64__)
294void *

Callers

nothing calls this directly

Calls 4

devmap_ptovFunction · 0.85
kva_allocFunction · 0.85
panicFunction · 0.70
pmap_kenter_deviceFunction · 0.50

Tested by

no test coverage detected