FreeBSD/sys/arm/arm/pmap-v6.c
/*
 *  Used to map a range of physical addresses into kernel
 *  virtual address space.
 *
 *  The value passed in '*virt' is a suggested virtual address for
 *  the mapping. Architectures which can support a direct-mapped
 *  physical to virtual region can return the appropriate address
 *  within that region, leaving '*virt' unchanged. Other
 *  architectures should map the pages starting at '*virt' and
 *  update '*virt' with the first usable address after the mapped
 *  region.
 *
 *  NOTE: Read the comments above pmap_kenter_prot_attr() as
 *        the function is used herein!
 */
Used to map a range of physical addresses into kernel
virtual address space.

The value passed in '*virt' is a suggested virtual address for
the mapping. Architectures which can support a direct-mapped
physical to virtual region can return the appropriate address
within that region, leaving '*virt' unchanged. Other
architectures should map the pages starting at '*virt' and
update '*virt' with the first usable address after the mapped
region.

Read the comments above pmap_kenter_prot_attr() as
the function is used herein!
Used to map a range of physical addresses into kernel virtual address space . The value passed in ' * virt ' is a suggested virtual address for the mapping . Architectures which can support a direct - mapped physical to virtual region can return the appropriate address within that region leaving ' * virt ' unchanged . Other architectures should map the pages starting at ' * virt ' and update ' * virt ' with the first usable address after the mapped region . Read the comments above pmap_kenter_prot_attr () as the function is used herein!
vm_offset_t
pmap_map(vm_offset_t *virt, vm_paddr_t start, vm_paddr_t end, int prot)
{
	vm_offset_t va, sva;
	vm_paddr_t pte1_offset;
	pt1_entry_t npte1;
	uint32_t l1prot, l2prot;
	uint32_t l1attr, l2attr;
	PDEBUG(1, printf("%s: virt = %#x, start = %#x, end = %#x (size = %#x),"
	    " prot = %d\n", __func__, *virt, start, end, end - start,  prot));
	l2prot = (prot & VM_PROT_WRITE) ? PTE2_AP_KRW : PTE2_AP_KR;
	l2prot |= (prot & VM_PROT_EXECUTE) ? PTE2_X : PTE2_NX;
	l1prot = ATTR_TO_L1(l2prot);
	l2attr = PTE2_ATTR_DEFAULT;
	l1attr = ATTR_TO_L1(l2attr);
	va = *virt;
	pte1_offset = start & PTE1_OFFSET;
	if ((end - start) - ((PTE1_SIZE - pte1_offset) & PTE1_OFFSET) >=
	    PTE1_SIZE) {
		if ((va & PTE1_OFFSET) < pte1_offset)
			va = pte1_trunc(va) + pte1_offset;
		else if ((va & PTE1_OFFSET) > pte1_offset)
			va = pte1_roundup(va) + pte1_offset;
	}
	sva = va;
	while (start < end) {
		if ((start & PTE1_OFFSET) == 0 && end - start >= PTE1_SIZE) {
			KASSERT((va & PTE1_OFFSET) == 0,
			    ("%s: misaligned va %#x", __func__, va));
			npte1 = PTE1_KERN(start, l1prot, l1attr);
			pmap_kenter_pte1(va, npte1);
			va += PTE1_SIZE;
			start += PTE1_SIZE;
		} else {
			pmap_kenter_prot_attr(va, start, l2prot, l2attr);
			va += PAGE_SIZE;
			start += PAGE_SIZE;
		}
	}
	tlb_flush_range(sva, va - sva);
	*virt = va;
	return (sva);
}
vm_offset_t pmap_map ( vm_offset_t * virt , vm_paddr_t start , vm_paddr_t end , int prot ) { vm_offset_t va , sva ; vm_paddr_t pte1_offset ; pt1_entry_t npte1 ; uint32_t l1prot , l2prot ; uint32_t l1attr , l2attr ; PDEBUG ( 1 , printf ( " " " \n " , __func__ , * virt , start , end , end - start , prot ) ) ; l2prot = ( prot & VM_PROT_WRITE ) ? PTE2_AP_KRW : PTE2_AP_KR ; l2prot |= ( prot & VM_PROT_EXECUTE ) ? PTE2_X : PTE2_NX ; l1prot = ATTR_TO_L1 ( l2prot ) ; l2attr = PTE2_ATTR_DEFAULT ; l1attr = ATTR_TO_L1 ( l2attr ) ; va = * virt ; pte1_offset = start & PTE1_OFFSET ; if ( ( end - start ) - ( ( PTE1_SIZE - pte1_offset ) & PTE1_OFFSET ) >= PTE1_SIZE ) { if ( ( va & PTE1_OFFSET ) < pte1_offset ) va = pte1_trunc ( va ) + pte1_offset ; else if ( ( va & PTE1_OFFSET ) > pte1_offset ) va = pte1_roundup ( va ) + pte1_offset ; } sva = va ; while ( start < end ) { if ( ( start & PTE1_OFFSET ) == 0 && end - start >= PTE1_SIZE ) { KASSERT ( ( va & PTE1_OFFSET ) == 0 , ( " " , __func__ , va ) ) ; npte1 = PTE1_KERN ( start , l1prot , l1attr ) ; pmap_kenter_pte1 ( va , npte1 ) ; va += PTE1_SIZE ; start += PTE1_SIZE ; } else { pmap_kenter_prot_attr ( va , start , l2prot , l2attr ) ; va += PAGE_SIZE ; start += PAGE_SIZE ; } } tlb_flush_range ( sva , va - sva ) ; * virt = va ; return ( sva ) ; }
Used to map a range of physical addresses into kernel
  virtual address space.
Used to map a range of physical addresses into kernel virtual address space .
/*
	 * Does the physical address range's size and alignment permit at
	 * least one section mapping to be created?
	 */ /*
		 * Increase the starting virtual address so that its alignment
		 * does not preclude the use of section mappings.
		 */