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

Function pmap_mapdev_attr

freebsd/mips/mips/pmap.c:3217–3245  ·  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 * routine is intended to be used for mapping device memory, * NOT real memory. * * Use XKPHYS uncached for 64 bit, and KSEG1 where possible for 32 bit. */

Source from the content-addressed store, hash-verified

3215 * Use XKPHYS uncached for 64 bit, and KSEG1 where possible for 32 bit.
3216 */
3217void *
3218pmap_mapdev_attr(vm_paddr_t pa, vm_size_t size, vm_memattr_t ma)
3219{
3220 vm_offset_t va, tmpva, offset;
3221
3222 /*
3223 * KSEG1 maps only first 512M of phys address space. For
3224 * pa > 0x20000000 we should make proper mapping * using pmap_kenter.
3225 */
3226 if (MIPS_DIRECT_MAPPABLE(pa + size - 1) && ma == VM_MEMATTR_UNCACHEABLE)
3227 return ((void *)MIPS_PHYS_TO_DIRECT_UNCACHED(pa));
3228 else {
3229 offset = pa & PAGE_MASK;
3230 size = roundup(size + offset, PAGE_SIZE);
3231
3232 va = kva_alloc(size);
3233 if (!va)
3234 panic("pmap_mapdev: Couldn't alloc kernel virtual memory");
3235 pa = trunc_page(pa);
3236 for (tmpva = va; size > 0;) {
3237 pmap_kenter_attr(tmpva, pa, ma);
3238 size -= PAGE_SIZE;
3239 tmpva += PAGE_SIZE;
3240 pa += PAGE_SIZE;
3241 }
3242 }
3243
3244 return ((void *)(va + offset));
3245}
3246
3247void *
3248pmap_mapdev(vm_paddr_t pa, vm_size_t size)

Callers 2

pmap_mapdevFunction · 0.70
nexus_map_resourceFunction · 0.50

Calls 3

kva_allocFunction · 0.85
pmap_kenter_attrFunction · 0.70
panicFunction · 0.50

Tested by

no test coverage detected