next up previous contents index
Next: 10.9.2 base_pdir_pa: initial kernel Up: (X86) Base Environment: Page Previous: (X86) Base Environment: Page

10.9.1 base_paging_init: create minimal kernel page tables and enable paging

   

SYNOPSIS

#include <oskit/x86/base_paging.h>

void base_paging_init(void);

DESCRIPTION

This function can be used to set up a minimal paging environment. It first allocates and clears an initial page directory using ptab_alloc (see Section 10.9.7), sets base_pdir_pa to point to it (see Section 10.9.2), then direct-maps all known physical memory into this address space starting at linear address 0, allocating additional page tables as needed. Finally, this function enables the processor's paging mechanism, using the base page directory as the initial page directory.

The global variable phys_mem_max (see Section 10.11.2) is assumed to indicate the top of physical memory; all memory from 0 up to at least this address is mapped. The function actually rounds phys_mem_max up to the next 4MB superpage boundary, so that on Pentium and higher processors, all physical memory can be mapped using 4MB superpages even if known physical memory does not end exactly on a 4MB boundary. Note that phys_mem_max does not necessarily need to reflect all physical memory in the machine; for example, it is perfectly reasonable for the client OS to set it to some artificially lower value so that only that part of physical memory is direct-mapped.

On Pentium and higher processors, this function sets the PSE (page size extensions) bit in CR4 in addition to the PG (paging) bit, so that the 4MB page mappings used to map physical memory will work properly.

DEPENDENCIES

base_pdir_pa
10.9.2
ptab_alloc
10.9.7
pdir_map_range
10.9.11
base_cpuid
10.6.6
paging_enable
10.5.8



University of Utah Flux Research Group