next up previous contents index
Next: 10.9.8 ptab_free: free a Up: (X86) Base Environment: Page Previous: 10.9.6 pdir_get_pte: retrieve the

10.9.7 ptab_alloc: allocate a page table page and clear it to zero

   

SYNOPSIS

#include <oskit/x86/base_paging.h>

int ptab_alloc([out] oskit_addr_t *out_ptab_pa);

DESCRIPTION

All of the following page mapping routines call this function to allocate new page tables as needed to create page mappings. It attempts to allocate a single page of physical memory, and if successful, returns 0 with the physical address of that page in *out_ptab_pa. The newly allocated page is cleared to all zeros by this function. If this function is unsuccessful, it returns nonzero.

The default implementation of this function assumes that the OSKit's minimal C library (libc) and list-based memory manager (liblmm) are being used to manage physical memory, and allocates page table pages from the malloc_lmm memory pool (see Section 9.5.1). However, in more complete OS environments, e.g., in which low physical memory conditions should trigger a page-out rather than failing immediately, this routine can be overridden to provide the desired behavior.

PARAMETERS

out_ptab_pa
The address of a variable of type oskit_addr_t into which this function will deposit the physical address of the allocated page, if the allocation was successful.

RETURNS

Returns zero if the allocation was successful, or nonzero on failure.

DEPENDENCIES

lmm_alloc_page
15.6.8
malloc_lmm
9.5.1
memset
9.4.18
kvtophys
10.6.2



University of Utah Flux Research Group