next up previous contents index
Next: 10.9.10 pdir_unmap_page: unmap a Up: (X86) Base Environment: Page Previous: 10.9.8 ptab_free: free a

10.9.9 pdir_map_page: map a 4KB page into a linear address space

   

SYNOPSIS

#include <oskit/x86/base_paging.h>

int pdir_map_page(oskit_addr_t pdir_pa, oskit_addr_t la, pt_entry_t mapping);

DESCRIPTION

This function creates a single 4KB page mapping in the linear address space represented by the specified page directory. If the page table covering the specified linear address does not exist (i.e., the selected page directory entry is invalid), then a new page table is allocated using ptab_alloc and inserted into the page directory before the actual page mapping is inserted into the page table. 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 specified mapping value, which is inserted into the selected page table entry, may restrict permissions at the individual page granularity.

This function assumes that if the page directory entry selected by bits 22-31 of la is valid (the INTEL_PDE_VALID bit is set), then that entry actually refers to a page table, and is not a 4MB page mapping. In other words, the caller should not attempt to create a 4KB page mapping in a part of the linear address space already covered by a valid 4MB superpage mapping. The caller must first unmap the 4MB superpage mapping, then map the 4KB page (which will cause a page table to be allocated). If the caller follows the guidelines described in Section 10.9, 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 page mapping.
la
Linear address at which to make the mapping. Only bits 12-31 are relevant to this function; bits 0-11 are ignored.
mapping
Contains the page table entry value to insert into the appropriate page table entry: the page frame number is in bits 12-31, and the INTEL_PTE_* flags are in bits 0-11. XXX The caller must include INTEL_PTE_VALID; other flags may be set according to the desired behavior. (To unmap pages, use pdir_unmap_page instead; see Section 10.9.10)

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


next up previous contents index
Next: 10.9.10 pdir_unmap_page: unmap a Up: (X86) Base Environment: Page Previous: 10.9.8 ptab_free: free a

University of Utah Flux Research Group