/** * io_map * * Maps an IO region and returns its virtual address. */ vm_offset_t io_map(vm_offset_t phys_addr, vm_size_t size, unsigned int flags) { vm_offset_t start; if (kernel_map == VM_MAP_NULL) { /* * VM is not initialized. Grab memory. */ start = virt_begin; virt_begin += round_page(size); (void) pmap_map_bd(start, phys_addr, phys_addr + round_page(size), VM_PROT_READ|VM_PROT_WRITE, flags); } else { (void) kmem_alloc_pageable(kernel_map, &start, round_page(size)); (void) pmap_map(start, phys_addr, phys_addr + round_page(size), VM_PROT_READ|VM_PROT_WRITE, flags); } return (start); }
/* * Allocate and map memory for devices that may need to be mapped before * Mach VM is running. */ vm_offset_t io_map( vm_offset_t phys_addr, vm_size_t size) { vm_offset_t start; if (kernel_map == VM_MAP_NULL) { /* * VM is not initialized. Grab memory. */ start = kernel_virtual_start; kernel_virtual_start += round_page(size); printf("stealing kernel virtual addresses %08lx-%08lx\n", start, kernel_virtual_start); } else { (void) kmem_alloc_pageable(kernel_map, &start, round_page(size)); } (void) pmap_map_bd(start, phys_addr, phys_addr + round_page(size), VM_PROT_READ|VM_PROT_WRITE); return (start); }