next up previous contents index
Next: 10.9.12 pdir_prot_range: change the Up: (X86) Base Environment: Page Previous: 10.9.10 pdir_unmap_page: unmap a

10.9.11 pdir_map_range: map a contiguous range of physical addresses

   

SYNOPSIS

#include <oskit/x86/base_paging.h>

int pdir_map_range(oskit_addr_t pdir_pa, oskit_addr_t la, oskit_addr_t pa, oskit_size_t size, pt_entry_t mapping_bits);

DESCRIPTION

This function maps a range of linear addresses in the linear address space represented by the specified page directory onto a contiguous range of physical addresses. The linear (source) address, physical (destination) address, and mapping size must be multiples of the 4KB architectural page size, but other than that no restrictions are imposed on the location or size of the mapping range. If the processor description in the global base_cpuid variable (see Section 10.6.6) indicates that page size extensions are available, and the physical and linear addresses are properly aligned, then this function maps as much of the range as possible using 4MB superpage mappings instead of 4KB page mappings. Where 4KB page mappings are needed, this function allocates new page tables as necessary using ptab_alloc. Any new page tables created by this function are mapped into the page directory with permissions INTEL_PTE_USER | INTEL_PTE_WRITE: full permissions are granted at the page directory level, although the mapping_bits may specify more restricted permissions for the actual page mappings.

This function assumes that no valid mappings already exist in the specified linear address range; if any mappings do exist, this function may not work properly. If the caller follows the guidelines described in Section 10.9, always unmapping previous mappings before creating new ones, then this requirement should not be a problem.

PARAMETERS

pdir_pa
Physical address of the page directory acting as the root of the linear address space in which to make the requested mapping.
la
Starting linear address at which to make the mapping. Must be page-aligned.
pa
Starting physical address to map to. Must be page-aligned.
size
Size of the linear-to-physical mapping to create. Must be page-aligned.
mapping_bits
Permission bits to OR into each page or superpage mapping entry. The caller must include INTEL_PTE_VALID; other flags may be set according to the desired behavior. (To unmap ranges, use pdir_unmap_range instead; see Section 10.9.13)

RETURNS

If all goes well and the mapping is successful, this function returns zero. If this function needed to allocate a new page table but the ptab_alloc function failed (returned nonzero), then this function passes back the return value from ptab_alloc.

DEPENDENCIES

pdir_find_pde
10.9.3
ptab_find_pte
10.9.4
ptab_alloc
10.9.7
base_cpuid
10.6.6


next up previous contents index
Next: 10.9.12 pdir_prot_range: change the Up: (X86) Base Environment: Page Previous: 10.9.10 pdir_unmap_page: unmap a

University of Utah Flux Research Group